author | kergoth <kergoth> | 2003-06-17 17:03:49 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-06-17 17:03:49 (UTC) |
commit | 16e53b2a2e94742f3b55ee73700bb264e36638d4 (patch) (side-by-side diff) | |
tree | 4f2b65a635d25c1ce0cfeea7953623c2bf7d9534 /scripts/kconfig/conf.c | |
parent | 384b7f1a42f9f2f101dc8fe11c3625055d96f672 (diff) | |
download | opie-16e53b2a2e94742f3b55ee73700bb264e36638d4.zip opie-16e53b2a2e94742f3b55ee73700bb264e36638d4.tar.gz opie-16e53b2a2e94742f3b55ee73700bb264e36638d4.tar.bz2 |
Update LinuxKernelConf version to 1.4.
-rw-r--r-- | scripts/kconfig/conf.c | 222 |
1 files changed, 110 insertions, 112 deletions
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 1602d5f..3c27a78 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -30,54 +30,16 @@ enum { static int indent = 1; static int valid_stdin = 1; static int conf_cnt; static char line[128]; static struct menu *rootEntry; static char nohelp_text[] = "Sorry, no help available for this option yet.\n"; -#if 0 -static void printc(int ch) -{ - static int sep = 0; - - if (!sep) { - putchar('['); - sep = 1; - } else if (ch) - putchar('/'); - if (!ch) { - putchar(']'); - putchar(' '); - sep = 0; - } else - putchar(ch); -} -#endif - -static void printo(const char *o) -{ - static int sep = 0; - - if (!sep) { - putchar('('); - sep = 1; - } else if (o) { - putchar(','); - putchar(' '); - } - if (!o) { - putchar(')'); - putchar(' '); - sep = 0; - } else - printf("%s", o); -} - static void strip(char *str) { char *p = str; int l; while ((isspace(*p))) p++; l = strlen(p); @@ -85,40 +47,52 @@ static void strip(char *str) memmove(str, p, l + 1); if (!l) return; p = str + l - 1; while ((isspace(*p))) *p-- = 0; } +static void check_stdin(void) +{ + if (!valid_stdin && input_mode == ask_silent) { + printf("aborted!\n\n"); + printf("Console input/output is redirected. "); + printf("Run 'make oldconfig' to update configuration.\n\n"); + exit(1); + } +} + static void conf_askvalue(struct symbol *sym, const char *def) { enum symbol_type type = sym_get_type(sym); tristate val; if (!sym_has_value(sym)) printf("(NEW) "); line[0] = '\n'; line[1] = 0; + if (!sym_is_changable(sym)) { + printf("%s\n", def); + line[0] = '\n'; + line[1] = 0; + return; + } + switch (input_mode) { case ask_new: case ask_silent: if (sym_has_value(sym)) { printf("%s\n", def); return; } - if (!valid_stdin && input_mode == ask_silent) { - printf("aborted!\n\n"); - printf("Console input/output is redirected. "); - printf("Run 'make oldconfig' to update configuration.\n\n"); - exit(1); - } + check_stdin(); case ask_all: fflush(stdout); fgets(line, 128, stdin); return; case set_default: printf("%s\n", def); return; default: @@ -289,19 +263,18 @@ help: help = sym->help; printf("\n%s\n", help); } } static int conf_choice(struct menu *menu) { struct symbol *sym, *def_sym; - struct menu *cmenu, *def_menu; - const char *help; - int type, len; + struct menu *child; + int type; bool is_new; sym = menu->sym; type = sym_get_type(sym); is_new = !sym_has_value(sym); if (sym_is_changable(sym)) { conf_sym(menu); sym_calc_value(sym); @@ -309,84 +282,121 @@ static int conf_choice(struct menu *menu) case no: return 1; case mod: return 0; case yes: break; } } else { - sym->def = sym->curr; - if (S_TRI(sym->curr) == mod) { + switch (sym_get_tristate_value(sym)) { + case no: + return 1; + case mod: printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); return 0; + case yes: + break; } } while (1) { - printf("%*s%s ", indent - 1, "", menu_get_prompt(menu)); + int cnt, def; + + printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); def_sym = sym_get_choice_value(sym); - def_menu = NULL; - for (cmenu = menu->list; cmenu; cmenu = cmenu->next) { - if (!menu_is_visible(cmenu)) + cnt = def = 0; + line[0] = '0'; + line[1] = 0; + for (child = menu->list; child; child = child->next) { + if (!menu_is_visible(child)) continue; - printo(menu_get_prompt(cmenu)); - if (cmenu->sym == def_sym) - def_menu = cmenu; - } - printo(NULL); - if (def_menu) - printf("[%s] ", menu_get_prompt(def_menu)); - else { + if (!child->sym) { + printf("%*c %s\n", indent, '*', menu_get_prompt(child)); + continue; + } + cnt++; + if (child->sym == def_sym) { + def = cnt; + printf("%*c", indent, '>'); + } else + printf("%*c", indent, ' '); + printf(" %d. %s", cnt, menu_get_prompt(child)); + if (child->sym->name) + printf(" (%s)", child->sym->name); + if (!sym_has_value(child->sym)) + printf(" (NEW)"); printf("\n"); - return 1; } + printf("%*schoice", indent - 1, ""); + if (cnt == 1) { + printf("[1]: 1\n"); + goto conf_childs; + } + printf("[1-%d", cnt); + if (sym->help) + printf("?"); + printf("]: "); switch (input_mode) { case ask_new: case ask_silent: + if (!is_new) { + cnt = def; + printf("%d\n", cnt); + break; + } + check_stdin(); case ask_all: - if (is_new) - sym->flags |= SYMBOL_NEW; - conf_askvalue(sym, menu_get_prompt(def_menu)); + fflush(stdout); + fgets(line, 128, stdin); strip(line); + if (line[0] == '?') { + printf("\n%s\n", menu->sym->help ? + menu->sym->help : nohelp_text); + continue; + } + if (!line[0]) + cnt = def; + else if (isdigit(line[0])) + cnt = atoi(line); + else + continue; + break; + case set_random: + def = (random() % cnt) + 1; + case set_default: + case set_yes: + case set_mod: + case set_no: + cnt = def; + printf("%d\n", cnt); break; - default: - line[0] = 0; - printf("\n"); } - if (line[0] == '?' && !line[1]) { - help = nohelp_text; - if (menu->sym->help) - help = menu->sym->help; - printf("\n%s\n", help); - continue; + + conf_childs: + for (child = menu->list; child; child = child->next) { + if (!child->sym || !menu_is_visible(child)) + continue; + if (!--cnt) + break; } - if (line[0]) { - len = strlen(line); - line[len] = 0; - - def_menu = NULL; - for (cmenu = menu->list; cmenu; cmenu = cmenu->next) { - if (!cmenu->sym || !menu_is_visible(cmenu)) - continue; - if (!strncasecmp(line, menu_get_prompt(cmenu), len)) { - def_menu = cmenu; - break; - } - } + if (!child) + continue; + if (line[strlen(line) - 1] == '?') { + printf("\n%s\n", child->sym->help ? + child->sym->help : nohelp_text); + continue; } - if (def_menu) { - sym_set_choice_value(sym, def_menu->sym); - if (def_menu->list) { - indent += 2; - conf(def_menu->list); - indent -= 2; - } - return 1; + sym_set_choice_value(sym, child->sym); + if (child->list) { + indent += 2; + conf(child->list); + indent -= 2; } + return 1; } } static void conf(struct menu *menu) { struct symbol *sym; struct property *prop; struct menu *child; @@ -417,17 +427,17 @@ static void conf(struct menu *menu) } } if (!sym) goto conf_childs; if (sym_is_choice(sym)) { conf_choice(menu); - if (S_TRI(sym->curr) != mod) + if (sym->curr.tri != mod) return; goto conf_childs; } switch (sym->type) { case S_INT: case S_HEX: case S_STRING: @@ -451,39 +461,27 @@ static void check_conf(struct menu *menu) { struct symbol *sym; struct menu *child; if (!menu_is_visible(menu)) return; sym = menu->sym; - if (!sym) - goto conf_childs; - - if (sym_is_choice(sym)) { - if (!sym_has_value(sym)) { + if (sym) { + if (sym_is_changable(sym) && !sym_has_value(sym)) { if (!conf_cnt++) printf("*\n* Restart config...\n*\n"); rootEntry = menu_get_parent_menu(menu); conf(rootEntry); } - if (sym_get_tristate_value(sym) != mod) + if (sym_is_choice(sym) && sym_get_tristate_value(sym) != mod) return; - goto conf_childs; } - if (!sym_has_value(sym)) { - if (!conf_cnt++) - printf("*\n* Restart config...\n*\n"); - rootEntry = menu_get_parent_menu(menu); - conf(rootEntry); - } - -conf_childs: for (child = menu->list; child; child = child->next) check_conf(child); } int main(int ac, char **av) { const char *name; struct stat tmpstat; @@ -531,17 +529,17 @@ int main(int ac, char **av) "*** Can't find default configuration \"%s\"!\n" "***\n", name); exit(1); } break; case ask_silent: if (stat(".config", &tmpstat)) { printf("***\n" - "*** You have not yet configured your kernel!\n" + "*** You have not yet configured!\n" "***\n" "*** Please run some configurator (e.g. \"make oldconfig\" or\n" "*** \"make menuconfig\" or \"make xconfig\").\n" "***\n"); exit(1); } case ask_all: case ask_new: |