X-Git-Url: https://jxself.org/git/?p=carl9170fw.git;a=blobdiff_plain;f=config%2Fzconf.y;h=e31e3d38740c4e8ba0d402b6e3b3344dfa497b6b;hp=7ca795404d38e2860f8c3cb046c2bbaea7c506e4;hb=19b576e68d1eb396821dde6f5ff7fb9848d338cc;hpb=42bc2cb9fd5367ea805f291c72c81e67fbcabde5 diff --git a/config/zconf.y b/config/zconf.y index 7ca7954..e31e3d3 100644 --- a/config/zconf.y +++ b/config/zconf.y @@ -20,10 +20,10 @@ int cdebug = PRINTD; -extern int zconflex(void); +int yylex(void); +static void yyerror(const char *err); static void zconfprint(const char *err, ...); static void zconf_error(const char *err, ...); -static void zconferror(const char *err); static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); struct symbol *symbol_hash[SYMBOL_HASHSIZE]; @@ -111,6 +111,13 @@ input: nl start | start; start: mainmenu_stmt stmt_list | stmt_list; +/* mainmenu entry */ + +mainmenu_stmt: T_MAINMENU prompt nl +{ + menu_add_prompt(P_MENU, $2, NULL); +}; + stmt_list: /* empty */ | stmt_list common_stmt @@ -155,7 +162,6 @@ config_entry_start: T_CONFIG nonconst_symbol T_EOL config_stmt: config_entry_start config_option_list { - menu_end_entry(); printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); }; @@ -172,7 +178,6 @@ menuconfig_stmt: menuconfig_entry_start config_option_list current_entry->prompt->type = P_MENU; else zconfprint("warning: menuconfig statement without prompt"); - menu_end_entry(); printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); }; @@ -236,8 +241,10 @@ symbol_option_list: | symbol_option_list T_WORD symbol_option_arg { const struct kconf_id *id = kconf_id_lookup($2, strlen($2)); - if (id && id->flags & TF_OPTION) + if (id && id->flags & TF_OPTION) { menu_add_option(id->token, $3); + free($3); + } else zconfprint("warning: ignoring unknown option %s", $2); free($2); @@ -256,6 +263,7 @@ choice: T_CHOICE word_opt T_EOL sym->flags |= SYMBOL_AUTO; menu_add_entry(sym); menu_add_expr(P_CHOICE, NULL, NULL); + free($2); printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); }; @@ -350,13 +358,6 @@ if_block: | if_block choice_stmt ; -/* mainmenu entry */ - -mainmenu_stmt: T_MAINMENU prompt nl -{ - menu_add_prompt(P_MENU, $2, NULL); -}; - /* menu entry */ menu: T_MENU prompt T_EOL @@ -406,9 +407,7 @@ comment: T_COMMENT prompt T_EOL }; comment_stmt: comment depends_list -{ - menu_end_entry(); -}; +; /* help option */ @@ -420,6 +419,17 @@ help_start: T_HELP T_EOL help: help_start T_HELPTEXT { + if (current_entry->help) { + free(current_entry->help); + zconfprint("warning: '%s' defined with more than one help text -- only the last one will be used", + current_entry->sym->name ?: ""); + } + + /* Is the help text empty or all whitespace? */ + if ($2[strspn($2, " \f\n\r\t\v")] == '\0') + zconfprint("warning: '%s' defined with blank help text", + current_entry->sym->name ?: ""); + current_entry->help = $2; }; @@ -510,27 +520,28 @@ void conf_parse(const char *name) zconf_initscan(name); - sym_init(); _menu_init(); rootmenu.prompt = menu_add_prompt(P_MENU, "CARL9170 Firmware Configuration", NULL); if (getenv("ZCONF_DEBUG")) - zconfdebug = 1; - zconfparse(); - if (zconfnerrs) + yydebug = 1; + yyparse(); + if (yynerrs) exit(1); if (!modules_sym) modules_sym = sym_find( "n" ); - rootmenu.prompt->text = _(rootmenu.prompt->text); - rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text); + if (!menu_has_prompt(&rootmenu)) { + current_entry = &rootmenu; + menu_add_prompt(P_MENU, "Main menu", NULL); + } menu_finalize(&rootmenu); for_all_symbols(i, sym) { if (sym_check_deps(sym)) - zconfnerrs++; + yynerrs++; } - if (zconfnerrs) + if (yynerrs) exit(1); sym_set_change_count(1); } @@ -555,7 +566,7 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok if (id->token != endtoken) { zconf_error("unexpected '%s' within %s block", id->name, zconf_tokenname(starttoken)); - zconfnerrs++; + yynerrs++; return false; } if (current_menu->file != current_file) { @@ -564,7 +575,7 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok fprintf(stderr, "%s:%d: location of the '%s'\n", current_menu->file->name, current_menu->lineno, zconf_tokenname(starttoken)); - zconfnerrs++; + yynerrs++; return false; } return true; @@ -585,7 +596,7 @@ static void zconf_error(const char *err, ...) { va_list ap; - zconfnerrs++; + yynerrs++; fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); va_start(ap, err); vfprintf(stderr, err, ap); @@ -593,7 +604,7 @@ static void zconf_error(const char *err, ...) fprintf(stderr, "\n"); } -static void zconferror(const char *err) +static void yyerror(const char *err) { fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); } @@ -626,7 +637,7 @@ static void print_symbol(FILE *out, struct menu *menu) fprintf(out, "\nconfig %s\n", sym->name); switch (sym->type) { case S_BOOLEAN: - fputs(" boolean\n", out); + fputs(" bool\n", out); break; case S_TRISTATE: fputs(" tristate\n", out); @@ -755,3 +766,4 @@ void zconfdump(FILE *out) #include "expr.c" #include "symbol.c" #include "menu.c" +#include "preprocess.c"