-rw-r--r-- | scripts/kconfig/symbol.c | 35 |
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 | |||
@@ -140,25 +140,25 @@ struct property *sym_get_default_prop(struct symbol *sym) | |||
140 | void sym_calc_visibility(struct symbol *sym) | 140 | void sym_calc_visibility(struct symbol *sym) |
141 | { | 141 | { |
142 | struct property *prop; | 142 | struct property *prop; |
143 | tristate visible, oldvisible; | 143 | tristate visible, oldvisible; |
144 | 144 | ||
145 | /* any prompt visible? */ | 145 | /* any prompt visible? */ |
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 | ||
156 | void sym_calc_value(struct symbol *sym) | 156 | void sym_calc_value(struct symbol *sym) |
157 | { | 157 | { |
158 | struct symbol_value newval, oldval; | 158 | struct symbol_value newval, oldval; |
159 | struct property *prop, *def_prop; | 159 | struct property *prop, *def_prop; |
160 | struct symbol *def_sym; | 160 | struct symbol *def_sym; |
161 | struct expr *e; | 161 | struct expr *e; |
162 | 162 | ||
163 | if (sym->flags & SYMBOL_VALID) | 163 | if (sym->flags & SYMBOL_VALID) |
164 | return; | 164 | return; |
@@ -195,25 +195,26 @@ void sym_calc_value(struct symbol *sym) | |||
195 | /* set default if recursively called */ | 195 | /* set default if recursively called */ |
196 | sym->curr = newval; | 196 | sym->curr = newval; |
197 | 197 | ||
198 | if (sym->visible != no) { | 198 | if (sym->visible != no) { |
199 | sym->flags |= SYMBOL_WRITE; | 199 | sym->flags |= SYMBOL_WRITE; |
200 | if (!sym_has_value(sym)) { | 200 | if (!sym_has_value(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. */ |
214 | if (!sym_is_optional(sym) && S_TRI(newval) == no) | 215 | if (!sym_is_optional(sym) && S_TRI(newval) == no) |
215 | S_TRI(newval) = sym->visible; | 216 | S_TRI(newval) = sym->visible; |
216 | if (sym_is_choice_value(sym) && sym->visible == yes) { | 217 | if (sym_is_choice_value(sym) && sym->visible == yes) { |
217 | prop = sym_get_choice_prop(sym); | 218 | prop = sym_get_choice_prop(sym); |
218 | S_TRI(newval) = (S_VAL(prop->def->curr) == sym) ? yes : no; | 219 | S_TRI(newval) = (S_VAL(prop->def->curr) == sym) ? yes : no; |
219 | } | 220 | } |
@@ -267,52 +268,66 @@ out: | |||
267 | sym_calc_visibility(e->right.sym); | 268 | sym_calc_visibility(e->right.sym); |
268 | if (e->right.sym->visible != no) { | 269 | if (e->right.sym->visible != no) { |
269 | def_sym = e->right.sym; | 270 | def_sym = e->right.sym; |
270 | break; | 271 | break; |
271 | } | 272 | } |
272 | } | 273 | } |
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 | ||
290 | void sym_clear_all_valid(void) | 294 | void sym_clear_all_valid(void) |
291 | { | 295 | { |
292 | struct symbol *sym; | 296 | struct symbol *sym; |
293 | int i; | 297 | int i; |
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 | ||
304 | void 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 | |||
300 | void sym_set_all_changed(void) | 315 | void 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 | ||
309 | bool sym_tristate_within_range(struct symbol *sym, tristate val) | 324 | bool 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 | ||
313 | if (sym->visible == no) | 328 | if (sym->visible == no) |
314 | return false; | 329 | return false; |
315 | 330 | ||
316 | if (type != S_BOOLEAN && type != S_TRISTATE) | 331 | if (type != S_BOOLEAN && type != S_TRISTATE) |
317 | return false; | 332 | return false; |
318 | 333 | ||
@@ -331,25 +346,25 @@ bool sym_tristate_within_range(struct symbol *sym, tristate val) | |||
331 | return false; | 346 | return false; |
332 | } | 347 | } |
333 | 348 | ||
334 | bool sym_set_tristate_value(struct symbol *sym, tristate val) | 349 | bool sym_set_tristate_value(struct symbol *sym, tristate val) |
335 | { | 350 | { |
336 | tristate oldval = sym_get_tristate_value(sym); | 351 | tristate oldval = sym_get_tristate_value(sym); |
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; |
350 | } | 365 | } |
351 | 366 | ||
352 | S_TRI(sym->def) = val; | 367 | S_TRI(sym->def) = val; |
353 | if (oldval != val) { | 368 | if (oldval != val) { |
354 | sym_clear_all_valid(); | 369 | sym_clear_all_valid(); |
355 | if (sym == modules_sym) | 370 | if (sym == modules_sym) |
@@ -451,25 +466,25 @@ bool sym_set_string_value(struct symbol *sym, const char *newval) | |||
451 | return sym_set_tristate_value(sym, no); | 466 | return sym_set_tristate_value(sym, no); |
452 | } | 467 | } |
453 | return false; | 468 | return false; |
454 | default: | 469 | default: |
455 | ; | 470 | ; |
456 | } | 471 | } |
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; |
470 | S_VAL(sym->def) = val = malloc(size); | 485 | S_VAL(sym->def) = val = malloc(size); |
471 | *val++ = '0'; | 486 | *val++ = '0'; |
472 | *val++ = 'x'; | 487 | *val++ = 'x'; |
473 | } else if (!oldval || strcmp(oldval, newval)) | 488 | } else if (!oldval || strcmp(oldval, newval)) |
474 | S_VAL(sym->def) = val = malloc(size); | 489 | S_VAL(sym->def) = val = malloc(size); |
475 | else | 490 | else |
@@ -516,64 +531,60 @@ bool sym_is_changable(struct symbol *sym) | |||
516 | if (sym_get_type(sym) == S_TRISTATE && sym->visible == yes) | 531 | if (sym_get_type(sym) == S_TRISTATE && sym->visible == yes) |
517 | return true; | 532 | return true; |
518 | return false; | 533 | return false; |
519 | } | 534 | } |
520 | 535 | ||
521 | struct symbol *sym_lookup(const char *name, int isconst) | 536 | 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; |
535 | } | 549 | } |
536 | } | 550 | } |
537 | for (ptr = name; *ptr; ptr++) | 551 | for (ptr = name; *ptr; ptr++) |
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 | ||
556 | symbol = malloc(sizeof(*symbol)); | 568 | symbol = malloc(sizeof(*symbol)); |
557 | memset(symbol, 0, sizeof(*symbol)); | 569 | memset(symbol, 0, sizeof(*symbol)); |
558 | symbol->name = new_name; | 570 | symbol->name = new_name; |
559 | symbol->type = S_UNKNOWN; | 571 | symbol->type = S_UNKNOWN; |
560 | symbol->flags = SYMBOL_NEW; | 572 | symbol->flags = SYMBOL_NEW; |
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 | ||
571 | struct symbol *sym_find(const char *name) | 582 | struct symbol *sym_find(const char *name) |
572 | { | 583 | { |
573 | struct symbol *symbol = NULL; | 584 | struct symbol *symbol = NULL; |
574 | const char *ptr; | 585 | const char *ptr; |
575 | int hash = 0; | 586 | int hash = 0; |
576 | 587 | ||
577 | if (!name) | 588 | if (!name) |
578 | return NULL; | 589 | return NULL; |
579 | 590 | ||