diff options
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"); |