On 11/10/16 20:19, Jakub Jelinek wrote:
On Tue, Oct 11, 2016 at 01:11:04PM -0600, Martin Sebor wrote:
Also, the pattern that starts with "/\+\+\+" looks like it's missing
the ^ anchor.  Presumably it should be "/^\+\+\+ \/testsuite\//".
No, it will be almost never +++ /testsuite/
There needs to be .* in between "+++ " and "/testsuite/", and perhaps
it should also ignore "+++ testsuite/".
So /^\+\+\+ (.*\/)?testsuite\// ?
Also, normally (when matching $0) there won't be newlines in the text.

        Jakub

Thanks.
Here is the updated patch with your suggestions.

2016-10-12  Kyrylo Tkachov  <kyrylo.tkac...@arm.com>

    * check_GNU_style.sh (remove_testsuite): New function.
    Use it to remove testsuite from the diff.
commit e4af5426c86a00a05fc08109fa84bfe30285f2a2
Author: Kyrylo Tkachov <kyrylo.tkac...@arm.com>
Date:   Tue Oct 11 11:33:50 2016 +0100

    [check_GNU_style.sh] Ignore testsuite

diff --git a/contrib/check_GNU_style.sh b/contrib/check_GNU_style.sh
index 87a276c..2787e9b 100755
--- a/contrib/check_GNU_style.sh
+++ b/contrib/check_GNU_style.sh
@@ -81,7 +81,17 @@ if [ $nfiles -eq 1 ]; then
 else
     format="-nH"
 fi
+
+# Remove the testsuite part of the diff.  We don't care about GNU style
+# in testcases and the dg-* directives give too many false positives.
+remove_testsuite ()
+{
+  awk 'BEGIN{testsuite=0} /^\+\+\+ / && ! /testsuite\//{testsuite=0} \
+       {if (!testsuite) print} /^\+\+\+ (.*\/)?testsuite\//{testsuite=1}'
+}
+
 grep $format '^+' $files \
+    | remove_testsuite \
     | grep -v ':+++' \
     > $inp
 
@@ -160,8 +170,9 @@ col (){
 	fi
 
 	# Don't reuse $inp, which may be generated using -H and thus contain a
-	# file prefix.
-	grep -n '^+' $f \
+	# file prefix.  Re-remove the testsuite since we're not using $inp.
+	remove_testsuite $f \
+	    | grep -n '^+' \
 	    | grep -v ':+++' \
 	    > $tmp
 
@@ -174,11 +185,10 @@ col (){
 	# Expand tabs to spaces according to tab positions.
 	# Keep long lines, make short lines empty.  Print the part past 80 chars
 	# in red.
-        # Don't complain about dg-xxx directives in tests.
 	cat "$tmp" \
 	    | sed 's/^[0-9]*:+//' \
 	    | expand \
-	    | awk '$0 !~ /{[[:space:]]*dg-(error|warning|message)[[:space:]]/ { \
+	    | awk '{ \
 		     if (length($0) > 80) \
 		       printf "%s\033[1;31m%s\033[0m\n", \
 			      substr($0,1,80), \

Reply via email to