]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add style checks to check_GNU_style.sh.
authorMartin Sebor <msebor@redhat.com>
Mon, 7 Mar 2016 17:01:44 +0000 (17:01 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Mon, 7 Mar 2016 17:01:44 +0000 (10:01 -0700)
gcc/contrib/ChangeLog:
2016-03-07  Martin Sebor  <msebor@redhat.com>

* check_GNU_style.sh (color): New global variable.
Add checks for trailing operators and spaces before left brackets.
Tightened up a check for a trailing left curly brace.
(g, ag, vg): Use color.
(col): Don't complain about excessively long lines with DejaGnu
directives.

From-SVN: r234035

contrib/ChangeLog
contrib/check_GNU_style.sh

index e40db53ed64a15813b7d086368b1830f31dc96f0..54f9d5e72b225faf559040f4756b7c735c9f6343 100644 (file)
@@ -1,3 +1,12 @@
+2016-03-07  Martin Sebor  <msebor@redhat.com>
+
+       * check_GNU_style.sh (color): New global variable.
+       Add checks for trailing operators and spaces before left brackets.
+       Tightened up a check for a trailing left curly brace.
+       (g, ag, vg): Use color.
+       (col): Don't complain about excessively long lines with DejaGnu
+       directives.
+
 2016-03-06  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>
 
        * mklog: Look for the ChangeLog file in $cwd.
index ac54ed070e73a2b931d348c216faa21b2070ecd9..fbf6cb2465d27009ee598c31a1166fd1474269f7 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 # Checks some of the GNU style formatting rules in a set of patches.
-# Copyright (C) 2010, 2012  Free Software Foundation, Inc.
+# Copyright (C) 2010, 2012, 2016  Free Software Foundation, Inc.
 # Contributed by Sebastian Pop <sebastian.pop@amd.com>
 
 # This program is free software; you can redistribute it and/or modify
 # GNU General Public License for more details.
 
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+# along with this program; if not, see the file COPYING3.  If not,
+# see <http://www.gnu.org/licenses/>.
+
+# Set to empty in the environment to override.
+: ${color:---color=always}
 
 usage() {
     cat <<EOF
@@ -100,7 +103,7 @@ g (){
 
     local found=false
     cat $inp \
-       | egrep --color=always -- "$arg" \
+       | egrep $color -- "$arg" \
        > "$tmp" && found=true
 
     if $found; then
@@ -117,8 +120,8 @@ ag (){
 
     local found=false
     cat $inp \
-       | egrep --color=always -- "$arg1" \
-       | egrep --color=always -- "$arg2" \
+       | egrep $color -- "$arg1" \
+       | egrep $color -- "$arg2" \
        > "$tmp" && found=true
 
     if $found; then
@@ -136,7 +139,7 @@ vg (){
     local found=false
     cat $inp \
        | egrep -v -- "$varg" \
-       | egrep --color=always -- "$arg" \
+       | egrep $color -- "$arg" \
        > "$tmp" && found=true
 
     if $found; then
@@ -171,10 +174,11 @@ 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 '{ \
+           | awk '$0 !~ /{[[:space:]]*dg-(error|warning|message)[[:space:]]/ { \
                     if (length($0) > 80) \
                       printf "%s\033[1;31m%s\033[0m\n", \
                              substr($0,1,80), \
@@ -201,6 +205,7 @@ col (){
     done
 }
 
+
 col 'Lines should not exceed 80 characters.'
 
 g 'Blocks of 8 spaces should be replaced with tabs.' \
@@ -221,13 +226,20 @@ g 'Dot, space, space, end of comment.' \
 g 'Sentences should end with a dot.  Dot, space, space, end of the comment.' \
     '[[:alnum:]][[:blank:]]*\*/'
 
-vg 'There should be exactly one space between function name and parentheses.' \
+vg 'There should be exactly one space between function name and parenthesis.' \
     '\#define' \
     '[[:alnum:]]([[:blank:]]{2,})?\('
 
-g 'There should be no space before closing parentheses.' \
+g 'There should be no space before a left square bracket.' \
+   '[[:alnum:]][[:blank:]]+\['
+
+g 'There should be no space before closing parenthesis.' \
     '[[:graph:]][[:blank:]]+\)'
 
-ag 'Braces should be on a separate line.' \
-    '\{' \
-    'if[[:blank:]]\(|while[[:blank:]]\(|switch[[:blank:]]\('
+# This will give false positives for C99 compound literals.
+g 'Braces should be on a separate line.' \
+    '(\)|else)[[:blank:]]*{'
+
+# Does this apply to definition of aggregate objects?
+g 'Trailing operator.' \
+  '(([^a-zA-Z_]\*)|([-%<=&|^?])|([^*]/)|([^:][+]))$'