2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
19 /* return true if 'path' exists, false otherwise */
20 static bool is_present(const char *path)
24 return !stat(path, &st);
27 /* return true if 'path' exists and it is a directory, false otherwise */
28 static bool is_dir(const char *path)
35 return S_ISDIR(st.st_mode);
39 * Create the parent directory of the given path.
41 * For example, if 'include/config/auto.conf' is given, create 'include/config'.
43 static int make_parent_dir(const char *path)
45 char tmp[PATH_MAX + 1];
48 strncpy(tmp, path, sizeof(tmp));
49 tmp[sizeof(tmp) - 1] = 0;
51 /* Remove the base name. Just return if nothing is left */
52 p = strrchr(tmp, '/');
57 /* Just in case it is an absolute path */
62 while ((p = strchr(p, '/'))) {
65 /* skip if the directory exists */
66 if (!is_dir(tmp) && mkdir(tmp, 0755))
78 void (*print_symbol)(FILE *, struct symbol *, const char *, void *);
79 void (*print_comment)(FILE *, const char *, void *);
82 static void conf_warning(const char *fmt, ...)
83 __attribute__ ((format (printf, 1, 2)));
85 static void conf_message(const char *fmt, ...)
86 __attribute__ ((format (printf, 1, 2)));
88 static const char *conf_filename;
89 static int conf_lineno, conf_warnings;
91 const char conf_defname[] = "include/generated/defconfig";
93 static void conf_warning(const char *fmt, ...)
97 fprintf(stderr, "%s:%d:warning: ", conf_filename, conf_lineno);
98 vfprintf(stderr, fmt, ap);
99 fprintf(stderr, "\n");
104 static void conf_default_message_callback(const char *s)
111 static void (*conf_message_callback)(const char *s) =
112 conf_default_message_callback;
113 void conf_set_message_callback(void (*fn)(const char *s))
115 conf_message_callback = fn;
118 static void conf_message(const char *fmt, ...)
123 if (!conf_message_callback)
128 vsnprintf(buf, sizeof(buf), fmt, ap);
129 conf_message_callback(buf);
133 const char *conf_get_configname(void)
135 char *name = getenv("KCONFIG_CONFIG");
137 return name ? name : ".config";
140 const char *conf_get_autoconfig_name(void)
142 char *name = getenv("KCONFIG_AUTOCONFIG");
144 return name ? name : "include/generated/auto.conf";
147 char *conf_get_default_confname(void)
149 static char fullname[PATH_MAX+1];
152 name = expand_string(conf_defname);
153 env = getenv(SRCTREE);
155 sprintf(fullname, "%s/%s", env, name);
156 if (is_present(fullname))
162 static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
169 sym->def[def].tri = mod;
170 sym->flags |= def_flags;
176 sym->def[def].tri = yes;
177 sym->flags |= def_flags;
181 sym->def[def].tri = no;
182 sym->flags |= def_flags;
185 if (def != S_DEF_AUTO)
186 conf_warning("symbol value '%s' invalid for %s",
191 for (p2 = p; *p2 && !isspace(*p2); p2++)
193 sym->type = S_STRING;
200 for (p2 = p; (p2 = strpbrk(p2, "\"\\")); p2++) {
205 memmove(p2, p2 + 1, strlen(p2));
208 if (def != S_DEF_AUTO)
209 conf_warning("invalid string found");
216 if (sym_string_valid(sym, p)) {
217 sym->def[def].val = xstrdup(p);
218 sym->flags |= def_flags;
220 if (def != S_DEF_AUTO)
221 conf_warning("symbol value '%s' invalid for %s",
232 #define LINE_GROWTH 16
233 static int add_byte(int c, char **lineptr, size_t slen, size_t *n)
236 size_t new_size = slen + 1;
238 new_size += LINE_GROWTH - 1;
240 nline = xrealloc(*lineptr, new_size);
248 (*lineptr)[slen] = c;
253 static ssize_t compat_getline(char **lineptr, size_t *n, FILE *stream)
255 char *line = *lineptr;
259 int c = getc(stream);
263 if (add_byte(c, &line, slen, n) < 0)
268 if (add_byte('\0', &line, slen, n) < 0)
275 if (add_byte(c, &line, slen, n) < 0)
287 int conf_read_simple(const char *name, int def)
291 size_t line_asize = 0;
297 in = zconf_fopen(name);
299 struct property *prop;
301 name = conf_get_configname();
302 in = zconf_fopen(name);
305 sym_add_change_count(1);
306 if (!sym_defconfig_list)
309 for_all_defaults(sym_defconfig_list, prop) {
310 if (expr_calc_value(prop->visible.expr) == no ||
311 prop->expr->type != E_SYMBOL)
313 sym_calc_value(prop->expr->left.sym);
314 name = sym_get_string_value(prop->expr->left.sym);
315 in = zconf_fopen(name);
317 conf_message("using defaults found in %s",
327 conf_filename = name;
331 def_flags = SYMBOL_DEF << def;
332 for_all_symbols(i, sym) {
333 sym->flags |= SYMBOL_CHANGED;
334 sym->flags &= ~(def_flags|SYMBOL_VALID);
335 if (sym_is_choice(sym))
336 sym->flags |= def_flags;
341 if (sym->def[def].val)
342 free(sym->def[def].val);
345 sym->def[def].val = NULL;
346 sym->def[def].tri = no;
350 while (compat_getline(&line, &line_asize, in) != -1) {
353 if (line[0] == '#') {
354 if (memcmp(line + 2, CONFIG_, strlen(CONFIG_)))
356 p = strchr(line + 2 + strlen(CONFIG_), ' ');
360 if (strncmp(p, "is not set", 10))
362 if (def == S_DEF_USER) {
363 sym = sym_find(line + 2 + strlen(CONFIG_));
365 sym_add_change_count(1);
369 sym = sym_lookup(line + 2 + strlen(CONFIG_), 0);
370 if (sym->type == S_UNKNOWN)
371 sym->type = S_BOOLEAN;
373 if (sym->flags & def_flags) {
374 conf_warning("override: reassigning to symbol %s", sym->name);
379 sym->def[def].tri = no;
380 sym->flags |= def_flags;
385 } else if (memcmp(line, CONFIG_, strlen(CONFIG_)) == 0) {
386 p = strchr(line + strlen(CONFIG_), '=');
390 p2 = strchr(p, '\n');
396 if (def == S_DEF_USER) {
397 sym = sym_find(line + strlen(CONFIG_));
399 sym_add_change_count(1);
403 sym = sym_lookup(line + strlen(CONFIG_), 0);
404 if (sym->type == S_UNKNOWN)
407 if (sym->flags & def_flags) {
408 conf_warning("override: reassigning to symbol %s", sym->name);
410 if (conf_set_sym_val(sym, def, def_flags, p))
413 if (line[0] != '\r' && line[0] != '\n')
414 conf_warning("unexpected data: %.*s",
415 (int)strcspn(line, "\r\n"), line);
420 if (sym && sym_is_choice_value(sym)) {
421 struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym));
422 switch (sym->def[def].tri) {
426 if (cs->def[def].tri == yes) {
427 conf_warning("%s creates inconsistent choice state", sym->name);
428 cs->flags &= ~def_flags;
432 if (cs->def[def].tri != no)
433 conf_warning("override: %s changes choice state", sym->name);
434 cs->def[def].val = sym;
437 cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
445 int conf_read(const char *name)
448 int conf_unsaved = 0;
451 sym_set_change_count(0);
453 if (conf_read_simple(name, S_DEF_USER)) {
454 sym_calc_value(modules_sym);
458 sym_calc_value(modules_sym);
460 for_all_symbols(i, sym) {
462 if (sym_is_choice(sym) || (sym->flags & SYMBOL_NO_WRITE))
464 if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) {
465 /* check that calculated value agrees with saved value */
469 if (sym->def[S_DEF_USER].tri != sym_get_tristate_value(sym))
471 if (!sym_is_choice(sym))
475 if (!strcmp(sym->curr.val, sym->def[S_DEF_USER].val))
479 } else if (!sym_has_value(sym) && !(sym->flags & SYMBOL_WRITE))
480 /* no previous value and not saved */
483 /* maybe print value in verbose mode... */
486 for_all_symbols(i, sym) {
487 if (sym_has_value(sym) && !sym_is_choice_value(sym)) {
488 /* Reset values of generates values, so they'll appear
489 * as new, if they should become visible, but that
490 * doesn't quite work if the Kconfig and the saved
491 * configuration disagree.
493 if (sym->visible == no && !conf_unsaved)
494 sym->flags &= ~SYMBOL_DEF_USER;
499 /* Reset a string value if it's out of range */
500 if (sym_string_within_range(sym, sym->def[S_DEF_USER].val))
502 sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER);
511 sym_add_change_count(conf_warnings || conf_unsaved);
517 * Kconfig configuration printer
519 * This printer is used when generating the resulting configuration after
520 * kconfig invocation and `defconfig' files. Unset symbol might be omitted by
521 * passing a non-NULL argument to the printer.
525 kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
532 bool skip_unset = (arg != NULL);
535 fprintf(fp, "# %s%s is not set\n",
544 fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, value);
548 kconfig_print_cmake_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
555 bool skip_unset = (arg != NULL);
558 fprintf(fp, "set(%s%s false)\n",
559 CONFIG_, sym->name, value);
561 } else if (*value == 'm') {
564 fprintf(fp, "set(%s%s true)\n", CONFIG_, sym->name, value);
568 const char *prefix = "";
570 if (value[0] != '0' || (value[1] != 'x' && value[1] != 'X'))
572 fprintf(fp, "set(%s%s %s%s)\n",
573 CONFIG_, sym->name, prefix, value);
578 fprintf(fp, "set(%s%s %s)\n",
579 CONFIG_, sym->name, value);
588 kconfig_print_comment(FILE *fp, const char *value, void *arg)
590 const char *p = value;
594 l = strcspn(p, "\n");
598 xfwrite(p, l, 1, fp);
607 static struct conf_printer kconfig_printer_cb =
609 .print_symbol = kconfig_print_symbol,
610 .print_comment = kconfig_print_comment,
613 static struct conf_printer kconfig_printer_cmake_cb =
615 .print_symbol = kconfig_print_cmake_symbol,
616 .print_comment = kconfig_print_comment,
622 * This printer is used when generating the `include/generated/autoconf.h' file.
625 header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
631 const char *suffix = "";
640 fprintf(fp, "#define %s%s%s 1\n",
641 CONFIG_, sym->name, suffix);
646 const char *prefix = "";
648 if (value[0] != '0' || (value[1] != 'x' && value[1] != 'X'))
650 fprintf(fp, "#define %s%s %s%s\n",
651 CONFIG_, sym->name, prefix, value);
656 fprintf(fp, "#define %s%s %s\n",
657 CONFIG_, sym->name, value);
666 header_print_comment(FILE *fp, const char *value, void *arg)
668 const char *p = value;
673 l = strcspn(p, "\n");
677 xfwrite(p, l, 1, fp);
684 fprintf(fp, " */\n");
687 static struct conf_printer header_printer_cb =
689 .print_symbol = header_print_symbol,
690 .print_comment = header_print_comment,
696 * This printer is used when generating the `include/generated/tristate.conf' file.
699 tristate_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
702 if (sym->type == S_TRISTATE && *value != 'n')
703 fprintf(fp, "%s%s=%c\n", CONFIG_, sym->name, (char)toupper(*value));
706 static struct conf_printer tristate_printer_cb =
708 .print_symbol = tristate_print_symbol,
709 .print_comment = kconfig_print_comment,
712 static void conf_write_symbol(FILE *fp, struct symbol *sym,
713 struct conf_printer *printer, void *printer_arg)
722 str = sym_get_string_value(sym);
723 str = sym_escape_string_value(str);
724 printer->print_symbol(fp, sym, str, printer_arg);
728 str = sym_get_string_value(sym);
729 printer->print_symbol(fp, sym, str, printer_arg);
734 conf_write_heading(FILE *fp, struct conf_printer *printer, void *printer_arg)
738 snprintf(buf, sizeof(buf),
740 "Automatically generated file; DO NOT EDIT.\n"
742 rootmenu.prompt->text);
744 printer->print_comment(fp, buf, printer_arg);
748 * Write out a minimal config.
749 * All values that has default values are skipped as this is redundant.
751 int conf_write_defconfig(const char *filename)
757 out = fopen(filename, "w");
761 sym_clear_all_valid();
763 /* Traverse all menus to find all relevant symbols */
764 menu = rootmenu.list;
770 if (!menu_is_visible(menu))
772 } else if (!sym_is_choice(sym)) {
774 if (!(sym->flags & SYMBOL_WRITE))
776 sym->flags &= ~SYMBOL_WRITE;
777 /* If we cannot change the symbol - skip */
778 if (!sym_is_changable(sym))
780 /* If symbol equals to default value - skip */
781 if (strcmp(sym_get_string_value(sym), sym_get_string_default(sym)) == 0)
785 * If symbol is a choice value and equals to the
786 * default for a choice - skip.
787 * But only if value is bool and equal to "y" and
788 * choice is not "optional".
789 * (If choice is "optional" then all values can be "n")
791 if (sym_is_choice_value(sym)) {
795 cs = prop_get_symbol(sym_get_choice_prop(sym));
796 ds = sym_choice_default(cs);
797 if (!sym_is_optional(cs) && sym == ds) {
798 if ((sym->type == S_BOOLEAN) &&
799 sym_get_tristate_value(sym) == yes)
803 conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);
806 if (menu->list != NULL) {
809 else if (menu->next != NULL) {
812 while ((menu = menu->parent)) {
813 if (menu->next != NULL) {
824 int conf_write(const char *name)
829 const char *basename;
831 char dirname[PATH_MAX+1], tmpname[PATH_MAX+22], newname[PATH_MAX+8];
835 if (name && name[0]) {
839 strcpy(dirname, name);
840 strcat(dirname, "/");
841 basename = conf_get_configname();
842 } else if ((slash = strrchr(name, '/'))) {
843 int size = slash - name + 1;
844 memcpy(dirname, name, size);
847 basename = slash + 1;
849 basename = conf_get_configname();
853 basename = conf_get_configname();
855 sprintf(newname, "%s%s", dirname, basename);
856 env = getenv("KCONFIG_OVERWRITECONFIG");
858 sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
859 out = fopen(tmpname, "w");
862 out = fopen(newname, "w");
867 conf_write_heading(out, &kconfig_printer_cb, NULL);
869 if (!conf_get_changed())
870 sym_clear_all_valid();
872 menu = rootmenu.list;
876 if (!menu_is_visible(menu))
878 str = menu_get_prompt(menu);
883 } else if (!(sym->flags & SYMBOL_CHOICE)) {
885 if (!(sym->flags & SYMBOL_WRITE))
887 sym->flags &= ~SYMBOL_WRITE;
889 conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);
899 else while ((menu = menu->parent)) {
909 strcat(dirname, basename);
910 strcat(dirname, ".old");
911 rename(newname, dirname);
912 if (rename(tmpname, newname))
916 conf_message("configuration written to %s", newname);
918 sym_set_change_count(0);
923 /* write a dependency file as used by kbuild to track dependencies */
924 static int conf_write_dep(const char *name)
931 out = fopen("..config.tmp", "w");
934 fprintf(out, "deps_config := \\\n");
935 for (file = file_list; file; file = file->next) {
937 fprintf(out, "\t%s \\\n", file->name);
939 fprintf(out, "\t%s\n", file->name);
941 fprintf(out, "\n%s: \\\n"
942 "\t$(deps_config)\n\n", conf_get_autoconfig_name());
944 env_write_dep(out, conf_get_autoconfig_name());
946 fprintf(out, "\n$(deps_config): ;\n");
948 rename("..config.tmp", name);
952 static int conf_split_config(void)
955 char path[PATH_MAX+1];
960 name = conf_get_autoconfig_name();
961 conf_read_simple(name, S_DEF_AUTO);
962 sym_calc_value(modules_sym);
964 if (chdir("include/generated"))
968 for_all_symbols(i, sym) {
970 if ((sym->flags & SYMBOL_NO_WRITE) || !sym->name)
972 if (sym->flags & SYMBOL_WRITE) {
973 if (sym->flags & SYMBOL_DEF_AUTO) {
975 * symbol has old and new value,
981 if (sym_get_tristate_value(sym) ==
982 sym->def[S_DEF_AUTO].tri)
988 if (!strcmp(sym_get_string_value(sym),
989 sym->def[S_DEF_AUTO].val))
997 * If there is no old value, only 'no' (unset)
998 * is allowed as new value.
1000 switch (sym->type) {
1003 if (sym_get_tristate_value(sym) == no)
1010 } else if (!(sym->flags & SYMBOL_DEF_AUTO))
1011 /* There is neither an old nor a new value. */
1014 * There is an old value, but no new value ('no' (unset)
1015 * isn't saved in auto.conf, so the old value is always
1016 * different from 'no').
1019 /* Replace all '_' and append ".h" */
1022 while ((c = *s++)) {
1024 *d++ = (c == '_') ? '/' : c;
1028 /* Assume directory path already exists. */
1029 fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
1031 if (errno != ENOENT) {
1036 if (make_parent_dir(path)) {
1041 fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
1056 int conf_write_autoconf(void)
1060 FILE *out, *tristate, *out_h, *out_c;
1063 sym_clear_all_valid();
1065 conf_write_dep("include/generated/auto.conf.cmd");
1067 if (conf_split_config())
1070 out = fopen(".tmpconfig", "w");
1074 tristate = fopen(".tmpconfig_tristate", "w");
1080 out_h = fopen(".tmpconfig.h", "w");
1087 out_c = fopen(".tmpconfig.cmake", "w");
1094 conf_write_heading(out, &kconfig_printer_cb, NULL);
1096 conf_write_heading(tristate, &tristate_printer_cb, NULL);
1098 conf_write_heading(out_h, &header_printer_cb, NULL);
1100 conf_write_heading(out_c, &kconfig_printer_cmake_cb, NULL);
1102 for_all_symbols(i, sym) {
1103 sym_calc_value(sym);
1104 if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
1107 /* write symbol to auto.conf, tristate and header files */
1108 conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1);
1110 conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1);
1112 conf_write_symbol(out_h, sym, &header_printer_cb, NULL);
1114 conf_write_symbol(out_c, sym, &kconfig_printer_cmake_cb, NULL);
1121 name = getenv("KCONFIG_AUTOHEADER");
1123 name = "include/generated/autoconf.h";
1124 if (rename(".tmpconfig.h", name))
1126 name = getenv("KCONFIG_TRISTATE");
1128 name = "include/generated/tristate.conf";
1129 if (rename(".tmpconfig_tristate", name))
1131 name = getenv("KCONFIG_CMAKE");
1133 name = "config.cmake";
1134 if (rename(".tmpconfig.cmake", name))
1136 name = conf_get_autoconfig_name();
1138 * This must be the last step, kbuild has a dependency on auto.conf
1139 * and this marks the successful completion of the previous steps.
1141 if (rename(".tmpconfig", name))
1147 static int sym_change_count;
1148 static void (*conf_changed_callback)(void);
1150 void sym_set_change_count(int count)
1152 int _sym_change_count = sym_change_count;
1153 sym_change_count = count;
1154 if (conf_changed_callback &&
1155 (bool)_sym_change_count != (bool)count)
1156 conf_changed_callback();
1159 void sym_add_change_count(int count)
1161 sym_set_change_count(count + sym_change_count);
1164 bool conf_get_changed(void)
1166 return sym_change_count;
1169 void conf_set_changed_callback(void (*fn)(void))
1171 conf_changed_callback = fn;
1174 static bool randomize_choice_values(struct symbol *csym)
1176 struct property *prop;
1182 * If choice is mod then we may have more items selected
1183 * and if no then no-one.
1184 * In both cases stop.
1186 if (csym->curr.tri != yes)
1189 prop = sym_get_choice_prop(csym);
1191 /* count entries in choice block */
1193 expr_list_for_each_sym(prop->expr, e, sym)
1197 * find a random value and set it to yes,
1198 * set the rest to no so we have only one set
1200 def = (rand() % cnt);
1203 expr_list_for_each_sym(prop->expr, e, sym) {
1205 sym->def[S_DEF_USER].tri = yes;
1206 csym->def[S_DEF_USER].val = sym;
1209 sym->def[S_DEF_USER].tri = no;
1211 sym->flags |= SYMBOL_DEF_USER;
1212 /* clear VALID to get value calculated */
1213 sym->flags &= ~SYMBOL_VALID;
1215 csym->flags |= SYMBOL_DEF_USER;
1216 /* clear VALID to get value calculated */
1217 csym->flags &= ~(SYMBOL_VALID);
1222 void set_all_choice_values(struct symbol *csym)
1224 struct property *prop;
1228 prop = sym_get_choice_prop(csym);
1231 * Set all non-assinged choice values to no
1233 expr_list_for_each_sym(prop->expr, e, sym) {
1234 if (!sym_has_value(sym))
1235 sym->def[S_DEF_USER].tri = no;
1237 csym->flags |= SYMBOL_DEF_USER;
1238 /* clear VALID to get value calculated */
1239 csym->flags &= ~(SYMBOL_VALID | SYMBOL_NEED_SET_CHOICE_VALUES);
1242 bool conf_set_all_new_symbols(enum conf_def_mode mode)
1244 struct symbol *sym, *csym;
1245 int i, cnt, pby, pty, ptm; /* pby: probability of bool = y
1246 * pty: probability of tristate = y
1247 * ptm: probability of tristate = m
1250 pby = 50; pty = ptm = 33; /* can't go as the default in switch-case
1251 * below, otherwise gcc whines about
1252 * -Wmaybe-uninitialized */
1253 if (mode == def_random) {
1255 char *env = getenv("KCONFIG_PROBABILITY");
1257 while( env && *env ) {
1259 int tmp = strtol( env, &endp, 10 );
1260 if( tmp >= 0 && tmp <= 100 ) {
1264 perror( "KCONFIG_PROBABILITY" );
1267 env = (*endp == ':') ? endp+1 : endp;
1274 pby = p[0]; ptm = pby/2; pty = pby-ptm;
1277 pty = p[0]; ptm = p[1]; pby = pty + ptm;
1280 pby = p[0]; pty = p[1]; ptm = p[2];
1284 if( pty+ptm > 100 ) {
1286 perror( "KCONFIG_PROBABILITY" );
1290 bool has_changed = false;
1292 for_all_symbols(i, sym) {
1293 if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID))
1295 switch (sym_get_type(sym)) {
1301 sym->def[S_DEF_USER].tri = yes;
1304 sym->def[S_DEF_USER].tri = mod;
1307 if (sym->flags & SYMBOL_ALLNOCONFIG_Y)
1308 sym->def[S_DEF_USER].tri = yes;
1310 sym->def[S_DEF_USER].tri = no;
1313 sym->def[S_DEF_USER].tri = no;
1315 if (sym->type == S_TRISTATE) {
1317 sym->def[S_DEF_USER].tri = yes;
1318 else if (cnt < (pty+ptm))
1319 sym->def[S_DEF_USER].tri = mod;
1320 } else if (cnt < pby)
1321 sym->def[S_DEF_USER].tri = yes;
1326 if (!(sym_is_choice(sym) && mode == def_random))
1327 sym->flags |= SYMBOL_DEF_USER;
1335 sym_clear_all_valid();
1338 * We have different type of choice blocks.
1339 * If curr.tri equals to mod then we can select several
1340 * choice symbols in one block.
1341 * In this case we do nothing.
1342 * If curr.tri equals yes then only one symbol can be
1343 * selected in a choice block and we set it to yes,
1344 * and the rest to no.
1346 if (mode != def_random) {
1347 for_all_symbols(i, csym) {
1348 if ((sym_is_choice(csym) && !sym_has_value(csym)) ||
1349 sym_is_choice_value(csym))
1350 csym->flags |= SYMBOL_NEED_SET_CHOICE_VALUES;
1354 for_all_symbols(i, csym) {
1355 if (sym_has_value(csym) || !sym_is_choice(csym))
1358 sym_calc_value(csym);
1359 if (mode == def_random)
1360 has_changed = randomize_choice_values(csym);
1362 set_all_choice_values(csym);