1 /* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2003
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 /* Match STRING against the filename pattern PATTERN, returning zero if
21 it matches, nonzero if not. */
22 static int FCT (const CHAR
*pattern
, const CHAR
*string
,
23 const CHAR
*string_end
, int no_leading_period
, int flags
)
25 static int EXT (INT opt
, const CHAR
*pattern
, const CHAR
*string
,
26 const CHAR
*string_end
, int no_leading_period
, int flags
)
28 static const CHAR
*END (const CHAR
*patternp
) internal_function
;
32 FCT (pattern
, string
, string_end
, no_leading_period
, flags
)
35 const CHAR
*string_end
;
36 int no_leading_period
;
39 register const CHAR
*p
= pattern
, *n
= string
;
42 # if WIDE_CHAR_VERSION
43 const char *collseq
= (const char *)
44 _NL_CURRENT(LC_COLLATE
, _NL_COLLATE_COLLSEQWC
);
46 const UCHAR
*collseq
= (const UCHAR
*)
47 _NL_CURRENT(LC_COLLATE
, _NL_COLLATE_COLLSEQMB
);
51 while ((c
= *p
++) != L('\0'))
53 int new_no_leading_period
= 0;
59 if (__builtin_expect (flags
& FNM_EXTMATCH
, 0) && *p
== '(')
63 res
= EXT (c
, p
, n
, string_end
, no_leading_period
,
71 else if (*n
== L('/') && (flags
& FNM_FILE_NAME
))
73 else if (*n
== L('.') && no_leading_period
)
78 if (!(flags
& FNM_NOESCAPE
))
82 /* Trailing \ loses. */
86 if (n
== string_end
|| FOLD ((UCHAR
) *n
) != c
)
91 if (__builtin_expect (flags
& FNM_EXTMATCH
, 0) && *p
== '(')
95 res
= EXT (c
, p
, n
, string_end
, no_leading_period
,
101 if (n
!= string_end
&& *n
== L('.') && no_leading_period
)
104 for (c
= *p
++; c
== L('?') || c
== L('*'); c
= *p
++)
106 if (*p
== L('(') && (flags
& FNM_EXTMATCH
) != 0)
108 const CHAR
*endp
= END (p
);
111 /* This is a pattern. Skip over it. */
119 /* A ? needs to match one character. */
121 /* There isn't another character; no match. */
123 else if (*n
== L('/')
124 && __builtin_expect (flags
& FNM_FILE_NAME
, 0))
125 /* A slash does not match a wildcard under
129 /* One character of the string is consumed in matching
130 this ? wildcard, so *??? won't match if there are
131 less than three characters. */
137 /* The wildcard(s) is/are the last element of the pattern.
138 If the name is a file name and contains another slash
139 this means it cannot match, unless the FNM_LEADING_DIR
142 int result
= (flags
& FNM_FILE_NAME
) == 0 ? 0 : FNM_NOMATCH
;
144 if (flags
& FNM_FILE_NAME
)
146 if (flags
& FNM_LEADING_DIR
)
150 if (MEMCHR (n
, L('/'), string_end
- n
) == NULL
)
161 endp
= MEMCHR (n
, (flags
& FNM_FILE_NAME
) ? L('/') : L('\0'),
167 || (__builtin_expect (flags
& FNM_EXTMATCH
, 0) != 0
168 && (c
== L('@') || c
== L('+') || c
== L('!'))
171 int flags2
= ((flags
& FNM_FILE_NAME
)
172 ? flags
: (flags
& ~FNM_PERIOD
));
173 int no_leading_period2
= no_leading_period
;
175 for (--p
; n
< endp
; ++n
, no_leading_period2
= 0)
176 if (FCT (p
, n
, string_end
, no_leading_period2
, flags2
)
180 else if (c
== L('/') && (flags
& FNM_FILE_NAME
))
182 while (n
< string_end
&& *n
!= L('/'))
184 if (n
< string_end
&& *n
== L('/')
185 && (FCT (p
, n
+ 1, string_end
, flags
& FNM_PERIOD
, flags
)
191 int flags2
= ((flags
& FNM_FILE_NAME
)
192 ? flags
: (flags
& ~FNM_PERIOD
));
193 int no_leading_period2
= no_leading_period
;
195 if (c
== L('\\') && !(flags
& FNM_NOESCAPE
))
198 for (--p
; n
< endp
; ++n
, no_leading_period2
= 0)
199 if (FOLD ((UCHAR
) *n
) == c
200 && (FCT (p
, n
, string_end
, no_leading_period2
, flags2
)
206 /* If we come here no match is possible with the wildcard. */
211 /* Nonzero if the sense of the character class is inverted. */
216 if (posixly_correct
== 0)
217 posixly_correct
= getenv ("POSIXLY_CORRECT") != NULL
? 1 : -1;
222 if (*n
== L('.') && no_leading_period
)
225 if (*n
== L('/') && (flags
& FNM_FILE_NAME
))
226 /* `/' cannot be matched. */
229 not = (*p
== L('!') || (posixly_correct
< 0 && *p
== L('^')));
233 fn
= FOLD ((UCHAR
) *n
);
238 if (!(flags
& FNM_NOESCAPE
) && c
== L('\\'))
242 c
= FOLD ((UCHAR
) *p
);
248 else if (c
== L('[') && *p
== L(':'))
250 /* Leave room for the null. */
251 CHAR str
[CHAR_CLASS_MAX_LENGTH
+ 1];
253 #if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
256 const CHAR
*startp
= p
;
260 if (c1
== CHAR_CLASS_MAX_LENGTH
)
261 /* The name is too long and therefore the pattern
266 if (c
== L(':') && p
[1] == L(']'))
271 if (c
< L('a') || c
>= L('z'))
273 /* This cannot possibly be a character class name.
274 Match it as a normal range. */
283 #if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
284 wt
= IS_CHAR_CLASS (str
);
286 /* Invalid character class name. */
289 # if defined _LIBC && ! WIDE_CHAR_VERSION
290 /* The following code is glibc specific but does
291 there a good job in speeding up the code since
292 we can avoid the btowc() call. */
293 if (_ISCTYPE ((UCHAR
) *n
, wt
))
296 if (ISWCTYPE (BTOWC ((UCHAR
) *n
), wt
))
300 if ((STREQ (str
, L("alnum")) && ISALNUM ((UCHAR
) *n
))
301 || (STREQ (str
, L("alpha")) && ISALPHA ((UCHAR
) *n
))
302 || (STREQ (str
, L("blank")) && ISBLANK ((UCHAR
) *n
))
303 || (STREQ (str
, L("cntrl")) && ISCNTRL ((UCHAR
) *n
))
304 || (STREQ (str
, L("digit")) && ISDIGIT ((UCHAR
) *n
))
305 || (STREQ (str
, L("graph")) && ISGRAPH ((UCHAR
) *n
))
306 || (STREQ (str
, L("lower")) && ISLOWER ((UCHAR
) *n
))
307 || (STREQ (str
, L("print")) && ISPRINT ((UCHAR
) *n
))
308 || (STREQ (str
, L("punct")) && ISPUNCT ((UCHAR
) *n
))
309 || (STREQ (str
, L("space")) && ISSPACE ((UCHAR
) *n
))
310 || (STREQ (str
, L("upper")) && ISUPPER ((UCHAR
) *n
))
311 || (STREQ (str
, L("xdigit")) && ISXDIGIT ((UCHAR
) *n
)))
317 else if (c
== L('[') && *p
== L('='))
321 _NL_CURRENT_WORD (LC_COLLATE
, _NL_COLLATE_NRULES
);
322 const CHAR
*startp
= p
;
334 if (c
!= L('=') || p
[1] != L(']'))
344 if ((UCHAR
) *n
== str
[0])
349 const int32_t *table
;
350 # if WIDE_CHAR_VERSION
351 const int32_t *weights
;
352 const int32_t *extra
;
354 const unsigned char *weights
;
355 const unsigned char *extra
;
357 const int32_t *indirect
;
359 const UCHAR
*cp
= (const UCHAR
*) str
;
361 /* This #include defines a local function! */
362 # if WIDE_CHAR_VERSION
363 # include <locale/weightwc.h>
365 # include <locale/weight.h>
368 # if WIDE_CHAR_VERSION
369 table
= (const int32_t *)
370 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_TABLEWC
);
371 weights
= (const int32_t *)
372 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_WEIGHTWC
);
373 extra
= (const int32_t *)
374 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_EXTRAWC
);
375 indirect
= (const int32_t *)
376 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_INDIRECTWC
);
378 table
= (const int32_t *)
379 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_TABLEMB
);
380 weights
= (const unsigned char *)
381 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_WEIGHTMB
);
382 extra
= (const unsigned char *)
383 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_EXTRAMB
);
384 indirect
= (const int32_t *)
385 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_INDIRECTMB
);
391 /* We found a table entry. Now see whether the
392 character we are currently at has the same
393 equivalance class value. */
394 int len
= weights
[idx
];
396 const UCHAR
*np
= (const UCHAR
*) n
;
398 idx2
= findidx (&np
);
399 if (idx2
!= 0 && len
== weights
[idx2
])
404 && (weights
[idx
+ 1 + cnt
]
405 == weights
[idx2
+ 1 + cnt
]))
417 else if (c
== L('\0'))
418 /* [ (unterminated) loses. */
427 if (c
== L('[') && *p
== L('.'))
430 _NL_CURRENT_WORD (LC_COLLATE
, _NL_COLLATE_NRULES
);
431 const CHAR
*startp
= p
;
437 if (c
== L('.') && p
[1] == L(']'))
447 /* We have to handling the symbols differently in
448 ranges since then the collation sequence is
450 is_range
= *p
== L('-') && p
[1] != L('\0');
454 /* There are no names defined in the collation
455 data. Therefore we only accept the trivial
456 names consisting of the character itself. */
460 if (!is_range
&& *n
== startp
[1])
469 const int32_t *symb_table
;
470 # ifdef WIDE_CHAR_VERSION
474 # define str (startp + 1)
476 const unsigned char *extra
;
482 # ifdef WIDE_CHAR_VERSION
483 /* We have to convert the name to a single-byte
484 string. This is possible since the names
485 consist of ASCII characters and the internal
486 representation is UCS4. */
487 for (strcnt
= 0; strcnt
< c1
; ++strcnt
)
488 str
[strcnt
] = startp
[1 + strcnt
];
492 _NL_CURRENT_WORD (LC_COLLATE
,
493 _NL_COLLATE_SYMB_HASH_SIZEMB
);
494 symb_table
= (const int32_t *)
495 _NL_CURRENT (LC_COLLATE
,
496 _NL_COLLATE_SYMB_TABLEMB
);
497 extra
= (const unsigned char *)
498 _NL_CURRENT (LC_COLLATE
,
499 _NL_COLLATE_SYMB_EXTRAMB
);
501 /* Locate the character in the hashing table. */
502 hash
= elem_hash (str
, c1
);
505 elem
= hash
% table_size
;
506 second
= hash
% (table_size
- 2);
507 while (symb_table
[2 * elem
] != 0)
509 /* First compare the hashing value. */
510 if (symb_table
[2 * elem
] == hash
511 && c1
== extra
[symb_table
[2 * elem
+ 1]]
513 &extra
[symb_table
[2 * elem
+ 1]
516 /* Yep, this is the entry. */
517 idx
= symb_table
[2 * elem
+ 1];
518 idx
+= 1 + extra
[idx
];
526 if (symb_table
[2 * elem
] != 0)
528 /* Compare the byte sequence but only if
529 this is not part of a range. */
530 # ifdef WIDE_CHAR_VERSION
533 idx
+= 1 + extra
[idx
];
534 /* Adjust for the alignment. */
535 idx
= (idx
+ 3) & ~3;
537 wextra
= (int32_t *) &extra
[idx
+ 4];
542 # ifdef WIDE_CHAR_VERSION
544 (int32_t) c1
< wextra
[idx
];
546 if (n
[c1
] != wextra
[1 + c1
])
549 if ((int32_t) c1
== wextra
[idx
])
552 for (c1
= 0; c1
< extra
[idx
]; ++c1
)
553 if (n
[c1
] != extra
[1 + c1
])
556 if (c1
== extra
[idx
])
561 /* Get the collation sequence value. */
563 # ifdef WIDE_CHAR_VERSION
564 cold
= wextra
[1 + wextra
[idx
]];
566 /* Adjust for the alignment. */
567 idx
+= 1 + extra
[idx
];
568 idx
= (idx
+ 3) & ~4;
569 cold
= *((int32_t *) &extra
[idx
]);
576 /* No valid character. Match it as a
578 if (!is_range
&& *n
== str
[0])
595 /* We have to handling the symbols differently in
596 ranges since then the collation sequence is
598 is_range
= (*p
== L('-') && p
[1] != L('\0')
601 if (!is_range
&& c
== fn
)
608 if (c
== L('-') && *p
!= L(']'))
611 /* We have to find the collation sequence
612 value for C. Collation sequence is nothing
613 we can regularly access. The sequence
614 value is defined by the order in which the
615 definitions of the collation values for the
616 various characters appear in the source
617 file. A strange concept, nowhere
623 # ifdef WIDE_CHAR_VERSION
624 /* Search in the `names' array for the characters. */
625 fcollseq
= __collseq_table_lookup (collseq
, fn
);
626 if (fcollseq
== ~((uint32_t) 0))
627 /* XXX We don't know anything about the character
628 we are supposed to match. This means we are
630 goto range_not_matched
;
635 lcollseq
= __collseq_table_lookup (collseq
, cold
);
637 fcollseq
= collseq
[fn
];
638 lcollseq
= is_seqval
? cold
: collseq
[(UCHAR
) cold
];
642 if (cend
== L('[') && *p
== L('.'))
645 _NL_CURRENT_WORD (LC_COLLATE
,
647 const CHAR
*startp
= p
;
653 if (c
== L('.') && p
[1] == L(']'))
665 /* There are no names defined in the
666 collation data. Therefore we only
667 accept the trivial names consisting
668 of the character itself. */
677 const int32_t *symb_table
;
678 # ifdef WIDE_CHAR_VERSION
682 # define str (startp + 1)
684 const unsigned char *extra
;
690 # ifdef WIDE_CHAR_VERSION
691 /* We have to convert the name to a single-byte
692 string. This is possible since the names
693 consist of ASCII characters and the internal
694 representation is UCS4. */
695 for (strcnt
= 0; strcnt
< c1
; ++strcnt
)
696 str
[strcnt
] = startp
[1 + strcnt
];
700 _NL_CURRENT_WORD (LC_COLLATE
,
701 _NL_COLLATE_SYMB_HASH_SIZEMB
);
702 symb_table
= (const int32_t *)
703 _NL_CURRENT (LC_COLLATE
,
704 _NL_COLLATE_SYMB_TABLEMB
);
705 extra
= (const unsigned char *)
706 _NL_CURRENT (LC_COLLATE
,
707 _NL_COLLATE_SYMB_EXTRAMB
);
709 /* Locate the character in the hashing
711 hash
= elem_hash (str
, c1
);
714 elem
= hash
% table_size
;
715 second
= hash
% (table_size
- 2);
716 while (symb_table
[2 * elem
] != 0)
718 /* First compare the hashing value. */
719 if (symb_table
[2 * elem
] == hash
721 == extra
[symb_table
[2 * elem
+ 1]])
723 &extra
[symb_table
[2 * elem
+ 1]
726 /* Yep, this is the entry. */
727 idx
= symb_table
[2 * elem
+ 1];
728 idx
+= 1 + extra
[idx
];
736 if (symb_table
[2 * elem
] != 0)
738 /* Compare the byte sequence but only if
739 this is not part of a range. */
740 # ifdef WIDE_CHAR_VERSION
743 idx
+= 1 + extra
[idx
];
744 /* Adjust for the alignment. */
745 idx
= (idx
+ 3) & ~4;
747 wextra
= (int32_t *) &extra
[idx
+ 4];
749 /* Get the collation sequence value. */
751 # ifdef WIDE_CHAR_VERSION
752 cend
= wextra
[1 + wextra
[idx
]];
754 /* Adjust for the alignment. */
755 idx
+= 1 + extra
[idx
];
756 idx
= (idx
+ 3) & ~4;
757 cend
= *((int32_t *) &extra
[idx
]);
760 else if (symb_table
[2 * elem
] != 0 && c1
== 1)
772 if (!(flags
& FNM_NOESCAPE
) && cend
== L('\\'))
779 /* XXX It is not entirely clear to me how to handle
780 characters which are not mentioned in the
781 collation specification. */
783 # ifdef WIDE_CHAR_VERSION
784 lcollseq
== 0xffffffff ||
786 lcollseq
<= fcollseq
)
788 /* We have to look at the upper bound. */
795 # ifdef WIDE_CHAR_VERSION
797 __collseq_table_lookup (collseq
, cend
);
798 if (hcollseq
== ~((uint32_t) 0))
800 /* Hum, no information about the upper
801 bound. The matching succeeds if the
802 lower bound is matched exactly. */
803 if (lcollseq
!= fcollseq
)
804 goto range_not_matched
;
809 hcollseq
= collseq
[cend
];
813 if (lcollseq
<= hcollseq
&& fcollseq
<= hcollseq
)
816 # ifdef WIDE_CHAR_VERSION
820 /* We use a boring value comparison of the character
821 values. This is better than comparing using
822 `strcoll' since the latter would have surprising
823 and sometimes fatal consequences. */
826 if (!(flags
& FNM_NOESCAPE
) && cend
== L('\\'))
832 if (cold
<= fn
&& fn
<= cend
)
849 /* Skip the rest of the [...] that already matched. */
856 /* [... (unterminated) loses. */
859 if (!(flags
& FNM_NOESCAPE
) && c
== L('\\'))
863 /* XXX 1003.2d11 is unclear if this is right. */
866 else if (c
== L('[') && *p
== L(':'))
869 const CHAR
*startp
= p
;
874 if (++c1
== CHAR_CLASS_MAX_LENGTH
)
877 if (*p
== L(':') && p
[1] == L(']'))
880 if (c
< L('a') || c
>= L('z'))
889 else if (c
== L('[') && *p
== L('='))
895 if (c
!= L('=') || p
[1] != L(']'))
900 else if (c
== L('[') && *p
== L('.'))
909 if (*p
== L('.') && p
[1] == L(']'))
925 if (__builtin_expect (flags
& FNM_EXTMATCH
, 0) && *p
== '(')
929 res
= EXT (c
, p
, n
, string_end
, no_leading_period
, flags
);
936 if (NO_LEADING_PERIOD (flags
))
938 if (n
== string_end
|| c
!= (UCHAR
) *n
)
941 new_no_leading_period
= 1;
947 if (n
== string_end
|| c
!= FOLD ((UCHAR
) *n
))
951 no_leading_period
= new_no_leading_period
;
958 if ((flags
& FNM_LEADING_DIR
) && n
!= string_end
&& *n
== L('/'))
959 /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */
968 END (const CHAR
*pattern
)
970 const CHAR
*p
= pattern
;
974 /* This is an invalid pattern. */
976 else if (*p
== L('['))
978 /* Handle brackets special. */
979 if (posixly_correct
== 0)
980 posixly_correct
= getenv ("POSIXLY_CORRECT") != NULL
? 1 : -1;
982 /* Skip the not sign. We have to recognize it because of a possibly
984 if (*++p
== L('!') || (posixly_correct
< 0 && *p
== L('^')))
986 /* A leading ']' is recognized as such. */
989 /* Skip over all characters of the list. */
992 /* This is no valid pattern. */
995 else if ((*p
== L('?') || *p
== L('*') || *p
== L('+') || *p
== L('@')
996 || *p
== L('!')) && p
[1] == L('('))
998 else if (*p
== L(')'))
1007 EXT (INT opt
, const CHAR
*pattern
, const CHAR
*string
, const CHAR
*string_end
,
1008 int no_leading_period
, int flags
)
1014 struct patternlist
*next
;
1017 struct patternlist
**lastp
= &list
;
1018 size_t pattern_len
= STRLEN (pattern
);
1022 /* Parse the pattern. Store the individual parts in the list. */
1024 for (startp
= p
= pattern
+ 1; level
>= 0; ++p
)
1026 /* This is an invalid pattern. */
1028 else if (*p
== L('['))
1030 /* Handle brackets special. */
1031 if (posixly_correct
== 0)
1032 posixly_correct
= getenv ("POSIXLY_CORRECT") != NULL
? 1 : -1;
1034 /* Skip the not sign. We have to recognize it because of a possibly
1036 if (*++p
== L('!') || (posixly_correct
< 0 && *p
== L('^')))
1038 /* A leading ']' is recognized as such. */
1041 /* Skip over all characters of the list. */
1042 while (*p
!= L(']'))
1043 if (*p
++ == L('\0'))
1044 /* This is no valid pattern. */
1047 else if ((*p
== L('?') || *p
== L('*') || *p
== L('+') || *p
== L('@')
1048 || *p
== L('!')) && p
[1] == L('('))
1049 /* Remember the nesting level. */
1051 else if (*p
== L(')'))
1055 /* This means we found the end of the pattern. */
1056 #define NEW_PATTERN \
1057 struct patternlist *newp; \
1059 if (opt == L('?') || opt == L('@')) \
1060 newp = alloca (sizeof (struct patternlist) \
1061 + (pattern_len * sizeof (CHAR))); \
1063 newp = alloca (sizeof (struct patternlist) \
1064 + ((p - startp + 1) * sizeof (CHAR))); \
1065 *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L('\0'); \
1066 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
) ? 1 : 0,
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
)
1114 flags
& FNM_FILE_NAME
1115 ? flags
: flags
& ~FNM_PERIOD
) == 0)))
1116 /* It worked. Signal success. */
1119 while ((list
= list
->next
) != NULL
);
1121 /* None of the patterns lead to a match. */
1125 if (FCT (p
, string
, string_end
, no_leading_period
, flags
) == 0)
1131 /* I cannot believe it but `strcat' is actually acceptable
1132 here. Match the entire string with the prefix from the
1133 pattern list and the rest of the pattern following the
1135 if (FCT (STRCAT (list
->str
, p
), string
, string_end
,
1137 flags
& FNM_FILE_NAME
? flags
: flags
& ~FNM_PERIOD
) == 0)
1138 /* It worked. Signal success. */
1140 while ((list
= list
->next
) != NULL
);
1142 /* None of the patterns lead to a match. */
1146 for (rs
= string
; rs
<= string_end
; ++rs
)
1148 struct patternlist
*runp
;
1150 for (runp
= list
; runp
!= NULL
; runp
= runp
->next
)
1151 if (FCT (runp
->str
, string
, rs
, no_leading_period
,
1152 flags
& FNM_FILE_NAME
? flags
: flags
& ~FNM_PERIOD
) == 0)
1155 /* If none of the patterns matched see whether the rest does. */
1157 && (FCT (p
, rs
, string_end
,
1160 : rs
[-1] == '/' && NO_LEADING_PERIOD (flags
) ? 1 : 0,
1161 flags
& FNM_FILE_NAME
? flags
: flags
& ~FNM_PERIOD
)
1163 /* This is successful. */
1167 /* None of the patterns together with the rest of the pattern
1172 assert (! "Invalid extended matching operator");