13 static const char nohelp_text[] =
"There is no help available for this option.";
16 static struct menu **last_entry_ptr;
31 static void prop_warn(
struct property *prop,
const char *
fmt, ...)
43 current_entry = current_menu = &
rootmenu;
51 menu =
malloc(
sizeof(*menu));
52 memset(menu, 0,
sizeof(*menu));
54 menu->
parent = current_menu;
58 *last_entry_ptr = menu;
59 last_entry_ptr = &menu->
next;
72 last_entry_ptr = ¤t_entry->
list;
73 return current_menu = current_entry;
78 last_entry_ptr = ¤t_menu->
next;
79 current_menu = current_menu->parent;
82 static struct expr *menu_check_dep(
struct expr *
e)
89 e->left.expr = menu_check_dep(e->left.expr);
93 e->left.expr = menu_check_dep(e->left.expr);
109 current_entry->dep =
expr_alloc_and(current_entry->dep, menu_check_dep(dep));
114 struct symbol *sym = current_entry->sym;
116 if (sym->
type == type)
122 menu_warn(current_entry,
"type of '%s' redefined from '%s' to '%s'",
131 prop->
menu = current_entry;
133 prop->
visible.expr = menu_check_dep(dep);
137 prop_warn(prop,
"leading whitespace ignored");
141 if (current_entry->prompt && current_entry != &
rootmenu)
142 prop_warn(prop,
"prompt redefined");
157 current_entry->prompt = prop;
171 current_entry->visibility =
expr_alloc_and(current_entry->visibility,
198 zconf_error(
"trying to redefine defconfig symbol");
206 static int menu_validate_number(
struct symbol *
sym,
struct symbol *sym2)
212 static void sym_check_prop(
struct symbol *
sym)
216 for (prop = sym->
prop; prop; prop = prop->
next) {
217 switch (prop->
type) {
222 "default for config symbol '%s'"
223 " must be a single symbol", sym->
name);
228 if (!menu_validate_number(sym, sym2))
230 "'%s': number is invalid",
238 "config symbol '%s' uses select, but is "
239 "not boolean or tristate", sym->
name);
244 "'%s' has wrong type. 'select' only "
245 "accept arguments of boolean and "
246 "tristate type", sym2->
name);
250 prop_warn(prop,
"range is only allowed "
251 "for int or hex symbols");
252 if (!menu_validate_number(sym, prop->
expr->left.sym) ||
253 !menu_validate_number(sym, prop->
expr->right.sym))
254 prop_warn(prop,
"range is invalid");
267 struct expr *parentdep, *basedep, *dep, *dep2, **ep;
271 if (sym && sym_is_choice(sym)) {
274 current_entry = parent;
275 for (menu = parent->
list; menu; menu = menu->
next) {
283 for (menu = parent->
list; menu; menu = menu->
next) {
284 current_entry = menu;
289 }
else if (parent->
prompt)
290 parentdep = parent->
prompt->visible.expr;
292 parentdep = parent->
dep;
294 for (menu = parent->
list; menu; menu = menu->
next) {
300 prop = menu->
sym->prop;
303 for (; prop; prop = prop->
next) {
304 if (prop->
menu != menu)
319 for (menu = parent->
list; menu; menu = menu->
next)
326 for (menu = parent->
next; menu; menu = menu->
next) {
337 if (!expr_is_yes(dep2)) {
355 for (menu = parent->
list; menu; menu = menu->
next) {
356 if (sym && sym_is_choice(sym) &&
357 menu->
sym && !sym_is_choice_value(menu->
sym)) {
358 current_entry = menu;
361 menu_warn(menu,
"choice value must have a prompt");
362 for (prop = menu->
sym->prop; prop; prop = prop->
next) {
364 prop_warn(prop,
"defaults for choice "
365 "values not supported");
366 if (prop->
menu == menu)
369 prop->
menu->parent->sym != sym)
370 prop_warn(prop,
"choice value used outside its choice group");
381 for (prop = menu->
sym->prop; prop; prop = prop->
next) {
382 if (prop->
menu != menu)
390 for (ep = &prop->
expr; *ep; ep = &(*ep)->left.expr)
393 (*ep)->right.sym = menu->
sym;
396 for (last_menu = menu->
list; ; last_menu = last_menu->
next) {
397 last_menu->
parent = parent;
398 if (!last_menu->
next)
409 menu_warn(parent,
"config symbol defined without type");
411 if (sym_is_choice(sym) && !parent->
prompt)
412 menu_warn(parent,
"choice must have a prompt");
419 if (sym && !sym_is_optional(sym) && parent->
prompt) {
450 visible = menu->
prompt->visible.tri;
457 if (!sym || sym_get_tristate_value(menu->
sym) ==
no)
460 for (child = menu->
list; child; child = child->
next) {
474 return menu->
prompt->text;
476 return menu->
sym->name;
510 static void get_prompt_str(
struct gstr *
r,
struct property *prop,
520 if (!expr_is_yes(prop->
visible.expr)) {
525 menu = prop->
menu->parent;
530 if (location ==
NULL && accessible)
533 if (head && location) {
547 if (list_empty(head))
558 for (j = 4; --i >= 0; j += 2) {
560 if (head && location && menu == location)
566 menu->
sym->name :
_(
"<choice>"),
583 if (sym && sym->
name) {
588 prop = sym_get_range_prop(sym);
597 get_prompt_str(r, prop, head);
623 for (i = 0; sym_arr && (sym = sym_arr[
i]); i++)
634 const char *help_text = nohelp_text;