From patchwork Thu Aug 6 19:19: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: 8068 Received: (qmail 111146 invoked by alias); 6 Aug 2015 22:03:35 -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 111048 invoked by uid 89); 6 Aug 2015 22:03:34 -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:33 +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 EAC90FC0FF 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 t76JJYF0012130 for ; Thu, 6 Aug 2015 15:19:34 -0400 Subject: [PATCH v3 13/19] Implement completion limiting for complete_on_enum. From: Keith Seitz To: gdb-patches@sourceware.org Date: Thu, 06 Aug 2015 12:19:34 -0700 Message-ID: <20150806191920.32159.96756.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_enum --- 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 | 21 +++------------------ gdb/testsuite/gdb.base/completion.exp | 12 ++++++++++++ 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 3cecc90..fa95ee6 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -1834,24 +1834,9 @@ complete_on_enum (struct completer_data *cdata, for (i = 0; (name = enumlist[i]) != NULL; i++) if (strncmp (name, text, textlen) == 0) { - char *match; - - match = (char *) xmalloc (strlen (word) + strlen (name) + 1); - if (word == text) - strcpy (match, name); - else if (word > text) - { - /* Return some portion of name. */ - strcpy (match, name + (word - text)); - } - else - { - /* Return some of text plus name. */ - strncpy (match, word, text - word); - match[text - word] = '\0'; - strcat (match, name); - } - VEC_safe_push (char_ptr, matchlist, match); + if (add_completion (cdata, &matchlist, name, text, word) + == ADD_COMPLETION_MAX_REACHED) + break; } return matchlist; diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp index 3f56a13..6c81505 100644 --- a/gdb/testsuite/gdb.base/completion.exp +++ b/gdb/testsuite/gdb.base/completion.exp @@ -1042,6 +1042,18 @@ with_test_prefix "interpreter_completer reset" { 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 +} + # # Test TUI completions #