Commit 8a36b98f authored by Roman Zippel's avatar Roman Zippel Committed by Ben Collins

[PATCH] choice handling fixes

A few choice handling fixes:
- only visible choice values define the new state of the complete choice
- improve handling of choices without visible value
- two new warnings
parent 89490f20
......@@ -286,10 +286,14 @@ static int conf_choice(struct menu *menu)
break;
}
} else {
sym->user = sym->curr;
if (sym->curr.tri == mod) {
switch (sym_get_tristate_value(sym)) {
case no:
return 1;
case mod:
printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
return 0;
case yes:
break;
}
}
......
......@@ -243,6 +243,7 @@ int conf_read(const char *name)
prop = sym_get_choice_prop(sym);
sym->flags &= ~SYMBOL_NEW;
for (e = prop->expr; e; e = e->left.expr)
if (e->right.sym->visible != no)
sym->flags |= e->right.sym->flags & SYMBOL_NEW;
}
......
......@@ -221,9 +221,16 @@ void menu_finalize(struct menu *parent)
for (menu = parent->list; menu; menu = menu->next) {
if (sym && sym_is_choice(sym) && menu->sym) {
menu->sym->flags |= SYMBOL_CHOICEVAL;
if (!menu->prompt)
fprintf(stderr, "%s:%d:warning: choice value must have a prompt\n",
menu->file->name, menu->lineno);
for (prop = menu->sym->prop; prop; prop = prop->next) {
if (prop->type != P_DEFAULT)
continue;
if (prop->type == P_PROMPT && prop->menu != menu) {
fprintf(stderr, "%s:%d:warning: choice values currently only support a single prompt\n",
prop->file->name, prop->lineno);
}
if (prop->type == P_DEFAULT)
fprintf(stderr, "%s:%d:warning: defaults for choice values not supported\n",
prop->file->name, prop->lineno);
}
......@@ -311,14 +318,6 @@ bool menu_is_visible(struct menu *menu)
} else
visible = menu->prompt->visible.tri = expr_calc_value(menu->prompt->visible.expr);
if (sym && sym_is_choice(sym)) {
for (child = menu->list; child; child = child->next)
if (menu_is_visible(child))
break;
if (!child)
return false;
}
if (visible != no)
return true;
if (!sym || sym_get_tristate_value(menu->sym) == no)
......
......@@ -201,6 +201,9 @@ static struct symbol *sym_calc_choice(struct symbol *sym)
if (def_sym->visible != no)
return def_sym;
}
/* no choice? reset tristate value */
sym->curr.tri = no;
return NULL;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment