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; in sym_get_type()
74 * sym_get_choice_menu - get the parent choice menu if present
89 list_for_each_entry(m, &sym->menus, link) in sym_get_choice_menu()
90 if (m->prompt) { in sym_get_choice_menu()
99 menu = menu->parent; in sym_get_choice_menu()
100 } while (menu && !menu->sym); in sym_get_choice_menu()
102 if (menu && menu->sym && sym_is_choice(menu->sym)) in sym_get_choice_menu()
113 prop->visible.tri = expr_calc_value(prop->visible.expr); in sym_get_default_prop()
114 if (prop->visible.tri != no) in sym_get_default_prop()
125 prop->visible.tri = expr_calc_value(prop->visible.expr); in sym_get_range_prop()
126 if (prop->visible.tri != no) in sym_get_range_prop()
135 switch (sym->type) { in sym_get_range_val()
142 default: in sym_get_range_val()
145 return strtoll(sym->curr.val, NULL, base); in sym_get_range_val()
155 switch (sym->type) { in sym_validate_range()
162 default: in sym_validate_range()
168 val = strtoll(sym->curr.val, NULL, base); in sym_validate_range()
169 range_sym = prop->expr->left.sym; in sym_validate_range()
172 range_sym = prop->expr->right.sym; in sym_validate_range()
177 sym->curr.val = range_sym->curr.val; in sym_validate_range()
184 list_for_each_entry(menu, &sym->menus, link) in sym_set_changed()
185 menu->flags |= MENU_CHANGED; in sym_set_changed()
199 tristate tri; in sym_calc_visibility() local
202 tri = no; in sym_calc_visibility()
204 prop->visible.tri = expr_calc_value(prop->visible.expr); in sym_calc_visibility()
205 tri = EXPR_OR(tri, prop->visible.tri); in sym_calc_visibility()
207 if (tri == mod && (sym->type != S_TRISTATE || modules_val == no)) in sym_calc_visibility()
208 tri = yes; in sym_calc_visibility()
209 if (sym->visible != tri) { in sym_calc_visibility()
210 sym->visible = tri; in sym_calc_visibility()
216 tri = yes; in sym_calc_visibility()
217 if (sym->dir_dep.expr) in sym_calc_visibility()
218 tri = expr_calc_value(sym->dir_dep.expr); in sym_calc_visibility()
219 if (tri == mod && sym_get_type(sym) == S_BOOLEAN) in sym_calc_visibility()
220 tri = yes; in sym_calc_visibility()
221 if (sym->dir_dep.tri != tri) { in sym_calc_visibility()
222 sym->dir_dep.tri = tri; in sym_calc_visibility()
225 tri = no; in sym_calc_visibility()
226 if (sym->rev_dep.expr) in sym_calc_visibility()
227 tri = expr_calc_value(sym->rev_dep.expr); in sym_calc_visibility()
228 if (tri == mod && sym_get_type(sym) == S_BOOLEAN) in sym_calc_visibility()
229 tri = yes; in sym_calc_visibility()
230 if (sym->rev_dep.tri != tri) { in sym_calc_visibility()
231 sym->rev_dep.tri = tri; in sym_calc_visibility()
234 tri = no; in sym_calc_visibility()
235 if (sym->implied.expr) in sym_calc_visibility()
236 tri = expr_calc_value(sym->implied.expr); in sym_calc_visibility()
237 if (tri == mod && sym_get_type(sym) == S_BOOLEAN) in sym_calc_visibility()
238 tri = yes; in sym_calc_visibility()
239 if (sym->implied.tri != tri) { in sym_calc_visibility()
240 sym->implied.tri = tri; in sym_calc_visibility()
246 * Find the default symbol for a choice.
247 * First try the default values for the choice symbol
258 for_all_defaults(choice->sym, prop) { in sym_choice_default()
259 prop->visible.tri = expr_calc_value(prop->visible.expr); in sym_choice_default()
260 if (prop->visible.tri == no) in sym_choice_default()
263 if (def_sym->visible != no) in sym_choice_default()
269 if (menu->sym && menu->sym->visible != no) in sym_choice_default()
270 return menu->sym; in sym_choice_default()
277 * sym_calc_choice - calculate symbol values in a choice
290 list_for_each_entry(sym, &choice->choice_members, choice_link) { in sym_calc_choice()
292 if (sym->visible == no) in sym_calc_choice()
296 if (sym_has_value(sym) && sym->def[S_DEF_USER].tri == yes) { in sym_calc_choice()
303 * If 'y' is not found in the user input, use the default, unless it is in sym_calc_choice()
308 if (res && sym_has_value(res) && res->def[S_DEF_USER].tri == no) in sym_calc_choice()
312 /* Still not found. Pick up the first visible, user-unspecified symbol. */ in sym_calc_choice()
315 sym = menu->sym; in sym_calc_choice()
317 if (!sym || sym->visible == no || sym_has_value(sym)) in sym_calc_choice()
330 list_for_each_entry_reverse(sym, &choice->choice_members, in sym_calc_choice()
332 if (sym->visible == no) in sym_calc_choice()
343 sym = menu->sym; in sym_calc_choice()
345 if (!sym || sym->visible == no) in sym_calc_choice()
350 if (sym->curr.tri != val) in sym_calc_choice()
353 sym->curr.tri = val; in sym_calc_choice()
354 sym->flags |= SYMBOL_VALID | SYMBOL_WRITE; in sym_calc_choice()
366 sym->name); in sym_warn_unmet_dep()
369 sym->dir_dep.tri == mod ? 'm' : 'n'); in sym_warn_unmet_dep()
370 expr_gstr_print(sym->dir_dep.expr, &gs); in sym_warn_unmet_dep()
373 expr_gstr_print_revdep(sym->rev_dep.expr, &gs, yes, in sym_warn_unmet_dep()
375 expr_gstr_print_revdep(sym->rev_dep.expr, &gs, mod, in sym_warn_unmet_dep()
398 if (sym->flags & SYMBOL_VALID) in sym_calc_value()
401 sym->flags |= SYMBOL_VALID; in sym_calc_value()
403 oldval = sym->curr; in sym_calc_value()
405 newval.tri = no; in sym_calc_value()
407 switch (sym->type) { in sym_calc_value()
421 default: in sym_calc_value()
422 sym->curr.val = sym->name; in sym_calc_value()
423 sym->curr.tri = no; in sym_calc_value()
426 sym->flags &= ~SYMBOL_WRITE; in sym_calc_value()
430 if (sym->visible != no) in sym_calc_value()
431 sym->flags |= SYMBOL_WRITE; in sym_calc_value()
433 /* set default if recursively called */ in sym_calc_value()
434 sym->curr = newval; in sym_calc_value()
443 newval.tri = sym->curr.tri; in sym_calc_value()
445 if (sym->visible != no) { in sym_calc_value()
447 * if available, otherwise try the default value in sym_calc_value()
450 newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri, in sym_calc_value()
451 sym->visible); in sym_calc_value()
455 if (sym->rev_dep.tri != no) in sym_calc_value()
456 sym->flags |= SYMBOL_WRITE; in sym_calc_value()
460 newval.tri = EXPR_AND(expr_calc_value(prop->expr), in sym_calc_value()
461 prop->visible.tri); in sym_calc_value()
462 if (newval.tri != no) in sym_calc_value()
463 sym->flags |= SYMBOL_WRITE; in sym_calc_value()
465 if (sym->implied.tri != no) { in sym_calc_value()
466 sym->flags |= SYMBOL_WRITE; in sym_calc_value()
467 newval.tri = EXPR_OR(newval.tri, sym->implied.tri); in sym_calc_value()
468 newval.tri = EXPR_AND(newval.tri, in sym_calc_value()
469 sym->dir_dep.tri); in sym_calc_value()
473 if (sym->dir_dep.tri < sym->rev_dep.tri) in sym_calc_value()
475 newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); in sym_calc_value()
477 if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN) in sym_calc_value()
478 newval.tri = yes; in sym_calc_value()
483 if (sym->visible != no && sym_has_value(sym)) { in sym_calc_value()
484 newval.val = sym->def[S_DEF_USER].val; in sym_calc_value()
491 sym->flags |= SYMBOL_WRITE; in sym_calc_value()
493 newval.val = ds->curr.val; in sym_calc_value()
497 default: in sym_calc_value()
501 sym->curr = newval; in sym_calc_value()
504 if (memcmp(&oldval, &sym->curr, sizeof(oldval))) { in sym_calc_value()
508 modules_val = modules_sym->curr.tri; in sym_calc_value()
513 sym->flags &= ~SYMBOL_WRITE; in sym_calc_value()
521 sym->flags &= ~SYMBOL_VALID; in sym_clear_all_valid()
531 if (sym->visible == no) in sym_tristate_within_range()
539 if (sym->visible <= sym->rev_dep.tri) in sym_tristate_within_range()
541 return val >= sym->rev_dep.tri && val <= sym->visible; in sym_tristate_within_range()
551 if (!(sym->flags & SYMBOL_DEF_USER) || sym->def[S_DEF_USER].tri != val) { in sym_set_tristate_value()
552 sym->def[S_DEF_USER].tri = val; in sym_set_tristate_value()
553 sym->flags |= SYMBOL_DEF_USER; in sym_set_tristate_value()
564 * choice_set_value - set the user input to a choice
577 if (!menu->sym) in choice_set_value()
580 if (menu->sym->visible == no) in choice_set_value()
583 val = menu->sym == sym ? yes : no; in choice_set_value()
585 if (menu->sym->curr.tri != val) in choice_set_value()
588 menu->sym->def[S_DEF_USER].tri = val; in choice_set_value()
589 menu->sym->flags |= SYMBOL_DEF_USER; in choice_set_value()
599 list_move(&menu->sym->choice_link, &choice->choice_members); in choice_set_value()
640 switch (sym->type) { in sym_string_valid()
645 if (ch == '-') in sym_string_valid()
658 str += 2; in sym_string_valid()
674 default: in sym_string_valid()
684 switch (sym->type) { in sym_string_within_range()
694 return val >= sym_get_range_val(prop->expr->left.sym, 10) && in sym_string_within_range()
695 val <= sym_get_range_val(prop->expr->right.sym, 10); in sym_string_within_range()
703 return val >= sym_get_range_val(prop->expr->left.sym, 16) && in sym_string_within_range()
704 val <= sym_get_range_val(prop->expr->right.sym, 16); in sym_string_within_range()
716 default: in sym_string_within_range()
727 switch (sym->type) { in sym_set_string_value()
739 default: in sym_set_string_value()
746 if (!(sym->flags & SYMBOL_DEF_USER)) { in sym_set_string_value()
747 sym->flags |= SYMBOL_DEF_USER; in sym_set_string_value()
751 oldval = sym->def[S_DEF_USER].val; in sym_set_string_value()
753 if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) { in sym_set_string_value()
754 size += 2; in sym_set_string_value()
755 sym->def[S_DEF_USER].val = val = xmalloc(size); in sym_set_string_value()
759 sym->def[S_DEF_USER].val = val = xmalloc(size); in sym_set_string_value()
771 * Find the default value associated to a symbol.
774 * If the symbol does not have any default then fallback
775 * to the fixed default values.
786 val = symbol_no.curr.tri; in sym_get_string_default()
788 /* If symbol has a default value look it up */ in sym_get_string_default()
791 switch (sym->type) { in sym_get_string_default()
795 val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri); in sym_get_string_default()
797 default: in sym_get_string_default()
800 * where a default value is further limited by in sym_get_string_default()
806 str = (const char *)ds->curr.val; in sym_get_string_default()
812 val = EXPR_OR(val, sym->rev_dep.tri); in sym_get_string_default()
816 if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no) in sym_get_string_default()
820 if (sym->type == S_BOOLEAN && val == mod) in sym_get_string_default()
823 /* adjust the default value if this symbol is implied by another */ in sym_get_string_default()
824 if (val < sym->implied.tri) in sym_get_string_default()
825 val = sym->implied.tri; in sym_get_string_default()
827 switch (sym->type) { in sym_get_string_default()
843 default: in sym_get_string_default()
853 switch (sym->type) { in sym_get_string_value()
866 default: in sym_get_string_value()
869 return (const char *)sym->curr.val; in sym_get_string_value()
874 return !sym_is_choice(sym) && sym->visible > sym->rev_dep.tri; in sym_is_changeable()
879 return !list_empty(&sym->choice_link); in sym_is_choice_value()
901 if (symbol->name && in sym_lookup()
902 !strcmp(symbol->name, name) && in sym_lookup()
903 (flags ? symbol->flags & flags in sym_lookup()
904 : !(symbol->flags & SYMBOL_CONST))) in sym_lookup()
915 symbol->name = new_name; in sym_lookup()
916 symbol->type = S_UNKNOWN; in sym_lookup()
917 symbol->flags = flags; in sym_lookup()
918 INIT_LIST_HEAD(&symbol->menus); in sym_lookup()
919 INIT_LIST_HEAD(&symbol->choice_link); in sym_lookup()
921 hash_add(sym_hashtable, &symbol->node, hash); in sym_lookup()
944 if (symbol->name && in sym_find()
945 !strcmp(symbol->name, name) && in sym_find()
946 !(symbol->flags & SYMBOL_CONST)) in sym_find()
959 * - first, symbols that match exactly
960 * - then, alphabetical sort
969 * - if matched length on symbol s1 is the length of that symbol, in sym_rel_comp()
971 * - if matched length on symbol s2 is the length of that symbol, in sym_rel_comp()
977 exact1 = (s1->eo - s1->so) == strlen(s1->sym->name); in sym_rel_comp()
978 exact2 = (s2->eo - s2->so) == strlen(s2->sym->name); in sym_rel_comp()
980 return -1; in sym_rel_comp()
985 return strcmp(s1->sym->name, s2->sym->name); in sym_rel_comp()
1004 if (sym->flags & SYMBOL_CONST || !sym->name) in sym_re_search()
1006 if (regexec(&re, sym->name, 1, match, 0)) in sym_re_search()
1058 check_top->next = stack; in dep_stack_insert()
1059 stack->prev = check_top; in dep_stack_insert()
1060 stack->sym = sym; in dep_stack_insert()
1066 check_top = check_top->prev; in dep_stack_remove()
1068 check_top->next = NULL; in dep_stack_remove()
1074 * the ->prev pointer to locate the bottom of the stack.
1087 last_sym = choice->sym; in sym_check_print_recursive()
1090 for (stack = check_top; stack != NULL; stack = stack->prev) in sym_check_print_recursive()
1091 if (stack->sym == last_sym) in sym_check_print_recursive()
1098 for (; stack; stack = stack->next) { in sym_check_print_recursive()
1099 sym = stack->sym; in sym_check_print_recursive()
1100 next_sym = stack->next ? stack->next->sym : last_sym; in sym_check_print_recursive()
1101 type = stack->prop ? stack->prop->type : P_UNKNOWN; in sym_check_print_recursive()
1103 if (stack->sym == last_sym) in sym_check_print_recursive()
1107 choice = list_first_entry(&next_sym->menus, struct menu, link); in sym_check_print_recursive()
1110 sym->name ? sym->name : "<choice>", in sym_check_print_recursive()
1111 choice->filename, choice->lineno); in sym_check_print_recursive()
1112 } else if (stack->expr == &sym->dir_dep.expr) { in sym_check_print_recursive()
1114 sym->name ? sym->name : "<choice>", in sym_check_print_recursive()
1115 next_sym->name); in sym_check_print_recursive()
1116 } else if (stack->expr == &sym->rev_dep.expr) { in sym_check_print_recursive()
1118 sym->name, next_sym->name); in sym_check_print_recursive()
1119 } else if (stack->expr == &sym->implied.expr) { in sym_check_print_recursive()
1121 sym->name, next_sym->name); in sym_check_print_recursive()
1122 } else if (stack->expr) { in sym_check_print_recursive()
1124 sym->name ? sym->name : "<choice>", in sym_check_print_recursive()
1126 next_sym->name); in sym_check_print_recursive()
1129 sym->name ? sym->name : "<choice>", in sym_check_print_recursive()
1131 next_sym->name); in sym_check_print_recursive()
1136 "For a resolution refer to Documentation/kbuild/kconfig-language.rst\n" in sym_check_print_recursive()
1150 switch (e->type) { in sym_check_expr_deps()
1153 sym = sym_check_expr_deps(e->left.expr); in sym_check_expr_deps()
1156 return sym_check_expr_deps(e->right.expr); in sym_check_expr_deps()
1158 return sym_check_expr_deps(e->left.expr); in sym_check_expr_deps()
1165 sym = sym_check_deps(e->left.sym); in sym_check_expr_deps()
1168 return sym_check_deps(e->right.sym); in sym_check_expr_deps()
1170 return sym_check_deps(e->left.sym); in sym_check_expr_deps()
1171 default: in sym_check_expr_deps()
1174 fprintf(stderr, "Oops! How to check %d?\n", e->type); in sym_check_expr_deps()
1187 stack.expr = &sym->dir_dep.expr; in sym_check_sym_deps()
1188 sym2 = sym_check_expr_deps(sym->dir_dep.expr); in sym_check_sym_deps()
1192 stack.expr = &sym->rev_dep.expr; in sym_check_sym_deps()
1193 sym2 = sym_check_expr_deps(sym->rev_dep.expr); in sym_check_sym_deps()
1197 stack.expr = &sym->implied.expr; in sym_check_sym_deps()
1198 sym2 = sym_check_expr_deps(sym->implied.expr); in sym_check_sym_deps()
1204 for (prop = sym->prop; prop; prop = prop->next) { in sym_check_sym_deps()
1205 if (prop->type == P_SELECT || prop->type == P_IMPLY) in sym_check_sym_deps()
1208 sym2 = sym_check_expr_deps(prop->visible.expr); in sym_check_sym_deps()
1211 if (prop->type != P_DEFAULT || sym_is_choice(sym)) in sym_check_sym_deps()
1213 stack.expr = &prop->expr; in sym_check_sym_deps()
1214 sym2 = sym_check_expr_deps(prop->expr); in sym_check_sym_deps()
1234 choice_menu = list_first_entry(&choice->menus, struct menu, link); in sym_check_choice_deps()
1237 if (menu->sym) in sym_check_choice_deps()
1238 menu->sym->flags |= SYMBOL_CHECK | SYMBOL_CHECKED; in sym_check_choice_deps()
1241 choice->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); in sym_check_choice_deps()
1243 choice->flags &= ~SYMBOL_CHECK; in sym_check_choice_deps()
1248 if (!menu->sym) in sym_check_choice_deps()
1250 sym2 = sym_check_sym_deps(menu->sym); in sym_check_choice_deps()
1256 if (menu->sym) in sym_check_choice_deps()
1257 menu->sym->flags &= ~SYMBOL_CHECK; in sym_check_choice_deps()
1277 if (sym->flags & SYMBOL_CHECK) { in sym_check_deps()
1281 if (sym->flags & SYMBOL_CHECKED) in sym_check_deps()
1290 sym2 = sym_check_deps(choice->sym); in sym_check_deps()
1295 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); in sym_check_deps()
1297 sym->flags &= ~SYMBOL_CHECK; in sym_check_deps()
1305 if (prop->expr && prop->expr->type == E_SYMBOL) in prop_get_symbol()
1306 return prop->expr->left.sym; in prop_get_symbol()
1320 return "default"; in prop_get_type_name()