blob: 11799894f3bda59425415545b9533db72f70b819 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
4 */
5
6#include <stdlib.h>
7#include <string.h>
8
9#define LKC_DIRECT_LINK
10#include "lkc.h"
11
Cheng Renquan6bd59992009-07-12 16:11:44 +080012static const char nohelp_text[] = N_(
13 "There is no help available for this kernel option.\n");
14
Linus Torvalds1da177e2005-04-16 15:20:36 -070015struct menu rootmenu;
16static struct menu **last_entry_ptr;
17
18struct file *file_list;
19struct file *current_file;
20
Roman Zippel93449082008-01-14 04:50:54 +010021void menu_warn(struct menu *menu, const char *fmt, ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -070022{
23 va_list ap;
24 va_start(ap, fmt);
25 fprintf(stderr, "%s:%d:warning: ", menu->file->name, menu->lineno);
26 vfprintf(stderr, fmt, ap);
27 fprintf(stderr, "\n");
28 va_end(ap);
29}
30
31static void prop_warn(struct property *prop, const char *fmt, ...)
32{
33 va_list ap;
34 va_start(ap, fmt);
35 fprintf(stderr, "%s:%d:warning: ", prop->file->name, prop->lineno);
36 vfprintf(stderr, fmt, ap);
37 fprintf(stderr, "\n");
38 va_end(ap);
39}
40
nir.tzachar@gmail.com692d97c2009-11-25 12:28:43 +020041void _menu_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070042{
43 current_entry = current_menu = &rootmenu;
44 last_entry_ptr = &rootmenu.list;
45}
46
47void menu_add_entry(struct symbol *sym)
48{
49 struct menu *menu;
50
51 menu = malloc(sizeof(*menu));
52 memset(menu, 0, sizeof(*menu));
53 menu->sym = sym;
54 menu->parent = current_menu;
55 menu->file = current_file;
56 menu->lineno = zconf_lineno();
57
58 *last_entry_ptr = menu;
59 last_entry_ptr = &menu->next;
60 current_entry = menu;
61}
62
63void menu_end_entry(void)
64{
65}
66
Roman Zippela02f0572005-11-08 21:34:53 -080067struct menu *menu_add_menu(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070068{
Roman Zippela02f0572005-11-08 21:34:53 -080069 menu_end_entry();
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 last_entry_ptr = &current_entry->list;
Roman Zippela02f0572005-11-08 21:34:53 -080071 return current_menu = current_entry;
Linus Torvalds1da177e2005-04-16 15:20:36 -070072}
73
74void menu_end_menu(void)
75{
76 last_entry_ptr = &current_menu->next;
77 current_menu = current_menu->parent;
78}
79
Trevor Keith4356f482009-09-18 12:49:23 -070080static struct expr *menu_check_dep(struct expr *e)
Linus Torvalds1da177e2005-04-16 15:20:36 -070081{
82 if (!e)
83 return e;
84
85 switch (e->type) {
86 case E_NOT:
87 e->left.expr = menu_check_dep(e->left.expr);
88 break;
89 case E_OR:
90 case E_AND:
91 e->left.expr = menu_check_dep(e->left.expr);
92 e->right.expr = menu_check_dep(e->right.expr);
93 break;
94 case E_SYMBOL:
95 /* change 'm' into 'm' && MODULES */
96 if (e->left.sym == &symbol_mod)
97 return expr_alloc_and(e, expr_alloc_symbol(modules_sym));
98 break;
99 default:
100 break;
101 }
102 return e;
103}
104
105void menu_add_dep(struct expr *dep)
106{
107 current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep));
Catalin Marinas246cf9c2010-06-08 17:25:57 +0100108 current_entry->dir_dep = current_entry->dep;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109}
110
111void menu_set_type(int type)
112{
113 struct symbol *sym = current_entry->sym;
114
115 if (sym->type == type)
116 return;
117 if (sym->type == S_UNKNOWN) {
118 sym->type = type;
119 return;
120 }
Roman Zippelf001f7f2006-06-08 22:12:48 -0700121 menu_warn(current_entry, "type of '%s' redefined from '%s' to '%s'",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 sym->name ? sym->name : "<choice>",
123 sym_type_name(sym->type), sym_type_name(type));
124}
125
126struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep)
127{
128 struct property *prop = prop_alloc(type, current_entry->sym);
129
130 prop->menu = current_entry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 prop->expr = expr;
132 prop->visible.expr = menu_check_dep(dep);
133
134 if (prompt) {
Roman Zippelf001f7f2006-06-08 22:12:48 -0700135 if (isspace(*prompt)) {
136 prop_warn(prop, "leading whitespace ignored");
137 while (isspace(*prompt))
138 prompt++;
139 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 if (current_entry->prompt)
Roman Zippelf001f7f2006-06-08 22:12:48 -0700141 prop_warn(prop, "prompt redefined");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 current_entry->prompt = prop;
143 }
Roman Zippelf001f7f2006-06-08 22:12:48 -0700144 prop->text = prompt;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145
146 return prop;
147}
148
blaisorblade@yahoo.itfb7f6ff2005-07-28 17:56:25 +0200149struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150{
blaisorblade@yahoo.itfb7f6ff2005-07-28 17:56:25 +0200151 return menu_add_prop(type, prompt, NULL, dep);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152}
153
154void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep)
155{
156 menu_add_prop(type, NULL, expr, dep);
157}
158
159void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep)
160{
161 menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep);
162}
163
Roman Zippelf6a88aa2006-06-08 22:12:44 -0700164void menu_add_option(int token, char *arg)
165{
Roman Zippelface4372006-06-08 22:12:45 -0700166 struct property *prop;
167
168 switch (token) {
169 case T_OPT_MODULES:
170 prop = prop_alloc(P_DEFAULT, modules_sym);
171 prop->expr = expr_alloc_symbol(current_entry->sym);
172 break;
173 case T_OPT_DEFCONFIG_LIST:
174 if (!sym_defconfig_list)
175 sym_defconfig_list = current_entry->sym;
176 else if (sym_defconfig_list != current_entry->sym)
177 zconf_error("trying to redefine defconfig symbol");
178 break;
Roman Zippel93449082008-01-14 04:50:54 +0100179 case T_OPT_ENV:
180 prop_add_env(arg);
181 break;
Roman Zippelface4372006-06-08 22:12:45 -0700182 }
Roman Zippelf6a88aa2006-06-08 22:12:44 -0700183}
184
Roman Zippel4cf3cbe2005-11-08 21:34:49 -0800185static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2)
186{
187 return sym2->type == S_INT || sym2->type == S_HEX ||
188 (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name));
189}
190
Trevor Keith4356f482009-09-18 12:49:23 -0700191static void sym_check_prop(struct symbol *sym)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192{
193 struct property *prop;
194 struct symbol *sym2;
195 for (prop = sym->prop; prop; prop = prop->next) {
196 switch (prop->type) {
197 case P_DEFAULT:
198 if ((sym->type == S_STRING || sym->type == S_INT || sym->type == S_HEX) &&
199 prop->expr->type != E_SYMBOL)
200 prop_warn(prop,
Li Zefan4280eae2010-04-14 11:44:05 +0800201 "default for config symbol '%s'"
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 " must be a single symbol", sym->name);
203 break;
204 case P_SELECT:
205 sym2 = prop_get_symbol(prop);
206 if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE)
207 prop_warn(prop,
208 "config symbol '%s' uses select, but is "
209 "not boolean or tristate", sym->name);
Sam Ravnborg603d4982008-02-02 21:09:57 +0100210 else if (sym2->type != S_UNKNOWN &&
211 sym2->type != S_BOOLEAN &&
212 sym2->type != S_TRISTATE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 prop_warn(prop,
214 "'%s' has wrong type. 'select' only "
215 "accept arguments of boolean and "
216 "tristate type", sym2->name);
217 break;
218 case P_RANGE:
219 if (sym->type != S_INT && sym->type != S_HEX)
220 prop_warn(prop, "range is only allowed "
221 "for int or hex symbols");
Roman Zippel4cf3cbe2005-11-08 21:34:49 -0800222 if (!menu_range_valid_sym(sym, prop->expr->left.sym) ||
223 !menu_range_valid_sym(sym, prop->expr->right.sym))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 prop_warn(prop, "range is invalid");
225 break;
226 default:
227 ;
228 }
229 }
230}
231
232void menu_finalize(struct menu *parent)
233{
234 struct menu *menu, *last_menu;
235 struct symbol *sym;
236 struct property *prop;
237 struct expr *parentdep, *basedep, *dep, *dep2, **ep;
238
239 sym = parent->sym;
240 if (parent->list) {
241 if (sym && sym_is_choice(sym)) {
Roman Zippel5a1aa8a2008-02-29 05:11:50 +0100242 if (sym->type == S_UNKNOWN) {
243 /* find the first choice value to find out choice type */
244 current_entry = parent;
245 for (menu = parent->list; menu; menu = menu->next) {
246 if (menu->sym && menu->sym->type != S_UNKNOWN) {
Jan Beulichf5eaa322008-01-24 11:54:23 +0000247 menu_set_type(menu->sym->type);
Roman Zippel5a1aa8a2008-02-29 05:11:50 +0100248 break;
249 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 }
251 }
Roman Zippel5a1aa8a2008-02-29 05:11:50 +0100252 /* set the type of the remaining choice values */
253 for (menu = parent->list; menu; menu = menu->next) {
254 current_entry = menu;
255 if (menu->sym && menu->sym->type == S_UNKNOWN)
256 menu_set_type(sym->type);
257 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 parentdep = expr_alloc_symbol(sym);
259 } else if (parent->prompt)
260 parentdep = parent->prompt->visible.expr;
261 else
262 parentdep = parent->dep;
263
264 for (menu = parent->list; menu; menu = menu->next) {
265 basedep = expr_transform(menu->dep);
Linus Torvaldse8b8c972007-10-19 21:25:45 -0700266 basedep = expr_alloc_and(expr_copy(parentdep), basedep);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267 basedep = expr_eliminate_dups(basedep);
268 menu->dep = basedep;
269 if (menu->sym)
270 prop = menu->sym->prop;
271 else
272 prop = menu->prompt;
273 for (; prop; prop = prop->next) {
274 if (prop->menu != menu)
275 continue;
276 dep = expr_transform(prop->visible.expr);
277 dep = expr_alloc_and(expr_copy(basedep), dep);
278 dep = expr_eliminate_dups(dep);
279 if (menu->sym && menu->sym->type != S_TRISTATE)
280 dep = expr_trans_bool(dep);
281 prop->visible.expr = dep;
282 if (prop->type == P_SELECT) {
283 struct symbol *es = prop_get_symbol(prop);
284 es->rev_dep.expr = expr_alloc_or(es->rev_dep.expr,
285 expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep)));
286 }
287 }
288 }
289 for (menu = parent->list; menu; menu = menu->next)
290 menu_finalize(menu);
291 } else if (sym) {
Catalin Marinas246cf9c2010-06-08 17:25:57 +0100292 /* ignore inherited dependencies for dir_dep */
293 sym->dir_dep.expr = expr_transform(expr_copy(parent->dir_dep));
294 sym->dir_dep.expr = expr_eliminate_dups(sym->dir_dep.expr);
295
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 basedep = parent->prompt ? parent->prompt->visible.expr : NULL;
297 basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no);
298 basedep = expr_eliminate_dups(expr_transform(basedep));
299 last_menu = NULL;
300 for (menu = parent->next; menu; menu = menu->next) {
301 dep = menu->prompt ? menu->prompt->visible.expr : menu->dep;
302 if (!expr_contains_symbol(dep, sym))
303 break;
304 if (expr_depends_symbol(dep, sym))
305 goto next;
306 dep = expr_trans_compare(dep, E_UNEQUAL, &symbol_no);
307 dep = expr_eliminate_dups(expr_transform(dep));
308 dep2 = expr_copy(basedep);
309 expr_eliminate_eq(&dep, &dep2);
310 expr_free(dep);
311 if (!expr_is_yes(dep2)) {
312 expr_free(dep2);
313 break;
314 }
315 expr_free(dep2);
316 next:
317 menu_finalize(menu);
318 menu->parent = parent;
319 last_menu = menu;
320 }
321 if (last_menu) {
322 parent->list = parent->next;
323 parent->next = last_menu->next;
324 last_menu->next = NULL;
325 }
326 }
327 for (menu = parent->list; menu; menu = menu->next) {
Roman Zippel5a1aa8a2008-02-29 05:11:50 +0100328 if (sym && sym_is_choice(sym) &&
329 menu->sym && !sym_is_choice_value(menu->sym)) {
330 current_entry = menu;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 menu->sym->flags |= SYMBOL_CHOICEVAL;
332 if (!menu->prompt)
333 menu_warn(menu, "choice value must have a prompt");
334 for (prop = menu->sym->prop; prop; prop = prop->next) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 if (prop->type == P_DEFAULT)
336 prop_warn(prop, "defaults for choice "
Roman Zippel5a1aa8a2008-02-29 05:11:50 +0100337 "values not supported");
338 if (prop->menu == menu)
339 continue;
340 if (prop->type == P_PROMPT &&
341 prop->menu->parent->sym != sym)
342 prop_warn(prop, "choice value used outside its choice group");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 }
Jan Beulichf5eaa322008-01-24 11:54:23 +0000344 /* Non-tristate choice values of tristate choices must
345 * depend on the choice being set to Y. The choice
346 * values' dependencies were propagated to their
347 * properties above, so the change here must be re-
Roman Zippel5a1aa8a2008-02-29 05:11:50 +0100348 * propagated.
349 */
Jan Beulichf5eaa322008-01-24 11:54:23 +0000350 if (sym->type == S_TRISTATE && menu->sym->type != S_TRISTATE) {
351 basedep = expr_alloc_comp(E_EQUAL, sym, &symbol_yes);
Roman Zippel5a1aa8a2008-02-29 05:11:50 +0100352 menu->dep = expr_alloc_and(basedep, menu->dep);
Jan Beulichf5eaa322008-01-24 11:54:23 +0000353 for (prop = menu->sym->prop; prop; prop = prop->next) {
354 if (prop->menu != menu)
355 continue;
Roman Zippel5a1aa8a2008-02-29 05:11:50 +0100356 prop->visible.expr = expr_alloc_and(expr_copy(basedep),
357 prop->visible.expr);
Jan Beulichf5eaa322008-01-24 11:54:23 +0000358 }
359 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 menu_add_symbol(P_CHOICE, sym, NULL);
361 prop = sym_get_choice_prop(sym);
362 for (ep = &prop->expr; *ep; ep = &(*ep)->left.expr)
363 ;
Roman Zippel7a962922008-01-14 04:50:23 +0100364 *ep = expr_alloc_one(E_LIST, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 (*ep)->right.sym = menu->sym;
366 }
367 if (menu->list && (!menu->prompt || !menu->prompt->text)) {
368 for (last_menu = menu->list; ; last_menu = last_menu->next) {
369 last_menu->parent = parent;
370 if (!last_menu->next)
371 break;
372 }
373 last_menu->next = menu->next;
374 menu->next = menu->list;
375 menu->list = NULL;
376 }
377 }
378
379 if (sym && !(sym->flags & SYMBOL_WARNED)) {
380 if (sym->type == S_UNKNOWN)
Roman Zippelf001f7f2006-06-08 22:12:48 -0700381 menu_warn(parent, "config symbol defined without type");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382
383 if (sym_is_choice(sym) && !parent->prompt)
Roman Zippelf001f7f2006-06-08 22:12:48 -0700384 menu_warn(parent, "choice must have a prompt");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385
386 /* Check properties connected to this symbol */
387 sym_check_prop(sym);
388 sym->flags |= SYMBOL_WARNED;
389 }
390
391 if (sym && !sym_is_optional(sym) && parent->prompt) {
392 sym->rev_dep.expr = expr_alloc_or(sym->rev_dep.expr,
393 expr_alloc_and(parent->prompt->visible.expr,
394 expr_alloc_symbol(&symbol_mod)));
395 }
396}
397
Li Zefan22c7eca2010-04-14 11:46:02 +0800398bool menu_has_prompt(struct menu *menu)
399{
400 if (!menu->prompt)
401 return false;
402 return true;
403}
404
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405bool menu_is_visible(struct menu *menu)
406{
407 struct menu *child;
408 struct symbol *sym;
409 tristate visible;
410
411 if (!menu->prompt)
412 return false;
Li Zefan22c7eca2010-04-14 11:46:02 +0800413
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414 sym = menu->sym;
415 if (sym) {
416 sym_calc_value(sym);
417 visible = menu->prompt->visible.tri;
418 } else
419 visible = menu->prompt->visible.tri = expr_calc_value(menu->prompt->visible.expr);
420
421 if (visible != no)
422 return true;
Li Zefan22c7eca2010-04-14 11:46:02 +0800423
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 if (!sym || sym_get_tristate_value(menu->sym) == no)
425 return false;
426
Li Zefan3fb9acb2010-05-07 13:57:07 +0800427 for (child = menu->list; child; child = child->next) {
428 if (menu_is_visible(child)) {
429 if (sym)
430 sym->flags |= SYMBOL_DEF_USER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 return true;
Li Zefan3fb9acb2010-05-07 13:57:07 +0800432 }
433 }
Li Zefan22c7eca2010-04-14 11:46:02 +0800434
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 return false;
436}
437
438const char *menu_get_prompt(struct menu *menu)
439{
440 if (menu->prompt)
EGRY Gabor01771b02008-01-11 23:53:43 +0100441 return menu->prompt->text;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 else if (menu->sym)
EGRY Gabor01771b02008-01-11 23:53:43 +0100443 return menu->sym->name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 return NULL;
445}
446
447struct menu *menu_get_root_menu(struct menu *menu)
448{
449 return &rootmenu;
450}
451
452struct menu *menu_get_parent_menu(struct menu *menu)
453{
454 enum prop_type type;
455
456 for (; menu != &rootmenu; menu = menu->parent) {
457 type = menu->prompt ? menu->prompt->type : 0;
458 if (type == P_MENU)
459 break;
460 }
461 return menu;
462}
463
Sam Ravnborg03d29122007-07-21 00:00:36 +0200464bool menu_has_help(struct menu *menu)
465{
466 return menu->help != NULL;
467}
468
469const char *menu_get_help(struct menu *menu)
470{
471 if (menu->help)
472 return menu->help;
473 else
474 return "";
475}
Cheng Renquan6bd59992009-07-12 16:11:44 +0800476
477static void get_prompt_str(struct gstr *r, struct property *prop)
478{
479 int i, j;
480 struct menu *submenu[8], *menu;
481
482 str_printf(r, _("Prompt: %s\n"), _(prop->text));
483 str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name,
484 prop->menu->lineno);
485 if (!expr_is_yes(prop->visible.expr)) {
486 str_append(r, _(" Depends on: "));
487 expr_gstr_print(prop->visible.expr, r);
488 str_append(r, "\n");
489 }
490 menu = prop->menu->parent;
491 for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent)
492 submenu[i++] = menu;
493 if (i > 0) {
494 str_printf(r, _(" Location:\n"));
495 for (j = 4; --i >= 0; j += 2) {
496 menu = submenu[i];
497 str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu)));
498 if (menu->sym) {
499 str_printf(r, " (%s [=%s])", menu->sym->name ?
500 menu->sym->name : _("<choice>"),
501 sym_get_string_value(menu->sym));
502 }
503 str_append(r, "\n");
504 }
505 }
506}
507
508void get_symbol_str(struct gstr *r, struct symbol *sym)
509{
510 bool hit;
511 struct property *prop;
512
Li Zefanb040b442010-05-07 13:56:33 +0800513 if (sym && sym->name) {
Cheng Renquan6bd59992009-07-12 16:11:44 +0800514 str_printf(r, "Symbol: %s [=%s]\n", sym->name,
515 sym_get_string_value(sym));
Li Zefanb040b442010-05-07 13:56:33 +0800516 str_printf(r, "Type : %s\n", sym_type_name(sym->type));
Li Zefan70ed0742010-05-07 13:56:50 +0800517 if (sym->type == S_INT || sym->type == S_HEX) {
518 prop = sym_get_range_prop(sym);
519 if (prop) {
520 str_printf(r, "Range : ");
521 expr_gstr_print(prop->expr, r);
522 str_append(r, "\n");
523 }
524 }
Li Zefanb040b442010-05-07 13:56:33 +0800525 }
Cheng Renquan6bd59992009-07-12 16:11:44 +0800526 for_all_prompts(sym, prop)
527 get_prompt_str(r, prop);
528 hit = false;
529 for_all_properties(sym, prop, P_SELECT) {
530 if (!hit) {
531 str_append(r, " Selects: ");
532 hit = true;
533 } else
534 str_printf(r, " && ");
535 expr_gstr_print(prop->expr, r);
536 }
537 if (hit)
538 str_append(r, "\n");
539 if (sym->rev_dep.expr) {
540 str_append(r, _(" Selected by: "));
541 expr_gstr_print(sym->rev_dep.expr, r);
542 str_append(r, "\n");
543 }
544 str_append(r, "\n\n");
545}
546
nir.tzachar@gmail.com692d97c2009-11-25 12:28:43 +0200547struct gstr get_relations_str(struct symbol **sym_arr)
548{
549 struct symbol *sym;
550 struct gstr res = str_new();
551 int i;
552
553 for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
554 get_symbol_str(&res, sym);
555 if (!i)
556 str_append(&res, _("No matches found.\n"));
557 return res;
558}
559
560
Cheng Renquan6bd59992009-07-12 16:11:44 +0800561void menu_get_ext_help(struct menu *menu, struct gstr *help)
562{
563 struct symbol *sym = menu->sym;
564
565 if (menu_has_help(menu)) {
566 if (sym->name) {
567 str_printf(help, "CONFIG_%s:\n\n", sym->name);
568 str_append(help, _(menu_get_help(menu)));
569 str_append(help, "\n");
570 }
571 } else {
572 str_append(help, nohelp_text);
573 }
Cheng Renquan47791052009-07-12 16:11:46 +0800574 if (sym)
575 get_symbol_str(help, sym);
Cheng Renquan6bd59992009-07-12 16:11:44 +0800576}