diff options
author | Daniel Stenberg <daniel@haxx.se> | 2016-12-13 23:34:59 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2016-12-13 23:39:11 +0100 |
commit | b228d2952b6762b5c9b851fba0cf391e80c6761a (patch) | |
tree | d8d52d61b047a31b1c51851f1b48c4dc9cfcd1f4 /lib/checksrc.pl | |
parent | 5fad800efdf1cb84f863f3634b85c898fb3d0d66 (diff) | |
download | curl-b228d2952b6762b5c9b851fba0cf391e80c6761a.tar.gz |
checksrc: stricter no-space-before-paren enforcement
In order to make the code style more uniform everywhere
Diffstat (limited to 'lib/checksrc.pl')
-rwxr-xr-x | lib/checksrc.pl | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/checksrc.pl b/lib/checksrc.pl index 479a5dbde..022b193aa 100755 --- a/lib/checksrc.pl +++ b/lib/checksrc.pl @@ -243,6 +243,12 @@ sub checksrc { } } +sub nostrings { + my ($str) = @_; + $str =~ s/\".*\"//g; + return $str; +} + sub scanfile { my ($file) = @_; @@ -329,11 +335,21 @@ sub scanfile { $line, length($1), $file, $l, "\/\/ comment"); } - # check spaces after for/if/while - if($l =~ /^(.*)(for|if|while) \(/) { + my $nostr = nostrings($l); + # check spaces after for/if/while/function call + if($nostr =~ /^(.*)(for|if|while| ([a-zA-Z0-9_]+)) \((.)/) { if($1 =~ / *\#/) { # this is a #if, treat it differently } + elsif($3 eq "return") { + # return must have a space + } + elsif($4 eq "*") { + # (* beginning makes the space OK! + } + elsif($1 =~ / *typedef/) { + # typedefs can use space-paren + } else { checkwarn("SPACEBEFOREPAREN", $line, length($1)+length($2), $file, $l, "$2 with space"); |