]> xenbits.xensource.com Git - libvirt.git/commitdiff
check-spacing: rewrite regex for checking the closing parenthesis
authorJán Tomko <jtomko@redhat.com>
Tue, 14 Jun 2016 16:27:24 +0000 (18:27 +0200)
committerJán Tomko <jtomko@redhat.com>
Wed, 15 Jun 2016 13:47:32 +0000 (15:47 +0200)
Instead of matching multiple characters before the parenthesis,
only check for a single whitespace, which is much less cpu-intensive.

This only matches a few dozen of places where they are on an separate
line, filter out those with a separate regex.

build-aux/check-spacing.pl

index d693fbe572298eabb3f8d7b7d6ccd621e2e7e1a6..7c5bbf9e51cf1011cdf9fe82d94d0b0d84e7ea68 100755 (executable)
@@ -118,7 +118,9 @@ foreach my $file (@ARGV) {
         }
 
         # Forbid whitespace following ( or prior to )
-        if ($data =~ /\S\s+\)/ ||
+        # but allow whitespace before ) on a single line
+        # (optionally followed by a semicolon)
+        if (($data =~ /\s\)/ && not $data =~ /^\s+\);?$/) ||
             $data =~ /\(\s+\S/) {
             print "Whitespace after '(' or before ')':\n";
             print "$file:$.: $line";