conf-parse: small prettification
Let's use first_word() instead of startswith(), it's more explanatory and a bit more correct. Also, let's use the return value instead of adding +9 when looking for the second part of the directive.
This commit is contained in:
@@ -180,7 +180,7 @@ static int parse_line(
|
|||||||
char *l,
|
char *l,
|
||||||
void *userdata) {
|
void *userdata) {
|
||||||
|
|
||||||
char *e;
|
char *e, *include;
|
||||||
|
|
||||||
assert(filename);
|
assert(filename);
|
||||||
assert(line > 0);
|
assert(line > 0);
|
||||||
@@ -194,7 +194,8 @@ static int parse_line(
|
|||||||
if (strchr(COMMENTS "\n", *l))
|
if (strchr(COMMENTS "\n", *l))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (startswith(l, ".include ")) {
|
include = first_word(l, ".include");
|
||||||
|
if (include) {
|
||||||
_cleanup_free_ char *fn = NULL;
|
_cleanup_free_ char *fn = NULL;
|
||||||
|
|
||||||
/* .includes are a bad idea, we only support them here
|
/* .includes are a bad idea, we only support them here
|
||||||
@@ -215,7 +216,7 @@ static int parse_line(
|
|||||||
".include directives are deprecated, and support for them will be removed in a future version of systemd. "
|
".include directives are deprecated, and support for them will be removed in a future version of systemd. "
|
||||||
"Please use drop-in files instead.");
|
"Please use drop-in files instead.");
|
||||||
|
|
||||||
fn = file_in_same_dir(filename, strstrip(l+9));
|
fn = file_in_same_dir(filename, strstrip(include));
|
||||||
if (!fn)
|
if (!fn)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user