[tor-commits] [tor/master] checkSpace.pl: Use a data structure for a list of non-function names

nickm at torproject.org nickm at torproject.org
Thu Mar 5 13:25:48 UTC 2020


commit bfa760738521715f8c858de7584fd08cd90cb538
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri Jan 10 08:31:35 2020 -0500

    checkSpace.pl: Use a data structure for a list of non-function names
---
 scripts/maint/checkSpace.pl | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/scripts/maint/checkSpace.pl b/scripts/maint/checkSpace.pl
index 3080fafd3..cc77d8d5b 100755
--- a/scripts/maint/checkSpace.pl
+++ b/scripts/maint/checkSpace.pl
@@ -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";
                 }
             }





More information about the tor-commits mailing list