You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by wr...@apache.org on 2011/05/14 14:39:30 UTC

svn commit: r1103091 - /apr/apr/trunk/strings/apr_fnmatch.c

Author: wrowe
Date: Sat May 14 12:39:30 2011
New Revision: 1103091

URL: http://svn.apache.org/viewvc?rev=1103091&view=rev
Log:
Further expression simplification for legibility.

Modified:
    apr/apr/trunk/strings/apr_fnmatch.c

Modified: apr/apr/trunk/strings/apr_fnmatch.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/strings/apr_fnmatch.c?rev=1103091&r1=1103090&r2=1103091&view=diff
==============================================================================
--- apr/apr/trunk/strings/apr_fnmatch.c (original)
+++ apr/apr/trunk/strings/apr_fnmatch.c Sat May 14 12:39:30 2011
@@ -209,7 +209,8 @@ APR_DECLARE(int) apr_fnmatch(const char 
 
     while (*pattern)
     {
-        /* Match balanced slashes, starting a new segment pattern
+        /* Pre-decode "\/" which has no special significance, and
+         * match balanced slashes, starting a new segment pattern
          */
         if (slash && escape && (*pattern == '\\') && (pattern[1] == '/'))
             ++pattern;
@@ -246,12 +247,17 @@ APR_DECLARE(int) apr_fnmatch(const char 
 
         /* Allow pattern '*' to be consumed even with no remaining string to match
          */
-        while (*pattern && !(slash && ((*pattern == '/')
-                                       || (escape && (*pattern == '\\')
-                                                  && (pattern[1] == '/'))))
-                        && ((string < strendseg)
-                            || ((*pattern == '*') && (string == strendseg))))
+        while (*pattern)
         {
+            if ((string > strendseg)
+                || ((string == strendseg) && (*pattern != '*')))
+                break;
+
+            if (slash && ((*pattern == '/')
+                           || (escape && (*pattern == '\\')
+                                      && (pattern[1] == '/'))))
+                break;
+
             /* Reduce groups of '*' and '?' to n '?' matches
              * followed by one '*' test for simplicity
              */
@@ -335,9 +341,10 @@ APR_DECLARE(int) apr_fnmatch(const char 
                 if (*pattern == '*')
                     break;
 
-                if (slash && ((*string == '/') || (*pattern == '/')
-                                               || (escape && (*pattern == '\\')
-                                                   && (pattern[1] == '/'))))
+                if (slash && ((*string == '/')
+                              || (*pattern == '/')
+                              || (escape && (*pattern == '\\')
+                                         && (pattern[1] == '/'))))
                     break;
 
                 /* Compare ch's (the pattern is advanced over "\/" to the '/',