summaryrefslogtreecommitdiff
path: root/libc/misc/fnmatch
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc/fnmatch')
-rw-r--r--libc/misc/fnmatch/fnmatch.c118
-rw-r--r--libc/misc/fnmatch/fnmatch_loop.c6
-rw-r--r--libc/misc/fnmatch/fnmatch_old.c11
3 files changed, 73 insertions, 62 deletions
diff --git a/libc/misc/fnmatch/fnmatch.c b/libc/misc/fnmatch/fnmatch.c
index d5d3e753b..dc18c2f59 100644
--- a/libc/misc/fnmatch/fnmatch.c
+++ b/libc/misc/fnmatch/fnmatch.c
@@ -17,8 +17,6 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define strcmp __strcmp
-
#if HAVE_CONFIG_H
# include <config.h>
#endif
@@ -34,11 +32,6 @@
# define HAVE_STRING_H 1
# define STDC_HEADERS
# define HAVE___STRCHRNUL 1
-extern void *__mempcpy (void *__restrict __dest,
- __const void *__restrict __src, size_t __n)
- __THROW __nonnull ((1, 2)) attribute_hidden;
-extern void *__memchr (__const void *__s, int __c, size_t __n)
- __THROW __attribute_pure__ __nonnull ((1)) attribute_hidden;
# ifdef __UCLIBC_HAS_WCHAR__
# define HAVE_WCHAR_H 1
# define HAVE_WCTYPE_H 1
@@ -64,6 +57,22 @@ extern void *__memchr (__const void *__s, int __c, size_t __n)
# include <stdlib.h>
#endif
+#ifdef __UCLIBC__
+#define __memset memset
+libc_hidden_proto(memchr)
+libc_hidden_proto(memset)
+libc_hidden_proto(mempcpy)
+libc_hidden_proto(strcat)
+libc_hidden_proto(strcmp)
+/*libc_hidden_proto(strchr)*/
+/*libc_hidden_proto(strchrnul)*/
+libc_hidden_proto(strlen)
+libc_hidden_proto(strcoll)
+libc_hidden_proto(tolower)
+libc_hidden_proto(fnmatch)
+libc_hidden_proto(getenv)
+#endif
+
/* For platform which support the ISO C amendement 1 functionality we
support user defined character classes. */
#if defined _LIBC || (defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H)
@@ -71,24 +80,20 @@ extern void *__memchr (__const void *__s, int __c, size_t __n)
# include <wchar.h>
# include <wctype.h>
# ifdef __UCLIBC__
-extern wctype_t __wctype (__const char *__property) __THROW attribute_hidden;
-extern int __iswctype (wint_t __wc, wctype_t __desc) __THROW attribute_hidden;
-extern wint_t __btowc (int __c) __THROW attribute_hidden;
+libc_hidden_proto(wctype)
+libc_hidden_proto(iswctype)
+libc_hidden_proto(btowc)
# ifdef __UCLIBC_HAS_LOCALE__
-extern size_t __mbsrtowcs (wchar_t *__restrict __dst,
- __const char **__restrict __src, size_t __len,
- mbstate_t *__restrict __ps) __THROW attribute_hidden;
-extern size_t __wcslen (__const wchar_t *__s) __THROW __attribute_pure__ attribute_hidden;
-extern wchar_t *__wmempcpy (wchar_t *__restrict __s1,
- __const wchar_t *__restrict __s2, size_t __n)
- __THROW attribute_hidden;
-extern wchar_t *__wcscat (wchar_t *__restrict __dest,
- __const wchar_t *__restrict __src) __THROW attribute_hidden;
-extern size_t __strnlen (__const char *__string, size_t __maxlen)
- __THROW __attribute_pure__ __nonnull ((1)) attribute_hidden;
-extern wchar_t *__wmemchr (__const wchar_t *__s, wchar_t __c, size_t __n)
- __THROW __attribute_pure__ attribute_hidden;
-extern wint_t __towlower (wint_t __wc) __THROW attribute_hidden;
+libc_hidden_proto(wmemchr)
+libc_hidden_proto(wmempcpy)
+libc_hidden_proto(wcscat)
+/*libc_hidden_proto(wcschr)*/
+/*libc_hidden_proto(wcschrnul)*/
+libc_hidden_proto(wcslen)
+libc_hidden_proto(wcscoll)
+libc_hidden_proto(towlower)
+libc_hidden_proto(mbsrtowcs)
+libc_hidden_proto(strnlen)
# endif
# endif
#endif
@@ -96,21 +101,22 @@ extern wint_t __towlower (wint_t __wc) __THROW attribute_hidden;
/* We need some of the locale data (the collation sequence information)
but there is no interface to get this information in general. Therefore
we support a correct implementation only in glibc. */
-#if defined _LIBC || defined __UCLIBC__
-# ifndef __UCLIBC__
+#if defined _LIBC
# include "../locale/localeinfo.h"
# include "../locale/elem-hash.h"
# include "../locale/coll-lookup.h"
# include <shlib-compat.h>
-# endif
# define CONCAT(a,b) __CONCAT(a,b)
-# if defined _LIBC || defined __UCLIBC_HAS_LOCALE__
+# if defined _LIBC
# define mbsrtowcs __mbsrtowcs
# endif
# define fnmatch __fnmatch
extern int fnmatch (const char *pattern, const char *string, int flags) attribute_hidden;
#endif
+#ifdef __UCLIBC__
+# define CONCAT(a,b) __CONCAT(a,b)
+#endif
/* We often have to test for FNM_FILE_NAME and FNM_PERIOD being both set. */
#define NO_LEADING_PERIOD(flags) \
@@ -168,13 +174,13 @@ extern int fnmatch (const char *pattern, const char *string, int flags) attribut
# define CHAR_CLASS_MAX_LENGTH 256
# endif
-# if defined _LIBC || defined __UCLIBC__
+# if defined _LIBC
# define IS_CHAR_CLASS(string) __wctype (string)
# else
# define IS_CHAR_CLASS(string) wctype (string)
# endif
-# if defined _LIBC || defined __UCLIBC__
+# if defined _LIBC
# define ISWCTYPE(WC, WT) __iswctype (WC, WT)
# else
# define ISWCTYPE(WC, WT) iswctype (WC, WT)
@@ -246,7 +252,7 @@ __wcschrnul (s, c)
# endif
/* Note that this evaluates C many times. */
-# if defined _LIBC || defined __UCLIBC__
+# if defined _LIBC
# define FOLD(c) ((flags & FNM_CASEFOLD) ? __tolower (c) : (c))
# else
# define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
@@ -258,22 +264,22 @@ __wcschrnul (s, c)
# define EXT ext_match
# define END end_pattern
# define L(CS) CS
-# if defined _LIBC || defined __UCLIBC__
+# if defined _LIBC
# define BTOWC(C) __btowc (C)
# else
# define BTOWC(C) btowc (C)
# endif
-# define STRLEN(S) __strlen (S)
-# define STRCAT(D, S) __strcat (D, S)
-# define MEMPCPY(D, S, N) __mempcpy (D, S, N)
-# define MEMCHR(S, C, N) __memchr (S, C, N)
-# define STRCOLL(S1, S2) __strcoll (S1, S2)
+# define STRLEN(S) strlen (S)
+# define STRCAT(D, S) strcat (D, S)
+# define MEMPCPY(D, S, N) mempcpy (D, S, N)
+# define MEMCHR(S, C, N) memchr (S, C, N)
+# define STRCOLL(S1, S2) strcoll (S1, S2)
# include "fnmatch_loop.c"
# if HANDLE_MULTIBYTE
/* Note that this evaluates C many times. */
-# if defined _LIBC || defined __UCLIBC__
+# if defined _LIBC
# define FOLD(c) ((flags & FNM_CASEFOLD) ? __towlower (c) : (c))
# else
# define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? towlower (c) : (c))
@@ -286,11 +292,11 @@ __wcschrnul (s, c)
# define END end_wpattern
# define L(CS) L##CS
# define BTOWC(C) (C)
-# define STRLEN(S) __wcslen (S)
-# define STRCAT(D, S) __wcscat (D, S)
-# define MEMPCPY(D, S, N) __wmempcpy (D, S, N)
-# define MEMCHR(S, C, N) __wmemchr (S, C, N)
-# define STRCOLL(S1, S2) __wcscoll (S1, S2)
+# define STRLEN(S) wcslen (S)
+# define STRCAT(D, S) wcscat (D, S)
+# define MEMPCPY(D, S, N) wmempcpy (D, S, N)
+# define MEMCHR(S, C, N) wmemchr (S, C, N)
+# define STRCOLL(S1, S2) wcscoll (S1, S2)
# ifndef __UCLIBC__
# define WIDE_CHAR_VERSION 1
# endif
@@ -354,7 +360,7 @@ is_char_class (const wchar_t *wcs)
*cp = '\0';
-# if defined _LIBC || defined __UCLIBC__
+# if defined _LIBC
return __wctype (s);
# else
return wctype (s);
@@ -365,15 +371,16 @@ is_char_class (const wchar_t *wcs)
# include "fnmatch_loop.c"
# endif
+extern size_t _stdlib_mb_cur_max (void) __THROW __wur;
+libc_hidden_proto(_stdlib_mb_cur_max)
-int attribute_hidden
+int
fnmatch (const char *pattern, const char *string, int flags)
{
# if HANDLE_MULTIBYTE
# ifdef __UCLIBC_HAS_WCHAR__
# undef MB_CUR_MAX
-# define MB_CUR_MAX (_stdlib_mb_cur_max_internal ())
-extern size_t _stdlib_mb_cur_max_internal (void) __THROW __wur attribute_hidden;
+# define MB_CUR_MAX (_stdlib_mb_cur_max ())
# endif
if (__builtin_expect (MB_CUR_MAX, 1) != 1)
{
@@ -387,9 +394,9 @@ extern size_t _stdlib_mb_cur_max_internal (void) __THROW __wur attribute_hidden;
__memset (&ps, '\0', sizeof (ps));
p = pattern;
#if defined _LIBC || defined __UCLIBC__
- n = __strnlen (pattern, 1024);
+ n = strnlen (pattern, 1024);
#else
- n = __strlen (pattern);
+ n = strlen (pattern);
#endif
if (__builtin_expect (n < 1024, 1))
{
@@ -418,9 +425,9 @@ extern size_t _stdlib_mb_cur_max_internal (void) __THROW __wur attribute_hidden;
assert (mbsinit (&ps));
#if defined _LIBC || defined __UCLIBC__
- n = __strnlen (string, 1024);
+ n = strnlen (string, 1024);
#else
- n = __strlen (string);
+ n = strlen (string);
#endif
p = string;
if (__builtin_expect (n < 1024, 1))
@@ -453,11 +460,11 @@ extern size_t _stdlib_mb_cur_max_internal (void) __THROW __wur attribute_hidden;
}
# endif /* mbstate_t and mbsrtowcs or _LIBC. */
- return internal_fnmatch (pattern, string, string + __strlen (string),
+ return internal_fnmatch (pattern, string, string + strlen (string),
flags & FNM_PERIOD, flags);
}
-# if defined _LIBC || defined __UCLIBC__
+# if defined _LIBC
# undef fnmatch
# ifndef __UCLIBC__
versioned_symbol (libc, __fnmatch, fnmatch, GLIBC_2_2_3);
@@ -466,9 +473,10 @@ strong_alias (__fnmatch, __fnmatch_old)
compat_symbol (libc, __fnmatch_old, fnmatch, GLIBC_2_0);
# endif
libc_hidden_ver (__fnmatch, fnmatch)
-# else
-strong_alias(__fnmatch,fnmatch)
# endif
+# else
+libc_hidden_proto(fnmatch)
+libc_hidden_def(fnmatch)
# endif
#endif /* _LIBC or not __GNU_LIBRARY__. */
diff --git a/libc/misc/fnmatch/fnmatch_loop.c b/libc/misc/fnmatch/fnmatch_loop.c
index 663af1222..191cef50c 100644
--- a/libc/misc/fnmatch/fnmatch_loop.c
+++ b/libc/misc/fnmatch/fnmatch_loop.c
@@ -214,7 +214,7 @@ FCT (pattern, string, string_end, no_leading_period, flags)
UCHAR fn;
if (posixly_correct == 0)
- posixly_correct = __getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
+ posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
if (n == string_end)
return FNM_NOMATCH;
@@ -993,7 +993,7 @@ END (const CHAR *pattern)
{
/* Handle brackets special. */
if (posixly_correct == 0)
- posixly_correct = __getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
+ posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
/* Skip the not sign. We have to recognize it because of a possibly
following ']'. */
@@ -1045,7 +1045,7 @@ EXT (INT opt, const CHAR *pattern, const CHAR *string, const CHAR *string_end,
{
/* Handle brackets special. */
if (posixly_correct == 0)
- posixly_correct = __getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
+ posixly_correct = getenv ("POSIXLY_CORRECT") != NULL ? 1 : -1;
/* Skip the not sign. We have to recognize it because of a possibly
following ']'. */
diff --git a/libc/misc/fnmatch/fnmatch_old.c b/libc/misc/fnmatch/fnmatch_old.c
index 2762b3930..47075e914 100644
--- a/libc/misc/fnmatch/fnmatch_old.c
+++ b/libc/misc/fnmatch/fnmatch_old.c
@@ -28,6 +28,9 @@ Cambridge, MA 02139, USA. */
#include <fnmatch.h>
#include <ctype.h>
+libc_hidden_proto(fnmatch)
+
+libc_hidden_proto(tolower)
/* 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
Library, but also included in many other GNU distributions. Compiling
@@ -50,13 +53,13 @@ Cambridge, MA 02139, USA. */
/* Match STRING against the filename pattern PATTERN, returning zero if
it matches, nonzero if not. */
-int attribute_hidden __fnmatch(const char *pattern, const char *string, int flags)
+int fnmatch(const char *pattern, const char *string, int flags)
{
register const char *p = pattern, *n = string;
register char c;
/* Note that this evaluates 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') {
c = FOLD(c);
@@ -116,7 +119,7 @@ int attribute_hidden __fnmatch(const char *pattern, const char *string, int flag
c1 = FOLD(c1);
for (--p; *n != '\0'; ++n)
if ((c == '[' || FOLD(*n) == c1) &&
- __fnmatch(p, n, flags & ~FNM_PERIOD) == 0)
+ fnmatch(p, n, flags & ~FNM_PERIOD) == 0)
return 0;
return FNM_NOMATCH;
}
@@ -220,5 +223,5 @@ int attribute_hidden __fnmatch(const char *pattern, const char *string, int flag
# undef FOLD
}
-strong_alias(__fnmatch,fnmatch)
+libc_hidden_def(fnmatch)
#endif /* _LIBC or not __GNU_LIBRARY__. */