From patchwork Thu Aug 6 19:21:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Seitz X-Patchwork-Id: 8066 Received: (qmail 111033 invoked by alias); 6 Aug 2015 22:03:34 -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 111009 invoked by uid 89); 6 Aug 2015 22:03:33 -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:03:32 +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 (Postfix) with ESMTPS id D3F00FC0EA for ; Thu, 6 Aug 2015 22:03:31 +0000 (UTC) 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 t76JL6C5013173 for ; Thu, 6 Aug 2015 15:21:06 -0400 Subject: [PATCH v3 16/19] Implement completion limiting for tui_reggroup_completer. From: Keith Seitz To: gdb-patches@sourceware.org Date: Thu, 06 Aug 2015 12:21:06 -0700 Message-ID: <20150806192023.32159.18803.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 This is a new patch in the series. --- This patch converts the (recently introduced) TUI register/group completer, tui_reggroup_completer, to use add_completion. gdb/ChangeLog * tui/tui-regs.c (tui_reggroup_completer): Use add_completion to add completions to the completion list. gdb/testsuite/ChangeLog * completion.exp: Add a completion-limit test for "tui reg". --- gdb/testsuite/gdb.base/completion.exp | 5 +++++ gdb/tui/tui-regs.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp index 1036af5..07ce660 100644 --- a/gdb/testsuite/gdb.base/completion.exp +++ b/gdb/testsuite/gdb.base/completion.exp @@ -1058,6 +1058,11 @@ if {$signal_to_use != ""} { test_completion_limit "print field_test_global.a" \ "print field_test_global\\\.a\[1-9\]_field" $max_completions +# Test TUI's reg completer +if {![skip_tui_tests]} { + test_completion_limit "tui reg " "tui reg \[a-z\]+" $max_completions +} + # # Test TUI completions # diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c index 756f598..17efd9f 100644 --- a/gdb/tui/tui-regs.c +++ b/gdb/tui/tui-regs.c @@ -683,7 +683,11 @@ tui_reggroup_completer (struct completer_data *cdata, for (tmp = extra; *tmp != NULL; ++tmp) { if (strncmp (word, *tmp, len) == 0) - VEC_safe_push (char_ptr, result, xstrdup (*tmp)); + { + if (add_completion (cdata, &result, *tmp, NULL, NULL) + == ADD_COMPLETION_MAX_REACHED) + break; + } } return result;