From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [RFC 3/5] [gdb/testsuite] Update regexp in string_to_regexp
Date: Fri, 4 Sep 2026 11:38:53 +0200 [thread overview]
Message-ID: <20260904093858.359604-3-tdevries@suse.de> (raw)
In-Reply-To: <20260904093858.359604-1-tdevries@suse.de>
There are two similar regexps, in string_to_regexp and with_gdb_prompt:
...
regsub -all {[]?*+.|(){}^$\[\\]} $str {\\&} result
regsub -all {[]*+.|()^$\[\\]} $prompt {\\&} prompt
...
In both cases, emacs tcl-mode has problems with it: auto indent doesn't
continue at column 4, but is reset to column 0.
The first regexp is basically one big bracket expression containing the chars:
...
] ? * + . | ( ) { } ^ $ \[ \\
...
There are a couple of ways that a ']' can be enclosed in a bracket
expression [1]:
- make it the first char
- escape using backslash
- make it a collating element
The first solution was chosen, but confuses tcl-mode.
Fix this by adding a backslash.
[1] https://www.tcl-lang.org/man/tcl8.6/TclCmd/re_syntax.htm#M30
---
gdb/testsuite/lib/gdb-utils.exp | 4 +++-
gdb/testsuite/lib/gdb.exp | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp
index cabeb7aa1ed..874de79e6d8 100644
--- a/gdb/testsuite/lib/gdb-utils.exp
+++ b/gdb/testsuite/lib/gdb-utils.exp
@@ -36,7 +36,9 @@ proc gdb_init_commands {} {
proc string_to_regexp {str} {
set result $str
- regsub -all {[]?*+.|(){}^$\[\\]} $str {\\&} result
+ # We use a backslash to escape the closing square bracket, even if it's
+ # the first character, to unconfuse emacs tcl-mode.
+ regsub -all {[\]?*+.|(){}^$\[\\]} $str {\\&} result
return $result
}
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index d4a471ff7c4..b0a4cc1b39f 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3650,7 +3650,9 @@ proc with_gdb_prompt { prompt body } {
# we start recording both forms separately instead of just $gdb_prompt.
# The testsuite is pretty-much hardwired to interpret $gdb_prompt as the
# regexp form.
- regsub -all {[]*+.|()^$\[\\]} $prompt {\\&} prompt
+ # We use a backslash to escape the closing square bracket, even if it's
+ # the first character, to unconfuse emacs tcl-mode.
+ regsub -all {[\]*+.|()^$\[\\]} $prompt {\\&} prompt
set saved $gdb_prompt
--
2.51.0
next prev parent reply other threads:[~2026-09-04 9:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 9:38 [RFC 1/5] [pre-commit] Add indent-exp Tom de Vries
2026-09-04 9:38 ` [RFC 2/5] [gdb/testsuite] Make lib/gdb.exp emacs indent compatible Tom de Vries
2026-09-04 9:38 ` Tom de Vries [this message]
2026-09-04 9:38 ` [RFC 4/5] [gdb/testsuite] Reformat lib/gdb.exp Tom de Vries
2026-09-04 9:38 ` [RFC 5/5] [gdb/testsuite] Reformat gdb.ada Tom de Vries
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=20260904093858.359604-3-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/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