Blame SOURCES/gcc11-dejagnu-multiline.patch

e60d6e
commit 14c7757e9b751781360737f53b71f851fc356d3d
e60d6e
Author: Jeff Law <jeffreyalaw@gmail.com>
e60d6e
Date:   Fri Oct 29 11:30:15 2021 -0400
e60d6e
e60d6e
    Avoid overly-greedy match in dejagnu regexp.
e60d6e
    
e60d6e
    Occasionally I've been seeing failures with the multi-line diagnostics.  It's never been clear what's causing the spurious failures, though I have long suspected a greedy regexp match.
e60d6e
    
e60d6e
    It happened again yesterday with a local change that in no way should affect diagnostics, so I finally went searching and found that sure enough the multi-line diagnostics had a ".*" in their regexp.  According to the comments, the .* is primarily to catch any dg directives that may appear -- ie it should eat to EOL, but not multiple lines.  But a .* can indeed match a newline and cause it to eat multiple lines.
e60d6e
    
e60d6e
    The fix is simple.  [^\r\n]* will eat to EOL, but not further.
e60d6e
    
e60d6e
    Regression tested on x86_64 and on our internal target.
e60d6e
    
e60d6e
    gcc/testsuite
e60d6e
    
e60d6e
            * lib/multiline.exp (_build_multiline_regex): Use a better
e60d6e
            regexp than .* to match up to EOL.
e60d6e
e60d6e
diff --git a/gcc/testsuite/lib/multiline.exp b/gcc/testsuite/lib/multiline.exp
e60d6e
index 0e151b6d222..86387f8209b 100644
e60d6e
--- a/gcc/testsuite/lib/multiline.exp
e60d6e
+++ b/gcc/testsuite/lib/multiline.exp
e60d6e
@@ -331,7 +331,7 @@ proc _build_multiline_regex { multiline index } {
e60d6e
 		# Support arbitrary followup text on each non-empty line,
e60d6e
 		# to deal with comments containing containing DejaGnu
e60d6e
 		# directives.
e60d6e
-		append rexp ".*"
e60d6e
+		append rexp "\[^\\n\\r\]*"
e60d6e
 	    }
e60d6e
 	}
e60d6e
 	append rexp "\n"