Merge "init: Fix parser line numbering"
This commit is contained in:
commit
fc0b4ff1c8
2 changed files with 9 additions and 5 deletions
|
|
@ -187,7 +187,7 @@ static void parse_config(const char *fn, char *s)
|
||||||
|
|
||||||
nargs = 0;
|
nargs = 0;
|
||||||
state.filename = fn;
|
state.filename = fn;
|
||||||
state.line = 1;
|
state.line = 0;
|
||||||
state.ptr = s;
|
state.ptr = s;
|
||||||
state.nexttoken = 0;
|
state.nexttoken = 0;
|
||||||
state.parse_line = parse_line_no_op;
|
state.parse_line = parse_line_no_op;
|
||||||
|
|
@ -197,6 +197,7 @@ static void parse_config(const char *fn, char *s)
|
||||||
state.parse_line(&state, 0, 0);
|
state.parse_line(&state, 0, 0);
|
||||||
return;
|
return;
|
||||||
case T_NEWLINE:
|
case T_NEWLINE:
|
||||||
|
state.line++;
|
||||||
if (nargs) {
|
if (nargs) {
|
||||||
int kw = lookup_keyword(args[0]);
|
int kw = lookup_keyword(args[0]);
|
||||||
if (kw_is(kw, SECTION)) {
|
if (kw_is(kw, SECTION)) {
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,6 @@ int next_token(struct parse_state *state)
|
||||||
state->ptr = x;
|
state->ptr = x;
|
||||||
return T_EOF;
|
return T_EOF;
|
||||||
case '\n':
|
case '\n':
|
||||||
state->line++;
|
|
||||||
x++;
|
x++;
|
||||||
state->ptr = x;
|
state->ptr = x;
|
||||||
return T_NEWLINE;
|
return T_NEWLINE;
|
||||||
|
|
@ -94,9 +93,13 @@ int next_token(struct parse_state *state)
|
||||||
continue;
|
continue;
|
||||||
case '#':
|
case '#':
|
||||||
while (*x && (*x != '\n')) x++;
|
while (*x && (*x != '\n')) x++;
|
||||||
state->line++;
|
if (*x == '\n') {
|
||||||
state->ptr = x;
|
state->ptr = x+1;
|
||||||
return T_NEWLINE;
|
return T_NEWLINE;
|
||||||
|
} else {
|
||||||
|
state->ptr = x;
|
||||||
|
return T_EOF;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
goto text;
|
goto text;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue