From cf271a82276a19917638de856a9d10f3b1ceb488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 14 May 2015 15:20:34 +0200 Subject: Fix problems with permute Permute should now reading and loading configurations right. In case of configuration change, forces save. --- conf.py | 2 +- scripts/permute/dotconf.c | 26 +++++++++++++++----------- scripts/permute/dotconf.h | 3 ++- scripts/permute/menudata.c | 19 +++++++++---------- scripts/permute/menudata.h | 1 + scripts/permute/permute.c | 30 +++++++++++++++++------------- 6 files changed, 45 insertions(+), 36 deletions(-) diff --git a/conf.py b/conf.py index b5a7524..df13e8a 100644 --- a/conf.py +++ b/conf.py @@ -11,11 +11,11 @@ ARCH = 'x86' SRCARCH = ARCH gen_all_solution_oninit = True # If True, all solutions are generated at initialization. +kernel_env = {'SRCARCH': SRCARCH, 'ARCH': ARCH, 'KERNELVERSION': ARCH} # linux_make_args # These are arguments passed to make when linux is build linux_make_args = ['-j8'] build_command = ['make'] + linux_make_args -kernel_env = {'SRCARCH': SRCARCH, 'ARCH': ARCH, 'KERNELVERSION': ARCH} # novaboot_args # These are arguments passed to novaboot, diff --git a/scripts/permute/dotconf.c b/scripts/permute/dotconf.c index aba607e..bf8e067 100644 --- a/scripts/permute/dotconf.c +++ b/scripts/permute/dotconf.c @@ -1,23 +1,28 @@ #include "dotconf.h" -bool dotconfig_read(void) { +void dotconfig_read(bool * reqsave) { FILE *f; f = fopen(DOTCONFIG_FILE, "r"); - if (f == NULL) - return false; + if (f == NULL) { + *reqsave = true; + return; + } char buffer[READBUFFER_SIZE]; while (fgets(buffer, READBUFFER_SIZE, f) != NULL) { if (buffer[0] == '\0' || buffer[1] == '\0') continue; - if (buffer[0] == '#') { - } else { + if (buffer[0] != '#') { char *wstr = buffer + 7; char *end = strchr(wstr, '='); *end = '\0'; struct symbol *sym = sym_find(wstr); if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE) continue; + if ((sym_get_tristate_value(sym) == yes && *(end + 1) != 'y') + || (sym_get_tristate_value(sym) == no + && *(end + 1) != 'n')) + *reqsave = true; struct property *prop; for_all_prompts(sym, prop) { if (prop->menu->data == NULL) @@ -68,8 +73,6 @@ bool dotconfig_read(void) { if (wmenu == NULL && stack_pos > 0) wmenu = stack[--stack_pos]; } - - return true; } void dotconfig_write(void) { @@ -81,8 +84,8 @@ void dotconfig_write(void) { int i; unsigned variable = 0, fixed = 0; for_all_symbols(i, sym) - if ((sym->type == S_BOOLEAN || sym->type == S_TRISTATE) - && sym->name != NULL) { + if ((sym->type == S_BOOLEAN || sym->type == S_TRISTATE) + && sym->name != NULL) { for_all_prompts(sym, prop) { if (prop->menu->data == NULL || !((struct menudata *) prop->menu->data)->permute) { @@ -92,8 +95,9 @@ void dotconfig_write(void) { break; } else { variable++; - printf("%s\n=%s\n", sym->name, - sym_get_tristate_value(sym) == no ? "n" : "y"); + if (verbose_level > 1) + printf("%s=%s\n", sym->name, + sym_get_tristate_value(sym) == no ? "n" : "y"); } } } diff --git a/scripts/permute/dotconf.h b/scripts/permute/dotconf.h index 8933f54..34fa8db 100644 --- a/scripts/permute/dotconf.h +++ b/scripts/permute/dotconf.h @@ -4,6 +4,7 @@ #include #include +#include #include "menudata.h" #ifndef _DOTCONF_H_ @@ -12,7 +13,7 @@ #define DOTCONFIG_FILE "../dot_config" #define READBUFFER_SIZE 128 -bool dotconfig_read(void); +void dotconfig_read(bool * reqsave); void dotconfig_write(void); #endif /* _DOTCONF_H_ */ diff --git a/scripts/permute/menudata.c b/scripts/permute/menudata.c index c941552..88910ab 100644 --- a/scripts/permute/menudata.c +++ b/scripts/permute/menudata.c @@ -8,11 +8,14 @@ struct menudata *menudata_new(void) { void menudata_set_permute(struct menu *m, bool perm) { ((struct menudata *) m->data)->permute = perm; - ((struct menudata *) m->data)->subpermute = perm; struct menu *prnt; - for (prnt = m->parent; prnt != NULL; prnt = prnt->parent) { + for (prnt = m; prnt != NULL; prnt = prnt->parent) { menudata_cal(prnt); } +} + +void menudata_set_all_permute(struct menu *m, bool perm) { + menudata_set_permute(m, perm); struct menu **stack; size_t stack_size = 2, stack_pos = 0; @@ -37,23 +40,19 @@ void menudata_set_permute(struct menu *m, bool perm) { if (m == NULL && stack_pos > 0) m = stack[--stack_pos]; } + } void menudata_cal(struct menu *m) { - bool perm = true; bool subperm = false; struct menu *w; for (w = m->list; w != NULL; w = w->next) { if (w->data != NULL && (((struct menudata *) w->data)->permute || ((struct menudata *) w->data)-> subpermute)) { - subperm = true; - } else { - perm = false; + if (m->data == NULL) + m->data = menudata_new(); + ((struct menudata *) m->data)->subpermute = subperm; } } - if (m->data == NULL) - m->data = menudata_new(); - ((struct menudata *) m->data)->permute = perm && subperm; - ((struct menudata *) m->data)->subpermute = subperm; } diff --git a/scripts/permute/menudata.h b/scripts/permute/menudata.h index 5b3c46b..a273891 100644 --- a/scripts/permute/menudata.h +++ b/scripts/permute/menudata.h @@ -14,6 +14,7 @@ struct menudata { struct menudata *menudata_new(void); void menudata_set_permute(struct menu *m, bool perm); +void menudata_set_all_permute(struct menu *m, bool perm); void menudata_cal(struct menu *m); #endif /* _MENUDATA_H_ */ diff --git a/scripts/permute/permute.c b/scripts/permute/permute.c index e3c6810..ec9abf0 100644 --- a/scripts/permute/permute.c +++ b/scripts/permute/permute.c @@ -9,7 +9,9 @@ #include #include "menudata.h" #include "dotconf.h" + #define INPUT_SIZE 1024 + int verbose_level; char *file; @@ -44,10 +46,7 @@ int main(int argc, char **argv) { conf_parse(file); conf_read(".config"); - if (!dotconfig_read()) - reqsave = true; - else - reqsave = false; + dotconfig_read(&reqsave); struct menu *wroot, *wmenu, *wwmenu; wroot = &rootmenu; @@ -136,7 +135,11 @@ int main(int argc, char **argv) { goto input; break; case 'v': - menudata_set_permute(wwmenu, true); + if (input[1] == 'a') { + menudata_set_all_permute(wwmenu, true); + } else { + menudata_set_permute(wwmenu, true); + } reqsave = true; break; case 'f': @@ -154,14 +157,15 @@ int main(int argc, char **argv) { void printf_help(void) { printf("As input are accepted these commands:\n"); - printf(" e Enter menu according to number.\n"); - printf(" u Go to previous upper menu.\n"); - printf(" v Set menu and all its submenus as variable.\n"); - printf(" f Set menu and all its submenus as fixed.\n"); - printf(" s Save settings.\n"); - printf(" r Reprint menu.\n"); - printf(" h Prints this text.\n"); - printf(" q Quit this program\n"); + printf(" e Enter menu according to number.\n"); + printf(" u Go to previous upper menu.\n"); + printf(" v Set config as variable.\n"); + printf(" va Set menu and all its submenus as variable.\n"); + printf(" f Set menu and all its submenus as fixed.\n"); + printf(" s Save settings.\n"); + printf(" r Reprint menu.\n"); + printf(" h Prints this text.\n"); + printf(" q Quit this program\n"); } void exit_save(void) { -- cgit v1.2.3