apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r1103092 - /apr/apr/branches/1.5.x/strings/apr_fnmatch.c
Date Sat, 14 May 2011 12:39:53 GMT
Author: wrowe
Date: Sat May 14 12:39:52 2011
New Revision: 1103092

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

Backport: r1103091

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

Modified: apr/apr/branches/1.5.x/strings/apr_fnmatch.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.5.x/strings/apr_fnmatch.c?rev=1103092&r1=1103091&r2=1103092&view=diff
==============================================================================
--- apr/apr/branches/1.5.x/strings/apr_fnmatch.c (original)
+++ apr/apr/branches/1.5.x/strings/apr_fnmatch.c Sat May 14 12:39:52 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 '/',



Mime
View raw message