From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 98569 invoked by alias); 11 Jun 2015 20:25:49 -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 98392 invoked by uid 89); 11 Jun 2015 20:25:49 -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; Thu, 11 Jun 2015 20:25:45 +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 (Postfix) with ESMTPS id 5B77F36B170 for ; Thu, 11 Jun 2015 20:25:43 +0000 (UTC) Received: from localhost (unused-10-15-17-126.yyz.redhat.com [10.15.17.126]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5BKPgNM001397 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA256 bits=256 verify=NO); Thu, 11 Jun 2015 16:25:43 -0400 From: Sergio Durigan Junior To: Keith Seitz Cc: gdb-patches@sourceware.org Subject: Re: [RFA/testsuite] Regexp-escape command in capture_command_output References: <20150519221428.769.46872.stgit@valrhona.uglyboxes.com> <555BB8E7.4010906@redhat.com> <87twuevz8b.fsf@redhat.com> <5579EB36.9010500@redhat.com> <87zj46uhp1.fsf@redhat.com> <5579EDE5.3080802@redhat.com> X-URL: http://blog.sergiodj.net Date: Thu, 11 Jun 2015 20:25:00 -0000 In-Reply-To: <5579EDE5.3080802@redhat.com> (Keith Seitz's message of "Thu, 11 Jun 2015 13:21:57 -0700") Message-ID: <87vbeuuh4w.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2015-06/txt/msg00236.txt.bz2 On Thursday, June 11 2015, Keith Seitz wrote: > On 06/11/2015 01:13 PM, Sergio Durigan Junior wrote: >> >> Aha, this is definitely not clear in the function comments. Would it be >> possible to explicitly mention this there? >> > > Sure thing! Looks good, thanks! > Keith > > > From 52323e069647b7931ad17c906b5a77980cc8b5e9 Mon Sep 17 00:00:00 2001 > From: Keith Seitz > Date: Thu, 11 Jun 2015 13:15:17 -0700 > Subject: [PATCH] Regexp-escape command in capture_command_output > > The test suite library procedure capture_command_output will fail if the > given command contains any regexp characters, such as "+" or "*". I noticed > this while writing a test which attempts to call: > > set xyz [capture_command_output "list +,-" ""] > > Because COMMAND is not escaped, gdb_test_multiple will generate a false > FAIL. This simple fix corrects that oversight. > > I've also updated the comment to clarify that PREFIX is a regexp. > > testsuite/ChangeLog > > * lib/gdb.exp (capture_command_output): Regexp-escape `command' > before using it in the matching pattern. > Clarify that `prefix' is a regular expression. > --- > gdb/testsuite/lib/gdb.exp | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index 41797e7..2796514 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -5196,12 +5196,15 @@ proc parse_args { argset } { > # number of items expected to be passed into the procedure... > } > > -# Capture the output of COMMAND in a string ignoring PREFIX; return > that string. > +# Capture the output of COMMAND in a string ignoring PREFIX (a regexp); > +# return that string. > + > proc capture_command_output { command prefix } { > global gdb_prompt > global expect_out > > set output_string "" > + set command [string_to_regexp $command] > gdb_test_multiple "$command" "capture_command_output for $command" { > -re "${command}\[\r\n\]+${prefix}(.*)\[\r\n\]+$gdb_prompt $" { > set output_string $expect_out(1,string) > -- > 2.1.0 -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/