From: Tom Tromey <tom@tromey.com>
To: Tom de Vries <tdevries@suse.de>
Cc: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] [gdb/testsuite] Fix gdb.tui/resize-3.exp on ppc64-linux
Date: Sat, 18 Oct 2025 11:19:07 -0600 [thread overview]
Message-ID: <87frbgb01g.fsf@tromey.com> (raw)
In-Reply-To: <d51080eb-544b-4841-8609-14ee97c0d616@suse.de> (Tom de Vries's message of "Sat, 18 Oct 2025 10:21:58 +0200")
Tom> - "$hex\\s+<foo"
Tom> + [string cat $hex {\s+} "<" ([string_to_regexp .])? "foo"]
>> Personally I find this a lot less readable than just writing out the
>> regular expression.
Tom> I find this style much less readable:
Tom> ...
Tom> set re "$hex\\s+<(\\.)?foo"
Tom> ...
Tom> That is, I don't understand why you would join logically separate
Tom> parts of the regexp together and force readers of the regexp to go
Tom> through the process of separating them out again.
The specific reason I do find this more readable is that reading a
regular expression is a skill I already have, whereas decoding:
[string cat $hex {\s+} "<" ([string_to_regexp .])? "foo"]
requires picking through each part and trying to understand what the
point is.
Tom> It's also error prone, especially where the dot is concerned:
Tom> - if you forget the second backslash on the s, you get a mismatch and
Tom> it's easily spotted.
Tom> - if you forget the second backslash on the dot, you still get a match,
Tom> but it'll match any character, say the a in "0x00c0ffee <afoo>".
Tom> I've seen many examples of this mistake in the testsuite sources.
This is not a mistake per se, I think. Like, it isn't an instance of
someone being confused as to what to write and picking the wrong one. I
think it is rather laziness about the quoting combined with the
recognition that it is hardly likely to matter.
Not that I'm supporting laziness in all cases, but a lot of times it
really just isn't important.
Like, in this case, if one wrote "<.?foo" would this really ever trigger
erroneously? In your example above, where does "afoo" come from? It
seems to me that a situation like that can be solved by picking more
distinct symbol names, something we've already had to do plenty of times
when it turns out that some C library happens to define the same symbol
name as a test case.
Another thought here is that regexps interact badly with Tcl double
quotes. But they aren't as bad when using braces. So maybe that's
another approach.
Just to ground this discussion a bit, I don't really care about this
particular test. You can land this patch if you want. I'm not likely
to ever look at it again. However this is more about the future
direction of the test suite in general. I would be against a more
global replacement of relatively straightforward (to me) regular
expressions with concatenations of function calls, not to mention
requiring this very wordy approach in patches.
Today I wrote a Tcl implementation of the "quotemeta" thing from the
AdaCore internal test suite. We discussed it once before. I'll attach
it to that bug. It does help quite a bit (IMO) but unfortunately not
with the particular problem in this thread.
Tom
next prev parent reply other threads:[~2025-10-18 17:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 13:39 Tom de Vries
2025-10-17 14:14 ` Tom Tromey
2025-10-18 8:21 ` Tom de Vries
2025-10-18 9:11 ` Tom de Vries
2025-10-18 17:19 ` Tom Tromey [this message]
2025-10-20 10:08 ` 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=87frbgb01g.fsf@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
--cc=tdevries@suse.de \
/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