1
0

menu.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. /*
  2. * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
  3. * Released under the terms of the GNU GPL v2.0.
  4. */
  5. #include <ctype.h>
  6. #include <stdarg.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include "lkc.h"
  10. static const char nohelp_text[] = "There is no help available for this option.";
  11. struct menu rootmenu;
  12. static struct menu **last_entry_ptr;
  13. struct file *file_list;
  14. struct file *current_file;
  15. void menu_warn(struct menu *menu, const char *fmt, ...)
  16. {
  17. va_list ap;
  18. va_start(ap, fmt);
  19. fprintf(stderr, "%s:%d:warning: ", menu->file->name, menu->lineno);
  20. vfprintf(stderr, fmt, ap);
  21. fprintf(stderr, "\n");
  22. va_end(ap);
  23. }
  24. static void prop_warn(struct property *prop, const char *fmt, ...)
  25. {
  26. va_list ap;
  27. va_start(ap, fmt);
  28. fprintf(stderr, "%s:%d:warning: ", prop->file->name, prop->lineno);
  29. vfprintf(stderr, fmt, ap);
  30. fprintf(stderr, "\n");
  31. va_end(ap);
  32. }
  33. void _menu_init(void)
  34. {
  35. current_entry = current_menu = &rootmenu;
  36. last_entry_ptr = &rootmenu.list;
  37. }
  38. void menu_add_entry(struct symbol *sym)
  39. {
  40. struct menu *menu;
  41. menu = xmalloc(sizeof(*menu));
  42. memset(menu, 0, sizeof(*menu));
  43. menu->sym = sym;
  44. menu->parent = current_menu;
  45. menu->file = current_file;
  46. menu->lineno = zconf_lineno();
  47. *last_entry_ptr = menu;
  48. last_entry_ptr = &menu->next;
  49. current_entry = menu;
  50. if (sym)
  51. menu_add_symbol(P_SYMBOL, sym, NULL);
  52. }
  53. void menu_end_entry(void)
  54. {
  55. }
  56. struct menu *menu_add_menu(void)
  57. {
  58. menu_end_entry();
  59. last_entry_ptr = &current_entry->list;
  60. return current_menu = current_entry;
  61. }
  62. void menu_end_menu(void)
  63. {
  64. last_entry_ptr = &current_menu->next;
  65. current_menu = current_menu->parent;
  66. }
  67. static struct expr *menu_check_dep(struct expr *e)
  68. {
  69. if (!e)
  70. return e;
  71. switch (e->type) {
  72. case E_NOT:
  73. e->left.expr = menu_check_dep(e->left.expr);
  74. break;
  75. case E_OR:
  76. case E_AND:
  77. e->left.expr = menu_check_dep(e->left.expr);
  78. e->right.expr = menu_check_dep(e->right.expr);
  79. break;
  80. case E_SYMBOL:
  81. /* change 'm' into 'm' && MODULES */
  82. if (e->left.sym == &symbol_mod)
  83. return expr_alloc_and(e, expr_alloc_symbol(modules_sym));
  84. break;
  85. default:
  86. break;
  87. }
  88. return e;
  89. }
  90. void menu_add_dep(struct expr *dep)
  91. {
  92. current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep));
  93. }
  94. void menu_set_type(int type)
  95. {
  96. struct symbol *sym = current_entry->sym;
  97. if (sym->type == type)
  98. return;
  99. if (sym->type == S_UNKNOWN) {
  100. sym->type = type;
  101. return;
  102. }
  103. menu_warn(current_entry,
  104. "ignoring type redefinition of '%s' from '%s' to '%s'",
  105. sym->name ? sym->name : "<choice>",
  106. sym_type_name(sym->type), sym_type_name(type));
  107. }
  108. struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr *expr, struct expr *dep)
  109. {
  110. struct property *prop = prop_alloc(type, current_entry->sym);
  111. prop->menu = current_entry;
  112. prop->expr = expr;
  113. prop->visible.expr = menu_check_dep(dep);
  114. if (prompt) {
  115. if (isspace(*prompt)) {
  116. prop_warn(prop, "leading whitespace ignored");
  117. while (isspace(*prompt))
  118. prompt++;
  119. }
  120. if (current_entry->prompt && current_entry != &rootmenu)
  121. prop_warn(prop, "prompt redefined");
  122. /* Apply all upper menus' visibilities to actual prompts. */
  123. if(type == P_PROMPT) {
  124. struct menu *menu = current_entry;
  125. while ((menu = menu->parent) != NULL) {
  126. struct expr *dup_expr;
  127. if (!menu->visibility)
  128. continue;
  129. /*
  130. * Do not add a reference to the
  131. * menu's visibility expression but
  132. * use a copy of it. Otherwise the
  133. * expression reduction functions
  134. * will modify expressions that have
  135. * multiple references which can
  136. * cause unwanted side effects.
  137. */
  138. dup_expr = expr_copy(menu->visibility);
  139. prop->visible.expr
  140. = expr_alloc_and(prop->visible.expr,
  141. dup_expr);
  142. }
  143. }
  144. current_entry->prompt = prop;
  145. }
  146. prop->text = prompt;
  147. return prop;
  148. }
  149. struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep)
  150. {
  151. return menu_add_prop(type, prompt, NULL, dep);
  152. }
  153. void menu_add_visibility(struct expr *expr)
  154. {
  155. current_entry->visibility = expr_alloc_and(current_entry->visibility,
  156. expr);
  157. }
  158. void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep)
  159. {
  160. menu_add_prop(type, NULL, expr, dep);
  161. }
  162. void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep)
  163. {
  164. menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep);
  165. }
  166. void menu_add_select(struct symbol *sym, struct expr *value, struct expr *dep)
  167. {
  168. struct property *p;
  169. p = menu_add_prop(P_SELECT, NULL, expr_alloc_symbol(sym), dep);
  170. p->value = value;
  171. }
  172. void menu_add_option(int token, char *arg)
  173. {
  174. switch (token) {
  175. case T_OPT_MODULES:
  176. if (modules_sym)
  177. zconf_error("symbol '%s' redefines option 'modules'"
  178. " already defined by symbol '%s'",
  179. current_entry->sym->name,
  180. modules_sym->name
  181. );
  182. modules_sym = current_entry->sym;
  183. break;
  184. case T_OPT_DEFCONFIG_LIST:
  185. if (!sym_defconfig_list)
  186. sym_defconfig_list = current_entry->sym;
  187. else if (sym_defconfig_list != current_entry->sym)
  188. zconf_error("trying to redefine defconfig symbol");
  189. break;
  190. case T_OPT_ENV:
  191. prop_add_env(arg);
  192. break;
  193. case T_OPT_ALLNOCONFIG_Y:
  194. current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y;
  195. break;
  196. }
  197. }
  198. static int menu_validate_number(struct symbol *sym, struct symbol *sym2)
  199. {
  200. return sym2->type == S_INT || sym2->type == S_HEX ||
  201. (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name));
  202. }
  203. static void sym_check_prop(struct symbol *sym)
  204. {
  205. struct property *prop;
  206. struct symbol *sym2;
  207. for (prop = sym->prop; prop; prop = prop->next) {
  208. switch (prop->type) {
  209. case P_DEFAULT:
  210. if ((sym->type == S_STRING || sym->type == S_INT || sym->type == S_HEX) &&
  211. prop->expr->type != E_SYMBOL)
  212. prop_warn(prop,
  213. "default for config symbol '%s'"
  214. " must be a single symbol", sym->name);
  215. if (prop->expr->type != E_SYMBOL)
  216. break;
  217. sym2 = prop_get_symbol(prop);
  218. if (sym->type == S_HEX || sym->type == S_INT) {
  219. if (!menu_validate_number(sym, sym2))
  220. prop_warn(prop,
  221. "'%s': number is invalid",
  222. sym->name);
  223. }
  224. break;
  225. case P_SELECT:
  226. sym2 = prop_get_symbol(prop);
  227. if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE)
  228. prop_warn(prop,
  229. "config symbol '%s' uses select, but is "
  230. "not boolean or tristate", sym->name);
  231. else if (prop->value == NULL &&
  232. sym2->type != S_UNKNOWN &&
  233. sym2->type != S_BOOLEAN &&
  234. sym2->type != S_TRISTATE)
  235. prop_warn(prop,
  236. "'%s' has wrong type. 'select' without a "
  237. "value only accepts arguments of boolean "
  238. "and tristate type", sym2->name);
  239. else if (prop->value != NULL &&
  240. (sym2->type == S_INT ||
  241. sym2->type == S_HEX ||
  242. sym2->type == S_STRING) &&
  243. prop->value->type != E_SYMBOL)
  244. prop_warn(prop,
  245. "select value for config symbol '%s'"
  246. " must be a single symbol", sym2->name);
  247. break;
  248. case P_RANGE:
  249. if (sym->type != S_INT && sym->type != S_HEX)
  250. prop_warn(prop, "range is only allowed "
  251. "for int or hex symbols");
  252. if (!menu_validate_number(sym, prop->expr->left.sym) ||
  253. !menu_validate_number(sym, prop->expr->right.sym))
  254. prop_warn(prop, "range is invalid");
  255. break;
  256. default:
  257. ;
  258. }
  259. }
  260. }
  261. static void finalize_select(struct symbol *sym, struct property *prop,
  262. struct expr *dep)
  263. {
  264. struct symbol *es = prop_get_symbol(prop);
  265. struct expr_select_value *esv;
  266. if (prop->value) {
  267. esv = malloc(sizeof *esv);
  268. esv->expr = expr_alloc_and(expr_alloc_symbol(sym),
  269. expr_copy(dep));
  270. esv->value = prop->value;
  271. esv->next = es->val_dep;
  272. es->val_dep = esv;
  273. } else {
  274. es->rev_dep.expr = expr_alloc_or(es->rev_dep.expr,
  275. expr_alloc_and(expr_alloc_symbol(sym), expr_copy(dep)));
  276. }
  277. }
  278. void menu_finalize(struct menu *parent)
  279. {
  280. struct menu *menu, *last_menu;
  281. struct symbol *sym;
  282. struct property *prop;
  283. struct expr *parentdep, *basedep, *dep, *dep2, **ep;
  284. sym = parent->sym;
  285. if (parent->list) {
  286. if (sym && sym_is_choice(sym)) {
  287. if (sym->type == S_UNKNOWN) {
  288. /* find the first choice value to find out choice type */
  289. current_entry = parent;
  290. for (menu = parent->list; menu; menu = menu->next) {
  291. if (menu->sym && menu->sym->type != S_UNKNOWN) {
  292. menu_set_type(menu->sym->type);
  293. break;
  294. }
  295. }
  296. }
  297. /* set the type of the remaining choice values */
  298. for (menu = parent->list; menu; menu = menu->next) {
  299. current_entry = menu;
  300. if (menu->sym && menu->sym->type == S_UNKNOWN)
  301. menu_set_type(sym->type);
  302. }
  303. parentdep = expr_alloc_symbol(sym);
  304. } else if (parent->prompt)
  305. parentdep = parent->prompt->visible.expr;
  306. else
  307. parentdep = parent->dep;
  308. for (menu = parent->list; menu; menu = menu->next) {
  309. basedep = expr_transform(menu->dep);
  310. basedep = expr_alloc_and(expr_copy(parentdep), basedep);
  311. basedep = expr_eliminate_dups(basedep);
  312. menu->dep = basedep;
  313. if (menu->sym)
  314. prop = menu->sym->prop;
  315. else
  316. prop = menu->prompt;
  317. for (; prop; prop = prop->next) {
  318. if (prop->menu != menu)
  319. continue;
  320. dep = expr_transform(prop->visible.expr);
  321. dep = expr_alloc_and(expr_copy(basedep), dep);
  322. dep = expr_eliminate_dups(dep);
  323. if (menu->sym && menu->sym->type != S_TRISTATE)
  324. dep = expr_trans_bool(dep);
  325. prop->visible.expr = dep;
  326. if (prop->type == P_SELECT)
  327. finalize_select(menu->sym, prop, dep);
  328. }
  329. }
  330. for (menu = parent->list; menu; menu = menu->next)
  331. menu_finalize(menu);
  332. } else if (sym) {
  333. basedep = parent->prompt ? parent->prompt->visible.expr : NULL;
  334. basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no);
  335. basedep = expr_eliminate_dups(expr_transform(basedep));
  336. last_menu = NULL;
  337. for (menu = parent->next; menu; menu = menu->next) {
  338. dep = menu->prompt ? menu->prompt->visible.expr : menu->dep;
  339. if (!expr_contains_symbol(dep, sym))
  340. break;
  341. if (expr_depends_symbol(dep, sym))
  342. goto next;
  343. dep = expr_trans_compare(dep, E_UNEQUAL, &symbol_no);
  344. dep = expr_eliminate_dups(expr_transform(dep));
  345. dep2 = expr_copy(basedep);
  346. expr_eliminate_eq(&dep, &dep2);
  347. expr_free(dep);
  348. if (!expr_is_yes(dep2)) {
  349. expr_free(dep2);
  350. break;
  351. }
  352. expr_free(dep2);
  353. next:
  354. menu_finalize(menu);
  355. menu->parent = parent;
  356. last_menu = menu;
  357. }
  358. if (last_menu) {
  359. parent->list = parent->next;
  360. parent->next = last_menu->next;
  361. last_menu->next = NULL;
  362. }
  363. sym->dir_dep.expr = expr_alloc_or(sym->dir_dep.expr, parent->dep);
  364. }
  365. for (menu = parent->list; menu; menu = menu->next) {
  366. if (sym && sym_is_choice(sym) &&
  367. menu->sym && !sym_is_choice_value(menu->sym)) {
  368. current_entry = menu;
  369. menu->sym->flags |= SYMBOL_CHOICEVAL;
  370. if (!menu->prompt)
  371. menu_warn(menu, "choice value must have a prompt");
  372. for (prop = menu->sym->prop; prop; prop = prop->next) {
  373. if (prop->type == P_DEFAULT)
  374. prop_warn(prop, "defaults for choice "
  375. "values not supported");
  376. if (prop->menu == menu)
  377. continue;
  378. if (prop->type == P_PROMPT &&
  379. prop->menu->parent->sym != sym)
  380. prop_warn(prop, "choice value used outside its choice group");
  381. }
  382. /* Non-tristate choice values of tristate choices must
  383. * depend on the choice being set to Y. The choice
  384. * values' dependencies were propagated to their
  385. * properties above, so the change here must be re-
  386. * propagated.
  387. */
  388. if (sym->type == S_TRISTATE && menu->sym->type != S_TRISTATE) {
  389. basedep = expr_alloc_comp(E_EQUAL, sym, &symbol_yes);
  390. menu->dep = expr_alloc_and(basedep, menu->dep);
  391. for (prop = menu->sym->prop; prop; prop = prop->next) {
  392. if (prop->menu != menu)
  393. continue;
  394. prop->visible.expr = expr_alloc_and(expr_copy(basedep),
  395. prop->visible.expr);
  396. }
  397. }
  398. menu_add_symbol(P_CHOICE, sym, NULL);
  399. prop = sym_get_choice_prop(sym);
  400. for (ep = &prop->expr; *ep; ep = &(*ep)->left.expr)
  401. ;
  402. *ep = expr_alloc_one(E_LIST, NULL);
  403. (*ep)->right.sym = menu->sym;
  404. }
  405. if (menu->list && (!menu->prompt || !menu->prompt->text)) {
  406. for (last_menu = menu->list; ; last_menu = last_menu->next) {
  407. last_menu->parent = parent;
  408. if (!last_menu->next)
  409. break;
  410. }
  411. last_menu->next = menu->next;
  412. menu->next = menu->list;
  413. menu->list = NULL;
  414. }
  415. }
  416. if (sym && !(sym->flags & SYMBOL_WARNED)) {
  417. if (sym->type == S_UNKNOWN)
  418. menu_warn(parent, "config symbol defined without type");
  419. if (sym_is_choice(sym) && !parent->prompt)
  420. menu_warn(parent, "choice must have a prompt");
  421. /* Check properties connected to this symbol */
  422. sym_check_prop(sym);
  423. sym->flags |= SYMBOL_WARNED;
  424. }
  425. if (sym && !sym_is_optional(sym) && parent->prompt) {
  426. struct expr_select_value *esv;
  427. sym->rev_dep.expr = expr_alloc_or(sym->rev_dep.expr,
  428. expr_alloc_and(parent->prompt->visible.expr,
  429. expr_alloc_symbol(&symbol_mod)));
  430. for (esv = sym->val_dep; esv; esv = esv->next)
  431. esv->expr = expr_alloc_or(esv->expr,
  432. expr_alloc_and(parent->prompt->visible.expr,
  433. expr_alloc_symbol(&symbol_mod)));
  434. }
  435. }
  436. bool menu_has_prompt(struct menu *menu)
  437. {
  438. if (!menu->prompt)
  439. return false;
  440. return true;
  441. }
  442. /*
  443. * Determine if a menu is empty.
  444. * A menu is considered empty if it contains no or only
  445. * invisible entries.
  446. */
  447. bool menu_is_empty(struct menu *menu)
  448. {
  449. struct menu *child;
  450. for (child = menu->list; child; child = child->next) {
  451. if (menu_is_visible(child))
  452. return(false);
  453. }
  454. return(true);
  455. }
  456. bool menu_is_visible(struct menu *menu)
  457. {
  458. struct menu *child;
  459. struct symbol *sym;
  460. tristate visible;
  461. if (!menu->prompt)
  462. return false;
  463. if (menu->visibility) {
  464. if (expr_calc_value(menu->visibility) == no)
  465. return no;
  466. }
  467. sym = menu->sym;
  468. if (sym) {
  469. sym_calc_value(sym);
  470. visible = menu->prompt->visible.tri;
  471. } else
  472. visible = menu->prompt->visible.tri = expr_calc_value(menu->prompt->visible.expr);
  473. if (visible != no)
  474. return true;
  475. if (!sym || sym_get_tristate_value(menu->sym) == no)
  476. return false;
  477. for (child = menu->list; child; child = child->next) {
  478. if (menu_is_visible(child)) {
  479. if (sym)
  480. sym->flags |= SYMBOL_DEF_USER;
  481. return true;
  482. }
  483. }
  484. return false;
  485. }
  486. const char *menu_get_prompt(struct menu *menu)
  487. {
  488. if (menu->prompt)
  489. return menu->prompt->text;
  490. else if (menu->sym)
  491. return menu->sym->name;
  492. return NULL;
  493. }
  494. struct menu *menu_get_root_menu(struct menu *menu)
  495. {
  496. return &rootmenu;
  497. }
  498. struct menu *menu_get_parent_menu(struct menu *menu)
  499. {
  500. enum prop_type type;
  501. for (; menu != &rootmenu; menu = menu->parent) {
  502. type = menu->prompt ? menu->prompt->type : 0;
  503. if (type == P_MENU)
  504. break;
  505. }
  506. return menu;
  507. }
  508. bool menu_has_help(struct menu *menu)
  509. {
  510. return menu->help != NULL;
  511. }
  512. const char *menu_get_help(struct menu *menu)
  513. {
  514. if (menu->help)
  515. return menu->help;
  516. else
  517. return "";
  518. }
  519. static void get_prompt_str(struct gstr *r, struct property *prop,
  520. struct list_head *head)
  521. {
  522. int i, j;
  523. struct menu *submenu[8], *menu, *location = NULL;
  524. struct jump_key *jump;
  525. str_printf(r, _("Prompt: %s\n"), _(prop->text));
  526. menu = prop->menu->parent;
  527. for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
  528. bool accessible = menu_is_visible(menu);
  529. submenu[i++] = menu;
  530. if (location == NULL && accessible)
  531. location = menu;
  532. }
  533. if (head && location) {
  534. jump = xmalloc(sizeof(struct jump_key));
  535. if (menu_is_visible(prop->menu)) {
  536. /*
  537. * There is not enough room to put the hint at the
  538. * beginning of the "Prompt" line. Put the hint on the
  539. * last "Location" line even when it would belong on
  540. * the former.
  541. */
  542. jump->target = prop->menu;
  543. } else
  544. jump->target = location;
  545. if (list_empty(head))
  546. jump->index = 0;
  547. else
  548. jump->index = list_entry(head->prev, struct jump_key,
  549. entries)->index + 1;
  550. list_add_tail(&jump->entries, head);
  551. }
  552. if (i > 0) {
  553. str_printf(r, _(" Location:\n"));
  554. for (j = 4; --i >= 0; j += 2) {
  555. menu = submenu[i];
  556. if (head && location && menu == location)
  557. jump->offset = strlen(r->s);
  558. str_printf(r, "%*c-> %s", j, ' ',
  559. _(menu_get_prompt(menu)));
  560. if (menu->sym) {
  561. str_printf(r, " (%s [=%s])", menu->sym->name ?
  562. menu->sym->name : _("<choice>"),
  563. sym_get_string_value(menu->sym));
  564. }
  565. str_append(r, "\n");
  566. }
  567. }
  568. }
  569. /*
  570. * get property of type P_SYMBOL
  571. */
  572. static struct property *get_symbol_prop(struct symbol *sym)
  573. {
  574. struct property *prop = NULL;
  575. for_all_properties(sym, prop, P_SYMBOL)
  576. break;
  577. return prop;
  578. }
  579. /*
  580. * head is optional and may be NULL
  581. */
  582. void get_symbol_str(struct gstr *r, struct symbol *sym,
  583. struct list_head *head)
  584. {
  585. bool hit;
  586. struct property *prop;
  587. struct expr_select_value *esv;
  588. if (sym && sym->name) {
  589. str_printf(r, "Symbol: %s [=%s]\n", sym->name,
  590. sym_get_string_value(sym));
  591. str_printf(r, "Type : %s\n", sym_type_name(sym->type));
  592. if (sym->type == S_INT || sym->type == S_HEX) {
  593. prop = sym_get_range_prop(sym);
  594. if (prop) {
  595. str_printf(r, "Range : ");
  596. expr_gstr_print(prop->expr, r);
  597. str_append(r, "\n");
  598. }
  599. }
  600. }
  601. for_all_prompts(sym, prop)
  602. get_prompt_str(r, prop, head);
  603. prop = get_symbol_prop(sym);
  604. if (prop) {
  605. str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name,
  606. prop->menu->lineno);
  607. if (!expr_is_yes(prop->visible.expr)) {
  608. str_append(r, _(" Depends on: "));
  609. expr_gstr_print(prop->visible.expr, r);
  610. str_append(r, "\n");
  611. }
  612. }
  613. hit = false;
  614. for_all_properties(sym, prop, P_SELECT) {
  615. if (!hit) {
  616. str_append(r, " Selects: ");
  617. hit = true;
  618. } else
  619. str_printf(r, " && ");
  620. expr_gstr_print(prop->expr, r);
  621. if (prop->value) {
  622. str_printf(r, " (value=");
  623. expr_gstr_print(prop->value, r);
  624. str_printf(r, ")");
  625. }
  626. }
  627. if (hit)
  628. str_append(r, "\n");
  629. if (sym->rev_dep.expr) {
  630. str_append(r, _(" Selected by: "));
  631. expr_gstr_print(sym->rev_dep.expr, r);
  632. str_append(r, "\n");
  633. }
  634. for (esv = sym->val_dep; esv; esv = esv->next) {
  635. str_append(r, " Selected by: ");
  636. expr_gstr_print(esv->expr, r);
  637. str_append(r, " with value: ");
  638. expr_gstr_print(esv->value, r);
  639. str_append(r, "\n");
  640. }
  641. str_append(r, "\n\n");
  642. }
  643. struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head)
  644. {
  645. struct symbol *sym;
  646. struct gstr res = str_new();
  647. int i;
  648. for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
  649. get_symbol_str(&res, sym, head);
  650. if (!i)
  651. str_append(&res, _("No matches found.\n"));
  652. return res;
  653. }
  654. void menu_get_ext_help(struct menu *menu, struct gstr *help)
  655. {
  656. struct symbol *sym = menu->sym;
  657. const char *help_text = nohelp_text;
  658. if (menu_has_help(menu)) {
  659. if (sym->name)
  660. str_printf(help, "%s%s:\n\n", CONFIG_, sym->name);
  661. help_text = menu_get_help(menu);
  662. }
  663. str_printf(help, "%s\n", _(help_text));
  664. if (sym)
  665. get_symbol_str(help, sym, NULL);
  666. }