X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=scripts%2Fkconfig%2Fmconf.c;h=6841e95c0989bcd2007b46ad4178e8ad28dd1bbf;hb=d00953a53e9a2edbe005c1e596f1e96a8a293401;hp=b1ad9a00ab19c9ee3149b379afbd2665ec9697e9;hpb=2982de6993e6d9944f2215d7cb9b558b465a0c99;p=safe%2Fjmp%2Flinux-2.6 diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index b1ad9a0..6841e95 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -8,17 +8,13 @@ * i18n, 2005, Arnaldo Carvalho de Melo */ -#include -#include #include #include #include #include -#include #include #include #include -#include #include #include @@ -26,7 +22,6 @@ #include "lkc.h" #include "lxdialog/dialog.h" -static char menu_backtitle[128]; static const char mconf_readme[] = N_( "Overview\n" "--------\n" @@ -36,9 +31,13 @@ static const char mconf_readme[] = N_( "kernel parameters which are not really features, but must be\n" "entered in as decimal or hexadecimal numbers or possibly text.\n" "\n" -"Menu items beginning with [*], or [ ] represent features\n" -"configured to be built in, modularized or removed respectively.\n" -"Pointed brackets <> represent module capable features.\n" +"Menu items beginning with following braces represent features that\n" +" [ ] can be built in or removed\n" +" < > can be built in, modularized or removed\n" +" { } can be built in or modularized (selected by other feature)\n" +" - - are selected by other feature,\n" +"while *, M or whitespace inside braces means to build in, build as\n" +"a module or to exclude the feature respectively.\n" "\n" "To change any of these features, highlight it with the cursor\n" "keys and press to build it in, to make it a module or\n" @@ -271,10 +270,7 @@ search_help[] = N_( " USB$ => find all CONFIG_ symbols ending with USB\n" "\n"); -static char filename[PATH_MAX+1] = ".config"; static int indent; -static struct termios ios_org; -static int rows = 0, cols = 0; static struct menu *current_menu; static int child_count; static int single_menu_mode; @@ -288,51 +284,16 @@ static void show_textbox(const char *title, const char *text, int r, int c); static void show_helptext(const char *title, const char *text); static void show_help(struct menu *menu); -static void init_wsize(void) -{ - struct winsize ws; - char *env; - - if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &ws)) { - rows = ws.ws_row; - cols = ws.ws_col; - } - - if (!rows) { - env = getenv("LINES"); - if (env) - rows = atoi(env); - if (!rows) - rows = 24; - } - if (!cols) { - env = getenv("COLUMNS"); - if (env) - cols = atoi(env); - if (!cols) - cols = 80; - } - - if (rows < 19 || cols < 80) { - fprintf(stderr, N_("Your display is too small to run Menuconfig!\n")); - fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n")); - exit(1); - } - - rows -= 4; - cols -= 5; -} - static void get_prompt_str(struct gstr *r, struct property *prop) { int i, j; struct menu *submenu[8], *menu; - str_printf(r, "Prompt: %s\n", prop->text); - str_printf(r, " Defined at %s:%d\n", prop->menu->file->name, + str_printf(r, _("Prompt: %s\n"), _(prop->text)); + str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name, prop->menu->lineno); if (!expr_is_yes(prop->visible.expr)) { - str_append(r, " Depends on: "); + str_append(r, _(" Depends on: ")); expr_gstr_print(prop->visible.expr, r); str_append(r, "\n"); } @@ -340,13 +301,13 @@ static void get_prompt_str(struct gstr *r, struct property *prop) for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) submenu[i++] = menu; if (i > 0) { - str_printf(r, " Location:\n"); + str_printf(r, _(" Location:\n")); for (j = 4; --i >= 0; j += 2) { menu = submenu[i]; - str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu)); + str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu))); if (menu->sym) { str_printf(r, " (%s [=%s])", menu->sym->name ? - menu->sym->name : "", + menu->sym->name : _(""), sym_get_string_value(menu->sym)); } str_append(r, "\n"); @@ -359,8 +320,9 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym) bool hit; struct property *prop; - str_printf(r, "Symbol: %s [=%s]\n", sym->name, - sym_get_string_value(sym)); + if (sym && sym->name) + str_printf(r, "Symbol: %s [=%s]\n", sym->name, + sym_get_string_value(sym)); for_all_prompts(sym, prop) get_prompt_str(r, prop); hit = false; @@ -375,7 +337,7 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym) if (hit) str_append(r, "\n"); if (sym->rev_dep.expr) { - str_append(r, " Selected by: "); + str_append(r, _(" Selected by: ")); expr_gstr_print(sym->rev_dep.expr, r); str_append(r, "\n"); } @@ -391,19 +353,43 @@ static struct gstr get_relations_str(struct symbol **sym_arr) for (i = 0; sym_arr && (sym = sym_arr[i]); i++) get_symbol_str(&res, sym); if (!i) - str_append(&res, "No matches found.\n"); + str_append(&res, _("No matches found.\n")); return res; } +static char filename[PATH_MAX+1]; +static void set_config_filename(const char *config_filename) +{ + static char menu_backtitle[PATH_MAX+128]; + int size; + struct symbol *sym; + + sym = sym_lookup("KERNELVERSION", 0); + sym_calc_value(sym); + size = snprintf(menu_backtitle, sizeof(menu_backtitle), + _("%s - Linux Kernel v%s Configuration"), + config_filename, sym_get_string_value(sym)); + if (size >= sizeof(menu_backtitle)) + menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; + set_dialog_backtitle(menu_backtitle); + + size = snprintf(filename, sizeof(filename), "%s", config_filename); + if (size >= sizeof(filename)) + filename[sizeof(filename)-1] = '\0'; +} + + static void search_conf(void) { struct symbol **sym_arr; struct gstr res; + char *dialog_input; int dres; again: - reset_dialog(); + dialog_clear(); dres = dialog_inputbox(_("Search Configuration Parameter"), - _("Enter CONFIG_ (sub)string to search for (omit CONFIG_)"), + _("Enter CONFIG_ (sub)string to search for " + "(with or without \"CONFIG\")"), 10, 75, ""); switch (dres) { case 0: @@ -415,7 +401,12 @@ again: return; } - sym_arr = sym_re_search(dialog_input_result); + /* strip CONFIG_ if necessary */ + dialog_input = dialog_input_result; + if (strncasecmp(dialog_input_result, "CONFIG_", 7) == 0) + dialog_input += 7; + + sym_arr = sym_re_search(dialog_input); res = get_relations_str(sym_arr); free(sym_arr); show_textbox(_("Search Results"), str_get(&res), 0, 0); @@ -442,6 +433,7 @@ static void build_conf(struct menu *menu) switch (prop->type) { case P_MENU: child_count++; + prompt = _(prompt); if (single_menu_mode) { item_make("%s%*c%s", menu->data ? "-->" : "++>", @@ -454,10 +446,18 @@ static void build_conf(struct menu *menu) if (single_menu_mode && menu->data) goto conf_childs; return; + case P_COMMENT: + if (prompt) { + child_count++; + item_make(" %*c*** %s ***", indent + 1, ' ', _(prompt)); + item_set_tag(':'); + item_set_data(menu); + } + break; default: if (prompt) { child_count++; - item_make("---%*c%s", indent + 1, ' ', prompt); + item_make("---%*c%s", indent + 1, ' ', _(prompt)); item_set_tag(':'); item_set_data(menu); } @@ -501,10 +501,10 @@ static void build_conf(struct menu *menu) item_set_data(menu); } - item_add_str("%*c%s", indent + 1, ' ', menu_get_prompt(menu)); + item_add_str("%*c%s", indent + 1, ' ', _(menu_get_prompt(menu))); if (val == yes) { if (def_menu) { - item_add_str(" (%s)", menu_get_prompt(def_menu)); + item_add_str(" (%s)", _(menu_get_prompt(def_menu))); item_add_str(" --->"); if (def_menu->list) { indent += 2; @@ -516,7 +516,7 @@ static void build_conf(struct menu *menu) } } else { if (menu == current_menu) { - item_make("---%*c%s", indent + 1, ' ', menu_get_prompt(menu)); + item_make("---%*c%s", indent + 1, ' ', _(menu_get_prompt(menu))); item_set_tag(':'); item_set_data(menu); goto conf_childs; @@ -533,7 +533,7 @@ static void build_conf(struct menu *menu) if (sym_is_changable(sym)) item_make("[%c]", val == no ? ' ' : '*'); else - item_make("---"); + item_make("-%c-", val == no ? ' ' : '*'); item_set_tag('t'); item_set_data(menu); break; @@ -543,10 +543,13 @@ static void build_conf(struct menu *menu) case mod: ch = 'M'; break; default: ch = ' '; break; } - if (sym_is_changable(sym)) - item_make("<%c>", ch); - else - item_make("---"); + if (sym_is_changable(sym)) { + if (sym->rev_dep.tri == mod) + item_make("{%c}", ch); + else + item_make("<%c>", ch); + } else + item_make("-%c-", ch); item_set_tag('t'); item_set_data(menu); break; @@ -556,17 +559,17 @@ static void build_conf(struct menu *menu) tmp = indent - tmp + 4; if (tmp < 0) tmp = 0; - item_add_str("%*c%s%s", tmp, ' ', menu_get_prompt(menu), + item_add_str("%*c%s%s", tmp, ' ', _(menu_get_prompt(menu)), (sym_has_value(sym) || !sym_is_changable(sym)) ? - "" : " (NEW)"); + "" : _(" (NEW)")); item_set_tag('s'); item_set_data(menu); goto conf_childs; } } - item_add_str("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), + item_add_str("%*c%s%s", indent + 1, ' ', _(menu_get_prompt(menu)), (sym_has_value(sym) || !sym_is_changable(sym)) ? - "" : " (NEW)"); + "" : _(" (NEW)")); if (menu->prompt->type == P_MENU) { item_add_str(" --->"); return; @@ -603,12 +606,11 @@ static void conf(struct menu *menu) item_make(_(" Save an Alternate Configuration File")); item_set_tag('S'); } - reset_dialog(); - res = dialog_menu(prompt ? prompt : _("Main Menu"), + dialog_clear(); + res = dialog_menu(prompt ? _(prompt) : _("Main Menu"), _(menu_instructions), - rows, cols, rows - 10, active_menu, &s_scroll); - if (res == 1 || res == 255) + if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL) break; if (!item_activate_selected()) continue; @@ -617,7 +619,10 @@ static void conf(struct menu *menu) submenu = item_data(); active_menu = item_data(); - sym = submenu->sym; + if (submenu) + sym = submenu->sym; + else + sym = NULL; switch (res) { case 0: @@ -649,7 +654,7 @@ static void conf(struct menu *menu) if (sym) show_help(submenu); else - show_helptext("README", _(mconf_readme)); + show_helptext(_("README"), _(mconf_readme)); break; case 3: if (item_is_tag('t')) { @@ -682,8 +687,8 @@ static void conf(struct menu *menu) static void show_textbox(const char *title, const char *text, int r, int c) { - reset_dialog(); - dialog_textbox(title, text, r ? r : rows, c ? c : cols); + dialog_clear(); + dialog_textbox(title, text, r, c); } static void show_helptext(const char *title, const char *text) @@ -696,24 +701,24 @@ static void show_help(struct menu *menu) struct gstr help = str_new(); struct symbol *sym = menu->sym; - if (sym->help) + if (menu_has_help(menu)) { if (sym->name) { str_printf(&help, "CONFIG_%s:\n\n", sym->name); - str_append(&help, _(sym->help)); + str_append(&help, _(menu_get_help(menu))); str_append(&help, "\n"); } } else { str_append(&help, nohelp_text); } get_symbol_str(&help, sym); - show_helptext(menu_get_prompt(menu), str_get(&help)); + show_helptext(_(menu_get_prompt(menu)), str_get(&help)); str_free(&help); } static void conf_choice(struct menu *menu) { - const char *prompt = menu_get_prompt(menu); + const char *prompt = _(menu_get_prompt(menu)); struct menu *child; struct symbol *active; @@ -727,15 +732,15 @@ static void conf_choice(struct menu *menu) for (child = menu->list; child; child = child->next) { if (!menu_is_visible(child)) continue; - item_make("%s", menu_get_prompt(child)); + item_make("%s", _(menu_get_prompt(child))); item_set_data(child); if (child->sym == active) item_set_selected(1); if (child->sym == sym_get_choice_value(menu->sym)) item_set_tag('X'); } - reset_dialog(); - res = dialog_checklist(prompt ? prompt : _("Main Menu"), + dialog_clear(); + res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"), _(radiolist_instructions), 15, 70, 6); selected = item_activate_selected(); @@ -754,7 +759,9 @@ static void conf_choice(struct menu *menu) } else show_help(menu); break; - case 255: + case KEY_ESC: + return; + case -ERRDISPLAYTOOSMALL: return; } } @@ -766,7 +773,7 @@ static void conf_string(struct menu *menu) while (1) { int res; - char *heading; + const char *heading; switch (sym_get_type(menu->sym)) { case S_INT: @@ -779,10 +786,10 @@ static void conf_string(struct menu *menu) heading = _(inputbox_instructions_string); break; default: - heading = "Internal mconf error!"; + heading = _("Internal mconf error!"); } - reset_dialog(); - res = dialog_inputbox(prompt ? prompt : _("Main Menu"), + dialog_clear(); + res = dialog_inputbox(prompt ? _(prompt) : _("Main Menu"), heading, 10, 75, sym_get_string_value(menu->sym)); switch (res) { @@ -794,7 +801,7 @@ static void conf_string(struct menu *menu) case 1: show_help(menu); break; - case 255: + case KEY_ESC: return; } } @@ -805,21 +812,24 @@ static void conf_load(void) while (1) { int res; - reset_dialog(); + dialog_clear(); res = dialog_inputbox(NULL, load_config_text, 11, 55, filename); switch(res) { case 0: if (!dialog_input_result[0]) return; - if (!conf_read(dialog_input_result)) + if (!conf_read(dialog_input_result)) { + set_config_filename(dialog_input_result); + sym_set_change_count(1); return; + } show_textbox(NULL, _("File does not exist!"), 5, 38); break; case 1: show_helptext(_("Load Alternate Configuration"), load_config_help); break; - case 255: + case KEY_ESC: return; } } @@ -829,34 +839,31 @@ static void conf_save(void) { while (1) { int res; - reset_dialog(); + dialog_clear(); res = dialog_inputbox(NULL, save_config_text, 11, 55, filename); switch(res) { case 0: if (!dialog_input_result[0]) return; - if (!conf_write(dialog_input_result)) + if (!conf_write(dialog_input_result)) { + set_config_filename(dialog_input_result); return; + } show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60); break; case 1: show_helptext(_("Save Alternate Configuration"), save_config_help); break; - case 255: + case KEY_ESC: return; } } } -static void conf_cleanup(void) -{ - tcsetattr(1, TCSAFLUSH, &ios_org); -} - int main(int ac, char **av) { - struct symbol *sym; + int saved_x, saved_y; char *mode; int res; @@ -867,42 +874,50 @@ int main(int ac, char **av) conf_parse(av[1]); conf_read(NULL); - sym = sym_lookup("KERNELVERSION", 0); - sym_calc_value(sym); - sprintf(menu_backtitle, _("Linux Kernel v%s Configuration"), - sym_get_string_value(sym)); - mode = getenv("MENUCONFIG_MODE"); if (mode) { if (!strcasecmp(mode, "single_menu")) single_menu_mode = 1; } - tcgetattr(1, &ios_org); - atexit(conf_cleanup); - init_wsize(); - reset_dialog(); - init_dialog(menu_backtitle); - conf(&rootmenu); - reset_dialog(); - res = dialog_yesno(NULL, - _("Do you wish to save your " - "new kernel configuration?"), - 5, 60); - end_dialog(); - if (res == 0) { - if (conf_write(NULL)) { + getyx(stdscr, saved_y, saved_x); + if (init_dialog(NULL)) { + fprintf(stderr, N_("Your display is too small to run Menuconfig!\n")); + fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n")); + return 1; + } + + set_config_filename(conf_get_configname()); + do { + conf(&rootmenu); + dialog_clear(); + if (conf_get_changed()) + res = dialog_yesno(NULL, + _("Do you wish to save your " + "new kernel configuration?\n" + " to continue."), + 6, 60); + else + res = -1; + } while (res == KEY_ESC); + end_dialog(saved_x, saved_y); + + switch (res) { + case 0: + if (conf_write(filename)) { fprintf(stderr, _("\n\n" "Error during writing of the kernel configuration.\n" "Your kernel configuration changes were NOT saved." "\n\n")); return 1; } + case -1: printf(_("\n\n" "*** End of Linux kernel configuration.\n" "*** Execute 'make' to build the kernel or try 'make help'." "\n\n")); - } else { + break; + default: fprintf(stderr, _("\n\n" "Your kernel configuration changes were NOT saved." "\n\n")); @@ -910,3 +925,4 @@ int main(int ac, char **av) return 0; } +