Lines Matching +full:tri +full:- +full:default +full:- +full:2

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
47 enum symbol_type type = sym->type;
74 * sym_get_prompt_menu - get the menu entry with a prompt
84 list_for_each_entry(m, &sym->menus, link)
85 if (m->prompt)
92 * sym_get_choice_menu - get the parent choice menu if present
111 menu = menu->parent;
112 } while (menu && !menu->sym);
114 if (menu && menu->sym && sym_is_choice(menu->sym))
125 prop->visible.tri = expr_calc_value(prop->visible.expr);
126 if (prop->visible.tri != no)
137 prop->visible.tri = expr_calc_value(prop->visible.expr);
138 if (prop->visible.tri != no)
147 switch (sym->type) {
154 default:
157 return strtoll(sym->curr.val, NULL, base);
167 switch (sym->type) {
174 default:
180 val = strtoll(sym->curr.val, NULL, base);
181 range_sym = prop->expr->left.sym;
184 range_sym = prop->expr->right.sym;
189 sym->curr.val = range_sym->curr.val;
196 list_for_each_entry(menu, &sym->menus, link)
197 menu->flags |= MENU_CHANGED;
211 tristate tri;
214 tri = no;
216 prop->visible.tri = expr_calc_value(prop->visible.expr);
217 tri = EXPR_OR(tri, prop->visible.tri);
219 if (tri == mod && (sym->type != S_TRISTATE || modules_val == no))
220 tri = yes;
221 if (sym->visible != tri) {
222 sym->visible = tri;
228 tri = yes;
229 if (sym->dir_dep.expr)
230 tri = expr_calc_value(sym->dir_dep.expr);
231 if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
232 tri = yes;
233 if (sym->dir_dep.tri != tri) {
234 sym->dir_dep.tri = tri;
237 tri = no;
238 if (sym->rev_dep.expr)
239 tri = expr_calc_value(sym->rev_dep.expr);
240 if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
241 tri = yes;
242 if (sym->rev_dep.tri != tri) {
243 sym->rev_dep.tri = tri;
246 tri = no;
247 if (sym->implied.expr)
248 tri = expr_calc_value(sym->implied.expr);
249 if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
250 tri = yes;
251 if (sym->implied.tri != tri) {
252 sym->implied.tri = tri;
258 * Find the default symbol for a choice.
259 * First try the default values for the choice symbol
270 for_all_defaults(choice->sym, prop) {
271 prop->visible.tri = expr_calc_value(prop->visible.expr);
272 if (prop->visible.tri == no)
275 if (def_sym->visible != no)
281 if (menu->sym && menu->sym->visible != no)
282 return menu->sym;
289 * sym_calc_choice - calculate symbol values in a choice
302 list_for_each_entry(sym, &choice->choice_members, choice_link) {
304 if (sym->visible == no)
308 if (sym_has_value(sym) && sym->def[S_DEF_USER].tri == yes) {
315 * If 'y' is not found in the user input, use the default, unless it is
320 if (res && sym_has_value(res) && res->def[S_DEF_USER].tri == no)
324 /* Still not found. Pick up the first visible, user-unspecified symbol. */
327 sym = menu->sym;
329 if (!sym || sym->visible == no || sym_has_value(sym))
342 list_for_each_entry_reverse(sym, &choice->choice_members,
344 if (sym->visible == no)
355 sym = menu->sym;
357 if (!sym || sym->visible == no)
362 if (sym->curr.tri != val)
365 sym->curr.tri = val;
366 sym->flags |= SYMBOL_VALID | SYMBOL_WRITE;
378 sym->name);
381 sym->dir_dep.tri == mod ? 'm' : 'n');
382 expr_gstr_print(sym->dir_dep.expr, &gs);
385 expr_gstr_print_revdep(sym->rev_dep.expr, &gs, yes,
387 expr_gstr_print_revdep(sym->rev_dep.expr, &gs, mod,
411 if (sym->flags & SYMBOL_VALID)
414 sym->flags |= SYMBOL_VALID;
416 oldval = sym->curr;
418 newval.tri = no;
420 switch (sym->type) {
434 default:
435 sym->curr.val = sym->name;
436 sym->curr.tri = no;
439 sym->flags &= ~SYMBOL_WRITE;
443 if (sym->visible != no)
444 sym->flags |= SYMBOL_WRITE;
446 /* set default if recursively called */
447 sym->curr = newval;
456 newval.tri = sym->curr.tri;
458 if (sym->visible != no) {
460 * if available, otherwise try the default value
463 newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri,
464 sym->visible);
468 if (sym->rev_dep.tri != no)
469 sym->flags |= SYMBOL_WRITE;
473 newval.tri = EXPR_AND(expr_calc_value(prop->expr),
474 prop->visible.tri);
475 if (newval.tri != no)
476 sym->flags |= SYMBOL_WRITE;
478 if (sym->implied.tri != no) {
479 sym->flags |= SYMBOL_WRITE;
480 newval.tri = EXPR_OR(newval.tri, sym->implied.tri);
481 newval.tri = EXPR_AND(newval.tri,
482 sym->dir_dep.tri);
486 if (sym->dir_dep.tri < sym->rev_dep.tri)
488 newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
490 if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN)
491 newval.tri = yes;
496 if (sym->visible != no && sym_has_value(sym)) {
497 newval.val = sym->def[S_DEF_USER].val;
504 sym->flags |= SYMBOL_WRITE;
506 newval.val = ds->curr.val;
510 default:
514 sym->curr = newval;
517 if (memcmp(&oldval, &sym->curr, sizeof(oldval))) {
521 modules_val = modules_sym->curr.tri;
526 sym->flags &= ~SYMBOL_WRITE;
534 sym->flags &= ~SYMBOL_VALID;
544 if (sym->visible == no)
552 if (sym->visible <= sym->rev_dep.tri)
554 return val >= sym->rev_dep.tri && val <= sym->visible;
564 if (!(sym->flags & SYMBOL_DEF_USER) || sym->def[S_DEF_USER].tri != val) {
565 sym->def[S_DEF_USER].tri = val;
566 sym->flags |= SYMBOL_DEF_USER;
577 * choice_set_value - set the user input to a choice
590 if (!menu->sym)
593 if (menu->sym->visible == no)
596 val = menu->sym == sym ? yes : no;
598 if (menu->sym->curr.tri != val)
601 menu->sym->def[S_DEF_USER].tri = val;
602 menu->sym->flags |= SYMBOL_DEF_USER;
612 list_move(&menu->sym->choice_link, &choice->choice_members);
653 switch (sym->type) {
658 if (ch == '-')
671 str += 2;
687 default:
697 switch (sym->type) {
707 return val >= sym_get_range_val(prop->expr->left.sym, 10) &&
708 val <= sym_get_range_val(prop->expr->right.sym, 10);
716 return val >= sym_get_range_val(prop->expr->left.sym, 16) &&
717 val <= sym_get_range_val(prop->expr->right.sym, 16);
729 default:
740 switch (sym->type) {
752 default:
759 if (!(sym->flags & SYMBOL_DEF_USER)) {
760 sym->flags |= SYMBOL_DEF_USER;
764 oldval = sym->def[S_DEF_USER].val;
766 if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
767 size += 2;
768 sym->def[S_DEF_USER].val = val = xmalloc(size);
772 sym->def[S_DEF_USER].val = val = xmalloc(size);
784 * Find the default value associated to a symbol.
787 * If the symbol does not have any default then fallback
788 * to the fixed default values.
799 val = symbol_no.curr.tri;
801 /* If symbol has a default value look it up */
804 switch (sym->type) {
808 val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri);
810 default:
813 * where a default value is further limited by
819 str = (const char *)ds->curr.val;
825 val = EXPR_OR(val, sym->rev_dep.tri);
829 if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no)
833 if (sym->type == S_BOOLEAN && val == mod)
836 /* adjust the default value if this symbol is implied by another */
837 if (val < sym->implied.tri)
838 val = sym->implied.tri;
840 switch (sym->type) {
856 default:
866 switch (sym->type) {
879 default:
882 return (const char *)sym->curr.val;
887 return !sym_is_choice(sym) && sym->visible > sym->rev_dep.tri;
892 return !list_empty(&sym->choice_link);
914 if (symbol->name &&
915 !strcmp(symbol->name, name) &&
916 (flags ? symbol->flags & flags
917 : !(symbol->flags & SYMBOL_CONST)))
928 symbol->name = new_name;
929 symbol->type = S_UNKNOWN;
930 symbol->flags = flags;
931 INIT_LIST_HEAD(&symbol->menus);
932 INIT_LIST_HEAD(&symbol->choice_link);
934 hash_add(sym_hashtable, &symbol->node, hash);
957 if (symbol->name &&
958 !strcmp(symbol->name, name) &&
959 !(symbol->flags & SYMBOL_CONST))
972 * - first, symbols that match exactly
973 * - then, alphabetical sort
982 * - if matched length on symbol s1 is the length of that symbol,
984 * - if matched length on symbol s2 is the length of that symbol,
990 exact1 = (s1->eo - s1->so) == strlen(s1->sym->name);
991 exact2 = (s2->eo - s2->so) == strlen(s2->sym->name);
993 return -1;
998 return strcmp(s1->sym->name, s2->sym->name);
1017 if (sym->flags & SYMBOL_CONST || !sym->name)
1019 if (regexec(&re, sym->name, 1, match, 0))
1071 check_top->next = stack;
1072 stack->prev = check_top;
1073 stack->sym = sym;
1079 check_top = check_top->prev;
1081 check_top->next = NULL;
1087 * the ->prev pointer to locate the bottom of the stack.
1100 last_sym = choice->sym;
1103 for (stack = check_top; stack != NULL; stack = stack->prev)
1104 if (stack->sym == last_sym)
1111 for (; stack; stack = stack->next) {
1112 sym = stack->sym;
1113 next_sym = stack->next ? stack->next->sym : last_sym;
1114 type = stack->prop ? stack->prop->type : P_UNKNOWN;
1116 if (stack->sym == last_sym)
1120 choice = list_first_entry(&next_sym->menus, struct menu, link);
1123 sym->name ? sym->name : "<choice>",
1124 choice->filename, choice->lineno);
1125 } else if (stack->expr == &sym->dir_dep.expr) {
1127 sym->name ? sym->name : "<choice>",
1128 next_sym->name);
1129 } else if (stack->expr == &sym->rev_dep.expr) {
1131 sym->name, next_sym->name);
1132 } else if (stack->expr == &sym->implied.expr) {
1134 sym->name, next_sym->name);
1135 } else if (stack->expr) {
1137 sym->name ? sym->name : "<choice>",
1139 next_sym->name);
1142 sym->name ? sym->name : "<choice>",
1144 next_sym->name);
1149 "For a resolution refer to Documentation/kbuild/kconfig-language.rst\n"
1163 switch (e->type) {
1166 sym = sym_check_expr_deps(e->left.expr);
1169 return sym_check_expr_deps(e->right.expr);
1171 return sym_check_expr_deps(e->left.expr);
1178 sym = sym_check_deps(e->left.sym);
1181 return sym_check_deps(e->right.sym);
1183 return sym_check_deps(e->left.sym);
1184 default:
1187 fprintf(stderr, "Oops! How to check %d?\n", e->type);
1200 stack.expr = &sym->dir_dep.expr;
1201 sym2 = sym_check_expr_deps(sym->dir_dep.expr);
1205 stack.expr = &sym->rev_dep.expr;
1206 sym2 = sym_check_expr_deps(sym->rev_dep.expr);
1210 stack.expr = &sym->implied.expr;
1211 sym2 = sym_check_expr_deps(sym->implied.expr);
1217 for (prop = sym->prop; prop; prop = prop->next) {
1218 if (prop->type == P_SELECT || prop->type == P_IMPLY)
1221 sym2 = sym_check_expr_deps(prop->visible.expr);
1224 if (prop->type != P_DEFAULT || sym_is_choice(sym))
1226 stack.expr = &prop->expr;
1227 sym2 = sym_check_expr_deps(prop->expr);
1247 choice_menu = list_first_entry(&choice->menus, struct menu, link);
1250 if (menu->sym)
1251 menu->sym->flags |= SYMBOL_CHECK | SYMBOL_CHECKED;
1254 choice->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
1256 choice->flags &= ~SYMBOL_CHECK;
1261 if (!menu->sym)
1263 sym2 = sym_check_sym_deps(menu->sym);
1269 if (menu->sym)
1270 menu->sym->flags &= ~SYMBOL_CHECK;
1290 if (sym->flags & SYMBOL_CHECK) {
1294 if (sym->flags & SYMBOL_CHECKED)
1303 sym2 = sym_check_deps(choice->sym);
1308 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
1310 sym->flags &= ~SYMBOL_CHECK;
1318 if (prop->expr && prop->expr->type == E_SYMBOL)
1319 return prop->expr->left.sym;
1333 return "default";