[01/11] Use complete_on_enum in tui_reggroup_completer

Message ID 20200618021523.10681-2-tom@tromey.com
State New
Headers show
Series
  • TUI cleanups
Related show

Commit Message

Tom Tromey June 18, 2020, 2:15 a.m.
tui_reggroup_completer has an "XXXX" comment suggesting the use of
complete_on_enum.  This patch implements this suggestion.

2020-06-14  Tom Tromey  <tom@tromey.com>

	* tui/tui-regs.c (tui_reggroup_completer): Use complete_on_enum.
---
 gdb/ChangeLog      |  4 ++++
 gdb/tui/tui-regs.c | 11 ++---------
 2 files changed, 6 insertions(+), 9 deletions(-)

-- 
2.17.2

Patch

diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index d33f0aadef8..b99e29972de 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -631,18 +631,11 @@  tui_reggroup_completer (struct cmd_list_element *ignore,
 			completion_tracker &tracker,
 			const char *text, const char *word)
 {
-  static const char *extra[] = { "next", "prev", NULL };
-  size_t len = strlen (word);
-  const char **tmp;
+  static const char * const extra[] = { "next", "prev", NULL };
 
   reggroup_completer (ignore, tracker, text, word);
 
-  /* XXXX use complete_on_enum instead?  */
-  for (tmp = extra; *tmp != NULL; ++tmp)
-    {
-      if (strncmp (word, *tmp, len) == 0)
-	tracker.add_completion (make_unique_xstrdup (*tmp));
-    }
+  complete_on_enum (tracker, extra, text, word);
 }
 
 void _initialize_tui_regs ();