diff options
author | William A. Rowe Jr <wrowe@apache.org> | 2011-05-14 12:39:30 +0000 |
---|---|---|
committer | William A. Rowe Jr <wrowe@apache.org> | 2011-05-14 12:39:30 +0000 |
commit | c68bdf65e4d216fe0d2b10a11cd73782ee681bbf (patch) | |
tree | 0c3396fe20098bb4b3d9ce67e54ea3820e36be91 /strings | |
parent | 051436251d284d3e2163f485157e9e1ea320de70 (diff) | |
download | apr-c68bdf65e4d216fe0d2b10a11cd73782ee681bbf.tar.gz |
Further expression simplification for legibility.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1103091 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'strings')
-rw-r--r-- | strings/apr_fnmatch.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/strings/apr_fnmatch.c b/strings/apr_fnmatch.c index 5e4b0d95f..7e5c47dbc 100644 --- a/strings/apr_fnmatch.c +++ b/strings/apr_fnmatch.c @@ -209,7 +209,8 @@ APR_DECLARE(int) apr_fnmatch(const char *pattern, const char *string, int flags) 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 *pattern, const char *string, int flags) /* 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 *pattern, const char *string, int flags) 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 '/',
|