From 9395999543eaad251d61a83b50f461cc29884cd2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 17 Mar 2015 13:41:49 +0100 Subject: checksrc: use space after comma --- lib/checksrc.pl | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'lib/checksrc.pl') diff --git a/lib/checksrc.pl b/lib/checksrc.pl index c4174709b..cd4314b51 100755 --- a/lib/checksrc.pl +++ b/lib/checksrc.pl @@ -154,6 +154,38 @@ sub scanfile { "return without space before paren"); } } + + # check for comma without space + if($l =~ /^(.*),[^ \n]/) { + my $pref=$1; + my $ign=0; + if($pref =~ / *\#/) { + # this is a #if, treat it differently + $ign=1; + } + elsif($pref =~ /\/\*/) { + # this is a comment + $ign=1; + } + elsif($pref =~ /[\"\']/) { + $ign = 1; + # There is a quote here, figure out whether the comma is + # within a string or '' or not. + if($pref =~ /\"/) { + # withing a string + } + elsif($pref =~ /\'$/) { + # a single letter + } + else { + $ign = 0; + } + } + if(!$ign) { + checkwarn($line, length($pref)+1, $file, $l, + "comma without following space"); + } + } # check for "} else" if($l =~ /^(.*)\} *else/) { -- cgit v1.2.3