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>
14 struct symbol symbol_yes = {
17 .flags = SYMBOL_CONST|SYMBOL_VALID,
21 .flags = SYMBOL_CONST|SYMBOL_VALID,
25 .flags = SYMBOL_CONST|SYMBOL_VALID,
29 .flags = SYMBOL_VALID,
32 struct symbol *sym_defconfig_list;
33 struct symbol *modules_sym;
36 struct expr *sym_env_list;
38 static void sym_add_default(struct symbol *sym, const char *def)
40 struct property *prop = prop_alloc(P_DEFAULT, sym);
42 prop->expr = expr_alloc_symbol(sym_lookup(def, SYMBOL_CONST));
49 static bool inited = false;
57 sym = sym_lookup("UNAME_RELEASE", 0);
59 sym->flags |= SYMBOL_AUTO;
60 sym_add_default(sym, uts.release);
63 enum symbol_type sym_get_type(struct symbol *sym)
65 enum symbol_type type = sym->type;
67 if (type == S_TRISTATE) {
68 if (sym_is_choice_value(sym) && sym->visible == yes)
70 else if (modules_val == no)
76 const char *sym_type_name(enum symbol_type type)
97 struct property *sym_get_choice_prop(struct symbol *sym)
99 struct property *prop;
101 for_all_choices(sym, prop)
106 struct property *sym_get_env_prop(struct symbol *sym)
108 struct property *prop;
110 for_all_properties(sym, prop, P_ENV)
115 struct property *sym_get_default_prop(struct symbol *sym)
117 struct property *prop;
119 for_all_defaults(sym, prop) {
120 prop->visible.tri = expr_calc_value(prop->visible.expr);
121 if (prop->visible.tri != no)
127 static struct property *sym_get_range_prop(struct symbol *sym)
129 struct property *prop;
131 for_all_properties(sym, prop, P_RANGE) {
132 prop->visible.tri = expr_calc_value(prop->visible.expr);
133 if (prop->visible.tri != no)
139 static int sym_get_range_val(struct symbol *sym, int base)
152 return strtol(sym->curr.val, NULL, base);
155 static void sym_validate_range(struct symbol *sym)
157 struct property *prop;
171 prop = sym_get_range_prop(sym);
174 val = strtol(sym->curr.val, NULL, base);
175 val2 = sym_get_range_val(prop->expr->left.sym, base);
177 val2 = sym_get_range_val(prop->expr->right.sym, base);
181 if (sym->type == S_INT)
182 sprintf(str, "%d", val2);
184 sprintf(str, "0x%x", val2);
185 sym->curr.val = strdup(str);
188 static void sym_calc_visibility(struct symbol *sym)
190 struct property *prop;
193 /* any prompt visible? */
195 for_all_prompts(sym, prop) {
196 prop->visible.tri = expr_calc_value(prop->visible.expr);
197 tri = EXPR_OR(tri, prop->visible.tri);
199 if (tri == mod && (sym->type != S_TRISTATE || modules_val == no))
201 if (sym->visible != tri) {
203 sym_set_changed(sym);
205 if (sym_is_choice_value(sym))
207 /* defaulting to "yes" if no explicit "depends on" are given */
209 if (sym->dir_dep.expr)
210 tri = expr_calc_value(sym->dir_dep.expr);
213 if (sym->dir_dep.tri != tri) {
214 sym->dir_dep.tri = tri;
215 sym_set_changed(sym);
218 if (sym->rev_dep.expr)
219 tri = expr_calc_value(sym->rev_dep.expr);
220 if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
222 if (sym->rev_dep.tri != tri) {
223 sym->rev_dep.tri = tri;
224 sym_set_changed(sym);
229 * Find the default symbol for a choice.
230 * First try the default values for the choice symbol
231 * Next locate the first visible choice value
232 * Return NULL if none was found
234 struct symbol *sym_choice_default(struct symbol *sym)
236 struct symbol *def_sym;
237 struct property *prop;
240 /* any of the defaults visible? */
241 for_all_defaults(sym, prop) {
242 prop->visible.tri = expr_calc_value(prop->visible.expr);
243 if (prop->visible.tri == no)
245 def_sym = prop_get_symbol(prop);
246 if (def_sym->visible != no)
250 /* just get the first visible value */
251 prop = sym_get_choice_prop(sym);
252 expr_list_for_each_sym(prop->expr, e, def_sym)
253 if (def_sym->visible != no)
256 /* failed to locate any defaults */
260 static struct symbol *sym_calc_choice(struct symbol *sym)
262 struct symbol *def_sym;
263 struct property *prop;
267 /* first calculate all choice values' visibilities */
269 prop = sym_get_choice_prop(sym);
270 expr_list_for_each_sym(prop->expr, e, def_sym) {
271 sym_calc_visibility(def_sym);
272 if (def_sym->visible != no)
273 flags &= def_sym->flags;
276 sym->flags &= flags | ~SYMBOL_DEF_USER;
278 /* is the user choice visible? */
279 def_sym = sym->def[S_DEF_USER].val;
280 if (def_sym && def_sym->visible != no)
283 def_sym = sym_choice_default(sym);
286 /* no choice? reset tristate value */
292 void sym_calc_value(struct symbol *sym)
294 struct symbol_value newval, oldval;
295 struct property *prop;
301 if (sym->flags & SYMBOL_VALID)
303 sym->flags |= SYMBOL_VALID;
311 newval = symbol_empty.curr;
315 newval = symbol_no.curr;
318 sym->curr.val = sym->name;
322 if (!sym_is_choice_value(sym))
323 sym->flags &= ~SYMBOL_WRITE;
325 sym_calc_visibility(sym);
327 /* set default if recursively called */
330 switch (sym_get_type(sym)) {
333 if (sym_is_choice_value(sym) && sym->visible == yes) {
334 prop = sym_get_choice_prop(sym);
335 newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no;
337 if (sym->visible != no) {
338 /* if the symbol is visible use the user value
339 * if available, otherwise try the default value
341 sym->flags |= SYMBOL_WRITE;
342 if (sym_has_value(sym)) {
343 newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri,
348 if (sym->rev_dep.tri != no)
349 sym->flags |= SYMBOL_WRITE;
350 if (!sym_is_choice(sym)) {
351 prop = sym_get_default_prop(sym);
353 sym->flags |= SYMBOL_WRITE;
354 newval.tri = EXPR_AND(expr_calc_value(prop->expr),
359 if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) {
361 e = expr_simplify_unmet_dep(sym->rev_dep.expr,
363 fprintf(stderr, "warning: (");
364 expr_fprint(e, stderr);
365 fprintf(stderr, ") selects %s which has unmet direct dependencies (",
367 expr_fprint(sym->dir_dep.expr, stderr);
368 fprintf(stderr, ")\n");
371 newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
373 if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN)
379 if (sym->visible != no) {
380 sym->flags |= SYMBOL_WRITE;
381 if (sym_has_value(sym)) {
382 newval.val = sym->def[S_DEF_USER].val;
386 prop = sym_get_default_prop(sym);
388 struct symbol *ds = prop_get_symbol(prop);
390 sym->flags |= SYMBOL_WRITE;
392 newval.val = ds->curr.val;
401 if (sym_is_choice(sym) && newval.tri == yes)
402 sym->curr.val = sym_calc_choice(sym);
403 sym_validate_range(sym);
405 if (memcmp(&oldval, &sym->curr, sizeof(oldval))) {
406 sym_set_changed(sym);
407 if (modules_sym == sym) {
408 sym_set_all_changed();
409 modules_val = modules_sym->curr.tri;
413 if (sym_is_choice(sym)) {
414 struct symbol *choice_sym;
416 prop = sym_get_choice_prop(sym);
417 expr_list_for_each_sym(prop->expr, e, choice_sym) {
418 if ((sym->flags & SYMBOL_WRITE) &&
419 choice_sym->visible != no)
420 choice_sym->flags |= SYMBOL_WRITE;
421 if (sym->flags & SYMBOL_CHANGED)
422 sym_set_changed(choice_sym);
426 if (sym->flags & SYMBOL_AUTO)
427 sym->flags &= ~SYMBOL_WRITE;
430 void sym_clear_all_valid(void)
435 for_all_symbols(i, sym)
436 sym->flags &= ~SYMBOL_VALID;
437 sym_add_change_count(1);
439 sym_calc_value(modules_sym);
442 void sym_set_changed(struct symbol *sym)
444 struct property *prop;
446 sym->flags |= SYMBOL_CHANGED;
447 for (prop = sym->prop; prop; prop = prop->next) {
449 prop->menu->flags |= MENU_CHANGED;
453 void sym_set_all_changed(void)
458 for_all_symbols(i, sym)
459 sym_set_changed(sym);
462 bool sym_tristate_within_range(struct symbol *sym, tristate val)
464 int type = sym_get_type(sym);
466 if (sym->visible == no)
469 if (type != S_BOOLEAN && type != S_TRISTATE)
472 if (type == S_BOOLEAN && val == mod)
474 if (sym->visible <= sym->rev_dep.tri)
476 if (sym_is_choice_value(sym) && sym->visible == yes)
478 return val >= sym->rev_dep.tri && val <= sym->visible;
481 bool sym_set_tristate_value(struct symbol *sym, tristate val)
483 tristate oldval = sym_get_tristate_value(sym);
485 if (oldval != val && !sym_tristate_within_range(sym, val))
488 if (!(sym->flags & SYMBOL_DEF_USER)) {
489 sym->flags |= SYMBOL_DEF_USER;
490 sym_set_changed(sym);
493 * setting a choice value also resets the new flag of the choice
494 * symbol and all other choice values.
496 if (sym_is_choice_value(sym) && val == yes) {
497 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
498 struct property *prop;
501 cs->def[S_DEF_USER].val = sym;
502 cs->flags |= SYMBOL_DEF_USER;
503 prop = sym_get_choice_prop(cs);
504 for (e = prop->expr; e; e = e->left.expr) {
505 if (e->right.sym->visible != no)
506 e->right.sym->flags |= SYMBOL_DEF_USER;
510 sym->def[S_DEF_USER].tri = val;
512 sym_clear_all_valid();
517 tristate sym_toggle_tristate_value(struct symbol *sym)
519 tristate oldval, newval;
521 oldval = newval = sym_get_tristate_value(sym);
534 if (sym_set_tristate_value(sym, newval))
536 } while (oldval != newval);
540 bool sym_string_valid(struct symbol *sym, const char *str)
553 if (ch == '0' && *str != 0)
555 while ((ch = *str++)) {
561 if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
567 } while ((ch = *str++));
583 bool sym_string_within_range(struct symbol *sym, const char *str)
585 struct property *prop;
590 return sym_string_valid(sym, str);
592 if (!sym_string_valid(sym, str))
594 prop = sym_get_range_prop(sym);
597 val = strtol(str, NULL, 10);
598 return val >= sym_get_range_val(prop->expr->left.sym, 10) &&
599 val <= sym_get_range_val(prop->expr->right.sym, 10);
601 if (!sym_string_valid(sym, str))
603 prop = sym_get_range_prop(sym);
606 val = strtol(str, NULL, 16);
607 return val >= sym_get_range_val(prop->expr->left.sym, 16) &&
608 val <= sym_get_range_val(prop->expr->right.sym, 16);
613 return sym_tristate_within_range(sym, yes);
615 return sym_tristate_within_range(sym, mod);
617 return sym_tristate_within_range(sym, no);
625 bool sym_set_string_value(struct symbol *sym, const char *newval)
636 return sym_set_tristate_value(sym, yes);
638 return sym_set_tristate_value(sym, mod);
640 return sym_set_tristate_value(sym, no);
647 if (!sym_string_within_range(sym, newval))
650 if (!(sym->flags & SYMBOL_DEF_USER)) {
651 sym->flags |= SYMBOL_DEF_USER;
652 sym_set_changed(sym);
655 oldval = sym->def[S_DEF_USER].val;
656 size = strlen(newval) + 1;
657 if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
659 sym->def[S_DEF_USER].val = val = xmalloc(size);
662 } else if (!oldval || strcmp(oldval, newval))
663 sym->def[S_DEF_USER].val = val = xmalloc(size);
668 free((void *)oldval);
669 sym_clear_all_valid();
675 * Find the default value associated to a symbol.
676 * For tristate symbol handle the modules=n case
677 * in which case "m" becomes "y".
678 * If the symbol does not have any default then fallback
679 * to the fixed default values.
681 const char *sym_get_string_default(struct symbol *sym)
683 struct property *prop;
688 sym_calc_visibility(sym);
689 sym_calc_value(modules_sym);
690 val = symbol_no.curr.tri;
691 str = symbol_empty.curr.val;
693 /* If symbol has a default value look it up */
694 prop = sym_get_default_prop(sym);
699 /* The visibility may limit the value from yes => mod */
700 val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri);
704 * The following fails to handle the situation
705 * where a default value is further limited by
708 ds = prop_get_symbol(prop);
711 str = (const char *)ds->curr.val;
716 /* Handle select statements */
717 val = EXPR_OR(val, sym->rev_dep.tri);
719 /* transpose mod to yes if modules are not enabled */
721 if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no)
724 /* transpose mod to yes if type is bool */
725 if (sym->type == S_BOOLEAN && val == mod)
733 case mod: return "m";
734 case yes: return "y";
748 const char *sym_get_string_value(struct symbol *sym)
755 val = sym_get_tristate_value(sym);
760 sym_calc_value(modules_sym);
761 return (modules_sym->curr.tri == no) ? "n" : "m";
769 return (const char *)sym->curr.val;
772 bool sym_is_changable(struct symbol *sym)
774 return sym->visible > sym->rev_dep.tri;
777 static unsigned strhash(const char *s)
780 unsigned hash = 2166136261U;
782 hash = (hash ^ *s) * 0x01000193;
786 struct symbol *sym_lookup(const char *name, int flags)
788 struct symbol *symbol;
793 if (name[0] && !name[1]) {
795 case 'y': return &symbol_yes;
796 case 'm': return &symbol_mod;
797 case 'n': return &symbol_no;
800 hash = strhash(name) % SYMBOL_HASHSIZE;
802 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
804 !strcmp(symbol->name, name) &&
805 (flags ? symbol->flags & flags
806 : !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE))))
809 new_name = strdup(name);
815 symbol = xmalloc(sizeof(*symbol));
816 memset(symbol, 0, sizeof(*symbol));
817 symbol->name = new_name;
818 symbol->type = S_UNKNOWN;
819 symbol->flags |= flags;
821 symbol->next = symbol_hash[hash];
822 symbol_hash[hash] = symbol;
827 struct symbol *sym_find(const char *name)
829 struct symbol *symbol = NULL;
835 if (name[0] && !name[1]) {
837 case 'y': return &symbol_yes;
838 case 'm': return &symbol_mod;
839 case 'n': return &symbol_no;
842 hash = strhash(name) % SYMBOL_HASHSIZE;
844 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
846 !strcmp(symbol->name, name) &&
847 !(symbol->flags & SYMBOL_CONST))
855 * Expand symbol's names embedded in the string given in argument. Symbols'
856 * name to be expanded shall be prefixed by a '$'. Unknown symbol expands to
859 const char *sym_expand_string_value(const char *in)
865 reslen = strlen(in) + 1;
866 res = xmalloc(reslen);
869 while ((src = strchr(in, '$'))) {
870 char *p, name[SYMBOL_MAXLENGTH];
871 const char *symval = "";
875 strncat(res, in, src - in);
879 while (isalnum(*src) || *src == '_')
883 sym = sym_find(name);
886 symval = sym_get_string_value(sym);
889 newlen = strlen(res) + strlen(symval) + strlen(src) + 1;
890 if (newlen > reslen) {
892 res = realloc(res, reslen);
903 const char *sym_escape_string_value(const char *in)
910 reslen = strlen(in) + strlen("\"\"") + 1;
914 l = strcspn(p, "\"\\");
924 res = xmalloc(reslen);
931 l = strcspn(p, "\"\\");
939 strncat(res, p++, 1);
946 struct symbol **sym_re_search(const char *pattern)
948 struct symbol *sym, **sym_arr = NULL;
954 if (strlen(pattern) == 0)
956 if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE))
959 for_all_symbols(i, sym) {
960 if (sym->flags & SYMBOL_CONST || !sym->name)
962 if (regexec(&re, sym->name, 0, NULL, 0))
964 if (cnt + 1 >= size) {
967 sym_arr = realloc(sym_arr, size * sizeof(struct symbol *));
974 sym_arr[cnt++] = sym;
984 * When we check for recursive dependencies we use a stack to save
985 * current state so we can print out relevant info to user.
986 * The entries are located on the call stack so no need to free memory.
987 * Note inser() remove() must always match to properly clear the stack.
989 static struct dep_stack {
990 struct dep_stack *prev, *next;
992 struct property *prop;
996 static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym)
998 memset(stack, 0, sizeof(*stack));
1000 check_top->next = stack;
1001 stack->prev = check_top;
1006 static void dep_stack_remove(void)
1008 check_top = check_top->prev;
1010 check_top->next = NULL;
1014 * Called when we have detected a recursive dependency.
1015 * check_top point to the top of the stact so we use
1016 * the ->prev pointer to locate the bottom of the stack.
1018 static void sym_check_print_recursive(struct symbol *last_sym)
1020 struct dep_stack *stack;
1021 struct symbol *sym, *next_sym;
1022 struct menu *menu = NULL;
1023 struct property *prop;
1024 struct dep_stack cv_stack;
1026 if (sym_is_choice_value(last_sym)) {
1027 dep_stack_insert(&cv_stack, last_sym);
1028 last_sym = prop_get_symbol(sym_get_choice_prop(last_sym));
1031 for (stack = check_top; stack != NULL; stack = stack->prev)
1032 if (stack->sym == last_sym)
1035 fprintf(stderr, "unexpected recursive dependency error\n");
1039 for (; stack; stack = stack->next) {
1041 next_sym = stack->next ? stack->next->sym : last_sym;
1044 prop = stack->sym->prop;
1046 /* for choice values find the menu entry (used below) */
1047 if (sym_is_choice(sym) || sym_is_choice_value(sym)) {
1048 for (prop = sym->prop; prop; prop = prop->next) {
1054 if (stack->sym == last_sym)
1055 fprintf(stderr, "%s:%d:error: recursive dependency detected!\n",
1056 prop->file->name, prop->lineno);
1058 fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
1059 prop->file->name, prop->lineno,
1060 sym->name ? sym->name : "<choice>",
1061 prop_get_type_name(prop->type),
1062 next_sym->name ? next_sym->name : "<choice>");
1063 } else if (stack->prop) {
1064 fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n",
1065 prop->file->name, prop->lineno,
1066 sym->name ? sym->name : "<choice>",
1067 next_sym->name ? next_sym->name : "<choice>");
1068 } else if (sym_is_choice(sym)) {
1069 fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n",
1070 menu->file->name, menu->lineno,
1071 sym->name ? sym->name : "<choice>",
1072 next_sym->name ? next_sym->name : "<choice>");
1073 } else if (sym_is_choice_value(sym)) {
1074 fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n",
1075 menu->file->name, menu->lineno,
1076 sym->name ? sym->name : "<choice>",
1077 next_sym->name ? next_sym->name : "<choice>");
1079 fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n",
1080 prop->file->name, prop->lineno,
1081 sym->name ? sym->name : "<choice>",
1082 next_sym->name ? next_sym->name : "<choice>");
1086 if (check_top == &cv_stack)
1090 static struct symbol *sym_check_expr_deps(struct expr *e)
1099 sym = sym_check_expr_deps(e->left.expr);
1102 return sym_check_expr_deps(e->right.expr);
1104 return sym_check_expr_deps(e->left.expr);
1107 sym = sym_check_deps(e->left.sym);
1110 return sym_check_deps(e->right.sym);
1112 return sym_check_deps(e->left.sym);
1116 printf("Oops! How to check %d?\n", e->type);
1120 /* return NULL when dependencies are OK */
1121 static struct symbol *sym_check_sym_deps(struct symbol *sym)
1123 struct symbol *sym2;
1124 struct property *prop;
1125 struct dep_stack stack;
1127 dep_stack_insert(&stack, sym);
1129 sym2 = sym_check_expr_deps(sym->rev_dep.expr);
1133 for (prop = sym->prop; prop; prop = prop->next) {
1134 if (prop->type == P_CHOICE || prop->type == P_SELECT)
1137 sym2 = sym_check_expr_deps(prop->visible.expr);
1140 if (prop->type != P_DEFAULT || sym_is_choice(sym))
1142 stack.expr = prop->expr;
1143 sym2 = sym_check_expr_deps(prop->expr);
1155 static struct symbol *sym_check_choice_deps(struct symbol *choice)
1157 struct symbol *sym, *sym2;
1158 struct property *prop;
1160 struct dep_stack stack;
1162 dep_stack_insert(&stack, choice);
1164 prop = sym_get_choice_prop(choice);
1165 expr_list_for_each_sym(prop->expr, e, sym)
1166 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
1168 choice->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
1169 sym2 = sym_check_sym_deps(choice);
1170 choice->flags &= ~SYMBOL_CHECK;
1174 expr_list_for_each_sym(prop->expr, e, sym) {
1175 sym2 = sym_check_sym_deps(sym);
1180 expr_list_for_each_sym(prop->expr, e, sym)
1181 sym->flags &= ~SYMBOL_CHECK;
1183 if (sym2 && sym_is_choice_value(sym2) &&
1184 prop_get_symbol(sym_get_choice_prop(sym2)) == choice)
1192 struct symbol *sym_check_deps(struct symbol *sym)
1194 struct symbol *sym2;
1195 struct property *prop;
1197 if (sym->flags & SYMBOL_CHECK) {
1198 sym_check_print_recursive(sym);
1201 if (sym->flags & SYMBOL_CHECKED)
1204 if (sym_is_choice_value(sym)) {
1205 struct dep_stack stack;
1207 /* for choice groups start the check with main choice symbol */
1208 dep_stack_insert(&stack, sym);
1209 prop = sym_get_choice_prop(sym);
1210 sym2 = sym_check_deps(prop_get_symbol(prop));
1212 } else if (sym_is_choice(sym)) {
1213 sym2 = sym_check_choice_deps(sym);
1215 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED);
1216 sym2 = sym_check_sym_deps(sym);
1217 sym->flags &= ~SYMBOL_CHECK;
1220 if (sym2 && sym2 == sym)
1226 struct property *prop_alloc(enum prop_type type, struct symbol *sym)
1228 struct property *prop;
1229 struct property **propp;
1231 prop = xmalloc(sizeof(*prop));
1232 memset(prop, 0, sizeof(*prop));
1235 prop->file = current_file;
1236 prop->lineno = zconf_lineno();
1238 /* append property to the prop list of symbol */
1240 for (propp = &sym->prop; *propp; propp = &(*propp)->next)
1248 struct symbol *prop_get_symbol(struct property *prop)
1250 if (prop->expr && (prop->expr->type == E_SYMBOL ||
1251 prop->expr->type == E_LIST))
1252 return prop->expr->left.sym;
1256 const char *prop_get_type_name(enum prop_type type)
1283 static void prop_add_env(const char *env)
1285 struct symbol *sym, *sym2;
1286 struct property *prop;
1289 sym = current_entry->sym;
1290 sym->flags |= SYMBOL_AUTO;
1291 for_all_properties(sym, prop, P_ENV) {
1292 sym2 = prop_get_symbol(prop);
1293 if (strcmp(sym2->name, env))
1294 menu_warn(current_entry, "redefining environment symbol from %s",
1299 prop = prop_alloc(P_ENV, sym);
1300 prop->expr = expr_alloc_symbol(sym_lookup(env, SYMBOL_CONST));
1302 sym_env_list = expr_alloc_one(E_LIST, sym_env_list);
1303 sym_env_list->right.sym = sym;
1307 sym_add_default(sym, p);
1309 menu_warn(current_entry, "environment variable %s undefined", env);