symbol.c (a23e1966932464e1c5226cb9ac4ce1d5fc10ba22) | symbol.c (fde192511bdbff554320b31574bb8a9cb3275522) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 4 */ 5 6#include <sys/types.h> 7#include <ctype.h> 8#include <stdlib.h> 9#include <string.h> 10#include <regex.h> 11 12#include "internal.h" 13#include "lkc.h" 14 15struct symbol symbol_yes = { 16 .name = "y", | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 4 */ 5 6#include <sys/types.h> 7#include <ctype.h> 8#include <stdlib.h> 9#include <string.h> 10#include <regex.h> 11 12#include "internal.h" 13#include "lkc.h" 14 15struct symbol symbol_yes = { 16 .name = "y", |
17 .type = S_TRISTATE, |
|
17 .curr = { "y", yes }, 18 .menus = LIST_HEAD_INIT(symbol_yes.menus), 19 .flags = SYMBOL_CONST|SYMBOL_VALID, 20}; 21 22struct symbol symbol_mod = { 23 .name = "m", | 18 .curr = { "y", yes }, 19 .menus = LIST_HEAD_INIT(symbol_yes.menus), 20 .flags = SYMBOL_CONST|SYMBOL_VALID, 21}; 22 23struct symbol symbol_mod = { 24 .name = "m", |
25 .type = S_TRISTATE, |
|
24 .curr = { "m", mod }, 25 .menus = LIST_HEAD_INIT(symbol_mod.menus), 26 .flags = SYMBOL_CONST|SYMBOL_VALID, 27}; 28 29struct symbol symbol_no = { 30 .name = "n", | 26 .curr = { "m", mod }, 27 .menus = LIST_HEAD_INIT(symbol_mod.menus), 28 .flags = SYMBOL_CONST|SYMBOL_VALID, 29}; 30 31struct symbol symbol_no = { 32 .name = "n", |
33 .type = S_TRISTATE, |
|
31 .curr = { "n", no }, 32 .menus = LIST_HEAD_INIT(symbol_no.menus), 33 .flags = SYMBOL_CONST|SYMBOL_VALID, 34}; 35 36struct symbol *modules_sym; 37static tristate modules_val; 38static int sym_warnings; 39 40enum symbol_type sym_get_type(struct symbol *sym) 41{ 42 enum symbol_type type = sym->type; 43 | 34 .curr = { "n", no }, 35 .menus = LIST_HEAD_INIT(symbol_no.menus), 36 .flags = SYMBOL_CONST|SYMBOL_VALID, 37}; 38 39struct symbol *modules_sym; 40static tristate modules_val; 41static int sym_warnings; 42 43enum symbol_type sym_get_type(struct symbol *sym) 44{ 45 enum symbol_type type = sym->type; 46 |
44 if (type == S_TRISTATE) { 45 if (sym_is_choice_value(sym) && sym->visible == yes) 46 type = S_BOOLEAN; 47 else if (modules_val == no) 48 type = S_BOOLEAN; 49 } | 47 if (type == S_TRISTATE && modules_val == no) 48 type = S_BOOLEAN; |
50 return type; 51} 52 53const char *sym_type_name(enum symbol_type type) 54{ 55 switch (type) { 56 case S_BOOLEAN: 57 return "bool"; --- 15 unchanged lines hidden (view full) --- 73{ 74 struct property *prop; 75 76 for_all_choices(sym, prop) 77 return prop; 78 return NULL; 79} 80 | 49 return type; 50} 51 52const char *sym_type_name(enum symbol_type type) 53{ 54 switch (type) { 55 case S_BOOLEAN: 56 return "bool"; --- 15 unchanged lines hidden (view full) --- 72{ 73 struct property *prop; 74 75 for_all_choices(sym, prop) 76 return prop; 77 return NULL; 78} 79 |
80/** 81 * sym_get_choice_menu - get the parent choice menu if present 82 * 83 * @sym: a symbol pointer 84 * 85 * Return: a choice menu if this function is called against a choice member. 86 */ 87struct menu *sym_get_choice_menu(struct symbol *sym) 88{ 89 struct menu *menu = NULL; 90 struct menu *m; 91 92 /* 93 * Choice members must have a prompt. Find a menu entry with a prompt, 94 * and assume it resides inside a choice block. 95 */ 96 list_for_each_entry(m, &sym->menus, link) 97 if (m->prompt) { 98 menu = m; 99 break; 100 } 101 102 if (!menu) 103 return NULL; 104 105 do { 106 menu = menu->parent; 107 } while (menu && !menu->sym); 108 109 if (menu && menu->sym && sym_is_choice(menu->sym)) 110 return menu; 111 112 return NULL; 113} 114 |
|
81static struct property *sym_get_default_prop(struct symbol *sym) 82{ 83 struct property *prop; 84 85 for_all_defaults(sym, prop) { 86 prop->visible.tri = expr_calc_value(prop->visible.expr); 87 if (prop->visible.tri != no) 88 return prop; --- 58 unchanged lines hidden (view full) --- 147 if (val <= val2) 148 return; 149 } 150 sym->curr.val = range_sym->curr.val; 151} 152 153static void sym_set_changed(struct symbol *sym) 154{ | 115static struct property *sym_get_default_prop(struct symbol *sym) 116{ 117 struct property *prop; 118 119 for_all_defaults(sym, prop) { 120 prop->visible.tri = expr_calc_value(prop->visible.expr); 121 if (prop->visible.tri != no) 122 return prop; --- 58 unchanged lines hidden (view full) --- 181 if (val <= val2) 182 return; 183 } 184 sym->curr.val = range_sym->curr.val; 185} 186 187static void sym_set_changed(struct symbol *sym) 188{ |
155 struct property *prop; | 189 struct menu *menu; |
156 157 sym->flags |= SYMBOL_CHANGED; | 190 191 sym->flags |= SYMBOL_CHANGED; |
158 for (prop = sym->prop; prop; prop = prop->next) { 159 if (prop->menu) 160 prop->menu->flags |= MENU_CHANGED; 161 } | 192 list_for_each_entry(menu, &sym->menus, link) 193 menu->flags |= MENU_CHANGED; |
162} 163 164static void sym_set_all_changed(void) 165{ 166 struct symbol *sym; 167 168 for_all_symbols(sym) 169 sym_set_changed(sym); 170} 171 172static void sym_calc_visibility(struct symbol *sym) 173{ 174 struct property *prop; | 194} 195 196static void sym_set_all_changed(void) 197{ 198 struct symbol *sym; 199 200 for_all_symbols(sym) 201 sym_set_changed(sym); 202} 203 204static void sym_calc_visibility(struct symbol *sym) 205{ 206 struct property *prop; |
175 struct symbol *choice_sym = NULL; | |
176 tristate tri; 177 178 /* any prompt visible? */ 179 tri = no; | 207 tristate tri; 208 209 /* any prompt visible? */ 210 tri = no; |
180 181 if (sym_is_choice_value(sym)) 182 choice_sym = prop_get_symbol(sym_get_choice_prop(sym)); 183 | |
184 for_all_prompts(sym, prop) { 185 prop->visible.tri = expr_calc_value(prop->visible.expr); | 211 for_all_prompts(sym, prop) { 212 prop->visible.tri = expr_calc_value(prop->visible.expr); |
186 /* 187 * Tristate choice_values with visibility 'mod' are 188 * not visible if the corresponding choice's value is 189 * 'yes'. 190 */ 191 if (choice_sym && sym->type == S_TRISTATE && 192 prop->visible.tri == mod && choice_sym->curr.tri == yes) 193 prop->visible.tri = no; 194 | |
195 tri = EXPR_OR(tri, prop->visible.tri); 196 } 197 if (tri == mod && (sym->type != S_TRISTATE || modules_val == no)) 198 tri = yes; 199 if (sym->visible != tri) { 200 sym->visible = tri; 201 sym_set_changed(sym); 202 } --- 258 unchanged lines hidden (view full) --- 461 prop = sym_get_choice_prop(sym); 462 expr_list_for_each_sym(prop->expr, e, choice_sym) { 463 if ((sym->flags & SYMBOL_WRITE) && 464 choice_sym->visible != no) 465 choice_sym->flags |= SYMBOL_WRITE; 466 if (sym->flags & SYMBOL_CHANGED) 467 sym_set_changed(choice_sym); 468 } | 213 tri = EXPR_OR(tri, prop->visible.tri); 214 } 215 if (tri == mod && (sym->type != S_TRISTATE || modules_val == no)) 216 tri = yes; 217 if (sym->visible != tri) { 218 sym->visible = tri; 219 sym_set_changed(sym); 220 } --- 258 unchanged lines hidden (view full) --- 479 prop = sym_get_choice_prop(sym); 480 expr_list_for_each_sym(prop->expr, e, choice_sym) { 481 if ((sym->flags & SYMBOL_WRITE) && 482 choice_sym->visible != no) 483 choice_sym->flags |= SYMBOL_WRITE; 484 if (sym->flags & SYMBOL_CHANGED) 485 sym_set_changed(choice_sym); 486 } |
469 } | |
470 | 487 |
471 if (sym->flags & SYMBOL_NO_WRITE) | |
472 sym->flags &= ~SYMBOL_WRITE; | 488 sym->flags &= ~SYMBOL_WRITE; |
489 } |
|
473 474 if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) 475 set_all_choice_values(sym); 476} 477 478void sym_clear_all_valid(void) 479{ 480 struct symbol *sym; --- 302 unchanged lines hidden (view full) --- 783 switch (sym->type) { 784 case S_BOOLEAN: 785 case S_TRISTATE: 786 val = sym_get_tristate_value(sym); 787 switch (val) { 788 case no: 789 return "n"; 790 case mod: | 490 491 if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) 492 set_all_choice_values(sym); 493} 494 495void sym_clear_all_valid(void) 496{ 497 struct symbol *sym; --- 302 unchanged lines hidden (view full) --- 800 switch (sym->type) { 801 case S_BOOLEAN: 802 case S_TRISTATE: 803 val = sym_get_tristate_value(sym); 804 switch (val) { 805 case no: 806 return "n"; 807 case mod: |
791 sym_calc_value(modules_sym); 792 return (modules_sym->curr.tri == no) ? "n" : "m"; | 808 return "m"; |
793 case yes: 794 return "y"; 795 } 796 break; 797 default: 798 ; 799 } 800 return (const char *)sym->curr.val; --- 21 unchanged lines hidden (view full) --- 822 } 823 } 824 hash = strhash(name); 825 826 hash_for_each_possible(sym_hashtable, symbol, node, hash) { 827 if (symbol->name && 828 !strcmp(symbol->name, name) && 829 (flags ? symbol->flags & flags | 809 case yes: 810 return "y"; 811 } 812 break; 813 default: 814 ; 815 } 816 return (const char *)sym->curr.val; --- 21 unchanged lines hidden (view full) --- 838 } 839 } 840 hash = strhash(name); 841 842 hash_for_each_possible(sym_hashtable, symbol, node, hash) { 843 if (symbol->name && 844 !strcmp(symbol->name, name) && 845 (flags ? symbol->flags & flags |
830 : !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE)))) | 846 : !(symbol->flags & SYMBOL_CONST))) |
831 return symbol; 832 } 833 new_name = xstrdup(name); 834 } else { 835 new_name = NULL; 836 hash = 0; 837 } 838 --- 328 unchanged lines hidden (view full) --- 1167out: 1168 dep_stack_remove(); 1169 1170 return sym2; 1171} 1172 1173static struct symbol *sym_check_choice_deps(struct symbol *choice) 1174{ | 847 return symbol; 848 } 849 new_name = xstrdup(name); 850 } else { 851 new_name = NULL; 852 hash = 0; 853 } 854 --- 328 unchanged lines hidden (view full) --- 1183out: 1184 dep_stack_remove(); 1185 1186 return sym2; 1187} 1188 1189static struct symbol *sym_check_choice_deps(struct symbol *choice) 1190{ |
1175 struct symbol *sym, *sym2; 1176 struct property *prop; 1177 struct expr *e; | 1191 struct menu *choice_menu, *menu; 1192 struct symbol *sym2; |
1178 struct dep_stack stack; 1179 1180 dep_stack_insert(&stack, choice); 1181 | 1193 struct dep_stack stack; 1194 1195 dep_stack_insert(&stack, choice); 1196 |
1182 prop = sym_get_choice_prop(choice); 1183 expr_list_for_each_sym(prop->expr, e, sym) 1184 sym->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); | 1197 choice_menu = list_first_entry(&choice->menus, struct menu, link); |
1185 | 1198 |
1199 menu_for_each_sub_entry(menu, choice_menu) { 1200 if (menu->sym) 1201 menu->sym->flags |= SYMBOL_CHECK | SYMBOL_CHECKED; 1202 } 1203 |
|
1186 choice->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); 1187 sym2 = sym_check_sym_deps(choice); 1188 choice->flags &= ~SYMBOL_CHECK; 1189 if (sym2) 1190 goto out; 1191 | 1204 choice->flags |= (SYMBOL_CHECK | SYMBOL_CHECKED); 1205 sym2 = sym_check_sym_deps(choice); 1206 choice->flags &= ~SYMBOL_CHECK; 1207 if (sym2) 1208 goto out; 1209 |
1192 expr_list_for_each_sym(prop->expr, e, sym) { 1193 sym2 = sym_check_sym_deps(sym); | 1210 menu_for_each_sub_entry(menu, choice_menu) { 1211 if (!menu->sym) 1212 continue; 1213 sym2 = sym_check_sym_deps(menu->sym); |
1194 if (sym2) 1195 break; 1196 } 1197out: | 1214 if (sym2) 1215 break; 1216 } 1217out: |
1198 expr_list_for_each_sym(prop->expr, e, sym) 1199 sym->flags &= ~SYMBOL_CHECK; | 1218 menu_for_each_sub_entry(menu, choice_menu) 1219 if (menu->sym) 1220 menu->sym->flags &= ~SYMBOL_CHECK; |
1200 1201 if (sym2 && sym_is_choice_value(sym2) && 1202 prop_get_symbol(sym_get_choice_prop(sym2)) == choice) 1203 sym2 = choice; 1204 1205 dep_stack_remove(); 1206 1207 return sym2; --- 67 unchanged lines hidden --- | 1221 1222 if (sym2 && sym_is_choice_value(sym2) && 1223 prop_get_symbol(sym_get_choice_prop(sym2)) == choice) 1224 sym2 = choice; 1225 1226 dep_stack_remove(); 1227 1228 return sym2; --- 67 unchanged lines hidden --- |