summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2018-12-11 20:00:48 +0900
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-12-13 00:16:24 +0900
commit21c5ecf60472be9f1b5bfe0b94870bef93db4202 (patch)
treee61a38ee50c5fa7fdd226bdf4fa5fdf1db15b36b
parentbe3c8075978a420b6eae944250bf336aa11d4964 (diff)
downloadlinux-21c5ecf60472be9f1b5bfe0b94870bef93db4202.tar.bz2
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 <yamada.masahiro@socionext.com>
-rw-r--r--scripts/kconfig/zconf.l14
1 files changed, 3 insertions, 11 deletions
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
index 709b774f2404..b7bc164fdf00 100644
--- a/scripts/kconfig/zconf.l
+++ b/scripts/kconfig/zconf.l
@@ -182,19 +182,9 @@ n [A-Za-z0-9_-]
<STRING>{
"$".* 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;
}
<<EOF>> {
BEGIN(INITIAL);