aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2010-04-26 18:37:14 +0000
committerTom Tromey <tromey@redhat.com>2010-04-26 18:37:14 +0000
commit3f172e2492c90613517c90f46a1161d44e2745ca (patch)
tree32ab2d6df9bb2a911b796965486a780a6e8f8d83 /gdb/cli
parent9757332fd2256ecc8b023181fcd0807e2a159ad6 (diff)
downloadgdb-3f172e2492c90613517c90f46a1161d44e2745ca.zip
gdb-3f172e2492c90613517c90f46a1161d44e2745ca.tar.gz
gdb-3f172e2492c90613517c90f46a1161d44e2745ca.tar.bz2
gdb
* cli/cli-decode.c (complete_on_cmdlist): Make two passes over the command list. gdb/testsuite * gdb.base/completion.exp: Add tests for completion and deprecated commands.
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-decode.c80
1 files changed, 51 insertions, 29 deletions
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index de261fa..1655e0a 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1597,43 +1597,65 @@ complete_on_cmdlist (struct cmd_list_element *list, char *text, char *word)
int sizeof_matchlist;
int matches;
int textlen = strlen (text);
+ int pass;
+ int saw_deprecated_match = 0;
sizeof_matchlist = 10;
matchlist = (char **) xmalloc (sizeof_matchlist * sizeof (char *));
matches = 0;
- for (ptr = list; ptr; ptr = ptr->next)
- if (!strncmp (ptr->name, text, textlen)
- && !ptr->abbrev_flag
- && (ptr->func
- || ptr->prefixlist))
- {
- if (matches == sizeof_matchlist)
+ /* We do one or two passes. In the first pass, we skip deprecated
+ commands. If we see no matching commands in the first pass, and
+ if we did happen to see a matching deprecated command, we do
+ another loop to collect those. */
+ for (pass = 0; matches == 0 && pass < 2; ++pass)
+ {
+ for (ptr = list; ptr; ptr = ptr->next)
+ if (!strncmp (ptr->name, text, textlen)
+ && !ptr->abbrev_flag
+ && (ptr->func
+ || ptr->prefixlist))
{
- sizeof_matchlist *= 2;
- matchlist = (char **) xrealloc ((char *) matchlist,
- (sizeof_matchlist
- * sizeof (char *)));
- }
+ if (pass == 0)
+ {
+ if ((ptr->flags & CMD_DEPRECATED) != 0)
+ {
+ saw_deprecated_match = 1;
+ continue;
+ }
+ }
- matchlist[matches] = (char *)
- xmalloc (strlen (word) + strlen (ptr->name) + 1);
- if (word == text)
- strcpy (matchlist[matches], ptr->name);
- else if (word > text)
- {
- /* Return some portion of ptr->name. */
- strcpy (matchlist[matches], ptr->name + (word - text));
- }
- else
- {
- /* Return some of text plus ptr->name. */
- strncpy (matchlist[matches], word, text - word);
- matchlist[matches][text - word] = '\0';
- strcat (matchlist[matches], ptr->name);
+ if (matches == sizeof_matchlist)
+ {
+ sizeof_matchlist *= 2;
+ matchlist = (char **) xrealloc ((char *) matchlist,
+ (sizeof_matchlist
+ * sizeof (char *)));
+ }
+
+ matchlist[matches] = (char *)
+ xmalloc (strlen (word) + strlen (ptr->name) + 1);
+ if (word == text)
+ strcpy (matchlist[matches], ptr->name);
+ else if (word > text)
+ {
+ /* Return some portion of ptr->name. */
+ strcpy (matchlist[matches], ptr->name + (word - text));
+ }
+ else
+ {
+ /* Return some of text plus ptr->name. */
+ strncpy (matchlist[matches], word, text - word);
+ matchlist[matches][text - word] = '\0';
+ strcat (matchlist[matches], ptr->name);
+ }
+ ++matches;
}
- ++matches;
- }
+ /* If we saw no matching deprecated commands in the first pass,
+ just bail out. */
+ if (!saw_deprecated_match)
+ break;
+ }
if (matches == 0)
{