Blame SOURCES/gcc11-dejagnu-multiline.patch

44ce1d
commit 14c7757e9b751781360737f53b71f851fc356d3d
44ce1d
Author: Jeff Law <jeffreyalaw@gmail.com>
44ce1d
Date:   Fri Oct 29 11:30:15 2021 -0400
44ce1d
44ce1d
    Avoid overly-greedy match in dejagnu regexp.
44ce1d
    
44ce1d
    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.
44ce1d
    
44ce1d
    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.
44ce1d
    
44ce1d
    The fix is simple.  [^\r\n]* will eat to EOL, but not further.
44ce1d
    
44ce1d
    Regression tested on x86_64 and on our internal target.
44ce1d
    
44ce1d
    gcc/testsuite
44ce1d
    
44ce1d
            * lib/multiline.exp (_build_multiline_regex): Use a better
44ce1d
            regexp than .* to match up to EOL.
44ce1d
44ce1d
diff --git a/gcc/testsuite/lib/multiline.exp b/gcc/testsuite/lib/multiline.exp
44ce1d
index 0e151b6d222..86387f8209b 100644
44ce1d
--- a/gcc/testsuite/lib/multiline.exp
44ce1d
+++ b/gcc/testsuite/lib/multiline.exp
44ce1d
@@ -331,7 +331,7 @@ proc _build_multiline_regex { multiline index } {
44ce1d
 		# Support arbitrary followup text on each non-empty line,
44ce1d
 		# to deal with comments containing containing DejaGnu
44ce1d
 		# directives.
44ce1d
-		append rexp ".*"
44ce1d
+		append rexp "\[^\\n\\r\]*"
44ce1d
 	    }
44ce1d
 	}
44ce1d
 	append rexp "\n"