This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 14/24] Handle ambiguity in tui_partial_win_by_name
- From: Tom Tromey <tom at tromey dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tom at tromey dot com>
- Date: Sat, 4 Jan 2020 11:34:00 -0700
- Subject: [PATCH 14/24] Handle ambiguity in tui_partial_win_by_name
- References: <20200104183410.17114-1-tom@tromey.com>
This changes tui_partial_win_by_name to correctly handle an ambiguous
name prefix. This will be important once the user can register new
window types.
2020-01-04 Tom Tromey <tom@tromey.com>
* tui/tui-win.c (tui_partial_win_by_name): Handle ambiguity
correctly.
Change-Id: I59aaacd697eeab649164183457ef722dae58d60d
---
gdb/ChangeLog | 5 +++++
gdb/tui/tui-win.c | 13 +++++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 8206f3e6965..6eab125d731 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -694,18 +694,27 @@ tui_scroll_right_command (const char *arg, int from_tty)
static struct tui_win_info *
tui_partial_win_by_name (gdb::string_view name)
{
+ struct tui_win_info *best = nullptr;
+
if (name != NULL)
{
for (tui_win_info *item : all_tui_windows ())
{
const char *cur_name = item->name ();
- if (startswith (cur_name, name))
+ if (name == cur_name)
return item;
+ if (startswith (cur_name, name))
+ {
+ if (best != nullptr)
+ error (_("Window name \"%*s\" is ambiguous"),
+ (int) name.size (), name.data ());
+ best = item;
+ }
}
}
- return NULL;
+ return best;
}
/* Set focus to the window named by 'arg'. */
--
2.17.2