tree-wide: port various parsers over to read_stripped_line()
This commit is contained in:
@@ -450,9 +450,8 @@ static int load_sysv(SysvStub *s) {
|
||||
|
||||
for (;;) {
|
||||
_cleanup_free_ char *l = NULL;
|
||||
char *t;
|
||||
|
||||
r = read_line(f, LONG_LINE_MAX, &l);
|
||||
r = read_stripped_line(f, LONG_LINE_MAX, &l);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to read configuration file '%s': %m", s->path);
|
||||
if (r == 0)
|
||||
@@ -460,17 +459,16 @@ static int load_sysv(SysvStub *s) {
|
||||
|
||||
line++;
|
||||
|
||||
t = strstrip(l);
|
||||
if (*t != '#') {
|
||||
if (l[0] != '#') {
|
||||
/* Try to figure out whether this init script supports
|
||||
* the reload operation. This heuristic looks for
|
||||
* "Usage" lines which include the reload option. */
|
||||
if (state == USAGE_CONTINUATION ||
|
||||
(state == NORMAL && strcasestr(t, "usage"))) {
|
||||
if (usage_contains_reload(t)) {
|
||||
(state == NORMAL && strcasestr(l, "usage"))) {
|
||||
if (usage_contains_reload(l)) {
|
||||
supports_reload = true;
|
||||
state = NORMAL;
|
||||
} else if (t[strlen(t)-1] == '\\')
|
||||
} else if (endswith(l, "\\"))
|
||||
state = USAGE_CONTINUATION;
|
||||
else
|
||||
state = NORMAL;
|
||||
@@ -479,18 +477,18 @@ static int load_sysv(SysvStub *s) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (state == NORMAL && streq(t, "### BEGIN INIT INFO")) {
|
||||
if (state == NORMAL && streq(l, "### BEGIN INIT INFO")) {
|
||||
state = LSB;
|
||||
s->has_lsb = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IN_SET(state, LSB_DESCRIPTION, LSB) && streq(t, "### END INIT INFO")) {
|
||||
if (IN_SET(state, LSB_DESCRIPTION, LSB) && streq(l, "### END INIT INFO")) {
|
||||
state = NORMAL;
|
||||
continue;
|
||||
}
|
||||
|
||||
t++;
|
||||
char *t = l + 1;
|
||||
t += strspn(t, WHITESPACE);
|
||||
|
||||
if (state == NORMAL) {
|
||||
|
||||
Reference in New Issue
Block a user