aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2015-05-14 15:20:34 +0200
committerKarel Kočí <cynerd@email.cz>2015-05-14 15:20:34 +0200
commitcf271a82276a19917638de856a9d10f3b1ceb488 (patch)
treea7bad80c1300e0504cd69885269ac81b642c33f9 /scripts
parent71ffeac967944bfd4f61d1f5724c8aed9d6d35a3 (diff)
downloadlinux-conf-perf-cf271a82276a19917638de856a9d10f3b1ceb488.tar.gz
linux-conf-perf-cf271a82276a19917638de856a9d10f3b1ceb488.tar.bz2
linux-conf-perf-cf271a82276a19917638de856a9d10f3b1ceb488.zip
Fix problems with permute
Permute should now reading and loading configurations right. In case of configuration change, forces save.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/permute/dotconf.c26
-rw-r--r--scripts/permute/dotconf.h3
-rw-r--r--scripts/permute/menudata.c19
-rw-r--r--scripts/permute/menudata.h1
-rw-r--r--scripts/permute/permute.c30
5 files changed, 44 insertions, 35 deletions
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 <stdbool.h>
#include <kconfig/lkc.h>
+#include <macros.h>
#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 <build_files.h>
#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 <NUM> Enter menu according to number.\n");
- printf(" u Go to previous upper menu.\n");
- printf(" v <NUM> Set menu and all its submenus as variable.\n");
- printf(" f <NUM> 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 <NUM> Enter menu according to number.\n");
+ printf(" u Go to previous upper menu.\n");
+ printf(" v <NUM> Set config as variable.\n");
+ printf(" va <NUM> Set menu and all its submenus as variable.\n");
+ printf(" f <NUM> 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) {