• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/apr-32/apr/apr/strings/

Lines Matching refs:pattern

22  * Filename pattern matches defined in section 2.13, "Pattern Matching Notation"
30 * number of consecutive slashes within pattern and string will NOT match;
49 * state of pattern and string (rewinding pattern and string repeatedly).
71 * Both pattern and string are **char to support pointer increment of arbitrary
74 static APR_INLINE int fnmatch_ch(const char **pattern, const char **string, int flags)
76 const char * const mismatch = *pattern;
84 if (**pattern == '[')
86 ++*pattern;
89 negate = ((**pattern == '!') || (**pattern == '^'));
91 ++*pattern;
93 /* ']' is an ordinary character at the start of the range pattern */
94 if (**pattern == ']')
97 while (**pattern)
99 if (**pattern == ']') {
100 ++*pattern;
106 if (escape && (**pattern == '\\')) {
107 ++*pattern;
110 if (!**pattern)
115 if (slash && (**pattern == '/'))
123 if (((*pattern)[1] == '-') && ((*pattern)[2] != ']'))
125 startch = *pattern;
126 *pattern += (escape && ((*pattern)[2] == '\\')) ? 3 : 2;
128 /* NOT a properly balanced [expr] pattern, EOS terminated
129 * or ranges containing a slash in FNM_PATHNAME mode pattern
132 if (!**pattern || (slash && (**pattern == '/')))
136 if ((**string >= *startch) && (**string <= **pattern))
139 || isupper(**pattern))
141 && (tolower(**string) <= tolower(**pattern)))
144 ++*pattern;
149 if ((**string == **pattern))
151 else if (nocase && (isupper(**string) || isupper(**pattern))
152 && (tolower(**string) == tolower(**pattern)))
155 ++*pattern;
158 /* NOT a properly balanced [expr] pattern; Rewind
161 *pattern = mismatch;
164 else if (**pattern == '?') {
165 /* Optimize '?' match before unescaping **pattern */
171 else if (escape && (**pattern == '\\') && (*pattern)[1]) {
172 ++*pattern;
176 if (**string == **pattern)
178 else if (nocase && (isupper(**string) || isupper(**pattern))
179 && (tolower(**string) == tolower(**pattern)))
184 if (!**string || !**pattern || (slash && ((**string == '/') || (**pattern == '/'))))
188 ++*pattern;
194 APR_DECLARE(int) apr_fnmatch(const char *pattern, const char *string, int flags)
210 if (*pattern == '*')
213 while (*pattern && *string)
216 * match balanced slashes, starting a new segment pattern
218 if (slash && escape && (*pattern == '\\') && (pattern[1] == '/'))
219 ++pattern;
220 if (slash && (*pattern == '/') && (*string == '/')) {
221 ++pattern;
230 if (*pattern == '.')
231 ++pattern;
232 else if (escape && (*pattern == '\\') && (pattern[1] == '.'))
233 pattern += 2;
252 /* Allow pattern '*' to be consumed even with no remaining string to match
254 while (*pattern)
257 || ((string == strendseg) && (*pattern != '*')))
260 if (slash && ((*pattern == '/')
261 || (escape && (*pattern == '\\')
262 && (pattern[1] == '/'))))
268 for (wild = 0; ((*pattern == '*') || (*pattern == '?')); ++pattern)
270 if (*pattern == '*') {
273 else if (string < strendseg) { /* && (*pattern == '?') */
277 else { /* (string >= strendseg) && (*pattern == '?') */
285 mismatch = pattern;
287 /* Count fixed (non '*') char matches remaining in pattern
290 for (matchptr = pattern, matchlen = 0; 1; ++matchlen)
322 /* Skip forward in pattern by a single character match
339 /* Incrementally match string against the pattern
341 while (*pattern && (string < strendseg))
343 /* Success; begin a new wild pattern search
345 if (*pattern == '*')
349 || (*pattern == '/')
350 || (escape && (*pattern == '\\')
351 && (pattern[1] == '/'))))
354 /* Compare ch's (the pattern is advanced over "\/" to the '/',
357 if (!fnmatch_ch(&pattern, &string, flags))
361 * until not enough string chars remain to match the fixed pattern
369 pattern = mismatch;
380 if (*pattern && !(slash && ((*pattern == '/')
381 || (escape && (*pattern == '\\')
382 && (pattern[1] == '/')))))
386 /* Where both pattern and string are at EOS, declare success
388 if (!*string && !*pattern)
391 /* pattern didn't match to the end of string */
397 * return non-zero if pattern has any glob chars in it
405 APR_DECLARE(int) apr_fnmatch_test(const char *pattern)
410 while (*pattern) {
411 switch (*pattern) {
417 if (*++pattern == '\0') {
432 ++pattern; }
437 /* Find all files matching the specified pattern */
438 APR_DECLARE(apr_status_t) apr_match_glob(const char *pattern,
448 * directories off the pattern, but there is no portable way to do that.
451 * screw up on unix if the pattern is something like "foo\.*" That '\'
456 char *idx = strrchr(pattern, '/');
459 idx = strrchr(pattern, '\\');
465 path = apr_pstrndup(p, pattern, idx - pattern);
466 pattern = idx + 1;
476 if (apr_fnmatch(pattern, finfo.name, 0) == APR_SUCCESS) {