1 /* Copyright (C) 1991-1993,1996-2001,2003-2005,2007
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
24 int no_leading_period
;
27 /* Match STRING against the filename pattern PATTERN, returning zero if
28 it matches, nonzero if not. */
29 static int FCT (const CHAR
*pattern
, const CHAR
*string
,
30 const CHAR
*string_end
, int no_leading_period
, int flags
,
33 static int EXT (INT opt
, const CHAR
*pattern
, const CHAR
*string
,
34 const CHAR
*string_end
, int no_leading_period
, int flags
)
36 static const CHAR
*END (const CHAR
*patternp
) internal_function
;
40 FCT (pattern
, string
, string_end
, no_leading_period
, flags
, ends
)
43 const CHAR
*string_end
;
44 int no_leading_period
;
48 register const CHAR
*p
= pattern
, *n
= string
;
51 # if WIDE_CHAR_VERSION
52 const char *collseq
= (const char *)
53 _NL_CURRENT(LC_COLLATE
, _NL_COLLATE_COLLSEQWC
);
55 const UCHAR
*collseq
= (const UCHAR
*)
56 _NL_CURRENT(LC_COLLATE
, _NL_COLLATE_COLLSEQMB
);
60 while ((c
= *p
++) != L('\0'))
62 int new_no_leading_period
= 0;
68 if (__builtin_expect (flags
& FNM_EXTMATCH
, 0) && *p
== '(')
72 res
= EXT (c
, p
, n
, string_end
, no_leading_period
,
80 else if (*n
== L('/') && (flags
& FNM_FILE_NAME
))
82 else if (*n
== L('.') && no_leading_period
)
87 if (!(flags
& FNM_NOESCAPE
))
91 /* Trailing \ loses. */
95 if (n
== string_end
|| FOLD ((UCHAR
) *n
) != c
)
100 if (__builtin_expect (flags
& FNM_EXTMATCH
, 0) && *p
== '(')
104 res
= EXT (c
, p
, n
, string_end
, no_leading_period
,
109 else if (ends
!= NULL
)
111 ends
->pattern
= p
- 1;
113 ends
->no_leading_period
= no_leading_period
;
117 if (n
!= string_end
&& *n
== L('.') && no_leading_period
)
120 for (c
= *p
++; c
== L('?') || c
== L('*'); c
= *p
++)
122 if (*p
== L('(') && (flags
& FNM_EXTMATCH
) != 0)
124 const CHAR
*endp
= END (p
);
127 /* This is a pattern. Skip over it. */
135 /* A ? needs to match one character. */
137 /* There isn't another character; no match. */
139 else if (*n
== L('/')
140 && __builtin_expect (flags
& FNM_FILE_NAME
, 0))
141 /* A slash does not match a wildcard under
145 /* One character of the string is consumed in matching
146 this ? wildcard, so *??? won't match if there are
147 less than three characters. */
153 /* The wildcard(s) is/are the last element of the pattern.
154 If the name is a file name and contains another slash
155 this means it cannot match, unless the FNM_LEADING_DIR
158 int result
= (flags
& FNM_FILE_NAME
) == 0 ? 0 : FNM_NOMATCH
;
160 if (flags
& FNM_FILE_NAME
)
162 if (flags
& FNM_LEADING_DIR
)
166 if (MEMCHR (n
, L('/'), string_end
- n
) == NULL
)
179 endp
= MEMCHR (n
, (flags
& FNM_FILE_NAME
) ? L('/') : L('\0'),
185 || (__builtin_expect (flags
& FNM_EXTMATCH
, 0) != 0
186 && (c
== L('@') || c
== L('+') || c
== L('!'))
189 int flags2
= ((flags
& FNM_FILE_NAME
)
190 ? flags
: (flags
& ~FNM_PERIOD
));
192 for (--p
; n
< endp
; ++n
, no_leading_period
= 0)
193 if (FCT (p
, n
, string_end
, no_leading_period
, flags2
,
197 else if (c
== L('/') && (flags
& FNM_FILE_NAME
))
199 while (n
< string_end
&& *n
!= L('/'))
201 if (n
< string_end
&& *n
== L('/')
202 && (FCT (p
, n
+ 1, string_end
, flags
& FNM_PERIOD
, flags
,
208 int flags2
= ((flags
& FNM_FILE_NAME
)
209 ? flags
: (flags
& ~FNM_PERIOD
));
211 if (c
== L('\\') && !(flags
& FNM_NOESCAPE
))
214 for (--p
; n
< endp
; ++n
, no_leading_period
= 0)
215 if (FOLD ((UCHAR
) *n
) == c
216 && (FCT (p
, n
, string_end
, no_leading_period
, flags2
,
220 if (end
.pattern
== NULL
)
224 if (end
.pattern
!= NULL
)
228 no_leading_period
= end
.no_leading_period
;
234 /* If we come here no match is possible with the wildcard. */
239 /* Nonzero if the sense of the character class is inverted. */
244 if (posixly_correct
== 0)
245 posixly_correct
= getenv ("POSIXLY_CORRECT") != NULL
? 1 : -1;
250 if (*n
== L('.') && no_leading_period
)
253 if (*n
== L('/') && (flags
& FNM_FILE_NAME
))
254 /* `/' cannot be matched. */
257 not = (*p
== L('!') || (posixly_correct
< 0 && *p
== L('^')));
261 fn
= FOLD ((UCHAR
) *n
);
266 if (!(flags
& FNM_NOESCAPE
) && c
== L('\\'))
270 c
= FOLD ((UCHAR
) *p
);
275 else if (c
== L('[') && *p
== L(':'))
277 /* Leave room for the null. */
278 CHAR str
[CHAR_CLASS_MAX_LENGTH
+ 1];
280 #if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
283 const CHAR
*startp
= p
;
287 if (c1
== CHAR_CLASS_MAX_LENGTH
)
288 /* The name is too long and therefore the pattern
293 if (c
== L(':') && p
[1] == L(']'))
298 if (c
< L('a') || c
>= L('z'))
300 /* This cannot possibly be a character class name.
301 Match it as a normal range. */
310 #if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
311 wt
= IS_CHAR_CLASS (str
);
313 /* Invalid character class name. */
316 # if defined _LIBC && ! WIDE_CHAR_VERSION
317 /* The following code is glibc specific but does
318 there a good job in speeding up the code since
319 we can avoid the btowc() call. */
320 if (_ISCTYPE ((UCHAR
) *n
, wt
))
323 if (ISWCTYPE (BTOWC ((UCHAR
) *n
), wt
))
327 if ((STREQ (str
, L("alnum")) && ISALNUM ((UCHAR
) *n
))
328 || (STREQ (str
, L("alpha")) && ISALPHA ((UCHAR
) *n
))
329 || (STREQ (str
, L("blank")) && ISBLANK ((UCHAR
) *n
))
330 || (STREQ (str
, L("cntrl")) && ISCNTRL ((UCHAR
) *n
))
331 || (STREQ (str
, L("digit")) && ISDIGIT ((UCHAR
) *n
))
332 || (STREQ (str
, L("graph")) && ISGRAPH ((UCHAR
) *n
))
333 || (STREQ (str
, L("lower")) && ISLOWER ((UCHAR
) *n
))
334 || (STREQ (str
, L("print")) && ISPRINT ((UCHAR
) *n
))
335 || (STREQ (str
, L("punct")) && ISPUNCT ((UCHAR
) *n
))
336 || (STREQ (str
, L("space")) && ISSPACE ((UCHAR
) *n
))
337 || (STREQ (str
, L("upper")) && ISUPPER ((UCHAR
) *n
))
338 || (STREQ (str
, L("xdigit")) && ISXDIGIT ((UCHAR
) *n
)))
344 else if (c
== L('[') && *p
== L('='))
348 _NL_CURRENT_WORD (LC_COLLATE
, _NL_COLLATE_NRULES
);
349 const CHAR
*startp
= p
;
361 if (c
!= L('=') || p
[1] != L(']'))
371 if ((UCHAR
) *n
== str
[0])
376 const int32_t *table
;
377 # if WIDE_CHAR_VERSION
378 const int32_t *weights
;
379 const int32_t *extra
;
381 const unsigned char *weights
;
382 const unsigned char *extra
;
384 const int32_t *indirect
;
386 const UCHAR
*cp
= (const UCHAR
*) str
;
388 /* This #include defines a local function! */
389 # if WIDE_CHAR_VERSION
390 # include <locale/weightwc.h>
392 # include <locale/weight.h>
395 # if WIDE_CHAR_VERSION
396 table
= (const int32_t *)
397 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_TABLEWC
);
398 weights
= (const int32_t *)
399 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_WEIGHTWC
);
400 extra
= (const int32_t *)
401 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_EXTRAWC
);
402 indirect
= (const int32_t *)
403 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_INDIRECTWC
);
405 table
= (const int32_t *)
406 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_TABLEMB
);
407 weights
= (const unsigned char *)
408 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_WEIGHTMB
);
409 extra
= (const unsigned char *)
410 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_EXTRAMB
);
411 indirect
= (const int32_t *)
412 _NL_CURRENT (LC_COLLATE
, _NL_COLLATE_INDIRECTMB
);
418 /* We found a table entry. Now see whether the
419 character we are currently at has the same
420 equivalance class value. */
421 int len
= weights
[idx
& 0xffffff];
423 const UCHAR
*np
= (const UCHAR
*) n
;
425 idx2
= findidx (&np
);
427 && (idx
>> 24) == (idx2
>> 24)
428 && len
== weights
[idx2
& 0xffffff])
436 && (weights
[idx
+ 1 + cnt
]
437 == weights
[idx2
+ 1 + cnt
]))
449 else if (c
== L('\0'))
450 /* [ (unterminated) loses. */
459 if (c
== L('[') && *p
== L('.'))
462 _NL_CURRENT_WORD (LC_COLLATE
, _NL_COLLATE_NRULES
);
463 const CHAR
*startp
= p
;
469 if (c
== L('.') && p
[1] == L(']'))
479 /* We have to handling the symbols differently in
480 ranges since then the collation sequence is
482 is_range
= *p
== L('-') && p
[1] != L('\0');
486 /* There are no names defined in the collation
487 data. Therefore we only accept the trivial
488 names consisting of the character itself. */
492 if (!is_range
&& *n
== startp
[1])
501 const int32_t *symb_table
;
502 # ifdef WIDE_CHAR_VERSION
506 # define str (startp + 1)
508 const unsigned char *extra
;
514 # ifdef WIDE_CHAR_VERSION
515 /* We have to convert the name to a single-byte
516 string. This is possible since the names
517 consist of ASCII characters and the internal
518 representation is UCS4. */
519 for (strcnt
= 0; strcnt
< c1
; ++strcnt
)
520 str
[strcnt
] = startp
[1 + strcnt
];
524 _NL_CURRENT_WORD (LC_COLLATE
,
525 _NL_COLLATE_SYMB_HASH_SIZEMB
);
526 symb_table
= (const int32_t *)
527 _NL_CURRENT (LC_COLLATE
,
528 _NL_COLLATE_SYMB_TABLEMB
);
529 extra
= (const unsigned char *)
530 _NL_CURRENT (LC_COLLATE
,
531 _NL_COLLATE_SYMB_EXTRAMB
);
533 /* Locate the character in the hashing table. */
534 hash
= elem_hash (str
, c1
);
537 elem
= hash
% table_size
;
538 if (symb_table
[2 * elem
] != 0)
540 second
= hash
% (table_size
- 2) + 1;
544 /* First compare the hashing value. */
545 if (symb_table
[2 * elem
] == hash
547 == extra
[symb_table
[2 * elem
+ 1]])
549 &extra
[symb_table
[2 * elem
553 /* Yep, this is the entry. */
554 idx
= symb_table
[2 * elem
+ 1];
555 idx
+= 1 + extra
[idx
];
562 while (symb_table
[2 * elem
] != 0);
565 if (symb_table
[2 * elem
] != 0)
567 /* Compare the byte sequence but only if
568 this is not part of a range. */
569 # ifdef WIDE_CHAR_VERSION
572 idx
+= 1 + extra
[idx
];
573 /* Adjust for the alignment. */
574 idx
= (idx
+ 3) & ~3;
576 wextra
= (int32_t *) &extra
[idx
+ 4];
581 # ifdef WIDE_CHAR_VERSION
583 (int32_t) c1
< wextra
[idx
];
585 if (n
[c1
] != wextra
[1 + c1
])
588 if ((int32_t) c1
== wextra
[idx
])
591 for (c1
= 0; c1
< extra
[idx
]; ++c1
)
592 if (n
[c1
] != extra
[1 + c1
])
595 if (c1
== extra
[idx
])
600 /* Get the collation sequence value. */
602 # ifdef WIDE_CHAR_VERSION
603 cold
= wextra
[1 + wextra
[idx
]];
605 /* Adjust for the alignment. */
606 idx
+= 1 + extra
[idx
];
607 idx
= (idx
+ 3) & ~4;
608 cold
= *((int32_t *) &extra
[idx
]);
615 /* No valid character. Match it as a
617 if (!is_range
&& *n
== str
[0])
634 /* We have to handling the symbols differently in
635 ranges since then the collation sequence is
637 is_range
= (*p
== L('-') && p
[1] != L('\0')
640 if (!is_range
&& c
== fn
)
643 /* This is needed if we goto normal_bracket; from
644 outside of is_seqval's scope. */
650 if (c
== L('-') && *p
!= L(']'))
653 /* We have to find the collation sequence
654 value for C. Collation sequence is nothing
655 we can regularly access. The sequence
656 value is defined by the order in which the
657 definitions of the collation values for the
658 various characters appear in the source
659 file. A strange concept, nowhere
665 # ifdef WIDE_CHAR_VERSION
666 /* Search in the `names' array for the characters. */
667 fcollseq
= __collseq_table_lookup (collseq
, fn
);
668 if (fcollseq
== ~((uint32_t) 0))
669 /* XXX We don't know anything about the character
670 we are supposed to match. This means we are
672 goto range_not_matched
;
677 lcollseq
= __collseq_table_lookup (collseq
, cold
);
679 fcollseq
= collseq
[fn
];
680 lcollseq
= is_seqval
? cold
: collseq
[(UCHAR
) cold
];
684 if (cend
== L('[') && *p
== L('.'))
687 _NL_CURRENT_WORD (LC_COLLATE
,
689 const CHAR
*startp
= p
;
695 if (c
== L('.') && p
[1] == L(']'))
707 /* There are no names defined in the
708 collation data. Therefore we only
709 accept the trivial names consisting
710 of the character itself. */
719 const int32_t *symb_table
;
720 # ifdef WIDE_CHAR_VERSION
724 # define str (startp + 1)
726 const unsigned char *extra
;
732 # ifdef WIDE_CHAR_VERSION
733 /* We have to convert the name to a single-byte
734 string. This is possible since the names
735 consist of ASCII characters and the internal
736 representation is UCS4. */
737 for (strcnt
= 0; strcnt
< c1
; ++strcnt
)
738 str
[strcnt
] = startp
[1 + strcnt
];
742 _NL_CURRENT_WORD (LC_COLLATE
,
743 _NL_COLLATE_SYMB_HASH_SIZEMB
);
744 symb_table
= (const int32_t *)
745 _NL_CURRENT (LC_COLLATE
,
746 _NL_COLLATE_SYMB_TABLEMB
);
747 extra
= (const unsigned char *)
748 _NL_CURRENT (LC_COLLATE
,
749 _NL_COLLATE_SYMB_EXTRAMB
);
751 /* Locate the character in the hashing
753 hash
= elem_hash (str
, c1
);
756 elem
= hash
% table_size
;
757 if (symb_table
[2 * elem
] != 0)
759 second
= hash
% (table_size
- 2) + 1;
763 /* First compare the hashing value. */
764 if (symb_table
[2 * elem
] == hash
766 == extra
[symb_table
[2 * elem
+ 1]])
768 &extra
[symb_table
[2 * elem
+ 1]
771 /* Yep, this is the entry. */
772 idx
= symb_table
[2 * elem
+ 1];
773 idx
+= 1 + extra
[idx
];
780 while (symb_table
[2 * elem
] != 0);
783 if (symb_table
[2 * elem
] != 0)
785 /* Compare the byte sequence but only if
786 this is not part of a range. */
787 # ifdef WIDE_CHAR_VERSION
790 idx
+= 1 + extra
[idx
];
791 /* Adjust for the alignment. */
792 idx
= (idx
+ 3) & ~4;
794 wextra
= (int32_t *) &extra
[idx
+ 4];
796 /* Get the collation sequence value. */
798 # ifdef WIDE_CHAR_VERSION
799 cend
= wextra
[1 + wextra
[idx
]];
801 /* Adjust for the alignment. */
802 idx
+= 1 + extra
[idx
];
803 idx
= (idx
+ 3) & ~4;
804 cend
= *((int32_t *) &extra
[idx
]);
807 else if (symb_table
[2 * elem
] != 0 && c1
== 1)
819 if (!(flags
& FNM_NOESCAPE
) && cend
== L('\\'))
826 /* XXX It is not entirely clear to me how to handle
827 characters which are not mentioned in the
828 collation specification. */
830 # ifdef WIDE_CHAR_VERSION
831 lcollseq
== 0xffffffff ||
833 lcollseq
<= fcollseq
)
835 /* We have to look at the upper bound. */
842 # ifdef WIDE_CHAR_VERSION
844 __collseq_table_lookup (collseq
, cend
);
845 if (hcollseq
== ~((uint32_t) 0))
847 /* Hum, no information about the upper
848 bound. The matching succeeds if the
849 lower bound is matched exactly. */
850 if (lcollseq
!= fcollseq
)
851 goto range_not_matched
;
856 hcollseq
= collseq
[cend
];
860 if (lcollseq
<= hcollseq
&& fcollseq
<= hcollseq
)
863 # ifdef WIDE_CHAR_VERSION
867 /* We use a boring value comparison of the character
868 values. This is better than comparing using
869 `strcoll' since the latter would have surprising
870 and sometimes fatal consequences. */
873 if (!(flags
& FNM_NOESCAPE
) && cend
== L('\\'))
879 if (cold
<= fn
&& fn
<= cend
)
896 /* Skip the rest of the [...] that already matched. */
903 /* [... (unterminated) loses. */
906 if (!(flags
& FNM_NOESCAPE
) && c
== L('\\'))
910 /* XXX 1003.2d11 is unclear if this is right. */
913 else if (c
== L('[') && *p
== L(':'))
916 const CHAR
*startp
= p
;
921 if (++c1
== CHAR_CLASS_MAX_LENGTH
)
924 if (*p
== L(':') && p
[1] == L(']'))
927 if (c
< L('a') || c
>= L('z'))
936 else if (c
== L('[') && *p
== L('='))
942 if (c
!= L('=') || p
[1] != L(']'))
947 else if (c
== L('[') && *p
== L('.'))
956 if (*p
== L('.') && p
[1] == L(']'))
972 if (__builtin_expect (flags
& FNM_EXTMATCH
, 0) && *p
== '(')
976 res
= EXT (c
, p
, n
, string_end
, no_leading_period
, flags
);
983 if (NO_LEADING_PERIOD (flags
))
985 if (n
== string_end
|| c
!= (UCHAR
) *n
)
988 new_no_leading_period
= 1;
994 if (n
== string_end
|| c
!= FOLD ((UCHAR
) *n
))
998 no_leading_period
= new_no_leading_period
;
1002 if (n
== string_end
)
1005 if ((flags
& FNM_LEADING_DIR
) && n
!= string_end
&& *n
== L('/'))
1006 /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */
1015 END (const CHAR
*pattern
)
1017 const CHAR
*p
= pattern
;
1020 if (*++p
== L('\0'))
1021 /* This is an invalid pattern. */
1023 else if (*p
== L('['))
1025 /* Handle brackets special. */
1026 if (posixly_correct
== 0)
1027 posixly_correct
= getenv ("POSIXLY_CORRECT") != NULL
? 1 : -1;
1029 /* Skip the not sign. We have to recognize it because of a possibly
1031 if (*++p
== L('!') || (posixly_correct
< 0 && *p
== L('^')))
1033 /* A leading ']' is recognized as such. */
1036 /* Skip over all characters of the list. */
1037 while (*p
!= L(']'))
1038 if (*p
++ == L('\0'))
1039 /* This is no valid pattern. */
1042 else if ((*p
== L('?') || *p
== L('*') || *p
== L('+') || *p
== L('@')
1043 || *p
== L('!')) && p
[1] == L('('))
1045 else if (*p
== L(')'))
1054 EXT (INT opt
, const CHAR
*pattern
, const CHAR
*string
, const CHAR
*string_end
,
1055 int no_leading_period
, int flags
)
1061 struct patternlist
*next
;
1064 struct patternlist
**lastp
= &list
;
1065 size_t pattern_len
= STRLEN (pattern
);
1069 /* Parse the pattern. Store the individual parts in the list. */
1071 for (startp
= p
= pattern
+ 1; level
>= 0; ++p
)
1073 /* This is an invalid pattern. */
1075 else if (*p
== L('['))
1077 /* Handle brackets special. */
1078 if (posixly_correct
== 0)
1079 posixly_correct
= getenv ("POSIXLY_CORRECT") != NULL
? 1 : -1;
1081 /* Skip the not sign. We have to recognize it because of a possibly
1083 if (*++p
== L('!') || (posixly_correct
< 0 && *p
== L('^')))
1085 /* A leading ']' is recognized as such. */
1088 /* Skip over all characters of the list. */
1089 while (*p
!= L(']'))
1090 if (*p
++ == L('\0'))
1091 /* This is no valid pattern. */
1094 else if ((*p
== L('?') || *p
== L('*') || *p
== L('+') || *p
== L('@')
1095 || *p
== L('!')) && p
[1] == L('('))
1096 /* Remember the nesting level. */
1098 else if (*p
== L(')'))
1102 /* This means we found the end of the pattern. */
1103 #define NEW_PATTERN \
1104 struct patternlist *newp; \
1106 if (opt == L('?') || opt == L('@')) \
1107 newp = alloca (sizeof (struct patternlist) \
1108 + (pattern_len * sizeof (CHAR))); \
1110 newp = alloca (sizeof (struct patternlist) \
1111 + ((p - startp + 1) * sizeof (CHAR))); \
1112 *((CHAR *) MEMPCPY (newp->str, startp, p - startp)) = L('\0'); \
1113 newp->next = NULL; \
1119 else if (*p
== L('|'))
1127 assert (list
!= NULL
);
1128 assert (p
[-1] == L(')'));
1134 if (FCT (p
, string
, string_end
, no_leading_period
, flags
, NULL
) == 0)
1141 for (rs
= string
; rs
<= string_end
; ++rs
)
1142 /* First match the prefix with the current pattern with the
1144 if (FCT (list
->str
, string
, rs
, no_leading_period
,
1145 flags
& FNM_FILE_NAME
? flags
: flags
& ~FNM_PERIOD
,
1147 /* This was successful. Now match the rest with the rest
1149 && (FCT (p
, rs
, string_end
,
1152 : rs
[-1] == '/' && NO_LEADING_PERIOD (flags
) ? 1 : 0,
1153 flags
& FNM_FILE_NAME
1154 ? flags
: flags
& ~FNM_PERIOD
, NULL
) == 0
1155 /* This didn't work. Try the whole pattern. */
1157 && FCT (pattern
- 1, rs
, string_end
,
1160 : (rs
[-1] == '/' && NO_LEADING_PERIOD (flags
)
1162 flags
& FNM_FILE_NAME
1163 ? flags
: flags
& ~FNM_PERIOD
, NULL
) == 0)))
1164 /* It worked. Signal success. */
1167 while ((list
= list
->next
) != NULL
);
1169 /* None of the patterns lead to a match. */
1173 if (FCT (p
, string
, string_end
, no_leading_period
, flags
, NULL
) == 0)
1179 /* I cannot believe it but `strcat' is actually acceptable
1180 here. Match the entire string with the prefix from the
1181 pattern list and the rest of the pattern following the
1183 if (FCT (STRCAT (list
->str
, p
), string
, string_end
,
1185 flags
& FNM_FILE_NAME
? flags
: flags
& ~FNM_PERIOD
,
1187 /* It worked. Signal success. */
1189 while ((list
= list
->next
) != NULL
);
1191 /* None of the patterns lead to a match. */
1195 for (rs
= string
; rs
<= string_end
; ++rs
)
1197 struct patternlist
*runp
;
1199 for (runp
= list
; runp
!= NULL
; runp
= runp
->next
)
1200 if (FCT (runp
->str
, string
, rs
, no_leading_period
,
1201 flags
& FNM_FILE_NAME
? flags
: flags
& ~FNM_PERIOD
,
1205 /* If none of the patterns matched see whether the rest does. */
1207 && (FCT (p
, rs
, string_end
,
1210 : rs
[-1] == '/' && NO_LEADING_PERIOD (flags
) ? 1 : 0,
1211 flags
& FNM_FILE_NAME
? flags
: flags
& ~FNM_PERIOD
,
1213 /* This is successful. */
1217 /* None of the patterns together with the rest of the pattern
1222 assert (! "Invalid extended matching operator");