]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
checksrc: improve the fopen() parser somewhat
authorDaniel Stenberg <daniel@haxx.se>
Sun, 3 Apr 2016 09:29:14 +0000 (11:29 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 3 Apr 2016 09:29:14 +0000 (11:29 +0200)
The quote scanner was too fragile, now look for a comma instead to find
the mode argument.

lib/checksrc.pl

index 0c16746216c1cf7c635a18f1972b06c4207a1ccf..f01eca3b30a6b1252b5b0c287b047abc74504d58 100755 (executable)
@@ -6,7 +6,7 @@
 #                            | (__| |_| |  _ <| |___
 #                             \___|\___/|_| \_\_____|
 #
-# Copyright (C) 2011 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 2011 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
@@ -51,7 +51,7 @@ sub checkwarn {
         $supressed++;
         return;
     }
-    
+
     my $w=$error?"error":"warning";
 
     if($w) {
@@ -212,7 +212,7 @@ sub scanfile {
                           "comma without following space");
             }
         }
-        
+
         # check for "} else"
         if($l =~ /^(.*)\} *else/) {
             checkwarn($line, length($1), $file, $l, "else after closing brace on same line");
@@ -234,11 +234,11 @@ sub scanfile {
         }
 
         # scan for use of non-binary fopen without the macro
-        if($l =~ /^(.*\W)fopen\s*\([^"]*\"([^"]*)/) {
+        if($l =~ /^(.*\W)fopen\s*\([^,]*, *\"([^"]*)/) {
             my $mode = $2;
             if($mode !~ /b/) {
                 checkwarn($line, length($1), $file, $l,
-                          "use of non-binary fopen without FOPEN_* macro");
+                          "use of non-binary fopen without FOPEN_* macro: $mode");
             }
         }