From: Eric Blake Date: Thu, 4 Sep 2014 19:11:04 +0000 (-0600) Subject: maintainer-makefile: add syntax check for useless ';;' X-Git-Tag: v1.0~7306 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=5be8d47e025293fc079ba15cd6a3f7a0a6f5790c;p=gnulib.git maintainer-makefile: add syntax check for useless ';;' 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 --- diff --git a/ChangeLog b/ChangeLog index a758d6bab9..d9c51262d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-09-04 Eric Blake + + maintainer-makefile: add syntax check for useless ';;' + * top/maint.mk (sc_prohibit_double_semicolon): New rule. + 2014-09-04 Paul Eggert pthread, pthread_sigmask, threadlib: port to Ubuntu 14.04 diff --git a/top/maint.mk b/top/maint.mk index e5a3782921..1f5bddd56a 100644 --- a/top/maint.mk +++ b/top/maint.mk @@ -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.