diff options
author | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-14 12:40:05 +0000 |
---|---|---|
committer | wrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-14 12:40:05 +0000 |
commit | 78a27bea103bff625378a0de7b51142642d70399 (patch) | |
tree | 2289b627c031f767cae4474b98e78db7866e6efd | |
parent | 5df0de3d9d00bcedbfd2de8e9864c40463d74aa1 (diff) | |
download | libapr-78a27bea103bff625378a0de7b51142642d70399.tar.gz |
Further expression simplification for legibility.
Backport: r1103091
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.4.x@1103093 13f79535-47bb-0310-9956-ffa450edef68
-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 eb6aeb01a..1773105d4 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 '/', |