Lines Matching refs:sym
38 static void sym_add_default(struct symbol *sym, const char *def) in sym_add_default() argument
40 struct property *prop = prop_alloc(P_DEFAULT, sym); in sym_add_default()
47 struct symbol *sym; in sym_init() local
57 sym = sym_lookup("UNAME_RELEASE", 0); in sym_init()
58 sym->type = S_STRING; in sym_init()
59 sym->flags |= SYMBOL_AUTO; in sym_init()
60 sym_add_default(sym, uts.release); in sym_init()
63 enum symbol_type sym_get_type(struct symbol *sym) in sym_get_type() argument
65 enum symbol_type type = sym->type; in sym_get_type()
68 if (sym_is_choice_value(sym) && sym->visible == yes) in sym_get_type()
97 struct property *sym_get_choice_prop(struct symbol *sym) in sym_get_choice_prop() argument
101 for_all_choices(sym, prop) in sym_get_choice_prop()
106 struct property *sym_get_env_prop(struct symbol *sym) in sym_get_env_prop() argument
110 for_all_properties(sym, prop, P_ENV) in sym_get_env_prop()
115 static struct property *sym_get_default_prop(struct symbol *sym) in sym_get_default_prop() argument
119 for_all_defaults(sym, prop) { in sym_get_default_prop()
127 static struct property *sym_get_range_prop(struct symbol *sym) in sym_get_range_prop() argument
131 for_all_properties(sym, prop, P_RANGE) { in sym_get_range_prop()
139 static long long sym_get_range_val(struct symbol *sym, int base) in sym_get_range_val() argument
141 sym_calc_value(sym); in sym_get_range_val()
142 switch (sym->type) { in sym_get_range_val()
152 return strtoll(sym->curr.val, NULL, base); in sym_get_range_val()
155 static void sym_validate_range(struct symbol *sym) in sym_validate_range() argument
162 switch (sym->type) { in sym_validate_range()
172 prop = sym_get_range_prop(sym); in sym_validate_range()
175 val = strtoll(sym->curr.val, NULL, base); in sym_validate_range()
176 val2 = sym_get_range_val(prop->expr->left.sym, base); in sym_validate_range()
178 val2 = sym_get_range_val(prop->expr->right.sym, base); in sym_validate_range()
182 if (sym->type == S_INT) in sym_validate_range()
186 sym->curr.val = xstrdup(str); in sym_validate_range()
189 static void sym_set_changed(struct symbol *sym) in sym_set_changed() argument
193 sym->flags |= SYMBOL_CHANGED; in sym_set_changed()
194 for (prop = sym->prop; prop; prop = prop->next) { in sym_set_changed()
202 struct symbol *sym; in sym_set_all_changed() local
205 for_all_symbols(i, sym) in sym_set_all_changed()
206 sym_set_changed(sym); in sym_set_all_changed()
209 static void sym_calc_visibility(struct symbol *sym) in sym_calc_visibility() argument
218 if (sym_is_choice_value(sym)) in sym_calc_visibility()
219 choice_sym = prop_get_symbol(sym_get_choice_prop(sym)); in sym_calc_visibility()
221 for_all_prompts(sym, prop) { in sym_calc_visibility()
228 if (choice_sym && sym->type == S_TRISTATE && in sym_calc_visibility()
234 if (tri == mod && (sym->type != S_TRISTATE || modules_val == no)) in sym_calc_visibility()
236 if (sym->visible != tri) { in sym_calc_visibility()
237 sym->visible = tri; in sym_calc_visibility()
238 sym_set_changed(sym); in sym_calc_visibility()
240 if (sym_is_choice_value(sym)) in sym_calc_visibility()
244 if (sym->dir_dep.expr) in sym_calc_visibility()
245 tri = expr_calc_value(sym->dir_dep.expr); in sym_calc_visibility()
246 if (tri == mod && sym_get_type(sym) == S_BOOLEAN) in sym_calc_visibility()
248 if (sym->dir_dep.tri != tri) { in sym_calc_visibility()
249 sym->dir_dep.tri = tri; in sym_calc_visibility()
250 sym_set_changed(sym); in sym_calc_visibility()
253 if (sym->rev_dep.expr) in sym_calc_visibility()
254 tri = expr_calc_value(sym->rev_dep.expr); in sym_calc_visibility()
255 if (tri == mod && sym_get_type(sym) == S_BOOLEAN) in sym_calc_visibility()
257 if (sym->rev_dep.tri != tri) { in sym_calc_visibility()
258 sym->rev_dep.tri = tri; in sym_calc_visibility()
259 sym_set_changed(sym); in sym_calc_visibility()
262 if (sym->implied.expr && sym->dir_dep.tri != no) in sym_calc_visibility()
263 tri = expr_calc_value(sym->implied.expr); in sym_calc_visibility()
264 if (tri == mod && sym_get_type(sym) == S_BOOLEAN) in sym_calc_visibility()
266 if (sym->implied.tri != tri) { in sym_calc_visibility()
267 sym->implied.tri = tri; in sym_calc_visibility()
268 sym_set_changed(sym); in sym_calc_visibility()
278 struct symbol *sym_choice_default(struct symbol *sym) in sym_choice_default() argument
285 for_all_defaults(sym, prop) { in sym_choice_default()
295 prop = sym_get_choice_prop(sym); in sym_choice_default()
304 static struct symbol *sym_calc_choice(struct symbol *sym) in sym_calc_choice() argument
312 flags = sym->flags; in sym_calc_choice()
313 prop = sym_get_choice_prop(sym); in sym_calc_choice()
320 sym->flags &= flags | ~SYMBOL_DEF_USER; in sym_calc_choice()
323 def_sym = sym->def[S_DEF_USER].val; in sym_calc_choice()
327 def_sym = sym_choice_default(sym); in sym_calc_choice()
331 sym->curr.tri = no; in sym_calc_choice()
336 static void sym_warn_unmet_dep(struct symbol *sym) in sym_warn_unmet_dep() argument
342 sym->name); in sym_warn_unmet_dep()
345 sym->dir_dep.tri == mod ? 'm' : 'n'); in sym_warn_unmet_dep()
346 expr_gstr_print(sym->dir_dep.expr, &gs); in sym_warn_unmet_dep()
349 expr_gstr_print_revdep(sym->rev_dep.expr, &gs, yes, in sym_warn_unmet_dep()
351 expr_gstr_print_revdep(sym->rev_dep.expr, &gs, mod, in sym_warn_unmet_dep()
357 void sym_calc_value(struct symbol *sym) in sym_calc_value() argument
363 if (!sym) in sym_calc_value()
366 if (sym->flags & SYMBOL_VALID) in sym_calc_value()
369 if (sym_is_choice_value(sym) && in sym_calc_value()
370 sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) { in sym_calc_value()
371 sym->flags &= ~SYMBOL_NEED_SET_CHOICE_VALUES; in sym_calc_value()
372 prop = sym_get_choice_prop(sym); in sym_calc_value()
376 sym->flags |= SYMBOL_VALID; in sym_calc_value()
378 oldval = sym->curr; in sym_calc_value()
380 switch (sym->type) { in sym_calc_value()
391 sym->curr.val = sym->name; in sym_calc_value()
392 sym->curr.tri = no; in sym_calc_value()
395 sym->flags &= ~SYMBOL_WRITE; in sym_calc_value()
397 sym_calc_visibility(sym); in sym_calc_value()
399 if (sym->visible != no) in sym_calc_value()
400 sym->flags |= SYMBOL_WRITE; in sym_calc_value()
403 sym->curr = newval; in sym_calc_value()
405 switch (sym_get_type(sym)) { in sym_calc_value()
408 if (sym_is_choice_value(sym) && sym->visible == yes) { in sym_calc_value()
409 prop = sym_get_choice_prop(sym); in sym_calc_value()
410 newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no; in sym_calc_value()
412 if (sym->visible != no) { in sym_calc_value()
416 if (sym_has_value(sym)) { in sym_calc_value()
417 newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri, in sym_calc_value()
418 sym->visible); in sym_calc_value()
422 if (sym->rev_dep.tri != no) in sym_calc_value()
423 sym->flags |= SYMBOL_WRITE; in sym_calc_value()
424 if (!sym_is_choice(sym)) { in sym_calc_value()
425 prop = sym_get_default_prop(sym); in sym_calc_value()
430 sym->flags |= SYMBOL_WRITE; in sym_calc_value()
432 if (sym->implied.tri != no) { in sym_calc_value()
433 sym->flags |= SYMBOL_WRITE; in sym_calc_value()
434 newval.tri = EXPR_OR(newval.tri, sym->implied.tri); in sym_calc_value()
438 if (sym->dir_dep.tri < sym->rev_dep.tri) in sym_calc_value()
439 sym_warn_unmet_dep(sym); in sym_calc_value()
440 newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); in sym_calc_value()
443 (sym_get_type(sym) == S_BOOLEAN || sym->implied.tri == yes)) in sym_calc_value()
449 if (sym->visible != no && sym_has_value(sym)) { in sym_calc_value()
450 newval.val = sym->def[S_DEF_USER].val; in sym_calc_value()
453 prop = sym_get_default_prop(sym); in sym_calc_value()
457 sym->flags |= SYMBOL_WRITE; in sym_calc_value()
467 sym->curr = newval; in sym_calc_value()
468 if (sym_is_choice(sym) && newval.tri == yes) in sym_calc_value()
469 sym->curr.val = sym_calc_choice(sym); in sym_calc_value()
470 sym_validate_range(sym); in sym_calc_value()
472 if (memcmp(&oldval, &sym->curr, sizeof(oldval))) { in sym_calc_value()
473 sym_set_changed(sym); in sym_calc_value()
474 if (modules_sym == sym) { in sym_calc_value()
480 if (sym_is_choice(sym)) { in sym_calc_value()
483 prop = sym_get_choice_prop(sym); in sym_calc_value()
485 if ((sym->flags & SYMBOL_WRITE) && in sym_calc_value()
488 if (sym->flags & SYMBOL_CHANGED) in sym_calc_value()
493 if (sym->flags & SYMBOL_AUTO) in sym_calc_value()
494 sym->flags &= ~SYMBOL_WRITE; in sym_calc_value()
496 if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) in sym_calc_value()
497 set_all_choice_values(sym); in sym_calc_value()
502 struct symbol *sym; in sym_clear_all_valid() local
505 for_all_symbols(i, sym) in sym_clear_all_valid()
506 sym->flags &= ~SYMBOL_VALID; in sym_clear_all_valid()
511 bool sym_tristate_within_range(struct symbol *sym, tristate val) in sym_tristate_within_range() argument
513 int type = sym_get_type(sym); in sym_tristate_within_range()
515 if (sym->visible == no) in sym_tristate_within_range()
523 if (sym->visible <= sym->rev_dep.tri) in sym_tristate_within_range()
525 if (sym->implied.tri == yes && val == mod) in sym_tristate_within_range()
527 if (sym_is_choice_value(sym) && sym->visible == yes) in sym_tristate_within_range()
529 return val >= sym->rev_dep.tri && val <= sym->visible; in sym_tristate_within_range()
532 bool sym_set_tristate_value(struct symbol *sym, tristate val) in sym_set_tristate_value() argument
534 tristate oldval = sym_get_tristate_value(sym); in sym_set_tristate_value()
536 if (oldval != val && !sym_tristate_within_range(sym, val)) in sym_set_tristate_value()
539 if (!(sym->flags & SYMBOL_DEF_USER)) { in sym_set_tristate_value()
540 sym->flags |= SYMBOL_DEF_USER; in sym_set_tristate_value()
541 sym_set_changed(sym); in sym_set_tristate_value()
547 if (sym_is_choice_value(sym) && val == yes) { in sym_set_tristate_value()
548 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); in sym_set_tristate_value()
552 cs->def[S_DEF_USER].val = sym; in sym_set_tristate_value()
556 if (e->right.sym->visible != no) in sym_set_tristate_value()
557 e->right.sym->flags |= SYMBOL_DEF_USER; in sym_set_tristate_value()
561 sym->def[S_DEF_USER].tri = val; in sym_set_tristate_value()
568 tristate sym_toggle_tristate_value(struct symbol *sym) in sym_toggle_tristate_value() argument
572 oldval = newval = sym_get_tristate_value(sym); in sym_toggle_tristate_value()
585 if (sym_set_tristate_value(sym, newval)) in sym_toggle_tristate_value()
591 bool sym_string_valid(struct symbol *sym, const char *str) in sym_string_valid() argument
595 switch (sym->type) { in sym_string_valid()
634 bool sym_string_within_range(struct symbol *sym, const char *str) in sym_string_within_range() argument
639 switch (sym->type) { in sym_string_within_range()
641 return sym_string_valid(sym, str); in sym_string_within_range()
643 if (!sym_string_valid(sym, str)) in sym_string_within_range()
645 prop = sym_get_range_prop(sym); in sym_string_within_range()
649 return val >= sym_get_range_val(prop->expr->left.sym, 10) && in sym_string_within_range()
650 val <= sym_get_range_val(prop->expr->right.sym, 10); in sym_string_within_range()
652 if (!sym_string_valid(sym, str)) in sym_string_within_range()
654 prop = sym_get_range_prop(sym); in sym_string_within_range()
658 return val >= sym_get_range_val(prop->expr->left.sym, 16) && in sym_string_within_range()
659 val <= sym_get_range_val(prop->expr->right.sym, 16); in sym_string_within_range()
664 return sym_tristate_within_range(sym, yes); in sym_string_within_range()
666 return sym_tristate_within_range(sym, mod); in sym_string_within_range()
668 return sym_tristate_within_range(sym, no); in sym_string_within_range()
676 bool sym_set_string_value(struct symbol *sym, const char *newval) in sym_set_string_value() argument
682 switch (sym->type) { in sym_set_string_value()
687 return sym_set_tristate_value(sym, yes); in sym_set_string_value()
689 return sym_set_tristate_value(sym, mod); in sym_set_string_value()
691 return sym_set_tristate_value(sym, no); in sym_set_string_value()
698 if (!sym_string_within_range(sym, newval)) in sym_set_string_value()
701 if (!(sym->flags & SYMBOL_DEF_USER)) { in sym_set_string_value()
702 sym->flags |= SYMBOL_DEF_USER; in sym_set_string_value()
703 sym_set_changed(sym); in sym_set_string_value()
706 oldval = sym->def[S_DEF_USER].val; in sym_set_string_value()
708 if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) { in sym_set_string_value()
710 sym->def[S_DEF_USER].val = val = xmalloc(size); in sym_set_string_value()
714 sym->def[S_DEF_USER].val = val = xmalloc(size); in sym_set_string_value()
732 const char *sym_get_string_default(struct symbol *sym) in sym_get_string_default() argument
739 sym_calc_visibility(sym); in sym_get_string_default()
745 prop = sym_get_default_prop(sym); in sym_get_string_default()
747 switch (sym->type) { in sym_get_string_default()
768 val = EXPR_OR(val, sym->rev_dep.tri); in sym_get_string_default()
772 if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no) in sym_get_string_default()
776 if (sym->type == S_BOOLEAN && val == mod) in sym_get_string_default()
780 if (val < sym->implied.tri) in sym_get_string_default()
781 val = sym->implied.tri; in sym_get_string_default()
783 switch (sym->type) { in sym_get_string_default()
803 const char *sym_get_string_value(struct symbol *sym) in sym_get_string_value() argument
807 switch (sym->type) { in sym_get_string_value()
810 val = sym_get_tristate_value(sym); in sym_get_string_value()
824 return (const char *)sym->curr.val; in sym_get_string_value()
827 bool sym_is_changable(struct symbol *sym) in sym_is_changable() argument
829 return sym->visible > sym->rev_dep.tri; in sym_is_changable()
931 struct symbol *sym; in sym_expand_string_value() local
942 sym = sym_find(name); in sym_expand_string_value()
943 if (sym != NULL) { in sym_expand_string_value()
944 sym_calc_value(sym); in sym_expand_string_value()
945 symval = sym_get_string_value(sym); in sym_expand_string_value()
1006 struct symbol *sym; member
1029 exact1 = (s1->eo - s1->so) == strlen(s1->sym->name); in sym_rel_comp()
1030 exact2 = (s2->eo - s2->so) == strlen(s2->sym->name); in sym_rel_comp()
1037 return strcmp(s1->sym->name, s2->sym->name); in sym_rel_comp()
1042 struct symbol *sym, **sym_arr = NULL; in sym_re_search() local
1055 for_all_symbols(i, sym) { in sym_re_search()
1056 if (sym->flags & SYMBOL_CONST || !sym->name) in sym_re_search()
1058 if (regexec(&re, sym->name, 1, match, 0)) in sym_re_search()
1068 sym_calc_value(sym); in sym_re_search()
1074 sym_match_arr[cnt++].sym = sym; in sym_re_search()
1082 sym_arr[i] = sym_match_arr[i].sym; in sym_re_search()
1101 struct symbol *sym; member
1106 static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym) in dep_stack_insert() argument
1112 stack->sym = sym; in dep_stack_insert()
1131 struct symbol *sym, *next_sym; in sym_check_print_recursive() local
1142 if (stack->sym == last_sym) in sym_check_print_recursive()
1150 sym = stack->sym; in sym_check_print_recursive()
1151 next_sym = stack->next ? stack->next->sym : last_sym; in sym_check_print_recursive()
1154 prop = stack->sym->prop; in sym_check_print_recursive()
1157 if (sym_is_choice(sym) || sym_is_choice_value(sym)) { in sym_check_print_recursive()
1158 for (prop = sym->prop; prop; prop = prop->next) { in sym_check_print_recursive()
1164 if (stack->sym == last_sym) in sym_check_print_recursive()
1171 sym->name ? sym->name : "<choice>", in sym_check_print_recursive()
1177 sym->name ? sym->name : "<choice>", in sym_check_print_recursive()
1179 } else if (sym_is_choice(sym)) { in sym_check_print_recursive()
1182 sym->name ? sym->name : "<choice>", in sym_check_print_recursive()
1184 } else if (sym_is_choice_value(sym)) { in sym_check_print_recursive()
1187 sym->name ? sym->name : "<choice>", in sym_check_print_recursive()
1192 sym->name ? sym->name : "<choice>", in sym_check_print_recursive()
1208 struct symbol *sym; in sym_check_expr_deps() local
1215 sym = sym_check_expr_deps(e->left.expr); in sym_check_expr_deps()
1216 if (sym) in sym_check_expr_deps()
1217 return sym; in sym_check_expr_deps()
1227 sym = sym_check_deps(e->left.sym); in sym_check_expr_deps()
1228 if (sym) in sym_check_expr_deps()
1229 return sym; in sym_check_expr_deps()
1230 return sym_check_deps(e->right.sym); in sym_check_expr_deps()
1232 return sym_check_deps(e->left.sym); in sym_check_expr_deps()
1241 static struct symbol *sym_check_sym_deps(struct symbol *sym) in sym_check_sym_deps() argument
1247 dep_stack_insert(&stack, sym); in sym_check_sym_deps()
1249 sym2 = sym_check_expr_deps(sym->rev_dep.expr); in sym_check_sym_deps()
1253 for (prop = sym->prop; prop; prop = prop->next) { in sym_check_sym_deps()
1260 if (prop->type != P_DEFAULT || sym_is_choice(sym)) in sym_check_sym_deps()
1277 struct symbol *sym, *sym2; in sym_check_choice_deps() local
1285 expr_list_for_each_sym(prop->expr, e, sym) in sym_check_choice_deps()
1286 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); in sym_check_choice_deps()
1294 expr_list_for_each_sym(prop->expr, e, sym) { in sym_check_choice_deps()
1295 sym2 = sym_check_sym_deps(sym); in sym_check_choice_deps()
1300 expr_list_for_each_sym(prop->expr, e, sym) in sym_check_choice_deps()
1301 sym->flags &= ~SYMBOL_CHECK; in sym_check_choice_deps()
1312 struct symbol *sym_check_deps(struct symbol *sym) in sym_check_deps() argument
1317 if (sym->flags & SYMBOL_CHECK) { in sym_check_deps()
1318 sym_check_print_recursive(sym); in sym_check_deps()
1319 return sym; in sym_check_deps()
1321 if (sym->flags & SYMBOL_CHECKED) in sym_check_deps()
1324 if (sym_is_choice_value(sym)) { in sym_check_deps()
1328 dep_stack_insert(&stack, sym); in sym_check_deps()
1329 prop = sym_get_choice_prop(sym); in sym_check_deps()
1332 } else if (sym_is_choice(sym)) { in sym_check_deps()
1333 sym2 = sym_check_choice_deps(sym); in sym_check_deps()
1335 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); in sym_check_deps()
1336 sym2 = sym_check_sym_deps(sym); in sym_check_deps()
1337 sym->flags &= ~SYMBOL_CHECK; in sym_check_deps()
1340 if (sym2 && sym2 == sym) in sym_check_deps()
1346 struct property *prop_alloc(enum prop_type type, struct symbol *sym) in prop_alloc() argument
1354 prop->sym = sym; in prop_alloc()
1359 if (sym) { in prop_alloc()
1360 for (propp = &sym->prop; *propp; propp = &(*propp)->next) in prop_alloc()
1372 return prop->expr->left.sym; in prop_get_symbol()
1407 struct symbol *sym, *sym2; in prop_add_env() local
1411 sym = current_entry->sym; in prop_add_env()
1412 sym->flags |= SYMBOL_AUTO; in prop_add_env()
1413 for_all_properties(sym, prop, P_ENV) { in prop_add_env()
1421 prop = prop_alloc(P_ENV, sym); in prop_add_env()
1425 sym_env_list->right.sym = sym; in prop_add_env()
1429 sym_add_default(sym, p); in prop_add_env()