check_GNU_style.sh: Fix tab size in 80 characters check
authorTom de Vries <tom@codesourcery.com>
Tue, 12 May 2015 16:23:38 +0000 (16:23 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Tue, 12 May 2015 16:23:38 +0000 (16:23 +0000)
2015-05-12  Tom de Vries  <tom@codesourcery.com>

* check_GNU_style.sh (col): Fix tab size.

From-SVN: r223088

contrib/ChangeLog
contrib/check_GNU_style.sh

index 97941f77f007496d575e609f71dc12d3c5724707..e9768a21a10ec23ed520c95342944a1a7f286ad1 100644 (file)
@@ -1,3 +1,7 @@
+2015-05-12  Tom de Vries  <tom@codesourcery.com>
+
+       * check_GNU_style.sh (col): Fix tab size.
+
 2015-05-12  Tom de Vries  <tom@codesourcery.com>
 
        * check_GNU_style.sh: Put stdin into a temp file.
index 318eb6adca5c776643da7f8b39e5db34f49e58cf..90c612ff1cb051b8a58a23d5cc9997673347a24b 100755 (executable)
@@ -116,13 +116,37 @@ vg (){
 
 col (){
     msg="$1"
-    cat $inp \
-       | awk -F':\\+' '{ if (length($2) > 80) print $0}' \
-       > $tmp
-    if [ -s $tmp ]; then
-       printf "\n$msg\n"
-       cat $tmp
-    fi
+    local first=true
+    local f
+    for f in $files; do
+       local prefix=""
+       if [ $nfiles -ne 1 ]; then
+           prefix="$f:"
+       fi
+
+       # Don't reuse $inp, which may be generated using -H and thus contain a
+       # file prefix.
+       grep -n '^+' $f \
+           | grep -v ':+++' \
+           > $tmp
+
+       cat $tmp | while IFS= read -r line; do
+           local longline
+           # Filter out the line number prefix and the patch line modifier '+'
+           # to obtain the bare line, before we use expand.
+           longline=$(echo "$line" \
+               | sed 's/^[0-9]*:+//' \
+               | expand \
+               | awk '{ if (length($0) > 80) print $0}')
+           if [ "$longline" != "" ]; then
+               if $first; then
+                   printf "\n$msg\n"
+                   first=false
+               fi
+               echo "$prefix$line"
+           fi
+       done
+    done
 }
 
 col 'Lines should not exceed 80 characters.'