conf-parser: accept trailing backslash at the end of the file (#8941)
This makes it behave the same whether there is a blank line or not at the end of the file. This is also consistent with the behavior of the shell on a shell script that ends on a trailing backslash at the last line. Added tests to test_config_parse(), which only pass if the corresponding change to config_parse() is included.
This commit is contained in:
committed by
Lennart Poettering
parent
3eff246a17
commit
4f29e0db12
@@ -401,6 +401,27 @@ int config_parse(const char *unit,
|
||||
continuation = mfree(continuation);
|
||||
}
|
||||
|
||||
if (continuation) {
|
||||
r = parse_line(unit,
|
||||
filename,
|
||||
++line,
|
||||
sections,
|
||||
lookup,
|
||||
table,
|
||||
flags,
|
||||
§ion,
|
||||
§ion_line,
|
||||
§ion_ignored,
|
||||
continuation,
|
||||
userdata);
|
||||
if (r < 0) {
|
||||
if (flags & CONFIG_PARSE_WARN)
|
||||
log_warning_errno(r, "%s:%u: Failed to parse file: %m", filename, line);
|
||||
return r;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user