Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Sergio Durigan Junior <sergiodj@redhat.com>
To: Keith Seitz <keiths@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA/testsuite] Regexp-escape command in capture_command_output
Date: Thu, 11 Jun 2015 19:09:00 -0000	[thread overview]
Message-ID: <87twuevz8b.fsf@redhat.com> (raw)
In-Reply-To: <555BB8E7.4010906@redhat.com> (Keith Seitz's message of "Tue, 19	May 2015 15:27:51 -0700")

On Tuesday, May 19 2015, Keith Seitz wrote:

> Hi,
>
> I think this qualifies as obvious, but I thought I'd give others a
> chance to comment...
>
> Our 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 +,-" ""]

Ouch :-/.  I've seen that before...

> Because COMMAND is not escaped, gdb_test_multiple will generate a false
> FAIL. This simple fix corrects that oversight.
>
> testsuite/ChangeLog
>
> 	* lib/gdb.exp (capture_command_output): Regexp-escape `command'
> 	before using in the matching pattern.
>
> On 05/19/2015 03:14 PM, Keith Seitz wrote:
>> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
>> index 73e55e3..fe7dd60 100644
>> --- a/gdb/testsuite/lib/gdb.exp
>> +++ b/gdb/testsuite/lib/gdb.exp
>> @@ -5185,7 +5185,7 @@ proc capture_command_output { command prefix } {
>>  
>>      set output_string ""
>>      gdb_test_multiple "$command" "capture_command_output for $command" {
>> -	-re "${command}\[\r\n\]+${prefix}(.*)\[\r\n\]+$gdb_prompt $" {
>> +	-re "[string_to_regexp ${command}]\[\r\n\]+${prefix}(.*)\[\r\n\]+$gdb_prompt $" {
>>  	    set output_string $expect_out(1,string)

The patch looks correct, but shouldn't we convert ${prefix} to regexp as
well?

Otherwise, looks good to me.

Thanks,

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/


  reply	other threads:[~2015-06-11 19:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-19 22:14 [PATCH v5] Explicit locations: add UI features for CLI Keith Seitz
2015-05-19 22:22 ` Keith Seitz
2015-05-19 22:27 ` [RFA/testsuite] Regexp-escape command in capture_command_output Keith Seitz
2015-06-11 19:09   ` Sergio Durigan Junior [this message]
2015-06-11 20:10     ` Keith Seitz
2015-06-11 20:13       ` Sergio Durigan Junior
2015-06-11 20:22         ` Keith Seitz
2015-06-11 20:25           ` Sergio Durigan Junior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87twuevz8b.fsf@redhat.com \
    --to=sergiodj@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox