Commit d3e4a68f authored by Masahiro Yamada's avatar Masahiro Yamada

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: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent fe273c6f
...@@ -274,25 +274,18 @@ repeat: ...@@ -274,25 +274,18 @@ repeat:
token = yylex1(); token = yylex1();
if (prev_token == T_EOL || prev_token == T_HELPTEXT) { 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. */ /* Do not pass unneeded T_EOL to the parser. */
goto repeat; 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 * of each statement. Generally, \n is a statement
* terminator in Kconfig, but it is not always true * terminator in Kconfig, but it is not always true
* because \n could be escaped by a backslash. * 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; cur_lineno = yylineno;
} }
}
if (prev_prev_token == T_EOL && prev_token == T_WORD && if (prev_prev_token == T_EOL && prev_token == T_WORD &&
(token == T_EQUAL || token == T_COLON_EQUAL || token == T_PLUS_EQUAL)) (token == T_EQUAL || token == T_COLON_EQUAL || token == T_PLUS_EQUAL))
...@@ -407,6 +400,7 @@ void zconf_initscan(const char *name) ...@@ -407,6 +400,7 @@ void zconf_initscan(const char *name)
} }
current_file = file_lookup(name); current_file = file_lookup(name);
cur_filename = current_file->name;
yylineno = 1; yylineno = 1;
} }
...@@ -448,6 +442,7 @@ void zconf_nextfile(const char *name) ...@@ -448,6 +442,7 @@ void zconf_nextfile(const char *name)
} }
yylineno = 1; yylineno = 1;
cur_filename = file->name;
current_file = file; current_file = file;
} }
...@@ -456,6 +451,8 @@ static void zconf_endfile(void) ...@@ -456,6 +451,8 @@ static void zconf_endfile(void)
struct buffer *tmp; struct buffer *tmp;
current_file = current_file->parent; current_file = current_file->parent;
if (current_file)
cur_filename = current_file->name;
if (!current_buf) if (!current_buf)
return; return;
......
...@@ -488,6 +488,14 @@ void conf_parse(const char *name) ...@@ -488,6 +488,14 @@ void conf_parse(const char *name)
yydebug = 1; yydebug = 1;
yyparse(); 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, str_printf(&autoconf_cmd,
"\n" "\n"
"$(autoconfig): $(deps_config)\n" "$(autoconfig): $(deps_config)\n"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment