conf-parse: small prettification
authorLennart Poettering <lennart@poettering.net>
Fri, 23 Feb 2018 19:50:22 +0000 (20:50 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 21 Mar 2018 19:04:16 +0000 (20:04 +0100)
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.

src/shared/conf-parser.c

index 0ac6364..483dc1a 100644 (file)
@@ -180,7 +180,7 @@ static int parse_line(
                 char *l,
                 void *userdata) {
 
-        char *e;
+        char *e, *include;
 
         assert(filename);
         assert(line > 0);
@@ -194,7 +194,8 @@ static int parse_line(
         if (strchr(COMMENTS "\n", *l))
                 return 0;
 
-        if (startswith(l, ".include ")) {
+        include = first_word(l, ".include");
+        if (include) {
                 _cleanup_free_ char *fn = NULL;
 
                 /* .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. "
                            "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)
                         return -ENOMEM;