apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r1098185 - /apr/apr/branches/1.4.x/strings/apr_fnmatch.c
Date Sat, 30 Apr 2011 23:27:16 GMT
Author: wrowe
Date: Sat Apr 30 23:27:16 2011
New Revision: 1098185

URL: http://svn.apache.org/viewvc?rev=1098185&view=rev
Log:
Document a mess of apr_fnmatch_test bugs mostly due 
to the missing flags arg.

Modified:
    apr/apr/branches/1.4.x/strings/apr_fnmatch.c

Modified: apr/apr/branches/1.4.x/strings/apr_fnmatch.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/strings/apr_fnmatch.c?rev=1098185&r1=1098184&r2=1098185&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/strings/apr_fnmatch.c (original)
+++ apr/apr/branches/1.4.x/strings/apr_fnmatch.c Sat Apr 30 23:27:16 2011
@@ -211,40 +211,48 @@ static const char *rangematch(const char
 }
 
 
-/* This function is an Apache addition */
-/* return non-zero if pattern has any glob chars in it */
+/* This function is an Apache addition
+ * return non-zero if pattern has any glob chars in it
+ * @bug Function does not distinguish for FNM_PATHNAME mode, which renders
+ * a false positive for test[/]this (which is not a range, but 
+ * seperate test[ and ]this segments and no glob.)
+ * @bug Function does not distinguish for non-FNM_ESCAPE mode.
+ * @bug Function does not parse []] correctly
+ * Solution may be to use fnmatch_ch() to walk the patterns?
+ */
 APR_DECLARE(int) apr_fnmatch_test(const char *pattern)
 {
     int nesting;
 
     nesting = 0;
     while (*pattern) {
-	switch (*pattern) {
-	case '?':
-	case '*':
-	    return 1;
-
-	case '\\':
-	    if (*++pattern == '\0') {
-		return 0;
-	    }
-	    break;
-
-	case '[':	/* '[' is only a glob if it has a matching ']' */
-	    ++nesting;
-	    break;
-
-	case ']':
-	    if (nesting) {
-		return 1;
-	    }
-	    break;
-	}
-	++pattern;
+        switch (*pattern) {
+        case '?':
+        case '*':
+            return 1;
+
+        case '\\':
+            if (*++pattern == '\0') {
+                return 0;
+            }
+            break;
+
+        case '[':         /* '[' is only a glob if it has a matching ']' */
+            ++nesting;
+            break;
+
+        case ']':
+            if (nesting) {
+                return 1;
+            }
+            break;
+        }
+        ++pattern;
     }
     return 0;
 }
 
+
 /* Find all files matching the specified pattern */
 APR_DECLARE(apr_status_t) apr_match_glob(const char *pattern, 
                                          apr_array_header_t **result,



Mime
View raw message