[PATCH 7/9] check-spacing: simplify keyword spacing check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/build-aux/check-spacing.pl b/build-aux/check-spacing.pl
index 962eabb..044cd25 100755
--- a/build-aux/check-spacing.pl
+++ b/build-aux/check-spacing.pl
@@ -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+\);?\s*$/) ||
-            $data =~ /\(\s+\S/) {
+            $data =~ /\((?!$)\s/) {
             print "Whitespace after '(' or before ')':\n";
             print "$file:$.: $line";
             $ret = 1;
-- 
2.7.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]