diff options
author | Eric Blake <eblake@redhat.com> | 2014-09-04 13:11:04 -0600 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2014-09-04 17:51:06 -0600 |
commit | 5be8d47e025293fc079ba15cd6a3f7a0a6f5790c (patch) | |
tree | 56244bc157c0149411427a1e1838d516f0d7f62e /top | |
parent | c76f7ed9b7805797a628727d10dcc2ada9c3bdfc (diff) | |
download | gnulib-5be8d47e025293fc079ba15cd6a3f7a0a6f5790c.tar.gz |
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 <eblake@redhat.com>
Diffstat (limited to 'top')
-rw-r--r-- | top/maint.mk | 8 |
1 files changed, 8 insertions, 0 deletions
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. |