]> Savannah Git Hosting - gnulib.git/commitdiff
maintainer-makefile: add syntax check for useless ';;'
authorEric Blake <eblake@redhat.com>
Thu, 4 Sep 2014 19:11:04 +0000 (13:11 -0600)
committerEric Blake <eblake@redhat.com>
Thu, 4 Sep 2014 23:51:06 +0000 (17:51 -0600)
Most instances of ;; in C code are mistakes, where the second
semicolon is a no-op.  This rule tries to make it easy to flag
the typos occuring at the end of a statement.  It intentionally
does not flag for(;;) loops, and misses grammar problems in
comments if the problem occurs in the middle of the line.

Shell files (including configure.ac and Makefile.am, which can
contain shell snippets) are too likely to use case statements
where ;; is legitimate, so those are not scanned.

* top/maint.mk (sc_prohibit_double_semicolon): New rule.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
top/maint.mk

index a758d6bab97e9fc79e78181cffc9eeab937c20ba..d9c51262d5aa994e0b1d45c43dbe9e2d872790f4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-09-04  Eric Blake  <eblake@redhat.com>
+
+       maintainer-makefile: add syntax check for useless ';;'
+       * top/maint.mk (sc_prohibit_double_semicolon): New rule.
+
 2014-09-04  Paul Eggert  <eggert@cs.ucla.edu>
 
        pthread, pthread_sigmask, threadlib: port to Ubuntu 14.04
index e5a37829216500ae76d197e7c4e1c73221e18f46..1f5bddd56a628219858edb1ea680295f2c7ba8ca 100644 (file)
@@ -996,6 +996,14 @@ sc_prohibit_undesirable_word_seq:
          | grep -vE '$(ignore_undesirable_word_sequence_RE_)' | grep . \
          && { echo '$(ME): undesirable word sequence' >&2; exit 1; } || :
 
+# Except for shell files and for loops, double semicolon is probably a mistake
+sc_prohibit_double_semicolon:
+       @prohibit='; *;[        {} \]*(/[/*]|$$)'                       \
+       in_vc_files='\.[chly]$$'                                        \
+       exclude='\bfor *\(.*\)'                                         \
+       halt="Double semicolon detected"                                \
+         $(_sc_search_regexp)
+
 _ptm1 = use "test C1 && test C2", not "test C1 -''a C2"
 _ptm2 = use "test C1 || test C2", not "test C1 -''o C2"
 # Using test's -a and -o operators is not portable.