summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libc/misc/Makefile.in1
-rw-r--r--libc/misc/assert/Makefile.in19
-rw-r--r--libc/misc/assert/__assert.c9
-rw-r--r--libc/misc/ctype/Makefile.in62
-rw-r--r--libc/misc/ctype/__C_ctype_b.c8
-rw-r--r--libc/misc/ctype/__C_ctype_tolower.c8
-rw-r--r--libc/misc/ctype/__C_ctype_toupper.c8
-rw-r--r--libc/misc/ctype/__ctype_assert.c8
-rw-r--r--libc/misc/ctype/__ctype_b_loc.c8
-rw-r--r--libc/misc/ctype/__ctype_tolower_loc.c8
-rw-r--r--libc/misc/ctype/__ctype_toupper_loc.c8
-rw-r--r--libc/misc/ctype/ctype.c102
-rw-r--r--libc/misc/ctype/isalnum.c8
-rw-r--r--libc/misc/ctype/isalnum_l.c9
-rw-r--r--libc/misc/ctype/isalpha.c8
-rw-r--r--libc/misc/ctype/isalpha_l.c9
-rw-r--r--libc/misc/ctype/isascii.c8
-rw-r--r--libc/misc/ctype/isascii_l.c9
-rw-r--r--libc/misc/ctype/isblank.c8
-rw-r--r--libc/misc/ctype/isblank_l.c9
-rw-r--r--libc/misc/ctype/iscntrl.c8
-rw-r--r--libc/misc/ctype/iscntrl_l.c9
-rw-r--r--libc/misc/ctype/isctype.c8
-rw-r--r--libc/misc/ctype/isdigit.c8
-rw-r--r--libc/misc/ctype/isdigit_l.c9
-rw-r--r--libc/misc/ctype/isgraph.c8
-rw-r--r--libc/misc/ctype/isgraph_l.c9
-rw-r--r--libc/misc/ctype/islower.c8
-rw-r--r--libc/misc/ctype/islower_l.c9
-rw-r--r--libc/misc/ctype/isprint.c8
-rw-r--r--libc/misc/ctype/isprint_l.c9
-rw-r--r--libc/misc/ctype/ispunct.c8
-rw-r--r--libc/misc/ctype/ispunct_l.c9
-rw-r--r--libc/misc/ctype/isspace.c8
-rw-r--r--libc/misc/ctype/isspace_l.c9
-rw-r--r--libc/misc/ctype/isupper.c8
-rw-r--r--libc/misc/ctype/isupper_l.c9
-rw-r--r--libc/misc/ctype/isxdigit.c8
-rw-r--r--libc/misc/ctype/isxdigit_l.c9
-rw-r--r--libc/misc/ctype/junk.c10
-rw-r--r--libc/misc/ctype/toascii.c8
-rw-r--r--libc/misc/ctype/toascii_l.c9
-rw-r--r--libc/misc/ctype/tolower.c8
-rw-r--r--libc/misc/ctype/tolower_l.c9
-rw-r--r--libc/misc/ctype/toupper.c8
-rw-r--r--libc/misc/ctype/toupper_l.c9
-rw-r--r--libc/misc/dirent/Makefile.in21
-rw-r--r--libc/misc/dirent/alphasort.c10
-rw-r--r--libc/misc/dirent/alphasort64.c23
-rw-r--r--libc/misc/dirent/dirfd.c12
-rw-r--r--libc/misc/dirent/dirstream.h2
-rw-r--r--libc/misc/dirent/readdir.c12
-rw-r--r--libc/misc/dirent/readdir64.c27
-rw-r--r--libc/misc/dirent/readdir64_r.c27
-rw-r--r--libc/misc/dirent/readdir_r.c12
-rw-r--r--libc/misc/dirent/rewinddir.c9
-rw-r--r--libc/misc/dirent/scandir.c40
-rw-r--r--libc/misc/dirent/scandir64.c29
-rw-r--r--libc/misc/dirent/seekdir.c10
-rw-r--r--libc/misc/dirent/telldir.c6
-rw-r--r--libc/misc/error/Makefile.in19
-rw-r--r--libc/misc/error/err.c49
-rw-r--r--libc/misc/error/error.c67
-rw-r--r--libc/misc/file/Makefile.in22
-rw-r--r--libc/misc/file/lockf.c20
-rw-r--r--libc/misc/file/lockf64.c39
-rw-r--r--libc/misc/fnmatch/Makefile.in21
-rw-r--r--libc/misc/fnmatch/fnmatch.c138
-rw-r--r--libc/misc/fnmatch/fnmatch_loop.c6
-rw-r--r--libc/misc/fnmatch/fnmatch_old.c16
-rw-r--r--libc/misc/ftw/Makefile.in15
-rw-r--r--libc/misc/ftw/ftw.c68
-rw-r--r--libc/misc/ftw/ftw64.c4
-rw-r--r--libc/misc/glob/Makefile.in35
-rw-r--r--libc/misc/glob/glob-hooks.c6
-rw-r--r--libc/misc/glob/glob-susv3.c322
-rw-r--r--libc/misc/glob/glob.c518
-rw-r--r--libc/misc/glob/glob64-susv3.c20
-rw-r--r--libc/misc/glob/glob64.c35
-rw-r--r--libc/misc/gnu/Makefile.in19
-rw-r--r--libc/misc/gnu/obstack.c28
-rw-r--r--libc/misc/locale/Makefile.in50
-rw-r--r--libc/misc/locale/__curlocale.c9
-rw-r--r--libc/misc/locale/__locale_mbrtowc_l.c8
-rw-r--r--libc/misc/locale/_locale_init.c8
-rw-r--r--libc/misc/locale/duplocale.c9
-rw-r--r--libc/misc/locale/freelocale.c9
-rw-r--r--libc/misc/locale/locale.c152
-rw-r--r--libc/misc/locale/localeconv.c8
-rw-r--r--libc/misc/locale/newlocale.c8
-rw-r--r--libc/misc/locale/nl_langinfo.c8
-rw-r--r--libc/misc/locale/nl_langinfo_l.c9
-rw-r--r--libc/misc/locale/setlocale.c8
-rw-r--r--libc/misc/locale/uselocale.c9
-rw-r--r--libc/misc/mntent/Makefile.in19
-rw-r--r--libc/misc/mntent/mntent.c38
-rw-r--r--libc/misc/regex/Makefile.in21
-rw-r--r--libc/misc/regex/regcomp.c21
-rw-r--r--libc/misc/regex/regex.c78
-rw-r--r--libc/misc/regex/regex_internal.c9
-rw-r--r--libc/misc/regex/regex_internal.h3
-rw-r--r--libc/misc/regex/regex_old.c82
-rw-r--r--libc/misc/regex/regexec.c12
-rw-r--r--libc/misc/search/Makefile.in75
-rw-r--r--libc/misc/search/_hsearch_r.c232
-rw-r--r--libc/misc/search/_lsearch.c51
-rw-r--r--libc/misc/search/_tsearch.c223
-rw-r--r--libc/misc/search/hcreate_r.c8
-rw-r--r--libc/misc/search/hdestroy_r.c8
-rw-r--r--libc/misc/search/hsearch.c13
-rw-r--r--libc/misc/search/hsearch_r.c236
-rw-r--r--libc/misc/search/insque.c8
-rw-r--r--libc/misc/search/insremque.c4
-rw-r--r--libc/misc/search/lfind.c8
-rw-r--r--libc/misc/search/lsearch.c50
-rw-r--r--libc/misc/search/remque.c8
-rw-r--r--libc/misc/search/tdelete.c8
-rw-r--r--libc/misc/search/tdestroy.c8
-rw-r--r--libc/misc/search/tfind.c8
-rw-r--r--libc/misc/search/tsearch.c220
-rw-r--r--libc/misc/search/twalk.c8
121 files changed, 2432 insertions, 1568 deletions
diff --git a/libc/misc/Makefile.in b/libc/misc/Makefile.in
index f9331c9dd..acc71aefe 100644
--- a/libc/misc/Makefile.in
+++ b/libc/misc/Makefile.in
@@ -19,7 +19,6 @@ include $(top_srcdir)libc/misc/ftw/Makefile.in
include $(top_srcdir)libc/misc/glob/Makefile.in
include $(top_srcdir)libc/misc/gnu/Makefile.in
include $(top_srcdir)libc/misc/internals/Makefile.in
-include $(top_srcdir)libc/misc/intl/Makefile.in
include $(top_srcdir)libc/misc/locale/Makefile.in
include $(top_srcdir)libc/misc/mntent/Makefile.in
include $(top_srcdir)libc/misc/pthread/Makefile.in
diff --git a/libc/misc/assert/Makefile.in b/libc/misc/assert/Makefile.in
index 0e41268b2..20f9c2115 100644
--- a/libc/misc/assert/Makefile.in
+++ b/libc/misc/assert/Makefile.in
@@ -1,25 +1,22 @@
# Makefile for uClibc
#
# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC:=__assert.c
+CSRC := __assert.c
-MISC_ASSERT_DIR:=$(top_srcdir)libc/misc/assert
-MISC_ASSERT_OUT:=$(top_builddir)libc/misc/assert
+MISC_ASSERT_DIR := $(top_srcdir)libc/misc/assert
+MISC_ASSERT_OUT := $(top_builddir)libc/misc/assert
-MISC_ASSERT_SRC:=$(MISC_ASSERT_DIR)/__assert.c
-MISC_ASSERT_OBJ:=$(MISC_ASSERT_OUT)/__assert.o
+MISC_ASSERT_SRC := $(MISC_ASSERT_DIR)/__assert.c
+MISC_ASSERT_OBJ := $(MISC_ASSERT_OUT)/__assert.o
-libc-a-y+=$(MISC_ASSERT_OBJ)
-libc-so-y+=$(MISC_ASSERT_OBJ:.o=.os)
+libc-y += $(MISC_ASSERT_OBJ)
-libc-multi-y+=$(MISC_ASSERT_SRC)
-
-objclean-y+=misc_assert_objclean
+objclean-y += misc_assert_objclean
misc_assert_objclean:
$(RM) $(MISC_ASSERT_OUT)/*.{o,os}
diff --git a/libc/misc/assert/__assert.c b/libc/misc/assert/__assert.c
index c55f0b6ae..4282812a5 100644
--- a/libc/misc/assert/__assert.c
+++ b/libc/misc/assert/__assert.c
@@ -33,17 +33,22 @@
#include <unistd.h>
#include <bits/uClibc_uintmaxtostr.h>
+libc_hidden_proto(fprintf)
+libc_hidden_proto(abort)
+libc_hidden_proto(stderr)
+
/* Get the prototype from assert.h as a double-check. */
#undef NDEBUG
#include <assert.h>
#undef assert
+libc_hidden_proto(__assert)
#define ASSERT_SHOW_PROGNAME 1
static int in_assert; /* bss inits to 0. */
-void __assert(const char *assertion, const char * filename,
+void attribute_noreturn __assert(const char *assertion, const char * filename,
int linenumber, register const char * function)
{
if (!in_assert) {
@@ -64,3 +69,5 @@ void __assert(const char *assertion, const char * filename,
}
abort();
}
+
+libc_hidden_def(__assert)
diff --git a/libc/misc/ctype/Makefile.in b/libc/misc/ctype/Makefile.in
index 87a3d11b1..b8a07ec84 100644
--- a/libc/misc/ctype/Makefile.in
+++ b/libc/misc/ctype/Makefile.in
@@ -1,59 +1,39 @@
# Makefile for uClibc
#
# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-MSRC:=ctype.c
-MOBJ:= isalnum.o isalpha.o isascii.o iscntrl.o isdigit.o \
- isgraph.o islower.o isprint.o ispunct.o isspace.o \
- isupper.o isxdigit.o toascii.o tolower.o toupper.o \
- isblank.o
+# multi source ctype.c
+COM_SRC := \
+ isalnum.c isalpha.c isascii.c iscntrl.c isdigit.c \
+ isgraph.c islower.c isprint.c ispunct.c isspace.c \
+ isupper.c isxdigit.c toascii.c tolower.c toupper.c \
+ isblank.c
+
+CSRC := $(COM_SRC)
ifeq ($(UCLIBC_HAS_CTYPE_TABLES),y)
-MOBJ+= __C_ctype_b.o __C_ctype_tolower.o __C_ctype_toupper.o \
- __ctype_b_loc.o __ctype_tolower_loc.o __ctype_toupper_loc.o \
- __ctype_assert.o isctype.o
+CSRC += __C_ctype_b.c __C_ctype_tolower.c __C_ctype_toupper.c \
+ __ctype_b_loc.c __ctype_tolower_loc.c __ctype_toupper_loc.c \
+ __ctype_assert.c isctype.c
endif
-MOBJx:= isalnum_l.o isalpha_l.o isascii_l.o iscntrl_l.o isdigit_l.o \
- isgraph_l.o islower_l.o isprint_l.o ispunct_l.o isspace_l.o \
- isupper_l.o isxdigit_l.o toascii_l.o tolower_l.o toupper_l.o \
- isblank_l.o
-
-MISC_CTYPE_DIR:=$(top_srcdir)libc/misc/ctype
-MISC_CTYPE_OUT:=$(top_builddir)libc/misc/ctype
-
-MISC_CTYPE_MSRC:=$(MISC_CTYPE_DIR)/$(MSRC)
-MISC_CTYPE_MOBJ:=$(patsubst %.o,$(MISC_CTYPE_OUT)/%.o,$(MOBJ))
-MISC_CTYPE_MOBJx:=$(patsubst %.o,$(MISC_CTYPE_OUT)/%.o,$(MOBJx))
-
-MISC_CTYPE_DEF:=$(patsubst %,-DL_%,$(subst .o,,$(notdir $(MISC_CTYPE_MOBJ))))
-
-$(MISC_CTYPE_MOBJ): $(MISC_CTYPE_MSRC)
- $(compile.m)
-
-$(MISC_CTYPE_MOBJ:.o=.os): $(MISC_CTYPE_MSRC)
- $(compile.m)
-
-$(MISC_CTYPE_MOBJx): $(MISC_CTYPE_MSRC)
- $(compile.m) -D__UCLIBC_DO_XLOCALE
+ifeq ($(UCLIBC_HAS_XLOCALE),y)
+CSRC += $(patsubst %.c,%_l.c,$(COM_SRC))
+endif
-$(MISC_CTYPE_MOBJx:.o=.os): $(MISC_CTYPE_MSRC)
- $(compile.m) -D__UCLIBC_DO_XLOCALE
+MISC_CTYPE_DIR := $(top_srcdir)libc/misc/ctype
+MISC_CTYPE_OUT := $(top_builddir)libc/misc/ctype
-libc-a-y+=$(MISC_CTYPE_MOBJ)
-libc-a-$(UCLIBC_HAS_XLOCALE)+=$(MISC_CTYPE_MOBJx)
-libc-so-y+=$(MISC_CTYPE_MOBJ:.o=.os)
-libc-so-$(UCLIBC_HAS_XLOCALE)+=$(MISC_CTYPE_MOBJx:.o=.os)
+MISC_CTYPE_SRC := $(patsubst %.c,$(MISC_CTYPE_DIR)/%.c,$(CSRC))
+MISC_CTYPE_OBJ := $(patsubst %.c,$(MISC_CTYPE_OUT)/%.o,$(CSRC))
-CFLAGS-multi-y+=$(MISC_CTYPE_DEF)
-libc-multi-y+=$(MISC_CTYPE_MSRC)
-libc-nomulti-$(UCLIBC_HAS_XLOCALE)+=$(MISC_CTYPE_MOBJx)
+libc-y += $(MISC_CTYPE_OBJ)
-objclean-y+=misc_ctype_objclean
+objclean-y += misc_ctype_objclean
misc_ctype_objclean:
$(RM) $(MISC_CTYPE_OUT)/*.{o,os}
diff --git a/libc/misc/ctype/__C_ctype_b.c b/libc/misc/ctype/__C_ctype_b.c
new file mode 100644
index 000000000..d22359f33
--- /dev/null
+++ b/libc/misc/ctype/__C_ctype_b.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___C_ctype_b
+#include "ctype.c"
diff --git a/libc/misc/ctype/__C_ctype_tolower.c b/libc/misc/ctype/__C_ctype_tolower.c
new file mode 100644
index 000000000..fc6027f51
--- /dev/null
+++ b/libc/misc/ctype/__C_ctype_tolower.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___C_ctype_tolower
+#include "ctype.c"
diff --git a/libc/misc/ctype/__C_ctype_toupper.c b/libc/misc/ctype/__C_ctype_toupper.c
new file mode 100644
index 000000000..ec42fbfbe
--- /dev/null
+++ b/libc/misc/ctype/__C_ctype_toupper.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___C_ctype_toupper
+#include "ctype.c"
diff --git a/libc/misc/ctype/__ctype_assert.c b/libc/misc/ctype/__ctype_assert.c
new file mode 100644
index 000000000..fe459458c
--- /dev/null
+++ b/libc/misc/ctype/__ctype_assert.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___ctype_assert
+#include "ctype.c"
diff --git a/libc/misc/ctype/__ctype_b_loc.c b/libc/misc/ctype/__ctype_b_loc.c
new file mode 100644
index 000000000..11d504693
--- /dev/null
+++ b/libc/misc/ctype/__ctype_b_loc.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___ctype_b_loc
+#include "ctype.c"
diff --git a/libc/misc/ctype/__ctype_tolower_loc.c b/libc/misc/ctype/__ctype_tolower_loc.c
new file mode 100644
index 000000000..54037a598
--- /dev/null
+++ b/libc/misc/ctype/__ctype_tolower_loc.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___ctype_tolower_loc
+#include "ctype.c"
diff --git a/libc/misc/ctype/__ctype_toupper_loc.c b/libc/misc/ctype/__ctype_toupper_loc.c
new file mode 100644
index 000000000..e511d0f72
--- /dev/null
+++ b/libc/misc/ctype/__ctype_toupper_loc.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___ctype_toupper_loc
+#include "ctype.c"
diff --git a/libc/misc/ctype/ctype.c b/libc/misc/ctype/ctype.c
index 69b4c1a6d..243031b6c 100644
--- a/libc/misc/ctype/ctype.c
+++ b/libc/misc/ctype/ctype.c
@@ -26,7 +26,6 @@
*
* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! */
-#define _GNU_SOURCE
#define __NO_CTYPE
#include <ctype.h>
@@ -36,6 +35,11 @@
#include <stdint.h>
#include <assert.h>
#include <locale.h>
+#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_b_loc)
+#else
+libc_hidden_proto(__ctype_b)
+#endif
#ifdef __UCLIBC_HAS_XLOCALE__
#include <xlocale.h>
@@ -88,7 +92,7 @@
#ifdef __UCLIBC_DO_XLOCALE
#define CTYPE_NAME(X) __is ## X ## _l
#define ISCTYPE(C,F) __isctype_l( C, F, locale_arg)
-#define CTYPE_ALIAS(NAME) weak_alias( __is ## NAME ## _l , is ## NAME ## _l)
+#define CTYPE_ALIAS(NAME) strong_alias( __is ## NAME ## _l , is ## NAME ## _l)
#else
#define CTYPE_NAME(X) is ## X
#define ISCTYPE(C,F) __isctype( C, F )
@@ -103,7 +107,7 @@
#undef NDEBUG
#include <assert.h>
-extern void __isctype_assert(int c, int mask) __attribute__ ((__noreturn__));
+extern void __isctype_assert(int c, int mask) __attribute__ ((__noreturn__)) attribute_hidden;
#define CTYPE_BODY(NAME,C,MASK) \
if (CTYPE_DOMAIN_CHECK(C)) { \
@@ -133,6 +137,7 @@ extern void __isctype_assert(int c, int mask) __attribute__ ((__noreturn__));
#define IS_FUNC_BODY(NAME) \
+int CTYPE_NAME(NAME) (int c __LOCALE_PARAM ); \
int CTYPE_NAME(NAME) (int c __LOCALE_PARAM ) \
{ \
CTYPE_BODY(NAME,c,PASTE2(_IS,NAME)) \
@@ -156,7 +161,10 @@ int CTYPE_NAME(NAME) (int c) \
#ifdef L___ctype_assert
#ifdef __UCLIBC_HAS_CTYPE_ENFORCED__
-void __isctype_assert(int c, int mask)
+libc_hidden_proto(fprintf)
+libc_hidden_proto(abort)
+
+attribute_hidden void __isctype_assert(int c, int mask)
{
fprintf(stderr, "%s: __is*{_l}(%d,%#x {locale})\n", __uclibc_progname, c, mask);
abort();
@@ -200,6 +208,7 @@ IS_FUNC_BODY(cntrl);
#define __isdigit_char_or_EOF(C) __isdigit_int((C))
#endif
+int CTYPE_NAME(digit) (int C __LOCALE_PARAM);
int CTYPE_NAME(digit) (int C __LOCALE_PARAM)
{
#if defined(__UCLIBC_HAS_CTYPE_ENFORCED__)
@@ -266,9 +275,16 @@ IS_FUNC_BODY(xdigit);
/**********************************************************************/
#ifdef L_tolower
+#undef tolower
+#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_tolower_loc)
+#else
+libc_hidden_proto(__ctype_tolower)
+#endif
+libc_hidden_proto(tolower)
#ifdef __UCLIBC_HAS_CTYPE_TABLES__
-int attribute_hidden __tolower(int c)
+int tolower(int c)
{
#if defined(__UCLIBC_HAS_CTYPE_ENFORCED__)
assert(CTYPE_DOMAIN_CHECK(c));
@@ -278,38 +294,43 @@ int attribute_hidden __tolower(int c)
#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
-int attribute_hidden __tolower(int c)
+int tolower(int c)
{
return __C_tolower(c);
}
#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
-strong_alias(__tolower,tolower)
+libc_hidden_def(tolower)
#endif
/**********************************************************************/
#ifdef L_tolower_l
#undef tolower_l
-#undef __tolower_l
-
-int __tolower_l(int c, __locale_t l)
+libc_hidden_proto(tolower_l)
+int tolower_l(int c, __locale_t l)
{
#if defined(__UCLIBC_HAS_CTYPE_ENFORCED__)
assert(CTYPE_DOMAIN_CHECK(c));
#endif
return __UCLIBC_CTYPE_IN_TO_DOMAIN(c) ? l->__ctype_tolower[c] : c;
}
-
-weak_alias(__tolower_l, tolower_l)
+libc_hidden_def(tolower_l)
#endif
/**********************************************************************/
#ifdef L_toupper
+#undef toupper
+#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_toupper_loc)
+#else
+libc_hidden_proto(__ctype_toupper)
+#endif
+libc_hidden_proto(toupper)
#ifdef __UCLIBC_HAS_CTYPE_TABLES__
-int attribute_hidden __toupper(int c)
+int toupper(int c)
{
#if defined(__UCLIBC_HAS_CTYPE_ENFORCED__)
assert(CTYPE_DOMAIN_CHECK(c));
@@ -319,30 +340,28 @@ int attribute_hidden __toupper(int c)
#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
-int attribute_hidden __toupper(int c)
+int toupper(int c)
{
return __C_toupper(c);
}
#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
-strong_alias(__toupper,toupper)
+libc_hidden_def(toupper)
#endif
/**********************************************************************/
#ifdef L_toupper_l
#undef toupper_l
-#undef __toupper_l
-
-int __toupper_l(int c, __locale_t l)
+libc_hidden_proto(toupper_l)
+int toupper_l(int c, __locale_t l)
{
#if defined(__UCLIBC_HAS_CTYPE_ENFORCED__)
assert(CTYPE_DOMAIN_CHECK(c));
#endif
return __UCLIBC_CTYPE_IN_TO_DOMAIN(c) ? l->__ctype_toupper[c] : c;
}
-
-weak_alias(__toupper_l, toupper_l)
+libc_hidden_def(toupper_l)
#endif
/**********************************************************************/
@@ -350,19 +369,20 @@ weak_alias(__toupper_l, toupper_l)
#ifdef __UCLIBC_HAS_CTYPE_TABLES__
-int __XL(isascii)(int c)
+int __XL_NPP(isascii)(int c);
+int __XL_NPP(isascii)(int c)
{
return __isascii(c); /* locale-independent */
}
-__XL_ALIAS(isascii)
-
#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
+libc_hidden_proto(isascii)
int isascii(int c)
{
return __isascii(c); /* locale-independent */
}
+libc_hidden_def(isascii)
#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
@@ -372,13 +392,12 @@ int isascii(int c)
#ifdef __UCLIBC_HAS_CTYPE_TABLES__
-int __XL(toascii)(int c)
+int __XL_NPP(toascii)(int c);
+int __XL_NPP(toascii)(int c)
{
return __toascii(c); /* locale-independent */
}
-__XL_ALIAS(toascii)
-
#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
int toascii(int c)
@@ -401,7 +420,7 @@ int isctype(int c, int mask)
#endif
/**********************************************************************/
-#if L___ctype_b_loc
+#ifdef L___ctype_b_loc
#ifdef __UCLIBC_HAS_XLOCALE__
@@ -410,31 +429,36 @@ const __ctype_mask_t **__ctype_b_loc(void)
return &(__UCLIBC_CURLOCALE_DATA).__ctype_b;
}
+libc_hidden_def(__ctype_b_loc)
#endif
#endif
/**********************************************************************/
-#if L___ctype_tolower_loc
+#ifdef L___ctype_tolower_loc
#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_tolower_loc)
const __ctype_touplow_t **__ctype_tolower_loc(void)
{
return &(__UCLIBC_CURLOCALE_DATA).__ctype_tolower;
}
+libc_hidden_def(__ctype_tolower_loc)
#endif
#endif
/**********************************************************************/
-#if L___ctype_toupper_loc
+#ifdef L___ctype_toupper_loc
#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_toupper_loc)
const __ctype_touplow_t **__ctype_toupper_loc(void)
{
return &(__UCLIBC_CURLOCALE_DATA).__ctype_toupper;
}
+libc_hidden_def(__ctype_toupper_loc)
#endif
@@ -442,6 +466,8 @@ const __ctype_touplow_t **__ctype_toupper_loc(void)
/**********************************************************************/
#ifdef L___C_ctype_b
+extern const __ctype_mask_t __C_ctype_b_data[];
+libc_hidden_proto(__C_ctype_b_data)
const __ctype_mask_t __C_ctype_b_data[] = {
#ifdef __UCLIBC_HAS_CTYPE_SIGNED__
/* -128 M-^@ */ 0,
@@ -830,12 +856,16 @@ const __ctype_mask_t __C_ctype_b_data[] = {
/* 254 M-~ */ 0,
/* 255 M-^? */ 0
};
+libc_hidden_data_def(__C_ctype_b_data)
+libc_hidden_proto(__C_ctype_b)
const __ctype_mask_t *__C_ctype_b = __C_ctype_b_data + __UCLIBC_CTYPE_B_TBL_OFFSET;
+libc_hidden_data_def(__C_ctype_b)
#ifndef __UCLIBC_HAS_XLOCALE__
const __ctype_mask_t *__ctype_b = __C_ctype_b_data + __UCLIBC_CTYPE_B_TBL_OFFSET;
+libc_hidden_data_def(__ctype_b)
#endif
@@ -843,6 +873,8 @@ const __ctype_mask_t *__ctype_b = __C_ctype_b_data + __UCLIBC_CTYPE_B_TBL_OFFSET
/**********************************************************************/
#ifdef L___C_ctype_tolower
+extern const __ctype_touplow_t __C_ctype_tolower_data[];
+libc_hidden_proto(__C_ctype_tolower_data)
const __ctype_touplow_t __C_ctype_tolower_data[] = {
#ifdef __UCLIBC_HAS_CTYPE_SIGNED__
-128, -127, -126, -125,
@@ -943,14 +975,19 @@ const __ctype_touplow_t __C_ctype_tolower_data[] = {
248, 249, 250, 251,
252, 253, 254, 255
};
+libc_hidden_data_def(__C_ctype_tolower_data)
+libc_hidden_proto(__C_ctype_tolower)
const __ctype_touplow_t *__C_ctype_tolower = __C_ctype_tolower_data
+ __UCLIBC_CTYPE_TO_TBL_OFFSET;
+libc_hidden_data_def(__C_ctype_tolower)
#ifndef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_tolower)
const __ctype_touplow_t *__ctype_tolower = __C_ctype_tolower_data
+ __UCLIBC_CTYPE_TO_TBL_OFFSET;
+libc_hidden_data_def(__ctype_tolower)
#endif
@@ -958,6 +995,8 @@ const __ctype_touplow_t *__ctype_tolower = __C_ctype_tolower_data
/**********************************************************************/
#ifdef L___C_ctype_toupper
+extern const __ctype_touplow_t __C_ctype_toupper_data[];
+libc_hidden_proto(__C_ctype_toupper_data)
const __ctype_touplow_t __C_ctype_toupper_data[] = {
#ifdef __UCLIBC_HAS_CTYPE_SIGNED__
-128, -127, -126, -125,
@@ -1058,14 +1097,19 @@ const __ctype_touplow_t __C_ctype_toupper_data[] = {
248, 249, 250, 251,
252, 253, 254, 255
};
+libc_hidden_data_def(__C_ctype_toupper_data)
+libc_hidden_proto(__C_ctype_toupper)
const __ctype_touplow_t *__C_ctype_toupper = __C_ctype_toupper_data
+ __UCLIBC_CTYPE_TO_TBL_OFFSET;
+libc_hidden_data_def(__C_ctype_toupper)
#ifndef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_toupper)
const __ctype_touplow_t *__ctype_toupper = __C_ctype_toupper_data
+ __UCLIBC_CTYPE_TO_TBL_OFFSET;
+libc_hidden_data_def(__ctype_toupper)
#endif
diff --git a/libc/misc/ctype/isalnum.c b/libc/misc/ctype/isalnum.c
new file mode 100644
index 000000000..8bc8ad6d5
--- /dev/null
+++ b/libc/misc/ctype/isalnum.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isalnum
+#include "ctype.c"
diff --git a/libc/misc/ctype/isalnum_l.c b/libc/misc/ctype/isalnum_l.c
new file mode 100644
index 000000000..8ecd9d59b
--- /dev/null
+++ b/libc/misc/ctype/isalnum_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isalnum_l
+#define __UCLIBC_DO_XLOCALE
+#include "ctype.c"
diff --git a/libc/misc/ctype/isalpha.c b/libc/misc/ctype/isalpha.c
new file mode 100644
index 000000000..22f23d92c
--- /dev/null
+++ b/libc/misc/ctype/isalpha.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isalpha
+#include "ctype.c"
diff --git a/libc/misc/ctype/isalpha_l.c b/libc/misc/ctype/isalpha_l.c
new file mode 100644
index 000000000..10a2ecfce
--- /dev/null
+++ b/libc/misc/ctype/isalpha_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isalpha_l
+#define __UCLIBC_DO_XLOCALE
+#include "ctype.c"
diff --git a/libc/misc/ctype/isascii.c b/libc/misc/ctype/isascii.c
new file mode 100644
index 000000000..84f701f8d
--- /dev/null
+++ b/libc/misc/ctype/isascii.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isascii
+#include "ctype.c"
diff --git a/libc/misc/ctype/isascii_l.c b/libc/misc/ctype/isascii_l.c
new file mode 100644
index 000000000..7fe5545b3
--- /dev/null
+++ b/libc/misc/ctype/isascii_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isascii_l
+#define __UCLIBC_DO_XLOCALE
+#include "ctype.c"
diff --git a/libc/misc/ctype/isblank.c b/libc/misc/ctype/isblank.c
new file mode 100644
index 000000000..d11fe26cd
--- /dev/null
+++ b/libc/misc/ctype/isblank.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isblank
+#include "ctype.c"
diff --git a/libc/misc/ctype/isblank_l.c b/libc/misc/ctype/isblank_l.c
new file mode 100644
index 000000000..144cd932d
--- /dev/null
+++ b/libc/misc/ctype/isblank_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isblank_l
+#define __UCLIBC_DO_XLOCALE
+#include "ctype.c"
diff --git a/libc/misc/ctype/iscntrl.c b/libc/misc/ctype/iscntrl.c
new file mode 100644
index 000000000..4a0c09d36
--- /dev/null
+++ b/libc/misc/ctype/iscntrl.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iscntrl
+#include "ctype.c"
diff --git a/libc/misc/ctype/iscntrl_l.c b/libc/misc/ctype/iscntrl_l.c
new file mode 100644
index 000000000..fbee951c4
--- /dev/null
+++ b/libc/misc/ctype/iscntrl_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iscntrl_l
+#define __UCLIBC_DO_XLOCALE
+#include "ctype.c"
diff --git a/libc/misc/ctype/isctype.c b/libc/misc/ctype/isctype.c
new file mode 100644
index 000000000..a2d0b3dd8
--- /dev/null
+++ b/libc/misc/ctype/isctype.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isctype
+#include "ctype.c"
diff --git a/libc/misc/ctype/isdigit.c b/libc/misc/ctype/isdigit.c
new file mode 100644
index 000000000..e185c89d5
--- /dev/null
+++ b/libc/misc/ctype/isdigit.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isdigit
+#include "ctype.c"
diff --git a/libc/misc/ctype/isdigit_l.c b/libc/misc/ctype/isdigit_l.c
new file mode 100644
index 000000000..5b764f12f
--- /dev/null
+++ b/libc/misc/ctype/isdigit_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isdigit_l
+#define __UCLIBC_DO_XLOCALE
+#include "ctype.c"
diff --git a/libc/misc/ctype/isgraph.c b/libc/misc/ctype/isgraph.c
new file mode 100644
index 000000000..c4ad1b7b5
--- /dev/null
+++ b/libc/misc/ctype/isgraph.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isgraph
+#include "ctype.c"
diff --git a/libc/misc/ctype/isgraph_l.c b/libc/misc/ctype/isgraph_l.c
new file mode 100644
index 000000000..005e19fc8
--- /dev/null
+++ b/libc/misc/ctype/isgraph_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isgraph_l
+#define __UCLIBC_DO_XLOCALE
+#include "ctype.c"
diff --git a/libc/misc/ctype/islower.c b/libc/misc/ctype/islower.c
new file mode 100644
index 000000000..aff65dd90
--- /dev/null
+++ b/libc/misc/ctype/islower.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_islower
+#include "ctype.c"
diff --git a/libc/misc/ctype/islower_l.c b/libc/misc/ctype/islower_l.c
new file mode 100644
index 000000000..dd085578f
--- /dev/null
+++ b/libc/misc/ctype/islower_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_islower_l
+#define __UCLIBC_DO_XLOCALE
+#include "ctype.c"
diff --git a/libc/misc/ctype/isprint.c b/libc/misc/ctype/isprint.c
new file mode 100644
index 000000000..b6f7d6cc1
--- /dev/null
+++ b/libc/misc/ctype/isprint.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isprint
+#include "ctype.c"
diff --git a/libc/misc/ctype/isprint_l.c b/libc/misc/ctype/isprint_l.c
new file mode 100644
index 000000000..32f9b3f32
--- /dev/null
+++ b/libc/misc/ctype/isprint_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isprint_l
+#define __UCLIBC_DO_XLOCALE
+#include "ctype.c"
diff --git a/libc/misc/ctype/ispunct.c b/libc/misc/ctype/ispunct.c
new file mode 100644
index 000000000..08f7b19ac
--- /dev/null
+++ b/libc/misc/ctype/ispunct.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_ispunct
+#include "ctype.c"
diff --git a/libc/misc/ctype/ispunct_l.c b/libc/misc/ctype/ispunct_l.c
new file mode 100644
index 000000000..513bb5238
--- /dev/null
+++ b/libc/misc/ctype/ispunct_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_ispunct_l
+#define __UCLIBC_DO_XLOCALE
+#include "ctype.c"
diff --git a/libc/misc/ctype/isspace.c b/libc/misc/ctype/isspace.c
new file mode 100644
index 000000000..c8ff56746
--- /dev/null
+++ b/libc/misc/ctype/isspace.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isspace
+#include "ctype.c"
diff --git a/libc/misc/ctype/isspace_l.c b/libc/misc/ctype/isspace_l.c
new file mode 100644
index 000000000..97e0c9921
--- /dev/null
+++ b/libc/misc/ctype/isspace_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isspace_l
+#define __UCLIBC_DO_XLOCALE
+#include "ctype.c"
diff --git a/libc/misc/ctype/isupper.c b/libc/misc/ctype/isupper.c
new file mode 100644
index 000000000..36d6e6e96
--- /dev/null
+++ b/libc/misc/ctype/isupper.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isupper
+#include "ctype.c"
diff --git a/libc/misc/ctype/isupper_l.c b/libc/misc/ctype/isupper_l.c
new file mode 100644
index 000000000..8aa4dbdfa
--- /dev/null
+++ b/libc/misc/ctype/isupper_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isupper_l
+#define __UCLIBC_DO_XLOCALE
+#include "ctype.c"
diff --git a/libc/misc/ctype/isxdigit.c b/libc/misc/ctype/isxdigit.c
new file mode 100644
index 000000000..40919f7bf
--- /dev/null
+++ b/libc/misc/ctype/isxdigit.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isxdigit
+#include "ctype.c"
diff --git a/libc/misc/ctype/isxdigit_l.c b/libc/misc/ctype/isxdigit_l.c
new file mode 100644
index 000000000..5dce7f1a5
--- /dev/null
+++ b/libc/misc/ctype/isxdigit_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_isxdigit_l
+#define __UCLIBC_DO_XLOCALE
+#include "ctype.c"
diff --git a/libc/misc/ctype/junk.c b/libc/misc/ctype/junk.c
deleted file mode 100644
index d074c997e..000000000
--- a/libc/misc/ctype/junk.c
+++ /dev/null
@@ -1,10 +0,0 @@
-/* Temporary rubbish till I can get this stuff
- * fixed properly */
-
-#include <features.h>
-#include <bits/types.h>
-
-const unsigned short int *__ctype_b; /* Characteristics. */
-const __int32_t *__ctype_tolower; /* Case conversions. */
-const __int32_t *__ctype_toupper; /* Case conversions. */
-
diff --git a/libc/misc/ctype/toascii.c b/libc/misc/ctype/toascii.c
new file mode 100644
index 000000000..a63b99344
--- /dev/null
+++ b/libc/misc/ctype/toascii.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_toascii
+#include "ctype.c"
diff --git a/libc/misc/ctype/toascii_l.c b/libc/misc/ctype/toascii_l.c
new file mode 100644
index 000000000..617952639
--- /dev/null
+++ b/libc/misc/ctype/toascii_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_toascii_l
+#define __UCLIBC_DO_XLOCALE
+#include "ctype.c"
diff --git a/libc/misc/ctype/tolower.c b/libc/misc/ctype/tolower.c
new file mode 100644
index 000000000..3673642c4
--- /dev/null
+++ b/libc/misc/ctype/tolower.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_tolower
+#include "ctype.c"
diff --git a/libc/misc/ctype/tolower_l.c b/libc/misc/ctype/tolower_l.c
new file mode 100644
index 000000000..327e63cae
--- /dev/null
+++ b/libc/misc/ctype/tolower_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_tolower_l
+#define __UCLIBC_DO_XLOCALE
+#include "ctype.c"
diff --git a/libc/misc/ctype/toupper.c b/libc/misc/ctype/toupper.c
new file mode 100644
index 000000000..a9d8aab6d
--- /dev/null
+++ b/libc/misc/ctype/toupper.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_toupper
+#include "ctype.c"
diff --git a/libc/misc/ctype/toupper_l.c b/libc/misc/ctype/toupper_l.c
new file mode 100644
index 000000000..c91d79151
--- /dev/null
+++ b/libc/misc/ctype/toupper_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2003-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_toupper_l
+#define __UCLIBC_DO_XLOCALE
+#include "ctype.c"
diff --git a/libc/misc/dirent/Makefile.in b/libc/misc/dirent/Makefile.in
index e1dfa3d94..d17ad8a17 100644
--- a/libc/misc/dirent/Makefile.in
+++ b/libc/misc/dirent/Makefile.in
@@ -1,30 +1,27 @@
# Makefile for uClibc
#
# Copyright (C) 2001 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC:= alphasort.c closedir.c dirfd.c opendir.c readdir.c rewinddir.c scandir.c \
+CSRC := alphasort.c closedir.c dirfd.c opendir.c readdir.c rewinddir.c scandir.c \
seekdir.c telldir.c readdir_r.c
ifeq ($(UCLIBC_HAS_LFS),y)
-CSRC+= readdir64.c alphasort64.c scandir64.c readdir64_r.c
+CSRC += readdir64.c alphasort64.c scandir64.c readdir64_r.c
endif
-MISC_DIRENT_DIR:=$(top_srcdir)libc/misc/dirent
-MISC_DIRENT_OUT:=$(top_builddir)libc/misc/dirent
+MISC_DIRENT_DIR := $(top_srcdir)libc/misc/dirent
+MISC_DIRENT_OUT := $(top_builddir)libc/misc/dirent
-MISC_DIRENT_SRC:=$(patsubst %.c,$(MISC_DIRENT_DIR)/%.c,$(CSRC))
-MISC_DIRENT_OBJ:=$(patsubst %.c,$(MISC_DIRENT_OUT)/%.o,$(CSRC))
+MISC_DIRENT_SRC := $(patsubst %.c,$(MISC_DIRENT_DIR)/%.c,$(CSRC))
+MISC_DIRENT_OBJ := $(patsubst %.c,$(MISC_DIRENT_OUT)/%.o,$(CSRC))
-libc-a-y+=$(MISC_DIRENT_OBJ)
-libc-so-y+=$(MISC_DIRENT_OBJ:.o=.os)
+libc-y += $(MISC_DIRENT_OBJ)
-libc-multi-y+=$(MISC_DIRENT_SRC)
-
-objclean-y+=misc_dirent_objclean
+objclean-y += misc_dirent_objclean
misc_dirent_objclean:
$(RM) $(MISC_DIRENT_OUT)/*.{o,os}
diff --git a/libc/misc/dirent/alphasort.c b/libc/misc/dirent/alphasort.c
index feae021e6..533366222 100644
--- a/libc/misc/dirent/alphasort.c
+++ b/libc/misc/dirent/alphasort.c
@@ -1,10 +1,18 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
#include <dirent.h>
#include <string.h>
#include "dirstream.h"
+libc_hidden_proto(strcmp)
+
int alphasort(const void * a, const void * b)
{
- return __strcmp ((*(const struct dirent **) a)->d_name,
+ return strcmp ((*(const struct dirent **) a)->d_name,
(*(const struct dirent **) b)->d_name);
}
diff --git a/libc/misc/dirent/alphasort64.c b/libc/misc/dirent/alphasort64.c
index c6cfcdacf..86a91095d 100644
--- a/libc/misc/dirent/alphasort64.c
+++ b/libc/misc/dirent/alphasort64.c
@@ -1,24 +1,19 @@
-#include <features.h>
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <_lfs_64.h>
-#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS != 64
-#undef _FILE_OFFSET_BITS
-#define _FILE_OFFSET_BITS 64
-#endif
-#ifndef __USE_LARGEFILE64
-# define __USE_LARGEFILE64 1
-#endif
-/* We absolutely do _NOT_ want interfaces silently
- * renamed under us or very bad things will happen... */
-#ifdef __USE_FILE_OFFSET64
-# undef __USE_FILE_OFFSET64
-#endif
#include <dirent.h>
#include <string.h>
#include "dirstream.h"
+libc_hidden_proto(strcmp)
int alphasort64(const void * a, const void * b)
{
- return __strcmp ((*(const struct dirent64 **) a)->d_name,
+ return strcmp ((*(const struct dirent64 **) a)->d_name,
(*(const struct dirent64 **) b)->d_name);
}
diff --git a/libc/misc/dirent/dirfd.c b/libc/misc/dirent/dirfd.c
index 48e955450..c6f46e965 100644
--- a/libc/misc/dirent/dirfd.c
+++ b/libc/misc/dirent/dirfd.c
@@ -1,8 +1,16 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
#include <dirent.h>
#include <errno.h>
#include "dirstream.h"
-int attribute_hidden __dirfd(DIR * dir)
+libc_hidden_proto(dirfd)
+
+int dirfd(DIR * dir)
{
if (!dir || dir->dd_fd == -1) {
__set_errno(EBADF);
@@ -11,4 +19,4 @@ int attribute_hidden __dirfd(DIR * dir)
return dir->dd_fd;
}
-strong_alias(__dirfd,dirfd)
+libc_hidden_def(dirfd)
diff --git a/libc/misc/dirent/dirstream.h b/libc/misc/dirent/dirstream.h
index 15c70858f..a90ca6312 100644
--- a/libc/misc/dirent/dirstream.h
+++ b/libc/misc/dirent/dirstream.h
@@ -72,10 +72,8 @@ struct __dirstream {
extern ssize_t __getdents(int fd, char *buf, size_t count) attribute_hidden;
-extern struct dirent *__readdir (DIR *__dirp) __nonnull ((1)) attribute_hidden;
#ifdef __UCLIBC_HAS_LFS__
extern ssize_t __getdents64 (int fd, char *buf, size_t count) attribute_hidden;
-extern struct dirent64 *__readdir64 (DIR *__dirp) __nonnull ((1)) attribute_hidden;
#endif
#endif /* dirent.h */
diff --git a/libc/misc/dirent/readdir.c b/libc/misc/dirent/readdir.c
index 2d4ad4aeb..6fb1146eb 100644
--- a/libc/misc/dirent/readdir.c
+++ b/libc/misc/dirent/readdir.c
@@ -1,3 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
#include <features.h>
#include <errno.h>
@@ -7,7 +13,9 @@
#include <dirent.h>
#include "dirstream.h"
-struct dirent attribute_hidden *__readdir(DIR * dir)
+libc_hidden_proto(readdir)
+
+struct dirent *readdir(DIR * dir)
{
ssize_t bytes;
struct dirent *de;
@@ -46,4 +54,4 @@ all_done:
__pthread_mutex_unlock(&(dir->dd_lock));
return de;
}
-strong_alias(__readdir,readdir)
+libc_hidden_def(readdir)
diff --git a/libc/misc/dirent/readdir64.c b/libc/misc/dirent/readdir64.c
index 177af3fc9..5386ee17e 100644
--- a/libc/misc/dirent/readdir64.c
+++ b/libc/misc/dirent/readdir64.c
@@ -1,17 +1,11 @@
-#include <features.h>
-
-#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS != 64
-#undef _FILE_OFFSET_BITS
-#define _FILE_OFFSET_BITS 64
-#endif
-#ifndef __USE_LARGEFILE64
-# define __USE_LARGEFILE64 1
-#endif
-/* We absolutely do _NOT_ want interfaces silently
- * renamed under us or very bad things will happen... */
-#ifdef __USE_FILE_OFFSET64
-# undef __USE_FILE_OFFSET64
-#endif
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <_lfs_64.h>
+
#include <dirent.h>
#include <errno.h>
#include <stdlib.h>
@@ -20,7 +14,8 @@
#include <dirent.h>
#include "dirstream.h"
-struct dirent64 attribute_hidden *__readdir64(DIR * dir)
+libc_hidden_proto(readdir64)
+struct dirent64 *readdir64(DIR * dir)
{
ssize_t bytes;
struct dirent64 *de;
@@ -60,4 +55,4 @@ all_done:
return de;
}
-strong_alias(__readdir64,readdir64)
+libc_hidden_def(readdir64)
diff --git a/libc/misc/dirent/readdir64_r.c b/libc/misc/dirent/readdir64_r.c
index 1cbaf3156..b42351702 100644
--- a/libc/misc/dirent/readdir64_r.c
+++ b/libc/misc/dirent/readdir64_r.c
@@ -1,17 +1,12 @@
-#include <features.h>
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
-#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS != 64
-#undef _FILE_OFFSET_BITS
-#define _FILE_OFFSET_BITS 64
-#endif
-#ifndef __USE_LARGEFILE64
-# define __USE_LARGEFILE64 1
-#endif
-/* We absolutely do _NOT_ want interfaces silently
- * renamed under us or very bad things will happen... */
-#ifdef __USE_FILE_OFFSET64
-# undef __USE_FILE_OFFSET64
-#endif
+#include <_lfs_64.h>
+
+#include <dirent.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
@@ -19,6 +14,9 @@
#include <dirent.h>
#include "dirstream.h"
+libc_hidden_proto(memcpy)
+
+libc_hidden_proto(readdir64_r)
int readdir64_r(DIR *dir, struct dirent64 *entry, struct dirent64 **result)
{
int ret;
@@ -59,7 +57,7 @@ int readdir64_r(DIR *dir, struct dirent64 *entry, struct dirent64 **result)
if (de == NULL) {
*result = NULL;
} else {
- *result = __memcpy (entry, de, de->d_reclen);
+ *result = memcpy (entry, de, de->d_reclen);
}
ret = 0;
@@ -68,3 +66,4 @@ all_done:
__pthread_mutex_unlock(&(dir->dd_lock));
return((de != NULL)? 0 : ret);
}
+libc_hidden_def(readdir64_r)
diff --git a/libc/misc/dirent/readdir_r.c b/libc/misc/dirent/readdir_r.c
index 25cb80b63..2c44707f2 100644
--- a/libc/misc/dirent/readdir_r.c
+++ b/libc/misc/dirent/readdir_r.c
@@ -1,3 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
#include <errno.h>
#include <stdlib.h>
#include <string.h>
@@ -5,6 +11,9 @@
#include <dirent.h>
#include "dirstream.h"
+libc_hidden_proto(memcpy)
+
+libc_hidden_proto(readdir_r)
int readdir_r(DIR *dir, struct dirent *entry, struct dirent **result)
{
int ret;
@@ -45,7 +54,7 @@ int readdir_r(DIR *dir, struct dirent *entry, struct dirent **result)
if (de == NULL) {
*result = NULL;
} else {
- *result = __memcpy (entry, de, de->d_reclen);
+ *result = memcpy (entry, de, de->d_reclen);
}
ret = 0;
@@ -55,3 +64,4 @@ all_done:
return((de != NULL)? 0 : ret);
}
+libc_hidden_def(readdir_r)
diff --git a/libc/misc/dirent/rewinddir.c b/libc/misc/dirent/rewinddir.c
index 18d6547a8..516700183 100644
--- a/libc/misc/dirent/rewinddir.c
+++ b/libc/misc/dirent/rewinddir.c
@@ -1,8 +1,15 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
#include <dirent.h>
#include <errno.h>
#include <unistd.h>
#include "dirstream.h"
+libc_hidden_proto(lseek)
/* rewinddir() just does an lseek(fd,0,0) - see close for comments */
void rewinddir(DIR * dir)
@@ -12,7 +19,7 @@ void rewinddir(DIR * dir)
return;
}
__pthread_mutex_lock(&(dir->dd_lock));
- __lseek(dir->dd_fd, 0, SEEK_SET);
+ lseek(dir->dd_fd, 0, SEEK_SET);
dir->dd_nextoff = dir->dd_nextloc = dir->dd_size = 0;
__pthread_mutex_unlock(&(dir->dd_lock));
}
diff --git a/libc/misc/dirent/scandir.c b/libc/misc/dirent/scandir.c
index 72929fb57..41491baee 100644
--- a/libc/misc/dirent/scandir.c
+++ b/libc/misc/dirent/scandir.c
@@ -1,28 +1,8 @@
-/* Copyright (C) 1992-1998, 2000 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA.
- */
-
-/* Modified for uClibc by Erik Andersen
- */
-
-#define qsort __qsort
-#define opendir __opendir
-#define closedir __closedir
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
#include <dirent.h>
#include <stdio.h>
@@ -32,6 +12,12 @@
#include <sys/types.h>
#include "dirstream.h"
+libc_hidden_proto(memcpy)
+libc_hidden_proto(readdir)
+libc_hidden_proto(opendir)
+libc_hidden_proto(closedir)
+libc_hidden_proto(qsort)
+
int scandir(const char *dir, struct dirent ***namelist,
int (*selector) (const struct dirent *),
int (*compar) (const void *, const void *))
@@ -49,7 +35,7 @@ int scandir(const char *dir, struct dirent ***namelist,
__set_errno (0);
pos = 0;
- while ((current = __readdir (dp)) != NULL)
+ while ((current = readdir (dp)) != NULL)
if (selector == NULL || (*selector) (current))
{
struct dirent *vnew;
@@ -76,7 +62,7 @@ int scandir(const char *dir, struct dirent ***namelist,
if (vnew == NULL)
break;
- names[pos++] = (struct dirent *) __memcpy (vnew, current, dsize);
+ names[pos++] = (struct dirent *) memcpy (vnew, current, dsize);
}
if (unlikely(errno != 0))
diff --git a/libc/misc/dirent/scandir64.c b/libc/misc/dirent/scandir64.c
index e77b88d3c..7b1dbd000 100644
--- a/libc/misc/dirent/scandir64.c
+++ b/libc/misc/dirent/scandir64.c
@@ -20,24 +20,7 @@
/* Modified for uClibc by Erik Andersen
*/
-#define qsort __qsort
-#define opendir __opendir
-#define closedir __closedir
-
-#include <features.h>
-
-#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS != 64
-#undef _FILE_OFFSET_BITS
-#define _FILE_OFFSET_BITS 64
-#endif
-#ifndef __USE_LARGEFILE64
-# define __USE_LARGEFILE64 1
-#endif
-/* We absolutely do _NOT_ want interfaces silently
- * renamed under us or very bad things will happen... */
-#ifdef __USE_FILE_OFFSET64
-# undef __USE_FILE_OFFSET64
-#endif
+#include <_lfs_64.h>
#include <dirent.h>
#include <stdio.h>
@@ -47,6 +30,12 @@
#include <sys/types.h>
#include "dirstream.h"
+libc_hidden_proto(memcpy)
+libc_hidden_proto(opendir)
+libc_hidden_proto(closedir)
+libc_hidden_proto(qsort)
+libc_hidden_proto(readdir64)
+
int scandir64(const char *dir, struct dirent64 ***namelist,
int (*selector) (const struct dirent64 *),
int (*compar) (const void *, const void *))
@@ -64,7 +53,7 @@ int scandir64(const char *dir, struct dirent64 ***namelist,
__set_errno (0);
pos = 0;
- while ((current = __readdir64 (dp)) != NULL)
+ while ((current = readdir64 (dp)) != NULL)
if (selector == NULL || (*selector) (current))
{
struct dirent64 *vnew;
@@ -91,7 +80,7 @@ int scandir64(const char *dir, struct dirent64 ***namelist,
if (vnew == NULL)
break;
- names[pos++] = (struct dirent64 *) __memcpy (vnew, current, dsize);
+ names[pos++] = (struct dirent64 *) memcpy (vnew, current, dsize);
}
if (unlikely(errno != 0))
diff --git a/libc/misc/dirent/seekdir.c b/libc/misc/dirent/seekdir.c
index 6e841291a..ba25ffd40 100644
--- a/libc/misc/dirent/seekdir.c
+++ b/libc/misc/dirent/seekdir.c
@@ -1,8 +1,16 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
#include <dirent.h>
#include <errno.h>
#include <unistd.h>
#include "dirstream.h"
+libc_hidden_proto(lseek)
+
void seekdir(DIR * dir, long int offset)
{
if (!dir) {
@@ -10,7 +18,7 @@ void seekdir(DIR * dir, long int offset)
return;
}
__pthread_mutex_lock(&(dir->dd_lock));
- dir->dd_nextoff = __lseek(dir->dd_fd, offset, SEEK_SET);
+ dir->dd_nextoff = lseek(dir->dd_fd, offset, SEEK_SET);
dir->dd_size = dir->dd_nextloc = 0;
__pthread_mutex_unlock(&(dir->dd_lock));
}
diff --git a/libc/misc/dirent/telldir.c b/libc/misc/dirent/telldir.c
index 124030431..3c5deca8e 100644
--- a/libc/misc/dirent/telldir.c
+++ b/libc/misc/dirent/telldir.c
@@ -1,3 +1,9 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
#include <dirent.h>
#include <errno.h>
#include <unistd.h>
diff --git a/libc/misc/error/Makefile.in b/libc/misc/error/Makefile.in
index 2977256d9..c529e955e 100644
--- a/libc/misc/error/Makefile.in
+++ b/libc/misc/error/Makefile.in
@@ -1,24 +1,21 @@
# Makefile for uClibc
#
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC:=error.c err.c
+CSRC := error.c err.c
-MISC_ERROR_DIR:=$(top_srcdir)libc/misc/error
-MISC_ERROR_OUT:=$(top_builddir)libc/misc/error
+MISC_ERROR_DIR := $(top_srcdir)libc/misc/error
+MISC_ERROR_OUT := $(top_builddir)libc/misc/error
-MISC_ERROR_SRC:=$(patsubst %.c,$(MISC_ERROR_DIR)/%.c,$(CSRC))
-MISC_ERROR_OBJ:=$(patsubst %.c,$(MISC_ERROR_OUT)/%.o,$(CSRC))
+MISC_ERROR_SRC := $(patsubst %.c,$(MISC_ERROR_DIR)/%.c,$(CSRC))
+MISC_ERROR_OBJ := $(patsubst %.c,$(MISC_ERROR_OUT)/%.o,$(CSRC))
-libc-a-y+=$(MISC_ERROR_OBJ)
-libc-so-y+=$(MISC_ERROR_OBJ:.o=.os)
+libc-y += $(MISC_ERROR_OBJ)
-libc-multi-y+=$(MISC_ERROR_SRC)
-
-objclean-y+=misc_error_objclean
+objclean-y += misc_error_objclean
misc_error_objclean:
$(RM) $(MISC_ERROR_OUT)/*.{o,os}
diff --git a/libc/misc/error/err.c b/libc/misc/error/err.c
index 43fe60cc6..00e74ce61 100644
--- a/libc/misc/error/err.c
+++ b/libc/misc/error/err.c
@@ -5,9 +5,6 @@
* Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details.
*/
-#define vfprintf __vfprintf
-
-#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -22,6 +19,18 @@
#warning REMINDER: Deal with wide oriented stderr case.
#endif
+libc_hidden_proto(vwarn)
+libc_hidden_proto(vwarnx)
+libc_hidden_proto(verr)
+libc_hidden_proto(verrx)
+
+libc_hidden_proto(fprintf)
+libc_hidden_proto(vfprintf)
+libc_hidden_proto(__xpg_strerror_r)
+libc_hidden_proto(exit)
+libc_hidden_proto(vfprintf)
+libc_hidden_proto(stderr)
+
static void vwarn_work(const char *format, va_list args, int showerr)
{
/* 0123 45678 9 a b*/
@@ -34,7 +43,7 @@ static void vwarn_work(const char *format, va_list args, int showerr)
f = fmt + 11; /* At 11. */
if (showerr) {
f -= 4; /* At 7. */
- __xpg_strerror_r_internal(errno, buf, sizeof(buf));
+ __xpg_strerror_r(errno, buf, sizeof(buf));
}
__STDIO_AUTO_THREADLOCK(stderr);
@@ -49,68 +58,68 @@ static void vwarn_work(const char *format, va_list args, int showerr)
__STDIO_AUTO_THREADUNLOCK(stderr);
}
-void attribute_hidden __vwarn(const char *format, va_list args)
+void vwarn(const char *format, va_list args)
{
vwarn_work(format, args, 1);
}
-strong_alias(__vwarn,vwarn)
+libc_hidden_def(vwarn)
void warn(const char *format, ...)
{
va_list args;
va_start(args, format);
- __vwarn(format, args);
+ vwarn(format, args);
va_end(args);
}
-void attribute_hidden __vwarnx(const char *format, va_list args)
+void vwarnx(const char *format, va_list args)
{
vwarn_work(format, args, 0);
}
-strong_alias(__vwarnx,vwarnx)
+libc_hidden_def(vwarnx)
void warnx(const char *format, ...)
{
va_list args;
va_start(args, format);
- __vwarnx(format, args);
+ vwarnx(format, args);
va_end(args);
}
-void attribute_hidden __verr(int status, const char *format, va_list args)
+void verr(int status, const char *format, va_list args)
{
- __vwarn(format, args);
- __exit(status);
+ vwarn(format, args);
+ exit(status);
}
-strong_alias(__verr,verr)
+libc_hidden_def(verr)
void attribute_noreturn err(int status, const char *format, ...)
{
va_list args;
va_start(args, format);
- __verr(status, format, args);
+ verr(status, format, args);
/* This should get optimized away. We'll leave it now for safety. */
/* The loop is added only to keep gcc happy. */
while(1)
va_end(args);
}
-void attribute_hidden __verrx(int status, const char *format, va_list args)
+void verrx(int status, const char *format, va_list args)
{
- __vwarnx(format, args);
- __exit(status);
+ vwarnx(format, args);
+ exit(status);
}
-strong_alias(__verrx,verrx)
+libc_hidden_def(verrx)
void attribute_noreturn errx(int status, const char *format, ...)
{
va_list args;
va_start(args, format);
- __verrx(status, format, args);
+ verrx(status, format, args);
/* This should get optimized away. We'll leave it now for safety. */
/* The loop is added only to keep gcc happy. */
while(1)
diff --git a/libc/misc/error/error.c b/libc/misc/error/error.c
index b51177e35..3e44a01ee 100644
--- a/libc/misc/error/error.c
+++ b/libc/misc/error/error.c
@@ -1,50 +1,54 @@
/* Error handler for noninteractive utilities
- Copyright (C) 1990-1998, 2000, 2001 Free Software Foundation, Inc.
-
- This file is part of the GNU C Library. Its master source is NOT part of
- the C library, however. The master source lives in /gd/gnu/lib.
+ Copyright (C) 1990-1998, 2000-2004, 2005 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
+ Lesser General Public License for more details.
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
/* Adjusted slightly by Erik Andersen <andersen@uclibc.org> */
-#define strerror __strerror
-#define vfprintf __vfprintf
-#define fflush __fflush
-
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-#include "error.h"
-
-extern int __putc(int c, FILE *stream) attribute_hidden;
+#include <error.h>
+
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strerror)
+libc_hidden_proto(fprintf)
+libc_hidden_proto(exit)
+libc_hidden_proto(putc)
+libc_hidden_proto(vfprintf)
+libc_hidden_proto(fflush)
+libc_hidden_proto(fputc)
+libc_hidden_proto(__fputc_unlocked)
+libc_hidden_proto(stdout)
+libc_hidden_proto(stderr)
/* This variable is incremented each time `error' is called. */
-unsigned int error_message_count;
+unsigned int error_message_count = 0;
/* Sometimes we want to have at most one error per line. This
variable controls whether this mode is selected or not. */
int error_one_per_line;
/* If NULL, error will flush stdout, then print on stderr the program
name, a colon and a space. Otherwise, error will call this
function without parameters instead. */
-void (*error_print_progname) (void) = NULL;
-
+/* void (*error_print_progname) (void) = NULL; */
+extern __typeof(error) __error attribute_hidden;
void __error (int status, int errnum, const char *message, ...)
{
va_list args;
@@ -58,11 +62,12 @@ void __error (int status, int errnum, const char *message, ...)
if (errnum) {
fprintf (stderr, ": %s", strerror (errnum));
}
- __putc ('\n', stderr);
+ putc ('\n', stderr);
if (status)
- __exit (status);
+ exit (status);
}
+extern __typeof(error_at_line) __error_at_line attribute_hidden;
void __error_at_line (int status, int errnum, const char *file_name,
unsigned int line_number, const char *message, ...)
{
@@ -73,7 +78,7 @@ void __error_at_line (int status, int errnum, const char *file_name,
static unsigned int old_line_number;
if (old_line_number == line_number &&
- (file_name == old_file_name || !__strcmp (old_file_name, file_name)))
+ (file_name == old_file_name || !strcmp (old_file_name, file_name)))
/* Simply return and print nothing. */
return;
@@ -94,13 +99,11 @@ void __error_at_line (int status, int errnum, const char *file_name,
if (errnum) {
fprintf (stderr, ": %s", strerror (errnum));
}
- __putc ('\n', stderr);
+ putc ('\n', stderr);
if (status)
- __exit (status);
+ exit (status);
}
-/* Use the weaks here in an effort at controlling namespace pollution */
-#undef error
-#undef error_at_line
-weak_alias (__error, error)
-weak_alias (__error_at_line, error_at_line)
+/* psm: keep this weak, too many use this in common code */
+weak_alias(__error,error)
+strong_alias(__error_at_line,error_at_line)
diff --git a/libc/misc/file/Makefile.in b/libc/misc/file/Makefile.in
index 9410a887a..bc3b2f124 100644
--- a/libc/misc/file/Makefile.in
+++ b/libc/misc/file/Makefile.in
@@ -1,27 +1,25 @@
# Makefile for uClibc
#
# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-MISC_FILE_DIR:=$(top_srcdir)libc/misc/file
-MISC_FILE_OUT:=$(top_builddir)libc/misc/file
+MISC_FILE_DIR := $(top_srcdir)libc/misc/file
+MISC_FILE_OUT := $(top_builddir)libc/misc/file
-MISC_FILE_SRC:=$(wildcard $(MISC_FILE_DIR)/*.c)
+MISC_FILE_SRC := $(wildcard $(MISC_FILE_DIR)/*.c)
ifneq ($(UCLIBC_HAS_LFS),y)
-MISC_FILE_SRC:=$(filter-out $(MISC_FILE_DIR)/lockf64.c,$(MISC_FILE_SRC))
+MISC_FILE_SRC := $(filter-out $(MISC_FILE_DIR)/lockf64.c,$(MISC_FILE_SRC))
endif
-MISC_FILE_OBJ:=$(patsubst $(MISC_FILE_DIR)/%.c,$(MISC_FILE_OUT)/%.o,$(MISC_FILE_SRC))
+MISC_FILE_OBJ := $(patsubst $(MISC_FILE_DIR)/%.c,$(MISC_FILE_OUT)/%.o,$(MISC_FILE_SRC))
-libc-a-y+=$(MISC_FILE_OBJ)
-libc-so-y+=$(MISC_FILE_OBJ:.o=.os)
+libc-y += $(MISC_FILE_OBJ)
-libc-multi-y+=$(MISC_FILE_DIR)/lockf.c
-libc-nomulti-$(UCLIBC_HAS_LFS)+=$(MISC_FILE_OUT)/lockf64.o
+libc-nomulti-$(UCLIBC_HAS_LFS) += $(MISC_FILE_OUT)/lockf64.o
-objclean-y+=misc_file_objclean
+objclean-y += misc_file_objclean
misc_file_objclean:
- $(RM) $(MISC_FILE_OUT)/*.{o,os}
+ $(RM) $(MISC_FILE_OUT)/*.{o,os,oS}
diff --git a/libc/misc/file/lockf.c b/libc/misc/file/lockf.c
index 2ba81de9a..6c1184be2 100644
--- a/libc/misc/file/lockf.c
+++ b/libc/misc/file/lockf.c
@@ -17,7 +17,6 @@
Boston, MA 02111-1307, USA. */
#include <features.h>
-#undef __lockf
#include <sys/types.h>
#include <unistd.h>
@@ -25,14 +24,19 @@
#include <errno.h>
#include <string.h>
+libc_hidden_proto(lockf)
+
+libc_hidden_proto(memset)
+libc_hidden_proto(fcntl)
+libc_hidden_proto(getpid)
+
/* lockf is a simplified interface to fcntl's locking facilities. */
-#undef lockf
-int attribute_hidden __lockf (int fd, int cmd, off_t len)
+int lockf (int fd, int cmd, off_t len)
{
struct flock fl;
- __memset ((char *) &fl, '\0', sizeof (fl));
+ memset ((char *) &fl, '\0', sizeof (fl));
/* lockf is always relative to the current file position. */
fl.l_whence = SEEK_CUR;
@@ -45,9 +49,9 @@ int attribute_hidden __lockf (int fd, int cmd, off_t len)
/* Test the lock: return 0 if FD is unlocked or locked by this process;
return -1, set errno to EACCES, if another process holds the lock. */
fl.l_type = F_RDLCK;
- if (__fcntl (fd, F_GETLK, &fl) < 0)
+ if (fcntl (fd, F_GETLK, &fl) < 0)
return -1;
- if (fl.l_type == F_UNLCK || fl.l_pid == __getpid ())
+ if (fl.l_type == F_UNLCK || fl.l_pid == getpid ())
return 0;
__set_errno(EACCES);
return -1;
@@ -70,6 +74,6 @@ int attribute_hidden __lockf (int fd, int cmd, off_t len)
return -1;
}
- return __fcntl(fd, cmd, &fl);
+ return fcntl(fd, cmd, &fl);
}
-strong_alias(__lockf,lockf)
+libc_hidden_def(lockf)
diff --git a/libc/misc/file/lockf64.c b/libc/misc/file/lockf64.c
index 1e294d9a6..48983d448 100644
--- a/libc/misc/file/lockf64.c
+++ b/libc/misc/file/lockf64.c
@@ -16,23 +16,7 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <features.h>
-#undef __lockf64
-
-#ifdef __UCLIBC_HAS_LFS__
-#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS != 64
-#undef _FILE_OFFSET_BITS
-#define _FILE_OFFSET_BITS 64
-#endif
-#ifndef __USE_FILE_OFFSET64
-# define __USE_FILE_OFFSET64 1
-#endif
-#ifndef __USE_LARGEFILE64
-# define __USE_LARGEFILE64 1
-#endif
-#endif
-
-#define __USE_GNU
+#include <_lfs_64.h>
#include <sys/types.h>
#include <unistd.h>
@@ -43,17 +27,23 @@
#ifdef __NR_fcntl64
#define flock flock64
-#define fcntl __fcntl64
+#define fcntl fcntl64
+#undef F_GETLK
#define F_GETLK F_GETLK64
+#undef F_SETLK
#define F_SETLK F_SETLK64
+libc_hidden_proto(fcntl64)
#else
-#define fcntl __fcntl
+libc_hidden_proto(fcntl)
#endif
+libc_hidden_proto(memset)
+libc_hidden_proto(getpid)
+
/* lockf is a simplified interface to fcntl's locking facilities. */
-#undef lockf64
-int attribute_hidden __lockf64 (int fd, int cmd, off64_t len64)
+libc_hidden_proto(lockf64)
+int lockf64 (int fd, int cmd, off64_t len64)
{
struct flock fl;
off_t len = (off_t) len64;
@@ -65,7 +55,7 @@ int attribute_hidden __lockf64 (int fd, int cmd, off64_t len64)
return -1;
}
- __memset((char *) &fl, '\0', sizeof (fl));
+ memset((char *) &fl, '\0', sizeof (fl));
/* lockf is always relative to the current file position. */
fl.l_whence = SEEK_CUR;
@@ -80,7 +70,7 @@ int attribute_hidden __lockf64 (int fd, int cmd, off64_t len64)
fl.l_type = F_RDLCK;
if (fcntl (fd, F_GETLK, &fl) < 0)
return -1;
- if (fl.l_type == F_UNLCK || fl.l_pid == __getpid ())
+ if (fl.l_type == F_UNLCK || fl.l_pid == getpid ())
return 0;
__set_errno(EACCES);
return -1;
@@ -105,5 +95,4 @@ int attribute_hidden __lockf64 (int fd, int cmd, off64_t len64)
return fcntl(fd, cmd, &fl);
}
-
-strong_alias(__lockf64,lockf64)
+libc_hidden_def(lockf64)
diff --git a/libc/misc/fnmatch/Makefile.in b/libc/misc/fnmatch/Makefile.in
index 61e125f9f..31873d676 100644
--- a/libc/misc/fnmatch/Makefile.in
+++ b/libc/misc/fnmatch/Makefile.in
@@ -1,29 +1,26 @@
# Makefile for uClibc
#
# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
ifeq ($(UCLIBC_HAS_FNMATCH_OLD),y)
-CSRC:=fnmatch_old.c
+CSRC := fnmatch_old.c
else
-CSRC:=fnmatch.c
+CSRC := fnmatch.c
endif
-MISC_FNMATCH_DIR:=$(top_srcdir)libc/misc/fnmatch
-MISC_FNMATCH_OUT:=$(top_builddir)libc/misc/fnmatch
+MISC_FNMATCH_DIR := $(top_srcdir)libc/misc/fnmatch
+MISC_FNMATCH_OUT := $(top_builddir)libc/misc/fnmatch
-MISC_FNMATCH_SRC:=$(patsubst %.c,$(MISC_FNMATCH_DIR)/%.c,$(CSRC))
-MISC_FNMATCH_OBJ:=$(patsubst %.c,$(MISC_FNMATCH_OUT)/%.o,$(CSRC))
+MISC_FNMATCH_SRC := $(patsubst %.c,$(MISC_FNMATCH_DIR)/%.c,$(CSRC))
+MISC_FNMATCH_OBJ := $(patsubst %.c,$(MISC_FNMATCH_OUT)/%.o,$(CSRC))
-libc-a-$(UCLIBC_HAS_FNMATCH)+=$(MISC_FNMATCH_OBJ)
-libc-so-$(UCLIBC_HAS_FNMATCH)+=$(MISC_FNMATCH_OBJ:.o=.os)
+libc-$(UCLIBC_HAS_FNMATCH) += $(MISC_FNMATCH_OBJ)
-libc-multi-$(UCLIBC_HAS_FNMATCH)+=$(MISC_FNMATCH_SRC)
-
-objclean-y+=misc_fnmatch_objclean
+objclean-y += misc_fnmatch_objclean
misc_fnmatch_objclean:
$(RM) $(MISC_FNMATCH_OUT)/*.{o,os}
diff --git a/libc/misc/fnmatch/fnmatch.c b/libc/misc/fnmatch/fnmatch.c
index 2dafebe18..5a6292c4b 100644
--- a/libc/misc/fnmatch/fnmatch.c
+++ b/libc/misc/fnmatch/fnmatch.c
@@ -17,28 +17,16 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define strcmp __strcmp
-
#if HAVE_CONFIG_H
# include <config.h>
#endif
-/* Enable GNU extensions in fnmatch.h. */
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-#endif
-
#include <features.h>
#ifdef __UCLIBC__
# undef _LIBC
# 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 +52,29 @@ 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)
+#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_b_loc)
+libc_hidden_proto(__ctype_tolower_loc)
+#else
+libc_hidden_proto(__ctype_b)
+libc_hidden_proto(__ctype_tolower)
+#endif
+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 +82,19 @@ 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)
# endif
# endif
#endif
@@ -96,21 +102,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 +175,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 +253,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 +265,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 +293,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 +361,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,16 +372,17 @@ is_char_class (const wchar_t *wcs)
# include "fnmatch_loop.c"
# endif
+#ifdef __UCLIBC_HAS_WCHAR__
+libc_hidden_proto(_stdlib_mb_cur_max)
+#else
+#undef MB_CUR_MAX
+#define MB_CUR_MAX 1
+#endif
-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;
-# endif
if (__builtin_expect (MB_CUR_MAX, 1) != 1)
{
mbstate_t ps;
@@ -386,10 +394,10 @@ extern size_t _stdlib_mb_cur_max_internal (void) __THROW __wur attribute_hidden;
/* Convert the strings into wide characters. */
__memset (&ps, '\0', sizeof (ps));
p = pattern;
-#if defined _LIBC || defined __UCLIBC__
- n = __strnlen (pattern, 1024);
+#ifdef _LIBC
+ n = strnlen (pattern, 1024);
#else
- n = __strlen (pattern);
+ n = strlen (pattern);
#endif
if (__builtin_expect (n < 1024, 1))
{
@@ -417,10 +425,10 @@ 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);
+#ifdef _LIBC
+ n = strnlen (string, 1024);
#else
- n = __strlen (string);
+ n = strlen (string);
#endif
p = string;
if (__builtin_expect (n < 1024, 1))
@@ -453,11 +461,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 +474,9 @@ 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_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 384756569..577e35676 100644
--- a/libc/misc/fnmatch/fnmatch_old.c
+++ b/libc/misc/fnmatch/fnmatch_old.c
@@ -19,15 +19,13 @@ Cambridge, MA 02139, USA. */
# include <config.h>
#endif
-/* Enable GNU extensions in fnmatch.h. */
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-#endif
-
#include <errno.h>
#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 +48,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 +114,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 +218,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__. */
diff --git a/libc/misc/ftw/Makefile.in b/libc/misc/ftw/Makefile.in
index 6c0304bc8..501b9084d 100644
--- a/libc/misc/ftw/Makefile.in
+++ b/libc/misc/ftw/Makefile.in
@@ -1,25 +1,22 @@
# Makefile for uClibc
#
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-SRC := ftw.c
+CSRC := ftw.c
ifeq ($(UCLIBC_HAS_LFS),y)
-SRC += ftw64.c
+CSRC += ftw64.c
endif
MISC_FTW_DIR := $(top_srcdir)libc/misc/ftw
MISC_FTW_OUT := $(top_builddir)libc/misc/ftw
-MISC_FTW_SRC := $(patsubst %.c,$(MISC_FTW_DIR)/%.c,$(SRC))
-MISC_FTW_OBJ := $(patsubst %.c,$(MISC_FTW_OUT)/%.o,$(SRC))
+MISC_FTW_SRC := $(patsubst %.c,$(MISC_FTW_DIR)/%.c,$(CSRC))
+MISC_FTW_OBJ := $(patsubst %.c,$(MISC_FTW_OUT)/%.o,$(CSRC))
-libc-a-$(UCLIBC_HAS_FTW) += $(MISC_FTW_OBJ)
-libc-so-$(UCLIBC_HAS_FTW) += $(MISC_FTW_OBJ:.o=.os)
-
-libc-multi-$(UCLIBC_HAS_FTW) += $(MISC_FTW_SRC)
+libc-$(UCLIBC_HAS_FTW) += $(MISC_FTW_OBJ)
objclean-y += misc_ftw_objclean
diff --git a/libc/misc/ftw/ftw.c b/libc/misc/ftw/ftw.c
index fdea1c208..18da40a33 100644
--- a/libc/misc/ftw/ftw.c
+++ b/libc/misc/ftw/ftw.c
@@ -22,7 +22,6 @@
# include <config.h>
#endif
-#define _GNU_SOURCE
#define _XOPEN_SOURCE 500
#include <features.h>
#ifdef __UCLIBC__
@@ -31,17 +30,6 @@
#define HAVE_SYS_PARAM_H 1
#define HAVE_DECL_STPCPY 1
#define HAVE_MEMPCPY 1
-#define dirfd __dirfd
-#define tsearch __tsearch
-#define tfind __tfind
-#define tdestroy __tdestroy
-#define getcwd __getcwd
-#define chdir __chdir
-#define fchdir __fchdir
-#define mempcpy __mempcpy
-#define opendir __opendir
-#define closedir __closedir
-#define stpcpy __stpcpy
#endif
#if __GNUC__
@@ -64,7 +52,7 @@ char *alloca ();
#else
# if HAVE_DIRENT_H
# include <dirent.h>
-# define NAMLEN(dirent) __strlen ((dirent)->d_name)
+# define NAMLEN(dirent) strlen ((dirent)->d_name)
# else
# define dirent direct
# define NAMLEN(dirent) (dirent)->d_namlen
@@ -96,6 +84,28 @@ char *alloca ();
# include <sys/stat.h>
#endif
+libc_hidden_proto(memset)
+libc_hidden_proto(strchr)
+libc_hidden_proto(strlen)
+libc_hidden_proto(dirfd)
+libc_hidden_proto(tsearch)
+libc_hidden_proto(tfind)
+libc_hidden_proto(tdestroy)
+libc_hidden_proto(getcwd)
+libc_hidden_proto(chdir)
+libc_hidden_proto(fchdir)
+libc_hidden_proto(mempcpy)
+libc_hidden_proto(opendir)
+#ifdef __UCLIBC_HAS_LFS__
+libc_hidden_proto(readdir64)
+libc_hidden_proto(lstat64)
+libc_hidden_proto(stat64)
+#endif
+libc_hidden_proto(closedir)
+libc_hidden_proto(stpcpy)
+libc_hidden_proto(lstat)
+libc_hidden_proto(stat)
+
#if ! _LIBC && !HAVE_DECL_STPCPY && !defined stpcpy
char *stpcpy ();
#endif
@@ -108,24 +118,30 @@ char *stpcpy ();
/* #define NDEBUG 1 */
#include <assert.h>
-#if !defined _LIBC && !defined __UCLIBC__
+#if !defined _LIBC
# undef __chdir
# define __chdir chdir
# undef __closedir
# define __closedir closedir
# undef __fchdir
# define __fchdir fchdir
-# ifndef __UCLIBC__
# undef __getcwd
+# ifndef __UCLIBC__
# define __getcwd(P, N) xgetcwd ()
extern char *xgetcwd (void);
+# else
+# define __getcwd getcwd
# endif
# undef __mempcpy
# define __mempcpy mempcpy
# undef __opendir
# define __opendir opendir
# undef __readdir64
+# ifndef __UCLIBC_HAS_LFS__
# define __readdir64 readdir
+# else
+# define __readdir64 readdir64
+# endif
# undef __stpcpy
# define __stpcpy stpcpy
# undef __tdestroy
@@ -136,8 +152,10 @@ extern char *xgetcwd (void);
# define __tsearch tsearch
# undef internal_function
# define internal_function /* empty */
+# ifndef __UCLIBC_HAS_LFS__
# undef dirent64
# define dirent64 dirent
+# endif
# undef MAX
# define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
@@ -167,21 +185,11 @@ int rpl_lstat (const char *, struct stat *);
# define LXSTAT __lxstat
# define XSTAT __xstat
# else
-# ifdef __UCLIBC__
-# define LXSTAT(V,f,sb) __lstat(f,sb)
-# define XSTAT(V,f,sb) __stat(f,sb)
-# define __readdir64 __readdir
-# define dirent64 dirent
-# else
# define LXSTAT(V,f,sb) lstat (f,sb)
# define XSTAT(V,f,sb) stat (f,sb)
-# endif
# endif
# define FTW_FUNC_T __ftw_func_t
# define NFTW_FUNC_T __nftw_func_t
-extern struct dirent *__readdir (DIR *__dirp) __nonnull ((1)) attribute_hidden;
-# else
-extern struct dirent64 *__readdir64 (DIR *__dirp) __nonnull ((1)) attribute_hidden;
#endif
/* We define PATH_MAX if the system does not provide a definition.
@@ -520,7 +528,7 @@ fail:
/* Next, update the `struct FTW' information. */
++data->ftw.level;
- startp = __strchr (data->dirbuf, '\0');
+ startp = strchr (data->dirbuf, '\0');
/* There always must be a directory name. */
assert (startp != data->dirbuf);
if (startp[-1] != '/')
@@ -556,7 +564,7 @@ fail:
while (result == 0 && *runp != '\0')
{
- char *endp = __strchr (runp, '\0');
+ char *endp = strchr (runp, '\0');
result = process_entry (data, &dir, runp, endp - runp);
@@ -633,10 +641,10 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
data.actdir = 0;
data.dirstreams = (struct dir_data **) alloca (data.maxdir
* sizeof (struct dir_data *));
- __memset (data.dirstreams, '\0', data.maxdir * sizeof (struct dir_data *));
+ memset (data.dirstreams, '\0', data.maxdir * sizeof (struct dir_data *));
/* PATH_MAX is always defined when we get here. */
- data.dirbufsize = MAX (2 * __strlen (dir), PATH_MAX);
+ data.dirbufsize = MAX (2 * strlen (dir), PATH_MAX);
data.dirbuf = (char *) malloc (data.dirbufsize);
if (data.dirbuf == NULL)
return -1;
@@ -749,7 +757,7 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
/* Return to the start directory (if necessary). */
if (cwd != NULL)
{
- int save_err = errno;
+ save_err = errno;
__chdir (cwd);
free (cwd);
__set_errno (save_err);
diff --git a/libc/misc/ftw/ftw64.c b/libc/misc/ftw/ftw64.c
index c4edd4d0a..de2fe22d1 100644
--- a/libc/misc/ftw/ftw64.c
+++ b/libc/misc/ftw/ftw64.c
@@ -24,8 +24,8 @@
#define NFTW_NEW_NAME __new_nftw64
#define INO_T ino64_t
#define STAT stat64
-#define LXSTAT(V,f,sb) __lstat64(f,sb)
-#define XSTAT(V,f,sb) __stat64(f,sb)
+#define LXSTAT(V,f,sb) lstat64(f,sb)
+#define XSTAT(V,f,sb) stat64(f,sb)
#define FTW_FUNC_T __ftw64_func_t
#define NFTW_FUNC_T __nftw64_func_t
diff --git a/libc/misc/glob/Makefile.in b/libc/misc/glob/Makefile.in
index cd845464f..2eda3dea2 100644
--- a/libc/misc/glob/Makefile.in
+++ b/libc/misc/glob/Makefile.in
@@ -1,31 +1,32 @@
# Makefile for uClibc
#
# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC:=glob.c glob64.c glob-hooks.c
+ifeq ($(UCLIBC_HAS_GNU_GLOB),y)
+CSRC := glob.c glob-hooks.c
+ifeq ($(UCLIBC_HAS_LFS),y)
+CSRC += glob64.c
+endif
+else
+CSRC := glob-susv3.c
+ifeq ($(UCLIBC_HAS_LFS),y)
+CSRC += glob64-susv3.c
+endif
+endif
-MISC_GLOB_DIR:=$(top_srcdir)libc/misc/glob
-MISC_GLOB_OUT:=$(top_builddir)libc/misc/glob
+MISC_GLOB_DIR := $(top_srcdir)libc/misc/glob
+MISC_GLOB_OUT := $(top_builddir)libc/misc/glob
-MISC_GLOB_SRC:=$(patsubst %.c,$(MISC_GLOB_DIR)/%.c,$(CSRC))
-MISC_GLOB_OBJ:=$(patsubst %.c,$(MISC_GLOB_OUT)/%.o,$(CSRC))
+MISC_GLOB_SRC := $(patsubst %.c,$(MISC_GLOB_DIR)/%.c,$(CSRC))
+MISC_GLOB_OBJ := $(patsubst %.c,$(MISC_GLOB_OUT)/%.o,$(CSRC))
-$(MISC_GLOB_OUT)/glob64.o: $(MISC_GLOB_DIR)/glob64.c $(MISC_GLOB_DIR)/glob.c
+libc-$(UCLIBC_HAS_GLOB) += $(MISC_GLOB_OBJ)
-$(MISC_GLOB_OUT)/glob64.os: $(MISC_GLOB_DIR)/glob64.c $(MISC_GLOB_DIR)/glob.c
-
-libc-a-$(UCLIBC_HAS_GLOB)+=$(MISC_GLOB_OBJ)
-libc-so-$(UCLIBC_HAS_GLOB)+=$(MISC_GLOB_OBJ:.o=.os)
-
-# glob has to be rewritten to allow multi
-#libc-multi-$(UCLIBC_HAS_GLOB)+=$(MISC_GLOB_SRC)
-libc-nomulti-$(UCLIBC_HAS_GLOB)+=$(MISC_GLOB_OBJ)
-
-objclean-y+=misc_glob_objclean
+objclean-y += misc_glob_objclean
misc_glob_objclean:
$(RM) $(MISC_GLOB_OUT)/*.{o,os}
diff --git a/libc/misc/glob/glob-hooks.c b/libc/misc/glob/glob-hooks.c
index e2d8030cf..e3529181f 100644
--- a/libc/misc/glob/glob-hooks.c
+++ b/libc/misc/glob/glob-hooks.c
@@ -29,7 +29,7 @@
#include <glob.h>
-__ptr_t (*__glob_opendir_hook) __P ((const char *directory));
-const char *(*__glob_readdir_hook) __P ((__ptr_t stream));
-void (*__glob_closedir_hook) __P ((__ptr_t stream));
+attribute_hidden __ptr_t (*__glob_opendir_hook) (const char *directory);
+attribute_hidden const char *(*__glob_readdir_hook) (__ptr_t stream);
+attribute_hidden void (*__glob_closedir_hook) (__ptr_t stream);
diff --git a/libc/misc/glob/glob-susv3.c b/libc/misc/glob/glob-susv3.c
new file mode 100644
index 000000000..e5b48cac3
--- /dev/null
+++ b/libc/misc/glob/glob-susv3.c
@@ -0,0 +1,322 @@
+/*
+ * Copyright (C) 2006 Rich Felker <dalias@aerifal.cx>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <features.h>
+
+#ifdef __UCLIBC_HAS_LFS__
+# define BUILD_GLOB64
+#endif
+
+#include <glob.h>
+#include <fnmatch.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <limits.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stddef.h>
+
+#include <unistd.h>
+#include <stdio.h>
+
+libc_hidden_proto(memcpy)
+libc_hidden_proto(strcat)
+libc_hidden_proto(strchr)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strcpy)
+libc_hidden_proto(strlen)
+libc_hidden_proto(opendir)
+libc_hidden_proto(closedir)
+libc_hidden_proto(qsort)
+libc_hidden_proto(fnmatch)
+
+struct match
+{
+ struct match *next;
+ char name[1];
+};
+
+#ifdef BUILD_GLOB64
+extern int __glob_is_literal(const char *p, int useesc) attribute_hidden;
+extern int __glob_append(struct match **tail, const char *name, size_t len, int mark) attribute_hidden;
+extern int __glob_ignore_err(const char *path, int err) attribute_hidden;
+extern void __glob_freelist(struct match *head) attribute_hidden;
+extern int __glob_sort(const void *a, const void *b) attribute_hidden;
+extern int __glob_match_in_dir(const char *d, const char *p, int flags, int (*errfunc)(const char *path, int err), struct match **tail) attribute_hidden;
+#endif
+
+#ifdef __UCLIBC_HAS_LFS__
+# define stat stat64
+# define readdir_r readdir64_r
+# define dirent dirent64
+libc_hidden_proto(readdir64_r)
+libc_hidden_proto(stat64)
+# define struct_stat struct stat64
+#else
+libc_hidden_proto(readdir_r)
+libc_hidden_proto(stat)
+# define struct_stat struct stat
+#endif
+
+/* keep only one copy of these */
+#ifndef __GLOB64
+
+# ifndef BUILD_GLOB64
+static
+# endif
+int __glob_is_literal(const char *p, int useesc)
+{
+ int bracket = 0;
+ for (; *p; p++) {
+ switch (*p) {
+ case '\\':
+ if (!useesc) break;
+ case '?':
+ case '*':
+ return 0;
+ case '[':
+ bracket = 1;
+ break;
+ case ']':
+ if (bracket) return 0;
+ break;
+ }
+ }
+ return 1;
+}
+
+# ifndef BUILD_GLOB64
+static
+# endif
+int __glob_append(struct match **tail, const char *name, size_t len, int mark)
+{
+ struct match *new = malloc(sizeof(struct match) + len + 1);
+ if (!new) return -1;
+ (*tail)->next = new;
+ new->next = NULL;
+ strcpy(new->name, name);
+ if (mark) strcat(new->name, "/");
+ *tail = new;
+ return 0;
+}
+
+# ifndef BUILD_GLOB64
+static
+# endif
+int __glob_match_in_dir(const char *d, const char *p, int flags, int (*errfunc)(const char *path, int err), struct match **tail)
+{
+ DIR *dir;
+ long long de_buf[(sizeof(struct dirent) + NAME_MAX + sizeof(long long))/sizeof(long long)];
+ struct dirent *de;
+ char pat[strlen(p)+1];
+ char *p2;
+ size_t l = strlen(d);
+ int literal;
+ int fnm_flags= ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0) | FNM_PERIOD;
+ int error;
+
+ if ((p2 = strchr(p, '/'))) {
+ strcpy(pat, p);
+ pat[p2-p] = 0;
+ for (; *p2 == '/'; p2++);
+ p = pat;
+ }
+ literal = __glob_is_literal(p, !(flags & GLOB_NOESCAPE));
+ if (*d == '/' && !*(d+1)) l = 0;
+
+ /* rely on opendir failing for nondirectory objects */
+ dir = opendir(*d ? d : ".");
+ error = errno;
+ if (!dir) {
+ /* this is not an error -- we let opendir call stat for us */
+ if (error == ENOTDIR) return 0;
+ if (error == EACCES && !*p) {
+ struct_stat st;
+ if (!stat(d, &st) && S_ISDIR(st.st_mode)) {
+ if (__glob_append(tail, d, l, l))
+ return GLOB_NOSPACE;
+ return 0;
+ }
+ }
+ if (errfunc(d, error) || (flags & GLOB_ERR))
+ return GLOB_ABORTED;
+ return 0;
+ }
+ if (!*p) {
+ error = __glob_append(tail, d, l, l) ? GLOB_NOSPACE : 0;
+ closedir(dir);
+ return error;
+ }
+ while (!(error = readdir_r(dir, (void *)de_buf, &de)) && de) {
+ char namebuf[l+de->d_reclen+2], *name = namebuf;
+ if (!literal && fnmatch(p, de->d_name, fnm_flags))
+ continue;
+ if (literal && strcmp(p, de->d_name))
+ continue;
+ if (p2 && de->d_type && !S_ISDIR(de->d_type<<12) && !S_ISLNK(de->d_type<<12))
+ continue;
+ if (*d) {
+ memcpy(name, d, l);
+ name[l] = '/';
+ strcpy(name+l+1, de->d_name);
+ } else {
+ name = de->d_name;
+ }
+ if (p2) {
+ if ((error = __glob_match_in_dir(name, p2, flags, errfunc, tail))) {
+ closedir(dir);
+ return error;
+ }
+ } else {
+ int mark = 0;
+ if (flags & GLOB_MARK) {
+ if (de->d_type)
+ mark = S_ISDIR(de->d_type<<12);
+ else {
+ struct_stat st;
+ stat(name, &st);
+ mark = S_ISDIR(st.st_mode);
+ }
+ }
+ if (__glob_append(tail, name, l+de->d_reclen+1, mark)) {
+ closedir(dir);
+ return GLOB_NOSPACE;
+ }
+ }
+ }
+ closedir(dir);
+ if (error && (errfunc(d, error) || (flags & GLOB_ERR)))
+ return GLOB_ABORTED;
+ return 0;
+}
+
+# ifndef BUILD_GLOB64
+static
+# endif
+int __glob_ignore_err(const char *path, int err)
+{
+ return 0;
+}
+
+# ifndef BUILD_GLOB64
+static
+# endif
+void __glob_freelist(struct match *head)
+{
+ struct match *match, *next;
+ for (match=head->next; match; match=next) {
+ next = match->next;
+ free(match);
+ }
+}
+
+# ifndef BUILD_GLOB64
+static
+# endif
+int __glob_sort(const void *a, const void *b)
+{
+ return strcmp(*(const char **)a, *(const char **)b);
+}
+#endif /* !__GLOB64 */
+
+#ifdef __GLOB64
+libc_hidden_proto(glob64)
+#else
+libc_hidden_proto(glob)
+#endif
+int glob(const char *pat, int flags, int (*errfunc)(const char *path, int err), glob_t *g)
+{
+ const char *p=pat, *d;
+ struct match head = { .next = NULL }, *tail = &head;
+ size_t cnt, i;
+ size_t offs = (flags & GLOB_DOOFFS) ? g->gl_offs : 0;
+ int error = 0;
+
+ if (*p == '/') {
+ for (; *p == '/'; p++);
+ d = "/";
+ } else {
+ d = "";
+ }
+
+ if (!errfunc) errfunc = __glob_ignore_err;
+
+ if (!(flags & GLOB_APPEND)) {
+ g->gl_offs = offs;
+ g->gl_pathc = 0;
+ g->gl_pathv = NULL;
+ }
+
+ if (*p) error = __glob_match_in_dir(d, p, flags, errfunc, &tail);
+ if (error == GLOB_NOSPACE) {
+ __glob_freelist(&head);
+ return error;
+ }
+
+ for (cnt=0, tail=head.next; tail; tail=tail->next, cnt++);
+ if (!cnt) {
+ if (flags & GLOB_NOCHECK) {
+ tail = &head;
+ if (__glob_append(&tail, pat, strlen(pat), 0))
+ return GLOB_NOSPACE;
+ cnt++;
+ } else
+ return GLOB_NOMATCH;
+ }
+
+ if (flags & GLOB_APPEND) {
+ char **pathv = realloc(g->gl_pathv, (offs + g->gl_pathc + cnt + 1) * sizeof(char *));
+ if (!pathv) {
+ __glob_freelist(&head);
+ return GLOB_NOSPACE;
+ }
+ g->gl_pathv = pathv;
+ offs += g->gl_pathc;
+ } else {
+ g->gl_pathv = malloc((offs + cnt + 1) * sizeof(char *));
+ if (!g->gl_pathv) {
+ __glob_freelist(&head);
+ return GLOB_NOSPACE;
+ }
+ for (i=0; i<offs; i++)
+ g->gl_pathv[i] = NULL;
+ }
+ for (i=0, tail=head.next; i<cnt; tail=tail->next, i++)
+ g->gl_pathv[offs + i] = tail->name;
+ g->gl_pathv[offs + i] = NULL;
+ g->gl_pathc += cnt;
+
+ if (!(flags & GLOB_NOSORT))
+ qsort(g->gl_pathv+offs, cnt, sizeof(char *), __glob_sort);
+
+ return error;
+}
+#ifdef __GLOB64
+libc_hidden_def(glob64)
+#else
+libc_hidden_def(glob)
+#endif
+
+#ifdef __GLOB64
+libc_hidden_proto(globfree64)
+#else
+libc_hidden_proto(globfree)
+#endif
+void globfree(glob_t *g)
+{
+ size_t i;
+ for (i=0; i<g->gl_pathc; i++)
+ free(g->gl_pathv[g->gl_offs + i] - offsetof(struct match, name));
+ free(g->gl_pathv);
+ g->gl_pathc = 0;
+ g->gl_pathv = NULL;
+}
+#ifdef __GLOB64
+libc_hidden_def(globfree64)
+#else
+libc_hidden_def(globfree)
+#endif
diff --git a/libc/misc/glob/glob.c b/libc/misc/glob/glob.c
index ea87d371c..f1875e8e3 100644
--- a/libc/misc/glob/glob.c
+++ b/libc/misc/glob/glob.c
@@ -15,11 +15,6 @@ 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. */
-#define strrchr __strrchr
-#define strcoll __strcoll
-#define qsort __qsort
-#define fnmatch __fnmatch
-
#include <features.h>
#include <stdlib.h>
#include <string.h>
@@ -30,36 +25,42 @@ Cambridge, MA 02139, USA. */
#include <dirent.h>
#include <malloc.h>
#include <fnmatch.h>
-#define _GNU_SOURCE
#include <glob.h>
-extern DIR *__opendir (__const char *__name) __nonnull ((1)) attribute_hidden;
-extern int __closedir (DIR *__dirp) __nonnull ((1)) attribute_hidden;
+libc_hidden_proto(memcpy)
+libc_hidden_proto(strcat)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strlen)
+libc_hidden_proto(strrchr)
+libc_hidden_proto(strcoll)
+libc_hidden_proto(opendir)
+libc_hidden_proto(closedir)
+libc_hidden_proto(fnmatch)
+libc_hidden_proto(qsort)
+libc_hidden_proto(lstat)
-extern __ptr_t (*__glob_opendir_hook) __P ((const char *directory));
-extern void (*__glob_closedir_hook) __P ((__ptr_t stream));
-extern const char *(*__glob_readdir_hook) __P ((__ptr_t stream));
+extern __ptr_t (*__glob_opendir_hook) (const char *directory) attribute_hidden;
+extern void (*__glob_closedir_hook) (__ptr_t stream) attribute_hidden;
+extern const char *(*__glob_readdir_hook) (__ptr_t stream) attribute_hidden;
-static int glob_in_dir __P ((const char *pattern, const char *directory,
- int flags,
- int (*errfunc) __P ((const char *, int)),
- glob_t *pglob));
-static int prefix_array __P ((const char *prefix, char **array, size_t n,
- int add_slash));
-static int collated_compare __P ((const __ptr_t, const __ptr_t));
+extern int __collated_compare (const __ptr_t a, const __ptr_t b) attribute_hidden;
+extern int __prefix_array (const char *dirname, char **array, size_t n, int add_slash) attribute_hidden;
+libc_hidden_proto(glob_pattern_p)
#ifdef __GLOB64
-extern int __glob_pattern_p(const char *pattern, int quote) attribute_hidden;
+libc_hidden_proto(glob64)
+libc_hidden_proto(globfree64)
+libc_hidden_proto(readdir64)
+#define __readdir readdir64
#else
-extern struct dirent *__readdir (DIR *__dirp) __nonnull ((1)) attribute_hidden;
-extern int __glob (__const char *__restrict __pattern, int __flags,
- int (*__errfunc) (__const char *, int),
- glob_t *__restrict __pglob) __THROW attribute_hidden;
-extern void __globfree (glob_t *__pglob) __THROW attribute_hidden;
+libc_hidden_proto(glob)
+libc_hidden_proto(globfree)
+#define __readdir readdir
+libc_hidden_proto(readdir)
/* Return nonzero if PATTERN contains any metacharacters.
Metacharacters can be quoted with backslashes if QUOTE is nonzero. */
-int attribute_hidden __glob_pattern_p(const char *pattern, int quote)
+int glob_pattern_p(const char *pattern, int quote)
{
const char *p;
int open = 0;
@@ -88,10 +89,208 @@ int attribute_hidden __glob_pattern_p(const char *pattern, int quote)
return 0;
}
-strong_alias(__glob_pattern_p,glob_pattern_p)
+libc_hidden_def(glob_pattern_p)
+
+
+/* Do a collated comparison of A and B. */
+int
+__collated_compare (const __ptr_t a, const __ptr_t b)
+{
+ const char *const s1 = *(const char *const *) a;
+ const char *const s2 = *(const char *const *) b;
+
+ if (s1 == s2)
+ return 0;
+ if (s1 == NULL)
+ return 1;
+ if (s2 == NULL)
+ return -1;
+ return strcoll (s1, s2);
+}
+
+
+/* Prepend DIRNAME to each of N members of ARRAY, replacing ARRAY's
+ elements in place. Return nonzero if out of memory, zero if successful.
+ A slash is inserted between DIRNAME and each elt of ARRAY,
+ unless DIRNAME is just "/". Each old element of ARRAY is freed.
+ If ADD_SLASH is non-zero, allocate one character more than
+ necessary, so that a slash can be appended later. */
+int
+__prefix_array (const char *dirname, char **array, size_t n, int add_slash)
+{
+ register size_t i;
+ size_t dirlen = strlen (dirname);
+
+ if (dirlen == 1 && dirname[0] == '/')
+ /* DIRNAME is just "/", so normal prepending would get us "//foo".
+ We want "/foo" instead, so don't prepend any chars from DIRNAME. */
+ dirlen = 0;
+
+ for (i = 0; i < n; ++i)
+ {
+ size_t eltlen = strlen (array[i]) + 1;
+ char *new = (char *) malloc (dirlen + 1 + eltlen + (add_slash ? 1 : 0));
+ if (new == NULL)
+ {
+ while (i > 0)
+ free ((__ptr_t) array[--i]);
+ return 1;
+ }
+
+ memcpy (new, dirname, dirlen);
+ new[dirlen] = '/';
+ memcpy (&new[dirlen + 1], array[i], eltlen);
+ free ((__ptr_t) array[i]);
+ array[i] = new;
+ }
+
+ return 0;
+}
#endif
+/* Like `glob', but PATTERN is a final pathname component,
+ and matches are searched for in DIRECTORY.
+ The GLOB_NOSORT bit in FLAGS is ignored. No sorting is ever done.
+ The GLOB_APPEND flag is assumed to be set (always appends). */
+static int
+glob_in_dir (const char *pattern, const char *directory, int flags, int (*errfunc) (const char *, int), glob_t *pglob)
+{
+ __ptr_t stream;
+
+ struct globlink
+ {
+ struct globlink *next;
+ char *name;
+ };
+ struct globlink *names = NULL;
+ size_t nfound = 0;
+ int meta;
+
+ stream = (__glob_opendir_hook ? (*__glob_opendir_hook) (directory)
+ : (__ptr_t) opendir (directory));
+ if (stream == NULL)
+ {
+ if ((errfunc != NULL && (*errfunc) (directory, errno)) ||
+ (flags & GLOB_ERR))
+ return GLOB_ABORTED;
+ }
+
+ meta = glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE));
+
+ if (meta)
+ flags |= GLOB_MAGCHAR;
+
+ while (1)
+ {
+ const char *name;
+ size_t len;
+
+ if (__glob_readdir_hook)
+ {
+ name = (*__glob_readdir_hook) (stream);
+ if (name == NULL)
+ break;
+ len = 0;
+ }
+ else
+ {
+ struct dirent *d = __readdir ((DIR *) stream);
+ if (d == NULL)
+ break;
+ if (! (d->d_ino != 0))
+ continue;
+ name = d->d_name;
+#ifdef _DIRENT_HAVE_D_NAMLEN
+ len = d->d_namlen;
+#else
+ len = 0;
+#endif
+ }
+
+ if ((!meta && strcmp (pattern, name) == 0)
+ || fnmatch (pattern, name,
+ (!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) |
+ ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)) == 0)
+ {
+ struct globlink *new
+ = (struct globlink *) alloca (sizeof (struct globlink));
+ if (len == 0)
+ len = strlen (name);
+ new->name
+ = (char *) malloc (len + ((flags & GLOB_MARK) ? 1 : 0) + 1);
+ if (new->name == NULL)
+ goto memory_error;
+ memcpy ((__ptr_t) new->name, name, len);
+ new->name[len] = '\0';
+ new->next = names;
+ names = new;
+ ++nfound;
+ if (!meta)
+ break;
+ }
+ }
+
+ if (nfound == 0 && (flags & GLOB_NOCHECK))
+ {
+ size_t len = strlen (pattern);
+ nfound = 1;
+ names = (struct globlink *) alloca (sizeof (struct globlink));
+ names->next = NULL;
+ names->name = (char *) malloc (len + (flags & GLOB_MARK ? 1 : 0) + 1);
+ if (names->name == NULL)
+ goto memory_error;
+ memcpy (names->name, pattern, len);
+ names->name[len] = '\0';
+ }
+
+ pglob->gl_pathv
+ = (char **) realloc (pglob->gl_pathv,
+ (pglob->gl_pathc +
+ ((flags & GLOB_DOOFFS) ? pglob->gl_offs : 0) +
+ nfound + 1) *
+ sizeof (char *));
+ if (pglob->gl_pathv == NULL)
+ goto memory_error;
+
+ if (flags & GLOB_DOOFFS)
+ while (pglob->gl_pathc < pglob->gl_offs)
+ pglob->gl_pathv[pglob->gl_pathc++] = NULL;
+
+ for (; names != NULL; names = names->next)
+ pglob->gl_pathv[pglob->gl_pathc++] = names->name;
+ pglob->gl_pathv[pglob->gl_pathc] = NULL;
+
+ pglob->gl_flags = flags;
+
+ {
+ int save = errno;
+ if (__glob_closedir_hook)
+ (*__glob_closedir_hook) (stream);
+ else
+ (void) closedir ((DIR *) stream);
+ errno = save;
+ }
+ return nfound == 0 ? GLOB_NOMATCH : 0;
+
+ memory_error:
+ {
+ int save = errno;
+ if (__glob_closedir_hook)
+ (*__glob_closedir_hook) (stream);
+ else
+ (void) closedir ((DIR *) stream);
+ errno = save;
+ }
+ while (names != NULL)
+ {
+ if (names->name != NULL)
+ free ((__ptr_t) names->name);
+ names = names->next;
+ }
+ return GLOB_NOSPACE;
+}
+
/* Do glob searching for PATTERN, placing results in PGLOB.
The bits defined above may be set in FLAGS.
If a directory cannot be opened or read and ERRFUNC is not nil,
@@ -100,11 +299,11 @@ strong_alias(__glob_pattern_p,glob_pattern_p)
`glob' returns GLOB_ABEND; if it returns zero, the error is ignored.
If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
Otherwise, `glob' returns zero. */
-int attribute_hidden
-__glob (pattern, flags, errfunc, pglob)
+int
+glob (pattern, flags, errfunc, pglob)
const char *pattern;
int flags;
- int (*errfunc) __P ((const char *, int));
+ int (*errfunc) (const char *, int);
glob_t *pglob;
{
const char *filename;
@@ -138,7 +337,7 @@ __glob (pattern, flags, errfunc, pglob)
{
dirlen = filename - pattern;
dirname = (char *) alloca (dirlen + 1);
- __memcpy (dirname, pattern, dirlen);
+ memcpy (dirname, pattern, dirlen);
dirname[dirlen] = '\0';
++filename;
}
@@ -146,7 +345,7 @@ __glob (pattern, flags, errfunc, pglob)
if (filename[0] == '\0' && dirlen > 1)
/* "pattern/". Expand "pattern", appending slashes. */
{
- int val = __glob (dirname, flags | GLOB_MARK, errfunc, pglob);
+ int val = glob (dirname, flags | GLOB_MARK, errfunc, pglob);
if (val == 0)
pglob->gl_flags = (pglob->gl_flags & ~GLOB_MARK) | (flags & GLOB_MARK);
return val;
@@ -160,7 +359,7 @@ __glob (pattern, flags, errfunc, pglob)
oldcount = pglob->gl_pathc;
- if (__glob_pattern_p (dirname, !(flags & GLOB_NOESCAPE)))
+ if (glob_pattern_p (dirname, !(flags & GLOB_NOESCAPE)))
{
/* The directory name contains metacharacters, so we
have to glob for the directory, and then glob for
@@ -168,7 +367,7 @@ __glob (pattern, flags, errfunc, pglob)
glob_t dirs;
register int i;
- status = __glob (dirname,
+ status = glob (dirname,
((flags & (GLOB_ERR | GLOB_NOCHECK | GLOB_NOESCAPE)) |
GLOB_NOSORT),
errfunc, &dirs);
@@ -180,8 +379,6 @@ __glob (pattern, flags, errfunc, pglob)
appending the results to PGLOB. */
for (i = 0; i < dirs.gl_pathc; ++i)
{
- int oldcount;
-
#ifdef SHELL
{
/* Make globbing interruptible in the bash shell. */
@@ -189,8 +386,8 @@ __glob (pattern, flags, errfunc, pglob)
if (interrupt_state)
{
- __globfree (&dirs);
- __globfree (&files);
+ globfree (&dirs);
+ globfree (&files);
return GLOB_ABEND;
}
}
@@ -206,19 +403,19 @@ __glob (pattern, flags, errfunc, pglob)
if (status != 0)
{
- __globfree (&dirs);
- __globfree (pglob);
+ globfree (&dirs);
+ globfree (pglob);
return status;
}
/* Stick the directory on the front of each name. */
- if (prefix_array (dirs.gl_pathv[i],
+ if (__prefix_array (dirs.gl_pathv[i],
&pglob->gl_pathv[oldcount],
pglob->gl_pathc - oldcount,
flags & GLOB_MARK))
{
- __globfree (&dirs);
- __globfree (pglob);
+ globfree (&dirs);
+ globfree (pglob);
return GLOB_NOSPACE;
}
}
@@ -230,11 +427,11 @@ __glob (pattern, flags, errfunc, pglob)
/* No matches. */
if (flags & GLOB_NOCHECK)
{
- size_t len = __strlen (pattern) + 1;
+ size_t len = strlen (pattern) + 1;
char *patcopy = (char *) malloc (len);
if (patcopy == NULL)
return GLOB_NOSPACE;
- __memcpy (patcopy, pattern, len);
+ memcpy (patcopy, pattern, len);
pglob->gl_pathv
= (char **) realloc (pglob->gl_pathv,
@@ -272,12 +469,12 @@ __glob (pattern, flags, errfunc, pglob)
if (dirlen > 0)
{
/* Stick the directory on the front of each name. */
- if (prefix_array (dirname,
+ if (__prefix_array (dirname,
&pglob->gl_pathv[oldcount],
pglob->gl_pathc - oldcount,
flags & GLOB_MARK))
{
- __globfree (pglob);
+ globfree (pglob);
return GLOB_NOSPACE;
}
}
@@ -290,29 +487,29 @@ __glob (pattern, flags, errfunc, pglob)
int i;
struct stat st;
for (i = oldcount; i < pglob->gl_pathc; ++i)
- if (__lstat (pglob->gl_pathv[i], &st) == 0 &&
+ if (lstat (pglob->gl_pathv[i], &st) == 0 &&
S_ISDIR (st.st_mode))
- __strcat (pglob->gl_pathv[i], "/");
+ strcat (pglob->gl_pathv[i], "/");
}
if (!(flags & GLOB_NOSORT))
/* Sort the vector. */
qsort ((__ptr_t) &pglob->gl_pathv[oldcount],
pglob->gl_pathc - oldcount,
- sizeof (char *), (__compar_fn_t)collated_compare);
+ sizeof (char *), (__compar_fn_t)__collated_compare);
return 0;
}
#ifdef __GLOB64
-strong_alias(__glob64,glob64)
+libc_hidden_def(glob64)
#else
-strong_alias(__glob,glob)
+libc_hidden_def(glob)
#endif
/* Free storage allocated in PGLOB by a previous `glob' call. */
-void attribute_hidden
-__globfree (pglob)
+void
+globfree (pglob)
register glob_t *pglob;
{
if (pglob->gl_pathv != NULL)
@@ -325,218 +522,7 @@ __globfree (pglob)
}
}
#ifdef __GLOB64
-strong_alias(__globfree64,globfree64)
+libc_hidden_def(globfree64)
#else
-strong_alias(__globfree,globfree)
+libc_hidden_def(globfree)
#endif
-
-
-/* Do a collated comparison of A and B. */
-static int
-collated_compare (a, b)
- const __ptr_t a;
- const __ptr_t b;
-{
- const char *const s1 = *(const char *const *) a;
- const char *const s2 = *(const char *const *) b;
-
- if (s1 == s2)
- return 0;
- if (s1 == NULL)
- return 1;
- if (s2 == NULL)
- return -1;
- return strcoll (s1, s2);
-}
-
-
-/* Prepend DIRNAME to each of N members of ARRAY, replacing ARRAY's
- elements in place. Return nonzero if out of memory, zero if successful.
- A slash is inserted between DIRNAME and each elt of ARRAY,
- unless DIRNAME is just "/". Each old element of ARRAY is freed.
- If ADD_SLASH is non-zero, allocate one character more than
- necessary, so that a slash can be appended later. */
-static int
-prefix_array (dirname, array, n, add_slash)
- const char *dirname;
- char **array;
- size_t n;
- int add_slash;
-{
- register size_t i;
- size_t dirlen = __strlen (dirname);
-
- if (dirlen == 1 && dirname[0] == '/')
- /* DIRNAME is just "/", so normal prepending would get us "//foo".
- We want "/foo" instead, so don't prepend any chars from DIRNAME. */
- dirlen = 0;
-
- for (i = 0; i < n; ++i)
- {
- size_t eltlen = __strlen (array[i]) + 1;
- char *new = (char *) malloc (dirlen + 1 + eltlen + (add_slash ? 1 : 0));
- if (new == NULL)
- {
- while (i > 0)
- free ((__ptr_t) array[--i]);
- return 1;
- }
-
- __memcpy (new, dirname, dirlen);
- new[dirlen] = '/';
- __memcpy (&new[dirlen + 1], array[i], eltlen);
- free ((__ptr_t) array[i]);
- array[i] = new;
- }
-
- return 0;
-}
-
-
-/* Like `glob', but PATTERN is a final pathname component,
- and matches are searched for in DIRECTORY.
- The GLOB_NOSORT bit in FLAGS is ignored. No sorting is ever done.
- The GLOB_APPEND flag is assumed to be set (always appends). */
-static int
-glob_in_dir (pattern, directory, flags, errfunc, pglob)
- const char *pattern;
- const char *directory;
- int flags;
- int (*errfunc) __P ((const char *, int));
- glob_t *pglob;
-{
- __ptr_t stream;
-
- struct globlink
- {
- struct globlink *next;
- char *name;
- };
- struct globlink *names = NULL;
- size_t nfound = 0;
- int meta;
-
- stream = (__glob_opendir_hook ? (*__glob_opendir_hook) (directory)
- : (__ptr_t) __opendir (directory));
- if (stream == NULL)
- {
- if ((errfunc != NULL && (*errfunc) (directory, errno)) ||
- (flags & GLOB_ERR))
- return GLOB_ABORTED;
- }
-
- meta = __glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE));
-
- if (meta)
- flags |= GLOB_MAGCHAR;
-
- while (1)
- {
- const char *name;
- size_t len;
-
- if (__glob_readdir_hook)
- {
- name = (*__glob_readdir_hook) (stream);
- if (name == NULL)
- break;
- len = 0;
- }
- else
- {
- struct dirent *d = __readdir ((DIR *) stream);
- if (d == NULL)
- break;
- if (! (d->d_ino != 0))
- continue;
- name = d->d_name;
-#ifdef _DIRENT_HAVE_D_NAMLEN
- len = d->d_namlen;
-#else
- len = 0;
-#endif
- }
-
- if ((!meta && __strcmp (pattern, name) == 0)
- || fnmatch (pattern, name,
- (!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) |
- ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)) == 0)
- {
- struct globlink *new
- = (struct globlink *) alloca (sizeof (struct globlink));
- if (len == 0)
- len = __strlen (name);
- new->name
- = (char *) malloc (len + ((flags & GLOB_MARK) ? 1 : 0) + 1);
- if (new->name == NULL)
- goto memory_error;
- __memcpy ((__ptr_t) new->name, name, len);
- new->name[len] = '\0';
- new->next = names;
- names = new;
- ++nfound;
- if (!meta)
- break;
- }
- }
-
- if (nfound == 0 && (flags & GLOB_NOCHECK))
- {
- size_t len = __strlen (pattern);
- nfound = 1;
- names = (struct globlink *) alloca (sizeof (struct globlink));
- names->next = NULL;
- names->name = (char *) malloc (len + (flags & GLOB_MARK ? 1 : 0) + 1);
- if (names->name == NULL)
- goto memory_error;
- __memcpy (names->name, pattern, len);
- names->name[len] = '\0';
- }
-
- pglob->gl_pathv
- = (char **) realloc (pglob->gl_pathv,
- (pglob->gl_pathc +
- ((flags & GLOB_DOOFFS) ? pglob->gl_offs : 0) +
- nfound + 1) *
- sizeof (char *));
- if (pglob->gl_pathv == NULL)
- goto memory_error;
-
- if (flags & GLOB_DOOFFS)
- while (pglob->gl_pathc < pglob->gl_offs)
- pglob->gl_pathv[pglob->gl_pathc++] = NULL;
-
- for (; names != NULL; names = names->next)
- pglob->gl_pathv[pglob->gl_pathc++] = names->name;
- pglob->gl_pathv[pglob->gl_pathc] = NULL;
-
- pglob->gl_flags = flags;
-
- {
- int save = errno;
- if (__glob_closedir_hook)
- (*__glob_closedir_hook) (stream);
- else
- (void) __closedir ((DIR *) stream);
- errno = save;
- }
- return nfound == 0 ? GLOB_NOMATCH : 0;
-
- memory_error:
- {
- int save = errno;
- if (__glob_closedir_hook)
- (*__glob_closedir_hook) (stream);
- else
- (void) __closedir ((DIR *) stream);
- errno = save;
- }
- while (names != NULL)
- {
- if (names->name != NULL)
- free ((__ptr_t) names->name);
- names = names->next;
- }
- return GLOB_NOSPACE;
-}
-
diff --git a/libc/misc/glob/glob64-susv3.c b/libc/misc/glob/glob64-susv3.c
new file mode 100644
index 000000000..cc633cd88
--- /dev/null
+++ b/libc/misc/glob/glob64-susv3.c
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2006 Rich Felker <dalias@aerifal.cx>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <_lfs_64.h>
+
+#include <dirent.h>
+#include <glob.h>
+#include <sys/stat.h>
+
+#define glob_t glob64_t
+#define glob(pattern, flags, errfunc, pglob) \
+ glob64 (pattern, flags, errfunc, pglob)
+#define globfree(pglob) globfree64 (pglob)
+
+#define __GLOB64 1
+
+#include "glob-susv3.c"
diff --git a/libc/misc/glob/glob64.c b/libc/misc/glob/glob64.c
index f0c65abe0..d84f874d5 100644
--- a/libc/misc/glob/glob64.c
+++ b/libc/misc/glob/glob64.c
@@ -1,47 +1,26 @@
-#include <features.h>
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
-#ifdef __UCLIBC_HAS_LFS__
+#include <_lfs_64.h>
-#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS != 64
-#undef _FILE_OFFSET_BITS
-#define _FILE_OFFSET_BITS 64
-#endif
-#ifndef __USE_LARGEFILE64
-# define __USE_LARGEFILE64 1
-#endif
-/* We absolutely do _NOT_ want interfaces silently
- * renamed under us or very bad things will happen... */
-#ifdef __USE_FILE_OFFSET64
-# undef __USE_FILE_OFFSET64
-#endif
#include <dirent.h>
#include <glob.h>
#include <sys/stat.h>
-extern struct dirent64 *__readdir64 (DIR *__dirp) __nonnull ((1)) attribute_hidden;
-extern int __glob64 (__const char *__restrict __pattern, int __flags,
- int (*__errfunc) (__const char *, int),
- glob64_t *__restrict __pglob) __THROW attribute_hidden;
-extern void __globfree (glob_t *__pglob) __THROW attribute_hidden;
-extern void __globfree64 (glob64_t *__pglob) __THROW attribute_hidden;
-
#define dirent dirent64
-#define __readdir(dirp) __readdir64(dirp)
#define glob_t glob64_t
-#define __glob(pattern, flags, errfunc, pglob) \
- __glob64 (pattern, flags, errfunc, pglob)
#define glob(pattern, flags, errfunc, pglob) \
glob64 (pattern, flags, errfunc, pglob)
-#define __globfree(pglob) __globfree64 (pglob)
#define globfree(pglob) globfree64 (pglob)
#undef stat
#define stat stat64
-#define __lstat __lstat64
+#define lstat lstat64
#define __GLOB64 1
#include "glob.c"
-
-#endif
diff --git a/libc/misc/gnu/Makefile.in b/libc/misc/gnu/Makefile.in
index d3ba2e549..bcd9400c3 100644
--- a/libc/misc/gnu/Makefile.in
+++ b/libc/misc/gnu/Makefile.in
@@ -1,25 +1,22 @@
# Makefile for uClibc
#
# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC:=obstack.c
+CSRC := obstack.c
-MISC_GNU_DIR:=$(top_srcdir)libc/misc/gnu
-MISC_GNU_OUT:=$(top_builddir)libc/misc/gnu
+MISC_GNU_DIR := $(top_srcdir)libc/misc/gnu
+MISC_GNU_OUT := $(top_builddir)libc/misc/gnu
-MISC_GNU_SRC:=$(MISC_GNU_DIR)/obstack.c
-MISC_GNU_OBJ:=$(MISC_GNU_OUT)/obstack.o
+MISC_GNU_SRC := $(MISC_GNU_DIR)/obstack.c
+MISC_GNU_OBJ := $(MISC_GNU_OUT)/obstack.o
-libc-a-y+=$(MISC_GNU_OBJ)
-libc-so-y+=$(MISC_GNU_OBJ:.o=.os)
+libc-y += $(MISC_GNU_OBJ)
-libc-multi-y+=$(MISC_GNU_SRC)
-
-objclean-y+=misc_gnu_objclean
+objclean-y += misc_gnu_objclean
misc_gnu_objclean:
$(RM) $(MISC_GNU_OUT)/*.{o,os}
diff --git a/libc/misc/gnu/obstack.c b/libc/misc/gnu/obstack.c
index 6521bd1d4..99311183f 100644
--- a/libc/misc/gnu/obstack.c
+++ b/libc/misc/gnu/obstack.c
@@ -51,7 +51,7 @@
# endif
#endif
-#if defined _LIBC && defined USE_IN_LIBIO
+#if (defined _LIBC && defined USE_IN_LIBIO) || defined __UCLIBC_HAS_WCHAR__
# include <wchar.h>
#endif
@@ -89,6 +89,7 @@ union fooround {long x; double d;};
abort gracefully or use longjump - but shouldn't return. This
variable by default points to the internal function
`print_and_abort'. */
+libc_hidden_proto(obstack_alloc_failed_handler)
# if defined __STDC__ && __STDC__
static void print_and_abort (void);
void (*obstack_alloc_failed_handler) (void) = print_and_abort;
@@ -96,6 +97,7 @@ void (*obstack_alloc_failed_handler) (void) = print_and_abort;
static void print_and_abort ();
void (*obstack_alloc_failed_handler) () = print_and_abort;
# endif
+libc_hidden_data_def(obstack_alloc_failed_handler)
/* Exit value used when `print_and_abort' is used. */
@@ -105,7 +107,18 @@ void (*obstack_alloc_failed_handler) () = print_and_abort;
# ifndef EXIT_FAILURE
# define EXIT_FAILURE 1
# endif
+
+libc_hidden_proto(fprintf)
+libc_hidden_proto(abort)
+libc_hidden_proto(exit)
+libc_hidden_proto(stderr)
+#ifdef __UCLIBC_HAS_WCHAR__
+libc_hidden_proto(fwprintf)
+#endif
+
+libc_hidden_proto(obstack_exit_failure)
int obstack_exit_failure = EXIT_FAILURE;
+libc_hidden_data_def(obstack_exit_failure)
/* The non-GNU-C macros copy the obstack into this global variable
to avoid multiple evaluation. */
@@ -480,15 +493,8 @@ _obstack_memory_used (h)
# define fputs(s, f) _IO_fputs (s, f)
# endif
-# ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later. */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
-# define __attribute__(Spec) /* empty */
-# endif
-# endif
-
static void
-__attribute__ ((noreturn))
+attribute_noreturn
print_and_abort ()
{
/* Don't change any of these strings. Yes, it would be possible to add
@@ -498,11 +504,11 @@ print_and_abort ()
a very similar string which requires a separate translation. */
# if defined _LIBC && defined USE_IN_LIBIO
if (_IO_fwide (stderr, 0) > 0)
- __fwprintf (stderr, L"%s\n", _("memory exhausted"));
+ fwprintf (stderr, L"%s\n", _("memory exhausted"));
else
# endif
fprintf (stderr, "%s\n", _("memory exhausted"));
- __exit (obstack_exit_failure);
+ exit (obstack_exit_failure);
}
# if 0
diff --git a/libc/misc/locale/Makefile.in b/libc/misc/locale/Makefile.in
index f4439cdf5..66b9809fa 100644
--- a/libc/misc/locale/Makefile.in
+++ b/libc/misc/locale/Makefile.in
@@ -1,57 +1,29 @@
# Makefile for uClibc
#
# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-MSRC:=locale.c
-MOBJ:=setlocale.o localeconv.o _locale_init.o nl_langinfo.o
-MOBJx:=
-
+# multi source locale.c
+CSRC := setlocale.c localeconv.c _locale_init.c nl_langinfo.c
ifeq ($(UCLIBC_HAS_LOCALE),y)
-MOBJ+=newlocale.o __locale_mbrtowc_l.o
+CSRC += newlocale.c __locale_mbrtowc_l.c
endif
-
ifeq ($(UCLIBC_HAS_XLOCALE),y)
-MOBJx:=nl_langinfo_l.o duplocale.o freelocale.o uselocale.o __curlocale.o
+CSRC += nl_langinfo_l.c duplocale.c freelocale.c uselocale.c __curlocale.c
endif
-MISC_LOCALE_NO_MULTI=localeconv.o
-
-MISC_LOCALE_DIR:=$(top_srcdir)libc/misc/locale
-MISC_LOCALE_OUT:=$(top_builddir)libc/misc/locale
-
-MISC_LOCALE_MSRC:=$(MISC_LOCALE_DIR)/$(MSRC)
-MISC_LOCALE_MOBJ:=$(patsubst %.o,$(MISC_LOCALE_OUT)/%.o,$(MOBJ))
-MISC_LOCALE_MOBJx:=$(patsubst %.o,$(MISC_LOCALE_OUT)/%.o,$(MOBJx))
-
-MISC_LOCALE_DEF:=$(patsubst %,-DL_%,$(subst .o,,$(filter-out $(MISC_LOCALE_NO_MULTI),$(notdir $(MISC_LOCALE_MOBJ)))))
-
-$(MISC_LOCALE_MOBJ): $(MISC_LOCALE_MSRC)
- $(compile.m)
-
-$(MISC_LOCALE_MOBJ:.o=.os): $(MISC_LOCALE_MSRC)
- $(compile.m)
-
-$(MISC_LOCALE_MOBJx): $(MISC_LOCALE_MSRC)
- $(compile.m) -D__UCLIBC_DO_XLOCALE
-
-$(MISC_LOCALE_MOBJx:.o=.os): $(MISC_LOCALE_MSRC)
- $(compile.m) -D__UCLIBC_DO_XLOCALE
+MISC_LOCALE_DIR := $(top_srcdir)libc/misc/locale
+MISC_LOCALE_OUT := $(top_builddir)libc/misc/locale
-libc-a-y+=$(MISC_LOCALE_MOBJ)
-libc-a-$(UCLIBC_HAS_XLOCALE)+=$(MISC_LOCALE_MOBJx)
-libc-so-y+=$(MISC_LOCALE_MOBJ:.o=.os)
-libc-so-$(UCLIBC_HAS_XLOCALE)+=$(MISC_LOCALE_MOBJx:.o=.os)
+MISC_LOCALE_SRC := $(patsubst %.c,$(MISC_LOCALE_DIR)/%.c,$(CSRC))
+MISC_LOCALE_OBJ := $(patsubst %.c,$(MISC_LOCALE_OUT)/%.o,$(CSRC))
-CFLAGS-multi-y+=$(MISC_LOCALE_DEF)
-libc-multi-y+=$(MISC_LOCALE_MSRC)
-libc-nomulti-y+=$(patsubst %.o,$(MISC_LOCALE_OUT)/%.o,$(MISC_LOCALE_NO_MULTI))
-libc-nomulti-$(UCLIBC_HAS_XLOCALE)+=$(MISC_LOCALE_MOBJx)
+libc-y += $(MISC_LOCALE_OBJ)
-objclean-y+=misc_locale_objclean
+objclean-y += misc_locale_objclean
misc_locale_objclean:
$(RM) $(MISC_LOCALE_OUT)/{*.{o,os}}
diff --git a/libc/misc/locale/__curlocale.c b/libc/misc/locale/__curlocale.c
new file mode 100644
index 000000000..aa38f4346
--- /dev/null
+++ b/libc/misc/locale/__curlocale.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___curlocale
+#define __UCLIBC_DO_XLOCALE
+#include "locale.c"
diff --git a/libc/misc/locale/__locale_mbrtowc_l.c b/libc/misc/locale/__locale_mbrtowc_l.c
new file mode 100644
index 000000000..ea7fbceb7
--- /dev/null
+++ b/libc/misc/locale/__locale_mbrtowc_l.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L___locale_mbrtowc_l
+#include "locale.c"
diff --git a/libc/misc/locale/_locale_init.c b/libc/misc/locale/_locale_init.c
new file mode 100644
index 000000000..9ced732a7
--- /dev/null
+++ b/libc/misc/locale/_locale_init.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L__locale_init
+#include "locale.c"
diff --git a/libc/misc/locale/duplocale.c b/libc/misc/locale/duplocale.c
new file mode 100644
index 000000000..db9c7a3c1
--- /dev/null
+++ b/libc/misc/locale/duplocale.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_duplocale
+#define __UCLIBC_DO_XLOCALE
+#include "locale.c"
diff --git a/libc/misc/locale/freelocale.c b/libc/misc/locale/freelocale.c
new file mode 100644
index 000000000..c1ef8e1ca
--- /dev/null
+++ b/libc/misc/locale/freelocale.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_freelocale
+#define __UCLIBC_DO_XLOCALE
+#include "locale.c"
diff --git a/libc/misc/locale/locale.c b/libc/misc/locale/locale.c
index 1a20300db..e53731e94 100644
--- a/libc/misc/locale/locale.c
+++ b/libc/misc/locale/locale.c
@@ -46,15 +46,8 @@
* locale support had (8-bit codesets only).
*/
-#define stpcpy __stpcpy
-#define strtok_r __strtok_r
-/* #define fflush __fflush */
-
-#define _GNU_SOURCE
-
#define __CTYPE_HAS_8_BIT_LOCALES 1
-
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
@@ -65,6 +58,19 @@
#include <ctype.h>
#include <stdio.h>
+libc_hidden_proto(memcpy)
+libc_hidden_proto(memset)
+libc_hidden_proto(stpcpy)
+libc_hidden_proto(strtok_r)
+libc_hidden_proto(strlen)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strcpy)
+libc_hidden_proto(strncmp)
+libc_hidden_proto(strchr)
+libc_hidden_proto(getenv)
+libc_hidden_proto(__C_ctype_toupper)
+/*libc_hidden_proto(fflush)*/
+
#ifdef __UCLIBC_MJN3_ONLY__
#ifdef L_setlocale
#warning TODO: Make the link_warning()s a config option?
@@ -142,6 +148,10 @@ extern void _locale_init_l(__locale_t base) attribute_hidden;
#include <langinfo.h>
#include <nl_types.h>
+#ifdef __UCLIBC_HAS_LOCALE__
+libc_hidden_proto(__global_locale)
+#endif
+
/**********************************************************************/
#ifdef L_setlocale
@@ -157,7 +167,7 @@ char *setlocale(int category, register const char *locale)
&& ( (!locale) /* Request for locale category string. */
|| (!*locale) /* Implementation-defined default is C. */
|| ((*locale == 'C') && !locale[1])
- || (!__strcmp(locale, "POSIX"))) )
+ || (!strcmp(locale, "POSIX"))) )
? (char *) C_string /* Always in C/POSIX locale. */
: NULL;
}
@@ -186,6 +196,8 @@ static const char utf8[] = "UTF-8";
*/
static char hr_locale[(MAX_LOCALE_CATEGORY_STR * LC_ALL) + MAX_LOCALE_STR];
+libc_hidden_proto(newlocale)
+
static void update_hr_locale(const unsigned char *spec)
{
const unsigned char *loc;
@@ -228,7 +240,7 @@ static void update_hr_locale(const unsigned char *spec)
*n = 0;
} else {
char at = 0;
- __memcpy(n, LOCALE_NAMES + 5*((*loc)-1), 5);
+ memcpy(n, LOCALE_NAMES + 5*((*loc)-1), 5);
if (n[2] != '_') {
at = n[2];
n[2] = '_';
@@ -263,9 +275,6 @@ static void update_hr_locale(const unsigned char *spec)
} while (!done);
}
-extern __locale_t __newlocale (int __category_mask, __const char *__locale,
- __locale_t __base) __THROW attribute_hidden;
-
char *setlocale(int category, const char *locale)
{
if (((unsigned int)(category)) > LC_ALL) {
@@ -276,7 +285,7 @@ char *setlocale(int category, const char *locale)
}
if (locale != NULL) { /* Not just a query... */
- if (!__newlocale((1 << category), locale, __global_locale)) {
+ if (!newlocale((1 << category), locale, __global_locale)) {
return NULL; /* Failed! */
}
update_hr_locale(__global_locale->cur_locale);
@@ -296,6 +305,8 @@ char *setlocale(int category, const char *locale)
* placement of the fields in the struct. If necessary, we could ensure
* this usings an array of offsets but at some size cost. */
+libc_hidden_proto(localeconv)
+
#ifdef __LOCALE_C_ONLY
link_warning(localeconv,"REMINDER: The 'localeconv' function is hardwired for C/POSIX locale only.")
@@ -349,16 +360,29 @@ struct lconv *localeconv(void)
#endif /* __LOCALE_C_ONLY */
+libc_hidden_def(localeconv)
+
#endif
/**********************************************************************/
#if defined(L__locale_init) && !defined(__LOCALE_C_ONLY)
+libc_hidden_proto(__C_ctype_b)
+libc_hidden_proto(__C_ctype_tolower)
+#ifndef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_b)
+libc_hidden_proto(__ctype_tolower)
+libc_hidden_proto(__ctype_toupper)
+#endif
+
__uclibc_locale_t __global_locale_data;
__locale_t __global_locale = &__global_locale_data;
+libc_hidden_data_def(__global_locale)
#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__curlocale_var)
__locale_t __curlocale_var = &__global_locale_data;
+libc_hidden_data_def(__curlocale_var)
#endif
/*----------------------------------------------------------------------*/
@@ -460,7 +484,7 @@ static int init_cur_collate(int der_num, __collate_t *cur_collate)
+ cdd->base_idx * sizeof(coldata_base_t)
)/2 );
- __memcpy(cur_collate, cdb, offsetof(coldata_base_t,index2weight_offset));
+ memcpy(cur_collate, cdb, offsetof(coldata_base_t,index2weight_offset));
cur_collate->undefined_idx = cdd->undefined_idx;
cur_collate->ti_mask = (1 << cur_collate->ti_shift)-1;
@@ -512,9 +536,9 @@ static int init_cur_collate(int der_num, __collate_t *cur_collate)
cur_collate->index2ruleidx = cur_collate->index2weight
+ cur_collate->max_col_index + 1;
- __memcpy(cur_collate->index2weight, cur_collate->index2weight_tbl,
+ memcpy(cur_collate->index2weight, cur_collate->index2weight_tbl,
cur_collate->num_col_base * sizeof(uint16_t));
- __memcpy(cur_collate->index2ruleidx, cur_collate->index2ruleidx_tbl,
+ memcpy(cur_collate->index2ruleidx, cur_collate->index2ruleidx_tbl,
cur_collate->num_col_base * sizeof(uint16_t));
/* now do the overrides */
@@ -599,7 +623,7 @@ int attribute_hidden _locale_set_l(const unsigned char *p, __locale_t base)
return 0; /* calloc failed. */
}
free(base->collate.index2weight);
- __memcpy(&base->collate, &newcol, sizeof(__collate_t));
+ memcpy(&base->collate, &newcol, sizeof(__collate_t));
}
do {
@@ -669,15 +693,15 @@ int attribute_hidden _locale_set_l(const unsigned char *p, __locale_t base)
* All of this will be replaced in the next generation
* of locale support anyway... */
- __memcpy(base->__ctype_b_data,
+ memcpy(base->__ctype_b_data,
__C_ctype_b - __UCLIBC_CTYPE_B_TBL_OFFSET,
(256 + __UCLIBC_CTYPE_B_TBL_OFFSET)
* sizeof(__ctype_mask_t));
- __memcpy(base->__ctype_tolower_data,
+ memcpy(base->__ctype_tolower_data,
__C_ctype_tolower - __UCLIBC_CTYPE_TO_TBL_OFFSET,
(256 + __UCLIBC_CTYPE_TO_TBL_OFFSET)
* sizeof(__ctype_touplow_t));
- __memcpy(base->__ctype_toupper_data,
+ memcpy(base->__ctype_toupper_data,
__C_ctype_toupper - __UCLIBC_CTYPE_TO_TBL_OFFSET,
(256 + __UCLIBC_CTYPE_TO_TBL_OFFSET)
* sizeof(__ctype_touplow_t));
@@ -787,7 +811,7 @@ int attribute_hidden _locale_set_l(const unsigned char *p, __locale_t base)
d = base->outdigit_length;
x = &base->outdigit0_mb;
for (c = 0 ; c < 10 ; c++) {
- ((unsigned char *)d)[c] = __strlen(x[c]);
+ ((unsigned char *)d)[c] = strlen(x[c]);
assert(d[c] > 0);
}
} else if (i == LC_NUMERIC) {
@@ -852,10 +876,10 @@ static const uint16_t __code2flag[16] = {
void attribute_hidden _locale_init_l(__locale_t base)
{
- __memset(base->cur_locale, 0, LOCALE_SELECTOR_SIZE);
+ memset(base->cur_locale, 0, LOCALE_SELECTOR_SIZE);
base->cur_locale[0] = '#';
- __memcpy(base->category_item_count,
+ memcpy(base->category_item_count,
__locale_mmap->lc_common_item_offsets_LEN,
LC_ALL);
@@ -913,7 +937,8 @@ void attribute_hidden _locale_init_l(__locale_t base)
_locale_set_l(C_LOCALE_SELECTOR, base);
}
-void attribute_hidden _locale_init(void)
+void _locale_init(void) attribute_hidden;
+void _locale_init(void)
{
/* TODO: mmap the locale file */
@@ -1006,7 +1031,8 @@ static const unsigned char nl_data[C_LC_ALL + 1 + 90 + 320] = {
']', '\x00', '^', '[', 'n', 'N', ']', '\x00',
};
-char attribute_hidden *__nl_langinfo(nl_item item)
+libc_hidden_proto(nl_langinfo)
+char *nl_langinfo(nl_item item)
{
unsigned int c;
unsigned int i;
@@ -1019,25 +1045,29 @@ char attribute_hidden *__nl_langinfo(nl_item item)
}
return (char *) cat_start; /* Conveniently, this is the empty string. */
}
-strong_alias(__nl_langinfo,nl_langinfo)
+libc_hidden_def(nl_langinfo)
#else /* __LOCALE_C_ONLY */
#if defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE)
-extern char *__nl_langinfo_l (nl_item __item, __locale_t l) attribute_hidden;
+libc_hidden_proto(nl_langinfo)
+
+libc_hidden_proto(nl_langinfo_l)
-char attribute_hidden *__nl_langinfo(nl_item item)
+char *nl_langinfo(nl_item item)
{
- return __nl_langinfo_l(item, __UCLIBC_CURLOCALE);
+ return nl_langinfo_l(item, __UCLIBC_CURLOCALE);
}
-strong_alias(__nl_langinfo,nl_langinfo)
+libc_hidden_def(nl_langinfo)
#else /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
+libc_hidden_proto(__XL_NPP(nl_langinfo))
+
static const char empty[] = "";
-char attribute_hidden *__UCXL(nl_langinfo)(nl_item item __LOCALE_PARAM )
+char *__XL_NPP(nl_langinfo)(nl_item item __LOCALE_PARAM )
{
unsigned int c = _NL_ITEM_CATEGORY(item);
unsigned int i = _NL_ITEM_INDEX(item);
@@ -1049,7 +1079,7 @@ char attribute_hidden *__UCXL(nl_langinfo)(nl_item item __LOCALE_PARAM )
return (char *) empty;
}
-__UCXL_ALIAS(nl_langinfo)
+libc_hidden_def(__XL_NPP(nl_langinfo))
#endif /* defined(__UCLIBC_HAS_XLOCALE__) && !defined(__UCLIBC_DO_XLOCALE) */
@@ -1059,6 +1089,8 @@ __UCXL_ALIAS(nl_langinfo)
/**********************************************************************/
#ifdef L_newlocale
+libc_hidden_proto(newlocale)
+
#ifdef __UCLIBC_MJN3_ONLY__
#warning TODO: Move posix and utf8 strings.
#endif
@@ -1082,14 +1114,14 @@ static int find_locale(int category_mask, const char *p,
char buf[18]; /* TODO: 7+{max codeset name length} */
const char *q;
- if ((q = __strchr(p,'@')) != NULL) {
+ if ((q = strchr(p,'@')) != NULL) {
if ((((size_t)((q-p)-5)) > (sizeof(buf) - 5)) || (p[2] != '_')) {
return 0;
}
/* locale name at least 5 chars long and 3rd char is '_' */
s = LOCALE_AT_MODIFIERS;
do {
- if (!__strcmp(s+2, q+1)) {
+ if (!strcmp(s+2, q+1)) {
break;
}
s += 2 + *s; /* TODO - fix this throughout */
@@ -1098,7 +1130,7 @@ static int find_locale(int category_mask, const char *p,
return 0;
}
assert(q - p < sizeof(buf));
- __memcpy(buf, p, q-p);
+ memcpy(buf, p, q-p);
buf[q-p] = 0;
buf[2] = s[1];
p = buf;
@@ -1106,19 +1138,19 @@ static int find_locale(int category_mask, const char *p,
#endif
lang_cult = codeset = 0; /* Assume C and default codeset. */
- if (((*p == 'C') && !p[1]) || !__strcmp(p, posix)) {
+ if (((*p == 'C') && !p[1]) || !strcmp(p, posix)) {
goto FIND_LOCALE;
}
- if ((__strlen(p) > 5) && (p[5] == '.')) { /* Codeset in locale name? */
+ if ((strlen(p) > 5) && (p[5] == '.')) { /* Codeset in locale name? */
/* TODO: maybe CODESET_LIST + *s ??? */
/* 7bit is 1, UTF-8 is 2, 8-bit is >= 3 */
codeset = 2;
- if (__strcmp(utf8,p+6) != 0) {/* TODO - fix! */
+ if (strcmp(utf8,p+6) != 0) {/* TODO - fix! */
s = CODESET_LIST;
do {
++codeset; /* Increment codeset first. */
- if (!__strcmp(CODESET_LIST+*s, p+6)) {
+ if (!strcmp(CODESET_LIST+*s, p+6)) {
goto FIND_LANG_CULT;
}
} while (*++s);
@@ -1131,7 +1163,7 @@ static int find_locale(int category_mask, const char *p,
do { /* TODO -- do a binary search? */
/* TODO -- fix gen_mmap!*/
++lang_cult; /* Increment first since C/POSIX is 0. */
- if (!__strncmp(s,p,5)) { /* Found a matching locale name; */
+ if (!strncmp(s,p,5)) { /* Found a matching locale name; */
goto FIND_LOCALE;
}
s += 5;
@@ -1173,14 +1205,14 @@ static unsigned char *composite_locale(int category_mask, const char *locale,
int c;
int component_mask;
- if (!__strchr(locale,'=')) {
+ if (!strchr(locale,'=')) {
if (!find_locale(category_mask, locale, new_locale)) {
return NULL;
}
return new_locale;
}
- if (__strlen(locale) >= sizeof(buf)) {
+ if (strlen(locale) >= sizeof(buf)) {
return NULL;
}
stpcpy(buf, locale);
@@ -1189,7 +1221,7 @@ static unsigned char *composite_locale(int category_mask, const char *locale,
t = strtok_r(buf, "=", &e); /* This can't fail because of strchr test above. */
do {
c = 0;
- while (__strcmp(CATEGORY_NAMES + (int) CATEGORY_NAMES[c], t)) {
+ while (strcmp(CATEGORY_NAMES + (int) CATEGORY_NAMES[c], t)) {
if (++c == LC_ALL) { /* Unknown category name! */
return NULL;
}
@@ -1212,7 +1244,7 @@ static unsigned char *composite_locale(int category_mask, const char *locale,
return new_locale;
}
-__locale_t attribute_hidden __newlocale(int category_mask, const char *locale, __locale_t base)
+__locale_t newlocale(int category_mask, const char *locale, __locale_t base)
{
const unsigned char *p;
int i, j, k;
@@ -1231,7 +1263,7 @@ __locale_t attribute_hidden __newlocale(int category_mask, const char *locale, _
#ifdef __UCLIBC_MJN3_ONLY__
#warning TODO: Rename cur_locale to locale_selector.
#endif
- __strcpy((char *) new_selector,
+ strcpy((char *) new_selector,
(base ? (char *) base->cur_locale : C_LOCALE_SELECTOR));
if (!*locale) { /* locale == "", so check environment. */
@@ -1251,7 +1283,7 @@ __locale_t attribute_hidden __newlocale(int category_mask, const char *locale, _
j = 0;
do {
p = envstr[j];
- } while ((++j < 4) && (!(p = __getenv(p)) || !*p));
+ } while ((++j < 4) && (!(p = getenv(p)) || !*p));
/* The user set something... is it valid? */
@@ -1296,18 +1328,19 @@ __locale_t attribute_hidden __newlocale(int category_mask, const char *locale, _
return base;
}
-
-weak_alias(__newlocale, newlocale)
+libc_hidden_def(newlocale)
#endif
/**********************************************************************/
#ifdef L_duplocale
+libc_hidden_proto(duplocale)
+
#ifdef __UCLIBC_MJN3_ONLY__
#warning REMINDER: When we allocate ctype tables, remember to dup them.
#endif
-__locale_t attribute_hidden __duplocale(__locale_t dataset)
+__locale_t duplocale(__locale_t dataset)
{
__locale_t r;
uint16_t * i2w;
@@ -1320,9 +1353,9 @@ __locale_t attribute_hidden __duplocale(__locale_t dataset)
if ((i2w = calloc(n, sizeof(uint16_t)))
!= NULL
) {
- __memcpy(r, dataset, sizeof(__uclibc_locale_t));
+ memcpy(r, dataset, sizeof(__uclibc_locale_t));
r->collate.index2weight = i2w;
- __memcpy(i2w, dataset->collate.index2weight, n * sizeof(uint16_t));
+ memcpy(i2w, dataset->collate.index2weight, n * sizeof(uint16_t));
} else {
free(r);
r = NULL;
@@ -1330,8 +1363,7 @@ __locale_t attribute_hidden __duplocale(__locale_t dataset)
}
return r;
}
-
-weak_alias(__duplocale, duplocale)
+libc_hidden_def(duplocale)
#endif
/**********************************************************************/
@@ -1341,7 +1373,7 @@ weak_alias(__duplocale, duplocale)
#warning REMINDER: When we allocate ctype tables, remember to free them.
#endif
-void __freelocale(__locale_t dataset)
+void freelocale(__locale_t dataset)
{
assert(dataset != __global_locale);
assert(dataset != LC_GLOBAL_LOCALE);
@@ -1350,13 +1382,14 @@ void __freelocale(__locale_t dataset)
free(dataset); /* Free locale */
}
-weak_alias(__freelocale, freelocale)
-
#endif
/**********************************************************************/
#ifdef L_uselocale
-__locale_t attribute_hidden __uselocale(__locale_t dataset)
+libc_hidden_proto(__curlocale_var)
+
+libc_hidden_proto(uselocale)
+__locale_t uselocale(__locale_t dataset)
{
__locale_t old;
@@ -1379,8 +1412,7 @@ __locale_t attribute_hidden __uselocale(__locale_t dataset)
}
return old;
}
-
-weak_alias(__uselocale, uselocale)
+libc_hidden_def(uselocale)
#endif
/**********************************************************************/
@@ -1388,6 +1420,8 @@ weak_alias(__uselocale, uselocale)
#ifdef __UCLIBC_HAS_THREADS__
+libc_hidden_proto(__curlocale_var)
+
__locale_t weak_const_function __curlocale(void)
{
return __curlocale_var; /* This is overriden by the thread version. */
diff --git a/libc/misc/locale/localeconv.c b/libc/misc/locale/localeconv.c
new file mode 100644
index 000000000..7e67fb249
--- /dev/null
+++ b/libc/misc/locale/localeconv.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_localeconv
+#include "locale.c"
diff --git a/libc/misc/locale/newlocale.c b/libc/misc/locale/newlocale.c
new file mode 100644
index 000000000..a9868849f
--- /dev/null
+++ b/libc/misc/locale/newlocale.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_newlocale
+#include "locale.c"
diff --git a/libc/misc/locale/nl_langinfo.c b/libc/misc/locale/nl_langinfo.c
new file mode 100644
index 000000000..0bc0a002b
--- /dev/null
+++ b/libc/misc/locale/nl_langinfo.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_nl_langinfo
+#include "locale.c"
diff --git a/libc/misc/locale/nl_langinfo_l.c b/libc/misc/locale/nl_langinfo_l.c
new file mode 100644
index 000000000..7205ccab1
--- /dev/null
+++ b/libc/misc/locale/nl_langinfo_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_nl_langinfo_l
+#define __UCLIBC_DO_XLOCALE
+#include "locale.c"
diff --git a/libc/misc/locale/setlocale.c b/libc/misc/locale/setlocale.c
new file mode 100644
index 000000000..1eae88aca
--- /dev/null
+++ b/libc/misc/locale/setlocale.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_setlocale
+#include "locale.c"
diff --git a/libc/misc/locale/uselocale.c b/libc/misc/locale/uselocale.c
new file mode 100644
index 000000000..2aecc5498
--- /dev/null
+++ b/libc/misc/locale/uselocale.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2004-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_uselocale
+#define __UCLIBC_DO_XLOCALE
+#include "locale.c"
diff --git a/libc/misc/mntent/Makefile.in b/libc/misc/mntent/Makefile.in
index c1674f494..b633e4eb2 100644
--- a/libc/misc/mntent/Makefile.in
+++ b/libc/misc/mntent/Makefile.in
@@ -1,25 +1,22 @@
# Makefile for uClibc
#
# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-CSRC:=mntent.c
+CSRC := mntent.c
-MISC_MNTENT_DIR:=$(top_srcdir)libc/misc/mntent
-MISC_MNTENT_OUT:=$(top_builddir)libc/misc/mntent
+MISC_MNTENT_DIR := $(top_srcdir)libc/misc/mntent
+MISC_MNTENT_OUT := $(top_builddir)libc/misc/mntent
-MISC_MNTENT_SRC:=$(MISC_MNTENT_DIR)/mntent.c
-MISC_MNTENT_OBJ:=$(MISC_MNTENT_OUT)/mntent.o
+MISC_MNTENT_SRC := $(MISC_MNTENT_DIR)/mntent.c
+MISC_MNTENT_OBJ := $(MISC_MNTENT_OUT)/mntent.o
-libc-a-y+=$(MISC_MNTENT_OBJ)
-libc-so-y+=$(MISC_MNTENT_OBJ:.o=.os)
+libc-y += $(MISC_MNTENT_OBJ)
-libc-multi-y+=$(MISC_MNTENT_SRC)
-
-objclean-y+=misc_mntent_objclean
+objclean-y += misc_mntent_objclean
misc_mntent_objclean:
$(RM) $(MISC_MNTENT_OUT)/*.{o,os}
diff --git a/libc/misc/mntent/mntent.c b/libc/misc/mntent/mntent.c
index 01970148f..3164f6634 100644
--- a/libc/misc/mntent/mntent.c
+++ b/libc/misc/mntent/mntent.c
@@ -1,14 +1,28 @@
-#define strtok_r __strtok_r
-#define strstr __strstr
-#define atoi __atoi
-#define fseek __fseek
-#define fgets __fgets
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <mntent.h>
+libc_hidden_proto(getmntent_r)
+libc_hidden_proto(setmntent)
+libc_hidden_proto(endmntent)
+
+libc_hidden_proto(strstr)
+libc_hidden_proto(strtok_r)
+libc_hidden_proto(atoi)
+libc_hidden_proto(fopen)
+libc_hidden_proto(fclose)
+libc_hidden_proto(fseek)
+libc_hidden_proto(fgets)
+libc_hidden_proto(abort)
+libc_hidden_proto(fprintf)
+
#ifdef __UCLIBC_HAS_THREADS__
# include <pthread.h>
static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER;
@@ -17,7 +31,7 @@ static pthread_mutex_t mylock = PTHREAD_MUTEX_INITIALIZER;
#define UNLOCK __pthread_mutex_unlock(&mylock)
/* Reentrant version of getmntent. */
-struct mntent attribute_hidden *__getmntent_r (FILE *filep,
+struct mntent *getmntent_r (FILE *filep,
struct mntent *mnt, char *buff, int bufsize)
{
char *cp, *ptrptr;
@@ -64,7 +78,7 @@ struct mntent attribute_hidden *__getmntent_r (FILE *filep,
return mnt;
}
-strong_alias(__getmntent_r,getmntent_r)
+libc_hidden_def(getmntent_r)
struct mntent *getmntent(FILE * filep)
{
@@ -79,7 +93,7 @@ struct mntent *getmntent(FILE * filep)
abort();
}
- tmp = __getmntent_r(filep, &mnt, buff, BUFSIZ);
+ tmp = getmntent_r(filep, &mnt, buff, BUFSIZ);
UNLOCK;
return(tmp);
}
@@ -101,16 +115,16 @@ char *hasmntopt(const struct mntent *mnt, const char *opt)
return strstr(mnt->mnt_opts, opt);
}
-FILE attribute_hidden *__setmntent(const char *name, const char *mode)
+FILE *setmntent(const char *name, const char *mode)
{
return fopen(name, mode);
}
-strong_alias(__setmntent,setmntent)
+libc_hidden_def(setmntent)
-int attribute_hidden __endmntent(FILE * filep)
+int endmntent(FILE * filep)
{
if (filep != NULL)
fclose(filep);
return 1;
}
-strong_alias(__endmntent,endmntent)
+libc_hidden_def(endmntent)
diff --git a/libc/misc/regex/Makefile.in b/libc/misc/regex/Makefile.in
index 9cd403add..4e76dee36 100644
--- a/libc/misc/regex/Makefile.in
+++ b/libc/misc/regex/Makefile.in
@@ -1,29 +1,26 @@
# Makefile for uClibc
#
# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
ifeq ($(UCLIBC_HAS_REGEX_OLD),y)
-CSRC:=regex_old.c
+CSRC := regex_old.c
else
-CSRC:=regex.c
+CSRC := regex.c
endif
-MISC_REGEX_DIR:=$(top_srcdir)libc/misc/regex
-MISC_REGEX_OUT:=$(top_builddir)libc/misc/regex
+MISC_REGEX_DIR := $(top_srcdir)libc/misc/regex
+MISC_REGEX_OUT := $(top_builddir)libc/misc/regex
-MISC_REGEX_SRC:=$(patsubst %.c,$(MISC_REGEX_DIR)/%.c,$(CSRC))
-MISC_REGEX_OBJ:=$(patsubst %.c,$(MISC_REGEX_OUT)/%.o,$(CSRC))
+MISC_REGEX_SRC := $(patsubst %.c,$(MISC_REGEX_DIR)/%.c,$(CSRC))
+MISC_REGEX_OBJ := $(patsubst %.c,$(MISC_REGEX_OUT)/%.o,$(CSRC))
-libc-a-$(UCLIBC_HAS_REGEX)+=$(MISC_REGEX_OBJ)
-libc-so-$(UCLIBC_HAS_REGEX)+=$(MISC_REGEX_OBJ:.o=.os)
+libc-$(UCLIBC_HAS_REGEX) += $(MISC_REGEX_OBJ)
-libc-multi-$(UCLIBC_HAS_REGEX)+=$(MISC_REGEX_SRC)
-
-objclean-y+=misc_regex_objclean
+objclean-y += misc_regex_objclean
misc_regex_objclean:
$(RM) $(MISC_REGEX_OUT)/*.{o,os}
diff --git a/libc/misc/regex/regcomp.c b/libc/misc/regex/regcomp.c
index 419d879be..8d464db2d 100644
--- a/libc/misc/regex/regcomp.c
+++ b/libc/misc/regex/regcomp.c
@@ -233,7 +233,7 @@ re_compile_pattern (pattern, length, bufp)
return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]);
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__re_compile_pattern, re_compile_pattern)
+strong_alias(__re_compile_pattern, re_compile_pattern)
#endif
/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can
@@ -261,7 +261,7 @@ re_set_syntax (syntax)
return ret;
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__re_set_syntax, re_set_syntax)
+strong_alias(__re_set_syntax, re_set_syntax)
#endif
int
@@ -283,7 +283,7 @@ re_compile_fastmap (bufp)
return 0;
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__re_compile_fastmap, re_compile_fastmap)
+strong_alias(__re_compile_fastmap, re_compile_fastmap)
#endif
static inline void
@@ -499,7 +499,7 @@ regcomp (preg, pattern, cflags)
return (int) ret;
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__regcomp, regcomp)
+strong_alias(__regcomp, regcomp)
#endif
/* Returns a message corresponding to an error code, ERRCODE, returned
@@ -546,7 +546,7 @@ regerror (errcode, preg, errbuf, errbuf_size)
return msg_size;
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__regerror, regerror)
+strong_alias(__regerror, regerror)
#endif
@@ -630,7 +630,7 @@ regfree (preg)
preg->translate = NULL;
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__regfree, regfree)
+strong_alias(__regfree, regfree)
#endif
/* Entry points compatible with 4.2 BSD regex library. We don't define
@@ -805,6 +805,10 @@ re_compile_internal (regex_t *preg, const char * pattern, size_t length,
/* Initialize DFA. We use the length of the regular expression PAT_LEN
as the initial length of some arrays. */
+#ifdef __UCLIBC_HAS_WCHAR__
+libc_hidden_proto(_stdlib_mb_cur_max)
+#endif
+
static reg_errcode_t
init_dfa (re_dfa_t *dfa, size_t pat_len)
{
@@ -834,9 +838,6 @@ init_dfa (re_dfa_t *dfa, size_t pat_len)
dfa->state_hash_mask = table_size - 1;
#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;
dfa->mb_cur_max = MB_CUR_MAX;
#else
dfa->mb_cur_max = 1;
@@ -1651,8 +1652,6 @@ calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, int node, int root)
&& dfa->edests[node].nelem
&& !dfa->nodes[dfa->edests[node].elems[0]].duplicated)
{
- int org_node, cur_node;
- org_node = cur_node = node;
err = duplicate_node_closure (dfa, node, node, node, constraint);
if (BE (err != REG_NOERROR, 0))
return err;
diff --git a/libc/misc/regex/regex.c b/libc/misc/regex/regex.c
index 99de9fd6c..77c09a011 100644
--- a/libc/misc/regex/regex.c
+++ b/libc/misc/regex/regex.c
@@ -28,48 +28,64 @@
#ifdef __UCLIBC__
#undef _LIBC
#define _REGEX_RE_COMP
+#define HAVE_MEMPCPY
+#define HAVE_LANGINFO
+#define HAVE_LANGINFO_CODESET
#include <stdbool.h>
#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
#ifdef __UCLIBC_HAS_WCHAR__
#define RE_ENABLE_I18N
-#define wcscoll __wcscoll
-#define wcrtomb __wcrtomb
-#define mbrtowc __mbrtowc
-#define iswctype __iswctype
-#define iswlower __iswlower
-#define iswalnum __iswalnum
-#define towlower __towlower
-#define towupper __towupper
-#define mbsinit __mbsinit
#include <wchar.h>
#include <wctype.h>
-/* attribute_hidden produces text relocation */
-//extern int __wcscoll (__const wchar_t *__s1, __const wchar_t *__s2) __THROW /*attribute_hidden*/;
+#define __iswctype iswctype
+#define __wcrtomb wcrtomb
+#define __btowc btowc
+#define __wctype wctype
+libc_hidden_proto(wcscoll)
+libc_hidden_proto(wcrtomb)
+libc_hidden_proto(mbrtowc)
+libc_hidden_proto(iswctype)
+libc_hidden_proto(iswlower)
+libc_hidden_proto(iswalnum)
+libc_hidden_proto(towlower)
+libc_hidden_proto(towupper)
+libc_hidden_proto(mbsinit)
+libc_hidden_proto(btowc)
+libc_hidden_proto(wctype)
-extern size_t __wcrtomb (char *__restrict __s, wchar_t __wc,
- mbstate_t *__restrict __ps) attribute_hidden;
-
-extern wint_t __btowc (int __c) attribute_hidden;
-
-extern wctype_t __wctype (__const char *__property) attribute_hidden;
+#endif
-//extern int __iswctype (wint_t __wc, wctype_t __desc) /*attribute_hidden*/;
+#include <ctype.h>
+#ifdef __UCLIBC_HAS_CTYPE_TABLES__
+#define __toupper toupper
+#define __tolower tolower
+#endif
+#define __mempcpy mempcpy
+#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_b_loc)
+libc_hidden_proto(__ctype_toupper_loc)
+#else
+libc_hidden_proto(__ctype_b)
+libc_hidden_proto(__ctype_toupper)
#endif
+libc_hidden_proto(toupper)
+libc_hidden_proto(tolower)
+libc_hidden_proto(memcmp)
+libc_hidden_proto(memcpy)
+libc_hidden_proto(memmove)
+libc_hidden_proto(memset)
+libc_hidden_proto(strchr)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strlen)
+libc_hidden_proto(strncpy)
+libc_hidden_proto(getenv)
+libc_hidden_proto(strcasecmp)
+libc_hidden_proto(mempcpy)
+libc_hidden_proto(abort)
-#define memcmp __memcmp
-#define memcpy __memcpy
-#define memmove __memmove
-#define memset __memset
-#define strchr __strchr
-#define strcmp __strcmp
-#define strlen __strlen
-#define strncpy __strncpy
-#define getenv __getenv
-#define strcasecmp __strcasecmp
-
-extern void *__mempcpy (void *__restrict __dest,
- __const void *__restrict __src, size_t __n) attribute_hidden;
#endif
/* Make sure noone compiles this code with a C++ compiler. */
diff --git a/libc/misc/regex/regex_internal.c b/libc/misc/regex/regex_internal.c
index c1ee85040..3fc62d731 100644
--- a/libc/misc/regex/regex_internal.c
+++ b/libc/misc/regex/regex_internal.c
@@ -195,7 +195,7 @@ static void
internal_function
build_wcs_buffer (re_string_t *pstr)
{
-#ifdef _LIBC
+#if defined _LIBC || defined __UCLIBC__
unsigned char buf[MB_LEN_MAX];
assert (MB_LEN_MAX >= pstr->mb_cur_max);
#else
@@ -266,7 +266,7 @@ build_wcs_upper_buffer (re_string_t *pstr)
mbstate_t prev_st;
int src_idx, byte_idx, end_idx, remain_len;
size_t mbclen;
-#ifdef _LIBC
+#if defined _LIBC || defined __UCLIBC__
char buf[MB_LEN_MAX];
assert (MB_LEN_MAX >= pstr->mb_cur_max);
#else
@@ -882,8 +882,9 @@ re_node_set_alloc (re_node_set *set, int size)
{
set->alloc = size;
set->nelem = 0;
- set->elems = re_malloc (int, size);
- if (BE (set->elems == NULL, 0))
+ set->elems = re_malloc (int, size); /* can be NULL if size == 0
+ (see re_node_set_init_empty(set)) */
+ if (BE (set->elems == NULL && size != 0, 0))
return REG_ESPACE;
return REG_NOERROR;
}
diff --git a/libc/misc/regex/regex_internal.h b/libc/misc/regex/regex_internal.h
index 4782883c1..d82cf6d42 100644
--- a/libc/misc/regex/regex_internal.h
+++ b/libc/misc/regex/regex_internal.h
@@ -29,6 +29,7 @@
#if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET || defined _LIBC
# include <langinfo.h>
+libc_hidden_proto(nl_langinfo)
#endif
#if defined HAVE_LOCALE_H || defined _LIBC
# include <locale.h>
@@ -52,7 +53,7 @@
#endif
/* In case that the system doesn't have isblank(). */
-#if !defined _LIBC && !defined HAVE_ISBLANK && !defined isblank
+#if !defined _LIBC && !defined HAVE_ISBLANK && !defined isblank && !defined __UCLIBC__
# define isblank(ch) ((ch) == ' ' || (ch) == '\t')
#endif
diff --git a/libc/misc/regex/regex_old.c b/libc/misc/regex/regex_old.c
index 9031cebff..29640734d 100644
--- a/libc/misc/regex/regex_old.c
+++ b/libc/misc/regex/regex_old.c
@@ -20,46 +20,35 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define HAVE_MEMPCPY
-#define memset __memset
-#define memcmp __memcmp
-#define strcmp __strcmp
-#define strlen __strlen
-#define wcslen __wcslen
-/* for some reason this does not work */
-#define memcpy __memcpy
-#define mbrtowc __mbrtowc
-#define wcrtomb __wcrtomb
-#define wcscoll __wcscoll
-#define wctype __wctype
-#define iswctype __iswctype
-#define iswalnum __iswalnum
-#define printf __printf
-#define btowc __btowc
-
/* To exclude some unwanted junk.... */
#undef emacs
-#define _REGEX_RE_COMP
#include <features.h>
#ifdef __UCLIBC__
# undef _LIBC
+# define _REGEX_RE_COMP
+# define HAVE_MEMPCPY
+# define STDC_HEADERS
+# define RE_TRANSLATE_TYPE char *
#endif
#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
-#define STDC_HEADERS
-#define RE_TRANSLATE_TYPE char *
+#include <stdio.h>
-extern void *__mempcpy (void *__restrict __dest,
- __const void *__restrict __src, size_t __n) /*attribute_hidden*/;
+libc_hidden_proto(memset)
+libc_hidden_proto(memcmp)
+libc_hidden_proto(memcpy)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strlen)
+libc_hidden_proto(printf)
+libc_hidden_proto(mempcpy)
+libc_hidden_proto(abort)
/* AIX requires this to be the first thing in the file. */
#if defined _AIX && !defined REGEX_MALLOC
#pragma alloca
#endif
-#undef _GNU_SOURCE
-#define _GNU_SOURCE
-
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
@@ -89,6 +78,15 @@ extern void *__mempcpy (void *__restrict __dest,
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
# include <wchar.h>
# include <wctype.h>
+libc_hidden_proto(wcslen)
+libc_hidden_proto(mbrtowc)
+libc_hidden_proto(wcrtomb)
+libc_hidden_proto(wcscoll)
+libc_hidden_proto(wctype)
+libc_hidden_proto(iswctype)
+libc_hidden_proto(iswalnum)
+libc_hidden_proto(btowc)
+
# endif
# if defined _LIBC || defined __UCLIBC__
@@ -113,10 +111,10 @@ extern void *__mempcpy (void *__restrict __dest,
__re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
# define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
+# ifndef __UCLIBC__
# define btowc __btowc
/* We are also using some library internals. */
-# ifndef __UCLIBC__
# include <locale/localeinfo.h>
# include <locale/elem-hash.h>
# include <langinfo.h>
@@ -334,7 +332,7 @@ init_syntax_once ()
# endif /* emacs */
/* Integer type for pointers. */
-# if !defined _LIBC
+# if !defined _LIBC && !defined __intptr_t_defined
typedef unsigned long int uintptr_t;
# endif
@@ -1389,7 +1387,7 @@ re_set_syntax (syntax)
return ret;
}
# if defined _LIBC || defined __UCLIBC__
-weak_alias (__re_set_syntax, re_set_syntax)
+strong_alias(__re_set_syntax, re_set_syntax)
# endif
/* This table gives an error message for each of the error codes listed
@@ -3315,11 +3313,15 @@ PREFIX(regex_compile) (ARG_PREFIX(pattern), ARG_PREFIX(size), syntax, bufp)
PATFETCH (c);
if ((c == ':' && *p == ']') || p == pend)
break;
+#if CHAR_CLASS_MAX_LENGTH != 256
if (c1 < CHAR_CLASS_MAX_LENGTH)
str[c1++] = c;
else
/* This is in any case an invalid class name. */
str[0] = '\0';
+#else
+ str[c1++] = c;
+#endif
}
str[c1] = '\0';
@@ -5009,7 +5011,7 @@ re_compile_fastmap (bufp)
return byte_re_compile_fastmap(bufp);
} /* re_compile_fastmap */
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__re_compile_fastmap, re_compile_fastmap)
+strong_alias(__re_compile_fastmap, re_compile_fastmap)
#endif
@@ -5048,7 +5050,7 @@ re_set_registers (bufp, regs, num_regs, starts, ends)
}
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__re_set_registers, re_set_registers)
+strong_alias(__re_set_registers, re_set_registers)
#endif
/* Searching routines. */
@@ -5067,7 +5069,7 @@ re_search (bufp, string, size, startpos, range, regs)
regs, size);
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__re_search, re_search)
+strong_alias(__re_search, re_search)
#endif
@@ -5112,7 +5114,7 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
range, regs, stop);
} /* re_search_2 */
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__re_search_2, re_search_2)
+strong_alias(__re_search_2, re_search_2)
#endif
#endif /* not INSIDE_RECURSION */
@@ -5571,7 +5573,7 @@ re_match (bufp, string, size, pos, regs)
return result;
}
# if defined _LIBC || defined __UCLIBC__
-weak_alias (__re_match, re_match)
+strong_alias(__re_match, re_match)
# endif
#endif /* not emacs */
@@ -5632,7 +5634,7 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
return result;
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__re_match_2, re_match_2)
+strong_alias(__re_match_2, re_match_2)
#endif
#endif /* not INSIDE_RECURSION */
@@ -7971,7 +7973,7 @@ re_compile_pattern (pattern, length, bufp)
return gettext (re_error_msgid + re_error_msgid_idx[(int) ret]);
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__re_compile_pattern, re_compile_pattern)
+strong_alias(__re_compile_pattern, re_compile_pattern)
#endif
/* Entry points compatible with 4.2 BSD regex library. We don't define
@@ -8167,7 +8169,7 @@ regcomp (preg, pattern, cflags)
return (int) ret;
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__regcomp, regcomp)
+strong_alias(__regcomp, regcomp)
#endif
@@ -8245,7 +8247,7 @@ regexec (preg, string, nmatch, pmatch, eflags)
return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH;
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__regexec, regexec)
+strong_alias(__regexec, regexec)
#endif
@@ -8280,7 +8282,7 @@ regerror (errcode, preg, errbuf, errbuf_size)
if (msg_size > errbuf_size)
{
#if defined HAVE_MEMPCPY || defined _LIBC
- *((char *) __mempcpy (errbuf, msg, errbuf_size - 1)) = '\0';
+ *((char *) mempcpy (errbuf, msg, errbuf_size - 1)) = '\0';
#else
memcpy (errbuf, msg, errbuf_size - 1);
errbuf[errbuf_size - 1] = 0;
@@ -8293,7 +8295,7 @@ regerror (errcode, preg, errbuf, errbuf_size)
return msg_size;
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__regerror, regerror)
+strong_alias(__regerror, regerror)
#endif
@@ -8320,7 +8322,7 @@ regfree (preg)
preg->translate = NULL;
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__regfree, regfree)
+strong_alias(__regfree, regfree)
#endif
#endif /* not emacs */
diff --git a/libc/misc/regex/regexec.c b/libc/misc/regex/regexec.c
index e8e2946b4..c56fb9d4a 100644
--- a/libc/misc/regex/regexec.c
+++ b/libc/misc/regex/regexec.c
@@ -275,7 +275,7 @@ __compat_regexec (const regex_t *__restrict preg,
compat_symbol (libc, __compat_regexec, regexec, GLIBC_2_0);
# endif
#elif __UCLIBC__
-weak_alias(__regexec,regexec)
+strong_alias(__regexec,regexec)
#endif
/* Entry points for GNU code. */
@@ -317,7 +317,7 @@ re_match (bufp, string, length, start, regs)
return re_search_stub (bufp, string, length, start, 0, length, regs, 1);
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__re_match, re_match)
+strong_alias(__re_match, re_match)
#endif
int
@@ -330,7 +330,7 @@ re_search (bufp, string, length, start, range, regs)
return re_search_stub (bufp, string, length, start, range, length, regs, 0);
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__re_search, re_search)
+strong_alias(__re_search, re_search)
#endif
int
@@ -344,7 +344,7 @@ re_match_2 (bufp, string1, length1, string2, length2, start, regs, stop)
start, 0, regs, stop, 1);
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__re_match_2, re_match_2)
+strong_alias(__re_match_2, re_match_2)
#endif
int
@@ -358,7 +358,7 @@ re_search_2 (bufp, string1, length1, string2, length2, start, range, regs, stop)
start, range, regs, stop, 0);
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__re_search_2, re_search_2)
+strong_alias(__re_search_2, re_search_2)
#endif
static int
@@ -593,7 +593,7 @@ re_set_registers (bufp, regs, num_regs, starts, ends)
}
}
#if defined _LIBC || defined __UCLIBC__
-weak_alias (__re_set_registers, re_set_registers)
+strong_alias(__re_set_registers, re_set_registers)
#endif
/* Entry points compatible with 4.2 BSD regex library. We don't define
diff --git a/libc/misc/search/Makefile.in b/libc/misc/search/Makefile.in
index 943ef34d0..80fafbf6c 100644
--- a/libc/misc/search/Makefile.in
+++ b/libc/misc/search/Makefile.in
@@ -1,77 +1,34 @@
# Makefile for uClibc
#
# Copyright (C) 2000 by Lineo, inc.
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-MSRC1:=tsearch.c
-MOBJ1:=tsearch.o tfind.o tdelete.o twalk.o tdestroy.o
+CSRC := hsearch.c
-MSRC2:=lsearch.c
-MOBJ2:=lfind.o lsearch.o
+# multi source _tsearch.c
+CSRC += tsearch.c tfind.c tdelete.c twalk.c tdestroy.c
-MSRC3:=insremque.c
-MOBJ3:=insque.o remque.o
+# multi source _lsearch.c
+CSRC += lfind.c lsearch.c
-MSRC4:=hsearch_r.c
-MOBJ4:=hcreate_r.o hdestroy_r.o hsearch_r.o
+# multi source insremque.c
+CSRC += insque.c remque.c
-CSRC:=hsearch.c
+# multi source _hsearch_r.c
+CSRC += hcreate_r.c hdestroy_r.c hsearch_r.c
-MISC_SEARCH_DIR:=$(top_srcdir)libc/misc/search
-MISC_SEARCH_OUT:=$(top_builddir)libc/misc/search
+MISC_SEARCH_DIR := $(top_srcdir)libc/misc/search
+MISC_SEARCH_OUT := $(top_builddir)libc/misc/search
-MISC_SEARCH_SRC:=$(patsubst %.c,$(MISC_SEARCH_DIR)/%.c,$(CSRC))
-MISC_SEARCH_OBJ:=$(patsubst %.c,$(MISC_SEARCH_OUT)/%.o,$(CSRC))
+MISC_SEARCH_SRC := $(patsubst %.c,$(MISC_SEARCH_DIR)/%.c,$(CSRC))
+MISC_SEARCH_OBJ := $(patsubst %.c,$(MISC_SEARCH_OUT)/%.o,$(CSRC))
-MISC_SEARCH_MSRC1:=$(MISC_SEARCH_DIR)/$(MSRC1)
-MISC_SEARCH_MSRC2:=$(MISC_SEARCH_DIR)/$(MSRC2)
-MISC_SEARCH_MSRC3:=$(MISC_SEARCH_DIR)/$(MSRC3)
-MISC_SEARCH_MSRC4:=$(MISC_SEARCH_DIR)/$(MSRC4)
-MISC_SEARCH_MOBJ1:=$(patsubst %.o,$(MISC_SEARCH_OUT)/%.o,$(MOBJ1))
-MISC_SEARCH_MOBJ2:=$(patsubst %.o,$(MISC_SEARCH_OUT)/%.o,$(MOBJ2))
-MISC_SEARCH_MOBJ3:=$(patsubst %.o,$(MISC_SEARCH_OUT)/%.o,$(MOBJ3))
-MISC_SEARCH_MOBJ4:=$(patsubst %.o,$(MISC_SEARCH_OUT)/%.o,$(MOBJ4))
+libc-y += $(MISC_SEARCH_OBJ)
-MISC_SEARCH_MSRC:=$(MISC_SEARCH_MSRC1) $(MISC_SEARCH_MSRC2) $(MISC_SEARCH_MSRC3) $(MISC_SEARCH_MSRC4)
-MISC_SEARCH_MOBJ:=$(MISC_SEARCH_MOBJ1) $(MISC_SEARCH_MOBJ2) $(MISC_SEARCH_MOBJ3) $(MISC_SEARCH_MOBJ4)
-MISC_SEARCH_DEF:=$(patsubst %,-DL_%,$(subst .o,,$(notdir $(MISC_SEARCH_MOBJ))))
-
-MISC_SEARCH_OBJS:=$(MISC_SEARCH_OBJ) $(MISC_SEARCH_MOBJ)
-
-$(MISC_SEARCH_MOBJ1): $(MISC_SEARCH_MSRC1)
- $(compile.m)
-
-$(MISC_SEARCH_MOBJ1:.o=.os): $(MISC_SEARCH_MSRC1)
- $(compile.m)
-
-$(MISC_SEARCH_MOBJ2): $(MISC_SEARCH_MSRC2)
- $(compile.m)
-
-$(MISC_SEARCH_MOBJ2:.o=.os): $(MISC_SEARCH_MSRC2)
- $(compile.m)
-
-$(MISC_SEARCH_MOBJ3): $(MISC_SEARCH_MSRC3)
- $(compile.m)
-
-$(MISC_SEARCH_MOBJ3:.o=.os): $(MISC_SEARCH_MSRC3)
- $(compile.m)
-
-$(MISC_SEARCH_MOBJ4): $(MISC_SEARCH_MSRC4)
- $(compile.m)
-
-$(MISC_SEARCH_MOBJ4:.o=.os): $(MISC_SEARCH_MSRC4)
- $(compile.m)
-
-libc-a-y+=$(MISC_SEARCH_OBJS)
-libc-so-y+=$(MISC_SEARCH_OBJS:.o=.os)
-
-CFLAGS-multi-y+=$(MISC_SEARCH_DEF)
-libc-multi-y+=$(MISC_SEARCH_SRC) $(MISC_SEARCH_MSRC)
-
-objclean-y+=misc_search_objclean
+objclean-y += misc_search_objclean
misc_search_objclean:
$(RM) $(MISC_SEARCH_OUT)/*.{o,os}
diff --git a/libc/misc/search/_hsearch_r.c b/libc/misc/search/_hsearch_r.c
new file mode 100644
index 000000000..a1cdbb681
--- /dev/null
+++ b/libc/misc/search/_hsearch_r.c
@@ -0,0 +1,232 @@
+/* Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1993.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <malloc.h>
+#include <string.h>
+
+#include <search.h>
+
+
+/* [Aho,Sethi,Ullman] Compilers: Principles, Techniques and Tools, 1986
+ [Knuth] The Art of Computer Programming, part 3 (6.4) */
+
+
+/* The reentrant version has no static variables to maintain the state.
+ Instead the interface of all functions is extended to take an argument
+ which describes the current status. */
+typedef struct _ENTRY
+{
+ unsigned int used;
+ ENTRY entry;
+}
+_ENTRY;
+
+
+#ifdef L_hcreate_r
+
+/* For the used double hash method the table size has to be a prime. To
+ correct the user given table size we need a prime test. This trivial
+ algorithm is adequate because
+ a) the code is (most probably) called a few times per program run and
+ b) the number is small because the table must fit in the core */
+static int isprime (unsigned int number)
+{
+ /* no even number will be passed */
+ unsigned int div = 3;
+
+ while (div * div < number && number % div != 0)
+ div += 2;
+
+ return number % div != 0;
+}
+
+
+/* Before using the hash table we must allocate memory for it.
+ Test for an existing table are done. We allocate one element
+ more as the found prime number says. This is done for more effective
+ indexing as explained in the comment for the hsearch function.
+ The contents of the table is zeroed, especially the field used
+ becomes zero. */
+libc_hidden_proto(hcreate_r)
+int hcreate_r (size_t nel, struct hsearch_data *htab)
+{
+ /* Test for correct arguments. */
+ if (htab == NULL)
+ {
+ __set_errno (EINVAL);
+ return 0;
+ }
+
+ /* There is still another table active. Return with error. */
+ if (htab->table != NULL)
+ return 0;
+
+ /* Change nel to the first prime number not smaller as nel. */
+ nel |= 1; /* make odd */
+ while (!isprime (nel))
+ nel += 2;
+
+ htab->size = nel;
+ htab->filled = 0;
+
+ /* allocate memory and zero out */
+ htab->table = (_ENTRY *) calloc (htab->size + 1, sizeof (_ENTRY));
+ if (htab->table == NULL)
+ return 0;
+
+ /* everything went alright */
+ return 1;
+}
+libc_hidden_def(hcreate_r)
+#endif
+
+#ifdef L_hdestroy_r
+/* After using the hash table it has to be destroyed. The used memory can
+ be freed and the local static variable can be marked as not used. */
+libc_hidden_proto(hdestroy_r)
+void hdestroy_r (struct hsearch_data *htab)
+{
+ /* Test for correct arguments. */
+ if (htab == NULL)
+ {
+ __set_errno (EINVAL);
+ return;
+ }
+
+ if (htab->table != NULL)
+ /* free used memory */
+ free (htab->table);
+
+ /* the sign for an existing table is an value != NULL in htable */
+ htab->table = NULL;
+}
+libc_hidden_def(hdestroy_r)
+#endif
+
+#ifdef L_hsearch_r
+/* This is the search function. It uses double hashing with open addressing.
+ The argument item.key has to be a pointer to an zero terminated, most
+ probably strings of chars. The function for generating a number of the
+ strings is simple but fast. It can be replaced by a more complex function
+ like ajw (see [Aho,Sethi,Ullman]) if the needs are shown.
+
+ We use an trick to speed up the lookup. The table is created by hcreate
+ with one more element available. This enables us to use the index zero
+ special. This index will never be used because we store the first hash
+ index in the field used where zero means not used. Every other value
+ means used. The used field can be used as a first fast comparison for
+ equality of the stored and the parameter value. This helps to prevent
+ unnecessary expensive calls of strcmp. */
+
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strlen)
+
+libc_hidden_proto(hsearch_r)
+int hsearch_r (ENTRY item, ACTION action, ENTRY **retval,
+ struct hsearch_data *htab)
+{
+ unsigned int hval;
+ unsigned int count;
+ unsigned int len = strlen (item.key);
+ unsigned int idx;
+
+ /* Compute an value for the given string. Perhaps use a better method. */
+ hval = len;
+ count = len;
+ while (count-- > 0)
+ {
+ hval <<= 4;
+ hval += item.key[count];
+ }
+
+ /* First hash function: simply take the modul but prevent zero. */
+ hval %= htab->size;
+ if (hval == 0)
+ ++hval;
+
+ /* The first index tried. */
+ idx = hval;
+
+ if (htab->table[idx].used)
+ {
+ /* Further action might be required according to the action value. */
+ unsigned hval2;
+
+ if (htab->table[idx].used == hval
+ && strcmp (item.key, htab->table[idx].entry.key) == 0)
+ {
+ *retval = &htab->table[idx].entry;
+ return 1;
+ }
+
+ /* Second hash function, as suggested in [Knuth] */
+ hval2 = 1 + hval % (htab->size - 2);
+
+ do
+ {
+ /* Because SIZE is prime this guarantees to step through all
+ available indeces. */
+ if (idx <= hval2)
+ idx = htab->size + idx - hval2;
+ else
+ idx -= hval2;
+
+ /* If we visited all entries leave the loop unsuccessfully. */
+ if (idx == hval)
+ break;
+
+ /* If entry is found use it. */
+ if (htab->table[idx].used == hval
+ && strcmp (item.key, htab->table[idx].entry.key) == 0)
+ {
+ *retval = &htab->table[idx].entry;
+ return 1;
+ }
+ }
+ while (htab->table[idx].used);
+ }
+
+ /* An empty bucket has been found. */
+ if (action == ENTER)
+ {
+ /* If table is full and another entry should be entered return
+ with error. */
+ if (htab->filled == htab->size)
+ {
+ __set_errno (ENOMEM);
+ *retval = NULL;
+ return 0;
+ }
+
+ htab->table[idx].used = hval;
+ htab->table[idx].entry = item;
+
+ ++htab->filled;
+
+ *retval = &htab->table[idx].entry;
+ return 1;
+ }
+
+ __set_errno (ESRCH);
+ *retval = NULL;
+ return 0;
+}
+libc_hidden_def(hsearch_r)
+#endif
diff --git a/libc/misc/search/_lsearch.c b/libc/misc/search/_lsearch.c
new file mode 100644
index 000000000..eefef2121
--- /dev/null
+++ b/libc/misc/search/_lsearch.c
@@ -0,0 +1,51 @@
+/*
+ * This file lifted in toto from 'Dlibs' on the atari ST (RdeBath)
+ *
+ *
+ * Dale Schumacher 399 Beacon Ave.
+ * (alias: Dalnefre') St. Paul, MN 55104
+ * dal@syntel.UUCP United States of America
+ * "It's not reality that's important, but how you perceive things."
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <search.h>
+
+libc_hidden_proto(lfind)
+
+#ifdef L_lfind
+
+void *lfind(const void *key, const void *base, size_t *nmemb,
+ size_t size, int (*compar)(const void *, const void *))
+{
+ register int n = *nmemb;
+
+ while (n--) {
+ if ((*compar) (base, key) == 0)
+ return ((void*)base);
+ base += size;
+ }
+ return (NULL);
+}
+libc_hidden_def(lfind)
+
+#endif
+
+#ifdef L_lsearch
+
+libc_hidden_proto(memcpy)
+
+void *lsearch(const void *key, void *base, size_t *nmemb,
+ size_t size, int (*compar)(const void *, const void *))
+{
+ register char *p;
+
+ if ((p = lfind(key, base, nmemb, size, compar)) == NULL) {
+ p = memcpy((base + (size * (*nmemb))), key, size);
+ ++(*nmemb);
+ }
+ return (p);
+}
+
+#endif
diff --git a/libc/misc/search/_tsearch.c b/libc/misc/search/_tsearch.c
new file mode 100644
index 000000000..989710e08
--- /dev/null
+++ b/libc/misc/search/_tsearch.c
@@ -0,0 +1,223 @@
+/* Copyright (C) 1994 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA. */
+
+/*
+ * Tree search generalized from Knuth (6.2.2) Algorithm T just like
+ * the AT&T man page says.
+ *
+ * The node_t structure is for internal use only, lint doesn't grok it.
+ *
+ * Written by reading the System V Interface Definition, not the code.
+ *
+ * Totally public domain.
+ */
+/*LINTLIBRARY*/
+
+#include <search.h>
+#include <stdlib.h>
+
+/* This routine is not very bad. It makes many assumptions about
+ * the compiler. It assumpts that the first field in node must be
+ * the "key" field, which points to the datum. It is a very trick
+ * stuff. H.J.
+ */
+
+typedef struct node_t
+{
+ void *key;
+ struct node_t *left, *right;
+} node;
+
+#ifdef L_tsearch
+/* find or insert datum into search tree.
+char *key; key to be located
+register node **rootp; address of tree root
+int (*compar)(); ordering function
+*/
+
+libc_hidden_proto(tsearch)
+void *tsearch(__const void *key, void **vrootp, __compar_fn_t compar)
+{
+ register node *q;
+ register node **rootp = (node **) vrootp;
+
+ if (rootp == (struct node_t **)0)
+ return ((struct node_t *)0);
+ while (*rootp != (struct node_t *)0) /* Knuth's T1: */
+ {
+ int r;
+
+ if ((r = (*compar)(key, (*rootp)->key)) == 0) /* T2: */
+ return (*rootp); /* we found it! */
+ rootp = (r < 0) ?
+ &(*rootp)->left : /* T3: follow left branch */
+ &(*rootp)->right; /* T4: follow right branch */
+ }
+ q = (node *) malloc(sizeof(node)); /* T5: key not found */
+ if (q != (struct node_t *)0) /* make new node */
+ {
+ *rootp = q; /* link new node to old */
+ q->key = (void *)key; /* initialize new node */
+ q->left = q->right = (struct node_t *)0;
+ }
+ return (q);
+}
+libc_hidden_def(tsearch)
+#endif
+
+#ifdef L_tfind
+libc_hidden_proto(tfind)
+void *tfind(__const void *key, void * __const *vrootp, __compar_fn_t compar)
+{
+ register node **rootp = (node **) vrootp;
+
+ if (rootp == (struct node_t **)0)
+ return ((struct node_t *)0);
+ while (*rootp != (struct node_t *)0) /* Knuth's T1: */
+ {
+ int r;
+
+ if ((r = (*compar)(key, (*rootp)->key)) == 0) /* T2: */
+ return (*rootp); /* we found it! */
+ rootp = (r < 0) ?
+ &(*rootp)->left : /* T3: follow left branch */
+ &(*rootp)->right; /* T4: follow right branch */
+ }
+ return NULL;
+}
+libc_hidden_def(tfind)
+#endif
+
+#ifdef L_tdelete
+/* delete node with given key
+char *key; key to be deleted
+register node **rootp; address of the root of tree
+int (*compar)(); comparison function
+*/
+void *tdelete(__const void *key, void ** vrootp, __compar_fn_t compar)
+{
+ node *p;
+ register node *q;
+ register node *r;
+ int cmp;
+ register node **rootp = (node **) vrootp;
+
+ if (rootp == (struct node_t **)0 || (p = *rootp) == (struct node_t *)0)
+ return ((struct node_t *)0);
+ while ((cmp = (*compar)(key, (*rootp)->key)) != 0)
+ {
+ p = *rootp;
+ rootp = (cmp < 0) ?
+ &(*rootp)->left : /* follow left branch */
+ &(*rootp)->right; /* follow right branch */
+ if (*rootp == (struct node_t *)0)
+ return ((struct node_t *)0); /* key not found */
+ }
+ r = (*rootp)->right; /* D1: */
+ if ((q = (*rootp)->left) == (struct node_t *)0) /* Left (struct node_t *)0? */
+ q = r;
+ else if (r != (struct node_t *)0) /* Right link is null? */
+ {
+ if (r->left == (struct node_t *)0) /* D2: Find successor */
+ {
+ r->left = q;
+ q = r;
+ }
+ else
+ { /* D3: Find (struct node_t *)0 link */
+ for (q = r->left; q->left != (struct node_t *)0; q = r->left)
+ r = q;
+ r->left = q->right;
+ q->left = (*rootp)->left;
+ q->right = (*rootp)->right;
+ }
+ }
+ free((struct node_t *) *rootp); /* D4: Free node */
+ *rootp = q; /* link parent to new node */
+ return(p);
+}
+#endif
+
+#ifdef L_twalk
+/* Walk the nodes of a tree
+register node *root; Root of the tree to be walked
+register void (*action)(); Function to be called at each node
+register int level;
+*/
+static void trecurse(__const void *vroot, __action_fn_t action, int level)
+{
+ register node *root = (node *) vroot;
+
+ if (root->left == (struct node_t *)0 && root->right == (struct node_t *)0)
+ (*action)(root, leaf, level);
+ else
+ {
+ (*action)(root, preorder, level);
+ if (root->left != (struct node_t *)0)
+ trecurse(root->left, action, level + 1);
+ (*action)(root, postorder, level);
+ if (root->right != (struct node_t *)0)
+ trecurse(root->right, action, level + 1);
+ (*action)(root, endorder, level);
+ }
+}
+
+/* void twalk(root, action) Walk the nodes of a tree
+node *root; Root of the tree to be walked
+void (*action)(); Function to be called at each node
+PTR
+*/
+void twalk(__const void *vroot, __action_fn_t action)
+{
+ register __const node *root = (node *) vroot;
+
+ if (root != (node *)0 && action != (__action_fn_t) 0)
+ trecurse(root, action, 0);
+}
+#endif
+
+#ifdef __USE_GNU
+#ifdef L_tdestroy
+/* The standardized functions miss an important functionality: the
+ tree cannot be removed easily. We provide a function to do this. */
+static void
+internal_function
+tdestroy_recurse (node *root, __free_fn_t freefct)
+{
+ if (root->left != NULL)
+ tdestroy_recurse (root->left, freefct);
+ if (root->right != NULL)
+ tdestroy_recurse (root->right, freefct);
+ (*freefct) ((void *) root->key);
+ /* Free the node itself. */
+ free (root);
+}
+
+libc_hidden_proto(tdestroy)
+void tdestroy (void *vroot, __free_fn_t freefct)
+{
+ node *root = (node *) vroot;
+ if (root != NULL) {
+ tdestroy_recurse (root, freefct);
+ }
+}
+libc_hidden_def(tdestroy)
+#endif
+#endif
+
+/* tsearch.c ends here */
diff --git a/libc/misc/search/hcreate_r.c b/libc/misc/search/hcreate_r.c
new file mode 100644
index 000000000..b62991e46
--- /dev/null
+++ b/libc/misc/search/hcreate_r.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_hcreate_r
+#include "_hsearch_r.c"
diff --git a/libc/misc/search/hdestroy_r.c b/libc/misc/search/hdestroy_r.c
new file mode 100644
index 000000000..98e1ddbe7
--- /dev/null
+++ b/libc/misc/search/hdestroy_r.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_hdestroy_r
+#include "_hsearch_r.c"
diff --git a/libc/misc/search/hsearch.c b/libc/misc/search/hsearch.c
index a9400f3ca..b1228e2ee 100644
--- a/libc/misc/search/hsearch.c
+++ b/libc/misc/search/hsearch.c
@@ -17,16 +17,12 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define hdestroy_r __hdestroy_r
-#define hsearch_r __hsearch_r
-#define hcreate_r __hcreate_r
-
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
#include <search.h>
+libc_hidden_proto(hdestroy_r)
+libc_hidden_proto(hsearch_r)
+libc_hidden_proto(hcreate_r)
+
/* The non-reentrant version use a global space for storing the table. */
static struct hsearch_data htab;
@@ -53,7 +49,6 @@ void hdestroy (void)
{
hdestroy_r (&htab);
}
-/* weak_alias (__hdestroy, hdestroy) */
/* Make sure the table is freed if we want to free everything before
exiting. */
diff --git a/libc/misc/search/hsearch_r.c b/libc/misc/search/hsearch_r.c
index d297b3280..48bdf2d61 100644
--- a/libc/misc/search/hsearch_r.c
+++ b/libc/misc/search/hsearch_r.c
@@ -1,228 +1,8 @@
-/* Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1993.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
-
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-#include <errno.h>
-#include <malloc.h>
-#include <string.h>
-
-#include <search.h>
-
-/* [Aho,Sethi,Ullman] Compilers: Principles, Techniques and Tools, 1986
- [Knuth] The Art of Computer Programming, part 3 (6.4) */
-
-
-/* The reentrant version has no static variables to maintain the state.
- Instead the interface of all functions is extended to take an argument
- which describes the current status. */
-typedef struct _ENTRY
-{
- unsigned int used;
- ENTRY entry;
-}
-_ENTRY;
-
-
-#ifdef L_hcreate_r
-
-/* For the used double hash method the table size has to be a prime. To
- correct the user given table size we need a prime test. This trivial
- algorithm is adequate because
- a) the code is (most probably) called a few times per program run and
- b) the number is small because the table must fit in the core */
-static int isprime (unsigned int number)
-{
- /* no even number will be passed */
- unsigned int div = 3;
-
- while (div * div < number && number % div != 0)
- div += 2;
-
- return number % div != 0;
-}
-
-
-/* Before using the hash table we must allocate memory for it.
- Test for an existing table are done. We allocate one element
- more as the found prime number says. This is done for more effective
- indexing as explained in the comment for the hsearch function.
- The contents of the table is zeroed, especially the field used
- becomes zero. */
-int attribute_hidden __hcreate_r (size_t nel, struct hsearch_data *htab)
-{
- /* Test for correct arguments. */
- if (htab == NULL)
- {
- __set_errno (EINVAL);
- return 0;
- }
-
- /* There is still another table active. Return with error. */
- if (htab->table != NULL)
- return 0;
-
- /* Change nel to the first prime number not smaller as nel. */
- nel |= 1; /* make odd */
- while (!isprime (nel))
- nel += 2;
-
- htab->size = nel;
- htab->filled = 0;
-
- /* allocate memory and zero out */
- htab->table = (_ENTRY *) calloc (htab->size + 1, sizeof (_ENTRY));
- if (htab->table == NULL)
- return 0;
-
- /* everything went alright */
- return 1;
-}
-strong_alias(__hcreate_r,hcreate_r)
-#endif
-
-#ifdef L_hdestroy_r
-/* After using the hash table it has to be destroyed. The used memory can
- be freed and the local static variable can be marked as not used. */
-void attribute_hidden __hdestroy_r (struct hsearch_data *htab)
-{
- /* Test for correct arguments. */
- if (htab == NULL)
- {
- __set_errno (EINVAL);
- return;
- }
-
- if (htab->table != NULL)
- /* free used memory */
- free (htab->table);
-
- /* the sign for an existing table is an value != NULL in htable */
- htab->table = NULL;
-}
-strong_alias(__hdestroy_r,hdestroy_r)
-#endif
-
-#ifdef L_hsearch_r
-/* This is the search function. It uses double hashing with open addressing.
- The argument item.key has to be a pointer to an zero terminated, most
- probably strings of chars. The function for generating a number of the
- strings is simple but fast. It can be replaced by a more complex function
- like ajw (see [Aho,Sethi,Ullman]) if the needs are shown.
-
- We use an trick to speed up the lookup. The table is created by hcreate
- with one more element available. This enables us to use the index zero
- special. This index will never be used because we store the first hash
- index in the field used where zero means not used. Every other value
- means used. The used field can be used as a first fast comparison for
- equality of the stored and the parameter value. This helps to prevent
- unnecessary expensive calls of strcmp. */
-int attribute_hidden __hsearch_r (ENTRY item, ACTION action, ENTRY **retval,
- struct hsearch_data *htab)
-{
- unsigned int hval;
- unsigned int count;
- unsigned int len = __strlen (item.key);
- unsigned int idx;
-
- /* Compute an value for the given string. Perhaps use a better method. */
- hval = len;
- count = len;
- while (count-- > 0)
- {
- hval <<= 4;
- hval += item.key[count];
- }
-
- /* First hash function: simply take the modul but prevent zero. */
- hval %= htab->size;
- if (hval == 0)
- ++hval;
-
- /* The first index tried. */
- idx = hval;
-
- if (htab->table[idx].used)
- {
- /* Further action might be required according to the action value. */
- unsigned hval2;
-
- if (htab->table[idx].used == hval
- && __strcmp (item.key, htab->table[idx].entry.key) == 0)
- {
- *retval = &htab->table[idx].entry;
- return 1;
- }
-
- /* Second hash function, as suggested in [Knuth] */
- hval2 = 1 + hval % (htab->size - 2);
-
- do
- {
- /* Because SIZE is prime this guarantees to step through all
- available indeces. */
- if (idx <= hval2)
- idx = htab->size + idx - hval2;
- else
- idx -= hval2;
-
- /* If we visited all entries leave the loop unsuccessfully. */
- if (idx == hval)
- break;
-
- /* If entry is found use it. */
- if (htab->table[idx].used == hval
- && __strcmp (item.key, htab->table[idx].entry.key) == 0)
- {
- *retval = &htab->table[idx].entry;
- return 1;
- }
- }
- while (htab->table[idx].used);
- }
-
- /* An empty bucket has been found. */
- if (action == ENTER)
- {
- /* If table is full and another entry should be entered return
- with error. */
- if (action == ENTER && htab->filled == htab->size)
- {
- __set_errno (ENOMEM);
- *retval = NULL;
- return 0;
- }
-
- htab->table[idx].used = hval;
- htab->table[idx].entry = item;
-
- ++htab->filled;
-
- *retval = &htab->table[idx].entry;
- return 1;
- }
-
- __set_errno (ESRCH);
- *retval = NULL;
- return 0;
-}
-strong_alias(__hsearch_r,hsearch_r)
-#endif
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_hsearch_r
+#include "_hsearch_r.c"
diff --git a/libc/misc/search/insque.c b/libc/misc/search/insque.c
new file mode 100644
index 000000000..fc5bf807e
--- /dev/null
+++ b/libc/misc/search/insque.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_insque
+#include "insremque.c"
diff --git a/libc/misc/search/insremque.c b/libc/misc/search/insremque.c
index 29e547ff3..32edf7a4e 100644
--- a/libc/misc/search/insremque.c
+++ b/libc/misc/search/insremque.c
@@ -17,11 +17,7 @@
Boston, MA 02111-1307, USA. */
#include <features.h>
-#define __USE_GNU
#include <stddef.h>
-#ifndef _SVID_SOURCE
-#define _SVID_SOURCE 1
-#endif
#include <search.h>
#ifdef L_insque
diff --git a/libc/misc/search/lfind.c b/libc/misc/search/lfind.c
new file mode 100644
index 000000000..66111c5a4
--- /dev/null
+++ b/libc/misc/search/lfind.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_lfind
+#include "_lsearch.c"
diff --git a/libc/misc/search/lsearch.c b/libc/misc/search/lsearch.c
index 4071cf1ab..1e632975f 100644
--- a/libc/misc/search/lsearch.c
+++ b/libc/misc/search/lsearch.c
@@ -1,50 +1,8 @@
/*
- * This file lifted in toto from 'Dlibs' on the atari ST (RdeBath)
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
- *
- * Dale Schumacher 399 Beacon Ave.
- * (alias: Dalnefre') St. Paul, MN 55104
- * dal@syntel.UUCP United States of America
- * "It's not reality that's important, but how you perceive things."
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <string.h>
-#include <stdio.h>
-#include <search.h>
-
-#ifdef L_lfind
-
-void attribute_hidden *__lfind(const void *key, const void *base, size_t *nmemb,
- size_t size, int (*compar)(const void *, const void *))
-{
- register int n = *nmemb;
-
- while (n--) {
- if ((*compar) (base, key) == 0)
- return ((void*)base);
- base += size;
- }
- return (NULL);
-}
-strong_alias(__lfind,lfind)
-
-#endif
-
-#ifdef L_lsearch
-
-extern void *__lfind (__const void *__key, __const void *__base,
- size_t *__nmemb, size_t __size, __compar_fn_t __compar) attribute_hidden;
-
-void *lsearch(const void *key, void *base, size_t *nmemb,
- size_t size, int (*compar)(const void *, const void *))
-{
- register char *p;
-
- if ((p = __lfind(key, base, nmemb, size, compar)) == NULL) {
- p = __memcpy((base + (size * (*nmemb))), key, size);
- ++(*nmemb);
- }
- return (p);
-}
-
-#endif
+#define L_lsearch
+#include "_lsearch.c"
diff --git a/libc/misc/search/remque.c b/libc/misc/search/remque.c
new file mode 100644
index 000000000..bab698505
--- /dev/null
+++ b/libc/misc/search/remque.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_remque
+#include "insremque.c"
diff --git a/libc/misc/search/tdelete.c b/libc/misc/search/tdelete.c
new file mode 100644
index 000000000..33d9fe8a6
--- /dev/null
+++ b/libc/misc/search/tdelete.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_tdelete
+#include "_tsearch.c"
diff --git a/libc/misc/search/tdestroy.c b/libc/misc/search/tdestroy.c
new file mode 100644
index 000000000..3e397ea8c
--- /dev/null
+++ b/libc/misc/search/tdestroy.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_tdestroy
+#include "_tsearch.c"
diff --git a/libc/misc/search/tfind.c b/libc/misc/search/tfind.c
new file mode 100644
index 000000000..e5a316172
--- /dev/null
+++ b/libc/misc/search/tfind.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_tfind
+#include "_tsearch.c"
diff --git a/libc/misc/search/tsearch.c b/libc/misc/search/tsearch.c
index 58f16ab79..8984fc1d5 100644
--- a/libc/misc/search/tsearch.c
+++ b/libc/misc/search/tsearch.c
@@ -1,220 +1,8 @@
-/* Copyright (C) 1994 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
-
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
-
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
-
/*
- * Tree search generalized from Knuth (6.2.2) Algorithm T just like
- * the AT&T man page says.
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
- * The node_t structure is for internal use only, lint doesn't grok it.
- *
- * Written by reading the System V Interface Definition, not the code.
- *
- * Totally public domain.
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/*LINTLIBRARY*/
-
-#define _GNU_SOURCE
-#include <search.h>
-#include <stdlib.h>
-
-/* This routine is not very bad. It makes many assumptions about
- * the compiler. It assumpts that the first field in node must be
- * the "key" field, which points to the datum. It is a very trick
- * stuff. H.J.
- */
-
-typedef struct node_t
-{
- void *key;
- struct node_t *left, *right;
-} node;
-
-#ifdef L_tsearch
-/* find or insert datum into search tree.
-char *key; key to be located
-register node **rootp; address of tree root
-int (*compar)(); ordering function
-*/
-
-void attribute_hidden *__tsearch(__const void *key, void **vrootp, __compar_fn_t compar)
-{
- register node *q;
- register node **rootp = (node **) vrootp;
-
- if (rootp == (struct node_t **)0)
- return ((struct node_t *)0);
- while (*rootp != (struct node_t *)0) /* Knuth's T1: */
- {
- int r;
-
- if ((r = (*compar)(key, (*rootp)->key)) == 0) /* T2: */
- return (*rootp); /* we found it! */
- rootp = (r < 0) ?
- &(*rootp)->left : /* T3: follow left branch */
- &(*rootp)->right; /* T4: follow right branch */
- }
- q = (node *) malloc(sizeof(node)); /* T5: key not found */
- if (q != (struct node_t *)0) /* make new node */
- {
- *rootp = q; /* link new node to old */
- q->key = (void *)key; /* initialize new node */
- q->left = q->right = (struct node_t *)0;
- }
- return (q);
-}
-strong_alias(__tsearch,tsearch)
-#endif
-
-#ifdef L_tfind
-void attribute_hidden *__tfind(__const void *key, void * __const *vrootp, __compar_fn_t compar)
-{
- register node **rootp = (node **) vrootp;
-
- if (rootp == (struct node_t **)0)
- return ((struct node_t *)0);
- while (*rootp != (struct node_t *)0) /* Knuth's T1: */
- {
- int r;
-
- if ((r = (*compar)(key, (*rootp)->key)) == 0) /* T2: */
- return (*rootp); /* we found it! */
- rootp = (r < 0) ?
- &(*rootp)->left : /* T3: follow left branch */
- &(*rootp)->right; /* T4: follow right branch */
- }
- return NULL;
-}
-strong_alias(__tfind,tfind)
-#endif
-
-#ifdef L_tdelete
-/* delete node with given key
-char *key; key to be deleted
-register node **rootp; address of the root of tree
-int (*compar)(); comparison function
-*/
-void *tdelete(__const void *key, void ** vrootp, __compar_fn_t compar)
-{
- node *p;
- register node *q;
- register node *r;
- int cmp;
- register node **rootp = (node **) vrootp;
-
- if (rootp == (struct node_t **)0 || (p = *rootp) == (struct node_t *)0)
- return ((struct node_t *)0);
- while ((cmp = (*compar)(key, (*rootp)->key)) != 0)
- {
- p = *rootp;
- rootp = (cmp < 0) ?
- &(*rootp)->left : /* follow left branch */
- &(*rootp)->right; /* follow right branch */
- if (*rootp == (struct node_t *)0)
- return ((struct node_t *)0); /* key not found */
- }
- r = (*rootp)->right; /* D1: */
- if ((q = (*rootp)->left) == (struct node_t *)0) /* Left (struct node_t *)0? */
- q = r;
- else if (r != (struct node_t *)0) /* Right link is null? */
- {
- if (r->left == (struct node_t *)0) /* D2: Find successor */
- {
- r->left = q;
- q = r;
- }
- else
- { /* D3: Find (struct node_t *)0 link */
- for (q = r->left; q->left != (struct node_t *)0; q = r->left)
- r = q;
- r->left = q->right;
- q->left = (*rootp)->left;
- q->right = (*rootp)->right;
- }
- }
- free((struct node_t *) *rootp); /* D4: Free node */
- *rootp = q; /* link parent to new node */
- return(p);
-}
-#endif
-
-#ifdef L_twalk
-/* Walk the nodes of a tree
-register node *root; Root of the tree to be walked
-register void (*action)(); Function to be called at each node
-register int level;
-*/
-static void trecurse(__const void *vroot, __action_fn_t action, int level)
-{
- register node *root = (node *) vroot;
-
- if (root->left == (struct node_t *)0 && root->right == (struct node_t *)0)
- (*action)(root, leaf, level);
- else
- {
- (*action)(root, preorder, level);
- if (root->left != (struct node_t *)0)
- trecurse(root->left, action, level + 1);
- (*action)(root, postorder, level);
- if (root->right != (struct node_t *)0)
- trecurse(root->right, action, level + 1);
- (*action)(root, endorder, level);
- }
-}
-
-/* void twalk(root, action) Walk the nodes of a tree
-node *root; Root of the tree to be walked
-void (*action)(); Function to be called at each node
-PTR
-*/
-void twalk(__const void *vroot, __action_fn_t action)
-{
- register __const node *root = (node *) vroot;
-
- if (root != (node *)0 && action != (__action_fn_t) 0)
- trecurse(root, action, 0);
-}
-#endif
-
-#ifdef L_tdestroy
-/* The standardized functions miss an important functionality: the
- tree cannot be removed easily. We provide a function to do this. */
-static void
-internal_function
-tdestroy_recurse (node *root, __free_fn_t freefct)
-{
- if (root->left != NULL)
- tdestroy_recurse (root->left, freefct);
- if (root->right != NULL)
- tdestroy_recurse (root->right, freefct);
- (*freefct) ((void *) root->key);
- /* Free the node itself. */
- free (root);
-}
-
-void attribute_hidden __tdestroy (void *vroot, __free_fn_t freefct)
-{
- node *root = (node *) vroot;
- if (root != NULL) {
- tdestroy_recurse (root, freefct);
- }
-}
-strong_alias(__tdestroy,tdestroy)
-#endif
-
-/* tsearch.c ends here */
+#define L_tsearch
+#include "_tsearch.c"
diff --git a/libc/misc/search/twalk.c b/libc/misc/search/twalk.c
new file mode 100644
index 000000000..f36d341f5
--- /dev/null
+++ b/libc/misc/search/twalk.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_twalk
+#include "_tsearch.c"