Skip to content

Commit

Permalink
kconfig: rename a variable in the lexer to a clearer name
Browse files Browse the repository at this point in the history
In Kconfig, like Python, you can enclose a string by double-quotes or
single-quotes. So, both "foo" and 'foo' are allowed.

The variable, "str", is used to remember whether the string started with
a double-quote or a single-quote because open/closing quotation marks
must match.

The name "str" is too generic to understand the intent. Rename it to
"open_quote", which is easier to understand. The type should be 'char'.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Boris Kolpackov <boris@codesynthesis.com>
  • Loading branch information
masahir0y committed Sep 29, 2021
1 parent 65017d8 commit 6988f70
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scripts/kconfig/lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ static void warn_ignored_character(char chr)
n [A-Za-z0-9_-]

%%
int str = 0;
char open_quote = 0;

#.* /* ignore comment */
[ \t]* /* whitespaces */
Expand Down Expand Up @@ -133,7 +133,7 @@ n [A-Za-z0-9_-]
":=" return T_COLON_EQUAL;
"+=" return T_PLUS_EQUAL;
\"|\' {
str = yytext[0];
open_quote = yytext[0];
new_string();
BEGIN(STRING);
}
Expand Down Expand Up @@ -170,7 +170,7 @@ n [A-Za-z0-9_-]
append_string(yytext + 1, yyleng - 1);
}
\'|\" {
if (str == yytext[0]) {
if (open_quote == yytext[0]) {
BEGIN(INITIAL);
yylval.string = text;
return T_WORD_QUOTE;
Expand Down

0 comments on commit 6988f70

Please sign in to comment.