Lines Matching refs:string
59 * number of consecutive slashes within pattern and string will NOT match;
72 * path segment of string, and FNM_CASEFOLD to ignore alpha case.
81 * state of pattern and string (rewinding pattern and string repeatedly).
89 #include <string.h>
142 * Both pattern and string are **char to support pointer increment of arbitrary
145 static int fnmatch_ch(const char **pattern, const char **string, int flags)
173 ++*string;
190 if (classmatch(*pattern, **string, nocase, pattern)
216 if ((**string >= *startch) && (**string <= **pattern))
218 else if (nocase && (isupper((unsigned char)**string) ||
221 && (tolower((unsigned char)**string) >=
223 && (tolower((unsigned char)**string) <=
232 if ((**string == **pattern))
234 else if (nocase && (isupper((unsigned char)**string) ||
236 && (tolower((unsigned char)**string) ==
251 if (!**string || (slash && (**string == '/')))
261 if (**string == **pattern)
263 else if (nocase && (isupper((unsigned char)**string) ||
265 && (tolower((unsigned char)**string) ==
271 if (!**string || !**pattern || (slash && ((**string == '/') || (**pattern == '/'))))
276 ++*string;
281 int fnmatch(const char *pattern, const char *string, int flags)
301 while (*pattern && *string)
308 if (slash && (*pattern == '/') && (*string == '/')) {
310 ++string;
316 if ((flags & FNM_PERIOD) && (*string == '.'))
324 ++string;
327 /* Determine the end of string segment
332 strendseg = strchr(string, '/');
334 strendseg = strchr(string, '\0');
337 strendseg = strchr(string, '\0');
340 /* Allow pattern '*' to be consumed even with no remaining string to match
344 if ((string > strendseg)
345 || ((string == strendseg) && (*pattern != '*')))
361 else if (string < strendseg) { /* && (*pattern == '?') */
363 ++string;
365 else { /* (string >= strendseg) && (*pattern == '?') */
372 strstartseg = string;
385 /* Compare precisely this many trailing string chars,
389 if (string + matchlen > strendseg)
392 string = strendseg - matchlen;
399 /* Ensure at least this many trailing string chars remain
403 if (string + matchlen > strendseg)
427 /* Incrementally match string against the pattern
429 while (*pattern && (string < strendseg))
436 if (slash && ((*string == '/')
445 if (!fnmatch_ch(&pattern, &string, flags))
448 /* Failed to match, loop against next char offset of string segment
449 * until not enough string chars remain to match the fixed pattern
453 string = ++strstartseg;
454 if (string + matchlen > strendseg)
465 if (*string && !((slash || leading_dir) && (*string == '/')))
473 if (leading_dir && !*pattern && *string == '/')
477 /* Where both pattern and string are at EOS, declare success
479 if (!*string && !*pattern)
482 /* pattern didn't match to the end of string */