]> xenbits.xensource.com Git - libvirt.git/commitdiff
check-spacing: use non-capturing groups
authorJán Tomko <jtomko@redhat.com>
Tue, 14 Jun 2016 15:13:13 +0000 (17:13 +0200)
committerJán Tomko <jtomko@redhat.com>
Wed, 15 Jun 2016 13:48:33 +0000 (15:48 +0200)
build-aux/check-spacing.pl

index becdbe9332bf43e0624b025eeaea4ec72777a8ac..f4fedbcea458fd736ea1a1c12a79e40dbe844b5a 100755 (executable)
@@ -43,7 +43,7 @@ foreach my $file (@ARGV) {
         $data =~ s/'[";,=]'/'X'/g;
 
         # Kill any quoted strings
-        $data =~ s,"([^\\\"]|\\.)*","XXX",g;
+        $data =~ s,"(?:[^\\\"]|\\.)*","XXX",g;
 
         # Kill any C++ style comments
         $data =~ s,//.*$,//,;
@@ -91,8 +91,8 @@ foreach my $file (@ARGV) {
             my $kw = $1;
 
             # Allow space after keywords only
-            if ($kw =~ /^(if|for|while|switch|return)$/) {
-                $tmpdata =~ s/($kw\s\()/XXX(/;
+            if ($kw =~ /^(?:if|for|while|switch|return)$/) {
+                $tmpdata =~ s/(?:$kw\s\()/XXX(/;
             } else {
                 print "Whitespace after non-keyword:\n";
                 print "$file:$.: $line";
@@ -102,7 +102,7 @@ foreach my $file (@ARGV) {
         }
 
         # Require whitespace immediately after keywords
-        if ($data =~ /\b(if|for|while|switch|return)\(/) {
+        if ($data =~ /\b(?:if|for|while|switch|return)\(/) {
             print "No whitespace after keyword:\n";
             print "$file:$.: $line";
             $ret = 1;