From patchwork Mon May 4 19:18:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Seitz X-Patchwork-Id: 6558 Received: (qmail 94899 invoked by alias); 4 May 2015 19:18:44 -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 94435 invoked by uid 89); 4 May 2015 19:18:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 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, 04 May 2015 19:18:42 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t44JId9M006570 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 4 May 2015 15:18:40 -0400 Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t44JIdXk032442 for ; Mon, 4 May 2015 15:18:39 -0400 Subject: [PATCH v2 13/18] Implement completion limiting for complete_on_enum. From: Keith Seitz To: gdb-patches@sourceware.org Date: Mon, 04 May 2015 12:18:39 -0700 Message-ID: <20150504191839.20434.12928.stgit@valrhona.uglyboxes.com> In-Reply-To: <20150504191734.20434.68053.stgit@valrhona.uglyboxes.com> References: <20150504191734.20434.68053.stgit@valrhona.uglyboxes.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-IsSubscribed: yes This is another patch to push along the conversion of location_completer toward using add_completion. In this patch, complete_on_enum is converted. This function is also used by several other commands, such as integer_unlimited_completer, handle_completer, cp_abi_completer, etc. gdb/ChangeLog * cli/cli-decode.c (complete_on_enum): Use add_completion. gdb/testsuite/ChangeLog * gdb.base/completion.exp: Add tests for complete_on_enum completion limiting using "handle signal". --- gdb/cli/cli-decode.c | 5 ++++- gdb/testsuite/gdb.base/completion.exp | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 011c427..a09ad5c 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -1868,7 +1868,10 @@ complete_on_enum (struct completer_data *cdata, match[text - word] = '\0'; strcat (match, name); } - VEC_safe_push (char_ptr, matchlist, match); + + if (add_completion (cdata, &matchlist, match) + == ADD_COMPLETION_MAX_REACHED) + break; } return matchlist; diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp index 4a35cd1..516975c 100644 --- a/gdb/testsuite/gdb.base/completion.exp +++ b/gdb/testsuite/gdb.base/completion.exp @@ -1041,3 +1041,15 @@ with_test_prefix "interpreter_completer reset" { # Test reg_or_group_completer. test_completion_limit "info registers " \ "info registers \[a-zA-Z0-9\]+" $max_completions + +# Test complete_on_enum. +set signal_to_use "" +set signal_list [split \ + [capture_command_output "complete handle signal " ""] \ + \r\n] +catch {lindex [split [lindex $signal_list 0]] 2} signal_to_use +if {$signal_to_use != ""} { + test_completion_limit "handle signal $signal_to_use n" \ + "handle signal $signal_to_use n\[a-z\]+" \ + $max_completions +}