From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 105429 invoked by alias); 23 Aug 2015 04:03:06 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 105389 invoked by uid 89); 23 Aug 2015 04:03:03 -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,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f49.google.com Received: from mail-pa0-f49.google.com (HELO mail-pa0-f49.google.com) (209.85.220.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sun, 23 Aug 2015 04:03:01 +0000 Received: by pacgr6 with SMTP id gr6so4913817pac.0 for ; Sat, 22 Aug 2015 21:02:59 -0700 (PDT) X-Received: by 10.66.141.74 with SMTP id rm10mr32553555pab.56.1440302579510; Sat, 22 Aug 2015 21:02:59 -0700 (PDT) Received: from seba.sebabeach.org.gmail.com (173-13-178-53-sfba.hfc.comcastbusiness.net. [173.13.178.53]) by smtp.gmail.com with ESMTPSA id fl6sm12707629pab.12.2015.08.22.21.02.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Aug 2015 21:02:59 -0700 (PDT) From: Doug Evans To: Keith Seitz Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v3 09/19] Implement completion limiting for interpreter_completer. References: <20150806191404.32159.50755.stgit@valrhona.uglyboxes.com> <20150806191756.32159.49337.stgit@valrhona.uglyboxes.com> Date: Sun, 23 Aug 2015 04:03:00 -0000 In-Reply-To: <20150806191756.32159.49337.stgit@valrhona.uglyboxes.com> (Keith Seitz's message of "Thu, 06 Aug 2015 12:18:12 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg00648.txt.bz2 Keith Seitz writes: > Differences in this revision: > > 1. Remove partial copy code from interpreter_completer.. > > --- > > This is another simple patch which converts interpreter_completer > to use add_completion and adds some tests to make sure that everything > is working properly. > > gdb/ChangeLog > > * interps.c (interpreter_completer): Use add_completion. > > gdb/testsuite/ChangeLog > > * gdb.base/completion.exp: Test completion limiting on > interpreter name with "interpreter-exec". LGTM with one nit below fixed. I'm really liking all this removal of duplicate code. Thanks! > --- > gdb/interps.c | 21 +++------------------ > gdb/testsuite/gdb.base/completion.exp | 16 ++++++++++++++++ > 2 files changed, 19 insertions(+), 18 deletions(-) > > diff --git a/gdb/interps.c b/gdb/interps.c > index 2cfe92b..9e993c8 100644 > --- a/gdb/interps.c > +++ b/gdb/interps.c > @@ -448,24 +448,9 @@ interpreter_completer (struct completer_data *cdata, > { > if (strncmp (interp->name, text, textlen) == 0) > { > - char *match; > - > - match = (char *) xmalloc (strlen (word) + strlen (interp->name) + 1); > - if (word == text) > - strcpy (match, interp->name); > - else if (word > text) > - { > - /* Return some portion of interp->name. */ > - strcpy (match, interp->name + (word - text)); > - } > - else > - { > - /* Return some of text plus interp->name. */ > - strncpy (match, word, text - word); > - match[text - word] = '\0'; > - strcat (match, interp->name); > - } > - VEC_safe_push (char_ptr, matches, match); > + if (add_completion (cdata, &matches, interp->name, text, word) > + == ADD_COMPLETION_MAX_REACHED) > + break; > } > } > > diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp > index 884b9f6..41323d2 100644 > --- a/gdb/testsuite/gdb.base/completion.exp > +++ b/gdb/testsuite/gdb.base/completion.exp > @@ -1022,6 +1022,22 @@ if {$num_signals > $max_completions} { > untested $msg > } > > +# Test interpreter_completer. There are only four completions > +# available for this, so temporarily set max-completions to 3. > +with_test_prefix "interpreter_completer" { > + set old_max $max_completions ==== There is save_vars now to handle restoring variables to their previous values. save_vars { max_completions } { ... } > + set max_completions 3 > + gdb_test_no_output "set max-completions $max_completions" > +} > + > +test_completion_limit "interpreter-exec m" \ > + "interpreter-exec mi\[1-3\]?" $max_completions > + > +with_test_prefix "interpreter_completer reset" { > + set max_completions $old_max > + gdb_test_no_output "set max-completions $max_completions" > +} > + > # > # Test TUI completions > #