| 694 | } |
| 695 | |
| 696 | static void get_prompt_str(struct gstr *r, struct property *prop, |
| 697 | struct list_head *head) |
| 698 | { |
| 699 | int i, j; |
| 700 | struct menu *submenu[8], *menu, *location = NULL; |
| 701 | struct jump_key *jump = NULL; |
| 702 | |
| 703 | str_printf(r, " Prompt: %s\n", prop->text); |
| 704 | |
| 705 | get_dep_str(r, prop->menu->dep, " Depends on: "); |
| 706 | /* |
| 707 | * Most prompts in Linux have visibility that exactly matches their |
| 708 | * dependencies. For these, we print only the dependencies to improve |
| 709 | * readability. However, prompts with inline "if" expressions and |
| 710 | * prompts with a parent that has a "visible if" expression have |
| 711 | * differing dependencies and visibility. In these rare cases, we |
| 712 | * print both. |
| 713 | */ |
| 714 | if (!expr_eq(prop->menu->dep, prop->visible.expr)) |
| 715 | get_dep_str(r, prop->visible.expr, " Visible if: "); |
| 716 | |
| 717 | menu = prop->menu; |
| 718 | for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) { |
| 719 | submenu[i++] = menu; |
| 720 | if (location == NULL && menu_is_visible(menu)) |
| 721 | location = menu; |
| 722 | } |
| 723 | if (head && location) { |
| 724 | jump = xmalloc(sizeof(struct jump_key)); |
| 725 | jump->target = location; |
| 726 | list_add_tail(&jump->entries, head); |
| 727 | } |
| 728 | |
| 729 | str_printf(r, " Location:\n"); |
| 730 | for (j = 0; --i >= 0; j++) { |
| 731 | int jk = -1; |
| 732 | int indent = 2 * j + 4; |
| 733 | |
| 734 | menu = submenu[i]; |
| 735 | if (jump && menu == location) { |
| 736 | jump->offset = strlen(r->s); |
| 737 | jk = get_jump_key_char(); |
| 738 | } |
| 739 | |
| 740 | if (jk >= 0) { |
| 741 | str_printf(r, "(%c)", jk); |
| 742 | indent -= 3; |
| 743 | } |
| 744 | |
| 745 | str_printf(r, "%*c-> %s", indent, ' ', menu_get_prompt(menu)); |
| 746 | if (menu->sym) { |
| 747 | str_printf(r, " (%s [=%s])", menu->sym->name ? |
| 748 | menu->sym->name : "<choice>", |
| 749 | sym_get_string_value(menu->sym)); |
| 750 | } |
| 751 | str_append(r, "\n"); |
| 752 | } |
| 753 | } |
no test coverage detected