diff options
| -rw-r--r-- | scripts/kconfig/mconf.c | 86 |
1 files changed, 52 insertions, 34 deletions
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 820d2b6800fb..19e200d91120 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include <stdarg.h> | 15 | #include <stdarg.h> |
| 16 | #include <stdlib.h> | 16 | #include <stdlib.h> |
| 17 | #include <string.h> | 17 | #include <string.h> |
| 18 | #include <signal.h> | ||
| 18 | #include <unistd.h> | 19 | #include <unistd.h> |
| 19 | #include <locale.h> | 20 | #include <locale.h> |
| 20 | 21 | ||
| @@ -272,6 +273,7 @@ static struct menu *current_menu; | |||
| 272 | static int child_count; | 273 | static int child_count; |
| 273 | static int single_menu_mode; | 274 | static int single_menu_mode; |
| 274 | static int show_all_options; | 275 | static int show_all_options; |
| 276 | static int saved_x, saved_y; | ||
| 275 | 277 | ||
| 276 | static void conf(struct menu *menu); | 278 | static void conf(struct menu *menu); |
| 277 | static void conf_choice(struct menu *menu); | 279 | static void conf_choice(struct menu *menu); |
| @@ -792,9 +794,54 @@ static void conf_save(void) | |||
| 792 | } | 794 | } |
| 793 | } | 795 | } |
| 794 | 796 | ||
| 797 | static int handle_exit(void) | ||
| 798 | { | ||
| 799 | int res; | ||
| 800 | |||
| 801 | dialog_clear(); | ||
| 802 | if (conf_get_changed()) | ||
| 803 | res = dialog_yesno(NULL, | ||
| 804 | _("Do you wish to save your new configuration ?\n" | ||
| 805 | "<ESC><ESC> to continue."), | ||
| 806 | 6, 60); | ||
| 807 | else | ||
| 808 | res = -1; | ||
| 809 | |||
| 810 | end_dialog(saved_x, saved_y); | ||
| 811 | |||
| 812 | switch (res) { | ||
| 813 | case 0: | ||
| 814 | if (conf_write(filename)) { | ||
| 815 | fprintf(stderr, _("\n\n" | ||
| 816 | "Error while writing of the configuration.\n" | ||
| 817 | "Your configuration changes were NOT saved." | ||
| 818 | "\n\n")); | ||
| 819 | return 1; | ||
| 820 | } | ||
| 821 | /* fall through */ | ||
| 822 | case -1: | ||
| 823 | printf(_("\n\n" | ||
| 824 | "*** End of the configuration.\n" | ||
| 825 | "*** Execute 'make' to start the build or try 'make help'." | ||
| 826 | "\n\n")); | ||
| 827 | res = 0; | ||
| 828 | break; | ||
| 829 | default: | ||
| 830 | fprintf(stderr, _("\n\n" | ||
| 831 | "Your configuration changes were NOT saved." | ||
| 832 | "\n\n")); | ||
| 833 | } | ||
| 834 | |||
| 835 | return res; | ||
| 836 | } | ||
| 837 | |||
| 838 | static void sig_handler(int signo) | ||
| 839 | { | ||
| 840 | exit(handle_exit()); | ||
| 841 | } | ||
| 842 | |||
| 795 | int main(int ac, char **av) | 843 | int main(int ac, char **av) |
| 796 | { | 844 | { |
| 797 | int saved_x, saved_y; | ||
| 798 | char *mode; | 845 | char *mode; |
| 799 | int res; | 846 | int res; |
| 800 | 847 | ||
| @@ -802,6 +849,8 @@ int main(int ac, char **av) | |||
| 802 | bindtextdomain(PACKAGE, LOCALEDIR); | 849 | bindtextdomain(PACKAGE, LOCALEDIR); |
| 803 | textdomain(PACKAGE); | 850 | textdomain(PACKAGE); |
| 804 | 851 | ||
| 852 | signal(SIGINT, sig_handler); | ||
| 853 | |||
| 805 | conf_parse(av[1]); | 854 | conf_parse(av[1]); |
| 806 | conf_read(NULL); | 855 | conf_read(NULL); |
| 807 | 856 | ||
| @@ -823,40 +872,9 @@ int main(int ac, char **av) | |||
| 823 | set_config_filename(conf_get_configname()); | 872 | set_config_filename(conf_get_configname()); |
| 824 | do { | 873 | do { |
| 825 | conf(&rootmenu); | 874 | conf(&rootmenu); |
| 826 | dialog_clear(); | 875 | res = handle_exit(); |
| 827 | if (conf_get_changed()) | ||
| 828 | res = dialog_yesno(NULL, | ||
| 829 | _("Do you wish to save your " | ||
| 830 | "new configuration?\n" | ||
| 831 | "<ESC><ESC> to continue."), | ||
| 832 | 6, 60); | ||
| 833 | else | ||
| 834 | res = -1; | ||
| 835 | } while (res == KEY_ESC); | 876 | } while (res == KEY_ESC); |
| 836 | end_dialog(saved_x, saved_y); | ||
| 837 | |||
| 838 | switch (res) { | ||
| 839 | case 0: | ||
| 840 | if (conf_write(filename)) { | ||
| 841 | fprintf(stderr, _("\n\n" | ||
| 842 | "Error while writing of the configuration.\n" | ||
| 843 | "Your configuration changes were NOT saved." | ||
| 844 | "\n\n")); | ||
| 845 | return 1; | ||
| 846 | } | ||
| 847 | /* fall through */ | ||
| 848 | case -1: | ||
| 849 | printf(_("\n\n" | ||
| 850 | "*** End of the configuration.\n" | ||
| 851 | "*** Execute 'make' to start the build or try 'make help'." | ||
| 852 | "\n\n")); | ||
| 853 | break; | ||
| 854 | default: | ||
| 855 | fprintf(stderr, _("\n\n" | ||
| 856 | "Your configuration changes were NOT saved." | ||
| 857 | "\n\n")); | ||
| 858 | } | ||
| 859 | 877 | ||
| 860 | return 0; | 878 | return res; |
| 861 | } | 879 | } |
| 862 | 880 | ||
