summaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorliwugang2018-06-25 03:04:33 -0500
committerliwugang2018-06-26 00:30:54 -0500
commit332afef5f4a04920cff630f02a948d3ca2072630 (patch)
tree56be57fdc819c5b4ea63a84f417b9f6c240ad567 /init
parentfc1cf90741e59d5615a7dcea1813f38bfa3a2eec (diff)
downloadplatform-system-core-332afef5f4a04920cff630f02a948d3ca2072630.tar.gz
platform-system-core-332afef5f4a04920cff630f02a948d3ca2072630.tar.xz
platform-system-core-332afef5f4a04920cff630f02a948d3ca2072630.zip
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')
-rw-r--r--init/tokenizer.cpp5
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:
85 goto textdone; 85 goto textdone;
86 case 'n': 86 case 'n':
87 *s++ = '\n'; 87 *s++ = '\n';
88 x++;
88 break; 89 break;
89 case 'r': 90 case 'r':
90 *s++ = '\r'; 91 *s++ = '\r';
92 x++;
91 break; 93 break;
92 case 't': 94 case 't':
93 *s++ = '\t'; 95 *s++ = '\t';
96 x++;
94 break; 97 break;
95 case '\\': 98 case '\\':
96 *s++ = '\\'; 99 *s++ = '\\';
100 x++;
97 break; 101 break;
98 case '\r': 102 case '\r':
99 /* \ <cr> <lf> -> line continuation */ 103 /* \ <cr> <lf> -> line continuation */
@@ -101,6 +105,7 @@ textresume:
101 x++; 105 x++;
102 continue; 106 continue;
103 } 107 }
108 x++;
104 case '\n': 109 case '\n':
105 /* \ <lf> -> line continuation */ 110 /* \ <lf> -> line continuation */
106 state->line++; 111 state->line++;