From patchwork Thu Aug 6 19:15:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Seitz X-Patchwork-Id: 8073 Received: (qmail 74812 invoked by alias); 6 Aug 2015 22:36:23 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 74801 invoked by uid 89); 6 Aug 2015 22:36:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 06 Aug 2015 22:36:22 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 0B6D93A9289 for ; Thu, 6 Aug 2015 22:36:21 +0000 (UTC) Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t76JFZ5p021055 for ; Thu, 6 Aug 2015 15:15:35 -0400 Subject: [PATCH v3 03/19] Implement completion-limiting for complete_on_cmdlist. From: Keith Seitz To: gdb-patches@sourceware.org Date: Thu, 06 Aug 2015 12:15:34 -0700 Message-ID: <20150806191517.32159.91797.stgit@valrhona.uglyboxes.com> In-Reply-To: <20150806191404.32159.50755.stgit@valrhona.uglyboxes.com> References: <20150806191404.32159.50755.stgit@valrhona.uglyboxes.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-IsSubscribed: yes Differences in this revision: 1. Remove partial copy code from complete_on_cmdlist. --- This is the first of a series of smaller patches to switch over all completion functions to using add_completion to add completions to the completion list to be presented to the user. Note that in order to verify that this patch works as intended, one must override the backup completion counting in complete_line. [This backup code will be permanently removed in a later patch.] During testing, I have verified all patches with this planned code removal to verify that it works. First up is complete_on_cmdlist. Completion-limiting is already tested in gdb.base/completion.exp, so there are no new tests. gdb/ChangeLog * cli/cli-decode.c (complete_on_cmdlist): Use add_completion to determine whether to continue looking for completions. --- gdb/cli/cli-decode.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 3415b77..3cecc90 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -1789,8 +1789,6 @@ complete_on_cmdlist (struct completer_data *cdata, && (!ignore_help_classes || ptr->func || ptr->prefixlist)) { - char *match; - if (pass == 0) { if (ptr->cmd_deprecated) @@ -1800,22 +1798,9 @@ complete_on_cmdlist (struct completer_data *cdata, } } - match = (char *) xmalloc (strlen (word) + strlen (ptr->name) + 1); - if (word == text) - strcpy (match, ptr->name); - else if (word > text) - { - /* Return some portion of ptr->name. */ - strcpy (match, ptr->name + (word - text)); - } - else - { - /* Return some of text plus ptr->name. */ - strncpy (match, word, text - word); - match[text - word] = '\0'; - strcat (match, ptr->name); - } - VEC_safe_push (char_ptr, matchlist, match); + if (add_completion (cdata, &matchlist, ptr->name, text, word) + == ADD_COMPLETION_MAX_REACHED) + return matchlist; } /* If we saw no matching deprecated commands in the first pass, just bail out. */