]> granicus.if.org Git - curl/commitdiff
checksrc: detect and warn for multiple spaces
authorDaniel Stenberg <daniel@haxx.se>
Tue, 12 Sep 2017 07:28:37 +0000 (09:28 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 12 Sep 2017 07:50:24 +0000 (09:50 +0200)
lib/checksrc.pl

index 535e3d9f5ce18f8b61e310696b6954c5e1fbe16b..c1f74bebf32e8fc12f298f0b83297ce892cf3def 100755 (executable)
@@ -62,6 +62,7 @@ my %warnings = (
     'EQUALSNOSPACE'    => 'equals sign without following space',
     'NOSPACEEQUALS'    => 'equals sign without preceeding space',
     'SEMINOSPACE'      => 'semicolon without following space',
+    'MULTISPACE'       => 'multiple spaces used when not suitable',
     );
 
 sub readwhitelist {
@@ -563,6 +564,18 @@ sub scanfile {
                       "no space after semilcolon");
         }
 
+        # check for more than one consecutive space before open brace or
+        # question mark. Skip lines containing strings since they make it hard
+        # due to artificially getting multiple spaces
+        if(($l eq $nostr) &&
+           $nostr =~ /^(.*(\S)) + [{?]/i) {
+            checkwarn("MULTISPACE",
+                      $line, length($1)+1, $file, $ol,
+                      "multiple space");
+            print STDERR "L: $l\n";
+            print STDERR "nostr: $nostr\n";
+        }
+
         $line++;
         $prevl = $ol;
     }