summaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorJean-Baptiste Queru <jbq@google.com>2011-01-07 15:34:03 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2011-01-07 15:34:03 -0800
commitf5cb0a138528144f3bb1cf6bbcb3c4e4ad5e9dc9 (patch)
tree36b86d8244d4aafb1622bbb2eb03af96a2daa383 /init
parentbf10797e538f9fa252d72710bd5ecf0ef1f6f3e0 (diff)
parentfc0b4ff1c8675be3626510a5adfbcae507ecfa43 (diff)
downloadcore-f5cb0a138528144f3bb1cf6bbcb3c4e4ad5e9dc9.tar.gz
core-f5cb0a138528144f3bb1cf6bbcb3c4e4ad5e9dc9.tar.bz2
core-f5cb0a138528144f3bb1cf6bbcb3c4e4ad5e9dc9.zip
am fc0b4ff1: Merge "init: Fix parser line numbering"
* commit 'fc0b4ff1c8675be3626510a5adfbcae507ecfa43': init: Fix parser line numbering
Diffstat (limited to 'init')
-rw-r--r--init/init_parser.c3
-rw-r--r--init/parser.c11
2 files changed, 9 insertions, 5 deletions
diff --git a/init/init_parser.c b/init/init_parser.c
index d136c28a0..fafd732c5 100644
--- a/init/init_parser.c
+++ b/init/init_parser.c
@@ -187,7 +187,7 @@ static void parse_config(const char *fn, char *s)
nargs = 0;
state.filename = fn;
- state.line = 1;
+ state.line = 0;
state.ptr = s;
state.nexttoken = 0;
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);
return;
case T_NEWLINE:
+ state.line++;
if (nargs) {
int kw = lookup_keyword(args[0]);
if (kw_is(kw, SECTION)) {
diff --git a/init/parser.c b/init/parser.c
index 2f36ac76a..3c2ec00b4 100644
--- a/init/parser.c
+++ b/init/parser.c
@@ -83,7 +83,6 @@ int next_token(struct parse_state *state)
state->ptr = x;
return T_EOF;
case '\n':
- state->line++;
x++;
state->ptr = x;
return T_NEWLINE;
@@ -94,9 +93,13 @@ int next_token(struct parse_state *state)
continue;
case '#':
while (*x && (*x != '\n')) x++;
- state->line++;
- state->ptr = x;
- return T_NEWLINE;
+ if (*x == '\n') {
+ state->ptr = x+1;
+ return T_NEWLINE;
+ } else {
+ state->ptr = x;
+ return T_EOF;
+ }
default:
goto text;
}