1 /* Copyright (C) 1991-2017 Free Software Foundation, Inc.
3 NOTE: This source is derived from an old version taken from the GNU C
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 51 Franklin Street - Fifth Floor,
19 Boston, MA 02110-1301, USA. */
22 #if defined (CONFIG_BROKETS)
23 /* We use <config.h> instead of "config.h" so that a compilation
24 using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
25 (which it would do because it found this file in $srcdir). */
37 /* This code to undef const added in libiberty. */
39 /* This is a separate conditional since some stdc systems
40 reject `defined (const)'. */
48 #include <safe-ctype.h>
50 /* Comment out all this code if we are using the GNU C Library, and are not
51 actually compiling the library itself. This code is part of the GNU C
52 Library, but also included in many other GNU distributions. Compiling
53 and linking in this code is a waste when using the GNU C library
54 (especially if it is a shared library). Rather than having every GNU
55 program understand `configure --with-gnu-libc' and omit the object files,
56 it is simpler to just do this in the source for each such file. */
58 #if defined (_LIBC) || !defined (__GNU_LIBRARY__)
61 #if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS)
65 /* Match STRING against the filename pattern PATTERN, returning zero if
66 it matches, nonzero if not. */
68 fnmatch (const char *pattern
, const char *string
, int flags
)
70 register const char *p
= pattern
, *n
= string
;
71 register unsigned char c
;
73 #define FOLD(c) ((flags & FNM_CASEFOLD) ? TOLOWER (c) : (c))
75 while ((c
= *p
++) != '\0')
84 else if ((flags
& FNM_FILE_NAME
) && *n
== '/')
86 else if ((flags
& FNM_PERIOD
) && *n
== '.' &&
87 (n
== string
|| ((flags
& FNM_FILE_NAME
) && n
[-1] == '/')))
92 if (!(flags
& FNM_NOESCAPE
))
97 if (FOLD ((unsigned char)*n
) != c
)
102 if ((flags
& FNM_PERIOD
) && *n
== '.' &&
103 (n
== string
|| ((flags
& FNM_FILE_NAME
) && n
[-1] == '/')))
106 for (c
= *p
++; c
== '?' || c
== '*'; c
= *p
++, ++n
)
107 if (((flags
& FNM_FILE_NAME
) && *n
== '/') ||
108 (c
== '?' && *n
== '\0'))
115 unsigned char c1
= (!(flags
& FNM_NOESCAPE
) && c
== '\\') ? *p
: c
;
117 for (--p
; *n
!= '\0'; ++n
)
118 if ((c
== '[' || FOLD ((unsigned char)*n
) == c1
) &&
119 fnmatch (p
, n
, flags
& ~FNM_PERIOD
) == 0)
126 /* Nonzero if the sense of the character class is inverted. */
132 if ((flags
& FNM_PERIOD
) && *n
== '.' &&
133 (n
== string
|| ((flags
& FNM_FILE_NAME
) && n
[-1] == '/')))
136 negate
= (*p
== '!' || *p
== '^');
143 register unsigned char cstart
= c
, cend
= c
;
145 if (!(flags
& FNM_NOESCAPE
) && c
== '\\')
146 cstart
= cend
= *p
++;
148 cstart
= cend
= FOLD (cstart
);
151 /* [ (unterminated) loses. */
157 if ((flags
& FNM_FILE_NAME
) && c
== '/')
158 /* [/] can never match. */
161 if (c
== '-' && *p
!= ']')
164 if (!(flags
& FNM_NOESCAPE
) && cend
== '\\')
173 if (FOLD ((unsigned char)*n
) >= cstart
174 && FOLD ((unsigned char)*n
) <= cend
)
185 /* Skip the rest of the [...] that already matched. */
189 /* [... (unterminated) loses. */
193 if (!(flags
& FNM_NOESCAPE
) && c
== '\\')
194 /* XXX 1003.2d11 is unclear if this is right. */
203 if (c
!= FOLD ((unsigned char)*n
))
213 if ((flags
& FNM_LEADING_DIR
) && *n
== '/')
214 /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */
220 #endif /* _LIBC or not __GNU_LIBRARY__. */
This page took 0.034323 seconds and 4 git commands to generate.