chiark / gitweb /
conf-parse: small prettification
authorLennart Poettering <lennart@poettering.net>
Fri, 23 Feb 2018 19:50:22 +0000 (20:50 +0100)
committerSven Eden <yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000 (16:47 +0200)
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 8a88820a1f18f59cee6534e3db4871ac5977a373..c7b453e8d0aebf51a47c7d529685a634079eaa9e 100644 (file)
@@ -184,7 +184,7 @@ static int parse_line(
                 char *l,
                 void *userdata) {
 
-        char *e;
+        char *e, *include;
 
         assert(filename);
         assert(line > 0);
@@ -198,7 +198,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
@@ -219,7 +220,7 @@ static int parse_line(
                            ".include directives are deprecated, and support for them will be removed in a future version of elogind. "
                            "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;