summaryrefslogtreecommitdiff
path: root/posix/fnmatch.c
diff options
context:
space:
mode:
Diffstat (limited to 'posix/fnmatch.c')
-rw-r--r--posix/fnmatch.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/posix/fnmatch.c b/posix/fnmatch.c
index de45941f8f..553a968eed 100644
--- a/posix/fnmatch.c
+++ b/posix/fnmatch.c
@@ -15,13 +15,13 @@ License along with this library; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA. */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
+#if HAVE_CONFIG_H
+# include <config.h>
#endif
/* Enable GNU extensions in fnmatch.h. */
#ifndef _GNU_SOURCE
-#define _GNU_SOURCE 1
+# define _GNU_SOURCE 1
#endif
#include <errno.h>
@@ -40,9 +40,18 @@ Cambridge, MA 02139, USA. */
#if defined (_LIBC) || !defined (__GNU_LIBRARY__)
-#ifndef errno
+# if defined (STDC_HEADERS) || !defined (isascii)
+# define ISASCII(c) 1
+# else
+# define ISASCII(c) isascii(c)
+# endif
+
+# define ISUPPER(c) (ISASCII (c) && isupper (c))
+
+
+# ifndef errno
extern int errno;
-#endif
+# endif
/* Match STRING against the filename pattern PATTERN, returning zero if
it matches, nonzero if not. */
@@ -56,7 +65,7 @@ fnmatch (pattern, string, flags)
register 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) && ISUPPER (c) ? tolower (c) : (c))
while ((c = *p++) != '\0')
{
@@ -225,6 +234,8 @@ fnmatch (pattern, string, flags)
return 0;
return FNM_NOMATCH;
+
+# undef FOLD
}
#endif /* _LIBC or not __GNU_LIBRARY__. */