summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter S. Mazinger <ps.m@gmx.net>2006-01-03 14:50:18 +0000
committerPeter S. Mazinger <ps.m@gmx.net>2006-01-03 14:50:18 +0000
commit167d5e33fcb821e51e2f9dcf460591737c3c7972 (patch)
tree79acefdd8c9781098adbf77278415eda6365fd3d
parentfe68563b9a070fedf117c8738652587945427bb3 (diff)
Complete split of all the string functions. Hope haven't broken too much. wcscoll/strcoll needs some love ...
-rw-r--r--libc/string/Makefile.in117
-rw-r--r--libc/string/__glibc_strerror_r.c19
-rw-r--r--libc/string/__xpg_basename.c35
-rw-r--r--libc/string/__xpg_strerror_r.c273
-rw-r--r--libc/string/_collate.c686
-rw-r--r--libc/string/_string.h33
-rw-r--r--libc/string/_string_syserrmsgs.c146
-rw-r--r--libc/string/_string_syssigmsgs.c50
-rw-r--r--libc/string/_syserrmsg.h35
-rw-r--r--libc/string/basename.c26
-rw-r--r--libc/string/bcopy.c53
-rw-r--r--libc/string/bzero.c31
-rw-r--r--libc/string/dirname.c43
-rw-r--r--libc/string/ffs.c54
-rw-r--r--libc/string/memccpy.c22
-rw-r--r--libc/string/memchr.c36
-rw-r--r--libc/string/memcmp.c39
-rw-r--r--libc/string/memcpy.c33
-rw-r--r--libc/string/memmem.c40
-rw-r--r--libc/string/memmove.c53
-rw-r--r--libc/string/mempcpy.c33
-rw-r--r--libc/string/memrchr.c33
-rw-r--r--libc/string/memset.c33
-rw-r--r--libc/string/psignal.c30
-rw-r--r--libc/string/rawmemchr.c19
-rw-r--r--libc/string/stpcpy.c27
-rw-r--r--libc/string/stpncpy.c37
-rw-r--r--libc/string/strcasecmp.c75
-rw-r--r--libc/string/strcasecmp_l.c8
-rw-r--r--libc/string/strcasestr.c51
-rw-r--r--libc/string/strcat.c25
-rw-r--r--libc/string/strchr.c29
-rw-r--r--libc/string/strchrnul.c21
-rw-r--r--libc/string/strcmp.c46
-rw-r--r--libc/string/strcpy.c29
-rw-r--r--libc/string/strcspn.c28
-rw-r--r--libc/string/strdup.c33
-rw-r--r--libc/string/strerror.c21
-rw-r--r--libc/string/strlcat.c46
-rw-r--r--libc/string/strlcpy.c55
-rw-r--r--libc/string/strlen.c23
-rw-r--r--libc/string/strncasecmp.c78
-rw-r--r--libc/string/strncasecmp_l.c8
-rw-r--r--libc/string/strncat.c34
-rw-r--r--libc/string/strncmp.c38
-rw-r--r--libc/string/strncpy.c35
-rw-r--r--libc/string/strndup.c25
-rw-r--r--libc/string/strnlen.c33
-rw-r--r--libc/string/strpbrk.c27
-rw-r--r--libc/string/strrchr.c31
-rw-r--r--libc/string/strsep.c31
-rw-r--r--libc/string/strsignal.c144
-rw-r--r--libc/string/strspn.c28
-rw-r--r--libc/string/strstr.c41
-rw-r--r--libc/string/strtok.c22
-rw-r--r--libc/string/strtok_r.c54
-rw-r--r--libc/string/strxfrm.c9
-rw-r--r--libc/string/strxfrm_l.c10
-rw-r--r--libc/string/sys_errlist.c171
-rw-r--r--libc/string/sys_siglist.c57
-rw-r--r--libc/string/wcpcpy.c9
-rw-r--r--libc/string/wcpncpy.c9
-rw-r--r--libc/string/wcscasecmp.c8
-rw-r--r--libc/string/wcscasecmp_l.c9
-rw-r--r--libc/string/wcscat.c9
-rw-r--r--libc/string/wcschr.c9
-rw-r--r--libc/string/wcschrnul.c9
-rw-r--r--libc/string/wcscmp.c14
-rw-r--r--libc/string/wcscpy.c9
-rw-r--r--libc/string/wcscspn.c9
-rw-r--r--libc/string/wcsdup.c14
-rw-r--r--libc/string/wcslcpy.c11
-rw-r--r--libc/string/wcslen.c9
-rw-r--r--libc/string/wcsncasecmp.c8
-rw-r--r--libc/string/wcsncasecmp_l.c9
-rw-r--r--libc/string/wcsncat.c9
-rw-r--r--libc/string/wcsncmp.c9
-rw-r--r--libc/string/wcsncpy.c9
-rw-r--r--libc/string/wcsnlen.c9
-rw-r--r--libc/string/wcspbrk.c9
-rw-r--r--libc/string/wcsrchr.c9
-rw-r--r--libc/string/wcsspn.c9
-rw-r--r--libc/string/wcsstr.c11
-rw-r--r--libc/string/wcstok.c14
-rw-r--r--libc/string/wcsxfrm.c9
-rw-r--r--libc/string/wcsxfrm_l.c10
-rw-r--r--libc/string/wmemchr.c9
-rw-r--r--libc/string/wmemcmp.c9
-rw-r--r--libc/string/wmemcpy.c9
-rw-r--r--libc/string/wmemmove.c9
-rw-r--r--libc/string/wmempcpy.c9
-rw-r--r--libc/string/wmemset.c9
-rw-r--r--libc/string/wstring.c3247
93 files changed, 3253 insertions, 3702 deletions
diff --git a/libc/string/Makefile.in b/libc/string/Makefile.in
index 0adcaee39..4f96b8354 100644
--- a/libc/string/Makefile.in
+++ b/libc/string/Makefile.in
@@ -9,112 +9,69 @@
-include $(top_srcdir)libc/string/$(TARGET_ARCH)/Makefile.arch
include $(top_srcdir)libc/string/generic/Makefile.in
-MSRC:=wstring.c
-MOBJ:= basename.o bcopy.o bzero.o dirname.o ffs.o memccpy.o \
- memrchr.o rawmemchr.o strcasecmp.o strcasestr.o \
- strncasecmp.o strndup.o strsep.o \
- strtok.o strerror.o __xpg_strerror_r.o \
- _string_syserrmsgs.o __glibc_strerror_r.o \
- _string_syssigmsgs.o sys_siglist.o strsignal.o psignal.o \
- __xpg_basename.o strlcat.o sys_errlist.o memmem.o
+STRING_DIR:=$(top_srcdir)libc/string
+STRING_OUT:=$(top_builddir)libc/string
-MOBJW:=
-ifeq ($(UCLIBC_HAS_WCHAR),y)
-MOBJW:= wcscasecmp.o wcsncasecmp.o \
- wcsxfrm.o strxfrm.o # wcscoll strcoll.o
+STRING_ALL_WXSRC:=$(wildcard $(STRING_DIR)/w*_l.c)
+ifeq ($(UCLIBC_HAS_LOCALE),y)
+STRING_WXSRC:=$(STRING_ALL_WXSRC)
+else
+# wcscoll_l
+STRING_WXSRC:=$(filter-out $(STRING_DIR)/wcsxfrm_l.c,$(STRING_ALL_WXSRC))
endif
-MOBJx:=
-MOBJWx:=
-ifeq ($(UCLIBC_HAS_XLOCALE),y)
-MOBJx:=strcasecmp_l.o strncasecmp_l.o
-ifeq ($(UCLIBC_HAS_WCHAR),y)
-MOBJWx:=wcscasecmp_l.o wcsncasecmp_l.o wcsxfrm_l.o strxfrm_l.o
+STRING_ALL_XLSRC:=$(filter-out $(STRING_ALL_WXSRC),$(wildcard $(STRING_DIR)/*_l.c))
+ifeq ($(UCLIBC_HAS_LOCALE),y)
+STRING_XLSRC:=$(STRING_ALL_XLSRC)
+else
+# strcoll_l
+STRING_XLSRC:=$(filter-out $(STRING_DIR)/strxfrm_l.c,$(STRING_ALL_XLSRC))
endif
-endif
-
-#ffsl ffsll
-ifeq ($(UCLIBC_HAS_STRING_ARCH_OPT),y)
-ifneq ($(strip $(STRING_ARCH_OBJS)),)
-MOBJ:=$(filter-out $(notdir $(STRING_ARCH_OBJS)),$(MOBJ))
+STRING_ALL_WSRC:=$(filter-out $(STRING_ALL_WXSRC),$(wildcard $(STRING_DIR)/w*.c))
+ifeq ($(UCLIBC_HAS_LOCALE),y)
+STRING_WSRC:=$(STRING_ALL_WSRC)
+else
+# wcscoll
+STRING_WSRC:=$(filter-out $(STRING_DIR)/wcsxfrm.c,$(STRING_ALL_WSRC))
endif
+
+STRING_ALL_CSRC:=$(filter-out $(STRING_ALL_WXSRC) $(STRING_ALL_XLSRC) $(STRING_ALL_WSRC) $(STRING_DIR)/_collate.c,$(wildcard $(STRING_DIR)/*.c))
+ifeq ($(UCLIBC_HAS_LOCALE),y)
+STRING_CSRC:=$(STRING_ALL_CSRC)
+else
+# strcoll
+STRING_CSRC:=$(filter-out $(STRING_DIR)/strxfrm.c,$(STRING_ALL_CSRC))
endif
-ifeq ($(UCLIBC_HAS_STRING_GENERIC_OPT),y)
-ifneq ($(strip $(STRING_GENERIC_OBJS)),)
-MOBJ:=$(filter-out $(notdir $(STRING_GENERIC_OBJS)),$(MOBJ))
+ifeq ($(UCLIBC_HAS_WCHAR),y)
+STRING_CSRC+=$(STRING_WSRC)
+endif
+ifeq ($(UCLIBC_HAS_XLOCALE),y)
+STRING_CSRC+=$(STRING_XLSRC)
+ifeq ($(UCLIBC_HAS_WCHAR),y)
+STRING_CSRC+=$(STRING_WXSRC)
endif
endif
-
-STRING_DIR:=$(top_srcdir)libc/string
-STRING_OUT:=$(top_builddir)libc/string
-
-STRING_WSRC:=$(filter-out $(STRING_DIR)/wstring.c,$(wildcard $(STRING_DIR)/w*.c))
-STRING_CSRC:=$(filter-out $(STRING_DIR)/wstring.c $(STRING_WSRC),$(wildcard $(STRING_DIR)/*.c))
ifeq ($(UCLIBC_HAS_STRING_ARCH_OPT),y)
ifneq ($(strip $(STRING_ARCH_OBJS)),)
-MOBJ:=$(filter-out $(notdir $(STRING_ARCH_OBJS)),$(MOBJ))
STRING_CSRC:=$(filter-out $(patsubst %.o,$(STRING_DIR)/%.c,$(notdir $(STRING_ARCH_OBJS))),$(STRING_CSRC))
-STRING_WSRC:=$(filter-out $(patsubst %.o,$(STRING_DIR)/%.c,$(notdir $(STRING_ARCH_OBJS))),$(STRING_WSRC))
endif
endif
ifeq ($(UCLIBC_HAS_STRING_GENERIC_OPT),y)
ifneq ($(strip $(STRING_GENERIC_OBJS)),)
-MOBJ:=$(filter-out $(notdir $(STRING_GENERIC_OBJS)),$(MOBJ))
STRING_CSRC:=$(filter-out $(patsubst %.o,$(STRING_DIR)/%.c,$(notdir $(STRING_GENERIC_OBJS))),$(STRING_CSRC))
-STRING_WSRC:=$(filter-out $(patsubst %.o,$(STRING_DIR)/%.c,$(notdir $(STRING_GENERIC_OBJS))),$(STRING_WSRC))
endif
endif
-
STRING_COBJ:=$(patsubst $(STRING_DIR)/%.c,$(STRING_OUT)/%.o,$(STRING_CSRC))
-ifeq ($(UCLIBC_HAS_WCHAR),y)
-STRING_WOBJ:=$(patsubst $(STRING_DIR)/%.c,$(STRING_OUT)/%.o,$(STRING_WSRC))
-endif
-STRING_MSRC:=$(patsubst %.c,$(STRING_DIR)/%.c,$(MSRC))
-STRING_MOBJ:=$(patsubst %.o,$(STRING_OUT)/%.o,$(MOBJ))
-STRING_MOBJW:=$(patsubst %.o,$(STRING_OUT)/%.o,$(MOBJW))
-STRING_MOBJx:=$(patsubst %.o,$(STRING_OUT)/%.o,$(MOBJx))
-STRING_MOBJWx:=$(patsubst %.o,$(STRING_OUT)/%.o,$(MOBJWx))
-
-STRING_DEF:=$(patsubst %,-DL_%,$(subst .o,,$(notdir $(STRING_MOBJ))))
-
-STRING_Wx:=$(STRING_MOBJW) $(STRING_MOBJx) $(STRING_MOBJWx)
-STRING_OBJS:=$(STRING_COBJ) $(STRING_WOBJ) $(STRING_MOBJ) $(STRING_Wx)
-
-$(STRING_MOBJ): $(STRING_MSRC)
- $(compile.m)
-
-$(STRING_MOBJ:.o=.os): $(STRING_MSRC)
- $(compile.m)
-
-$(STRING_MOBJW): $(STRING_MSRC)
- $(compile.m) -DWANT_WIDE
-
-$(STRING_MOBJW:.o=.os): $(STRING_MSRC)
- $(compile.m) -DWANT_WIDE
-
-$(STRING_MOBJx): $(STRING_MSRC)
- $(compile.m) -D__UCLIBC_DO_XLOCALE
-
-$(STRING_MOBJx:.o=.os): $(STRING_MSRC)
- $(compile.m) -D__UCLIBC_DO_XLOCALE
-
-$(STRING_MOBJWx): $(STRING_MSRC)
- $(compile.m) -DWANT_WIDE -D__UCLIBC_DO_XLOCALE
-
-$(STRING_MOBJWx:.o=.os): $(STRING_MSRC)
- $(compile.m) -DWANT_WIDE -D__UCLIBC_DO_XLOCALE
-libc-a-y+=$(STRING_OBJS)
-libc-so-y+=$(STRING_OBJS:.o=.os)
+libc-a-y+=$(STRING_COBJ)
+libc-so-y+=$(STRING_COBJ:.o=.os)
-CFLAGS-multi-y+=$(STRING_DEF)
-libc-multi-y+=$(STRING_MSRC) $(STRING_CSRC) $(STRING_WSRC)
-libc-nomulti-y+=$(STRING_Wx)
+libc-multi-y+=$(STRING_CSRC)
objclean-y+=string_objclean
diff --git a/libc/string/__glibc_strerror_r.c b/libc/string/__glibc_strerror_r.c
new file mode 100644
index 000000000..54955ec25
--- /dev/null
+++ b/libc/string/__glibc_strerror_r.c
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2002 Manuel Novoa III
+ * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include <features.h>
+#include <string.h>
+
+char attribute_hidden *__glibc_strerror_r_internal(int errnum, char *strerrbuf, size_t buflen)
+{
+ __xpg_strerror_r_internal(errnum, strerrbuf, buflen);
+
+ return strerrbuf;
+}
+
+strong_alias(__glibc_strerror_r_internal,__glibc_strerror_r)
+/*hidden_weak_alias(__glibc_strerror_r_internal,__strerror_r)*/
diff --git a/libc/string/__xpg_basename.c b/libc/string/__xpg_basename.c
new file mode 100644
index 000000000..6281f015c
--- /dev/null
+++ b/libc/string/__xpg_basename.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2002 Manuel Novoa III
+ * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#include "_string.h"
+
+char *__xpg_basename(register char *path)
+{
+ static const char null_or_empty[] = ".";
+ char *first;
+ register char *last;
+
+ first = (char *) null_or_empty;
+
+ if (path && *path) {
+ first = path;
+ last = path - 1;
+
+ do {
+ if ((*path != '/') && (path > ++last)) {
+ last = first = path;
+ }
+ } while (*++path);
+
+ if (*first == '/') {
+ last = first;
+ }
+ last[1] = 0;
+ }
+
+ return first;
+}
diff --git a/libc/string/__xpg_strerror_r.c b/libc/string/__xpg_strerror_r.c
new file mode 100644
index 000000000..93dffc732
--- /dev/null
+++ b/libc/string/__xpg_strerror_r.c
@@ -0,0 +1,273 @@
+/*
+ * Copyright (C) 2002 Manuel Novoa III
+ * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define _GNU_SOURCE
+#include <features.h>
+#include <errno.h>
+#include <bits/uClibc_uintmaxtostr.h>
+#include "_syserrmsg.h"
+
+#ifdef __UCLIBC_HAS_ERRNO_MESSAGES__
+
+extern const char _string_syserrmsgs[];
+
+#if defined(__alpha__) || defined(__mips__) || defined(__sparc__)
+
+static const unsigned char estridx[] = {
+ 0, /* success is always 0 */
+ EPERM,
+ ENOENT,
+ ESRCH,
+ EINTR,
+ EIO,
+ ENXIO,
+ E2BIG,
+ ENOEXEC,
+ EBADF,
+ ECHILD,
+ EAGAIN,
+ ENOMEM,
+ EACCES,
+ EFAULT,
+ ENOTBLK,
+ EBUSY,
+ EEXIST,
+ EXDEV,
+ ENODEV,
+ ENOTDIR,
+ EISDIR,
+ EINVAL,
+ ENFILE,
+ EMFILE,
+ ENOTTY,
+ ETXTBSY,
+ EFBIG,
+ ENOSPC,
+ ESPIPE,
+ EROFS,
+ EMLINK,
+ EPIPE,
+ EDOM,
+ ERANGE,
+ EDEADLK,
+ ENAMETOOLONG,
+ ENOLCK,
+ ENOSYS,
+ ENOTEMPTY,
+ ELOOP,
+ 0,
+ ENOMSG,
+ EIDRM,
+ ECHRNG,
+ EL2NSYNC,
+ EL3HLT,
+ EL3RST,
+ ELNRNG,
+ EUNATCH,
+ ENOCSI,
+ EL2HLT,
+ EBADE,
+ EBADR,
+ EXFULL,
+ ENOANO,
+ EBADRQC,
+ EBADSLT,
+ 0,
+ EBFONT,
+ ENOSTR,
+ ENODATA,
+ ETIME,
+ ENOSR,
+ ENONET,
+ ENOPKG,
+ EREMOTE,
+ ENOLINK,
+ EADV,
+ ESRMNT,
+ ECOMM,
+ EPROTO,
+ EMULTIHOP,
+ EDOTDOT,
+ EBADMSG,
+ EOVERFLOW,
+ ENOTUNIQ,
+ EBADFD,
+ EREMCHG,
+ ELIBACC,
+ ELIBBAD,
+ ELIBSCN,
+ ELIBMAX,
+ ELIBEXEC,
+ EILSEQ,
+ ERESTART,
+ ESTRPIPE,
+ EUSERS,
+ ENOTSOCK,
+ EDESTADDRREQ,
+ EMSGSIZE,
+ EPROTOTYPE,
+ ENOPROTOOPT,
+ EPROTONOSUPPORT,
+ ESOCKTNOSUPPORT,
+ EOPNOTSUPP,
+ EPFNOSUPPORT,
+ EAFNOSUPPORT,
+ EADDRINUSE,
+ EADDRNOTAVAIL,
+ ENETDOWN,
+ ENETUNREACH,
+ ENETRESET,
+ ECONNABORTED,
+ ECONNRESET,
+ ENOBUFS,
+ EISCONN,
+ ENOTCONN,
+ ESHUTDOWN,
+ ETOOMANYREFS,
+ ETIMEDOUT,
+ ECONNREFUSED,
+ EHOSTDOWN,
+ EHOSTUNREACH,
+ EALREADY,
+ EINPROGRESS,
+ ESTALE,
+ EUCLEAN,
+ ENOTNAM,
+ ENAVAIL,
+ EISNAM,
+ EREMOTEIO,
+#ifdef __mips__
+ 0, /* mips has an outrageous value for this... */
+#else
+ EDQUOT,
+#endif
+ ENOMEDIUM,
+ EMEDIUMTYPE,
+#if defined(__mips__) || defined(__sparc__)
+ EDEADLOCK,
+#endif
+};
+
+#endif
+
+/* __xpg_strerror_r is used in header */
+int attribute_hidden __xpg_strerror_r_internal(int errnum, char *strerrbuf, size_t buflen)
+{
+ register char *s;
+ int i, retval;
+ char buf[_STRERROR_BUFSIZE];
+ static const char unknown[] = {
+ 'U', 'n', 'k', 'n', 'o', 'w', 'n', ' ', 'e', 'r', 'r', 'o', 'r', ' '
+ };
+
+ retval = EINVAL;
+
+
+#ifdef __UCLIBC_HAS_ERRNO_MESSAGES__
+
+#if defined(__alpha__) || defined(__mips__) || defined(__sparc__)
+ /* Need to translate errno to string index. */
+ for (i = 0 ; i < sizeof(estridx)/sizeof(estridx[0]) ; i++) {
+ if (estridx[i] == errnum) {
+ goto GOT_ESTRIDX;
+ }
+ }
+ i = INT_MAX; /* Failed, but may need to check mips special case. */
+#ifdef __mips__
+ if (errnum == EDQUOT) { /* Deal with large EDQUOT value on mips */
+ i = 122;
+ }
+#endif /* __mips__ */
+ GOT_ESTRIDX:
+#else
+ /* No errno to string index translation needed. */
+ i = errnum;
+#endif
+
+ if (