diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-11-08 21:38:51 +0100 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-11-08 21:38:51 +0100 |
commit | f3d32ccc5e78e7f40538a8e3672b449148beb343 (patch) | |
tree | 2ed8b3f6213ce0c067d5dd5006531aada8226744 /src | |
parent | 098560201cc4ab7cce25f5c820d2ff6618f7c9dc (diff) |
conf-parser: simplify things a bit by using strextend()
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/conf-parser.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 0735901e3..b95cd0fd5 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -190,7 +190,6 @@ static int parse_line(const char* unit, assert(l); l = strstrip(l); - if (!*l) return 0; @@ -323,8 +322,8 @@ int config_parse(const char *unit, for (;;) { _cleanup_free_ char *buf = NULL; - char *l, *p, *c = NULL, *e; bool escaped = false; + char *l, *p, *e; r = read_line(f, LONG_LINE_MAX, &buf); if (r == 0) @@ -360,15 +359,13 @@ int config_parse(const char *unit, return -ENOBUFS; } - c = strappend(continuation, l); - if (!c) { + if (!strextend(&continuation, l, NULL)) { if (warn) log_oom(); return -ENOMEM; } - continuation = mfree(continuation); - p = c; + p = continuation; } else p = l; @@ -382,9 +379,7 @@ int config_parse(const char *unit, if (escaped) { *(e-1) = ' '; - if (c) - continuation = c; - else { + if (!continuation) { continuation = strdup(l); if (!continuation) { if (warn) @@ -409,13 +404,14 @@ int config_parse(const char *unit, §ion_ignored, p, userdata); - free(c); - if (r < 0) { if (warn) log_warning_errno(r, "%s:%u: Failed to parse file: %m", filename, line); return r; + } + + continuation = mfree(continuation); } return 0; |