]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
checkSpace.pl: Use a data structure for a list of non-function names
authorNick Mathewson <nickm@torproject.org>
Fri, 10 Jan 2020 13:31:35 +0000 (08:31 -0500)
committerNick Mathewson <nickm@torproject.org>
Thu, 6 Feb 2020 19:33:05 +0000 (14:33 -0500)
scripts/maint/checkSpace.pl

index 3080fafd3e2b1bade21bd92f44e03a73938396f5..cc77d8d5be35ef1022ce4926e85a351a040a7607 100755 (executable)
@@ -23,6 +23,12 @@ if ($ARGV[0] =~ /^-/) {
     $C = ($lang eq '-C');
 }
 
+# hashmap of things where we allow spaces between them and (.
+our %allow_space_after= map {$_, 1} qw{
+    if while for switch return int unsigned elsif WINAPI
+    void __attribute__ op size_t double uint64_t workqueue_reply_t bool
+};
+
 our %basenames = ();
 
 our %guardnames = ();
@@ -177,12 +183,7 @@ for my $fn (@ARGV) {
             #   (Don't put a space between the name of a function and its
             #   arguments.)
             if (/(\w+)\s\(([A-Z]*)/) {
-                if ($1 ne "if" and $1 ne "while" and $1 ne "for" and
-                    $1 ne "switch" and $1 ne "return" and $1 ne "int" and
-                    $1 ne "elsif" and $1 ne "WINAPI" and $2 ne "WINAPI" and
-                    $1 ne "void" and $1 ne "__attribute__" and $1 ne "op" and
-                    $1 ne "size_t" and $1 ne "double" and $1 ne "uint64_t" and
-                    $1 ne "workqueue_reply_t" and $1 ne "bool") {
+                if (! $allow_space_after{$1} && $2 ne 'WINAPI') {
                     msg "fn ():$fn:$.\n";
                 }
             }