]> xenbits.xensource.com Git - libvirt.git/commitdiff
check-spacing: simplify keyword spacing check
authorJán Tomko <jtomko@redhat.com>
Tue, 14 Jun 2016 16:30:30 +0000 (18:30 +0200)
committerJán Tomko <jtomko@redhat.com>
Wed, 15 Jun 2016 13:48:32 +0000 (15:48 +0200)
We do not need a separate check forbidding whitespace
after the opening parenthesis after a keyword -
we forbid it after all of them.

The only allowed whitespace after an opening parenthesis
is a newline, tune the regex to reflect that.

build-aux/check-spacing.pl

index 7c5bbf9e51cf1011cdf9fe82d94d0b0d84e7ea68..a0fb1109dea489256abacb150705f5f9bdf942e5 100755 (executable)
@@ -101,10 +101,8 @@ foreach my $file (@ARGV) {
             }
         }
 
-        # Require whitespace immediately after keywords,
-        # but none after the opening bracket
-        if ($data =~ /\b(if|for|while|switch|return)\(/ ||
-            $data =~ /\b(if|for|while|switch|return)\s+\(\s/) {
+        # Require whitespace immediately after keywords
+        if ($data =~ /\b(if|for|while|switch|return)\(/) {
             print "No whitespace after keyword:\n";
             print "$file:$.: $line";
             $ret = 1;
@@ -121,7 +119,7 @@ foreach my $file (@ARGV) {
         # but allow whitespace before ) on a single line
         # (optionally followed by a semicolon)
         if (($data =~ /\s\)/ && not $data =~ /^\s+\);?$/) ||
-            $data =~ /\(\s+\S/) {
+            $data =~ /\((?!$)\s/) {
             print "Whitespace after '(' or before ')':\n";
             print "$file:$.: $line";
             $ret = 1;