summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMasahiro Yamada <masahiroy@kernel.org>2024-02-03 00:58:12 +0900
committerMasahiro Yamada <masahiroy@kernel.org>2024-02-19 18:20:40 +0900
commitd3e4a68fe20f3c05de77f5e300e3d76a9f68d942 (patch)
tree14a47f85673b753e3ec3f40c248c740780d62f19
parentfe273c6fc318da07bdbb42d26d8e6e150aa947af (diff)
kconfig: do not delay the cur_filename update
Currently, cur_filename is updated at the first token of each statement. However, this seems unnecessary based on my understanding; the parser can use the same variable as the lexer tracks. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
-rw-r--r--scripts/kconfig/lexer.l17
-rw-r--r--scripts/kconfig/parser.y8
2 files changed, 15 insertions, 10 deletions
diff --git a/scripts/kconfig/lexer.l b/scripts/kconfig/lexer.l
index 35ad1b256470..28e279cd5a22 100644
--- a/scripts/kconfig/lexer.l
+++ b/scripts/kconfig/lexer.l
@@ -274,24 +274,17 @@ repeat:
token = yylex1();
if (prev_token == T_EOL || prev_token == T_HELPTEXT) {
- if (token == T_EOL) {
+ if (token == T_EOL)
/* Do not pass unneeded T_EOL to the parser. */
goto repeat;
- } else {
+ else
/*
- * For the parser, update file/lineno at the first token
+ * For the parser, update lineno at the first token
* of each statement. Generally, \n is a statement
* terminator in Kconfig, but it is not always true
* because \n could be escaped by a backslash.
- *
- * FIXME:
- * cur_filename and cur_lineno are used even after
- * yyparse(); menu_finalize() calls menu_add_symbol().
- * This should be fixed.
*/
- cur_filename = current_file ? current_file->name : "<none>";
cur_lineno = yylineno;
- }
}
if (prev_prev_token == T_EOL && prev_token == T_WORD &&
@@ -407,6 +400,7 @@ void zconf_initscan(const char *name)
}
current_file = file_lookup(name);
+ cur_filename = current_file->name;
yylineno = 1;
}
@@ -448,6 +442,7 @@ void zconf_nextfile(const char *name)
}
yylineno = 1;
+ cur_filename = file->name;
current_file = file;
}
@@ -456,6 +451,8 @@ static void zconf_endfile(void)
struct buffer *tmp;
current_file = current_file->parent;
+ if (current_file)
+ cur_filename = current_file->name;
if (!current_buf)
return;
diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y
index d1d05c8cd89d..e58c24d2e5ab 100644
--- a/scripts/kconfig/parser.y
+++ b/scripts/kconfig/parser.y
@@ -488,6 +488,14 @@ void conf_parse(const char *name)
yydebug = 1;
yyparse();
+ /*
+ * FIXME:
+ * cur_filename and cur_lineno are used even after yyparse();
+ * menu_finalize() calls menu_add_symbol(). This should be fixed.
+ */
+ cur_filename = "<none>";
+ cur_lineno = 0;
+
str_printf(&autoconf_cmd,
"\n"
"$(autoconfig): $(deps_config)\n"