summaryrefslogtreecommitdiff
path: root/scripts/kconfig/conf.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/kconfig/conf.c')
-rw-r--r--scripts/kconfig/conf.c52
1 files changed, 27 insertions, 25 deletions
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 1199baf866ca..a38787a881ea 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -37,6 +37,14 @@ static struct menu *rootEntry;
static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n");
+static const char *get_help(struct menu *menu)
+{
+ if (menu_has_help(menu))
+ return menu_get_help(menu);
+ else
+ return nohelp_text;
+}
+
static void strip(char *str)
{
char *p = str;
@@ -64,7 +72,7 @@ static void check_stdin(void)
}
}
-static void conf_askvalue(struct symbol *sym, const char *def)
+static int conf_askvalue(struct symbol *sym, const char *def)
{
enum symbol_type type = sym_get_type(sym);
tristate val;
@@ -79,7 +87,7 @@ static void conf_askvalue(struct symbol *sym, const char *def)
printf("%s\n", def);
line[0] = '\n';
line[1] = 0;
- return;
+ return 0;
}
switch (input_mode) {
@@ -89,23 +97,23 @@ static void conf_askvalue(struct symbol *sym, const char *def)
case set_random:
if (sym_has_value(sym)) {
printf("%s\n", def);
- return;
+ return 0;
}
break;
case ask_new:
case ask_silent:
if (sym_has_value(sym)) {
printf("%s\n", def);
- return;
+ return 0;
}
check_stdin();
case ask_all:
fflush(stdout);
fgets(line, 128, stdin);
- return;
+ return 1;
case set_default:
printf("%s\n", def);
- return;
+ return 1;
default:
break;
}
@@ -115,7 +123,7 @@ static void conf_askvalue(struct symbol *sym, const char *def)
case S_HEX:
case S_STRING:
printf("%s\n", def);
- return;
+ return 1;
default:
;
}
@@ -166,12 +174,13 @@ static void conf_askvalue(struct symbol *sym, const char *def)
break;
}
printf("%s", line);
+ return 1;
}
int conf_string(struct menu *menu)
{
struct symbol *sym = menu->sym;
- const char *def, *help;
+ const char *def;
while (1) {
printf("%*s%s ", indent - 1, "", menu->prompt->text);
@@ -179,17 +188,15 @@ int conf_string(struct menu *menu)
def = sym_get_string_value(sym);
if (sym_get_string_value(sym))
printf("[%s] ", def);
- conf_askvalue(sym, def);
+ if (!conf_askvalue(sym, def))
+ return 0;
switch (line[0]) {
case '\n':
break;
case '?':
/* print help */
if (line[1] == '\n') {
- help = nohelp_text;
- if (menu->sym->help)
- help = menu->sym->help;
- printf("\n%s\n", menu->sym->help);
+ printf("\n%s\n", get_help(menu));
def = NULL;
break;
}
@@ -207,7 +214,6 @@ static int conf_sym(struct menu *menu)
struct symbol *sym = menu->sym;
int type;
tristate oldval, newval;
- const char *help;
while (1) {
printf("%*s%s ", indent - 1, "", menu->prompt->text);
@@ -233,10 +239,11 @@ static int conf_sym(struct menu *menu)
printf("/m");
if (oldval != yes && sym_tristate_within_range(sym, yes))
printf("/y");
- if (sym->help)
+ if (menu_has_help(menu))
printf("/?");
printf("] ");
- conf_askvalue(sym, sym_get_string_value(sym));
+ if (!conf_askvalue(sym, sym_get_string_value(sym)))
+ return 0;
strip(line);
switch (line[0]) {
@@ -269,10 +276,7 @@ static int conf_sym(struct menu *menu)
if (sym_set_tristate_value(sym, newval))
return 0;
help:
- help = nohelp_text;
- if (sym->help)
- help = sym->help;
- printf("\n%s\n", help);
+ printf("\n%s\n", get_help(menu));
}
}
@@ -342,7 +346,7 @@ static int conf_choice(struct menu *menu)
goto conf_childs;
}
printf("[1-%d", cnt);
- if (sym->help)
+ if (menu_has_help(menu))
printf("?");
printf("]: ");
switch (input_mode) {
@@ -359,8 +363,7 @@ static int conf_choice(struct menu *menu)
fgets(line, 128, stdin);
strip(line);
if (line[0] == '?') {
- printf("\n%s\n", menu->sym->help ?
- menu->sym->help : nohelp_text);
+ printf("\n%s\n", get_help(menu));
continue;
}
if (!line[0])
@@ -391,8 +394,7 @@ static int conf_choice(struct menu *menu)
if (!child)
continue;
if (line[strlen(line) - 1] == '?') {
- printf("\n%s\n", child->sym->help ?
- child->sym->help : nohelp_text);
+ printf("\n%s\n", get_help(child));
continue;
}
sym_set_choice_value(sym, child->sym);