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:40:05 UTC
svn commit: r1103093 - /apr/apr/branches/1.4.x/strings/apr_fnmatch.c
Author: wrowe
Date: Sat May 14 12:40:05 2011
New Revision: 1103093
URL: http://svn.apache.org/viewvc?rev=1103093&view=rev
Log:
Further expression simplification for legibility.
Backport: r1103091
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=1103093&r1=1103092&r2=1103093&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/strings/apr_fnmatch.c (original)
+++ apr/apr/branches/1.4.x/strings/apr_fnmatch.c Sat May 14 12:40:05 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 '/',