summaryrefslogtreecommitdiff
path: root/scripts/kconfig/symbol.c
Unidiff
Diffstat (limited to 'scripts/kconfig/symbol.c') (more/less context) (show whitespace changes)
-rw-r--r--scripts/kconfig/symbol.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 59c88d2..845d8a3 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -146,13 +146,13 @@ void sym_calc_visibility(struct symbol *sym)
146 oldvisible = sym->visible; 146 oldvisible = sym->visible;
147 visible = no; 147 visible = no;
148 for_all_prompts(sym, prop) 148 for_all_prompts(sym, prop)
149 visible = E_OR(visible, E_CALC(prop->visible)); 149 visible = E_OR(visible, E_CALC(prop->visible));
150 if (oldvisible != visible) { 150 if (oldvisible != visible) {
151 sym->visible = visible; 151 sym->visible = visible;
152 sym->flags |= SYMBOL_CHANGED; 152 sym_set_changed(sym);
153 } 153 }
154} 154}
155 155
156void sym_calc_value(struct symbol *sym) 156void sym_calc_value(struct symbol *sym)
157{ 157{
158 struct symbol_value newval, oldval; 158 struct symbol_value newval, oldval;
@@ -201,13 +201,14 @@ void sym_calc_value(struct symbol *sym)
201 if (!sym_is_choice(sym)) { 201 if (!sym_is_choice(sym)) {
202 prop = sym_get_default_prop(sym); 202 prop = sym_get_default_prop(sym);
203 if (prop) { 203 if (prop) {
204 sym_calc_value(prop->def); 204 sym_calc_value(prop->def);
205 newval = prop->def->curr; 205 newval = prop->def->curr;
206 } 206 }
207 } 207 } else
208 S_TRI(newval) = S_TRI(sym->def);
208 } else 209 } else
209 newval = sym->def; 210 newval = sym->def;
210 211
211 S_TRI(newval) = E_AND(S_TRI(newval), sym->visible); 212 S_TRI(newval) = E_AND(S_TRI(newval), sym->visible);
212 /* if the symbol is visible and not optionial, 213 /* if the symbol is visible and not optionial,
213 * possibly ignore old user choice. */ 214 * possibly ignore old user choice. */
@@ -273,20 +274,23 @@ out:
273 } 274 }
274 275
275 S_VAL(newval) = def_sym; 276 S_VAL(newval) = def_sym;
276 } 277 }
277 278
278 if (memcmp(&oldval, &newval, sizeof(newval))) 279 if (memcmp(&oldval, &newval, sizeof(newval)))
279 sym->flags |= SYMBOL_CHANGED; 280 sym_set_changed(sym);
280 sym->curr = newval; 281 sym->curr = newval;
281 282
282 if (sym_is_choice(sym)) { 283 if (sym_is_choice(sym)) {
283 int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE); 284 int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
284 prop = sym_get_choice_prop(sym); 285 prop = sym_get_choice_prop(sym);
285 for (e = prop->dep; e; e = e->left.expr) 286 for (e = prop->dep; e; e = e->left.expr) {
286 e->right.sym->flags |= flags; 287 e->right.sym->flags |= flags;
288 if (flags & SYMBOL_CHANGED)
289 sym_set_changed(e->right.sym);
290 }
287 } 291 }
288} 292}
289 293
290void sym_clear_all_valid(void) 294void sym_clear_all_valid(void)
291{ 295{
292 struct symbol *sym; 296 struct symbol *sym;
@@ -294,19 +298,30 @@ void sym_clear_all_valid(void)
294 298
295 for_all_symbols(i, sym) 299 for_all_symbols(i, sym)
296 sym->flags &= ~SYMBOL_VALID; 300 sym->flags &= ~SYMBOL_VALID;
297 sym_change_count++; 301 sym_change_count++;
298} 302}
299 303
304void sym_set_changed(struct symbol *sym)
305{
306 struct property *prop;
307
308 sym->flags |= SYMBOL_CHANGED;
309 for (prop = sym->prop; prop; prop = prop->next) {
310 if (prop->menu)
311 prop->menu->flags |= MENU_CHANGED;
312 }
313}
314
300void sym_set_all_changed(void) 315void sym_set_all_changed(void)
301{ 316{
302 struct symbol *sym; 317 struct symbol *sym;
303 int i; 318 int i;
304 319
305 for_all_symbols(i, sym) 320 for_all_symbols(i, sym)
306 sym->flags |= SYMBOL_CHANGED; 321 sym_set_changed(sym);
307} 322}
308 323
309bool sym_tristate_within_range(struct symbol *sym, tristate val) 324bool sym_tristate_within_range(struct symbol *sym, tristate val)
310{ 325{
311 int type = sym_get_type(sym); 326 int type = sym_get_type(sym);
312 327
@@ -337,13 +352,13 @@ bool sym_set_tristate_value(struct symbol *sym, tristate val)
337 352
338 if (oldval != val && !sym_tristate_within_range(sym, val)) 353 if (oldval != val && !sym_tristate_within_range(sym, val))
339 return false; 354 return false;
340 355
341 if (sym->flags & SYMBOL_NEW) { 356 if (sym->flags & SYMBOL_NEW) {
342 sym->flags &= ~SYMBOL_NEW; 357 sym->flags &= ~SYMBOL_NEW;
343 sym->flags |= SYMBOL_CHANGED; 358 sym_set_changed(sym);
344 } 359 }
345 if (sym_is_choice_value(sym) && val == yes) { 360 if (sym_is_choice_value(sym) && val == yes) {
346 struct property *prop = sym_get_choice_prop(sym); 361 struct property *prop = sym_get_choice_prop(sym);
347 362
348 S_VAL(prop->def->def) = sym; 363 S_VAL(prop->def->def) = sym;
349 prop->def->flags &= ~SYMBOL_NEW; 364 prop->def->flags &= ~SYMBOL_NEW;
@@ -457,13 +472,13 @@ bool sym_set_string_value(struct symbol *sym, const char *newval)
457 472
458 if (!sym_string_valid(sym, newval)) 473 if (!sym_string_valid(sym, newval))
459 return false; 474 return false;
460 475
461 if (sym->flags & SYMBOL_NEW) { 476 if (sym->flags & SYMBOL_NEW) {
462 sym->flags &= ~SYMBOL_NEW; 477 sym->flags &= ~SYMBOL_NEW;
463 sym->flags |= SYMBOL_CHANGED; 478 sym_set_changed(sym);
464 } 479 }
465 480
466 oldval = S_VAL(sym->def); 481 oldval = S_VAL(sym->def);
467 size = strlen(newval) + 1; 482 size = strlen(newval) + 1;
468 if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) { 483 if (sym->type == S_HEX && (newval[0] != '0' || (newval[1] != 'x' && newval[1] != 'X'))) {
469 size += 2; 484 size += 2;
@@ -522,13 +537,12 @@ struct symbol *sym_lookup(const char *name, int isconst)
522{ 537{
523 struct symbol *symbol; 538 struct symbol *symbol;
524 const char *ptr; 539 const char *ptr;
525 char *new_name; 540 char *new_name;
526 int hash = 0; 541 int hash = 0;
527 542
528 //printf("lookup: %s -> ", name);
529 if (name) { 543 if (name) {
530 if (name[0] && !name[1]) { 544 if (name[0] && !name[1]) {
531 switch (name[0]) { 545 switch (name[0]) {
532 case 'y': return &symbol_yes; 546 case 'y': return &symbol_yes;
533 case 'm': return &symbol_mod; 547 case 'm': return &symbol_mod;
534 case 'n': return &symbol_no; 548 case 'n': return &symbol_no;
@@ -538,18 +552,16 @@ struct symbol *sym_lookup(const char *name, int isconst)
538 hash += *ptr; 552 hash += *ptr;
539 hash &= 0xff; 553 hash &= 0xff;
540 554
541 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { 555 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
542 if (!strcmp(symbol->name, name)) { 556 if (!strcmp(symbol->name, name)) {
543 if ((isconst && symbol->flags & SYMBOL_CONST) || 557 if ((isconst && symbol->flags & SYMBOL_CONST) ||
544 (!isconst && !(symbol->flags & SYMBOL_CONST))) { 558 (!isconst && !(symbol->flags & SYMBOL_CONST)))
545 //printf("h:%p\n", symbol);
546 return symbol; 559 return symbol;
547 } 560 }
548 } 561 }
549 }
550 new_name = strdup(name); 562 new_name = strdup(name);
551 } else { 563 } else {
552 new_name = NULL; 564 new_name = NULL;
553 hash = 256; 565 hash = 256;
554 } 566 }
555 567
@@ -561,13 +573,12 @@ struct symbol *sym_lookup(const char *name, int isconst)
561 if (isconst) 573 if (isconst)
562 symbol->flags |= SYMBOL_CONST; 574 symbol->flags |= SYMBOL_CONST;
563 575
564 symbol->next = symbol_hash[hash]; 576 symbol->next = symbol_hash[hash];
565 symbol_hash[hash] = symbol; 577 symbol_hash[hash] = symbol;
566 578
567 //printf("n:%p\n", symbol);
568 return symbol; 579 return symbol;
569} 580}
570 581
571struct symbol *sym_find(const char *name) 582struct symbol *sym_find(const char *name)
572{ 583{
573 struct symbol *symbol = NULL; 584 struct symbol *symbol = NULL;