diff options
author | Sam Ravnborg <sam@ravnborg.org> | 2007-03-18 05:48:46 -0400 |
---|---|---|
committer | Sam Ravnborg <sam@ravnborg.org> | 2007-05-02 14:58:09 -0400 |
commit | 95e30f9593ebf39e26227a20ae8d9f160c50fb67 (patch) | |
tree | 1ad3db38f47f079c7cd71251849de7e9778f3ef6 /scripts | |
parent | dd7e54ade8f515ec38d5dc2129705352e2296f8e (diff) |
menuconfig: remember alternate config filename
When loading an alternate configuration use that file as
current configuration filename.
Make the filename visible in the dialog.
Default continue to be .config.
Inspired by patch from: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/kconfig/lxdialog/dialog.h | 1 | ||||
-rw-r--r-- | scripts/kconfig/lxdialog/util.c | 5 | ||||
-rw-r--r-- | scripts/kconfig/mconf.c | 43 |
3 files changed, 37 insertions, 12 deletions
diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index fd695e1070f7..7e17eba75ae8 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h | |||
@@ -188,6 +188,7 @@ int on_key_esc(WINDOW *win); | |||
188 | int on_key_resize(void); | 188 | int on_key_resize(void); |
189 | 189 | ||
190 | void init_dialog(const char *backtitle); | 190 | void init_dialog(const char *backtitle); |
191 | void set_dialog_backtitle(const char *backtitle); | ||
191 | void reset_dialog(void); | 192 | void reset_dialog(void); |
192 | void end_dialog(void); | 193 | void end_dialog(void); |
193 | void attr_clear(WINDOW * win, int height, int width, chtype attr); | 194 | void attr_clear(WINDOW * win, int height, int width, chtype attr); |
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c index a1a1354ba238..a1bddefe73d0 100644 --- a/scripts/kconfig/lxdialog/util.c +++ b/scripts/kconfig/lxdialog/util.c | |||
@@ -272,6 +272,11 @@ void init_dialog(const char *backtitle) | |||
272 | color_setup(getenv("MENUCONFIG_COLOR")); | 272 | color_setup(getenv("MENUCONFIG_COLOR")); |
273 | } | 273 | } |
274 | 274 | ||
275 | void set_dialog_backtitle(const char *backtitle) | ||
276 | { | ||
277 | dlg.backtitle = backtitle; | ||
278 | } | ||
279 | |||
275 | void reset_dialog(void) | 280 | void reset_dialog(void) |
276 | { | 281 | { |
277 | initscr(); /* Init curses */ | 282 | initscr(); /* Init curses */ |
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 3f9a1321b3e6..462256d72baa 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "lkc.h" | 26 | #include "lkc.h" |
27 | #include "lxdialog/dialog.h" | 27 | #include "lxdialog/dialog.h" |
28 | 28 | ||
29 | static char menu_backtitle[128]; | ||
30 | static const char mconf_readme[] = N_( | 29 | static const char mconf_readme[] = N_( |
31 | "Overview\n" | 30 | "Overview\n" |
32 | "--------\n" | 31 | "--------\n" |
@@ -271,7 +270,6 @@ search_help[] = N_( | |||
271 | " USB$ => find all CONFIG_ symbols ending with USB\n" | 270 | " USB$ => find all CONFIG_ symbols ending with USB\n" |
272 | "\n"); | 271 | "\n"); |
273 | 272 | ||
274 | static char filename[PATH_MAX+1] = ".config"; | ||
275 | static int indent; | 273 | static int indent; |
276 | static struct termios ios_org; | 274 | static struct termios ios_org; |
277 | static int rows = 0, cols = 0; | 275 | static int rows = 0, cols = 0; |
@@ -395,6 +393,28 @@ static struct gstr get_relations_str(struct symbol **sym_arr) | |||
395 | return res; | 393 | return res; |
396 | } | 394 | } |
397 | 395 | ||
396 | static char filename[PATH_MAX+1]; | ||
397 | static void set_config_filename(const char *config_filename) | ||
398 | { | ||
399 | static char menu_backtitle[PATH_MAX+128]; | ||
400 | int size; | ||
401 | struct symbol *sym; | ||
402 | |||
403 | sym = sym_lookup("KERNELVERSION", 0); | ||
404 | sym_calc_value(sym); | ||
405 | size = snprintf(menu_backtitle, sizeof(menu_backtitle), | ||
406 | _("%s - Linux Kernel v%s Configuration"), | ||
407 | config_filename, sym_get_string_value(sym)); | ||
408 | if (size >= sizeof(menu_backtitle)) | ||
409 | menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; | ||
410 | set_dialog_backtitle(menu_backtitle); | ||
411 | |||
412 | size = snprintf(filename, sizeof(filename), "%s", config_filename); | ||
413 | if (size >= sizeof(filename)) | ||
414 | filename[sizeof(filename)-1] = '\0'; | ||
415 | } | ||
416 | |||
417 | |||
398 | static void search_conf(void) | 418 | static void search_conf(void) |
399 | { | 419 | { |
400 | struct symbol **sym_arr; | 420 | struct symbol **sym_arr; |
@@ -816,8 +836,10 @@ static void conf_load(void) | |||
816 | case 0: | 836 | case 0: |
817 | if (!dialog_input_result[0]) | 837 | if (!dialog_input_result[0]) |
818 | return; | 838 | return; |
819 | if (!conf_read(dialog_input_result)) | 839 | if (!conf_read(dialog_input_result)) { |
840 | set_config_filename(dialog_input_result); | ||
820 | return; | 841 | return; |
842 | } | ||
821 | show_textbox(NULL, _("File does not exist!"), 5, 38); | 843 | show_textbox(NULL, _("File does not exist!"), 5, 38); |
822 | break; | 844 | break; |
823 | case 1: | 845 | case 1: |
@@ -840,8 +862,10 @@ static void conf_save(void) | |||
840 | case 0: | 862 | case 0: |
841 | if (!dialog_input_result[0]) | 863 | if (!dialog_input_result[0]) |
842 | return; | 864 | return; |
843 | if (!conf_write(dialog_input_result)) | 865 | if (!conf_write(dialog_input_result)) { |
866 | set_config_filename(dialog_input_result); | ||
844 | return; | 867 | return; |
868 | } | ||
845 | show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60); | 869 | show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60); |
846 | break; | 870 | break; |
847 | case 1: | 871 | case 1: |
@@ -860,7 +884,6 @@ static void conf_cleanup(void) | |||
860 | 884 | ||
861 | int main(int ac, char **av) | 885 | int main(int ac, char **av) |
862 | { | 886 | { |
863 | struct symbol *sym; | ||
864 | char *mode; | 887 | char *mode; |
865 | int res; | 888 | int res; |
866 | 889 | ||
@@ -871,11 +894,6 @@ int main(int ac, char **av) | |||
871 | conf_parse(av[1]); | 894 | conf_parse(av[1]); |
872 | conf_read(NULL); | 895 | conf_read(NULL); |
873 | 896 | ||
874 | sym = sym_lookup("KERNELVERSION", 0); | ||
875 | sym_calc_value(sym); | ||
876 | sprintf(menu_backtitle, _("Linux Kernel v%s Configuration"), | ||
877 | sym_get_string_value(sym)); | ||
878 | |||
879 | mode = getenv("MENUCONFIG_MODE"); | 897 | mode = getenv("MENUCONFIG_MODE"); |
880 | if (mode) { | 898 | if (mode) { |
881 | if (!strcasecmp(mode, "single_menu")) | 899 | if (!strcasecmp(mode, "single_menu")) |
@@ -886,7 +904,8 @@ int main(int ac, char **av) | |||
886 | atexit(conf_cleanup); | 904 | atexit(conf_cleanup); |
887 | init_wsize(); | 905 | init_wsize(); |
888 | reset_dialog(); | 906 | reset_dialog(); |
889 | init_dialog(menu_backtitle); | 907 | init_dialog(NULL); |
908 | set_config_filename(".config"); | ||
890 | do { | 909 | do { |
891 | conf(&rootmenu); | 910 | conf(&rootmenu); |
892 | dialog_clear(); | 911 | dialog_clear(); |
@@ -903,7 +922,7 @@ int main(int ac, char **av) | |||
903 | 922 | ||
904 | switch (res) { | 923 | switch (res) { |
905 | case 0: | 924 | case 0: |
906 | if (conf_write(NULL)) { | 925 | if (conf_write(filename)) { |
907 | fprintf(stderr, _("\n\n" | 926 | fprintf(stderr, _("\n\n" |
908 | "Error during writing of the kernel configuration.\n" | 927 | "Error during writing of the kernel configuration.\n" |
909 | "Your kernel configuration changes were NOT saved." | 928 | "Your kernel configuration changes were NOT saved." |