diff options
author | liwugang <liwugang@xiaomi.com> | 2018-06-25 16:04:33 +0800 |
---|---|---|
committer | liwugang <liwugang@xiaomi.com> | 2018-06-26 13:30:54 +0800 |
commit | 332afef5f4a04920cff630f02a948d3ca2072630 (patch) | |
tree | 56be57fdc819c5b4ea63a84f417b9f6c240ad567 /init/tokenizer.cpp | |
parent | fc1cf90741e59d5615a7dcea1813f38bfa3a2eec (diff) |
init: fix the parse error when meeting escape characters
After dealing with some specical escape characters('\n','\r','\t','\\',"\r\n")
it doesn't goto the next position in the next loop, so it process the current
character twice.
For example, when parsing the string "test\ntoken" we expect the
"test'\n'token" but actually we got the "test'\n'ntoken"
Test: have espace characters in init .rc files
Change-Id: I015c087a5c6e5ee9c490f29a83b15b89443f7f81
Signed-off-by: liwugang <liwugang@xiaomi.com>
Diffstat (limited to 'init/tokenizer.cpp')
-rw-r--r-- | init/tokenizer.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/init/tokenizer.cpp b/init/tokenizer.cpp index f8d9b6be7..bb143f18a 100644 --- a/init/tokenizer.cpp +++ b/init/tokenizer.cpp @@ -85,15 +85,19 @@ textresume: goto textdone; case 'n': *s++ = '\n'; + x++; break; case 'r': *s++ = '\r'; + x++; break; case 't': *s++ = '\t'; + x++; break; case '\\': *s++ = '\\'; + x++; break; case '\r': /* \ <cr> <lf> -> line continuation */ @@ -101,6 +105,7 @@ textresume: x++; continue; } + x++; case '\n': /* \ <lf> -> line continuation */ state->line++; |