summaryrefslogtreecommitdiff
path: root/scripts/kconfig/conf.c
Unidiff
Diffstat (limited to 'scripts/kconfig/conf.c') (more/less context) (show whitespace changes)
-rw-r--r--scripts/kconfig/conf.c208
1 files changed, 103 insertions, 105 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
@@ -37,40 +37,2 @@ static char nohelp_text[] = "Sorry, no help available for this option yet.\n";
37 37
38#if 0
39static void printc(int ch)
40{
41 static int sep = 0;
42
43 if (!sep) {
44 putchar('[');
45 sep = 1;
46 } else if (ch)
47 putchar('/');
48 if (!ch) {
49 putchar(']');
50 putchar(' ');
51 sep = 0;
52 } else
53 putchar(ch);
54}
55#endif
56
57static void printo(const char *o)
58{
59 static int sep = 0;
60
61 if (!sep) {
62 putchar('(');
63 sep = 1;
64 } else if (o) {
65 putchar(',');
66 putchar(' ');
67 }
68 if (!o) {
69 putchar(')');
70 putchar(' ');
71 sep = 0;
72 } else
73 printf("%s", o);
74}
75
76static void strip(char *str) 38static void strip(char *str)
@@ -92,2 +54,12 @@ static void strip(char *str)
92 54
55static void check_stdin(void)
56{
57 if (!valid_stdin && input_mode == ask_silent) {
58 printf("aborted!\n\n");
59 printf("Console input/output is redirected. ");
60 printf("Run 'make oldconfig' to update configuration.\n\n");
61 exit(1);
62 }
63}
64
93static void conf_askvalue(struct symbol *sym, const char *def) 65static void conf_askvalue(struct symbol *sym, const char *def)
@@ -103,2 +75,9 @@ static void conf_askvalue(struct symbol *sym, const char *def)
103 75
76 if (!sym_is_changable(sym)) {
77 printf("%s\n", def);
78 line[0] = '\n';
79 line[1] = 0;
80 return;
81 }
82
104 switch (input_mode) { 83 switch (input_mode) {
@@ -110,8 +89,3 @@ static void conf_askvalue(struct symbol *sym, const char *def)
110 } 89 }
111 if (!valid_stdin && input_mode == ask_silent) { 90 check_stdin();
112 printf("aborted!\n\n");
113 printf("Console input/output is redirected. ");
114 printf("Run 'make oldconfig' to update configuration.\n\n");
115 exit(1);
116 }
117 case ask_all: 91 case ask_all:
@@ -296,5 +270,4 @@ static int conf_choice(struct menu *menu)
296 struct symbol *sym, *def_sym; 270 struct symbol *sym, *def_sym;
297 struct menu *cmenu, *def_menu; 271 struct menu *child;
298 const char *help; 272 int type;
299 int type, len;
300 bool is_new; 273 bool is_new;
@@ -316,6 +289,10 @@ static int conf_choice(struct menu *menu)
316 } else { 289 } else {
317 sym->def = sym->curr; 290 switch (sym_get_tristate_value(sym)) {
318 if (S_TRI(sym->curr) == mod) { 291 case no:
292 return 1;
293 case mod:
319 printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu)); 294 printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
320 return 0; 295 return 0;
296 case yes:
297 break;
321 } 298 }
@@ -324,19 +301,38 @@ static int conf_choice(struct menu *menu)
324 while (1) { 301 while (1) {
325 printf("%*s%s ", indent - 1, "", menu_get_prompt(menu)); 302 int cnt, def;
303
304 printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
326 def_sym = sym_get_choice_value(sym); 305 def_sym = sym_get_choice_value(sym);
327 def_menu = NULL; 306 cnt = def = 0;
328 for (cmenu = menu->list; cmenu; cmenu = cmenu->next) { 307 line[0] = '0';
329 if (!menu_is_visible(cmenu)) 308 line[1] = 0;
309 for (child = menu->list; child; child = child->next) {
310 if (!menu_is_visible(child))
311 continue;
312 if (!child->sym) {
313 printf("%*c %s\n", indent, '*', menu_get_prompt(child));
330 continue; 314 continue;
331 printo(menu_get_prompt(cmenu)); 315 }
332 if (cmenu->sym == def_sym) 316 cnt++;
333 def_menu = cmenu; 317 if (child->sym == def_sym) {
334 } 318 def = cnt;
335 printo(NULL); 319 printf("%*c", indent, '>');
336 if (def_menu) 320 } else
337 printf("[%s] ", menu_get_prompt(def_menu)); 321 printf("%*c", indent, ' ');
338 else { 322 printf(" %d. %s", cnt, menu_get_prompt(child));
323 if (child->sym->name)
324 printf(" (%s)", child->sym->name);
325 if (!sym_has_value(child->sym))
326 printf(" (NEW)");
339 printf("\n"); 327 printf("\n");
340 return 1;
341 } 328 }
329 printf("%*schoice", indent - 1, "");
330 if (cnt == 1) {
331 printf("[1]: 1\n");
332 goto conf_childs;
333 }
334 printf("[1-%d", cnt);
335 if (sym->help)
336 printf("?");
337 printf("]: ");
342 switch (input_mode) { 338 switch (input_mode) {
@@ -344,38 +340,53 @@ static int conf_choice(struct menu *menu)
344 case ask_silent: 340 case ask_silent:
341 if (!is_new) {
342 cnt = def;
343 printf("%d\n", cnt);
344 break;
345 }
346 check_stdin();
345 case ask_all: 347 case ask_all:
346 if (is_new) 348 fflush(stdout);
347 sym->flags |= SYMBOL_NEW; 349 fgets(line, 128, stdin);
348 conf_askvalue(sym, menu_get_prompt(def_menu));
349 strip(line); 350 strip(line);
350 break; 351 if (line[0] == '?') {
351 default: 352 printf("\n%s\n", menu->sym->help ?
352 line[0] = 0; 353 menu->sym->help : nohelp_text);
353 printf("\n"); 354 continue;
354 } 355 }
355 if (line[0] == '?' && !line[1]) { 356 if (!line[0])
356 help = nohelp_text; 357 cnt = def;
357 if (menu->sym->help) 358 else if (isdigit(line[0]))
358 help = menu->sym->help; 359 cnt = atoi(line);
359 printf("\n%s\n", help); 360 else
360 continue; 361 continue;
362 break;
363 case set_random:
364 def = (random() % cnt) + 1;
365 case set_default:
366 case set_yes:
367 case set_mod:
368 case set_no:
369 cnt = def;
370 printf("%d\n", cnt);
371 break;
361 } 372 }
362 if (line[0]) {
363 len = strlen(line);
364 line[len] = 0;
365 373
366 def_menu = NULL; 374 conf_childs:
367 for (cmenu = menu->list; cmenu; cmenu = cmenu->next) { 375 for (child = menu->list; child; child = child->next) {
368 if (!cmenu->sym || !menu_is_visible(cmenu)) 376 if (!child->sym || !menu_is_visible(child))
369 continue; 377 continue;
370 if (!strncasecmp(line, menu_get_prompt(cmenu), len)) { 378 if (!--cnt)
371 def_menu = cmenu;
372 break; 379 break;
373 } 380 }
381 if (!child)
382 continue;
383 if (line[strlen(line) - 1] == '?') {
384 printf("\n%s\n", child->sym->help ?
385 child->sym->help : nohelp_text);
386 continue;
374 } 387 }
375 } 388 sym_set_choice_value(sym, child->sym);
376 if (def_menu) { 389 if (child->list) {
377 sym_set_choice_value(sym, def_menu->sym);
378 if (def_menu->list) {
379 indent += 2; 390 indent += 2;
380 conf(def_menu->list); 391 conf(child->list);
381 indent -= 2; 392 indent -= 2;
@@ -385,3 +396,2 @@ static int conf_choice(struct menu *menu)
385 } 396 }
386}
387 397
@@ -424,3 +434,3 @@ static void conf(struct menu *menu)
424 conf_choice(menu); 434 conf_choice(menu);
425 if (S_TRI(sym->curr) != mod) 435 if (sym->curr.tri != mod)
426 return; 436 return;
@@ -458,7 +468,4 @@ static void check_conf(struct menu *menu)
458 sym = menu->sym; 468 sym = menu->sym;
459 if (!sym) 469 if (sym) {
460 goto conf_childs; 470 if (sym_is_changable(sym) && !sym_has_value(sym)) {
461
462 if (sym_is_choice(sym)) {
463 if (!sym_has_value(sym)) {
464 if (!conf_cnt++) 471 if (!conf_cnt++)
@@ -468,15 +475,6 @@ static void check_conf(struct menu *menu)
468 } 475 }
469 if (sym_get_tristate_value(sym) != mod) 476 if (sym_is_choice(sym) && sym_get_tristate_value(sym) != mod)
470 return; 477 return;
471 goto conf_childs;
472 }
473
474 if (!sym_has_value(sym)) {
475 if (!conf_cnt++)
476 printf("*\n* Restart config...\n*\n");
477 rootEntry = menu_get_parent_menu(menu);
478 conf(rootEntry);
479 } 478 }
480 479
481conf_childs:
482 for (child = menu->list; child; child = child->next) 480 for (child = menu->list; child; child = child->next)
@@ -538,3 +536,3 @@ int main(int ac, char **av)
538 printf("***\n" 536 printf("***\n"
539 "*** You have not yet configured your kernel!\n" 537 "*** You have not yet configured!\n"
540 "***\n" 538 "***\n"