ares: better error return on timeouts
[platform/upstream/curl.git] / lib / curl_fnmatch.c
index 410938a..e8108bb 100644 (file)
@@ -5,11 +5,11 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 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
- * are also available at http://curl.haxx.se/docs/copyright.html.
+ * are also available at https://curl.haxx.se/docs/copyright.html.
  *
  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  * copies of the Software, and permit persons to whom the Software is
  *
  ***************************************************************************/
 
+#include "curl_setup.h"
+
+#include <curl/curl.h>
+
 #include "curl_fnmatch.h"
-#include "setup.h"
+#include "curl_memory.h"
+
+/* The last #include file should be: */
+#include "memdebug.h"
 
 #define CURLFNM_CHARSET_LEN (sizeof(char) * 256)
 #define CURLFNM_CHSET_SIZE (CURLFNM_CHARSET_LEN + 15)
@@ -169,7 +176,7 @@ static int setcharset(unsigned char **p, unsigned char *charset)
         if(!something_found) {
           if(charset[CURLFNM_NEGATE]) {
             charset[c] = 1;
-            something_found = 1;
+            something_found = TRUE;
           }
           else
             charset[CURLFNM_NEGATE] = 1; /* negate charset */
@@ -215,7 +222,7 @@ static int setcharset(unsigned char **p, unsigned char *charset)
       }
       else if(c == '\\') {
         c = *(++(*p));
-        if(isprint(c)) {
+        if(ISPRINT(c)) {
           charset[c] = 1;
           (*p)++;
         }
@@ -280,7 +287,10 @@ static int setcharset(unsigned char **p, unsigned char *charset)
         state = CURLFNM_SCHS_DEFAULT;
       }
       else
-        return SETCHARSET_FAIL;
+        /* used 'goto fail' instead of 'return SETCHARSET_FAIL' to avoid a
+         * nonsense warning 'statement not reached' at end of the fnc when
+         * compiling on Solaris */
+        goto fail;
       break;
     case CURLFNM_SCHS_RIGHTBRLEFTBR:
       if(c == ']') {
@@ -294,6 +304,7 @@ static int setcharset(unsigned char **p, unsigned char *charset)
       break;
     }
   }
+fail:
   return SETCHARSET_FAIL;
 }
 
@@ -305,7 +316,7 @@ static int loop(const unsigned char *pattern, const unsigned char *string)
   unsigned char charset[CURLFNM_CHSET_SIZE] = { 0 };
   int rc = 0;
 
-  for (;;) {
+  for(;;) {
     switch(state) {
     case CURLFNM_LOOP_DEFAULT:
       if(*p == '*') {
@@ -401,6 +412,9 @@ static int loop(const unsigned char *pattern, const unsigned char *string)
   }
 }
 
+/*
+ * @unittest: 1307
+ */
 int Curl_fnmatch(void *ptr, const char *pattern, const char *string)
 {
   (void)ptr; /* the argument is specified by the curl_fnmatch_callback