From patchwork Mon Apr 13 19:23:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Seitz X-Patchwork-Id: 6192 Received: (qmail 119084 invoked by alias); 13 Apr 2015 19:23:12 -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 119059 invoked by uid 89); 13 Apr 2015 19:23:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham 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; Mon, 13 Apr 2015 19:23:10 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3DJN8aZ013591 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 13 Apr 2015 15:23:08 -0400 Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3DJN870030841 for ; Mon, 13 Apr 2015 15:23:08 -0400 Subject: [PATCH 03/18] Implement completion limiting for complete_on_cmdlist. From: Keith Seitz To: gdb-patches@sourceware.org Date: Mon, 13 Apr 2015 12:23:08 -0700 Message-ID: <20150413192308.29172.54277.stgit@valrhona.uglyboxes.com> In-Reply-To: <20150413192235.29172.13097.stgit@valrhona.uglyboxes.com> References: <20150413192235.29172.13097.stgit@valrhona.uglyboxes.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-IsSubscribed: yes This is the first of a series of smaller patches to switch over all completion functions to using maybe_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 maybe_add_completion to determine whether to continue looking for completions. --- gdb/cli/cli-decode.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 286fc61..21f4c45 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -1790,6 +1790,7 @@ complete_on_cmdlist (struct completer_data *cdata, || ptr->prefixlist)) { char *match; + enum maybe_add_completion_enum add_status; if (pass == 0) { @@ -1815,7 +1816,22 @@ complete_on_cmdlist (struct completer_data *cdata, match[text - word] = '\0'; strcat (match, ptr->name); } - VEC_safe_push (char_ptr, matchlist, match); + add_status = maybe_add_completion (cdata, match); + switch (add_status) + { + case MAYBE_ADD_COMPLETION_OK: + VEC_safe_push (char_ptr, matchlist, match); + break; + case MAYBE_ADD_COMPLETION_OK_MAX_REACHED: + VEC_safe_push (char_ptr, matchlist, match); + return matchlist; + case MAYBE_ADD_COMPLETION_MAX_REACHED: + xfree (match); + return matchlist; + case MAYBE_ADD_COMPLETION_DUPLICATE: + xfree (match); + break; + } } /* If we saw no matching deprecated commands in the first pass, just bail out. */