kconfig: drop localization support
[carl9170fw.git] / config / zconf.y
index d49ed3ae5d3e0889aa74fba98b7a5b8b6f5238c3..c9a1bcb5fce055b39cc1d4c064235ee9b06ffb7c 100644 (file)
 
 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];
@@ -109,7 +109,27 @@ static struct menu *current_menu, *current_entry;
 %%
 input: nl start | start;
 
-start: mainmenu_stmt stmt_list | stmt_list;
+start: mainmenu_stmt stmt_list | no_mainmenu_stmt stmt_list;
+
+/* mainmenu entry */
+
+mainmenu_stmt: T_MAINMENU prompt nl
+{
+       menu_add_prompt(P_MENU, $2, NULL);
+};
+
+/* Default main menu, if there's no mainmenu entry */
+
+no_mainmenu_stmt: /* empty */
+{
+       /*
+        * Hack: Keep the main menu title on the heap so we can safely free it
+        * later regardless of whether it comes from the 'prompt' in
+        * mainmenu_stmt or here
+        */
+       menu_add_prompt(P_MENU, xstrdup("Linux Kernel Configuration"), NULL);
+};
+
 
 stmt_list:
          /* empty */
@@ -155,7 +175,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 +191,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());
 };
 
@@ -258,6 +276,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());
 };
 
@@ -352,13 +371,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
@@ -408,9 +420,7 @@ comment: T_COMMENT prompt T_EOL
 };
 
 comment_stmt: comment depends_list
-{
-       menu_end_entry();
-};
+;
 
 /* help option */
 
@@ -422,6 +432,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 ?: "<choice>");
+       }
+
+       /* 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 ?: "<choice>");
+
        current_entry->help = $2;
 };
 
@@ -507,6 +528,7 @@ word_opt: /* empty */                       { $$ = NULL; }
 
 void conf_parse(const char *name)
 {
+       const char *tmp;
        struct symbol *sym;
        int i;
 
@@ -517,22 +539,24 @@ void conf_parse(const char *name)
        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);
+       tmp = rootmenu.prompt->text;
+       rootmenu.prompt->text = rootmenu.prompt->text;
        rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text);
+       free((char*)tmp);
 
        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);
 }
@@ -557,7 +581,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) {
@@ -566,7 +590,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;
@@ -587,7 +611,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);
@@ -595,7 +619,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);
 }
@@ -628,7 +652,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);