diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-06-23 15:51:48 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-06-23 15:54:01 -0400 |
commit | a6688c574e569a2a018038414198ab440344ba95 (patch) | |
tree | 01d47f7c81d3ff01166db55c61dd5637262bc297 /contrib | |
parent | ce44346aa5b4dddf37aff992755ef472d0d1f5a2 (diff) | |
download | tor-a6688c574e569a2a018038414198ab440344ba95.tar.gz tor-a6688c574e569a2a018038414198ab440344ba95.zip |
Catch a few more K&R violations with make check-spaces
We now catch bare {s that should be on the previous line with a do,
while, if, or for, and elses that should share a line with their
preceding }.
That is,
if (foo)
{
and
if (foo) {
...
}
else
are now detected.
We should think about maybe making Tor uncrustify-clean some day,
but configuring uncrustify is an exercise in bizarreness, and
reformatting huge gobs of Tor is always painful.
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/checkSpace.pl | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/contrib/checkSpace.pl b/contrib/checkSpace.pl index a18df99b16..682dbced00 100755 --- a/contrib/checkSpace.pl +++ b/contrib/checkSpace.pl @@ -32,10 +32,18 @@ for $fn (@ARGV) { if ($C && /\s(?:if|while|for|switch)\(/) { print " KW(:$fn:$.\n"; } - ## Warn about #else #if instead of #elif. + ## Warn about #else #if instead of #elif. if (($lastline =~ /^\# *else/) and ($_ =~ /^\# *if/)) { print " #else#if:$fn:$.\n"; } + ## Warn about some K&R violations + if (/^\s+\{/ and $lastline =~ /^\s*(if|while|for|else if)/ and + $lastline !~ /\{$/) { + print "non-K&R {:$fn:$.\n"; + } + if (/^\s*else/ and $lastline =~ /\}$/) { + print " }\\nelse:$fn:$.\n"; + } $lastline = $_; ## Warn about unnecessary empty lines. if ($lastnil && /^\s*}\n/) { |