check-spacing: rewrite whitespace check before (semi)colon

Instead of matching multiple characters, match any occurrence
preceded by a single whitespace and handle the exceptions
later.
This commit is contained in:
Ján Tomko 2016-06-14 18:13:42 +02:00
parent 4e1a7dbb31
commit b953e163ad

View File

@ -135,10 +135,13 @@ foreach my $file (@ARGV) {
# errno == EINTR)
# ;
#
if ($data =~ /[^;\s]\s+[;,]/) {
print "Whitespace before (semi)colon:\n";
print "$file:$.: $line";
$ret = 1;
if ($data =~ /\s[;,]/) {
unless ($data =~ /\S; ; / ||
$data =~ /^\s+;/) {
print "Whitespace before (semi)colon:\n";
print "$file:$.: $line";
$ret = 1;
}
}
# Require EOL, macro line continuation, or whitespace after ";".