From: Masahiro Yamada Date: Tue, 11 Dec 2018 11:00:48 +0000 (+0900) Subject: kconfig: refactor pattern matching in STRING state X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=cc43c9e39b766069cad56a27764a283e10171d90;p=carl9170fw.git kconfig: refactor pattern matching in STRING state Here, similar matching patters are duplicated in order to look ahead the '\n' character. If the next character is '\n', the lexer returns T_WORD_QUOTE because it must be prepared to return T_EOL at the next match. Use unput('\n') trick to reduce the code duplication. Signed-off-by: Masahiro Yamada Signed-off-by: Christian Lamparter --- diff --git a/config/zconf.l b/config/zconf.l index 289813d..323fb55 100644 --- a/config/zconf.l +++ b/config/zconf.l @@ -182,19 +182,9 @@ n [A-Za-z0-9_-] { "$".* append_expanded_string(yytext); - [^$'"\\\n]+/\n { - append_string(yytext, yyleng); - yylval.string = text; - return T_WORD_QUOTE; - } [^$'"\\\n]+ { append_string(yytext, yyleng); } - \\.?/\n { - append_string(yytext + 1, yyleng - 1); - yylval.string = text; - return T_WORD_QUOTE; - } \\.? { append_string(yytext + 1, yyleng - 1); } @@ -210,8 +200,10 @@ n [A-Za-z0-9_-] fprintf(stderr, "%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); + unput('\n'); BEGIN(INITIAL); - return T_EOL; + yylval.string = text; + return T_WORD_QUOTE; } <> { BEGIN(INITIAL);