]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - scripts/kconfig/symbol.c
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
10 #include <sys/utsname.h>
12 #define LKC_DIRECT_LINK
15 struct symbol symbol_yes
= {
18 .flags
= SYMBOL_CONST
|SYMBOL_VALID
,
22 .flags
= SYMBOL_CONST
|SYMBOL_VALID
,
26 .flags
= SYMBOL_CONST
|SYMBOL_VALID
,
30 .flags
= SYMBOL_VALID
,
33 struct symbol
*sym_defconfig_list
;
34 struct symbol
*modules_sym
;
37 struct expr
*sym_env_list
;
39 static void sym_add_default(struct symbol
*sym
, const char *def
)
41 struct property
*prop
= prop_alloc(P_DEFAULT
, sym
);
43 prop
->expr
= expr_alloc_symbol(sym_lookup(def
, SYMBOL_CONST
));
50 static bool inited
= false;
58 sym
= sym_lookup("UNAME_RELEASE", 0);
60 sym
->flags
|= SYMBOL_AUTO
;
61 sym_add_default(sym
, uts
.release
);
64 enum symbol_type
sym_get_type(struct symbol
*sym
)
66 enum symbol_type type
= sym
->type
;
68 if (type
== S_TRISTATE
) {
69 if (sym_is_choice_value(sym
) && sym
->visible
== yes
)
71 else if (modules_val
== no
)
77 const char *sym_type_name(enum symbol_type type
)
98 struct property
*sym_get_choice_prop(struct symbol
*sym
)
100 struct property
*prop
;
102 for_all_choices(sym
, prop
)
107 struct property
*sym_get_env_prop(struct symbol
*sym
)
109 struct property
*prop
;
111 for_all_properties(sym
, prop
, P_ENV
)
116 struct property
*sym_get_default_prop(struct symbol
*sym
)
118 struct property
*prop
;
120 for_all_defaults(sym
, prop
) {
121 prop
->visible
.tri
= expr_calc_value(prop
->visible
.expr
);
122 if (prop
->visible
.tri
!= no
)
128 static struct property
*sym_get_range_prop(struct symbol
*sym
)
130 struct property
*prop
;
132 for_all_properties(sym
, prop
, P_RANGE
) {
133 prop
->visible
.tri
= expr_calc_value(prop
->visible
.expr
);
134 if (prop
->visible
.tri
!= no
)
140 static int sym_get_range_val(struct symbol
*sym
, int base
)
153 return strtol(sym
->curr
.val
, NULL
, base
);
156 static void sym_validate_range(struct symbol
*sym
)
158 struct property
*prop
;
172 prop
= sym_get_range_prop(sym
);
175 val
= strtol(sym
->curr
.val
, NULL
, base
);
176 val2
= sym_get_range_val(prop
->expr
->left
.sym
, base
);
178 val2
= sym_get_range_val(prop
->expr
->right
.sym
, base
);
182 if (sym
->type
== S_INT
)
183 sprintf(str
, "%d", val2
);
185 sprintf(str
, "0x%x", val2
);
186 sym
->curr
.val
= strdup(str
);
189 static void sym_calc_visibility(struct symbol
*sym
)
191 struct property
*prop
;
194 /* any prompt visible? */
196 for_all_prompts(sym
, prop
) {
197 prop
->visible
.tri
= expr_calc_value(prop
->visible
.expr
);
198 tri
= EXPR_OR(tri
, prop
->visible
.tri
);
200 if (tri
== mod
&& (sym
->type
!= S_TRISTATE
|| modules_val
== no
))
202 if (sym
->visible
!= tri
) {
204 sym_set_changed(sym
);
206 if (sym_is_choice_value(sym
))
208 /* defaulting to "yes" if no explicit "depends on" are given */
210 if (sym
->dir_dep
.expr
)
211 tri
= expr_calc_value(sym
->dir_dep
.expr
);
214 if (sym
->dir_dep
.tri
!= tri
) {
215 sym
->dir_dep
.tri
= tri
;
216 sym_set_changed(sym
);
219 if (sym
->rev_dep
.expr
)
220 tri
= expr_calc_value(sym
->rev_dep
.expr
);
221 if (tri
== mod
&& sym_get_type(sym
) == S_BOOLEAN
)
223 if (sym
->rev_dep
.tri
!= tri
) {
224 sym
->rev_dep
.tri
= tri
;
225 sym_set_changed(sym
);
230 * Find the default symbol for a choice.
231 * First try the default values for the choice symbol
232 * Next locate the first visible choice value
233 * Return NULL if none was found
235 struct symbol
*sym_choice_default(struct symbol
*sym
)
237 struct symbol
*def_sym
;
238 struct property
*prop
;
241 /* any of the defaults visible? */
242 for_all_defaults(sym
, prop
) {
243 prop
->visible
.tri
= expr_calc_value(prop
->visible
.expr
);
244 if (prop
->visible
.tri
== no
)
246 def_sym
= prop_get_symbol(prop
);
247 if (def_sym
->visible
!= no
)
251 /* just get the first visible value */
252 prop
= sym_get_choice_prop(sym
);
253 expr_list_for_each_sym(prop
->expr
, e
, def_sym
)
254 if (def_sym
->visible
!= no
)
257 /* failed to locate any defaults */
261 static struct symbol
*sym_calc_choice(struct symbol
*sym
)
263 struct symbol
*def_sym
;
264 struct property
*prop
;
267 /* first calculate all choice values' visibilities */
268 prop
= sym_get_choice_prop(sym
);
269 expr_list_for_each_sym(prop
->expr
, e
, def_sym
)
270 sym_calc_visibility(def_sym
);
272 /* is the user choice visible? */
273 def_sym
= sym
->def
[S_DEF_USER
].val
;
274 if (def_sym
&& def_sym
->visible
!= no
)
277 def_sym
= sym_choice_default(sym
);
280 /* no choice? reset tristate value */
286 void sym_calc_value(struct symbol
*sym
)
288 struct symbol_value newval
, oldval
;
289 struct property
*prop
;
295 if (sym
->flags
& SYMBOL_VALID
)
297 sym
->flags
|= SYMBOL_VALID
;
305 newval
= symbol_empty
.curr
;
309 newval
= symbol_no
.curr
;
312 sym
->curr
.val
= sym
->name
;
316 if (!sym_is_choice_value(sym
))
317 sym
->flags
&= ~SYMBOL_WRITE
;
319 sym_calc_visibility(sym
);
321 /* set default if recursively called */
324 switch (sym_get_type(sym
)) {
327 if (sym_is_choice_value(sym
) && sym
->visible
== yes
) {
328 prop
= sym_get_choice_prop(sym
);
329 newval
.tri
= (prop_get_symbol(prop
)->curr
.val
== sym
) ? yes
: no
;
331 if (sym
->visible
!= no
) {
332 /* if the symbol is visible use the user value
333 * if available, otherwise try the default value
335 sym
->flags
|= SYMBOL_WRITE
;
336 if (sym_has_value(sym
)) {
337 newval
.tri
= EXPR_AND(sym
->def
[S_DEF_USER
].tri
,
342 if (sym
->rev_dep
.tri
!= no
)
343 sym
->flags
|= SYMBOL_WRITE
;
344 if (!sym_is_choice(sym
)) {
345 prop
= sym_get_default_prop(sym
);
347 sym
->flags
|= SYMBOL_WRITE
;
348 newval
.tri
= EXPR_AND(expr_calc_value(prop
->expr
),
354 if (sym
->dir_dep
.tri
== no
&& sym
->rev_dep
.tri
!= no
) {
355 fprintf(stderr
, "warning: (");
356 expr_fprint(sym
->rev_dep
.expr
, stderr
);
357 fprintf(stderr
, ") selects %s which has unmet direct dependencies (",
359 expr_fprint(sym
->dir_dep
.expr
, stderr
);
360 fprintf(stderr
, ")\n");
363 newval
.tri
= EXPR_OR(newval
.tri
, sym
->rev_dep
.tri
);
365 if (newval
.tri
== mod
&& sym_get_type(sym
) == S_BOOLEAN
)
371 if (sym
->visible
!= no
) {
372 sym
->flags
|= SYMBOL_WRITE
;
373 if (sym_has_value(sym
)) {
374 newval
.val
= sym
->def
[S_DEF_USER
].val
;
378 prop
= sym_get_default_prop(sym
);
380 struct symbol
*ds
= prop_get_symbol(prop
);
382 sym
->flags
|= SYMBOL_WRITE
;
384 newval
.val
= ds
->curr
.val
;
393 if (sym_is_choice(sym
) && newval
.tri
== yes
)
394 sym
->curr
.val
= sym_calc_choice(sym
);
395 sym_validate_range(sym
);
397 if (memcmp(&oldval
, &sym
->curr
, sizeof(oldval
))) {
398 sym_set_changed(sym
);
399 if (modules_sym
== sym
) {
400 sym_set_all_changed();
401 modules_val
= modules_sym
->curr
.tri
;
405 if (sym_is_choice(sym
)) {
406 struct symbol
*choice_sym
;
408 prop
= sym_get_choice_prop(sym
);
409 expr_list_for_each_sym(prop
->expr
, e
, choice_sym
) {
410 if ((sym
->flags
& SYMBOL_WRITE
) &&
411 choice_sym
->visible
!= no
)
412 choice_sym
->flags
|= SYMBOL_WRITE
;
413 if (sym
->flags
& SYMBOL_CHANGED
)
414 sym_set_changed(choice_sym
);
418 if (sym
->flags
& SYMBOL_AUTO
)
419 sym
->flags
&= ~SYMBOL_WRITE
;
422 void sym_clear_all_valid(void)
427 for_all_symbols(i
, sym
)
428 sym
->flags
&= ~SYMBOL_VALID
;
429 sym_add_change_count(1);
431 sym_calc_value(modules_sym
);
434 void sym_set_changed(struct symbol
*sym
)
436 struct property
*prop
;
438 sym
->flags
|= SYMBOL_CHANGED
;
439 for (prop
= sym
->prop
; prop
; prop
= prop
->next
) {
441 prop
->menu
->flags
|= MENU_CHANGED
;
445 void sym_set_all_changed(void)
450 for_all_symbols(i
, sym
)
451 sym_set_changed(sym
);
454 bool sym_tristate_within_range(struct symbol
*sym
, tristate val
)
456 int type
= sym_get_type(sym
);
458 if (sym
->visible
== no
)
461 if (type
!= S_BOOLEAN
&& type
!= S_TRISTATE
)
464 if (type
== S_BOOLEAN
&& val
== mod
)
466 if (sym
->visible
<= sym
->rev_dep
.tri
)
468 if (sym_is_choice_value(sym
) && sym
->visible
== yes
)
470 return val
>= sym
->rev_dep
.tri
&& val
<= sym
->visible
;
473 bool sym_set_tristate_value(struct symbol
*sym
, tristate val
)
475 tristate oldval
= sym_get_tristate_value(sym
);
477 if (oldval
!= val
&& !sym_tristate_within_range(sym
, val
))
480 if (!(sym
->flags
& SYMBOL_DEF_USER
)) {
481 sym
->flags
|= SYMBOL_DEF_USER
;
482 sym_set_changed(sym
);
485 * setting a choice value also resets the new flag of the choice
486 * symbol and all other choice values.
488 if (sym_is_choice_value(sym
) && val
== yes
) {
489 struct symbol
*cs
= prop_get_symbol(sym_get_choice_prop(sym
));
490 struct property
*prop
;
493 cs
->def
[S_DEF_USER
].val
= sym
;
494 cs
->flags
|= SYMBOL_DEF_USER
;
495 prop
= sym_get_choice_prop(cs
);
496 for (e
= prop
->expr
; e
; e
= e
->left
.expr
) {
497 if (e
->right
.sym
->visible
!= no
)
498 e
->right
.sym
->flags
|= SYMBOL_DEF_USER
;
502 sym
->def
[S_DEF_USER
].tri
= val
;
504 sym_clear_all_valid();
509 tristate
sym_toggle_tristate_value(struct symbol
*sym
)
511 tristate oldval
, newval
;
513 oldval
= newval
= sym_get_tristate_value(sym
);
526 if (sym_set_tristate_value(sym
, newval
))
528 } while (oldval
!= newval
);
532 bool sym_string_valid(struct symbol
*sym
, const char *str
)
545 if (ch
== '0' && *str
!= 0)
547 while ((ch
= *str
++)) {
553 if (str
[0] == '0' && (str
[1] == 'x' || str
[1] == 'X'))
559 } while ((ch
= *str
++));
575 bool sym_string_within_range(struct symbol
*sym
, const char *str
)
577 struct property
*prop
;
582 return sym_string_valid(sym
, str
);
584 if (!sym_string_valid(sym
, str
))
586 prop
= sym_get_range_prop(sym
);
589 val
= strtol(str
, NULL
, 10);
590 return val
>= sym_get_range_val(prop
->expr
->left
.sym
, 10) &&
591 val
<= sym_get_range_val(prop
->expr
->right
.sym
, 10);
593 if (!sym_string_valid(sym
, str
))
595 prop
= sym_get_range_prop(sym
);
598 val
= strtol(str
, NULL
, 16);
599 return val
>= sym_get_range_val(prop
->expr
->left
.sym
, 16) &&
600 val
<= sym_get_range_val(prop
->expr
->right
.sym
, 16);
605 return sym_tristate_within_range(sym
, yes
);
607 return sym_tristate_within_range(sym
, mod
);
609 return sym_tristate_within_range(sym
, no
);
617 bool sym_set_string_value(struct symbol
*sym
, const char *newval
)
628 return sym_set_tristate_value(sym
, yes
);
630 return sym_set_tristate_value(sym
, mod
);
632 return sym_set_tristate_value(sym
, no
);
639 if (!sym_string_within_range(sym
, newval
))
642 if (!(sym
->flags
& SYMBOL_DEF_USER
)) {
643 sym
->flags
|= SYMBOL_DEF_USER
;
644 sym_set_changed(sym
);
647 oldval
= sym
->def
[S_DEF_USER
].val
;
648 size
= strlen(newval
) + 1;
649 if (sym
->type
== S_HEX
&& (newval
[0] != '0' || (newval
[1] != 'x' && newval
[1] != 'X'))) {
651 sym
->def
[S_DEF_USER
].val
= val
= malloc(size
);
654 } else if (!oldval
|| strcmp(oldval
, newval
))
655 sym
->def
[S_DEF_USER
].val
= val
= malloc(size
);
660 free((void *)oldval
);
661 sym_clear_all_valid();
667 * Find the default value associated to a symbol.
668 * For tristate symbol handle the modules=n case
669 * in which case "m" becomes "y".
670 * If the symbol does not have any default then fallback
671 * to the fixed default values.
673 const char *sym_get_string_default(struct symbol
*sym
)
675 struct property
*prop
;
680 sym_calc_visibility(sym
);
681 sym_calc_value(modules_sym
);
682 val
= symbol_no
.curr
.tri
;
683 str
= symbol_empty
.curr
.val
;
685 /* If symbol has a default value look it up */
686 prop
= sym_get_default_prop(sym
);
691 /* The visibility imay limit the value from yes => mod */
692 val
= EXPR_AND(expr_calc_value(prop
->expr
), prop
->visible
.tri
);
696 * The following fails to handle the situation
697 * where a default value is further limited by
700 ds
= prop_get_symbol(prop
);
703 str
= (const char *)ds
->curr
.val
;
708 /* Handle select statements */
709 val
= EXPR_OR(val
, sym
->rev_dep
.tri
);
711 /* transpose mod to yes if modules are not enabled */
713 if (!sym_is_choice_value(sym
) && modules_sym
->curr
.tri
== no
)
716 /* transpose mod to yes if type is bool */
717 if (sym
->type
== S_BOOLEAN
&& val
== mod
)
725 case mod
: return "m";
726 case yes
: return "y";
740 const char *sym_get_string_value(struct symbol
*sym
)
747 val
= sym_get_tristate_value(sym
);
760 return (const char *)sym
->curr
.val
;
763 bool sym_is_changable(struct symbol
*sym
)
765 return sym
->visible
> sym
->rev_dep
.tri
;
768 static unsigned strhash(const char *s
)
771 unsigned hash
= 2166136261U;
773 hash
= (hash
^ *s
) * 0x01000193;
777 struct symbol
*sym_lookup(const char *name
, int flags
)
779 struct symbol
*symbol
;
784 if (name
[0] && !name
[1]) {
786 case 'y': return &symbol_yes
;
787 case 'm': return &symbol_mod
;
788 case 'n': return &symbol_no
;
791 hash
= strhash(name
) % SYMBOL_HASHSIZE
;
793 for (symbol
= symbol_hash
[hash
]; symbol
; symbol
= symbol
->next
) {
795 !strcmp(symbol
->name
, name
) &&
796 (flags
? symbol
->flags
& flags
797 : !(symbol
->flags
& (SYMBOL_CONST
|SYMBOL_CHOICE
))))
800 new_name
= strdup(name
);
806 symbol
= malloc(sizeof(*symbol
));
807 memset(symbol
, 0, sizeof(*symbol
));
808 symbol
->name
= new_name
;
809 symbol
->type
= S_UNKNOWN
;
810 symbol
->flags
|= flags
;
812 symbol
->next
= symbol_hash
[hash
];
813 symbol_hash
[hash
] = symbol
;
818 struct symbol
*sym_find(const char *name
)
820 struct symbol
*symbol
= NULL
;
826 if (name
[0] && !name
[1]) {
828 case 'y': return &symbol_yes
;
829 case 'm': return &symbol_mod
;
830 case 'n': return &symbol_no
;
833 hash
= strhash(name
) % SYMBOL_HASHSIZE
;
835 for (symbol
= symbol_hash
[hash
]; symbol
; symbol
= symbol
->next
) {
837 !strcmp(symbol
->name
, name
) &&
838 !(symbol
->flags
& SYMBOL_CONST
))
845 struct symbol
**sym_re_search(const char *pattern
)
847 struct symbol
*sym
, **sym_arr
= NULL
;
853 if (strlen(pattern
) == 0)
855 if (regcomp(&re
, pattern
, REG_EXTENDED
|REG_NOSUB
|REG_ICASE
))
858 for_all_symbols(i
, sym
) {
859 if (sym
->flags
& SYMBOL_CONST
|| !sym
->name
)
861 if (regexec(&re
, sym
->name
, 0, NULL
, 0))
863 if (cnt
+ 1 >= size
) {
866 sym_arr
= realloc(sym_arr
, size
* sizeof(struct symbol
*));
873 sym_arr
[cnt
++] = sym
;
883 * When we check for recursive dependencies we use a stack to save
884 * current state so we can print out relevant info to user.
885 * The entries are located on the call stack so no need to free memory.
886 * Note inser() remove() must always match to properly clear the stack.
888 static struct dep_stack
{
889 struct dep_stack
*prev
, *next
;
891 struct property
*prop
;
895 static void dep_stack_insert(struct dep_stack
*stack
, struct symbol
*sym
)
897 memset(stack
, 0, sizeof(*stack
));
899 check_top
->next
= stack
;
900 stack
->prev
= check_top
;
905 static void dep_stack_remove(void)
907 check_top
= check_top
->prev
;
909 check_top
->next
= NULL
;
913 * Called when we have detected a recursive dependency.
914 * check_top point to the top of the stact so we use
915 * the ->prev pointer to locate the bottom of the stack.
917 static void sym_check_print_recursive(struct symbol
*last_sym
)
919 struct dep_stack
*stack
;
920 struct symbol
*sym
, *next_sym
;
921 struct menu
*menu
= NULL
;
922 struct property
*prop
;
923 struct dep_stack cv_stack
;
925 if (sym_is_choice_value(last_sym
)) {
926 dep_stack_insert(&cv_stack
, last_sym
);
927 last_sym
= prop_get_symbol(sym_get_choice_prop(last_sym
));
930 for (stack
= check_top
; stack
!= NULL
; stack
= stack
->prev
)
931 if (stack
->sym
== last_sym
)
934 fprintf(stderr
, "unexpected recursive dependency error\n");
938 for (; stack
; stack
= stack
->next
) {
940 next_sym
= stack
->next
? stack
->next
->sym
: last_sym
;
943 prop
= stack
->sym
->prop
;
945 /* for choice values find the menu entry (used below) */
946 if (sym_is_choice(sym
) || sym_is_choice_value(sym
)) {
947 for (prop
= sym
->prop
; prop
; prop
= prop
->next
) {
953 if (stack
->sym
== last_sym
)
954 fprintf(stderr
, "%s:%d:error: recursive dependency detected!\n",
955 prop
->file
->name
, prop
->lineno
);
957 fprintf(stderr
, "%s:%d:\tsymbol %s %s value contains %s\n",
958 prop
->file
->name
, prop
->lineno
,
959 sym
->name
? sym
->name
: "<choice>",
960 prop_get_type_name(prop
->type
),
961 next_sym
->name
? next_sym
->name
: "<choice>");
962 } else if (stack
->prop
) {
963 fprintf(stderr
, "%s:%d:\tsymbol %s depends on %s\n",
964 prop
->file
->name
, prop
->lineno
,
965 sym
->name
? sym
->name
: "<choice>",
966 next_sym
->name
? next_sym
->name
: "<choice>");
967 } else if (sym_is_choice(sym
)) {
968 fprintf(stderr
, "%s:%d:\tchoice %s contains symbol %s\n",
969 menu
->file
->name
, menu
->lineno
,
970 sym
->name
? sym
->name
: "<choice>",
971 next_sym
->name
? next_sym
->name
: "<choice>");
972 } else if (sym_is_choice_value(sym
)) {
973 fprintf(stderr
, "%s:%d:\tsymbol %s is part of choice %s\n",
974 menu
->file
->name
, menu
->lineno
,
975 sym
->name
? sym
->name
: "<choice>",
976 next_sym
->name
? next_sym
->name
: "<choice>");
978 fprintf(stderr
, "%s:%d:\tsymbol %s is selected by %s\n",
979 prop
->file
->name
, prop
->lineno
,
980 sym
->name
? sym
->name
: "<choice>",
981 next_sym
->name
? next_sym
->name
: "<choice>");
985 if (check_top
== &cv_stack
)
989 static struct symbol
*sym_check_expr_deps(struct expr
*e
)
998 sym
= sym_check_expr_deps(e
->left
.expr
);
1001 return sym_check_expr_deps(e
->right
.expr
);
1003 return sym_check_expr_deps(e
->left
.expr
);
1006 sym
= sym_check_deps(e
->left
.sym
);
1009 return sym_check_deps(e
->right
.sym
);
1011 return sym_check_deps(e
->left
.sym
);
1015 printf("Oops! How to check %d?\n", e
->type
);
1019 /* return NULL when dependencies are OK */
1020 static struct symbol
*sym_check_sym_deps(struct symbol
*sym
)
1022 struct symbol
*sym2
;
1023 struct property
*prop
;
1024 struct dep_stack stack
;
1026 dep_stack_insert(&stack
, sym
);
1028 sym2
= sym_check_expr_deps(sym
->rev_dep
.expr
);
1032 for (prop
= sym
->prop
; prop
; prop
= prop
->next
) {
1033 if (prop
->type
== P_CHOICE
|| prop
->type
== P_SELECT
)
1036 sym2
= sym_check_expr_deps(prop
->visible
.expr
);
1039 if (prop
->type
!= P_DEFAULT
|| sym_is_choice(sym
))
1041 stack
.expr
= prop
->expr
;
1042 sym2
= sym_check_expr_deps(prop
->expr
);
1054 static struct symbol
*sym_check_choice_deps(struct symbol
*choice
)
1056 struct symbol
*sym
, *sym2
;
1057 struct property
*prop
;
1059 struct dep_stack stack
;
1061 dep_stack_insert(&stack
, choice
);
1063 prop
= sym_get_choice_prop(choice
);
1064 expr_list_for_each_sym(prop
->expr
, e
, sym
)
1065 sym
->flags
|= (SYMBOL_CHECK
| SYMBOL_CHECKED
);
1067 choice
->flags
|= (SYMBOL_CHECK
| SYMBOL_CHECKED
);
1068 sym2
= sym_check_sym_deps(choice
);
1069 choice
->flags
&= ~SYMBOL_CHECK
;
1073 expr_list_for_each_sym(prop
->expr
, e
, sym
) {
1074 sym2
= sym_check_sym_deps(sym
);
1079 expr_list_for_each_sym(prop
->expr
, e
, sym
)
1080 sym
->flags
&= ~SYMBOL_CHECK
;
1082 if (sym2
&& sym_is_choice_value(sym2
) &&
1083 prop_get_symbol(sym_get_choice_prop(sym2
)) == choice
)
1091 struct symbol
*sym_check_deps(struct symbol
*sym
)
1093 struct symbol
*sym2
;
1094 struct property
*prop
;
1096 if (sym
->flags
& SYMBOL_CHECK
) {
1097 sym_check_print_recursive(sym
);
1100 if (sym
->flags
& SYMBOL_CHECKED
)
1103 if (sym_is_choice_value(sym
)) {
1104 struct dep_stack stack
;
1106 /* for choice groups start the check with main choice symbol */
1107 dep_stack_insert(&stack
, sym
);
1108 prop
= sym_get_choice_prop(sym
);
1109 sym2
= sym_check_deps(prop_get_symbol(prop
));
1111 } else if (sym_is_choice(sym
)) {
1112 sym2
= sym_check_choice_deps(sym
);
1114 sym
->flags
|= (SYMBOL_CHECK
| SYMBOL_CHECKED
);
1115 sym2
= sym_check_sym_deps(sym
);
1116 sym
->flags
&= ~SYMBOL_CHECK
;
1119 if (sym2
&& sym2
== sym
)
1125 struct property
*prop_alloc(enum prop_type type
, struct symbol
*sym
)
1127 struct property
*prop
;
1128 struct property
**propp
;
1130 prop
= malloc(sizeof(*prop
));
1131 memset(prop
, 0, sizeof(*prop
));
1134 prop
->file
= current_file
;
1135 prop
->lineno
= zconf_lineno();
1137 /* append property to the prop list of symbol */
1139 for (propp
= &sym
->prop
; *propp
; propp
= &(*propp
)->next
)
1147 struct symbol
*prop_get_symbol(struct property
*prop
)
1149 if (prop
->expr
&& (prop
->expr
->type
== E_SYMBOL
||
1150 prop
->expr
->type
== E_LIST
))
1151 return prop
->expr
->left
.sym
;
1155 const char *prop_get_type_name(enum prop_type type
)
1182 static void prop_add_env(const char *env
)
1184 struct symbol
*sym
, *sym2
;
1185 struct property
*prop
;
1188 sym
= current_entry
->sym
;
1189 sym
->flags
|= SYMBOL_AUTO
;
1190 for_all_properties(sym
, prop
, P_ENV
) {
1191 sym2
= prop_get_symbol(prop
);
1192 if (strcmp(sym2
->name
, env
))
1193 menu_warn(current_entry
, "redefining environment symbol from %s",
1198 prop
= prop_alloc(P_ENV
, sym
);
1199 prop
->expr
= expr_alloc_symbol(sym_lookup(env
, SYMBOL_CONST
));
1201 sym_env_list
= expr_alloc_one(E_LIST
, sym_env_list
);
1202 sym_env_list
->right
.sym
= sym
;
1206 sym_add_default(sym
, p
);
1208 menu_warn(current_entry
, "environment variable %s undefined", env
);