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