aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kconfig/confdata.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig/confdata.c')
-rw-r--r--scripts/kconfig/confdata.c436
1 files changed, 285 insertions, 151 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index c4dec80cfd8e..9df80114b47b 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -5,6 +5,7 @@
5 5
6#include <sys/stat.h> 6#include <sys/stat.h>
7#include <ctype.h> 7#include <ctype.h>
8#include <errno.h>
8#include <fcntl.h> 9#include <fcntl.h>
9#include <stdio.h> 10#include <stdio.h>
10#include <stdlib.h> 11#include <stdlib.h>
@@ -18,6 +19,9 @@
18static void conf_warning(const char *fmt, ...) 19static void conf_warning(const char *fmt, ...)
19 __attribute__ ((format (printf, 1, 2))); 20 __attribute__ ((format (printf, 1, 2)));
20 21
22static void conf_message(const char *fmt, ...)
23 __attribute__ ((format (printf, 1, 2)));
24
21static const char *conf_filename; 25static const char *conf_filename;
22static int conf_lineno, conf_warnings, conf_unsaved; 26static int conf_lineno, conf_warnings, conf_unsaved;
23 27
@@ -34,6 +38,29 @@ static void conf_warning(const char *fmt, ...)
34 conf_warnings++; 38 conf_warnings++;
35} 39}
36 40
41static void conf_default_message_callback(const char *fmt, va_list ap)
42{
43 printf("#\n# ");
44 vprintf(fmt, ap);
45 printf("\n#\n");
46}
47
48static void (*conf_message_callback) (const char *fmt, va_list ap) =
49 conf_default_message_callback;
50void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap))
51{
52 conf_message_callback = fn;
53}
54
55static void conf_message(const char *fmt, ...)
56{
57 va_list ap;
58
59 va_start(ap, fmt);
60 if (conf_message_callback)
61 conf_message_callback(fmt, ap);
62}
63
37const char *conf_get_configname(void) 64const char *conf_get_configname(void)
38{ 65{
39 char *name = getenv("KCONFIG_CONFIG"); 66 char *name = getenv("KCONFIG_CONFIG");
@@ -170,8 +197,11 @@ int conf_read_simple(const char *name, int def)
170 if (in) 197 if (in)
171 goto load; 198 goto load;
172 sym_add_change_count(1); 199 sym_add_change_count(1);
173 if (!sym_defconfig_list) 200 if (!sym_defconfig_list) {
201 if (modules_sym)
202 sym_calc_value(modules_sym);
174 return 1; 203 return 1;
204 }
175 205
176 for_all_defaults(sym_defconfig_list, prop) { 206 for_all_defaults(sym_defconfig_list, prop) {
177 if (expr_calc_value(prop->visible.expr) == no || 207 if (expr_calc_value(prop->visible.expr) == no ||
@@ -180,9 +210,8 @@ int conf_read_simple(const char *name, int def)
180 name = conf_expand_value(prop->expr->left.sym->name); 210 name = conf_expand_value(prop->expr->left.sym->name);
181 in = zconf_fopen(name); 211 in = zconf_fopen(name);
182 if (in) { 212 if (in) {
183 printf(_("#\n" 213 conf_message(_("using defaults found in %s"),
184 "# using defaults found in %s\n" 214 name);
185 "#\n"), name);
186 goto load; 215 goto load;
187 } 216 }
188 } 217 }
@@ -217,24 +246,23 @@ load:
217 while (fgets(line, sizeof(line), in)) { 246 while (fgets(line, sizeof(line), in)) {
218 conf_lineno++; 247 conf_lineno++;
219 sym = NULL; 248 sym = NULL;
220 switch (line[0]) { 249 if (line[0] == '#') {
221 case '#': 250 if (memcmp(line + 2, CONFIG_, strlen(CONFIG_)))
222 if (memcmp(line + 2, "CONFIG_", 7))
223 continue; 251 continue;
224 p = strchr(line + 9, ' '); 252 p = strchr(line + 2 + strlen(CONFIG_), ' ');
225 if (!p) 253 if (!p)
226 continue; 254 continue;
227 *p++ = 0; 255 *p++ = 0;
228 if (strncmp(p, "is not set", 10)) 256 if (strncmp(p, "is not set", 10))
229 continue; 257 continue;
230 if (def == S_DEF_USER) { 258 if (def == S_DEF_USER) {
231 sym = sym_find(line + 9); 259 sym = sym_find(line + 2 + strlen(CONFIG_));
232 if (!sym) { 260 if (!sym) {
233 sym_add_change_count(1); 261 sym_add_change_count(1);
234 break; 262 goto setsym;
235 } 263 }
236 } else { 264 } else {
237 sym = sym_lookup(line + 9, 0); 265 sym = sym_lookup(line + 2 + strlen(CONFIG_), 0);
238 if (sym->type == S_UNKNOWN) 266 if (sym->type == S_UNKNOWN)
239 sym->type = S_BOOLEAN; 267 sym->type = S_BOOLEAN;
240 } 268 }
@@ -250,13 +278,8 @@ load:
250 default: 278 default:
251 ; 279 ;
252 } 280 }
253 break; 281 } else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) {
254 case 'C': 282 p = strchr(line + strlen(CONFIG_), '=');
255 if (memcmp(line, "CONFIG_", 7)) {
256 conf_warning("unexpected data");
257 continue;
258 }
259 p = strchr(line + 7, '=');
260 if (!p) 283 if (!p)
261 continue; 284 continue;
262 *p++ = 0; 285 *p++ = 0;
@@ -267,13 +290,13 @@ load:
267 *p2 = 0; 290 *p2 = 0;
268 } 291 }
269 if (def == S_DEF_USER) { 292 if (def == S_DEF_USER) {
270 sym = sym_find(line + 7); 293 sym = sym_find(line + strlen(CONFIG_));
271 if (!sym) { 294 if (!sym) {
272 sym_add_change_count(1); 295 sym_add_change_count(1);
273 break; 296 goto setsym;
274 } 297 }
275 } else { 298 } else {
276 sym = sym_lookup(line + 7, 0); 299 sym = sym_lookup(line + strlen(CONFIG_), 0);
277 if (sym->type == S_UNKNOWN) 300 if (sym->type == S_UNKNOWN)
278 sym->type = S_OTHER; 301 sym->type = S_OTHER;
279 } 302 }
@@ -282,14 +305,12 @@ load:
282 } 305 }
283 if (conf_set_sym_val(sym, def, def_flags, p)) 306 if (conf_set_sym_val(sym, def, def_flags, p))
284 continue; 307 continue;
285 break; 308 } else {
286 case '\r': 309 if (line[0] != '\r' && line[0] != '\n')
287 case '\n': 310 conf_warning("unexpected data");
288 break;
289 default:
290 conf_warning("unexpected data");
291 continue; 311 continue;
292 } 312 }
313setsym:
293 if (sym && sym_is_choice_value(sym)) { 314 if (sym && sym_is_choice_value(sym)) {
294 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); 315 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
295 switch (sym->def[def].tri) { 316 switch (sym->def[def].tri) {
@@ -396,15 +417,151 @@ int conf_read(const char *name)
396 return 0; 417 return 0;
397} 418}
398 419
420/* Write a S_STRING */
421static void conf_write_string(bool headerfile, const char *name,
422 const char *str, FILE *out)
423{
424 int l;
425 if (headerfile)
426 fprintf(out, "#define %s%s \"", CONFIG_, name);
427 else
428 fprintf(out, "%s%s=\"", CONFIG_, name);
429
430 while (1) {
431 l = strcspn(str, "\"\\");
432 if (l) {
433 xfwrite(str, l, 1, out);
434 str += l;
435 }
436 if (!*str)
437 break;
438 fprintf(out, "\\%c", *str++);
439 }
440 fputs("\"\n", out);
441}
442
443static void conf_write_symbol(struct symbol *sym, enum symbol_type type,
444 FILE *out, bool write_no)
445{
446 const char *str;
447
448 switch (type) {
449 case S_BOOLEAN:
450 case S_TRISTATE:
451 switch (sym_get_tristate_value(sym)) {
452 case no:
453 if (write_no)
454 fprintf(out, "# %s%s is not set\n",
455 CONFIG_, sym->name);
456 break;
457 case mod:
458 fprintf(out, "%s%s=m\n", CONFIG_, sym->name);
459 break;
460 case yes:
461 fprintf(out, "%s%s=y\n", CONFIG_, sym->name);
462 break;
463 }
464 break;
465 case S_STRING:
466 conf_write_string(false, sym->name, sym_get_string_value(sym), out);
467 break;
468 case S_HEX:
469 case S_INT:
470 str = sym_get_string_value(sym);
471 fprintf(out, "%s%s=%s\n", CONFIG_, sym->name, str);
472 break;
473 case S_OTHER:
474 case S_UNKNOWN:
475 break;
476 }
477}
478
479/*
480 * Write out a minimal config.
481 * All values that has default values are skipped as this is redundant.
482 */
483int conf_write_defconfig(const char *filename)
484{
485 struct symbol *sym;
486 struct menu *menu;
487 FILE *out;
488
489 out = fopen(filename, "w");
490 if (!out)
491 return 1;
492
493 sym_clear_all_valid();
494
495 /* Traverse all menus to find all relevant symbols */
496 menu = rootmenu.list;
497
498 while (menu != NULL)
499 {
500 sym = menu->sym;
501 if (sym == NULL) {
502 if (!menu_is_visible(menu))
503 goto next_menu;
504 } else if (!sym_is_choice(sym)) {
505 sym_calc_value(sym);
506 if (!(sym->flags & SYMBOL_WRITE))
507 goto next_menu;
508 sym->flags &= ~SYMBOL_WRITE;
509 /* If we cannot change the symbol - skip */
510 if (!sym_is_changable(sym))
511 goto next_menu;
512 /* If symbol equals to default value - skip */
513 if (strcmp(sym_get_string_value(sym), sym_get_string_default(sym)) == 0)
514 goto next_menu;
515
516 /*
517 * If symbol is a choice value and equals to the
518 * default for a choice - skip.
519 * But only if value is bool and equal to "y" and
520 * choice is not "optional".
521 * (If choice is "optional" then all values can be "n")
522 */
523 if (sym_is_choice_value(sym)) {
524 struct symbol *cs;
525 struct symbol *ds;
526
527 cs = prop_get_symbol(sym_get_choice_prop(sym));
528 ds = sym_choice_default(cs);
529 if (!sym_is_optional(cs) && sym == ds) {
530 if ((sym->type == S_BOOLEAN) &&
531 sym_get_tristate_value(sym) == yes)
532 goto next_menu;
533 }
534 }
535 conf_write_symbol(sym, sym->type, out, true);
536 }
537next_menu:
538 if (menu->list != NULL) {
539 menu = menu->list;
540 }
541 else if (menu->next != NULL) {
542 menu = menu->next;
543 } else {
544 while ((menu = menu->parent)) {
545 if (menu->next != NULL) {
546 menu = menu->next;
547 break;
548 }
549 }
550 }
551 }
552 fclose(out);
553 return 0;
554}
555
399int conf_write(const char *name) 556int conf_write(const char *name)
400{ 557{
401 FILE *out; 558 FILE *out;
402 struct symbol *sym; 559 struct symbol *sym;
403 struct menu *menu; 560 struct menu *menu;
404 const char *basename; 561 const char *basename;
405 char dirname[128], tmpname[128], newname[128];
406 int type, l;
407 const char *str; 562 const char *str;
563 char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1];
564 enum symbol_type type;
408 time_t now; 565 time_t now;
409 int use_timestamp = 1; 566 int use_timestamp = 1;
410 char *env; 567 char *env;
@@ -443,8 +600,6 @@ int conf_write(const char *name)
443 if (!out) 600 if (!out)
444 return 1; 601 return 1;
445 602
446 sym = sym_lookup("KERNELVERSION", 0);
447 sym_calc_value(sym);
448 time(&now); 603 time(&now);
449 env = getenv("KCONFIG_NOTIMESTAMP"); 604 env = getenv("KCONFIG_NOTIMESTAMP");
450 if (env && *env) 605 if (env && *env)
@@ -452,10 +607,10 @@ int conf_write(const char *name)
452 607
453 fprintf(out, _("#\n" 608 fprintf(out, _("#\n"
454 "# Automatically generated make config: don't edit\n" 609 "# Automatically generated make config: don't edit\n"
455 "# Linux kernel version: %s\n" 610 "# %s\n"
456 "%s%s" 611 "%s%s"
457 "#\n"), 612 "#\n"),
458 sym_get_string_value(sym), 613 rootmenu.prompt->text,
459 use_timestamp ? "# " : "", 614 use_timestamp ? "# " : "",
460 use_timestamp ? ctime(&now) : ""); 615 use_timestamp ? ctime(&now) : "");
461 616
@@ -484,50 +639,11 @@ int conf_write(const char *name)
484 if (modules_sym->curr.tri == no) 639 if (modules_sym->curr.tri == no)
485 type = S_BOOLEAN; 640 type = S_BOOLEAN;
486 } 641 }
487 switch (type) { 642 /* Write config symbol to file */
488 case S_BOOLEAN: 643 conf_write_symbol(sym, type, out, true);
489 case S_TRISTATE:
490 switch (sym_get_tristate_value(sym)) {
491 case no:
492 fprintf(out, "# CONFIG_%s is not set\n", sym->name);
493 break;
494 case mod:
495 fprintf(out, "CONFIG_%s=m\n", sym->name);
496 break;
497 case yes:
498 fprintf(out, "CONFIG_%s=y\n", sym->name);
499 break;
500 }
501 break;
502 case S_STRING:
503 str = sym_get_string_value(sym);
504 fprintf(out, "CONFIG_%s=\"", sym->name);
505 while (1) {
506 l = strcspn(str, "\"\\");
507 if (l) {
508 fwrite(str, l, 1, out);
509 str += l;
510 }
511 if (!*str)
512 break;
513 fprintf(out, "\\%c", *str++);
514 }
515 fputs("\"\n", out);
516 break;
517 case S_HEX:
518 str = sym_get_string_value(sym);
519 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
520 fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
521 break;
522 }
523 case S_INT:
524 str = sym_get_string_value(sym);
525 fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
526 break;
527 }
528 } 644 }
529 645
530 next: 646next:
531 if (menu->list) { 647 if (menu->list) {
532 menu = menu->list; 648 menu = menu->list;
533 continue; 649 continue;
@@ -551,9 +667,7 @@ int conf_write(const char *name)
551 return 1; 667 return 1;
552 } 668 }
553 669
554 printf(_("#\n" 670 conf_message(_("configuration written to %s"), newname);
555 "# configuration written to %s\n"
556 "#\n"), newname);
557 671
558 sym_set_change_count(0); 672 sym_set_change_count(0);
559 673
@@ -563,7 +677,7 @@ int conf_write(const char *name)
563static int conf_split_config(void) 677static int conf_split_config(void)
564{ 678{
565 const char *name; 679 const char *name;
566 char path[128]; 680 char path[PATH_MAX+1];
567 char *s, *d, c; 681 char *s, *d, c;
568 struct symbol *sym; 682 struct symbol *sym;
569 struct stat sb; 683 struct stat sb;
@@ -679,7 +793,7 @@ int conf_write_autoconf(void)
679 const char *name; 793 const char *name;
680 FILE *out, *tristate, *out_h; 794 FILE *out, *tristate, *out_h;
681 time_t now; 795 time_t now;
682 int i, l; 796 int i;
683 797
684 sym_clear_all_valid(); 798 sym_clear_all_valid();
685 799
@@ -705,30 +819,33 @@ int conf_write_autoconf(void)
705 return 1; 819 return 1;
706 } 820 }
707 821
708 sym = sym_lookup("KERNELVERSION", 0);
709 sym_calc_value(sym);
710 time(&now); 822 time(&now);
711 fprintf(out, "#\n" 823 fprintf(out, "#\n"
712 "# Automatically generated make config: don't edit\n" 824 "# Automatically generated make config: don't edit\n"
713 "# Linux kernel version: %s\n" 825 "# %s\n"
714 "# %s" 826 "# %s"
715 "#\n", 827 "#\n",
716 sym_get_string_value(sym), ctime(&now)); 828 rootmenu.prompt->text, ctime(&now));
717 fprintf(tristate, "#\n" 829 fprintf(tristate, "#\n"
718 "# Automatically generated - do not edit\n" 830 "# Automatically generated - do not edit\n"
719 "\n"); 831 "\n");
720 fprintf(out_h, "/*\n" 832 fprintf(out_h, "/*\n"
721 " * Automatically generated C config: don't edit\n" 833 " * Automatically generated C config: don't edit\n"
722 " * Linux kernel version: %s\n" 834 " * %s\n"
723 " * %s" 835 " * %s"
724 " */\n" 836 " */\n"
725 "#define AUTOCONF_INCLUDED\n", 837 "#define AUTOCONF_INCLUDED\n",
726 sym_get_string_value(sym), ctime(&now)); 838 rootmenu.prompt->text, ctime(&now));
727 839
728 for_all_symbols(i, sym) { 840 for_all_symbols(i, sym) {
729 sym_calc_value(sym); 841 sym_calc_value(sym);
730 if (!(sym->flags & SYMBOL_WRITE) || !sym->name) 842 if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
731 continue; 843 continue;
844
845 /* write symbol to config file */
846 conf_write_symbol(sym, sym->type, out, false);
847
848 /* update autoconf and tristate files */
732 switch (sym->type) { 849 switch (sym->type) {
733 case S_BOOLEAN: 850 case S_BOOLEAN:
734 case S_TRISTATE: 851 case S_TRISTATE:
@@ -736,50 +853,34 @@ int conf_write_autoconf(void)
736 case no: 853 case no:
737 break; 854 break;
738 case mod: 855 case mod:
739 fprintf(out, "CONFIG_%s=m\n", sym->name); 856 fprintf(tristate, "%s%s=M\n",
740 fprintf(tristate, "CONFIG_%s=M\n", sym->name); 857 CONFIG_, sym->name);
741 fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name); 858 fprintf(out_h, "#define %s%s_MODULE 1\n",
859 CONFIG_, sym->name);
742 break; 860 break;
743 case yes: 861 case yes:
744 fprintf(out, "CONFIG_%s=y\n", sym->name);
745 if (sym->type == S_TRISTATE) 862 if (sym->type == S_TRISTATE)
746 fprintf(tristate, "CONFIG_%s=Y\n", 863 fprintf(tristate,"%s%s=Y\n",
747 sym->name); 864 CONFIG_, sym->name);
748 fprintf(out_h, "#define CONFIG_%s 1\n", sym->name); 865 fprintf(out_h, "#define %s%s 1\n",
866 CONFIG_, sym->name);
749 break; 867 break;
750 } 868 }
751 break; 869 break;
752 case S_STRING: 870 case S_STRING:
753 str = sym_get_string_value(sym); 871 conf_write_string(true, sym->name, sym_get_string_value(sym), out_h);
754 fprintf(out, "CONFIG_%s=\"", sym->name);
755 fprintf(out_h, "#define CONFIG_%s \"", sym->name);
756 while (1) {
757 l = strcspn(str, "\"\\");
758 if (l) {
759 fwrite(str, l, 1, out);
760 fwrite(str, l, 1, out_h);
761 str += l;
762 }
763 if (!*str)
764 break;
765 fprintf(out, "\\%c", *str);
766 fprintf(out_h, "\\%c", *str);
767 str++;
768 }
769 fputs("\"\n", out);
770 fputs("\"\n", out_h);
771 break; 872 break;
772 case S_HEX: 873 case S_HEX:
773 str = sym_get_string_value(sym); 874 str = sym_get_string_value(sym);
774 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { 875 if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
775 fprintf(out, "CONFIG_%s=%s\n", sym->name, str); 876 fprintf(out_h, "#define %s%s 0x%s\n",
776 fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str); 877 CONFIG_, sym->name, str);
777 break; 878 break;
778 } 879 }
779 case S_INT: 880 case S_INT:
780 str = sym_get_string_value(sym); 881 str = sym_get_string_value(sym);
781 fprintf(out, "CONFIG_%s=%s\n", sym->name, str); 882 fprintf(out_h, "#define %s%s %s\n",
782 fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str); 883 CONFIG_, sym->name, str);
783 break; 884 break;
784 default: 885 default:
785 break; 886 break;
@@ -837,13 +938,73 @@ void conf_set_changed_callback(void (*fn)(void))
837 conf_changed_callback = fn; 938 conf_changed_callback = fn;
838} 939}
839 940
941static void randomize_choice_values(struct symbol *csym)
942{
943 struct property *prop;
944 struct symbol *sym;
945 struct expr *e;
946 int cnt, def;
840 947
841void conf_set_all_new_symbols(enum conf_def_mode mode) 948 /*
949 * If choice is mod then we may have more items slected
950 * and if no then no-one.
951 * In both cases stop.
952 */
953 if (csym->curr.tri != yes)
954 return;
955
956 prop = sym_get_choice_prop(csym);
957
958 /* count entries in choice block */
959 cnt = 0;
960 expr_list_for_each_sym(prop->expr, e, sym)
961 cnt++;
962
963 /*
964 * find a random value and set it to yes,
965 * set the rest to no so we have only one set
966 */
967 def = (rand() % cnt);
968
969 cnt = 0;
970 expr_list_for_each_sym(prop->expr, e, sym) {
971 if (def == cnt++) {
972 sym->def[S_DEF_USER].tri = yes;
973 csym->def[S_DEF_USER].val = sym;
974 }
975 else {
976 sym->def[S_DEF_USER].tri = no;
977 }
978 }
979 csym->flags |= SYMBOL_DEF_USER;
980 /* clear VALID to get value calculated */
981 csym->flags &= ~(SYMBOL_VALID);
982}
983
984static void set_all_choice_values(struct symbol *csym)
842{ 985{
843 struct symbol *sym, *csym;
844 struct property *prop; 986 struct property *prop;
987 struct symbol *sym;
845 struct expr *e; 988 struct expr *e;
846 int i, cnt, def; 989
990 prop = sym_get_choice_prop(csym);
991
992 /*
993 * Set all non-assinged choice values to no
994 */
995 expr_list_for_each_sym(prop->expr, e, sym) {
996 if (!sym_has_value(sym))
997 sym->def[S_DEF_USER].tri = no;
998 }
999 csym->flags |= SYMBOL_DEF_USER;
1000 /* clear VALID to get value calculated */
1001 csym->flags &= ~(SYMBOL_VALID);
1002}
1003
1004void conf_set_all_new_symbols(enum conf_def_mode mode)
1005{
1006 struct symbol *sym, *csym;
1007 int i, cnt;
847 1008
848 for_all_symbols(i, sym) { 1009 for_all_symbols(i, sym) {
849 if (sym_has_value(sym)) 1010 if (sym_has_value(sym))
@@ -862,7 +1023,8 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
862 sym->def[S_DEF_USER].tri = no; 1023 sym->def[S_DEF_USER].tri = no;
863 break; 1024 break;
864 case def_random: 1025 case def_random:
865 sym->def[S_DEF_USER].tri = (tristate)(rand() % 3); 1026 cnt = sym_get_type(sym) == S_TRISTATE ? 3 : 2;
1027 sym->def[S_DEF_USER].tri = (tristate)(rand() % cnt);
866 break; 1028 break;
867 default: 1029 default:
868 continue; 1030 continue;
@@ -878,8 +1040,6 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
878 1040
879 sym_clear_all_valid(); 1041 sym_clear_all_valid();
880 1042
881 if (mode != def_random)
882 return;
883 /* 1043 /*
884 * We have different type of choice blocks. 1044 * We have different type of choice blocks.
885 * If curr.tri equal to mod then we can select several 1045 * If curr.tri equal to mod then we can select several
@@ -894,35 +1054,9 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
894 continue; 1054 continue;
895 1055
896 sym_calc_value(csym); 1056 sym_calc_value(csym);
897 1057 if (mode == def_random)
898 if (csym->curr.tri != yes) 1058 randomize_choice_values(csym);
899 continue; 1059 else
900 1060 set_all_choice_values(csym);
901 prop = sym_get_choice_prop(csym);
902
903 /* count entries in choice block */
904 cnt = 0;
905 expr_list_for_each_sym(prop->expr, e, sym)
906 cnt++;
907
908 /*
909 * find a random value and set it to yes,
910 * set the rest to no so we have only one set
911 */
912 def = (rand() % cnt);
913
914 cnt = 0;
915 expr_list_for_each_sym(prop->expr, e, sym) {
916 if (def == cnt++) {
917 sym->def[S_DEF_USER].tri = yes;
918 csym->def[S_DEF_USER].val = sym;
919 }
920 else {
921 sym->def[S_DEF_USER].tri = no;
922 }
923 }
924 csym->flags |= SYMBOL_DEF_USER;
925 /* clear VALID to get value calculated */
926 csym->flags &= ~(SYMBOL_VALID);
927 } 1061 }
928} 1062}