[review,gdb/testsuite] Use non-capturing parentheses for inferior_exited_re

Message ID gerrit.1580742892000.I7640c6129b1ada617424d6a63730d4b119c58ef3@gnutoolchain-gerrit.osci.io
State New
Headers show
Series
  • [review,gdb/testsuite] Use non-capturing parentheses for inferior_exited_re
Related show

Commit Message

Simon Marchi (Code Review) Feb. 3, 2020, 3:14 p.m.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/763
......................................................................

[gdb/testsuite] Use non-capturing parentheses for inferior_exited_re

The set_inferior_exited_re regexp uses capturing parentheses by default:
...
set inferior_exited_re "(\\\[Inferior \[0-9\]+ \\(.*\\) exited)"
...

The parentheses are there to be able to use the expression as an atom, f.i.,
to have '+' apply to the whole regexp in "${inferior_exited_re}+".

But the capturing is not necessary, and it can be confusing because it's not
obvious in a regexp using "$inferior_exited_re (bla|bli)" that the first
captured expression is in $inferior_exited_re.

Replace by non-capturing parentheses.  If we still want to capture the
expression, we can simply (and more clearly) use "($inferior_exited_re)".

Build and reg-tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-02-01  Tom de Vries  <tdevries@suse.de>

	* lib/gdb.exp (inferior_exited_re): Use non-capturing parentheses.

Change-Id: I7640c6129b1ada617424d6a63730d4b119c58ef3
---
M gdb/testsuite/lib/gdb.exp
1 file changed, 1 insertion(+), 1 deletion(-)




-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I7640c6129b1ada617424d6a63730d4b119c58ef3
Gerrit-Change-Number: 763
Gerrit-PatchSet: 1
Gerrit-Owner: Tom de Vries <tdevries@suse.de>
Gerrit-MessageType: newchange

Comments

Simon Marchi (Code Review) Feb. 4, 2020, 4:34 a.m. | #1
Simon Marchi has posted comments on this change.

Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/763
......................................................................


Patch Set 1: Code-Review+2

(1 comment)

Just a nit in the commit message, but otherwise this LGTM.

| --- /dev/null
| +++ /COMMIT_MSG
| @@ -1,0 +1,18 @@ 
| +Parent:     0b398d69 (binutils: drop redundant 'program_name' definition (-fno-common))
| +Author:     Tom de Vries <tdevries@suse.de>
| +AuthorDate: 2020-02-01 11:56:29 +0100
| +Commit:     Tom de Vries <tdevries@suse.de>
| +CommitDate: 2020-02-03 15:28:19 +0100
| +
| +[gdb/testsuite] Use non-capturing parentheses for inferior_exited_re
| +
| +The set_inferior_exited_re regexp uses capturing parentheses by default:

PS1, Line 9:

Just `inferior_exited_re`.

| +...
| +set inferior_exited_re "(\\\[Inferior \[0-9\]+ \\(.*\\) exited)"
| +...
| +
| +The parentheses are there to be able to use the expression as an atom, f.i.,
| +to have '+' apply to the whole regexp in "${inferior_exited_re}+".
| +
| +But the capturing is not necessary, and it can be confusing because it's not
| +obvious in a regexp using "$inferior_exited_re (bla|bli)" that the first

-- 
Gerrit-Project: binutils-gdb
Gerrit-Branch: master
Gerrit-Change-Id: I7640c6129b1ada617424d6a63730d4b119c58ef3
Gerrit-Change-Number: 763
Gerrit-PatchSet: 1
Gerrit-Owner: Tom de Vries <tdevries@suse.de>
Gerrit-Reviewer: Simon Marchi <simon.marchi@polymtl.ca>
Gerrit-Comment-Date: Tue, 04 Feb 2020 04:34:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

Patch

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 2d230b7..25bed76 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -117,7 +117,7 @@ 
 
 set octal "\[0-7\]+"
 
-set inferior_exited_re "(\\\[Inferior \[0-9\]+ \\(.*\\) exited)"
+set inferior_exited_re "(?:\\\[Inferior \[0-9\]+ \\(.*\\) exited)"
 
 # A regular expression that matches a value history number.
 # E.g., $1, $2, etc.