1 /* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
3 NOTE: The canonical source of this file is maintained with the GNU C Library.
4 Bugs can be reported to bug-glibc@prep.ai.mit.edu.
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, 675 Mass Ave, Cambridge, MA 02139, USA. */
20 /* Modified for GNU ld to include sysdep.h. */
24 #if defined (CONFIG_BROKETS)
25 /* We use <config.h> instead of "config.h" so that a compilation
26 using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
27 (which it would do because it found this file in $srcdir). */
44 /* Comment out all this code if we are using the GNU C Library, and are not
45 actually compiling the library itself. This code is part of the GNU C
46 Library, but also included in many other GNU distributions. Compiling
47 and linking in this code is a waste when using the GNU C library
48 (especially if it is a shared library). Rather than having every GNU
49 program understand `configure --with-gnu-libc' and omit the object files,
50 it is simpler to just do this in the source for each such file. */
52 #if defined (_LIBC) || !defined (__GNU_LIBRARY__)
55 #if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS)
59 /* Match STRING against the filename pattern PATTERN, returning zero if
60 it matches, nonzero if not. */
62 fnmatch (pattern
, string
, flags
)
67 register const char *p
= pattern
, *n
= string
;
70 /* Note that this evalutes C many times. */
71 #define FOLD(c) ((flags & FNM_CASEFOLD) && isupper (c) ? tolower (c) : (c))
73 while ((c
= *p
++) != '\0')
82 else if ((flags
& FNM_FILE_NAME
) && *n
== '/')
84 else if ((flags
& FNM_PERIOD
) && *n
== '.' &&
85 (n
== string
|| ((flags
& FNM_FILE_NAME
) && n
[-1] == '/')))
90 if (!(flags
& FNM_NOESCAPE
))
100 if ((flags
& FNM_PERIOD
) && *n
== '.' &&
101 (n
== string
|| ((flags
& FNM_FILE_NAME
) && n
[-1] == '/')))
104 for (c
= *p
++; c
== '?' || c
== '*'; c
= *p
++, ++n
)
105 if (((flags
& FNM_FILE_NAME
) && *n
== '/') ||
106 (c
== '?' && *n
== '\0'))
113 char c1
= (!(flags
& FNM_NOESCAPE
) && c
== '\\') ? *p
: c
;
115 for (--p
; *n
!= '\0'; ++n
)
116 if ((c
== '[' || FOLD (*n
) == c1
) &&
117 fnmatch (p
, n
, flags
& ~FNM_PERIOD
) == 0)
124 /* Nonzero if the sense of the character class is inverted. */
130 if ((flags
& FNM_PERIOD
) && *n
== '.' &&
131 (n
== string
|| ((flags
& FNM_FILE_NAME
) && n
[-1] == '/')))
134 not = (*p
== '!' || *p
== '^');
141 register char cstart
= c
, cend
= c
;
143 if (!(flags
& FNM_NOESCAPE
) && c
== '\\')
144 cstart
= cend
= *p
++;
146 cstart
= cend
= FOLD (cstart
);
149 /* [ (unterminated) loses. */
155 if ((flags
& FNM_FILE_NAME
) && c
== '/')
156 /* [/] can never match. */
159 if (c
== '-' && *p
!= ']')
162 if (!(flags
& FNM_NOESCAPE
) && cend
== '\\')
171 if (FOLD (*n
) >= cstart
&& FOLD (*n
) <= cend
)
182 /* Skip the rest of the [...] that already matched. */
186 /* [... (unterminated) loses. */
190 if (!(flags
& FNM_NOESCAPE
) && c
== '\\')
191 /* XXX 1003.2d11 is unclear if this is right. */
210 if ((flags
& FNM_LEADING_DIR
) && *n
== '/')
211 /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */
217 #endif /* _LIBC or not __GNU_LIBRARY__. */
This page took 0.032711 seconds and 4 git commands to generate.