fix menuconfig 'deselect' statement
[openwrt.git] / scripts / config / symbol.c
index 3d7877a..2c1392a 100644 (file)
@@ -61,10 +61,10 @@ void sym_init(void)
        if (p)
                sym_add_default(sym, p);
 
        if (p)
                sym_add_default(sym, p);
 
-       sym = sym_lookup("KERNELVERSION", 0);
+       sym = sym_lookup("OPENWRTVERSION", 0);
        sym->type = S_STRING;
        sym->flags |= SYMBOL_AUTO;
        sym->type = S_STRING;
        sym->flags |= SYMBOL_AUTO;
-       p = getenv("KERNELVERSION");
+       p = getenv("OPENWRTVERSION");
        if (p)
                sym_add_default(sym, p);
 
        if (p)
                sym_add_default(sym, p);
 
@@ -81,8 +81,11 @@ enum symbol_type sym_get_type(struct symbol *sym)
        if (type == S_TRISTATE) {
                if (sym_is_choice_value(sym) && sym->visible == yes)
                        type = S_BOOLEAN;
        if (type == S_TRISTATE) {
                if (sym_is_choice_value(sym) && sym->visible == yes)
                        type = S_BOOLEAN;
+/* tristate always enabled */
+#if 0
                else if (modules_val == no)
                        type = S_BOOLEAN;
                else if (modules_val == no)
                        type = S_BOOLEAN;
+#endif
        }
        return type;
 }
        }
        return type;
 }
@@ -194,6 +197,7 @@ static void sym_calc_visibility(struct symbol *sym)
 {
        struct property *prop;
        tristate tri;
 {
        struct property *prop;
        tristate tri;
+       int deselected = 0;
 
        /* any prompt visible? */
        tri = no;
 
        /* any prompt visible? */
        tri = no;
@@ -201,13 +205,17 @@ static void sym_calc_visibility(struct symbol *sym)
                prop->visible.tri = expr_calc_value(prop->visible.expr);
                tri = E_OR(tri, prop->visible.tri);
        }
                prop->visible.tri = expr_calc_value(prop->visible.expr);
                tri = E_OR(tri, prop->visible.tri);
        }
-       if (tri == mod && (sym->type != S_TRISTATE || modules_val == no))
+       if (tri == mod && (sym->type != S_TRISTATE))
                tri = yes;
                tri = yes;
+       if (sym->rev_dep_inv.expr && (expr_calc_value(sym->rev_dep_inv.expr) == yes)) {
+               tri = no;
+               deselected = 1;
+       }
        if (sym->visible != tri) {
                sym->visible = tri;
                sym_set_changed(sym);
        }
        if (sym->visible != tri) {
                sym->visible = tri;
                sym_set_changed(sym);
        }
-       if (sym_is_choice_value(sym))
+       if (sym_is_choice_value(sym) || deselected)
                return;
        tri = no;
        if (sym->rev_dep.expr)
                return;
        tri = no;
        if (sym->rev_dep.expr)
@@ -303,6 +311,8 @@ void sym_calc_value(struct symbol *sym)
                if (sym_is_choice_value(sym) && sym->visible == yes) {
                        prop = sym_get_choice_prop(sym);
                        newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no;
                if (sym_is_choice_value(sym) && sym->visible == yes) {
                        prop = sym_get_choice_prop(sym);
                        newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no;
+               } else if (sym->rev_dep_inv.expr && (expr_calc_value(sym->rev_dep_inv.expr) == yes)) {
+                       newval.tri = no;
                } else if (E_OR(sym->visible, sym->rev_dep.tri) != no) {
                        sym->flags |= SYMBOL_WRITE;
                        if (sym_has_value(sym))
                } else if (E_OR(sym->visible, sym->rev_dep.tri) != no) {
                        sym->flags |= SYMBOL_WRITE;
                        if (sym_has_value(sym))
@@ -354,6 +364,7 @@ void sym_calc_value(struct symbol *sym)
 
        if (memcmp(&oldval, &sym->curr, sizeof(oldval)))
                sym_set_changed(sym);
 
        if (memcmp(&oldval, &sym->curr, sizeof(oldval)))
                sym_set_changed(sym);
+
        if (modules_sym == sym)
                modules_val = modules_sym->curr.tri;
 
        if (modules_sym == sym)
                modules_val = modules_sym->curr.tri;
 
@@ -805,7 +816,7 @@ struct symbol *sym_check_deps(struct symbol *sym)
                goto out;
 
        for (prop = sym->prop; prop; prop = prop->next) {
                goto out;
 
        for (prop = sym->prop; prop; prop = prop->next) {
-               if (prop->type == P_CHOICE || prop->type == P_SELECT)
+               if (prop->type == P_CHOICE || prop->type == P_SELECT || prop->type == P_DESELECT)
                        continue;
                sym2 = sym_check_expr_deps(prop->visible.expr);
                if (sym2)
                        continue;
                sym2 = sym_check_expr_deps(prop->visible.expr);
                if (sym2)
@@ -873,6 +884,8 @@ const char *prop_get_type_name(enum prop_type type)
                return "choice";
        case P_SELECT:
                return "select";
                return "choice";
        case P_SELECT:
                return "select";
+       case P_DESELECT:
+               return "deselect";
        case P_RANGE:
                return "range";
        case P_UNKNOWN:
        case P_RANGE:
                return "range";
        case P_UNKNOWN: