disable the automatic config reset if 'Advanced configuration options' is selected
[openwrt.git] / scripts / config / mconf.c
index 2ef24aa..7403617 100644 (file)
@@ -22,6 +22,7 @@
 #include <unistd.h>
 #include <locale.h>
 
+#define BUFSIZE 524288
 #define LKC_DIRECT_LINK
 #include "lkc.h"
 
@@ -254,10 +255,10 @@ search_help[] = N_(
        "          USB$ => find all CONFIG_ symbols ending with USB\n"
        "\n");
 
-static char buf[4096], *bufptr = buf;
-static char input_buf[4096];
+static char buf[BUFSIZE], *bufptr = buf;
+static char input_buf[BUFSIZE];
 static char filename[PATH_MAX+1] = ".config";
-static char *args[1024], **argptr = args;
+static char *args[BUFSIZE], **argptr = args;
 static int indent;
 static struct termios ios_org;
 static int rows = 0, cols = 0;
@@ -737,6 +738,8 @@ static void conf(struct menu *menu)
                if (menu == &rootmenu) {
                        cprint(":");
                        cprint("--- ");
+                       cprint("D");
+                       cprint(_("    Reset to defaults"));
                        cprint("L");
                        cprint(_("    Load an Alternate Configuration File"));
                        cprint("S");
@@ -783,6 +786,9 @@ static void conf(struct menu *menu)
                        case 's':
                                conf_string(submenu);
                                break;
+                       case 'D':
+                               conf_reset();
+                               break;
                        case 'L':
                                conf_load();
                                break;
@@ -882,6 +888,7 @@ static void conf_choice(struct menu *menu)
        const char *prompt = menu_get_prompt(menu);
        struct menu *child;
        struct symbol *active;
+       struct property *prop;
        int stat;
 
        active = sym_get_choice_value(menu->sym);
@@ -914,6 +921,13 @@ static void conf_choice(struct menu *menu)
                case 0:
                        if (sscanf(input_buf, "%p", &child) != 1)
                                break;
+                       
+                       if (sym_get_tristate_value(child->sym) != yes) {
+                               for_all_properties(menu->sym, prop, P_RESET) {
+                                       if (expr_calc_value(prop->visible.expr) != no)
+                                               conf_reset();
+                               }
+                       }
                        sym_set_tristate_value(child->sym, yes);
                        return;
                case 1: