Our config should write out each symbol once and only once, but still write

out all symbols in all sub-menus.  I think this finally does it right.
This commit is contained in:
Rob Landley 2005-09-14 14:40:01 +00:00
parent 1e51925684
commit 2ee82723a8

View File

@ -255,6 +255,21 @@ int conf_read(const char *name)
return 0; return 0;
} }
struct menu *next_menu(struct menu *menu)
{
if (menu->list) return menu->list;
do {
if (menu->next) {
menu = menu->next;
break;
}
} while ((menu = menu->parent));
return menu;
}
#define SYMBOL_FORCEWRITE (1<<31)
int conf_write(const char *name) int conf_write(const char *name)
{ {
FILE *out, *out_h; FILE *out, *out_h;
@ -318,27 +333,34 @@ int conf_write(const char *name)
if (!sym_change_count) if (!sym_change_count)
sym_clear_all_valid(); sym_clear_all_valid();
/* Force write of all non-duplicate symbols. */
/* Write out everything by default. */
for(menu = rootmenu.list; menu; menu = next_menu(menu))
if (menu->sym) menu->sym->flags |= SYMBOL_FORCEWRITE;
menu = rootmenu.list; menu = rootmenu.list;
while (menu) { while (menu) {
sym = menu->sym; sym = menu->sym;
if (!sym) { if (!sym) {
if (menu_is_visible(menu)) { if (!menu_is_visible(menu))
str = menu_get_prompt(menu); goto next;
fprintf(out, "\n" str = menu_get_prompt(menu);
"#\n" fprintf(out, "\n"
"# %s\n" "#\n"
"#\n", str); "# %s\n"
if (out_h) "#\n", str);
fprintf(out_h, "\n" if (out_h)
"/*\n" fprintf(out_h, "\n"
" * %s\n" "/*\n"
" */\n", str); " * %s\n"
} " */\n", str);
} else if (!(sym->flags & SYMBOL_CHOICE)) { } else if (!(sym->flags & SYMBOL_CHOICE)) {
sym_calc_value(sym); sym_calc_value(sym);
//if (!(sym->flags & SYMBOL_WRITE)) if (!(sym->flags & SYMBOL_FORCEWRITE))
// goto next; goto next;
sym->flags &= ~SYMBOL_WRITE;
sym->flags &= ~SYMBOL_FORCEWRITE;
type = sym->type; type = sym->type;
if (type == S_TRISTATE) { if (type == S_TRISTATE) {
sym_calc_value(modules_sym); sym_calc_value(modules_sym);
@ -409,19 +431,8 @@ int conf_write(const char *name)
break; break;
} }
} }
next:
if (menu->list) { menu = next_menu(menu);
menu = menu->list;
continue;
}
if (menu->next)
menu = menu->next;
else while ((menu = menu->parent)) {
if (menu->next) {
menu = menu->next;
break;
}
}
} }
fclose(out); fclose(out);
if (out_h) { if (out_h) {