1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 00:51:24 +03:00

conf-parser: simplify things a bit by using strextend()

This commit is contained in:
Lennart Poettering 2017-11-08 21:38:51 +01:00
parent 57d6f70019
commit 92b5e60542

View File

@ -186,7 +186,6 @@ static int parse_line(const char* unit,
assert(l);
l = strstrip(l);
if (!*l)
return 0;
@ -319,8 +318,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)
@ -356,15 +355,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;
@ -378,9 +375,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)
@ -405,13 +400,14 @@ int config_parse(const char *unit,
&section_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;