1 /* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2004
2 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 /* Match STRING against the filename pattern PATTERN, returning zero if
19 it matches, nonzero if not. */
20 static int EXT (INT opt
, const CHAR
*pattern
, const CHAR
*string
,
21 const CHAR
*string_end
, bool no_leading_period
, int flags
)
23 static const CHAR
*END (const CHAR
*patternp
) internal_function
;
27 FCT (const CHAR
*pattern
, const CHAR
*string
, const CHAR
*string_end
,
28 bool no_leading_period
, int flags
)
30 register const CHAR
*p
= pattern
, *n
= string
;
33 # if WIDE_CHAR_VERSION
34 const char *collseq
= (const char *)
35 _NL_CURRENT(LC_COLLATE
, _NL_COLLATE_COLLSEQWC
);
37 const UCHAR
*collseq
= (const UCHAR
*)
38 _NL_CURRENT(LC_COLLATE
, _NL_COLLATE_COLLSEQMB
);
42 while ((c
= *p
++) != L('\0'))
44 bool new_no_leading_period
= false;
50 if (__builtin_expect (flags
& FNM_EXTMATCH
, 0) && *p
== '(')
54 res
= EXT (c
, p
, n
, string_end
, no_leading_period
,
62 else if (*n
== L('/') && (flags
& FNM_FILE_NAME
))
64 else if (*n
== L('.') && no_leading_period
)
69 if (!(flags
& FNM_NOESCAPE
))
73 /* Trailing \ loses. */
77 if (n
== string_end
|| FOLD ((UCHAR
) *n
) != c
)
82 if (__builtin_expect (flags
& FNM_EXTMATCH
, 0) && *p
== '(')
86 res
= EXT (c
, p
, n
, string_end
, no_leading_period
,
92 if (n
!= string_end
&& *n
== L('.') && no_leading_period
)
95 for (c
= *p
++; c
== L('?') || c
== L('*'); c
= *p
++)
97 if (*p
== L('(') && (flags
& FNM_EXTMATCH
) != 0)
99 const CHAR
*endp
= END (p
);
102 /* This is a pattern. Skip over it. */
110 /* A ? needs to match one character. */
112 /* There isn't another character; no match. */
114 else if (*n
== L('/')
115 && __builtin_expect (flags
& FNM_FILE_NAME
, 0))
116 /* A slash does not match a wildcard under
120 /* One character of the string is consumed in matching
121 this ? wildcard, so *??? won't match if there are
122 less than three characters. */
128 /* The wildcard(s) is/are the last element of the pattern.
129 If the name is a file name and contains another slash
130 this means it cannot match, unless the FNM_LEADING_DIR
133 int result
= (flags
& FNM_FILE_NAME
) == 0 ? 0 : FNM_NOMATCH
;
135 if (flags
& FNM_FILE_NAME
)
137 if (flags
& FNM_LEADING_DIR
)
141 if (MEMCHR (n
, L('/'), string_end
- n
) == NULL
)
152 endp
= MEMCHR (n
, (flags
& FNM_FILE_NAME
) ? L('/') : L('\0'),
158 || (__builtin_expect (flags
& FNM_EXTMATCH
, 0) != 0
159 && (c
== L('@') || c
== L('+') || c
== L('!'))
162 int flags2
= ((flags
& FNM_FILE_NAME
)
163 ? flags
: (flags
& ~FNM_PERIOD
));
164 bool no_leading_period2
= no_leading_period
;
166 for (--p
; n
< endp
; ++n
, no_leading_period2
= false)
167 if (FCT (p
, n
, string_end
, no_leading_period2
, flags2
)
171 else if (c
== L('/') && (flags
& FNM_FILE_NAME
))
173 while (n
< string_end
&& *n
!= L('/'))
175 if (n
< string_end
&& *n
== L('/')
176 && (FCT (p
, n
+ 1, string_end
, flags
& FNM_PERIOD
, flags
)
182 int flags2
= ((flags
& FNM_FILE_NAME
)
183 ? flags
: (flags
& ~FNM_PERIOD
));
184 int no_leading_period2
= no_leading_period
;
186 if (c
== L('\\') && !(flags
& FNM_NOESCAPE
))
189 for (--p
; n
< endp
; ++n
, no_leading_period2
= false)
190 if (FOLD ((UCHAR
) *n
) == c
191 && (FCT (p
, n
, string_end
, no_leading_period2
, flags2
)
197 /* If we come here no match is possible with the wildcard. */
202 /* Nonzero if the sense of the character class is inverted. */
207 if (posixly_correct
== 0)
208 posixly_correct
= getenv ("POSIXLY_CORRECT") != NULL
? 1 : -1;
213 if (*n
== L('.') && no_leading_period
)
216 if (*n
== L('/') && (flags
& FNM_FILE_NAME
))
217 /* `/' cannot be matched. */
220 not = (*p
== L('!') || (posixly_correct
< 0 && *p
== L('^')));
224 fn
= FOLD ((UCHAR
) *n
);
229 if (!(flags
& FNM_NOESCAPE
) && c
== L('\\'))
233 c
= FOLD ((UCHAR
) *p
);
239 else if (c
== L('[') && *p
== L(':'))
241 /* Leave room for the null. */
242 CHAR str
[CHAR_CLASS_MAX_LENGTH
+ 1];
244 #if defined _LIBC || WIDE_CHAR_SUPPORT
247 const CHAR
*startp
= p
;
251 if (c1
== CHAR_CLASS_MAX_LENGTH
)
252 /* The name is too long and therefore the pattern
257 if (c
== L(':') && p
[1] == L(']'))
262 if (c
< L('a') || c
>= L('z'))
264 /* This cannot possibly be a character class name.
265 Match it as a normal range. */
274 #if defined _LIBC || WIDE_CHAR_SUPPORT
275 wt
= IS_CHAR_CLASS (str
);
277 /* Invalid character class name. */
280 # if defined _LIBC && ! WIDE_CHAR_VERSION
281 /* The following code is glibc specific but does
282 there a good job in speeding up the code since
283 we can avoid the btowc() call. */
284 if (_ISCTYPE ((UCHAR
) *n
, wt
))
287 if (ISWCTYPE (BTOWC ((UCHAR
) *n
), wt
))
291 if ((STREQ (str
, L("alnum")) && ISALNUM ((UCHAR
) *n
))
292 || (STREQ (str
, L("alpha")) && ISALPHA ((UCHAR
) *n
))
293 || (STREQ (str
, L("blank")) && ISBLANK ((UCHAR
) *n
))
294 || (STREQ (str
, L("cntrl")) && ISCNTRL ((UCHAR
) *n
))
295 || (STREQ (str
, L("digit")) && ISDIGIT ((UCHAR
) *n
))
296 || (STREQ (str
, L("graph")) && ISGRAPH ((UCHAR
) *n
))
297 || (STREQ (str
, L("lower")) && ISLOWER ((UCHAR
) *n
))
298 || (STREQ (str
, L("print")) && ISPRINT ((UCHAR
) *n
))
299 || (STREQ (str
, L("punct")) && ISPUNCT ((UCHAR
) *n
))
300 || (STREQ (str
, L("space")) && ISSPACE ((UCHAR
) *n
))
301 || (STREQ (str
, L("upper")) && ISUPPER ((UCHAR
) *n
))
302 || (STREQ (str
, L("xdigit")) && ISXDIGIT ((UCHAR
) *n
)))
308 else if (c
== L('[') && *p
== L('='))
312 _NL_CURRENT_WORD (LC_COLLATE
, _NL_COLLATE_NRULES
);
313 const CHAR
*startp
= p
;
325 if (c
!= L('=') || p
[1] != L(']'))
335 if ((UCHAR
) *n
== str
[0])
340 const int32_t *table
;
341 # if WIDE_CHAR_VERSION
342 const int32_t *weights
;
343 const int32_t *extra
;
345 const unsigned char *weights
;
346 const unsigned char *extra
;
348 const int32_t *indirect
;
350 const UCHAR
*cp
= (const UCHAR
*) str
;
352 /* This #include defines a local function! */
353 # if WIDE_CHAR_VERSION
354 # include <locale/weightwc.h>
356 # include <locale/weight.h>
359 # if WIDE_CHAR_VERSION
360 table
= (const int32_t *)
361 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_TABLEWC
);
362 weights
= (const int32_t *)
363 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_WEIGHTWC
);
364 extra
= (const int32_t *)
365 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_EXTRAWC
);
366 indirect
= (const int32_t *)
367 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_INDIRECTWC
);
369 table
= (const int32_t *)
370 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_TABLEMB
);
371 weights
= (const unsigned char *)
372 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_WEIGHTMB
);
373 extra
= (const unsigned char *)
374 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_EXTRAMB
);
375 indirect
= (const int32_t *)
376 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_INDIRECTMB
);
382 /* We found a table entry. Now see whether the
383 character we are currently at has the same
384 equivalance class value. */
385 int len
= weights
[idx
];
387 const UCHAR
*np
= (const UCHAR
*) n
;
389 idx2
= findidx (&np
);
390 if (idx2
!= 0 && len
== weights
[idx2
])
395 && (weights
[idx
+ 1 + cnt
]
396 == weights
[idx2
+ 1 + cnt
]))
408 else if (c
== L('\0'))
409 /* [ (unterminated) loses. */
413 bool is_range
= false;
416 bool is_seqval
= false;
418 if (c
== L('[') && *p
== L('.'))
421 _NL_CURRENT_WORD (LC_COLLATE
, _NL_COLLATE_NRULES
);
422 const CHAR
*startp
= p
;
428 if (c
== L('.') && p
[1] == L(']'))
438 /* We have to handling the symbols differently in
439 ranges since then the collation sequence is
441 is_range
= *p
== L('-') && p
[1] != L('\0');
445 /* There are no names defined in the collation
446 data. Therefore we only accept the trivial
447 names consisting of the character itself. */
451 if (!is_range
&& *n
== startp
[1])
460 const int32_t *symb_table
;
461 # ifdef WIDE_CHAR_VERSION
465 # define str (startp + 1)
467 const unsigned char *extra
;
473 # ifdef WIDE_CHAR_VERSION
474 /* We have to convert the name to a single-byte
475 string. This is possible since the names
476 consist of ASCII characters and the internal
477 representation is UCS4. */
478 for (strcnt
= 0; strcnt
< c1
; ++strcnt
)
479 str
[strcnt
] = startp
[1 + strcnt
];
483 _NL_CURRENT_WORD (LC_COLLATE
,
484 _NL_COLLATE_SYMB_HASH_SIZEMB
);
485 symb_table
= (const int32_t *)
486 _NL_CURRENT (LC_COLLATE
,
487 _NL_COLLATE_SYMB_TABLEMB
);
488 extra
= (const unsigned char *)
489 _NL_CURRENT (LC_COLLATE
,
490 _NL_COLLATE_SYMB_EXTRAMB
);
492 /* Locate the character in the hashing table. */
493 hash
= elem_hash (str
, c1
);
496 elem
= hash
% table_size
;
497 second
= hash
% (table_size
- 2);
498 while (symb_table
[2 * elem
] != 0)
500 /* First compare the hashing value. */
501 if (symb_table
[2 * elem
] == hash
502 && c1
== extra
[symb_table
[2 * elem
+ 1]]
504 &extra
[symb_table
[2 * elem
+ 1]
507 /* Yep, this is the entry. */
508 idx
= symb_table
[2 * elem
+ 1];
509 idx
+= 1 + extra
[idx
];
517 if (symb_table
[2 * elem
] != 0)
519 /* Compare the byte sequence but only if
520 this is not part of a range. */
521 # ifdef WIDE_CHAR_VERSION
524 idx
+= 1 + extra
[idx
];
525 /* Adjust for the alignment. */
526 idx
= (idx
+ 3) & ~3;
528 wextra
= (int32_t *) &extra
[idx
+ 4];
533 # ifdef WIDE_CHAR_VERSION
535 (int32_t) c1
< wextra
[idx
];
537 if (n
[c1
] != wextra
[1 + c1
])
540 if ((int32_t) c1
== wextra
[idx
])
543 for (c1
= 0; c1
< extra
[idx
]; ++c1
)
544 if (n
[c1
] != extra
[1 + c1
])
547 if (c1
== extra
[idx
])
552 /* Get the collation sequence value. */
554 # ifdef WIDE_CHAR_VERSION
555 cold
= wextra
[1 + wextra
[idx
]];
557 /* Adjust for the alignment. */
558 idx
+= 1 + extra
[idx
];
559 idx
= (idx
+ 3) & ~4;
560 cold
= *((int32_t *) &extra
[idx
]);
567 /* No valid character. Match it as a
569 if (!is_range
&& *n
== str
[0])
586 /* We have to handling the symbols differently in
587 ranges since then the collation sequence is
589 is_range
= (*p
== L('-') && p
[1] != L('\0')
592 if (!is_range
&& c
== fn
)
599 if (c
== L('-') && *p
!= L(']'))
602 /* We have to find the collation sequence
603 value for C. Collation sequence is nothing
604 we can regularly access. The sequence
605 value is defined by the order in which the
606 definitions of the collation values for the
607 various characters appear in the source
608 file. A strange concept, nowhere
614 # ifdef WIDE_CHAR_VERSION
615 /* Search in the `names' array for the characters. */
616 fcollseq
= __collseq_table_lookup (collseq
, fn
);
617 if (fcollseq
== ~((uint32_t) 0))
618 /* XXX We don't know anything about the character
619 we are supposed to match. This means we are
621 goto range_not_matched
;
626 lcollseq
= __collseq_table_lookup (collseq
, cold
);
628 fcollseq
= collseq
[fn
];
629 lcollseq
= is_seqval
? cold
: collseq
[(UCHAR
) cold
];
633 if (cend
== L('[') && *p
== L('.'))
636 _NL_CURRENT_WORD (LC_COLLATE
,
638 const CHAR
*startp
= p
;
644 if (c
== L('.') && p
[1] == L(']'))
656 /* There are no names defined in the
657 collation data. Therefore we only
658 accept the trivial names consisting
659 of the character itself. */
668 const int32_t *symb_table
;
669 # ifdef WIDE_CHAR_VERSION
673 # define str (startp + 1)
675 const unsigned char *extra
;
681 # ifdef WIDE_CHAR_VERSION
682 /* We have to convert the name to a single-byte
683 string. This is possible since the names
684 consist of ASCII characters and the internal
685 representation is UCS4. */
686 for (strcnt
= 0; strcnt
< c1
; ++strcnt
)
687 str
[strcnt
] = startp
[1 + strcnt
];
691 _NL_CURRENT_WORD (LC_COLLATE
,
692 _NL_COLLATE_SYMB_HASH_SIZEMB
);
693 symb_table
= (const int32_t *)
694 _NL_CURRENT (LC_COLLATE
,
695 _NL_COLLATE_SYMB_TABLEMB
);
696 extra
= (const unsigned char *)
697 _NL_CURRENT (LC_COLLATE
,
698 _NL_COLLATE_SYMB_EXTRAMB
);
700 /* Locate the character in the hashing
702 hash
= elem_hash (str
, c1
);
705 elem
= hash
% table_size
;
706 second
= hash
% (table_size
- 2);
707 while (symb_table
[2 * elem
] != 0)
709 /* First compare the hashing value. */
710 if (symb_table
[2 * elem
] == hash
712 == extra
[symb_table
[2 * elem
+ 1]])
714 &extra
[symb_table
[2 * elem
+ 1]
717 /* Yep, this is the entry. */
718 idx
= symb_table
[2 * elem
+ 1];
719 idx
+= 1 + extra
[idx
];
727 if (symb_table
[2 * elem
] != 0)
729 /* Compare the byte sequence but only if
730 this is not part of a range. */
731 # ifdef WIDE_CHAR_VERSION
734 idx
+= 1 + extra
[idx
];
735 /* Adjust for the alignment. */
736 idx
= (idx
+ 3) & ~4;
738 wextra
= (int32_t *) &extra
[idx
+ 4];
740 /* Get the collation sequence value. */
742 # ifdef WIDE_CHAR_VERSION
743 cend
= wextra
[1 + wextra
[idx
]];
745 /* Adjust for the alignment. */
746 idx
+= 1 + extra
[idx
];
747 idx
= (idx
+ 3) & ~4;
748 cend
= *((int32_t *) &extra
[idx
]);
751 else if (symb_table
[2 * elem
] != 0 && c1
== 1)
763 if (!(flags
& FNM_NOESCAPE
) && cend
== L('\\'))
770 /* XXX It is not entirely clear to me how to handle
771 characters which are not mentioned in the
772 collation specification. */
774 # ifdef WIDE_CHAR_VERSION
775 lcollseq
== 0xffffffff ||
777 lcollseq
<= fcollseq
)
779 /* We have to look at the upper bound. */
786 # ifdef WIDE_CHAR_VERSION
788 __collseq_table_lookup (collseq
, cend
);
789 if (hcollseq
== ~((uint32_t) 0))
791 /* Hum, no information about the upper
792 bound. The matching succeeds if the
793 lower bound is matched exactly. */
794 if (lcollseq
!= fcollseq
)
795 goto range_not_matched
;
800 hcollseq
= collseq
[cend
];
804 if (lcollseq
<= hcollseq
&& fcollseq
<= hcollseq
)
807 # ifdef WIDE_CHAR_VERSION
811 /* We use a boring value comparison of the character
812 values. This is better than comparing using
813 `strcoll' since the latter would have surprising
814 and sometimes fatal consequences. */
817 if (!(flags
& FNM_NOESCAPE
) && cend
== L('\\'))
823 if (cold
<= fn
&& fn
<= cend
)
840 /* Skip the rest of the [...] that already matched. */
847 /* [... (unterminated) loses. */
850 if (!(flags
& FNM_NOESCAPE
) && c
== L('\\'))
854 /* XXX 1003.2d11 is unclear if this is right. */
857 else if (c
== L('[') && *p
== L(':'))
860 const CHAR
*startp
= p
;
865 if (++c1
== CHAR_CLASS_MAX_LENGTH
)
868 if (*p
== L(':') && p
[1] == L(']'))
871 if (c
< L('a') || c
>= L('z'))
880 else if (c
== L('[') && *p
== L('='))
886 if (c
!= L('=') || p
[1] != L(']'))
891 else if (c
== L('[') && *p
== L('.'))
900 if (*p
== L('.') && p
[1] == L(']'))
916 if (__builtin_expect (flags
& FNM_EXTMATCH
, 0) && *p
== '(')
920 res
= EXT (c
, p
, n
, string_end
, no_leading_period
, flags
);
927 if (NO_LEADING_PERIOD (flags
))
929 if (n
== string_end
|| c
!= (UCHAR
) *n
)
932 new_no_leading_period
= true;
938 if (n
== string_end
|| c
!= FOLD ((UCHAR
) *n
))
942 no_leading_period
= new_no_leading_period
;
949 if ((flags
& FNM_LEADING_DIR
) && n
!= string_end
&& *n
== L('/'))
950 /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */
959 END (const CHAR
*pattern
)
961 const CHAR
*p
= pattern
;
965 /* This is an invalid pattern. */
967 else if (*p
== L('['))
969 /* Handle brackets special. */
970 if (posixly_correct
== 0)
971 posixly_correct
= getenv ("POSIXLY_CORRECT") != NULL
? 1 : -1;
973 /* Skip the not sign. We have to recognize it because of a possibly
975 if (*++p
== L('!') || (posixly_correct
< 0 && *p
== L('^')))
977 /* A leading ']' is recognized as such. */
980 /* Skip over all characters of the list. */
983 /* This is no valid pattern. */
986 else if ((*p
== L('?') || *p
== L('*') || *p
== L('+') || *p
== L('@')
987 || *p
== L('!')) && p
[1] == L('('))
989 else if (*p
== L(')'))
998 EXT (INT opt
, const CHAR
*pattern
, const CHAR
*string
, const CHAR
*string_end
,
999 bool no_leading_period
, int flags
)
1005 struct patternlist
*next
;
1008 struct patternlist
**lastp
= &list
;
1009 size_t pattern_len
= STRLEN (pattern
);
1012 enum { ALLOCA_LIMIT
= 8000 };
1014 /* Parse the pattern. Store the individual parts in the list. */
1016 for (startp
= p
= pattern
+ 1; ; ++p
)
1018 /* This is an invalid pattern. */
1020 else if (*p
== L('['))
1022 /* Handle brackets special. */
1023 if (posixly_correct
== 0)
1024 posixly_correct
= getenv ("POSIXLY_CORRECT") != NULL
? 1 : -1;
1026 /* Skip the not sign. We have to recognize it because of a possibly
1028 if (*++p
== L('!') || (posixly_correct
< 0 && *p
== L('^')))
1030 /* A leading ']' is recognized as such. */
1033 /* Skip over all characters of the list. */
1034 while (*p
!= L(']'))
1035 if (*p
++ == L('\0'))
1036 /* This is no valid pattern. */
1039 else if ((*p
== L('?') || *p
== L('*') || *p
== L('+') || *p
== L('@')
1040 || *p
== L('!')) && p
[1] == L('('))
1041 /* Remember the nesting level. */
1043 else if (*p
== L(')'))
1047 /* This means we found the end of the pattern. */
1048 #define NEW_PATTERN \
1049 struct patternlist *newp; \
1054 plen = (opt == L('?') || opt == L('@') \
1056 : p - startp + 1); \
1057 plensize = plen * sizeof (CHAR); \
1058 newpsize = offsetof (struct patternlist, str) + plensize; \
1059 if ((size_t) -1 / sizeof (CHAR) < plen \
1060 || newpsize < offsetof (struct patternlist, str) \
1061 || ALLOCA_LIMIT <= newpsize) \
1063 newp = (struct patternlist *) alloca (newpsize); \
1064 *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L('\0'); \
1065 newp->next = NULL; \
1072 else if (*p
== L('|'))
1080 assert (list
!= NULL
);
1081 assert (p
[-1] == L(')'));
1087 if (FCT (p
, string
, string_end
, no_leading_period
, flags
) == 0)
1094 for (rs
= string
; rs
<= string_end
; ++rs
)
1095 /* First match the prefix with the current pattern with the
1097 if (FCT (list
->str
, string
, rs
, no_leading_period
,
1098 flags
& FNM_FILE_NAME
? flags
: flags
& ~FNM_PERIOD
) == 0
1099 /* This was successful. Now match the rest with the rest
1101 && (FCT (p
, rs
, string_end
,
1104 : rs
[-1] == '/' && NO_LEADING_PERIOD (flags
),
1105 flags
& FNM_FILE_NAME
1106 ? flags
: flags
& ~FNM_PERIOD
) == 0
1107 /* This didn't work. Try the whole pattern. */
1109 && FCT (pattern
- 1, rs
, string_end
,
1112 : rs
[-1] == '/' && NO_LEADING_PERIOD (flags
),
1113 flags
& FNM_FILE_NAME
1114 ? flags
: flags
& ~FNM_PERIOD
) == 0)))
1115 /* It worked. Signal success. */
1118 while ((list
= list
->next
) != NULL
);
1120 /* None of the patterns lead to a match. */
1124 if (FCT (p
, string
, string_end
, no_leading_period
, flags
) == 0)
1130 /* I cannot believe it but `strcat' is actually acceptable
1131 here. Match the entire string with the prefix from the
1132 pattern list and the rest of the pattern following the
1134 if (FCT (STRCAT (list
->str
, p
), string
, string_end
,
1136 flags
& FNM_FILE_NAME
? flags
: flags
& ~FNM_PERIOD
) == 0)
1137 /* It worked. Signal success. */
1139 while ((list
= list
->next
) != NULL
);
1141 /* None of the patterns lead to a match. */
1145 for (rs
= string
; rs
<= string_end
; ++rs
)
1147 struct patternlist
*runp
;
1149 for (runp
= list
; runp
!= NULL
; runp
= runp
->next
)
1150 if (FCT (runp
->str
, string
, rs
, no_leading_period
,
1151 flags
& FNM_FILE_NAME
? flags
: flags
& ~FNM_PERIOD
) == 0)
1154 /* If none of the patterns matched see whether the rest does. */
1156 && (FCT (p
, rs
, string_end
,
1159 : rs
[-1] == '/' && NO_LEADING_PERIOD (flags
),
1160 flags
& FNM_FILE_NAME
? flags
: flags
& ~FNM_PERIOD
)
1162 /* This is successful. */
1166 /* None of the patterns together with the rest of the pattern
1171 assert (! "Invalid extended matching operator");