[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PATCH: simplify regular expressions
From: |
Andreas Schwab |
Subject: |
Re: PATCH: simplify regular expressions |
Date: |
Mon, 10 Dec 2018 13:04:33 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1.90 (gnu/linux) |
On Dez 10 2018, Ben Elliston <address@hidden> wrote:
> diff --git a/config/gdb-comm.exp b/config/gdb-comm.exp
> index c9ef574..1e57eac 100644
> --- a/config/gdb-comm.exp
> +++ b/config/gdb-comm.exp
> @@ -86,7 +86,7 @@ proc gdb_comm_file_cmd { arg } {
> verbose "\t\tKilling previous program being debugged"
> exp_continue
> }
> - -re "Load new symbol table from \".*\".*y or n.*$" {
> + -re {Load new symbol table from ".*".*y or n.*$" {
Missing close brace.
> @@ -493,7 +493,7 @@ proc gdb_comm_load { dest prog args } {
> remote_reboot $dest
> return [list "fail" $output]
> }
> - -re "(.*)Program exited with code \[0-9\]+.*$gdb_prompt $" {
> + -re "(.*)Program exited with code [0-9]+.*$gdb_prompt $" {
You cannot remove the backslash here.
> diff --git a/lib/framework.exp b/lib/framework.exp
> index 5879ea6..a5ae572 100644
> --- a/lib/framework.exp
> +++ b/lib/framework.exp
> @@ -292,7 +292,7 @@ proc clone_output { message } {
> puts $sum_file $message
> }
>
> - regsub "^\[ \t\]*(\[^ \t\]+).*$" $message "\\1" firstword
> + regsub "^\[ \t\]*(\[^ \t\]+).*$" $message {\1} firstword
The re can be simplified too.
> diff --git a/lib/target.exp b/lib/target.exp
> index 2620e30..3a40995 100644
> --- a/lib/target.exp
> +++ b/lib/target.exp
> @@ -124,15 +124,15 @@ proc prune_warnings { text } {
> regsub -all -- "\r" $text "" text
>
> # This is from sun4's. Do it for all machines for now.
> - # The "\\1" is to try to preserve a "\n" but only if necessary.
> + # The {\1} is to try to preserve a "\n" but only if necessary.
> if {[ishost "sparc-*-sunos*"]} {
> - regsub -all "(^|\n)(ld.so: warning:\[^\n\]*\n?)+" $text "\\1" text
> + regsub -all "(^|\n)(ld.so: warning:\[^\n\]*\n?)+" $text {\1} text
Likewise.
> }
>
> # See Brendan for the raison d'etre of this one.
> # http://en.wikipedia.org/wiki/Brendan_Kehoe
> if {[ishost "alpha*-*-*"]} {
> - regsub -all "(^|\n)(/usr/(ucb|bin)/ld.*without exceptions
> was\[^\n\]+\n?)" $text "\\1" text
> + regsub -all "(^|\n)(/usr/(ucb|bin)/ld.*without exceptions
> was\[^\n\]+\n?)" $text {\1} text
Likewise.
> @@ -197,72 +197,72 @@ proc prune_warnings { text } {
> regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $text
> "" text
>
> # This is from sun4's. Do it for all machines for now.
> - # The "\\1" is to try to preserve a "\n" but only if necessary.
> - regsub -all "(^|\n)(ld.so: warning:\[^\n\]*\n?)+" $text "\\1" text
> + # The {\1} is to try to preserve a "\n" but only if necessary.
> + regsub -all "(^|\n)(ld.so: warning:\[^\n\]*\n?)+" $text {\1} text
Likewise.
>
> # This happens when compiling on Alpha OSF/1 with cc -g -O.
> - regsub -all "(^|\n)(\n*uopt: Warning: file not optimized; use -g3 if
> both optimization and debug wanted\n?)+" $text "\\1" text
> + regsub -all "(^|\n)(\n*uopt: Warning: file not optimized; use -g3 if
> both optimization and debug wanted\n?)+" $text {\1} text
Likewise.
Many more occurences following.
Andreas.
--
Andreas Schwab, SUSE Labs, address@hidden
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."