conf.c (a23e1966932464e1c5226cb9ac4ce1d5fc10ba22) | conf.c (fde192511bdbff554320b31574bb8a9cb3275522) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 4 */ 5 6#include <ctype.h> 7#include <limits.h> 8#include <stdio.h> --- 100 unchanged lines hidden (view full) --- 109 gettimeofday(&now, NULL); 110 seed = (now.tv_sec + 1) * (now.tv_usec + 1); 111 } 112 113 printf("KCONFIG_SEED=0x%X\n", seed); 114 srand(seed); 115} 116 | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org> 4 */ 5 6#include <ctype.h> 7#include <limits.h> 8#include <stdio.h> --- 100 unchanged lines hidden (view full) --- 109 gettimeofday(&now, NULL); 110 seed = (now.tv_sec + 1) * (now.tv_usec + 1); 111 } 112 113 printf("KCONFIG_SEED=0x%X\n", seed); 114 srand(seed); 115} 116 |
117static bool randomize_choice_values(struct symbol *csym) | 117static void randomize_choice_values(struct symbol *csym) |
118{ 119 struct property *prop; 120 struct symbol *sym; 121 struct expr *e; 122 int cnt, def; 123 | 118{ 119 struct property *prop; 120 struct symbol *sym; 121 struct expr *e; 122 int cnt, def; 123 |
124 /* 125 * If choice is mod then we may have more items selected 126 * and if no then no-one. 127 * In both cases stop. 128 */ 129 if (csym->curr.tri != yes) 130 return false; 131 | |
132 prop = sym_get_choice_prop(csym); 133 134 /* count entries in choice block */ 135 cnt = 0; 136 expr_list_for_each_sym(prop->expr, e, sym) 137 cnt++; 138 139 /* --- 12 unchanged lines hidden (view full) --- 152 } 153 sym->flags |= SYMBOL_DEF_USER; 154 /* clear VALID to get value calculated */ 155 sym->flags &= ~SYMBOL_VALID; 156 } 157 csym->flags |= SYMBOL_DEF_USER; 158 /* clear VALID to get value calculated */ 159 csym->flags &= ~SYMBOL_VALID; | 124 prop = sym_get_choice_prop(csym); 125 126 /* count entries in choice block */ 127 cnt = 0; 128 expr_list_for_each_sym(prop->expr, e, sym) 129 cnt++; 130 131 /* --- 12 unchanged lines hidden (view full) --- 144 } 145 sym->flags |= SYMBOL_DEF_USER; 146 /* clear VALID to get value calculated */ 147 sym->flags &= ~SYMBOL_VALID; 148 } 149 csym->flags |= SYMBOL_DEF_USER; 150 /* clear VALID to get value calculated */ 151 csym->flags &= ~SYMBOL_VALID; |
160 161 return true; | |
162} 163 164enum conf_def_mode { 165 def_default, 166 def_yes, 167 def_mod, 168 def_no, 169 def_random --- 94 unchanged lines hidden (view full) --- 264 default: 265 break; 266 } 267 268 } 269 270 sym_clear_all_valid(); 271 | 152} 153 154enum conf_def_mode { 155 def_default, 156 def_yes, 157 def_mod, 158 def_no, 159 def_random --- 94 unchanged lines hidden (view full) --- 254 default: 255 break; 256 } 257 258 } 259 260 sym_clear_all_valid(); 261 |
272 /* 273 * We have different type of choice blocks. 274 * If curr.tri equals to mod then we can select several 275 * choice symbols in one block. 276 * In this case we do nothing. 277 * If curr.tri equals yes then only one symbol can be 278 * selected in a choice block and we set it to yes, 279 * and the rest to no. 280 */ | |
281 if (mode != def_random) { 282 for_all_symbols(csym) { 283 if ((sym_is_choice(csym) && !sym_has_value(csym)) || 284 sym_is_choice_value(csym)) 285 csym->flags |= SYMBOL_NEED_SET_CHOICE_VALUES; 286 } 287 } 288 289 for_all_symbols(csym) { 290 if (sym_has_value(csym) || !sym_is_choice(csym)) 291 continue; 292 293 sym_calc_value(csym); 294 if (mode == def_random) | 262 if (mode != def_random) { 263 for_all_symbols(csym) { 264 if ((sym_is_choice(csym) && !sym_has_value(csym)) || 265 sym_is_choice_value(csym)) 266 csym->flags |= SYMBOL_NEED_SET_CHOICE_VALUES; 267 } 268 } 269 270 for_all_symbols(csym) { 271 if (sym_has_value(csym) || !sym_is_choice(csym)) 272 continue; 273 274 sym_calc_value(csym); 275 if (mode == def_random) |
295 has_changed |= randomize_choice_values(csym); 296 else { | 276 randomize_choice_values(csym); 277 else |
297 set_all_choice_values(csym); | 278 set_all_choice_values(csym); |
298 has_changed = true; 299 } | 279 has_changed = true; |
300 } 301 302 return has_changed; 303} 304 305static void conf_rewrite_tristates(tristate old_val, tristate new_val) 306{ 307 struct symbol *sym; --- 133 unchanged lines hidden (view full) --- 441 } 442 if (sym_set_tristate_value(sym, newval)) 443 return 0; 444help: 445 print_help(menu); 446 } 447} 448 | 280 } 281 282 return has_changed; 283} 284 285static void conf_rewrite_tristates(tristate old_val, tristate new_val) 286{ 287 struct symbol *sym; --- 133 unchanged lines hidden (view full) --- 421 } 422 if (sym_set_tristate_value(sym, newval)) 423 return 0; 424help: 425 print_help(menu); 426 } 427} 428 |
449static int conf_choice(struct menu *menu) | 429static void conf_choice(struct menu *menu) |
450{ 451 struct symbol *sym, *def_sym; 452 struct menu *child; 453 bool is_new; 454 455 sym = menu->sym; 456 is_new = !sym_has_value(sym); | 430{ 431 struct symbol *sym, *def_sym; 432 struct menu *child; 433 bool is_new; 434 435 sym = menu->sym; 436 is_new = !sym_has_value(sym); |
457 if (sym_is_changeable(sym)) { 458 conf_sym(menu); 459 sym_calc_value(sym); 460 switch (sym_get_tristate_value(sym)) { 461 case no: 462 return 1; 463 case mod: 464 return 0; 465 case yes: 466 break; 467 } 468 } else { 469 switch (sym_get_tristate_value(sym)) { 470 case no: 471 return 1; 472 case mod: 473 printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); 474 return 0; 475 case yes: 476 break; 477 } 478 } | |
479 480 while (1) { 481 int cnt, def; 482 483 printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); 484 def_sym = sym_get_choice_value(sym); 485 cnt = def = 0; 486 line[0] = 0; --- 5 unchanged lines hidden (view full) --- 492 continue; 493 } 494 cnt++; 495 if (child->sym == def_sym) { 496 def = cnt; 497 printf("%*c", indent, '>'); 498 } else 499 printf("%*c", indent, ' '); | 437 438 while (1) { 439 int cnt, def; 440 441 printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); 442 def_sym = sym_get_choice_value(sym); 443 cnt = def = 0; 444 line[0] = 0; --- 5 unchanged lines hidden (view full) --- 450 continue; 451 } 452 cnt++; 453 if (child->sym == def_sym) { 454 def = cnt; 455 printf("%*c", indent, '>'); 456 } else 457 printf("%*c", indent, ' '); |
500 printf(" %d. %s", cnt, menu_get_prompt(child)); 501 if (child->sym->name) 502 printf(" (%s)", child->sym->name); | 458 printf(" %d. %s (%s)", cnt, menu_get_prompt(child), 459 child->sym->name); |
503 if (!sym_has_value(child->sym)) 504 printf(" (NEW)"); 505 printf("\n"); 506 } 507 printf("%*schoice", indent - 1, ""); 508 if (cnt == 1) { 509 printf("[1]: 1\n"); 510 goto conf_childs; --- 36 unchanged lines hidden (view full) --- 547 } 548 if (!child) 549 continue; 550 if (line[0] && line[strlen(line) - 1] == '?') { 551 print_help(child); 552 continue; 553 } 554 sym_set_tristate_value(child->sym, yes); | 460 if (!sym_has_value(child->sym)) 461 printf(" (NEW)"); 462 printf("\n"); 463 } 464 printf("%*schoice", indent - 1, ""); 465 if (cnt == 1) { 466 printf("[1]: 1\n"); 467 goto conf_childs; --- 36 unchanged lines hidden (view full) --- 504 } 505 if (!child) 506 continue; 507 if (line[0] && line[strlen(line) - 1] == '?') { 508 print_help(child); 509 continue; 510 } 511 sym_set_tristate_value(child->sym, yes); |
555 return 1; | 512 return; |
556 } 557} 558 559static void conf(struct menu *menu) 560{ 561 struct symbol *sym; 562 struct property *prop; 563 struct menu *child; --- 29 unchanged lines hidden (view full) --- 593 } 594 } 595 596 if (!sym) 597 goto conf_childs; 598 599 if (sym_is_choice(sym)) { 600 conf_choice(menu); | 513 } 514} 515 516static void conf(struct menu *menu) 517{ 518 struct symbol *sym; 519 struct property *prop; 520 struct menu *child; --- 29 unchanged lines hidden (view full) --- 550 } 551 } 552 553 if (!sym) 554 goto conf_childs; 555 556 if (sym_is_choice(sym)) { 557 conf_choice(menu); |
601 if (sym->curr.tri != mod) 602 return; 603 goto conf_childs; | 558 return; |
604 } 605 606 switch (sym->type) { 607 case S_INT: 608 case S_HEX: 609 case S_STRING: 610 conf_string(menu); 611 break; --- 16 unchanged lines hidden (view full) --- 628 struct symbol *sym; 629 struct menu *child; 630 631 if (!menu_is_visible(menu)) 632 return; 633 634 sym = menu->sym; 635 if (sym && !sym_has_value(sym) && | 559 } 560 561 switch (sym->type) { 562 case S_INT: 563 case S_HEX: 564 case S_STRING: 565 conf_string(menu); 566 break; --- 16 unchanged lines hidden (view full) --- 583 struct symbol *sym; 584 struct menu *child; 585 586 if (!menu_is_visible(menu)) 587 return; 588 589 sym = menu->sym; 590 if (sym && !sym_has_value(sym) && |
636 (sym_is_changeable(sym) || 637 (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes))) { | 591 (sym_is_changeable(sym) || sym_is_choice(sym))) { |
638 639 switch (input_mode) { 640 case listnewconfig: 641 if (sym->name) 642 print_symbol_for_listconfig(sym); 643 break; 644 case helpnewconfig: 645 printf("-----\n"); --- 277 unchanged lines hidden --- | 592 593 switch (input_mode) { 594 case listnewconfig: 595 if (sym->name) 596 print_symbol_for_listconfig(sym); 597 break; 598 case helpnewconfig: 599 printf("-----\n"); --- 277 unchanged lines hidden --- |