aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/python.c
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2021-09-10 17:16:48 +0200
committerTom de Vries <tdevries@suse.de>2021-09-10 17:16:48 +0200
commitca4987847046f288573278237673ded42a2dead8 (patch)
tree5d1fed8166541752f297268b45e437b1258123da /gdb/python/python.c
parent49a9ec7f6a37117519aba9d3e31b1fe17a9dc029 (diff)
downloadbinutils-ca4987847046f288573278237673ded42a2dead8.zip
binutils-ca4987847046f288573278237673ded42a2dead8.tar.gz
binutils-ca4987847046f288573278237673ded42a2dead8.tar.bz2
[gdb/testsuite] Add string_list_to_regexp
A regexp pattern with escapes like this is hard to read: ... set re "~\"\[$\]$decimal = 1\\\\n\"\r\n\\^done" ... We can make it more readable by spacing out parts (which allows us to also use the curly braces where that's convenient): ... set re [list "~" {"} {[$]} $decimal " = 1" "\\\\" "n" {"} "\r\n" "\\^" "done"] set re [join $re ""] ... or by using string_to_regexp: ... set re [list \ [string_to_regexp {~"$}] \ $decimal \ [string_to_regexp " = 1\\n\"\r\n^done"]] set re [join $re ""] ... Note: we have to avoid applying string_to_list to decimal, which is already a regexp. Add a proc string_list_to_regexp to make it easy to do both: ... set re [list \ [string_list_to_regexp ~ {"} $] \ $decimal \ [string_list_to_regexp " = 1" \\ n {"} \r\n ^ done]] ... Also add a test-case gdb.testsuite/string_to_regexp.exp.
Diffstat (limited to 'gdb/python/python.c')
0 files changed, 0 insertions, 0 deletions