-/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2024 Free Software Foundation, Inc.
-NOTE: The canonical source of this file is maintained with the GNU C Library.
-Bugs can be reported to bug-glibc@prep.ai.mit.edu.
+NOTE: This source is derived from an old version taken from the GNU C
+Library (glibc).
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+Foundation, 51 Franklin Street - Fifth Floor,
+Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
#if defined (CONFIG_BROKETS)
#include <errno.h>
#include <fnmatch.h>
-#include <ctype.h>
-
+#include <safe-ctype.h>
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
/* Match STRING against the filename pattern PATTERN, returning zero if
it matches, nonzero if not. */
int
-fnmatch (pattern, string, flags)
- const char *pattern;
- const char *string;
- int flags;
+fnmatch (const char *pattern, const char *string, int flags)
{
register const char *p = pattern, *n = string;
register unsigned char c;
-/* Note that this evalutes C many times. */
-#define FOLD(c) ((flags & FNM_CASEFOLD) && isupper (c) ? tolower (c) : (c))
+#define FOLD(c) ((flags & FNM_CASEFOLD) ? TOLOWER (c) : (c))
while ((c = *p++) != '\0')
{
case '[':
{
/* Nonzero if the sense of the character class is inverted. */
- register int not;
+ register int negate;
if (*n == '\0')
return FNM_NOMATCH;
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
return FNM_NOMATCH;
- not = (*p == '!' || *p == '^');
- if (not)
+ negate = (*p == '!' || *p == '^');
+ if (negate)
++p;
c = *p++;
if (c == ']')
break;
}
- if (!not)
+ if (!negate)
return FNM_NOMATCH;
break;
/* XXX 1003.2d11 is unclear if this is right. */
++p;
}
- if (not)
+ if (negate)
return FNM_NOMATCH;
}
break;