Commit 1d7c4f10 authored by Masahiro Yamada's avatar Masahiro Yamada

kconfig: remove zconf_curname() and zconf_lineno()

Now zconf_curname() and zconf_lineno() are so simple that they just
return cur_filename, cur_lineno, respectively.

Remove these functions, and then use cur_filename and cur_lineno
directly.
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent 52907c07
...@@ -6,4 +6,7 @@ struct menu; ...@@ -6,4 +6,7 @@ struct menu;
extern struct menu *current_menu, *current_entry; extern struct menu *current_menu, *current_entry;
extern const char *cur_filename;
extern int cur_lineno;
#endif /* INTERNAL_H */ #endif /* INTERNAL_H */
...@@ -23,13 +23,13 @@ ...@@ -23,13 +23,13 @@
#define START_STRSIZE 16 #define START_STRSIZE 16
/* The Kconfig file currently being parsed. */ /* The Kconfig file currently being parsed. */
static const char *cur_filename; const char *cur_filename;
/* /*
* The line number of the current statement. This does not match yylineno. * The line number of the current statement. This does not match yylineno.
* yylineno is used by the lexer, while cur_lineno is used by the parser. * yylineno is used by the lexer, while cur_lineno is used by the parser.
*/ */
static int cur_lineno; int cur_lineno;
static int prev_prev_token = T_EOL; static int prev_prev_token = T_EOL;
static int prev_token = T_EOL; static int prev_token = T_EOL;
...@@ -187,7 +187,7 @@ n [A-Za-z0-9_-] ...@@ -187,7 +187,7 @@ n [A-Za-z0-9_-]
\n { \n {
fprintf(stderr, fprintf(stderr,
"%s:%d:warning: multi-line strings not supported\n", "%s:%d:warning: multi-line strings not supported\n",
zconf_curname(), zconf_lineno()); cur_filename, cur_lineno);
unput('\n'); unput('\n');
BEGIN(INITIAL); BEGIN(INITIAL);
yylval.string = text; yylval.string = text;
...@@ -423,12 +423,12 @@ void zconf_nextfile(const char *name) ...@@ -423,12 +423,12 @@ void zconf_nextfile(const char *name)
yyin = zconf_fopen(file->name); yyin = zconf_fopen(file->name);
if (!yyin) { if (!yyin) {
fprintf(stderr, "%s:%d: can't open file \"%s\"\n", fprintf(stderr, "%s:%d: can't open file \"%s\"\n",
zconf_curname(), zconf_lineno(), file->name); cur_filename, cur_lineno, file->name);
exit(1); exit(1);
} }
yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE));
current_file->lineno = zconf_lineno(); current_file->lineno = cur_lineno;
file->parent = current_file; file->parent = current_file;
for (iter = current_file; iter; iter = iter->parent) { for (iter = current_file; iter; iter = iter->parent) {
...@@ -468,13 +468,3 @@ static void zconf_endfile(void) ...@@ -468,13 +468,3 @@ static void zconf_endfile(void)
current_buf = current_buf->parent; current_buf = current_buf->parent;
free(tmp); free(tmp);
} }
int zconf_lineno(void)
{
return cur_lineno;
}
const char *zconf_curname(void)
{
return cur_filename;
}
...@@ -36,8 +36,6 @@ void zconf_starthelp(void); ...@@ -36,8 +36,6 @@ void zconf_starthelp(void);
FILE *zconf_fopen(const char *name); FILE *zconf_fopen(const char *name);
void zconf_initscan(const char *name); void zconf_initscan(const char *name);
void zconf_nextfile(const char *name); void zconf_nextfile(const char *name);
int zconf_lineno(void);
const char *zconf_curname(void);
/* confdata.c */ /* confdata.c */
extern struct gstr autoconf_cmd; extern struct gstr autoconf_cmd;
......
...@@ -54,7 +54,7 @@ void menu_add_entry(struct symbol *sym) ...@@ -54,7 +54,7 @@ void menu_add_entry(struct symbol *sym)
menu->sym = sym; menu->sym = sym;
menu->parent = current_menu; menu->parent = current_menu;
menu->file = current_file; menu->file = current_file;
menu->lineno = zconf_lineno(); menu->lineno = cur_lineno;
*last_entry_ptr = menu; *last_entry_ptr = menu;
last_entry_ptr = &menu->next; last_entry_ptr = &menu->next;
...@@ -135,7 +135,7 @@ static struct property *menu_add_prop(enum prop_type type, struct expr *expr, ...@@ -135,7 +135,7 @@ static struct property *menu_add_prop(enum prop_type type, struct expr *expr,
memset(prop, 0, sizeof(*prop)); memset(prop, 0, sizeof(*prop));
prop->type = type; prop->type = type;
prop->file = current_file; prop->file = current_file;
prop->lineno = zconf_lineno(); prop->lineno = cur_lineno;
prop->menu = current_entry; prop->menu = current_entry;
prop->expr = expr; prop->expr = expr;
prop->visible.expr = dep; prop->visible.expr = dep;
......
...@@ -144,19 +144,19 @@ config_entry_start: T_CONFIG nonconst_symbol T_EOL ...@@ -144,19 +144,19 @@ config_entry_start: T_CONFIG nonconst_symbol T_EOL
{ {
$2->flags |= SYMBOL_OPTIONAL; $2->flags |= SYMBOL_OPTIONAL;
menu_add_entry($2); menu_add_entry($2);
printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2->name); printd(DEBUG_PARSE, "%s:%d:config %s\n", cur_filename, cur_lineno, $2->name);
}; };
config_stmt: config_entry_start config_option_list config_stmt: config_entry_start config_option_list
{ {
printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:endconfig\n", cur_filename, cur_lineno);
}; };
menuconfig_entry_start: T_MENUCONFIG nonconst_symbol T_EOL menuconfig_entry_start: T_MENUCONFIG nonconst_symbol T_EOL
{ {
$2->flags |= SYMBOL_OPTIONAL; $2->flags |= SYMBOL_OPTIONAL;
menu_add_entry($2); menu_add_entry($2);
printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), $2->name); printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", cur_filename, cur_lineno, $2->name);
}; };
menuconfig_stmt: menuconfig_entry_start config_option_list menuconfig_stmt: menuconfig_entry_start config_option_list
...@@ -165,7 +165,7 @@ menuconfig_stmt: menuconfig_entry_start config_option_list ...@@ -165,7 +165,7 @@ menuconfig_stmt: menuconfig_entry_start config_option_list
current_entry->prompt->type = P_MENU; current_entry->prompt->type = P_MENU;
else else
zconfprint("warning: menuconfig statement without prompt"); zconfprint("warning: menuconfig statement without prompt");
printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:endconfig\n", cur_filename, cur_lineno);
}; };
config_option_list: config_option_list:
...@@ -178,15 +178,13 @@ config_option_list: ...@@ -178,15 +178,13 @@ config_option_list:
config_option: type prompt_stmt_opt T_EOL config_option: type prompt_stmt_opt T_EOL
{ {
menu_set_type($1); menu_set_type($1);
printd(DEBUG_PARSE, "%s:%d:type(%u)\n", printd(DEBUG_PARSE, "%s:%d:type(%u)\n", cur_filename, cur_lineno, $1);
zconf_curname(), zconf_lineno(),
$1);
}; };
config_option: T_PROMPT T_WORD_QUOTE if_expr T_EOL config_option: T_PROMPT T_WORD_QUOTE if_expr T_EOL
{ {
menu_add_prompt(P_PROMPT, $2, $3); menu_add_prompt(P_PROMPT, $2, $3);
printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:prompt\n", cur_filename, cur_lineno);
}; };
config_option: default expr if_expr T_EOL config_option: default expr if_expr T_EOL
...@@ -194,27 +192,26 @@ config_option: default expr if_expr T_EOL ...@@ -194,27 +192,26 @@ config_option: default expr if_expr T_EOL
menu_add_expr(P_DEFAULT, $2, $3); menu_add_expr(P_DEFAULT, $2, $3);
if ($1 != S_UNKNOWN) if ($1 != S_UNKNOWN)
menu_set_type($1); menu_set_type($1);
printd(DEBUG_PARSE, "%s:%d:default(%u)\n", printd(DEBUG_PARSE, "%s:%d:default(%u)\n", cur_filename, cur_lineno,
zconf_curname(), zconf_lineno(),
$1); $1);
}; };
config_option: T_SELECT nonconst_symbol if_expr T_EOL config_option: T_SELECT nonconst_symbol if_expr T_EOL
{ {
menu_add_symbol(P_SELECT, $2, $3); menu_add_symbol(P_SELECT, $2, $3);
printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:select\n", cur_filename, cur_lineno);
}; };
config_option: T_IMPLY nonconst_symbol if_expr T_EOL config_option: T_IMPLY nonconst_symbol if_expr T_EOL
{ {
menu_add_symbol(P_IMPLY, $2, $3); menu_add_symbol(P_IMPLY, $2, $3);
printd(DEBUG_PARSE, "%s:%d:imply\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:imply\n", cur_filename, cur_lineno);
}; };
config_option: T_RANGE symbol symbol if_expr T_EOL config_option: T_RANGE symbol symbol if_expr T_EOL
{ {
menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,$2, $3), $4); menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,$2, $3), $4);
printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:range\n", cur_filename, cur_lineno);
}; };
config_option: T_MODULES T_EOL config_option: T_MODULES T_EOL
...@@ -234,7 +231,7 @@ choice: T_CHOICE word_opt T_EOL ...@@ -234,7 +231,7 @@ choice: T_CHOICE word_opt T_EOL
menu_add_entry(sym); menu_add_entry(sym);
menu_add_expr(P_CHOICE, NULL, NULL); menu_add_expr(P_CHOICE, NULL, NULL);
free($2); free($2);
printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:choice\n", cur_filename, cur_lineno);
}; };
choice_entry: choice choice_option_list choice_entry: choice choice_option_list
...@@ -246,7 +243,7 @@ choice_end: end ...@@ -246,7 +243,7 @@ choice_end: end
{ {
if (zconf_endtoken($1, "choice")) { if (zconf_endtoken($1, "choice")) {
menu_end_menu(); menu_end_menu();
printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:endchoice\n", cur_filename, cur_lineno);
} }
}; };
...@@ -263,27 +260,25 @@ choice_option_list: ...@@ -263,27 +260,25 @@ choice_option_list:
choice_option: T_PROMPT T_WORD_QUOTE if_expr T_EOL choice_option: T_PROMPT T_WORD_QUOTE if_expr T_EOL
{ {
menu_add_prompt(P_PROMPT, $2, $3); menu_add_prompt(P_PROMPT, $2, $3);
printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:prompt\n", cur_filename, cur_lineno);
}; };
choice_option: logic_type prompt_stmt_opt T_EOL choice_option: logic_type prompt_stmt_opt T_EOL
{ {
menu_set_type($1); menu_set_type($1);
printd(DEBUG_PARSE, "%s:%d:type(%u)\n", printd(DEBUG_PARSE, "%s:%d:type(%u)\n", cur_filename, cur_lineno, $1);
zconf_curname(), zconf_lineno(), $1);
}; };
choice_option: T_OPTIONAL T_EOL choice_option: T_OPTIONAL T_EOL
{ {
current_entry->sym->flags |= SYMBOL_OPTIONAL; current_entry->sym->flags |= SYMBOL_OPTIONAL;
printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:optional\n", cur_filename, cur_lineno);
}; };
choice_option: T_DEFAULT nonconst_symbol if_expr T_EOL choice_option: T_DEFAULT nonconst_symbol if_expr T_EOL
{ {
menu_add_symbol(P_DEFAULT, $2, $3); menu_add_symbol(P_DEFAULT, $2, $3);
printd(DEBUG_PARSE, "%s:%d:default\n", printd(DEBUG_PARSE, "%s:%d:default\n", cur_filename, cur_lineno);
zconf_curname(), zconf_lineno());
}; };
type: type:
...@@ -305,7 +300,7 @@ default: ...@@ -305,7 +300,7 @@ default:
if_entry: T_IF expr T_EOL if_entry: T_IF expr T_EOL
{ {
printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:if\n", cur_filename, cur_lineno);
menu_add_entry(NULL); menu_add_entry(NULL);
menu_add_dep($2); menu_add_dep($2);
$$ = menu_add_menu(); $$ = menu_add_menu();
...@@ -315,7 +310,7 @@ if_end: end ...@@ -315,7 +310,7 @@ if_end: end
{ {
if (zconf_endtoken($1, "if")) { if (zconf_endtoken($1, "if")) {
menu_end_menu(); menu_end_menu();
printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:endif\n", cur_filename, cur_lineno);
} }
}; };
...@@ -331,7 +326,7 @@ menu: T_MENU T_WORD_QUOTE T_EOL ...@@ -331,7 +326,7 @@ menu: T_MENU T_WORD_QUOTE T_EOL
{ {
menu_add_entry(NULL); menu_add_entry(NULL);
menu_add_prompt(P_MENU, $2, NULL); menu_add_prompt(P_MENU, $2, NULL);
printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:menu\n", cur_filename, cur_lineno);
}; };
menu_entry: menu menu_option_list menu_entry: menu menu_option_list
...@@ -343,7 +338,7 @@ menu_end: end ...@@ -343,7 +338,7 @@ menu_end: end
{ {
if (zconf_endtoken($1, "menu")) { if (zconf_endtoken($1, "menu")) {
menu_end_menu(); menu_end_menu();
printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:endmenu\n", cur_filename, cur_lineno);
} }
}; };
...@@ -358,7 +353,7 @@ menu_option_list: ...@@ -358,7 +353,7 @@ menu_option_list:
source_stmt: T_SOURCE T_WORD_QUOTE T_EOL source_stmt: T_SOURCE T_WORD_QUOTE T_EOL
{ {
printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2); printd(DEBUG_PARSE, "%s:%d:source %s\n", cur_filename, cur_lineno, $2);
zconf_nextfile($2); zconf_nextfile($2);
free($2); free($2);
}; };
...@@ -369,7 +364,7 @@ comment: T_COMMENT T_WORD_QUOTE T_EOL ...@@ -369,7 +364,7 @@ comment: T_COMMENT T_WORD_QUOTE T_EOL
{ {
menu_add_entry(NULL); menu_add_entry(NULL);
menu_add_prompt(P_COMMENT, $2, NULL); menu_add_prompt(P_COMMENT, $2, NULL);
printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:comment\n", cur_filename, cur_lineno);
}; };
comment_stmt: comment comment_option_list comment_stmt: comment comment_option_list
...@@ -384,7 +379,7 @@ comment_option_list: ...@@ -384,7 +379,7 @@ comment_option_list:
help_start: T_HELP T_EOL help_start: T_HELP T_EOL
{ {
printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:help\n", cur_filename, cur_lineno);
zconf_starthelp(); zconf_starthelp();
}; };
...@@ -409,7 +404,7 @@ help: help_start T_HELPTEXT ...@@ -409,7 +404,7 @@ help: help_start T_HELPTEXT
depends: T_DEPENDS T_ON expr T_EOL depends: T_DEPENDS T_ON expr T_EOL
{ {
menu_add_dep($3); menu_add_dep($3);
printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); printd(DEBUG_PARSE, "%s:%d:depends on\n", cur_filename, cur_lineno);
}; };
/* visibility option */ /* visibility option */
...@@ -548,7 +543,7 @@ static void zconfprint(const char *err, ...) ...@@ -548,7 +543,7 @@ static void zconfprint(const char *err, ...)
{ {
va_list ap; va_list ap;
fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); fprintf(stderr, "%s:%d: ", cur_filename, cur_lineno);
va_start(ap, err); va_start(ap, err);
vfprintf(stderr, err, ap); vfprintf(stderr, err, ap);
va_end(ap); va_end(ap);
...@@ -560,7 +555,7 @@ static void zconf_error(const char *err, ...) ...@@ -560,7 +555,7 @@ static void zconf_error(const char *err, ...)
va_list ap; va_list ap;
yynerrs++; yynerrs++;
fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); fprintf(stderr, "%s:%d: ", cur_filename, cur_lineno);
va_start(ap, err); va_start(ap, err);
vfprintf(stderr, err, ap); vfprintf(stderr, err, ap);
va_end(ap); va_end(ap);
...@@ -569,7 +564,7 @@ static void zconf_error(const char *err, ...) ...@@ -569,7 +564,7 @@ static void zconf_error(const char *err, ...)
static void yyerror(const char *err) static void yyerror(const char *err)
{ {
fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno(), err); fprintf(stderr, "%s:%d: %s\n", cur_filename, cur_lineno, err);
} }
static void print_quoted_string(FILE *out, const char *str) static void print_quoted_string(FILE *out, const char *str)
......
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