Lines Matching refs:pat
49 static int pat_next(const char *pat, size_t m, size_t *step, int flags)
52 if (!m || !*pat) {
57 if (pat[0]=='\\' && pat[1] && !(flags & FNM_NOESCAPE)) {
59 pat++;
63 if (pat[0]=='[') {
65 if (k<m) if (pat[k] == '^' || pat[k] == '!') k++;
66 if (k<m) if (pat[k] == ']') k++;
67 for (; k<m && pat[k] && pat[k]!=']'; k++) {
68 if (k+1<m && pat[k+1] && pat[k]=='[' && (pat[k+1]==':' || pat[k+1]=='.' || pat[k+1]=='=')) {
69 int z = pat[k+1];
71 if (k<m && pat[k]) k++;
72 while (k<m && pat[k] && (pat[k-1]!=z || pat[k]!=']')) k++;
73 if (k==m || !pat[k]) break;
76 if (k==m || !pat[k]) {
83 if (pat[0] == '*')
85 if (pat[0] == '?')
88 if (pat[0] >= 128U) {
90 int k = mbtowc(&wc, pat, m);
98 return pat[0];
163 static int fnmatch_internal(const char *pat, size_t m, const char *str, size_t n, int flags)
171 if (*str == '.' && *pat != '.')
175 switch ((c = pat_next(pat, m, &pinc, flags))) {
179 pat++;
190 if (!match_bracket(pat, k, kfold))
195 pat+=pinc;
202 /* Compute real pat length if it was initially unknown/-1 */
203 m = strnlen(pat, m);
204 endpat = pat + m;
206 /* Find the last * in pat and count chars needed after it */
207 for (p=ptail=pat; p<endpat; p+=pinc) {
221 /* Past this point we need not check for UNMATCHABLE in pat,
222 * because all of pat has already been parsed once. */
239 /* Check that the pat and str tails match */
263 while (pat<endpat) {
264 p = pat;
271 pat = p;
298 int fnmatch(const char *pat, const char *str, int flags)
305 for (p=pat; (c=pat_next(p, -1, &inc, flags))!=END && c!='/'; p+=inc);
308 if (fnmatch_internal(pat, p-pat, str, s-str, flags))
312 pat = p+inc;
316 if (!fnmatch_internal(pat, -1, str, s-str, flags))
320 return fnmatch_internal(pat, -1, str, -1, flags);