From 332afef5f4a04920cff630f02a948d3ca2072630 Mon Sep 17 00:00:00 2001 From: liwugang Date: Mon, 25 Jun 2018 16:04:33 +0800 Subject: [PATCH] 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 --- init/tokenizer.cpp | 5 +++++ 1 file changed, 5 insertions(+) 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': /* \ -> line continuation */ @@ -101,6 +105,7 @@ textresume: x++; continue; } + x++; case '\n': /* \ -> line continuation */ state->line++;