summaryrefslogtreecommitdiffstats
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/misc/statfs/Makefile.in23
-rw-r--r--libc/misc/statfs/fstatfs64.c34
-rw-r--r--libc/misc/statfs/fstatvfs.c17
-rw-r--r--libc/misc/statfs/fstatvfs64.c41
-rw-r--r--libc/misc/statfs/internal_statvfs.c45
-rw-r--r--libc/misc/statfs/statfs64.c34
-rw-r--r--libc/misc/statfs/statvfs.c16
-rw-r--r--libc/misc/statfs/statvfs64.c39
-rw-r--r--libc/misc/syslog/Makefile.in19
-rw-r--r--libc/misc/syslog/syslog.c107
-rw-r--r--libc/misc/sysvipc/Makefile.in66
-rw-r--r--libc/misc/sysvipc/ftok.c4
-rw-r--r--libc/misc/sysvipc/ipc.h11
-rw-r--r--libc/misc/sysvipc/msgctl.c8
-rw-r--r--libc/misc/sysvipc/msgget.c8
-rw-r--r--libc/misc/sysvipc/msgq.c2
-rw-r--r--libc/misc/sysvipc/msgrcv.c8
-rw-r--r--libc/misc/sysvipc/msgsnd.c8
-rw-r--r--libc/misc/sysvipc/semctl.c8
-rw-r--r--libc/misc/sysvipc/semget.c8
-rw-r--r--libc/misc/sysvipc/semop.c8
-rw-r--r--libc/misc/sysvipc/shm.c14
-rw-r--r--libc/misc/sysvipc/shmat.c8
-rw-r--r--libc/misc/sysvipc/shmctl.c8
-rw-r--r--libc/misc/sysvipc/shmdt.c8
-rw-r--r--libc/misc/sysvipc/shmget.c8
-rw-r--r--libc/misc/ttyent/Makefile.in19
-rw-r--r--libc/misc/ttyent/getttyent.c61
-rw-r--r--libc/misc/utmp/Makefile.in19
-rw-r--r--libc/misc/utmp/utent.c81
-rw-r--r--libc/misc/utmp/wtent.c54
-rw-r--r--libc/misc/wchar/Makefile.in35
-rw-r--r--libc/misc/wchar/_wchar_utf8sntowcs.c8
-rw-r--r--libc/misc/wchar/_wchar_wcsntoutf8s.c8
-rw-r--r--libc/misc/wchar/btowc.c8
-rw-r--r--libc/misc/wchar/iconv.c8
-rw-r--r--libc/misc/wchar/mbrlen.c8
-rw-r--r--libc/misc/wchar/mbrtowc.c8
-rw-r--r--libc/misc/wchar/mbsinit.c8
-rw-r--r--libc/misc/wchar/mbsnrtowcs.c8
-rw-r--r--libc/misc/wchar/mbsrtowcs.c8
-rw-r--r--libc/misc/wchar/wchar.c123
-rw-r--r--libc/misc/wchar/wcrtomb.c8
-rw-r--r--libc/misc/wchar/wcsnrtombs.c8
-rw-r--r--libc/misc/wchar/wcsrtombs.c8
-rw-r--r--libc/misc/wchar/wcswidth.c8
-rw-r--r--libc/misc/wchar/wctob.c8
-rw-r--r--libc/misc/wchar/wcwidth.c8
-rw-r--r--libc/misc/wchar/wstdio.c450
-rw-r--r--libc/misc/wctype/Makefile.in58
-rw-r--r--libc/misc/wctype/_wctype.c947
-rw-r--r--libc/misc/wctype/iswalnum.c8
-rw-r--r--libc/misc/wctype/iswalnum_l.c9
-rw-r--r--libc/misc/wctype/iswalpha.c8
-rw-r--r--libc/misc/wctype/iswalpha_l.c9
-rw-r--r--libc/misc/wctype/iswblank.c8
-rw-r--r--libc/misc/wctype/iswblank_l.c9
-rw-r--r--libc/misc/wctype/iswcntrl.c8
-rw-r--r--libc/misc/wctype/iswcntrl_l.c9
-rw-r--r--libc/misc/wctype/iswctype.c8
-rw-r--r--libc/misc/wctype/iswctype_l.c9
-rw-r--r--libc/misc/wctype/iswdigit.c8
-rw-r--r--libc/misc/wctype/iswdigit_l.c9
-rw-r--r--libc/misc/wctype/iswgraph.c8
-rw-r--r--libc/misc/wctype/iswgraph_l.c9
-rw-r--r--libc/misc/wctype/iswlower.c8
-rw-r--r--libc/misc/wctype/iswlower_l.c9
-rw-r--r--libc/misc/wctype/iswprint.c8
-rw-r--r--libc/misc/wctype/iswprint_l.c9
-rw-r--r--libc/misc/wctype/iswpunct.c8
-rw-r--r--libc/misc/wctype/iswpunct_l.c9
-rw-r--r--libc/misc/wctype/iswspace.c8
-rw-r--r--libc/misc/wctype/iswspace_l.c9
-rw-r--r--libc/misc/wctype/iswupper.c8
-rw-r--r--libc/misc/wctype/iswupper_l.c9
-rw-r--r--libc/misc/wctype/iswxdigit.c8
-rw-r--r--libc/misc/wctype/iswxdigit_l.c9
-rw-r--r--libc/misc/wctype/towctrans.c8
-rw-r--r--libc/misc/wctype/towctrans_l.c9
-rw-r--r--libc/misc/wctype/towlower.c8
-rw-r--r--libc/misc/wctype/towlower_l.c9
-rw-r--r--libc/misc/wctype/towupper.c8
-rw-r--r--libc/misc/wctype/towupper_l.c9
-rw-r--r--libc/misc/wctype/wctrans.c8
-rw-r--r--libc/misc/wctype/wctrans_l.c9
-rw-r--r--libc/misc/wctype/wctype.c940
-rw-r--r--libc/misc/wctype/wctype_l.c9
-rw-r--r--libc/misc/wordexp/Makefile.in19
-rw-r--r--libc/misc/wordexp/wordexp.c173
89 files changed, 2000 insertions, 1957 deletions
diff --git a/libc/misc/statfs/Makefile.in b/libc/misc/statfs/Makefile.in
index 9350e221e..c979b2255 100644
--- a/libc/misc/statfs/Makefile.in
+++ b/libc/misc/statfs/Makefile.in
@@ -1,27 +1,26 @@
# 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:=statvfs.c fstatvfs.c
+CSRC := statvfs.c fstatvfs.c
ifeq ($(UCLIBC_HAS_LFS),y)
-CSRC+=fstatfs64.c statfs64.c statvfs64.c fstatvfs64.c
+CSRC += fstatfs64.c statfs64.c statvfs64.c fstatvfs64.c
endif
-MISC_STATFS_DIR:=$(top_srcdir)libc/misc/statfs
-MISC_STATFS_OUT:=$(top_builddir)libc/misc/statfs
+MISC_STATFS_DIR := $(top_srcdir)libc/misc/statfs
+MISC_STATFS_OUT := $(top_builddir)libc/misc/statfs
-MISC_STATFS_SRC:=$(patsubst %.c,$(MISC_STATFS_DIR)/%.c,$(CSRC))
-MISC_STATFS_OBJ:=$(patsubst %.c,$(MISC_STATFS_OUT)/%.o,$(CSRC))
+MISC_STATFS_SRC := $(patsubst %.c,$(MISC_STATFS_DIR)/%.c,$(CSRC))
+MISC_STATFS_OBJ := $(patsubst %.c,$(MISC_STATFS_OUT)/%.o,$(CSRC))
-libc-a-y+=$(MISC_STATFS_OBJ)
-libc-so-y+=$(MISC_STATFS_OBJ:.o=.os)
+libc-y += $(MISC_STATFS_OBJ)
-libc-multi-y+=$(MISC_STATFS_SRC)
+libc-nomulti-$(UCLIBC_HAS_LFS) += $(MISC_STATFS_OUT)/statvfs64.o $(MISC_STATFS_OUT)/fstatvfs64.o
-objclean-y+=misc_statfs_objclean
+objclean-y += misc_statfs_objclean
misc_statfs_objclean:
- $(RM) $(MISC_STATFS_OUT)/*.{o,os}
+ $(RM) $(MISC_STATFS_OUT)/*.{o,os,oS}
diff --git a/libc/misc/statfs/fstatfs64.c b/libc/misc/statfs/fstatfs64.c
index 63bd640b7..dd271e7a3 100644
--- a/libc/misc/statfs/fstatfs64.c
+++ b/libc/misc/statfs/fstatfs64.c
@@ -17,24 +17,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <features.h>
-#undef __fstatfs64
-#undef __fstatfs
-
-#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_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 <errno.h>
#include <string.h>
@@ -42,13 +25,16 @@
#include <sys/statvfs.h>
#include <stddef.h>
-#undef fstatfs64
+libc_hidden_proto(memcpy)
+libc_hidden_proto(fstatfs)
+
/* Return information about the filesystem on which FD resides. */
-int attribute_hidden __fstatfs64 (int fd, struct statfs64 *buf)
+libc_hidden_proto(fstatfs64)
+int fstatfs64 (int fd, struct statfs64 *buf)
{
struct statfs buf32;
- if (__fstatfs (fd, &buf32) < 0)
+ if (fstatfs (fd, &buf32) < 0)
return -1;
buf->f_type = buf32.f_type;
@@ -60,10 +46,8 @@ int attribute_hidden __fstatfs64 (int fd, struct statfs64 *buf)
buf->f_ffree = buf32.f_ffree;
buf->f_fsid = buf32.f_fsid;
buf->f_namelen = buf32.f_namelen;
- __memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
+ memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
return 0;
}
-strong_alias(__fstatfs64,fstatfs64)
-
-#endif /* __UCLIBC_HAS_LFS__ */
+libc_hidden_def(fstatfs64)
diff --git a/libc/misc/statfs/fstatvfs.c b/libc/misc/statfs/fstatvfs.c
index 14ef6ecce..c28132022 100644
--- a/libc/misc/statfs/fstatvfs.c
+++ b/libc/misc/statfs/fstatvfs.c
@@ -18,8 +18,6 @@
02111-1307 USA. */
#include <features.h>
-
-#define __USE_GNU
#include <errno.h>
#include <mntent.h>
#include <paths.h>
@@ -29,16 +27,27 @@
#include <sys/statfs.h>
#include <sys/statvfs.h>
+libc_hidden_proto(memset)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strsep)
+libc_hidden_proto(setmntent)
+libc_hidden_proto(getmntent_r)
+libc_hidden_proto(endmntent)
+
+libc_hidden_proto(fstatfs)
+libc_hidden_proto(fstat)
+libc_hidden_proto(stat)
+
int fstatvfs (int fd, struct statvfs *buf)
{
struct statfs fsbuf;
struct stat st;
/* Get as much information as possible from the system. */
- if (__fstatfs (fd, &fsbuf) < 0)
+ if (fstatfs (fd, &fsbuf) < 0)
return -1;
-#define STAT(st) __fstat (fd, st)
+#define STAT(st) fstat (fd, st)
#include "internal_statvfs.c"
/* We signal success if the statfs call succeeded. */
diff --git a/libc/misc/statfs/fstatvfs64.c b/libc/misc/statfs/fstatvfs64.c
index 993caf955..a37642e70 100644
--- a/libc/misc/statfs/fstatvfs64.c
+++ b/libc/misc/statfs/fstatvfs64.c
@@ -17,22 +17,8 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <features.h>
-
-#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 <errno.h>
#include <mntent.h>
#include <paths.h>
@@ -42,16 +28,29 @@
#include <sys/statfs.h>
#include <sys/statvfs.h>
-int fstatvfs (int fd, struct statvfs *buf)
+libc_hidden_proto(memset)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strsep)
+libc_hidden_proto(setmntent)
+libc_hidden_proto(getmntent_r)
+libc_hidden_proto(endmntent)
+
+#undef stat
+#define stat stat64
+libc_hidden_proto(fstatfs64)
+libc_hidden_proto(fstat64)
+libc_hidden_proto(stat64)
+
+int fstatvfs64 (int fd, struct statvfs64 *buf)
{
- struct statfs fsbuf;
- struct stat st;
+ struct statfs64 fsbuf;
+ struct stat64 st;
/* Get as much information as possible from the system. */
- if (__fstatfs (fd, &fsbuf) < 0)
+ if (fstatfs64 (fd, &fsbuf) < 0)
return -1;
-#define STAT(st) __fstat (fd, st)
+#define STAT(st) fstat64 (fd, st)
#include "internal_statvfs.c"
/* We signal success if the statfs call succeeded. */
diff --git a/libc/misc/statfs/internal_statvfs.c b/libc/misc/statfs/internal_statvfs.c
index d41c3052d..6075e9cf4 100644
--- a/libc/misc/statfs/internal_statvfs.c
+++ b/libc/misc/statfs/internal_statvfs.c
@@ -17,19 +17,6 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-extern FILE *__setmntent (__const char *__file, __const char *__mode) __THROW attribute_hidden;
-
-extern struct mntent *__getmntent_r (FILE *__restrict __stream,
- struct mntent *__restrict __result,
- char *__restrict __buffer,
- int __bufsize) __THROW attribute_hidden;
-
-extern int __endmntent (FILE *__stream) __THROW attribute_hidden;
-
-extern char *__strsep (char **__restrict __stringp,
- __const char *__restrict __delim)
- __THROW __nonnull ((1, 2)) attribute_hidden;
-
/* Now fill in the fields we have information for. */
buf->f_bsize = fsbuf.f_bsize;
/* Linux does not support f_frsize, so set it to the full block size. */
@@ -52,7 +39,7 @@ extern char *__strsep (char **__restrict __stringp,
buf->__f_unused = 0;
#endif
buf->f_namemax = fsbuf.f_namelen;
- __memset (buf->__f_spare, '\0', 6 * sizeof (int));
+ memset (buf->__f_spare, '\0', 6 * sizeof (int));
/* What remains to do is to fill the fields f_favail and f_flag. */
@@ -70,20 +57,20 @@ extern char *__strsep (char **__restrict __stringp,
struct mntent mntbuf;
FILE *mtab;
- mtab = __setmntent ("/proc/mounts", "r");
+ mtab = setmntent ("/proc/mounts", "r");
if (mtab == NULL)
- mtab = __setmntent (_PATH_MOUNTED, "r");
+ mtab = setmntent (_PATH_MOUNTED, "r");
if (mtab != NULL)
{
char tmpbuf[1024];
- while (__getmntent_r (mtab, &mntbuf, tmpbuf, sizeof (tmpbuf)))
+ while (getmntent_r (mtab, &mntbuf, tmpbuf, sizeof (tmpbuf)))
{
struct stat fsst;
/* Find out about the device the current entry is for. */
- if (__stat (mntbuf.mnt_dir, &fsst) >= 0
+ if (stat (mntbuf.mnt_dir, &fsst) >= 0
&& st.st_dev == fsst.st_dev)
{
/* Bingo, we found the entry for the device FD is on.
@@ -91,23 +78,25 @@ extern char *__strsep (char **__restrict __stringp,
char *cp = mntbuf.mnt_opts;
char *opt;
- while ((opt = __strsep (&cp, ",")) != NULL)
- if (__strcmp (opt, "ro") == 0)
+ while ((opt = strsep (&cp, ",")) != NULL)
+ if (strcmp (opt, "ro") == 0)
buf->f_flag |= ST_RDONLY;
- else if (__strcmp (opt, "nosuid") == 0)
+ else if (strcmp (opt, "nosuid") == 0)
buf->f_flag |= ST_NOSUID;
- else if (__strcmp (opt, "noexec") == 0)
+#ifdef __USE_GNU
+ else if (strcmp (opt, "noexec") == 0)
buf->f_flag |= ST_NOEXEC;
- else if (__strcmp (opt, "nodev") == 0)
+ else if (strcmp (opt, "nodev") == 0)
buf->f_flag |= ST_NODEV;
- else if (__strcmp (opt, "sync") == 0)
+ else if (strcmp (opt, "sync") == 0)
buf->f_flag |= ST_SYNCHRONOUS;
- else if (__strcmp (opt, "mand") == 0)
+ else if (strcmp (opt, "mand") == 0)
buf->f_flag |= ST_MANDLOCK;
- else if (__strcmp (opt, "noatime") == 0)
+ else if (strcmp (opt, "noatime") == 0)
buf->f_flag |= ST_NOATIME;
- else if (__strcmp (opt, "nodiratime") == 0)
+ else if (strcmp (opt, "nodiratime") == 0)
buf->f_flag |= ST_NODIRATIME;
+#endif
/* We can stop looking for more entries. */
break;
@@ -115,7 +104,7 @@ extern char *__strsep (char **__restrict __stringp,
}
/* Close the file. */
- __endmntent (mtab);
+ endmntent (mtab);
}
__set_errno (save_errno);
diff --git a/libc/misc/statfs/statfs64.c b/libc/misc/statfs/statfs64.c
index 9d326f1f8..8574c17af 100644
--- a/libc/misc/statfs/statfs64.c
+++ b/libc/misc/statfs/statfs64.c
@@ -17,35 +17,23 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <features.h>
-#undef __statfs64
-#undef __statfs
-
-#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 <string.h>
#include <stddef.h>
#include <sys/statfs.h>
-#if defined __UCLIBC_HAS_LFS__
-#undef statfs64
+
+libc_hidden_proto(memcpy)
+libc_hidden_proto(statfs)
+
/* Return information about the filesystem on which FILE resides. */
-int attribute_hidden __statfs64 (const char *file, struct statfs64 *buf)
+libc_hidden_proto(statfs64)
+int statfs64 (const char *file, struct statfs64 *buf)
{
struct statfs buf32;
- if (__statfs (file, &buf32) < 0)
+ if (statfs (file, &buf32) < 0)
return -1;
buf->f_type = buf32.f_type;
@@ -57,10 +45,8 @@ int attribute_hidden __statfs64 (const char *file, struct statfs64 *buf)
buf->f_ffree = buf32.f_ffree;
buf->f_fsid = buf32.f_fsid;
buf->f_namelen = buf32.f_namelen;
- __memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
+ memcpy (buf->f_spare, buf32.f_spare, sizeof (buf32.f_spare));
return 0;
}
-strong_alias(__statfs64,statfs64)
-
-#endif
+libc_hidden_def(statfs64)
diff --git a/libc/misc/statfs/statvfs.c b/libc/misc/statfs/statvfs.c
index a7c553fb6..6c3bf7c56 100644
--- a/libc/misc/statfs/statvfs.c
+++ b/libc/misc/statfs/statvfs.c
@@ -18,8 +18,6 @@
02111-1307 USA. */
#include <features.h>
-
-#define __USE_GNU
#include <errno.h>
#include <mntent.h>
#include <paths.h>
@@ -29,16 +27,26 @@
#include <sys/statfs.h>
#include <sys/statvfs.h>
+libc_hidden_proto(memset)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strsep)
+libc_hidden_proto(setmntent)
+libc_hidden_proto(getmntent_r)
+libc_hidden_proto(endmntent)
+
+libc_hidden_proto(statfs)
+libc_hidden_proto(stat)
+
int statvfs (const char *file, struct statvfs *buf)
{
struct statfs fsbuf;
struct stat st;
/* Get as much information as possible from the system. */
- if (__statfs (file, &fsbuf) < 0)
+ if (statfs (file, &fsbuf) < 0)
return -1;
-#define STAT(st) __stat (file, st)
+#define STAT(st) stat (file, st)
#include "internal_statvfs.c"
/* We signal success if the statfs call succeeded. */
diff --git a/libc/misc/statfs/statvfs64.c b/libc/misc/statfs/statvfs64.c
index dc2458f5f..4a71989ec 100644
--- a/libc/misc/statfs/statvfs64.c
+++ b/libc/misc/statfs/statvfs64.c
@@ -17,22 +17,8 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#include <features.h>
-
-#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 <errno.h>
#include <mntent.h>
#include <paths.h>
@@ -42,17 +28,28 @@
#include <sys/statfs.h>
#include <sys/statvfs.h>
+libc_hidden_proto(memset)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strsep)
+libc_hidden_proto(setmntent)
+libc_hidden_proto(getmntent_r)
+libc_hidden_proto(endmntent)
+
+#undef stat
+#define stat stat64
+libc_hidden_proto(statfs64)
+libc_hidden_proto(stat64)
-int statvfs (const char *file, struct statvfs *buf)
+int statvfs64 (const char *file, struct statvfs64 *buf)
{
- struct statfs fsbuf;
- struct stat st;
+ struct statfs64 fsbuf;
+ struct stat64 st;
/* Get as much information as possible from the system. */
- if (__statfs (file, &fsbuf) < 0)
+ if (statfs64 (file, &fsbuf) < 0)
return -1;
-#define STAT(st) __stat (file, st)
+#define STAT(st) stat (file, st)
#include "internal_statvfs.c"
/* We signal success if the statfs call succeeded. */
diff --git a/libc/misc/syslog/Makefile.in b/libc/misc/syslog/Makefile.in
index c1cd2ee18..b1d87e85d 100644
--- a/libc/misc/syslog/Makefile.in
+++ b/libc/misc/syslog/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:=syslog.c
+CSRC := syslog.c
-MISC_SYSLOG_DIR:=$(top_srcdir)libc/misc/syslog
-MISC_SYSLOG_OUT:=$(top_builddir)libc/misc/syslog
+MISC_SYSLOG_DIR := $(top_srcdir)libc/misc/syslog
+MISC_SYSLOG_OUT := $(top_builddir)libc/misc/syslog
-MISC_SYSLOG_SRC:=$(patsubst %.c,$(MISC_SYSLOG_DIR)/%.c,$(CSRC))
-MISC_SYSLOG_OBJ:=$(patsubst %.c,$(MISC_SYSLOG_OUT)/%.o,$(CSRC))
+MISC_SYSLOG_SRC := $(patsubst %.c,$(MISC_SYSLOG_DIR)/%.c,$(CSRC))
+MISC_SYSLOG_OBJ := $(patsubst %.c,$(MISC_SYSLOG_OUT)/%.o,$(CSRC))
-libc-a-y+=$(MISC_SYSLOG_OBJ)
-libc-so-y+=$(MISC_SYSLOG_OBJ:.o=.os)
+libc-y += $(MISC_SYSLOG_OBJ)
-libc-multi-y+=$(MISC_SYSLOG_SRC)
-
-objclean-y+=misc_syslog_objclean
+objclean-y += misc_syslog_objclean
misc_syslog_objclean:
$(RM) $(MISC_SYSLOG_OUT)/*.{o,os}
diff --git a/libc/misc/syslog/syslog.c b/libc/misc/syslog/syslog.c
index a4bb56bfc..10b8e6e58 100644
--- a/libc/misc/syslog/syslog.c
+++ b/libc/misc/syslog/syslog.c
@@ -31,14 +31,6 @@
* SUCH DAMAGE.
*/
-#define ctime __ctime
-#define sigaction __sigaction
-#define connect __connect
-#define vsnprintf __vsnprintf
-
-#define __FORCE_GLIBC
-#define _GNU_SOURCE
-#include <features.h>
/*
* SYSLOG -- print message on log file
*
@@ -66,6 +58,8 @@
* - Major code cleanup.
*/
+#define __FORCE_GLIBC
+#include <features.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/file.h>
@@ -85,7 +79,30 @@
#include <ctype.h>
#include <signal.h>
-extern time_t __time (time_t *__timer) attribute_hidden;
+libc_hidden_proto(openlog)
+libc_hidden_proto(syslog)
+libc_hidden_proto(vsyslog)
+libc_hidden_proto(closelog)
+
+libc_hidden_proto(memset)
+libc_hidden_proto(memcpy)
+libc_hidden_proto(memmove)
+libc_hidden_proto(strchr)
+libc_hidden_proto(strlen)
+libc_hidden_proto(strncpy)
+libc_hidden_proto(open)
+/*libc_hidden_proto(fcntl)*/
+libc_hidden_proto(socket)
+libc_hidden_proto(close)
+libc_hidden_proto(write)
+libc_hidden_proto(getpid)
+libc_hidden_proto(ctime)
+libc_hidden_proto(sigaction)
+libc_hidden_proto(sigemptyset)
+libc_hidden_proto(connect)
+libc_hidden_proto(sprintf)
+libc_hidden_proto(vsnprintf)
+libc_hidden_proto(time)
#ifdef __UCLIBC_HAS_THREADS__
# include <pthread.h>
@@ -108,7 +125,7 @@ closelog_intern(int to_default)
{
LOCK;
if (LogFile != -1) {
- (void) __close(LogFile);
+ (void) close(LogFile);
}
LogFile = -1;
connected = 0;
@@ -131,8 +148,8 @@ sigpipe_handler (attribute_unused int sig)
/*
* OPENLOG -- open system log
*/
-void attribute_hidden
-__openlog( const char *ident, int logstat, int logfac )
+void
+openlog( const char *ident, int logstat, int logfac )
{
int logType = SOCK_DGRAM;
@@ -145,33 +162,33 @@ __openlog( const char *ident, int logstat, int logfac )
LogFacility = logfac;
if (LogFile == -1) {
SyslogAddr.sa_family = AF_UNIX;
- (void)__strncpy(SyslogAddr.sa_data, _PATH_LOG,
+ (void)strncpy(SyslogAddr.sa_data, _PATH_LOG,
sizeof(SyslogAddr.sa_data));
retry:
if (LogStat & LOG_NDELAY) {
- if ((LogFile = __socket(AF_UNIX, logType, 0)) == -1){
+ if ((LogFile = socket(AF_UNIX, logType, 0)) == -1){
UNLOCK;
return;
}
- /* __fcntl(LogFile, F_SETFD, 1); */
+ /* fcntl(LogFile, F_SETFD, 1); */
}
}
if (LogFile != -1 && !connected) {
if (connect(LogFile, &SyslogAddr, sizeof(SyslogAddr) -
- sizeof(SyslogAddr.sa_data) + __strlen(SyslogAddr.sa_data)) != -1)
+ sizeof(SyslogAddr.sa_data) + strlen(SyslogAddr.sa_data)) != -1)
{
connected = 1;
} else if (logType == SOCK_DGRAM) {
logType = SOCK_STREAM;
if (LogFile != -1) {
- __close(LogFile);
+ close(LogFile);
LogFile = -1;
}
goto retry;
} else {
if (LogFile != -1) {
- __close(LogFile);
+ close(LogFile);
LogFile = -1;
}
}
@@ -179,14 +196,14 @@ retry:
UNLOCK;
}
-strong_alias(__openlog,openlog)
+libc_hidden_def(openlog)
/*
* syslog, vsyslog --
* print message on log file; output is intended for syslogd(8).
*/
-void attribute_hidden
-__vsyslog( int pri, const char *fmt, va_list ap )
+void
+vsyslog( int pri, const char *fmt, va_list ap )
{
register char *p;
char *last_chr, *head_end, *end, *stdp;
@@ -197,7 +214,7 @@ __vsyslog( int pri, const char *fmt, va_list ap )
struct sigaction action, oldaction;
int sigpipe;
- __memset (&action, 0, sizeof (action));
+ memset (&action, 0, sizeof (action));
action.sa_handler = sigpipe_handler;
sigemptyset (&action.sa_mask);
sigpipe = sigaction (SIGPIPE, &action, &oldaction);
@@ -210,7 +227,7 @@ __vsyslog( int pri, const char *fmt, va_list ap )
if (!(LogMask & LOG_MASK(LOG_PRI(pri))) || (pri &~ (LOG_PRIMASK|LOG_FACMASK)))
goto getout;
if (LogFile < 0 || !connected)
- __openlog(LogTag, LogStat | LOG_NDELAY, 0);
+ openlog(LogTag, LogStat | LOG_NDELAY, 0);
/* Set default facility if none specified. */
if ((pri & LOG_FACMASK) == 0)
@@ -220,16 +237,16 @@ __vsyslog( int pri, const char *fmt, va_list ap )
* no longer than 64 characters plus length of the LogTag. So it's
* safe to test only LogTag and use normal sprintf everywhere else.
*/
- (void)__time(&now);
- stdp = p = tbuf + __sprintf(tbuf, "<%d>%.15s ", pri, ctime(&now) + 4);
+ (void)time(&now);
+ stdp = p = tbuf + sprintf(tbuf, "<%d>%.15s ", pri, ctime(&now) + 4);
if (LogTag) {
- if (__strlen(LogTag) < sizeof(tbuf) - 64)
- p += __sprintf(p, "%s", LogTag);
+ if (strlen(LogTag) < sizeof(tbuf) - 64)
+ p += sprintf(p, "%s", LogTag);
else
- p += __sprintf(p, "<BUFFER OVERRUN ATTEMPT>");
+ p += sprintf(p, "<BUFFER OVERRUN ATTEMPT>");
}
if (LogStat & LOG_PID)
- p += __sprintf(p, "[%d]", __getpid());
+ p += sprintf(p, "[%d]", getpid());
if (LogTag) {
*p++ = ':';
*p++ = ' ';
@@ -246,9 +263,9 @@ __vsyslog( int pri, const char *fmt, va_list ap )
p += vsnprintf(p, end - p, fmt, ap);
if (p >= end || p < head_end) { /* Returned -1 in case of error... */
static const char truncate_msg[12] = "[truncated] ";
- __memmove(head_end + sizeof(truncate_msg), head_end,
+ memmove(head_end + sizeof(truncate_msg), head_end,
end - head_end - sizeof(truncate_msg));
- __memcpy(head_end, truncate_msg, sizeof(truncate_msg));
+ memcpy(head_end, truncate_msg, sizeof(truncate_msg));
if (p < head_end) {
while (p < end && *p) {
p++;
@@ -264,14 +281,14 @@ __vsyslog( int pri, const char *fmt, va_list ap )
/* Output to stderr if requested. */
if (LogStat & LOG_PERROR) {
*last_chr = '\n';
- (void)__write(STDERR_FILENO, stdp, last_chr - stdp + 1);
+ (void)write(STDERR_FILENO, stdp, last_chr - stdp + 1);
}
/* Output the message to the local logger using NUL as a message delimiter. */
p = tbuf;
*last_chr = 0;
do {
- rc = __write(LogFile, p, last_chr + 1 - p);
+ rc = write(LogFile, p, last_chr + 1 - p);
if (rc < 0) {
if ((errno==EAGAIN) || (errno==EINTR))
rc=0;
@@ -292,12 +309,12 @@ __vsyslog( int pri, const char *fmt, va_list ap )
*/
/* should mode be `O_WRONLY | O_NOCTTY' ? -- Uli */
if (LogStat & LOG_CONS &&
- (fd = __open(_PATH_CONSOLE, O_WRONLY, 0)) >= 0) {
- p = __strchr(tbuf, '>') + 1;
+ (fd = open(_PATH_CONSOLE, O_WRONLY, 0)) >= 0) {
+ p = strchr(tbuf, '>') + 1;
last_chr[0] = '\r';
last_chr[1] = '\n';
- (void)__write(fd, p, last_chr - p + 2);
- (void)__close(fd);
+ (void)write(fd, p, last_chr - p + 2);
+ (void)close(fd);
}
getout:
@@ -306,28 +323,28 @@ getout:
sigaction (SIGPIPE, &oldaction,
(struct sigaction *) NULL);
}
-strong_alias(__vsyslog,vsyslog)
+libc_hidden_def(vsyslog)
-void attribute_hidden
-__syslog(int pri, const char *fmt, ...)
+void
+syslog(int pri, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
- __vsyslog(pri, fmt, ap);
+ vsyslog(pri, fmt, ap);
va_end(ap);
}
-strong_alias(__syslog,syslog)
+libc_hidden_def(syslog)
/*
* CLOSELOG -- close the system log
*/
-void attribute_hidden
-__closelog( void )
+void
+closelog( void )
{
closelog_intern(1);
}
-strong_alias(__closelog,closelog)
+libc_hidden_def(closelog)
/* setlogmask -- set the log mask level */
int setlogmask(int pmask)
diff --git a/libc/misc/sysvipc/Makefile.in b/libc/misc/sysvipc/Makefile.in
index 9a4446cb3..44707d643 100644
--- a/libc/misc/sysvipc/Makefile.in
+++ b/libc/misc/sysvipc/Makefile.in
@@ -1,69 +1,31 @@
# 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:=sem.c
-MOBJ1:=semget.o semctl.o semop.o
+CSRC := ftok.c
-MSRC2:=shm.c
-MOBJ2:=shmat.o shmctl.o shmdt.o shmget.o
+# multi source sem.c
+CSRC += semget.c semctl.c semop.c
-MSRC3:=msgq.c
-MOBJ3:=msgctl.o msgget.o msgrcv.o msgsnd.o
+# multi source shm.c
+CSRC += shmat.c shmctl.c shmdt.c shmget.c
-CSRC:=ftok.c
+# multi source msgq.c
+CSRC += msgctl.c msgget.c msgrcv.c msgsnd.c
-MISC_SYSVIPC_DIR:=$(top_srcdir)libc/misc/sysvipc
-MISC_SYSVIPC_OUT:=$(top_builddir)libc/misc/sysvipc
+MISC_SYSVIPC_DIR := $(top_srcdir)libc/misc/sysvipc
+MISC_SYSVIPC_OUT := $(top_builddir)libc/misc/sysvipc
-MISC_SYSVIPC_SRC:=$(patsubst %.c,$(MISC_SYSVIPC_DIR)/%.c,$(CSRC))
-MISC_SYSVIPC_OBJ:=$(patsubst %.c,$(MISC_SYSVIPC_OUT)/%.o,$(CSRC))
+MISC_SYSVIPC_SRC := $(patsubst %.c,$(MISC_SYSVIPC_DIR)/%.c,$(CSRC))
+MISC_SYSVIPC_OBJ := $(patsubst %.c,$(MISC_SYSVIPC_OUT)/%.o,$(CSRC))
-MISC_SYSVIPC_NO_MULTI:=$(MOBJ1) $(MOBJ3)
+libc-y += $(MISC_SYSVIPC_OBJ)
-MISC_SYSVIPC_MSRC1:=$(patsubst %.c,$(MISC_SYSVIPC_DIR)/%.c,$(MSRC1))
-MISC_SYSVIPC_MSRC2:=$(patsubst %.c,$(MISC_SYSVIPC_DIR)/%.c,$(MSRC2))
-MISC_SYSVIPC_MSRC3:=$(patsubst %.c,$(MISC_SYSVIPC_DIR)/%.c,$(MSRC3))
-MISC_SYSVIPC_MOBJ1:=$(patsubst %.o,$(MISC_SYSVIPC_OUT)/%.o,$(MOBJ1))
-MISC_SYSVIPC_MOBJ2:=$(patsubst %.o,$(MISC_SYSVIPC_OUT)/%.o,$(MOBJ2))
-MISC_SYSVIPC_MOBJ3:=$(patsubst %.o,$(MISC_SYSVIPC_OUT)/%.o,$(MOBJ3))
-
-MISC_SYSVIPC_MSRC:=$(MISC_SYSVIPC_MSRC1) $(MISC_SYSVIPC_MSRC2) $(MISC_SYSVIPC_MSRC3)
-MISC_SYSVIPC_MOBJ:=$(MISC_SYSVIPC_MOBJ1) $(MISC_SYSVIPC_MOBJ2) $(MISC_SYSVIPC_MOBJ3)
-
-MISC_SYSVIPC_DEF:=$(patsubst %,-DL_%,$(subst .o,,$(notdir $(MISC_SYSVIPC_MOBJ))))
-
-MISC_SYSVIPC_OBJS:=$(MISC_SYSVIPC_OBJ) $(MISC_SYSVIPC_MOBJ)
-
-$(MISC_SYSVIPC_MOBJ1): $(MISC_SYSVIPC_MSRC1)
- $(compile.m)
-
-$(MISC_SYSVIPC_MOBJ1:.o=.os): $(MISC_SYSVIPC_MSRC1)
- $(compile.m)
-
-$(MISC_SYSVIPC_MOBJ2): $(MISC_SYSVIPC_MSRC2)
- $(compile.m)
-
-$(MISC_SYSVIPC_MOBJ2:.o=.os): $(MISC_SYSVIPC_MSRC2)
- $(compile.m)
-
-$(MISC_SYSVIPC_MOBJ3): $(MISC_SYSVIPC_MSRC3)
- $(compile.m)
-
-$(MISC_SYSVIPC_MOBJ3:.o=.os): $(MISC_SYSVIPC_MSRC3)
- $(compile.m)
-
-libc-a-y+=$(MISC_SYSVIPC_OBJS)
-libc-so-y+=$(MISC_SYSVIPC_OBJS:.o=.os)
-
-CFLAGS-multi-y+=$(MISC_SYSVIPC_DEF)
-libc-multi-y+=$(MISC_SYSVIPC_SRC) $(MISC_SYSVIPC_MSRC)
-
-objclean-y+=misc_sysvipc_objclean
+objclean-y += misc_sysvipc_objclean
misc_sysvipc_objclean:
$(RM) $(MISC_SYSVIPC_OUT)/*.{o,os}
diff --git a/libc/misc/sysvipc/ftok.c b/libc/misc/sysvipc/ftok.c
index fd4021d3e..12627cad1 100644
--- a/libc/misc/sysvipc/ftok.c
+++ b/libc/misc/sysvipc/ftok.c
@@ -20,12 +20,14 @@
#include <sys/ipc.h>
#include <sys/stat.h>
+libc_hidden_proto(stat)
+
key_t ftok (const char *pathname, int proj_id)
{
struct stat st;
key_t key;
- if (__stat(pathname, &st) < 0)
+ if (stat(pathname, &st) < 0)
return (key_t) -1;
key = ((st.st_ino & 0xffff) | ((st.st_dev & 0xff) << 16)
diff --git a/libc/misc/sysvipc/ipc.h b/libc/misc/sysvipc/ipc.h
index 105232fea..ffc07daf9 100644
--- a/libc/misc/sysvipc/ipc.h
+++ b/libc/misc/sysvipc/ipc.h
@@ -1,14 +1,19 @@
#ifndef IPC_H
#define IPC_H
#include <syscall.h>
+#include <bits/wordsize.h>
-#define __IPC_64 0x100
+#if __WORDSIZE == 32
+# define __IPC_64 0x100
+#else
+# define __IPC_64 0x0
+#endif
#ifdef __NR_ipc
/* The actual system call: all functions are multiplexed by this. */
-extern int __syscall_ipc __P((unsigned int __call, int __first, int __second,
- int __third, void *__ptr)) attribute_hidden;
+extern int __syscall_ipc (unsigned int __call, int __first, int __second,
+ int __third, void *__ptr) attribute_hidden;
/* The codes for the functions to use the multiplexer `__syscall_ipc'. */
diff --git a/libc/misc/sysvipc/msgctl.c b/libc/misc/sysvipc/msgctl.c
new file mode 100644
index 000000000..480a54cbb
--- /dev/null
+++ b/libc/misc/sysvipc/msgctl.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_msgctl
+#include "msgq.c"
diff --git a/libc/misc/sysvipc/msgget.c b/libc/misc/sysvipc/msgget.c
new file mode 100644
index 000000000..f7e54d5c8
--- /dev/null
+++ b/libc/misc/sysvipc/msgget.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_msgget
+#include "msgq.c"
diff --git a/libc/misc/sysvipc/msgq.c b/libc/misc/sysvipc/msgq.c
index 758dbaa47..f56bb4e8a 100644
--- a/libc/misc/sysvipc/msgq.c
+++ b/libc/misc/sysvipc/msgq.c
@@ -7,7 +7,7 @@
#ifdef __NR_msgctl
#define __NR___libc_msgctl __NR_msgctl
-_syscall3(int, __libc_msgctl, int, msqid, int, cmd, struct msqid_ds *, buf);
+static inline _syscall3(int, __libc_msgctl, int, msqid, int, cmd, struct msqid_ds *, buf);
#endif
/* Message queue control operation. */
int msgctl(int msqid, int cmd, struct msqid_ds *buf)
diff --git a/libc/misc/sysvipc/msgrcv.c b/libc/misc/sysvipc/msgrcv.c
new file mode 100644
index 000000000..a85e52a99
--- /dev/null
+++ b/libc/misc/sysvipc/msgrcv.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_msgrcv
+#include "msgq.c"
diff --git a/libc/misc/sysvipc/msgsnd.c b/libc/misc/sysvipc/msgsnd.c
new file mode 100644
index 000000000..9f09d1fd4
--- /dev/null
+++ b/libc/misc/sysvipc/msgsnd.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_msgsnd
+#include "msgq.c"
diff --git a/libc/misc/sysvipc/semctl.c b/libc/misc/sysvipc/semctl.c
new file mode 100644
index 000000000..df62a76e3
--- /dev/null
+++ b/libc/misc/sysvipc/semctl.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_semctl
+#include "sem.c"
diff --git a/libc/misc/sysvipc/semget.c b/libc/misc/sysvipc/semget.c
new file mode 100644
index 000000000..94d0b5dad
--- /dev/null
+++ b/libc/misc/sysvipc/semget.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_semget
+#include "sem.c"
diff --git a/libc/misc/sysvipc/semop.c b/libc/misc/sysvipc/semop.c
new file mode 100644
index 000000000..0c67f62f3
--- /dev/null
+++ b/libc/misc/sysvipc/semop.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_semop
+#include "sem.c"
diff --git a/libc/misc/sysvipc/shm.c b/libc/misc/sysvipc/shm.c
index 20e28d3b1..a466de921 100644
--- a/libc/misc/sysvipc/shm.c
+++ b/libc/misc/sysvipc/shm.c
@@ -17,8 +17,8 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-/* SHMLBA uses it */
-#define __getpagesize __getpagesize_internal
+/* SHMLBA uses it on most of the archs (not mips) */
+#define __getpagesize getpagesize
#include <stdlib.h>
#include <errno.h>
@@ -30,12 +30,16 @@
/* Attach the shared memory segment associated with SHMID to the data
segment of the calling process. SHMADDR and SHMFLG determine how
and where the segment is attached. */
-#if defined (__alpha__)
-#define __NR_shmat __NR_osf_shmat
+#if defined(__NR_osf_shmat)
+# define __NR_shmat __NR_osf_shmat
#endif
#ifdef __NR_shmat
_syscall3(void *, shmat, int, shmid, const void *,shmaddr, int, shmflg);
#else
+/* psm: don't remove this, else mips will fail */
+#include <unistd.h>
+libc_hidden_proto(getpagesize)
+
void * shmat (int shmid, const void *shmaddr, int shmflg)
{
int retval;
@@ -52,7 +56,7 @@ void * shmat (int shmid, const void *shmaddr, int shmflg)
/* Provide operations to control over shared memory segments. */
#ifdef __NR_shmctl
#define __NR___libc_shmctl __NR_shmctl
-_syscall3(int, __libc_shmctl, int, shmid, int, cmd, struct shmid_ds *, buf);
+static inline _syscall3(int, __libc_shmctl, int, shmid, int, cmd, struct shmid_ds *, buf);
#endif
int shmctl(int shmid, int cmd, struct shmid_ds *buf)
{
diff --git a/libc/misc/sysvipc/shmat.c b/libc/misc/sysvipc/shmat.c
new file mode 100644
index 000000000..d6cd22a59
--- /dev/null
+++ b/libc/misc/sysvipc/shmat.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_shmat
+#include "shm.c"
diff --git a/libc/misc/sysvipc/shmctl.c b/libc/misc/sysvipc/shmctl.c
new file mode 100644
index 000000000..90fab5a25
--- /dev/null
+++ b/libc/misc/sysvipc/shmctl.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_shmctl
+#include "shm.c"
diff --git a/libc/misc/sysvipc/shmdt.c b/libc/misc/sysvipc/shmdt.c
new file mode 100644
index 000000000..078334136
--- /dev/null
+++ b/libc/misc/sysvipc/shmdt.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_shmdt
+#include "shm.c"
diff --git a/libc/misc/sysvipc/shmget.c b/libc/misc/sysvipc/shmget.c
new file mode 100644
index 000000000..4778e3619
--- /dev/null
+++ b/libc/misc/sysvipc/shmget.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_shmget
+#include "shm.c"
diff --git a/libc/misc/ttyent/Makefile.in b/libc/misc/ttyent/Makefile.in
index eff772546..288a4c09b 100644
--- a/libc/misc/ttyent/Makefile.in
+++ b/libc/misc/ttyent/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:=getttyent.c
+CSRC := getttyent.c
-MISC_TTYENT_DIR:=$(top_srcdir)libc/misc/ttyent
-MISC_TTYENT_OUT:=$(top_builddir)libc/misc/ttyent
+MISC_TTYENT_DIR := $(top_srcdir)libc/misc/ttyent
+MISC_TTYENT_OUT := $(top_builddir)libc/misc/ttyent
-MISC_TTYENT_SRC:=$(patsubst %.c,$(MISC_TTYENT_DIR)/%.c,$(CSRC))
-MISC_TTYENT_OBJ:=$(patsubst %.c,$(MISC_TTYENT_OUT)/%.o,$(CSRC))
+MISC_TTYENT_SRC := $(patsubst %.c,$(MISC_TTYENT_DIR)/%.c,$(CSRC))
+MISC_TTYENT_OBJ := $(patsubst %.c,$(MISC_TTYENT_OUT)/%.o,$(CSRC))
-libc-a-y+=$(MISC_TTYENT_OBJ)
-libc-so-y+=$(MISC_TTYENT_OBJ:.o=.os)
+libc-y += $(MISC_TTYENT_OBJ)
-libc-multi-y+=$(MISC_TTYENT_SRC)
-
-objclean-y+=misc_ttyent_objclean
+objclean-y += misc_ttyent_objclean
misc_ttyent_objclean:
$(RM) $(MISC_TTYENT_OUT)/*.{o,os}
diff --git a/libc/misc/ttyent/getttyent.c b/libc/misc/ttyent/getttyent.c
index 9b83b6ede..e9cc9be2a 100644
--- a/libc/misc/ttyent/getttyent.c
+++ b/libc/misc/ttyent/getttyent.c
@@ -27,11 +27,6 @@
* SUCH DAMAGE.
*/
-#define __fsetlocking __fsetlocking_internal
-#define rewind __rewind
-#define fgets_unlocked __fgets_unlocked
-
-#define _GNU_SOURCE
#include <features.h>
#include <ttyent.h>
#include <stdio.h>
@@ -43,7 +38,22 @@
#include <pthread.h>
#endif
-extern int __getc_unlocked (FILE *__stream) attribute_hidden;
+libc_hidden_proto(strchr)
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strncmp)
+libc_hidden_proto(__fsetlocking)
+libc_hidden_proto(rewind)
+libc_hidden_proto(fgets_unlocked)
+libc_hidden_proto(getc_unlocked)
+libc_hidden_proto(__fgetc_unlocked)
+libc_hidden_proto(fopen)
+libc_hidden_proto(fclose)
+libc_hidden_proto(abort)
+#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_b_loc)
+#else
+libc_hidden_proto(__ctype_b)
+#endif
static char zapchar;
static FILE *tf;
@@ -89,10 +99,11 @@ static char * skip(register char *p)
static char * value(register char *p)
{
- return ((p = __strchr(p, '=')) ? ++p : NULL);
+ return ((p = strchr(p, '=')) ? ++p : NULL);
}
-int attribute_hidden __setttyent(void)
+libc_hidden_proto(setttyent)
+int setttyent(void)
{
if (tf) {
@@ -107,15 +118,16 @@ int attribute_hidden __setttyent(void)
}
return (0);
}
-strong_alias(__setttyent,setttyent)
+libc_hidden_def(setttyent)
-struct ttyent attribute_hidden * __getttyent(void)
+libc_hidden_proto(getttyent)
+struct ttyent * getttyent(void)
{
register int c;
register char *p;
static char *line = NULL;
- if (!tf && !__setttyent())
+ if (!tf && !setttyent())
return (NULL);
if (!line) {
@@ -132,8 +144,8 @@ struct ttyent attribute_hidden * __getttyent(void)
return (NULL);
}
/* skip lines that are too big */
- if (!__strchr(p, '\n')) {
- while ((c = __getc_unlocked(tf)) != '\n' && c != EOF)
+ if (!strchr(p, '\n')) {
+ while ((c = getc_unlocked(tf)) != '\n' && c != EOF)
;
continue;
}
@@ -158,8 +170,8 @@ struct ttyent attribute_hidden * __getttyent(void)
tty.ty_status = 0;
tty.ty_window = NULL;
-#define scmp(e) !__strncmp(p, e, sizeof(e) - 1) && isspace(p[sizeof(e) - 1])
-#define vcmp(e) !__strncmp(p, e, sizeof(e) - 1) && p[sizeof(e) - 1] == '='
+#define scmp(e) !strncmp(p, e, sizeof(e) - 1) && isspace(p[sizeof(e) - 1])
+#define vcmp(e) !strncmp(p, e, sizeof(e) - 1) && p[sizeof(e) - 1] == '='
for (; *p; p = skip(p)) {
if (scmp(_TTYS_OFF))
tty.ty_status &= ~TTY_ON;
@@ -181,13 +193,14 @@ struct ttyent attribute_hidden * __getttyent(void)
tty.ty_comment = p;
if (*p == 0)
tty.ty_comment = 0;
- if ((p = __strchr(p, '\n')))
+ if ((p = strchr(p, '\n')))
*p = '\0';
return (&tty);
}
-strong_alias(__getttyent,getttyent)
+libc_hidden_def(getttyent)
-int attribute_hidden __endttyent(void)
+libc_hidden_proto(endttyent)
+int endttyent(void)
{
int rval;
@@ -198,16 +211,16 @@ int attribute_hidden __endttyent(void)
}
return (1);
}
-strong_alias(__endttyent,endttyent)
+libc_hidden_def(endttyent)
-struct ttyent * getttynam(const char *tty)
+struct ttyent * getttynam(const char *_tty)
{
register struct ttyent *t;
- __setttyent();
- while ((t = __getttyent()))
- if (!__strcmp(tty, t->ty_name))
+ setttyent();
+ while ((t = getttyent()))
+ if (!strcmp(_tty, t->ty_name))
break;
- __endttyent();
+ endttyent();
return (t);
}
diff --git a/libc/misc/utmp/Makefile.in b/libc/misc/utmp/Makefile.in
index 2a0fe0f13..5e584372c 100644
--- a/libc/misc/utmp/Makefile.in
+++ b/libc/misc/utmp/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:=utent.c wtent.c
+CSRC := utent.c wtent.c
-MISC_UTMP_DIR:=$(top_srcdir)libc/misc/utmp
-MISC_UTMP_OUT:=$(top_builddir)libc/misc/utmp
+MISC_UTMP_DIR := $(top_srcdir)libc/misc/utmp
+MISC_UTMP_OUT := $(top_builddir)libc/misc/utmp
-MISC_UTMP_SRC:=$(patsubst %.c,$(MISC_UTMP_DIR)/%.c,$(CSRC))
-MISC_UTMP_OBJ:=$(patsubst %.c,$(MISC_UTMP_OUT)/%.o,$(CSRC))
+MISC_UTMP_SRC := $(patsubst %.c,$(MISC_UTMP_DIR)/%.c,$(CSRC))
+MISC_UTMP_OBJ := $(patsubst %.c,$(MISC_UTMP_OUT)/%.o,$(CSRC))
-libc-a-y+=$(MISC_UTMP_OBJ)
-libc-so-y+=$(MISC_UTMP_OBJ:.o=.os)
+libc-y += $(MISC_UTMP_OBJ)
-libc-multi-y+=$(MISC_UTMP_SRC)
-
-objclean-y+=misc_utmp_objclean
+objclean-y += misc_utmp_objclean
misc_utmp_objclean:
$(RM) $(MISC_UTMP_OUT)/*.{o,os}
diff --git a/libc/misc/utmp/utent.c b/libc/misc/utmp/utent.c
index 3ad5bc828..597307738 100644
--- a/libc/misc/utmp/utent.c
+++ b/libc/misc/utmp/utent.c
@@ -20,7 +20,16 @@
#include <string.h>
#include <utmp.h>
-
+libc_hidden_proto(strcmp)
+libc_hidden_proto(strdup)
+libc_hidden_proto(strncmp)
+libc_hidden_proto(read)
+libc_hidden_proto(write)
+libc_hidden_proto(open)
+libc_hidden_proto(fcntl)
+libc_hidden_proto(close)
+libc_hidden_proto(lseek)
+libc_hidden_proto(setutent)
#ifdef __UCLIBC_HAS_THREADS__
# include <pthread.h>
@@ -37,61 +46,62 @@ static struct utmp static_utmp;
static const char default_file_name[] = _PATH_UTMP;
static const char *static_ut_name = (const char *) default_file_name;
-void attribute_hidden __setutent(void)
+void setutent(void)
{
int ret;
LOCK;
if (static_fd == -1) {
- if ((static_fd = __open(static_ut_name, O_RDWR)) < 0) {
- if ((static_fd = __open(static_ut_name, O_RDONLY)) < 0) {
+ if ((static_fd = open(static_ut_name, O_RDWR)) < 0) {
+ if ((static_fd = open(static_ut_name, O_RDONLY)) < 0) {
goto bummer;
}
}
/* Make sure the file will be closed on exec() */
- ret = __fcntl(static_fd, F_GETFD, 0);
+ ret = fcntl(static_fd, F_GETFD, 0);
if (ret >= 0) {
- ret = __fcntl(static_fd, F_GETFD, 0);
+ ret = fcntl(static_fd, F_SETFD, ret | FD_CLOEXEC);
}
if (ret < 0) {
bummer:
- UNLOCK;
static_fd = -1;
- __close(static_fd);
+ close(static_fd);
+unlock_and_ret:
+ UNLOCK;
return;
}
}
- __lseek(static_fd, 0, SEEK_SET);
- UNLOCK;
- return;
+ lseek(static_fd, 0, SEEK_SET);
+ goto unlock_and_ret;
}
-strong_alias(__setutent,setutent)
+libc_hidden_def(setutent)
static struct utmp *__getutent(int utmp_fd)
{
+ struct utmp *ret = NULL;
+
if (utmp_fd == -1) {
- __setutent();
+ setutent();
}
if (utmp_fd == -1) {
return NULL;
}
LOCK;
- if (__read(utmp_fd, (char *) &static_utmp, sizeof(struct utmp)) != sizeof(struct utmp))
+ if (read(utmp_fd, (char *) &static_utmp, sizeof(struct utmp)) == sizeof(struct utmp))
{
- return NULL;
+ ret = &static_utmp;
}
UNLOCK;
- return &static_utmp;
+ return ret;
}
void endutent(void)
{
LOCK;
- if (static_fd != -1) {
- __close(static_fd);
- }
+ if (static_fd != -1)
+ close(static_fd);
static_fd = -1;
UNLOCK;
}
@@ -103,7 +113,8 @@ struct utmp *getutent(void)
}
/* Locking is done in __getutent */
-struct utmp attribute_hidden *__getutid (const struct utmp *utmp_entry)
+libc_hidden_proto(getutid)
+struct utmp *getutid (const struct utmp *utmp_entry)
{
struct utmp *lutmp;
@@ -120,7 +131,7 @@ struct utmp attribute_hidden *__getutid (const struct utmp *utmp_entry)
utmp_entry->ut_type == DEAD_PROCESS ||
utmp_entry->ut_type == LOGIN_PROCESS ||
utmp_entry->ut_type == USER_PROCESS) &&
- !__strncmp(lutmp->ut_id, utmp_entry->ut_id, sizeof(lutmp->ut_id)))
+ !strncmp(lutmp->ut_id, utmp_entry->ut_id, sizeof(lutmp->ut_id)))
{
return lutmp;
}
@@ -128,7 +139,7 @@ struct utmp attribute_hidden *__getutid (const struct utmp *utmp_entry)
return NULL;
}
-strong_alias(__getutid,getutid)
+libc_hidden_def(getutid)
/* Locking is done in __getutent */
struct utmp *getutline(const struct utmp *utmp_entry)
@@ -137,7 +148,7 @@ struct utmp *getutline(const struct utmp *utmp_entry)
while ((lutmp = __getutent(static_fd)) != NULL) {
if ((lutmp->ut_type == USER_PROCESS || lutmp->ut_type == LOGIN_PROCESS) &&
- !__strcmp(lutmp->ut_line, utmp_entry->ut_line))
+ !strcmp(lutmp->ut_line, utmp_entry->ut_line))
{
return lutmp;
}
@@ -151,17 +162,14 @@ struct utmp *pututline (const struct utmp *utmp_entry)
LOCK;
/* Ignore the return value. That way, if they've already positioned
the file pointer where they want it, everything will work out. */
- __lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR);
-
- if (__getutid(utmp_entry) != NULL) {
- __lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR);
- if (__write(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp))
- return NULL;
- } else {
- __lseek(static_fd, (off_t) 0, SEEK_END);
- if (__write(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp))
- return NULL;
- }
+ lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR);
+
+ if (getutid(utmp_entry) != NULL)
+ lseek(static_fd, (off_t) - sizeof(struct utmp), SEEK_CUR);
+ else
+ lseek(static_fd, (off_t) 0, SEEK_END);
+ if (write(static_fd, utmp_entry, sizeof(struct utmp)) != sizeof(struct utmp))
+ utmp_entry = NULL;
UNLOCK;
return (struct utmp *)utmp_entry;
@@ -173,7 +181,7 @@ int utmpname (const char *new_ut_name)
if (new_ut_name != NULL) {
if (static_ut_name != default_file_name)
free((char *)static_ut_name);
- static_ut_name = __strdup(new_ut_name);
+ static_ut_name = strdup(new_ut_name);
if (static_ut_name == NULL) {
/* We should probably whine about out-of-memory
* errors here... Instead just reset to the default */
@@ -182,7 +190,8 @@ int utmpname (const char *new_ut_name)
}
if (static_fd != -1)
- __close(static_fd);
+ close(static_fd);
+ static_fd = -1;
UNLOCK;
return 0;
}
diff --git a/libc/misc/utmp/wtent.c b/libc/misc/utmp/wtent.c
index 35947f19e..0378070e7 100644
--- a/libc/misc/utmp/wtent.c
+++ b/libc/misc/utmp/wtent.c
@@ -1,23 +1,10 @@
-/* wtmp support rubbish (i.e. complete crap)
+/*
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
- * Written by Erik Andersen <andersee@debian.org>
- *
- * This 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.
- *
- * This 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 this library; see the file COPYING.LIB. If not,
- * write to the Free Software Foundation, Inc., 675 Mass Ave,
- * Cambridge, MA 02139, USA. */
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
-#define gettimeofday __gettimeofday
+/* wtmp support rubbish (i.e. complete crap) */
#include <string.h>
#include <sys/time.h>
@@ -27,36 +14,45 @@
#include <fcntl.h>
#include <sys/file.h>
+#if 0
+libc_hidden_proto(memset)
+libc_hidden_proto(strncpy)
+libc_hidden_proto(updwtmp)
+#endif
+libc_hidden_proto(open)
+libc_hidden_proto(write)
+libc_hidden_proto(close)
+libc_hidden_proto(lockf)
+libc_hidden_proto(gettimeofday)
#if 0
/* This is enabled in uClibc/libutil/logwtmp.c */
void logwtmp (const char *line, const char *name, const char *host)
{
struct utmp lutmp;
- __memset (&(lutmp), 0, sizeof (struct utmp));
+ memset (&(lutmp), 0, sizeof (struct utmp));
lutmp.ut_type = (name && *name)? USER_PROCESS : DEAD_PROCESS;
lutmp.ut_pid = __getpid();
- __strncpy(lutmp.ut_line, line, sizeof(lutmp.ut_line)-1);
- __strncpy(lutmp.ut_name, name, sizeof(lutmp.ut_name)-1);
- __strncpy(lutmp.ut_host, host, sizeof(lutmp.ut_host)-1);
+ strncpy(lutmp.ut_line, line, sizeof(lutmp.ut_line)-1);
+ strncpy(lutmp.ut_name, name, sizeof(lutmp.ut_name)-1);
+ strncpy(lutmp.ut_host, host, sizeof(lutmp.ut_host)-1);
gettimeofday(&(lutmp.ut_tv), NULL);
updwtmp(_PATH_WTMP, &(lutmp));
}
#endif
-extern void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
+void updwtmp(const char *wtmp_file, const struct utmp *lutmp)
{
int fd;
- fd = __open(wtmp_file, O_APPEND | O_WRONLY, 0);
+ fd = open(wtmp_file, O_APPEND | O_WRONLY, 0);
if (fd >= 0) {
- if (__lockf(fd, F_LOCK, 0)==0) {
- __write(fd, (const char *) lutmp, sizeof(struct utmp));
- __lockf(fd, F_ULOCK, 0);
- __close(fd);
+ if (lockf(fd, F_LOCK, 0)==0) {
+ write(fd, (const char *) lutmp, sizeof(struct utmp));
+ lockf(fd, F_ULOCK, 0);
+ close(fd);
}
}
}
-
diff --git a/libc/misc/wchar/Makefile.in b/libc/misc/wchar/Makefile.in
index 9059d71d8..64171eb96 100644
--- a/libc/misc/wchar/Makefile.in
+++ b/libc/misc/wchar/Makefile.in
@@ -1,7 +1,7 @@
# 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.
#
@@ -17,35 +17,24 @@
# wcsftime
#
-MSRC:=wchar.c
-MOBJ:= btowc.o wctob.o mbsinit.o mbrlen.o mbrtowc.o wcrtomb.o mbsrtowcs.o \
- wcsrtombs.o _wchar_utf8sntowcs.o _wchar_wcsntoutf8s.o \
- __mbsnrtowcs.o __wcsnrtombs.o wcwidth.o wcswidth.o
+# multi source wchar.c
+CSRC := btowc.c wctob.c mbsinit.c mbrlen.c mbrtowc.c wcrtomb.c mbsrtowcs.c \
+ wcsrtombs.c _wchar_utf8sntowcs.c _wchar_wcsntoutf8s.c \
+ mbsnrtowcs.c wcsnrtombs.c wcwidth.c wcswidth.c
ifeq ($(UCLIBC_HAS_LOCALE),y)
-MOBJ+=iconv.o
+CSRC += iconv.c
endif
-MISC_WCHAR_DIR:=$(top_srcdir)libc/misc/wchar
-MISC_WCHAR_OUT:=$(top_builddir)libc/misc/wchar
+MISC_WCHAR_DIR := $(top_srcdir)libc/misc/wchar
+MISC_WCHAR_OUT := $(top_builddir)libc/misc/wchar
-MISC_WCHAR_MSRC:=$(MISC_WCHAR_DIR)/$(MSRC)
-MISC_WCHAR_MOBJ:=$(patsubst %.o,$(MISC_WCHAR_OUT)/%.o,$(MOBJ))
-MISC_WCHAR_DEF:=$(patsubst %,-DL_%,$(subst .o,,$(notdir $(MISC_WCHAR_MOBJ))))
+MISC_WCHAR_SRC := $(patsubst %.c,$(MISC_WCHAR_DIR)/%.c,$(CSRC))
+MISC_WCHAR_OBJ := $(patsubst %.c,$(MISC_WCHAR_OUT)/%.o,$(CSRC))
-$(MISC_WCHAR_MOBJ): $(MISC_WCHAR_MSRC)
- $(compile.m)
+libc-$(UCLIBC_HAS_WCHAR) += $(MISC_WCHAR_OBJ)
-$(MISC_WCHAR_MOBJ:.o=.os): $(MISC_WCHAR_MSRC)
- $(compile.m)
-
-libc-a-$(UCLIBC_HAS_WCHAR)+=$(MISC_WCHAR_MOBJ)
-libc-so-$(UCLIBC_HAS_WCHAR)+=$(MISC_WCHAR_MOBJ:.o=.os)
-
-CFLAGS-multi-$(UCLIBC_HAS_WCHAR)+=$(MISC_WCHAR_DEF)
-libc-multi-$(UCLIBC_HAS_WCHAR)+=$(MISC_WCHAR_MSRC)
-
-objclean-y+=misc_wchar_objclean
+objclean-y += misc_wchar_objclean
misc_wchar_objclean:
$(RM) $(MISC_WCHAR_OUT)/*.{o,os}
diff --git a/libc/misc/wchar/_wchar_utf8sntowcs.c b/libc/misc/wchar/_wchar_utf8sntowcs.c
new file mode 100644
index 000000000..a01990ebd
--- /dev/null
+++ b/libc/misc/wchar/_wchar_utf8sntowcs.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__wchar_utf8sntowcs
+#include "wchar.c"
diff --git a/libc/misc/wchar/_wchar_wcsntoutf8s.c b/libc/misc/wchar/_wchar_wcsntoutf8s.c
new file mode 100644
index 000000000..a63aa9114
--- /dev/null
+++ b/libc/misc/wchar/_wchar_wcsntoutf8s.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__wchar_wcsntoutf8s
+#include "wchar.c"
diff --git a/libc/misc/wchar/btowc.c b/libc/misc/wchar/btowc.c
new file mode 100644
index 000000000..d5e60ce6c
--- /dev/null
+++ b/libc/misc/wchar/btowc.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_btowc
+#include "wchar.c"
diff --git a/libc/misc/wchar/iconv.c b/libc/misc/wchar/iconv.c
new file mode 100644
index 000000000..e6e8ea881
--- /dev/null
+++ b/libc/misc/wchar/iconv.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_iconv
+#include "wchar.c"
diff --git a/libc/misc/wchar/mbrlen.c b/libc/misc/wchar/mbrlen.c
new file mode 100644
index 000000000..01bd31ebc
--- /dev/null
+++ b/libc/misc/wchar/mbrlen.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_mbrlen
+#include "wchar.c"
diff --git a/libc/misc/wchar/mbrtowc.c b/libc/misc/wchar/mbrtowc.c
new file mode 100644
index 000000000..76ce28a71
--- /dev/null
+++ b/libc/misc/wchar/mbrtowc.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_mbrtowc
+#include "wchar.c"
diff --git a/libc/misc/wchar/mbsinit.c b/libc/misc/wchar/mbsinit.c
new file mode 100644
index 000000000..23aaac50f
--- /dev/null
+++ b/libc/misc/wchar/mbsinit.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_mbsinit
+#include "wchar.c"
diff --git a/libc/misc/wchar/mbsnrtowcs.c b/libc/misc/wchar/mbsnrtowcs.c
new file mode 100644
index 000000000..9b407c1d8
--- /dev/null
+++ b/libc/misc/wchar/mbsnrtowcs.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_mbsnrtowcs
+#include "wchar.c"
diff --git a/libc/misc/wchar/mbsrtowcs.c b/libc/misc/wchar/mbsrtowcs.c
new file mode 100644
index 000000000..dd47a91a3
--- /dev/null
+++ b/libc/misc/wchar/mbsrtowcs.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_mbsrtowcs
+#include "wchar.c"
diff --git a/libc/misc/wchar/wchar.c b/libc/misc/wchar/wchar.c
index 2535b5fff..a795986e8 100644
--- a/libc/misc/wchar/wchar.c
+++ b/libc/misc/wchar/wchar.c
@@ -98,7 +98,6 @@
* Manuel
*/
-#define _GNU_SOURCE
#define _ISOC99_SOURCE
#include <errno.h>
#include <stddef.h>
@@ -112,6 +111,9 @@
#include <wchar.h>
#include <bits/uClibc_uwchar.h>
+#ifdef __UCLIBC_HAS_LOCALE__
+libc_hidden_proto(__global_locale)
+#endif
/**********************************************************************/
#ifdef __UCLIBC_HAS_LOCALE__
#ifdef __UCLIBC_MJN3_ONLY__
@@ -164,13 +166,6 @@
#define KUHN 1
-extern size_t __mbrtowc (wchar_t *__restrict __pwc,
- __const char *__restrict __s, size_t __n,
- mbstate_t *__p) attribute_hidden;
-
-extern size_t __wcrtomb (char *__restrict __s, wchar_t __wc,
- mbstate_t *__restrict __ps) attribute_hidden;
-
/* Implementation-specific work functions. */
extern size_t _wchar_utf8sntowcs(wchar_t *__restrict pwc, size_t wn,
@@ -180,20 +175,13 @@ extern size_t _wchar_utf8sntowcs(wchar_t *__restrict pwc, size_t wn,
extern size_t _wchar_wcsntoutf8s(char *__restrict s, size_t n,
const wchar_t **__restrict src, size_t wn) attribute_hidden;
-/* glibc extensions. */
-
-extern size_t __mbsnrtowcs(wchar_t *__restrict dst,
- const char **__restrict src,
- size_t NMC, size_t len, mbstate_t *__restrict ps) attribute_hidden;
-
-extern size_t __wcsnrtombs(char *__restrict dst,
- const wchar_t **__restrict src,
- size_t NWC, size_t len, mbstate_t *__restrict ps) attribute_hidden;
-
/**********************************************************************/
#ifdef L_btowc
-wint_t attribute_hidden __btowc(int c)
+libc_hidden_proto(mbrtowc)
+
+libc_hidden_proto(btowc)
+wint_t btowc(int c)
{
#ifdef __CTYPE_HAS_8_BIT_LOCALES
@@ -204,7 +192,7 @@ wint_t attribute_hidden __btowc(int c)
if (c != EOF) {
*buf = (unsigned char) c;
mbstate.__mask = 0; /* Initialize the mbstate. */
- if (__mbrtowc(&wc, buf, 1, &mbstate) <= 1) {
+ if (mbrtowc(&wc, buf, 1, &mbstate) <= 1) {
return wc;
}
}
@@ -223,7 +211,7 @@ wint_t attribute_hidden __btowc(int c)
#endif /* __CTYPE_HAS_8_BIT_LOCALES */
}
-strong_alias(__btowc,btowc)
+libc_hidden_def(btowc)
#endif
/**********************************************************************/
@@ -231,13 +219,15 @@ strong_alias(__btowc,btowc)
/* Note: We completely ignore ps in all currently supported conversions. */
+libc_hidden_proto(wcrtomb)
+
int wctob(wint_t c)
{
#ifdef __CTYPE_HAS_8_BIT_LOCALES
unsigned char buf[MB_LEN_MAX];
- return (__wcrtomb(buf, c, NULL) == 1) ? *buf : EOF;
+ return (wcrtomb(buf, c, NULL) == 1) ? *buf : EOF;
#else /* __CTYPE_HAS_8_BIT_LOCALES */
@@ -260,29 +250,36 @@ int wctob(wint_t c)
/**********************************************************************/
#ifdef L_mbsinit
-int attribute_hidden __mbsinit(const mbstate_t *ps)
+libc_hidden_proto(mbsinit)
+int mbsinit(const mbstate_t *ps)
{
return !ps || !ps->__mask;
}
-strong_alias(__mbsinit,mbsinit)
+libc_hidden_def(mbsinit)
#endif
/**********************************************************************/
#ifdef L_mbrlen
-size_t attribute_hidden __mbrlen(const char *__restrict s, size_t n, mbstate_t *__restrict ps)
+libc_hidden_proto(mbrtowc)
+
+libc_hidden_proto(mbrlen)
+size_t mbrlen(const char *__restrict s, size_t n, mbstate_t *__restrict ps)
{
static mbstate_t mbstate; /* Rely on bss 0-init. */
- return __mbrtowc(NULL, s, n, (ps != NULL) ? ps : &mbstate);
+ return mbrtowc(NULL, s, n, (ps != NULL) ? ps : &mbstate);
}
-strong_alias(__mbrlen,mbrlen)
+libc_hidden_def(mbrlen)
#endif
/**********************************************************************/
#ifdef L_mbrtowc
-size_t attribute_hidden __mbrtowc(wchar_t *__restrict pwc, const char *__restrict s,
+libc_hidden_proto(mbsnrtowcs)
+
+libc_hidden_proto(mbrtowc)
+size_t mbrtowc(wchar_t *__restrict pwc, const char *__restrict s,
size_t n, mbstate_t *__restrict ps)
{
static mbstate_t mbstate; /* Rely on bss 0-init. */
@@ -323,7 +320,7 @@ size_t attribute_hidden __mbrtowc(wchar_t *__restrict pwc, const char *__restric
#warning TODO: This adds a trailing nul!
#endif /* __UCLIBC_MJN3_ONLY__ */
- r = __mbsnrtowcs(wcbuf, &p, SIZE_MAX, 1, ps);
+ r = mbsnrtowcs(wcbuf, &p, SIZE_MAX, 1, ps);
if (((ssize_t) r) >= 0) {
if (pwc) {
@@ -332,16 +329,19 @@ size_t attribute_hidden __mbrtowc(wchar_t *__restrict pwc, const char *__restric
}
return (size_t) r;
}
-strong_alias(__mbrtowc,mbrtowc)
+libc_hidden_def(mbrtowc)
#endif
/**********************************************************************/
#ifdef L_wcrtomb
+libc_hidden_proto(wcsnrtombs)
+
/* Note: We completely ignore ps in all currently supported conversions. */
/* TODO: Check for valid state anyway? */
-size_t attribute_hidden __wcrtomb(register char *__restrict s, wchar_t wc,
+libc_hidden_proto(wcrtomb)
+size_t wcrtomb(register char *__restrict s, wchar_t wc,
mbstate_t *__restrict ps)
{
#ifdef __UCLIBC_MJN3_ONLY__
@@ -360,24 +360,27 @@ size_t attribute_hidden __wcrtomb(register char *__restrict s, wchar_t wc,
pwc = wcbuf;
wcbuf[0] = wc;
- r = __wcsnrtombs(s, &pwc, 1, MB_LEN_MAX, ps);
+ r = wcsnrtombs(s, &pwc, 1, MB_LEN_MAX, ps);
return (r != 0) ? r : 1;
}
-strong_alias(__wcrtomb,wcrtomb)
+libc_hidden_def(wcrtomb)
#endif
/**********************************************************************/
#ifdef L_mbsrtowcs
-size_t attribute_hidden __mbsrtowcs(wchar_t *__restrict dst, const char **__restrict src,
+libc_hidden_proto(mbsnrtowcs)
+
+libc_hidden_proto(mbsrtowcs)
+size_t mbsrtowcs(wchar_t *__restrict dst, const char **__restrict src,
size_t len, mbstate_t *__restrict ps)
{
static mbstate_t mbstate; /* Rely on bss 0-init. */
- return __mbsnrtowcs(dst, src, SIZE_MAX, len,
+ return mbsnrtowcs(dst, src, SIZE_MAX, len,
((ps != NULL) ? ps : &mbstate));
}
-strong_alias(__mbsrtowcs,mbsrtowcs)
+libc_hidden_def(mbsrtowcs)
#endif
/**********************************************************************/
@@ -387,12 +390,15 @@ strong_alias(__mbsrtowcs,mbsrtowcs)
* TODO: Check for valid state anyway? */
-size_t attribute_hidden __wcsrtombs(char *__restrict dst, const wchar_t **__restrict src,
+libc_hidden_proto(wcsnrtombs)
+
+libc_hidden_proto(wcsrtombs)
+size_t wcsrtombs(char *__restrict dst, const wchar_t **__restrict src,
size_t len, mbstate_t *__restrict ps)
{
- return __wcsnrtombs(dst, src, SIZE_MAX, len, ps);
+ return wcsnrtombs(dst, src, SIZE_MAX, len, ps);
}
-strong_alias(__wcsrtombs,wcsrtombs)
+libc_hidden_def(wcsrtombs)
#endif
/**********************************************************************/
@@ -686,11 +692,12 @@ size_t attribute_hidden _wchar_wcsntoutf8s(char *__restrict s, size_t n,
#endif
/**********************************************************************/
-#ifdef L___mbsnrtowcs
+#ifdef L_mbsnrtowcs
/* WARNING: We treat len as SIZE_MAX when dst is NULL! */
-size_t attribute_hidden __mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
+libc_hidden_proto(mbsnrtowcs)
+size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
size_t NMC, size_t len, mbstate_t *__restrict ps)
{
static mbstate_t mbstate; /* Rely on bss 0-init. */
@@ -788,18 +795,19 @@ size_t attribute_hidden __mbsnrtowcs(wchar_t *__restrict dst, const char **__res
}
return len - count;
}
-weak_alias(__mbsnrtowcs,mbsnrtowcs)
+libc_hidden_def(mbsnrtowcs)
#endif
/**********************************************************************/
-#ifdef L___wcsnrtombs
+#ifdef L_wcsnrtombs
/* WARNING: We treat len as SIZE_MAX when dst is NULL! */
/* Note: We completely ignore ps in all currently supported conversions.
* TODO: Check for valid state anyway? */
-size_t attribute_hidden __wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
+libc_hidden_proto(wcsnrtombs)
+size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
size_t NWC, size_t len, mbstate_t *__restrict ps)
{
const __uwchar_t *s;
@@ -907,12 +915,14 @@ size_t attribute_hidden __wcsnrtombs(char *__restrict dst, const wchar_t **__res
}
return len - count;
}
-weak_alias(__wcsnrtombs,wcsnrtombs)
+libc_hidden_def(wcsnrtombs)
#endif
/**********************************************************************/
#ifdef L_wcswidth
+libc_hidden_proto(wcswidth)
+
#ifdef __UCLIBC_MJN3_ONLY__
#warning REMINDER: If we start doing translit, wcwidth and wcswidth will need updating.
#warning TODO: Update wcwidth to match latest by Kuhn.
@@ -1027,7 +1037,9 @@ static const signed char new_wtbl[] = {
0, 2, 1, 2, 1, 0, 1,
};
-int attribute_hidden __wcswidth(const wchar_t *pwcs, size_t n)
+libc_hidden_proto(wcsnrtombs)
+
+int wcswidth(const wchar_t *pwcs, size_t n)
{
int h, l, m, count;
wchar_t wc;
@@ -1047,7 +1059,7 @@ int attribute_hidden __wcswidth(const wchar_t *pwcs, size_t n)
mbstate_t mbstate;
mbstate.__mask = 0; /* Initialize the mbstate. */
- if (__wcsnrtombs(NULL, &pwcs, n, SIZE_MAX, &mbstate) == ((size_t) - 1)) {
+ if (wcsnrtombs(NULL, &pwcs, n, SIZE_MAX, &mbstate) == ((size_t) - 1)) {
return -1;
}
}
@@ -1124,7 +1136,7 @@ int attribute_hidden __wcswidth(const wchar_t *pwcs, size_t n)
#else /* __UCLIBC_HAS_LOCALE__ */
-int attribute_hidden __wcswidth(const wchar_t *pwcs, size_t n)
+int wcswidth(const wchar_t *pwcs, size_t n)
{
int count;
wchar_t wc;
@@ -1147,17 +1159,17 @@ int attribute_hidden __wcswidth(const wchar_t *pwcs, size_t n)
#endif /* __UCLIBC_HAS_LOCALE__ */
-strong_alias(__wcswidth,wcswidth)
+libc_hidden_def(wcswidth)
#endif
/**********************************************************************/
#ifdef L_wcwidth
-extern int __wcswidth (__const wchar_t *__s, size_t __n) attribute_hidden;
+libc_hidden_proto(wcswidth)
int wcwidth(wchar_t wc)
{
- return __wcswidth(&wc, 1);
+ return wcswidth(&wc, 1);
}
#endif
@@ -1223,6 +1235,8 @@ enum {
*
*/
+extern const unsigned char __iconv_codesets[];
+libc_hidden_proto(__iconv_codesets)
const unsigned char __iconv_codesets[] =
"\x0a\xe0""WCHAR_T\x00" /* superset of UCS-4 but platform-endian */
#if __BYTE_ORDER == __BIG_ENDIAN
@@ -1255,6 +1269,9 @@ const unsigned char __iconv_codesets[] =
"\x08\x02""UTF-8\x00"
"\x0b\x01""US-ASCII\x00"
"\x07\x01""ASCII"; /* Must be last! (special case to save a nul) */
+libc_hidden_data_def(__iconv_codesets)
+
+libc_hidden_proto(strcasecmp)
static int find_codeset(const char *name)
{
@@ -1262,7 +1279,7 @@ static int find_codeset(const char *name)
int codeset;
for (s = __iconv_codesets ; *s ; s += *s) {
- if (!__strcasecmp(s+2, name)) {
+ if (!strcasecmp(s+2, name)) {
return s[1];
}
}
@@ -1275,7 +1292,7 @@ static int find_codeset(const char *name)
s = __LOCALE_DATA_CODESET_LIST;
do {
++codeset; /* Increment codeset first. */
- if (!__strcasecmp(__LOCALE_DATA_CODESET_LIST+*s, name)) {
+ if (!strcasecmp(__LOCALE_DATA_CODESET_LIST+*s, name)) {
return codeset;
}
} while (*++s);
diff --git a/libc/misc/wchar/wcrtomb.c b/libc/misc/wchar/wcrtomb.c
new file mode 100644
index 000000000..91eb3062d
--- /dev/null
+++ b/libc/misc/wchar/wcrtomb.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_wcrtomb
+#include "wchar.c"
diff --git a/libc/misc/wchar/wcsnrtombs.c b/libc/misc/wchar/wcsnrtombs.c
new file mode 100644
index 000000000..af9d6c33d
--- /dev/null
+++ b/libc/misc/wchar/wcsnrtombs.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_wcsnrtombs
+#include "wchar.c"
diff --git a/libc/misc/wchar/wcsrtombs.c b/libc/misc/wchar/wcsrtombs.c
new file mode 100644
index 000000000..e5b6c0b38
--- /dev/null
+++ b/libc/misc/wchar/wcsrtombs.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_wcsrtombs
+#include "wchar.c"
diff --git a/libc/misc/wchar/wcswidth.c b/libc/misc/wchar/wcswidth.c
new file mode 100644
index 000000000..3d955a21c
--- /dev/null
+++ b/libc/misc/wchar/wcswidth.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_wcswidth
+#include "wchar.c"
diff --git a/libc/misc/wchar/wctob.c b/libc/misc/wchar/wctob.c
new file mode 100644
index 000000000..88d31f5ad
--- /dev/null
+++ b/libc/misc/wchar/wctob.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_wctob
+#include "wchar.c"
diff --git a/libc/misc/wchar/wcwidth.c b/libc/misc/wchar/wcwidth.c
new file mode 100644
index 000000000..6c4a34476
--- /dev/null
+++ b/libc/misc/wchar/wcwidth.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_wcwidth
+#include "wchar.c"
diff --git a/libc/misc/wchar/wstdio.c b/libc/misc/wchar/wstdio.c
deleted file mode 100644
index 55e7fef6b..000000000
--- a/libc/misc/wchar/wstdio.c
+++ /dev/null
@@ -1,450 +0,0 @@
-/* Copyright (C) 2002 Manuel Novoa III
- *
- * This 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.
- *
- * This 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 this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION!
- *
- * Besides uClibc, I'm using this code in my libc for elks, which is
- * a 16-bit environment with a fairly limited compiler. It would make
- * things much easier for me if this file isn't modified unnecessarily.
- * In particular, please put any new or replacement functions somewhere
- * else, and modify the makefile to use your version instead.
- * Thanks. Manuel
- *
- * ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! */
-
-/* Nov 21, 2002
- *
- * Reimplement fputwc and fputws in terms of internal function _wstdio_fwrite.
- */
-
-
-
-
-/*
- * ANSI/ISO C99 says
-
- 9 Although both text and binary wide­oriented streams are conceptually sequences of wide
- characters, the external file associated with a wide­oriented stream is a sequence of
- multibyte characters, generalized as follows:
- --- Multibyte encodings within files may contain embedded null bytes (unlike multibyte
- encodings valid for use internal to the program).
- --- A file need not begin nor end in the initial shift state. 225)
-
- * How do we deal with this?
-
- * Should auto_wr_transition init the mbstate object?
-*/
-
-#define wcslen __wcslen
-#define wcsrtombs __wcsrtombs
-#define mbrtowc __mbrtowc
-#define wcrtomb __wcrtomb
-#define fflush_unlocked __fflush_unlocked
-
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <wchar.h>
-#include <limits.h>
-#include <errno.h>
-#include <assert.h>
-
-#ifndef __UCLIBC_HAS_THREADS__
-
-#ifdef __BCC__
-#define UNLOCKED_STREAM(RETURNTYPE,NAME,PARAMS,ARGS,STREAM) \
-asm(".text\nexport _" "NAME" "_unlocked\n_" "NAME" "_unlocked = _" "NAME"); \
-RETURNTYPE NAME PARAMS
-#else
-#define UNLOCKED_STREAM(RETURNTYPE,NAME,PARAMS,ARGS,STREAM) \
-strong_alias(NAME,NAME##_unlocked) \
-RETURNTYPE NAME PARAMS
-#endif
-
-#define UNLOCKED(RETURNTYPE,NAME,PARAMS,ARGS) \
- UNLOCKED_STREAM(RETURNTYPE,NAME,PARAMS,ARGS,stream)
-
-#ifdef __BCC__
-#define UNLOCKED_VOID_RETURN(NAME,PARAMS,ARGS) \
-asm(".text\nexport _" "NAME" "_unlocked\n_" "NAME" "_unlocked = _" "NAME"); \
-void NAME PARAMS
-#else
-#define UNLOCKED_VOID_RETURN(NAME,PARAMS,ARGS) \
-strong_alias(NAME,NAME##_unlocked) \
-void NAME PARAMS
-#endif
-
-#define __STDIO_THREADLOCK_OPENLIST
-#define __STDIO_THREADUNLOCK_OPENLIST
-
-#else /* __UCLIBC_HAS_THREADS__ */
-
-#include <pthread.h>
-
-#define UNLOCKED_STREAM(RETURNTYPE,NAME,PARAMS,ARGS,STREAM) \
-RETURNTYPE NAME PARAMS \
-{ \
- RETURNTYPE retval; \
- __STDIO_THREADLOCK(STREAM); \
- retval = NAME##_unlocked ARGS ; \
- __STDIO_THREADUNLOCK(STREAM); \
- return retval; \
-} \
-RETURNTYPE NAME##_unlocked PARAMS
-
-#define UNLOCKED(RETURNTYPE,NAME,PARAMS,ARGS) \
- UNLOCKED_STREAM(RETURNTYPE,NAME,PARAMS,ARGS,stream)
-
-#define UNLOCKED_VOID_RETURN(NAME,PARAMS,ARGS) \
-void NAME PARAMS \
-{ \
- __STDIO_THREADLOCK(stream); \
- NAME##_unlocked ARGS ; \
- __STDIO_THREADUNLOCK(stream); \
-} \
-void NAME##_unlocked PARAMS
-
-#define __STDIO_THREADLOCK_OPENLIST \
- __pthread_mutex_lock(&_stdio_openlist_lock)
-
-#define __STDIO_THREADUNLOCK_OPENLIST \
- __pthread_mutex_unlock(&_stdio_openlist_lock)
-
-#define __STDIO_THREADTRYLOCK_OPENLIST \
- __pthread_mutex_trylock(&_stdio_openlist_lock)
-
-#endif /* __UCLIBC_HAS_THREADS__ */
-
-#ifndef __STDIO_BUFFERS
-#error stdio buffers are currently required for wide i/o
-#endif
-
-/**********************************************************************/
-#ifdef L_fwide
-
-/* TODO: According to SUSv3 should return EBADF if invalid stream. */
-
-int fwide(register FILE *stream, int mode)
-{
- __STDIO_THREADLOCK(stream);
-
- if (mode && !(stream->modeflags & (__FLAG_WIDE|__FLAG_NARROW))) {
- stream->modeflags |= ((mode > 0) ? __FLAG_WIDE : __FLAG_NARROW);
- }
-
- mode = (stream->modeflags & __FLAG_WIDE)
- - (stream->modeflags & __FLAG_NARROW);
-
- __STDIO_THREADUNLOCK(stream);
-
- return mode;
-}
-
-#endif
-/**********************************************************************/
-#ifdef L_fgetwc
-
-static void munge_stream(register FILE *stream, unsigned char *buf)
-{
-#ifdef __STDIO_GETC_MACRO
- stream->bufgetc =
-#endif
-#ifdef __STDIO_PUTC_MACRO
- stream->bufputc =
-#endif
- stream->bufpos = stream->bufread = stream->bufend = stream->bufstart = buf;
-}
-
-UNLOCKED(wint_t,fgetwc,(register FILE *stream),(stream))
-{
- wint_t wi;
- wchar_t wc[1];
- int n;
- size_t r;
- unsigned char c[1];
- unsigned char sbuf[1];
-
- wi = WEOF; /* Prepare for failure. */
-
- if (stream->modeflags & __FLAG_NARROW) {
- stream->modeflags |= __FLAG_ERROR;
- __set_errno(EBADF);
- goto DONE;
- }
- stream->modeflags |= __FLAG_WIDE;
-
- if (stream->modeflags & __MASK_UNGOT) {/* Any ungetwc()s? */
-
- assert(stream->modeflags & __FLAG_READING);
-
-/* assert( (stream->modeflags & (__FLAG_READING|__FLAG_ERROR)) */
-/* == __FLAG_READING); */
-
- if ((((stream->modeflags & __MASK_UNGOT) > 1) || stream->ungot[1])) {
- stream->ungot_width[0] = 0; /* Application ungot... */
- } else {
- stream->ungot_width[0] = stream->ungot_width[1]; /* scanf ungot */
- }
-
- wi = stream->ungot[(--stream->modeflags) & __MASK_UNGOT];
- stream->ungot[1] = 0;
- goto DONE;
- }
-
- if (!stream->bufstart) { /* Ugh... stream isn't buffered! */
- /* Munge the stream temporarily to use a 1-byte buffer. */
- munge_stream(stream, sbuf);
- ++stream->bufend;
- }
-
- if (stream->state.mask == 0) { /* If last was a complete char */
- stream->ungot_width[0] = 0; /* then reset the width. */
- }
-
- LOOP:
- if ((n = stream->bufread - stream->bufpos) == 0) {
- goto FILL_BUFFER;
- }
-
- r = mbrtowc(wc, stream->bufpos, n, &stream->state);
- if (((ssize_t) r) >= 0) { /* Success... */
- if (r == 0) { /* Nul wide char... means 0 byte for us so */
- ++r; /* increment r and handle below as single. */
- }
- stream->bufpos += r;
- stream->ungot_width[0] += r;
- wi = *wc;
- goto DONE;
- }
-
- if (r == ((size_t) -2)) {
- /* Potentially valid but incomplete and no more buffered. */
- stream->bufpos += n; /* Update bufpos for stream. */
- stream->ungot_width[0] += n;
- FILL_BUFFER:
- if (_stdio_fread(c, (size_t) 1, stream) > 0) {
- assert(stream->bufpos == stream->bufstart + 1);
- *--stream->bufpos = *c; /* Insert byte into buffer. */
- goto LOOP;
- }
- if (!__FERROR(stream)) { /* EOF with no error. */
- if (!stream->state.mask) { /* No partially complete wchar. */
- goto DONE;
- }
- /* EOF but partially complete wchar. */
- /* TODO: should EILSEQ be set? */
- __set_errno(EILSEQ);
- }
- }
-
- /* If we reach here, either r == ((size_t)-1) and mbrtowc set errno
- * to EILSEQ, or r == ((size_t)-2) and stream is in an error state
- * or at EOF with a partially complete wchar. Make sure stream's
- * error indicator is set. */
- stream->modeflags |= __FLAG_ERROR;
-
- DONE:
- if (stream->bufstart == sbuf) { /* Need to un-munge the stream. */
- munge_stream(stream, NULL);
- }
-
- return wi;
-}
-
-strong_alias(fgetwc_unlocked,getwc_unlocked)
-strong_alias(fgetwc,getwc)
-
-#endif
-/**********************************************************************/
-#ifdef L_getwchar
-
-UNLOCKED_STREAM(wint_t,getwchar,(void),(),stdin)
-{
- register FILE *stream = stdin; /* This helps bcc optimize. */
-
- return fgetwc_unlocked(stream);
-}
-
-#endif
-/**********************************************************************/
-#ifdef L_fgetws
-
-UNLOCKED(wchar_t *,fgetws,(wchar_t *__restrict ws, int n,
- FILE *__restrict stream),(ws, n, stream))
-{
- register wchar_t *p = ws;
- wint_t wi;
-
- while ((n > 1)
- && ((wi = __fgetwc_unlocked(stream)) != WEOF)
- && ((*p++ = wi) != '\n')
- ) {
- --n;
- }
- if (p == ws) {
- /* TODO -- should we set errno? */
-/* if (n <= 0) { */
-/* errno = EINVAL; */
-/* } */
- return NULL;
- }
- *p = 0;
- return ws;
-}
-
-#endif
-/**********************************************************************/
-#ifdef L_fputwc
-
-UNLOCKED(wint_t,fputwc,(wchar_t wc, FILE *stream),(wc, stream))
-{
-#if 1
- return _wstdio_fwrite(&wc, 1, stream) ? wc : WEOF;
-#else
- size_t n;
- char buf[MB_LEN_MAX];
-
- if (stream->modeflags & __FLAG_NARROW) {
- stream->modeflags |= __FLAG_ERROR;
- __set_errno(EBADF);
- return WEOF;
- }
- stream->modeflags |= __FLAG_WIDE;
-
- return (((n = wcrtomb(buf, wc, &stream->state)) != ((size_t)-1)) /* !EILSEQ */
- && (_stdio_fwrite(buf, n, stream) == n))/* and wrote everything. */
- ? wc : WEOF;
-#endif
-}
-
-strong_alias(fputwc_unlocked,putwc_unlocked)
-strong_alias(fputwc,putwc)
-
-#endif
-/**********************************************************************/
-#ifdef L_putwchar
-
-UNLOCKED_STREAM(wint_t,putwchar,(wchar_t wc),(wc),stdout)
-{
- register FILE *stream = stdout; /* This helps bcc optimize. */
-
- return fputwc_unlocked(wc, stream);
-}
-
-#endif
-/**********************************************************************/
-#ifdef L_fputws
-
-UNLOCKED(int,fputws,(const wchar_t *__restrict ws,
- register FILE *__restrict stream),(ws, stream))
-{
-#if 1
- size_t n = wcslen(ws);
-
- return (_wstdio_fwrite(ws, n, stream) == n) ? 0 : -1;
-#else
- size_t n;
- char buf[64];
-
- if (stream->modeflags & __FLAG_NARROW) {
- stream->modeflags |= __FLAG_ERROR;
- __set_errno(EBADF);
- return -1;
- }
- stream->modeflags |= __FLAG_WIDE;
-
- while ((n = wcsrtombs(buf, &ws, sizeof(buf), &stream->state)) != 0) {
- /* Wasn't an empty wide string. */
- if ((n == ((size_t) -1))/* Encoding error! */
- || (_stdio_fwrite(buf, n, stream) != n)/* Didn't write everything. */
- ) {
- return -1;
- }
- if (!ws) { /* Done? */
- break;
- }
- }
-
- return 1;
-#endif
-}
-
-#endif
-/**********************************************************************/
-#ifdef L_ungetwc
-/*
- * Note: This is the application-callable ungetwc. If wscanf calls this, it
- * should also set stream->ungot[1] to 0 if this is the only ungot, as well
- * as reset stream->ungot_width[1] for use by _stdio_adjpos().
- */
-
-/* Reentrant. */
-
-wint_t ungetwc(wint_t c, register FILE *stream)
-{
- __STDIO_THREADLOCK(stream);
-
- __stdio_validate_FILE(stream); /* debugging only */
-
- if (stream->modeflags & __FLAG_NARROW) {
- stream->modeflags |= __FLAG_ERROR;
- c = WEOF;
- goto DONE;
- }
- stream->modeflags |= __FLAG_WIDE;
-
- /* If can't read or c == WEOF or ungot slots already filled, then fail. */
- if ((stream->modeflags
- & (__MASK_UNGOT2|__FLAG_WRITEONLY
-#ifndef __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__
- |__FLAG_WRITING /* Note: technically no, but yes in spirit */
-#endif /* __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__ */
- ))
- || ((stream->modeflags & __MASK_UNGOT1) && (stream->ungot[1]))
- || (c == WEOF) ) {
- c = WEOF;
- goto DONE;;
- }
-
-/* ungot_width */
-
-#ifdef __STDIO_BUFFERS
-#ifdef __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__
- if (stream->modeflags & __FLAG_WRITING) {
- fflush_unlocked(stream); /* Commit any write-buffered chars. */
- }
-#endif /* __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__ */
-#endif /* __STDIO_BUFFERS */
-
- /* Clear EOF and WRITING flags, and set READING FLAG */
- stream->modeflags &= ~(__FLAG_EOF|__FLAG_WRITING);
-#ifdef __UCLIBC_MJN3_ONLY__
-#warning CONSIDER: Is setting the reading flag after an ungetwc necessary?
-#endif /* __UCLIBC_MJN3_ONLY__ */
- stream->modeflags |= __FLAG_READING;
- stream->ungot[1] = 1; /* Flag as app ungetc call; wscanf fixes up. */
- stream->ungot[(stream->modeflags++) & __MASK_UNGOT] = c;
-
- __stdio_validate_FILE(stream); /* debugging only */
-
- DONE:
- __STDIO_THREADUNLOCK(stream);
-
- return c;
-}
-
-#endif
-/**********************************************************************/
diff --git a/libc/misc/wctype/Makefile.in b/libc/misc/wctype/Makefile.in
index dc008ec7d..0dcd485de 100644
--- a/libc/misc/wctype/Makefile.in
+++ b/libc/misc/wctype/Makefile.in
@@ -1,53 +1,35 @@
# 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:=wctype.c
-MOBJ:= iswalnum.o iswalpha.o iswcntrl.o iswdigit.o iswgraph.o \
- iswlower.o iswprint.o iswpunct.o iswspace.o iswupper.o \
- iswxdigit.o iswblank.o wctrans.o towctrans.o \
- wctype.o iswctype.o towlower.o towupper.o
+# multi source _wctype.c
+COM_SRC := \
+ iswalnum.c iswalpha.c iswcntrl.c iswdigit.c iswgraph.c \
+ iswlower.c iswprint.c iswpunct.c iswspace.c iswupper.c \
+ iswxdigit.c iswblank.c wctrans.c towctrans.c \
+ wctype.c iswctype.c towlower.c towupper.c
-MOBJx:= iswalnum_l.o iswalpha_l.o iswcntrl_l.o iswdigit_l.o iswgraph_l.o \
- iswlower_l.o iswprint_l.o iswpunct_l.o iswspace_l.o iswupper_l.o \
- iswxdigit_l.o iswblank_l.o \
- wctype_l.o iswctype_l.o wctrans_l.o towctrans_l.o towlower_l.o towupper_l.o
+CSRC :=
+ifeq ($(UCLIBC_HAS_WCHAR),y)
+CSRC += $(COM_SRC)
+endif
+ifeq ($(UCLIBC_HAS_XLOCALE),y)
+CSRC += $(patsubst %.c,%_l.c,$(COM_SRC))
+endif
-MISC_WCTYPE_DIR:=$(top_srcdir)libc/misc/wctype
-MISC_WCTYPE_OUT:=$(top_builddir)libc/misc/wctype
+MISC_WCTYPE_DIR := $(top_srcdir)libc/misc/wctype
+MISC_WCTYPE_OUT := $(top_builddir)libc/misc/wctype
-MISC_WCTYPE_MSRC:=$(MISC_WCTYPE_DIR)/$(MSRC)
-MISC_WCTYPE_MOBJ:=$(patsubst %.o,$(MISC_WCTYPE_OUT)/%.o,$(MOBJ))
-MISC_WCTYPE_MOBJx:=$(patsubst %.o,$(MISC_WCTYPE_OUT)/%.o,$(MOBJx))
+MISC_WCTYPE_SRC := $(patsubst %.c,$(MISC_WCTYPE_DIR)/%.c,$(CSRC))
+MISC_WCTYPE_OBJ := $(patsubst %.c,$(MISC_WCTYPE_OUT)/%.o,$(CSRC))
-MISC_WCTYPE_DEF:=$(patsubst %,-DL_%,$(subst .o,,$(notdir $(MISC_WCTYPE_MOBJ))))
+libc-y += $(MISC_WCTYPE_OBJ)
-$(MISC_WCTYPE_MOBJ): $(MISC_WCTYPE_MSRC)
- $(compile.m)
-
-$(MISC_WCTYPE_MOBJ:.o=.os): $(MISC_WCTYPE_MSRC)
- $(compile.m)
-
-$(MISC_WCTYPE_MOBJx): $(MISC_WCTYPE_MSRC)
- $(compile.m) -D__UCLIBC_DO_XLOCALE
-
-$(MISC_WCTYPE_MOBJx:.o=.os): $(MISC_WCTYPE_MSRC)
- $(compile.m) -D__UCLIBC_DO_XLOCALE
-
-libc-a-$(UCLIBC_HAS_WCHAR)+=$(MISC_WCTYPE_MOBJ)
-libc-a-$(UCLIBC_HAS_XLOCALE)+=$(MISC_WCTYPE_MOBJx)
-libc-so-$(UCLIBC_HAS_WCHAR)+=$(MISC_WCTYPE_MOBJ:.o=.os)
-libc-so-$(UCLIBC_HAS_XLOCALE)+=$(MISC_WCTYPE_MOBJx:.o=.os)
-
-CFLAGS-multi-$(UCLIBC_HAS_WCHAR)+=$(MISC_WCTYPE_DEF)
-libc-multi-$(UCLIBC_HAS_WCHAR)+=$(MISC_WCTYPE_MSRC)
-libc-nomulti-$(UCLIBC_HAS_XLOCALE)+=$(MISC_WCTYPE_MOBJx)
-
-objclean-y+=misc_wctype_objclean
+objclean-y += misc_wctype_objclean
misc_wctype_objclean:
$(RM) $(MISC_WCTYPE_OUT)/*.{o,os}
diff --git a/libc/misc/wctype/_wctype.c b/libc/misc/wctype/_wctype.c
new file mode 100644
index 000000000..a7d111039
--- /dev/null
+++ b/libc/misc/wctype/_wctype.c
@@ -0,0 +1,947 @@
+/* Copyright (C) 2002, 2003 Manuel Novoa III
+ *
+ * This 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.
+ *
+ * This 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 this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION!
+ *
+ * Besides uClibc, I'm using this code in my libc for elks, which is
+ * a 16-bit environment with a fairly limited compiler. It would make
+ * things much easier for me if this file isn't modified unnecessarily.
+ * In particular, please put any new or replacement functions somewhere
+ * else, and modify the makefile to use your version instead.
+ * Thanks. Manuel
+ *
+ * ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! */
+
+#define __NO_CTYPE
+
+#include <wctype.h>
+#include <assert.h>
+#include <string.h>
+#include <errno.h>
+#include <locale.h>
+#include <ctype.h>
+#include <stdint.h>
+#include <bits/uClibc_uwchar.h>
+
+libc_hidden_proto(strcmp)
+libc_hidden_proto(__C_ctype_tolower)
+libc_hidden_proto(tolower)
+libc_hidden_proto(__C_ctype_toupper)
+libc_hidden_proto(toupper)
+libc_hidden_proto(towlower)
+libc_hidden_proto(towupper)
+libc_hidden_proto(towctrans)
+libc_hidden_proto(iswctype)
+
+#if defined(__LOCALE_C_ONLY) && defined(__UCLIBC_DO_XLOCALE)
+#error xlocale functionality is not supported in stub locale mode.
+#endif
+
+#ifdef __UCLIBC_HAS_XLOCALE__
+#include <xlocale.h>
+libc_hidden_proto(towlower_l)
+libc_hidden_proto(towupper_l)
+libc_hidden_proto(towctrans_l)
+libc_hidden_proto(iswctype_l)
+#else
+libc_hidden_proto(__ctype_b)
+#endif /* __UCLIBC_HAS_XLOCALE__ */
+#ifdef __UCLIBC_HAS_LOCALE__
+libc_hidden_proto(__global_locale)
+#endif
+
+/* We know wide char support is enabled. We wouldn't be here otherwise. */
+
+/* Define this if you want to unify the towupper and towlower code in the
+ * towctrans function. */
+/* #define SMALL_UPLOW */
+
+/**********************************************************************/
+#ifdef __UCLIBC_MJN3_ONLY__
+#ifdef L_iswspace
+/* generates one warning */
+#warning TODO: Fix the __CTYPE_* codes!
+#endif
+#endif /* __UCLIBC_MJN3_ONLY__ */
+
+#if 1
+/* Taking advantage of the C99 mutual-exclusion guarantees for the various
+ * (w)ctype classes, including the descriptions of printing and control
+ * (w)chars, we can place each in one of the following mutually-exlusive
+ * subsets. Since there are less than 16, we can store the data for
+ * each (w)chars in a nibble. In contrast, glibc uses an unsigned int
+ * per (w)char, with one bit flag for each is* type. While this allows
+ * a simple '&' operation to determine the type vs. a range test and a
+ * little special handling for the "blank" and "xdigit" types in my
+ * approach, it also uses 8 times the space for the tables on the typical
+ * 32-bit archs we supported.*/
+enum {
+ __CTYPE_unclassified = 0,
+ __CTYPE_alpha_nonupper_nonlower,
+ __CTYPE_alpha_lower,
+ __CTYPE_alpha_upper_lower,
+ __CTYPE_alpha_upper,
+ __CTYPE_digit,
+ __CTYPE_punct,
+ __CTYPE_graph,
+ __CTYPE_print_space_nonblank,
+ __CTYPE_print_space_blank,
+ __CTYPE_space_nonblank_noncntrl,
+ __CTYPE_space_blank_noncntrl,
+ __CTYPE_cntrl_space_nonblank,
+ __CTYPE_cntrl_space_blank,
+ __CTYPE_cntrl_nonspace
+};
+#endif
+
+
+/* The following is used to implement wctype(), but it is defined
+ * here because the ordering must agree with that of the enumeration
+ * below (ignoring unclassified). */
+#define __CTYPE_TYPESTRING \
+ "\6alnum\0\6alpha\0\6blank\0\6cntrl\0\6digit\0\6graph\0\6lower\0" \
+ "\6print\0\6punct\0\6space\0\6upper\0\7xdigit\0\0"
+
+
+/* The values for wctype_t. */
+enum {
+ _CTYPE_unclassified = 0,
+ _CTYPE_isalnum,
+ _CTYPE_isalpha,
+ _CTYPE_isblank,
+ _CTYPE_iscntrl,
+ _CTYPE_isdigit,
+ _CTYPE_isgraph,
+ _CTYPE_islower,
+ _CTYPE_isprint,
+ _CTYPE_ispunct,
+ _CTYPE_isspace,
+ _CTYPE_isupper,
+ _CTYPE_isxdigit /* _MUST_ be last of the standard classes! */
+};
+
+/* The following is used to implement wctrans(). */
+
+#define __CTYPE_TRANSTRING "\10tolower\0\10toupper\0\10totitle\0\0"
+
+enum {
+ _CTYPE_tolower = 1,
+ _CTYPE_toupper,
+ _CTYPE_totitle
+};
+
+/*--------------------------------------------------------------------*/
+
+#define _CTYPE_iswxdigit (_CTYPE_isxdigit)
+
+/*--------------------------------------------------------------------*/
+
+#ifdef __UCLIBC_MJN3_ONLY__
+#ifdef L_iswspace
+/* generates one warning */
+#warning TODO: Fix WC* defines!
+#endif
+#endif /* __UCLIBC_MJN3_ONLY__ */
+
+#define ENCODING ((__UCLIBC_CURLOCALE_DATA).encoding)
+
+#define WCctype ((__UCLIBC_CURLOCALE_DATA).tblwctype)
+#define WCuplow ((__UCLIBC_CURLOCALE_DATA).tblwuplow)
+#define WCcmob ((__UCLIBC_CURLOCALE_DATA).tblwcomb)
+#define WCuplow_diff ((__UCLIBC_CURLOCALE_DATA).tblwuplow_diff)
+
+
+#define WC_TABLE_DOMAIN_MAX __LOCALE_DATA_WC_TABLE_DOMAIN_MAX
+
+#define WCctype_II_LEN __LOCALE_DATA_WCctype_II_LEN
+#define WCctype_TI_LEN __LOCALE_DATA_WCctype_TI_LEN
+#define WCctype_UT_LEN __LOCALE_DATA_WCctype_UT_LEN
+#define WCctype_II_SHIFT __LOCALE_DATA_WCctype_II_SHIFT
+#define WCctype_TI_SHIFT __LOCALE_DATA_WCctype_TI_SHIFT
+
+#define WCuplow_II_LEN __LOCALE_DATA_WCuplow_II_LEN
+#define WCuplow_TI_LEN __LOCALE_DATA_WCuplow_TI_LEN
+#define WCuplow_UT_LEN __LOCALE_DATA_WCuplow_UT_LEN
+#define WCuplow_II_SHIFT __LOCALE_DATA_WCuplow_II_SHIFT
+#define WCuplow_TI_SHIFT __LOCALE_DATA_WCuplow_TI_SHIFT
+
+
+#define WCctype_TI_MASK ((1 << (WCctype_TI_SHIFT)) - 1)
+#define WCctype_II_MASK ((1 << (WCctype_II_SHIFT)) - 1)
+
+/**********************************************************************/
+
+#undef __PASTE2
+#undef __PASTE3
+#define __PASTE2(X,Y) X ## Y
+#define __PASTE3(X,Y,Z) X ## Y ## Z
+
+#ifdef __UCLIBC_DO_XLOCALE
+
+#define ISW_FUNC_BODY(NAME) \
+libc_hidden_proto(__PASTE3(isw,NAME,_l)); \
+int __PASTE3(isw,NAME,_l) (wint_t wc, __locale_t l) \
+{ \
+ return iswctype_l(wc, __PASTE2(_CTYPE_is,NAME), l); \
+} \
+libc_hidden_def(__PASTE3(isw,NAME,_l))
+
+#else /* __UCLIBC_DO_XLOCALE */
+
+#define ISW_FUNC_BODY(NAME) \
+libc_hidden_proto(__PASTE2(isw,NAME)); \
+int __PASTE2(isw,NAME) (wint_t wc) \
+{ \
+ return iswctype(wc, __PASTE2(_CTYPE_is,NAME)); \
+} \
+libc_hidden_def(__PASTE2(isw,NAME))
+
+#endif /* __UCLIBC_DO_XLOCALE */
+/**********************************************************************/
+#if defined(L_iswalnum) || defined(L_iswalnum_l)
+
+ISW_FUNC_BODY(alnum);
+
+#endif
+/**********************************************************************/
+#if defined(L_iswalpha) || defined(L_iswalpha_l)
+
+ISW_FUNC_BODY(alpha);
+
+#endif
+/**********************************************************************/
+#if defined(L_iswblank) || defined(L_iswblank_l)
+
+ISW_FUNC_BODY(blank);
+
+#endif
+/**********************************************************************/
+#if defined(L_iswcntrl) || defined(L_iswcntrl_l)
+
+ISW_FUNC_BODY(cntrl);
+
+#endif
+/**********************************************************************/
+#if defined(L_iswdigit) || defined(L_iswdigit_l)
+
+ISW_FUNC_BODY(digit);
+
+#endif
+/**********************************************************************/
+#if defined(L_iswgraph) || defined(L_iswgraph_l)
+
+ISW_FUNC_BODY(graph);
+
+#endif
+/**********************************************************************/
+#if defined(L_iswlower) || defined(L_iswlower_l)
+
+ISW_FUNC_BODY(lower);
+
+#endif
+/**********************************************************************/
+#if defined(L_iswprint) || defined(L_iswprint_l)
+
+ISW_FUNC_BODY(print);
+
+#endif
+/**********************************************************************/
+#if defined(L_iswpunct) || defined(L_iswpunct_l)
+
+ISW_FUNC_BODY(punct);
+
+#endif
+/**********************************************************************/
+#if defined(L_iswspace) || defined(L_iswspace_l)
+
+ISW_FUNC_BODY(space);
+
+#endif
+/**********************************************************************/
+#if defined(L_iswupper) || defined(L_iswupper_l)
+
+ISW_FUNC_BODY(upper);
+
+#endif
+/**********************************************************************/
+#if defined(L_iswxdigit) || defined(L_iswxdigit_l)
+
+ISW_FUNC_BODY(xdigit);
+
+#endif
+/**********************************************************************/
+#if defined(L_towlower) || defined(L_towlower_l)
+
+#ifdef L_towlower
+#define TOWLOWER(w) towlower(w)
+#else /* L_towlower */
+#define TOWLOWER(w) towlower_l(w, __locale_t locale)
+#undef __UCLIBC_CURLOCALE_DATA
+#undef __UCLIBC_CURLOCALE
+#define __UCLIBC_CURLOCALE_DATA (*locale)
+#define __UCLIBC_CURLOCALE (locale)
+#endif /* L_towlower */
+
+#ifdef __UCLIBC_HAS_XLOCALE__
+#define TOWCTRANS(w,d) towctrans_l(w,d, __UCLIBC_CURLOCALE)
+#else /* __UCLIBC_HAS_XLOCALE__ */
+#define TOWCTRANS(w,d) towctrans(w,d)
+#endif /* __UCLIBC_HAS_XLOCALE__ */
+
+#define __C_towlower(wc) \
+ ((((__uwchar_t)(wc)) <= 0x7f) ? (__C_ctype_tolower)[(wc)] : (wc))
+
+#ifdef __LOCALE_C_ONLY
+
+wint_t towlower(wint_t wc)
+{
+#ifdef __UCLIBC_HAS_CTYPE_TABLES__
+ return __C_towlower(wc);
+#else
+ return (wc == ((unsigned int)(wc)))
+ ? __C_tolower(((unsigned int)(wc)))
+ : 0;
+#endif
+}
+
+#else /* __LOCALE_C_ONLY */
+
+#ifdef SMALL_UPLOW
+
+#if defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__)
+
+wint_t towlower(wint_t wc)
+{
+ return towctrans_l(wc, _CTYPE_tolower, __UCLIBC_CURLOCALE);
+}
+
+#else /* defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__) */
+
+wint_t TOWLOWER(wint_t wc)
+{
+ return TOWCTRANS(wc, _CTYPE_tolower);
+}
+
+#endif /* defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__) */
+
+#else /* SMALL_UPLOW */
+
+#if defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__)
+
+wint_t towlower(wint_t wc)
+{
+ return towlower_l(wc, __UCLIBC_CURLOCALE);
+}
+
+#else /* defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__) */
+
+wint_t TOWLOWER(wint_t wc)
+{
+ unsigned int sc, n, i;
+ __uwchar_t u = wc;
+
+ if (ENCODING == __ctype_encoding_7_bit) {
+ /* We're in the C/POSIX locale, so ignore the tables. */
+ return __C_towlower(wc);
+ }
+
+ if (u <= WC_TABLE_DOMAIN_MAX) {
+ sc = u & ((1 << WCuplow_TI_SHIFT) - 1);
+ u >>= WCuplow_TI_SHIFT;
+ n = u & ((1 << WCuplow_II_SHIFT) - 1);
+ u >>= WCuplow_II_SHIFT;
+
+ i = ((unsigned int) WCuplow[u]) << WCuplow_II_SHIFT;
+ i = ((unsigned int) WCuplow[WCuplow_II_LEN + i + n])
+ << WCuplow_TI_SHIFT;
+ i = ((unsigned int) WCuplow[WCuplow_II_LEN + WCuplow_TI_LEN
+ + i + sc]) << 1;
+ wc += WCuplow_diff[i + 1];
+ }
+ return wc;
+}
+
+#endif /* defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__) */
+
+#endif /* SMALL_UPLOW */
+
+#ifdef L_towlower_l
+libc_hidden_def(towlower_l)
+#endif /* L_towlower_l */
+
+#endif /* __LOCALE_C_ONLY */
+
+#ifndef L_towlower_l
+libc_hidden_def(towlower)
+#endif
+
+#endif
+/**********************************************************************/
+#if defined(L_towupper) || defined(L_towupper_l)
+
+#ifdef L_towupper
+#define TOWUPPER(w) towupper(w)
+#else /* L_towupper */
+#define TOWUPPER(w) towupper_l(w, __locale_t locale)
+#undef __UCLIBC_CURLOCALE_DATA
+#undef __UCLIBC_CURLOCALE
+#define __UCLIBC_CURLOCALE_DATA (*locale)
+#define __UCLIBC_CURLOCALE (locale)
+#endif /* L_towupper */
+
+#ifdef __UCLIBC_HAS_XLOCALE__
+#define TOWCTRANS(w,d) towctrans_l(w,d, __UCLIBC_CURLOCALE)
+#else /* __UCLIBC_HAS_XLOCALE__ */
+#define TOWCTRANS(w,d) towctrans(w,d)
+#endif /* __UCLIBC_HAS_XLOCALE__ */
+
+#define __C_towupper(wc) \
+ ((((__uwchar_t)(wc)) <= 0x7f) ? (__C_ctype_toupper)[(wc)] : (wc))
+
+#ifdef __LOCALE_C_ONLY
+
+wint_t towupper(wint_t wc)
+{
+#ifdef __UCLIBC_HAS_CTYPE_TABLES__
+ return __C_towupper(wc);
+#else
+ return (wc == ((unsigned int)(wc)))
+ ? __C_toupper(((unsigned int)(wc)))
+ : 0;
+#endif
+
+}
+
+#else /* __LOCALE_C_ONLY */
+
+#ifdef SMALL_UPLOW
+
+#if defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__)
+
+wint_t towupper(wint_t wc)
+{
+ return towctrans_l(wc, _CTYPE_toupper, __UCLIBC_CURLOCALE);
+}
+
+#else /* defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__) */
+
+wint_t TOWUPPER(wint_t wc)
+{
+ return TOWCTRANS(wc, _CTYPE_toupper);
+}
+
+#endif /* defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__) */
+
+#else /* SMALL_UPLOW */
+
+#if defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__)
+
+wint_t towupper(wint_t wc)
+{
+ return towupper_l(wc, __UCLIBC_CURLOCALE);
+}
+
+#else /* defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__) */
+
+wint_t TOWUPPER(wint_t wc)
+{
+ unsigned int sc, n, i;
+ __uwchar_t u = wc;
+
+ if (ENCODING == __ctype_encoding_7_bit) {
+ /* We're in the C/POSIX locale, so ignore the tables. */
+ return __C_towupper(wc);
+ }
+
+ if (u <= WC_TABLE_DOMAIN_MAX) {
+ sc = u & ((1 << WCuplow_TI_SHIFT) - 1);
+ u >>= WCuplow_TI_SHIFT;
+ n = u & ((1 << WCuplow_II_SHIFT) - 1);
+ u >>= WCuplow_II_SHIFT;
+
+ i = ((unsigned int) WCuplow[u]) << WCuplow_II_SHIFT;
+ i = ((unsigned int) WCuplow[WCuplow_II_LEN + i + n])
+ << WCuplow_TI_SHIFT;
+ i = ((unsigned int) WCuplow[WCuplow_II_LEN + WCuplow_TI_LEN
+ + i + sc]) << 1;
+ wc += WCuplow_diff[i];
+ }
+ return wc;
+}
+
+#endif /* defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__) */
+
+#endif /* SMALL_UPLOW */
+
+#ifdef L_towupper_l
+libc_hidden_def(towupper_l)
+#endif /* L_towupper_l */
+
+#endif /* __LOCALE_C_ONLY */
+
+#ifndef L_towupper_l
+libc_hidden_def(towupper)
+#endif
+
+#endif
+/**********************************************************************/
+#ifdef L_wctype
+
+static const unsigned char typestring[] = __CTYPE_TYPESTRING;
+/* extern const unsigned char typestring[]; */
+
+libc_hidden_proto(wctype)
+wctype_t wctype(const char *property)
+{
+ const unsigned char *p;
+ int i;
+
+ p = typestring;
+ i = 1;
+ do {
+ if (!strcmp(property, ++p)) {
+ return i;
+ }
+ ++i;
+ p += p[-1];
+ } while (*p);
+
+ /* TODO - Add locale-specific classifications. */
+ return 0;
+}
+libc_hidden_def(wctype)
+
+#endif
+/**********************************************************************/
+#ifdef L_wctype_l
+
+#ifdef __UCLIBC_MJN3_ONLY__
+#warning REMINDER: Currently wctype_l simply calls wctype.
+#endif /* __UCLIBC_MJN3_ONLY__ */
+
+libc_hidden_proto(wctype)
+
+libc_hidden_proto(wctype_l)
+wctype_t wctype_l (const char *property, __locale_t locale)
+{
+ return wctype(property);
+}
+libc_hidden_def(wctype_l)
+
+#endif
+/**********************************************************************/
+#if defined(L_iswctype) || defined(L_iswctype_l)
+
+#define __C_iswdigit(c) \
+ ((sizeof(c) == sizeof(char)) \
+ ? (((unsigned char)((c) - '0')) < 10) \
+ : (((__uwchar_t)((c) - '0')) < 10))
+#define __C_iswxdigit(c) \
+ (__C_iswdigit(c) \
+ || ((sizeof(c) == sizeof(char)) \
+ ? (((unsigned char)((((c)) | 0x20) - 'a')) < 6) \
+ : (((__uwchar_t)((((c)) | 0x20) - 'a')) < 6)))
+
+#ifdef __UCLIBC_MJN3_ONLY__
+#ifdef L_iswctype
+#warning CONSIDER: Change to bit shift? would need to sync with wctype.h
+#endif
+#endif /* __UCLIBC_MJN3_ONLY__ */
+
+
+#ifdef __UCLIBC_HAS_CTYPE_TABLES__
+#if !defined(__UCLIBC_HAS_XLOCALE__) || defined(L_iswctype_l)
+
+static const unsigned short int desc2flag[] = {
+ [_CTYPE_unclassified] = 0,
+ [_CTYPE_isalnum] = (unsigned short int) _ISwalnum,
+ [_CTYPE_isalpha] = (unsigned short int) _ISwalpha,
+ [_CTYPE_isblank] = (unsigned short int) _ISwblank,
+ [_CTYPE_iscntrl] = (unsigned short int) _ISwcntrl,
+ [_CTYPE_isdigit] = (unsigned short int) _ISwdigit,
+ [_CTYPE_isgraph] = (unsigned short int) _ISwgraph,
+ [_CTYPE_islower] = (unsigned short int) _ISwlower,
+ [_CTYPE_isprint] = (unsigned short int) _ISwprint,
+ [_CTYPE_ispunct] = (unsigned short int) _ISwpunct,
+ [_CTYPE_isspace] = (unsigned short int) _ISwspace,
+ [_CTYPE_isupper] = (unsigned short int) _ISwupper,
+ [_CTYPE_isxdigit] = (unsigned short int) _ISwxdigit,
+};
+
+#endif /* defined(L_iswctype_L) || defined(__LOCALE_C_ONLY) */
+#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
+
+#ifdef __LOCALE_C_ONLY
+
+#ifdef __UCLIBC_HAS_CTYPE_TABLES__
+
+int iswctype(wint_t wc, wctype_t desc)
+{
+ /* Note... wctype_t is unsigned. */
+
+ if ((((__uwchar_t) wc) <= 0x7f)
+ && (desc < (sizeof(desc2flag)/sizeof(desc2flag[0])))
+ ) {
+ return __isctype(wc, desc2flag[desc]);
+ }
+ return 0;
+}
+
+#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
+
+int iswctype(wint_t wc, wctype_t desc)
+{
+ /* This is lame, but it is here just to get it working for now. */
+
+ if (wc == ((unsigned int)(wc))) {
+ switch(desc) {
+ case _CTYPE_isupper:
+ return __C_isupper((unsigned int)(wc));
+ case _CTYPE_islower:
+ return __C_islower((unsigned int)(wc));
+ case _CTYPE_isalpha:
+ return __C_isalpha((unsigned int)(wc));
+ case _CTYPE_isdigit:
+ return __C_isdigit((unsigned int)(wc));
+ case _CTYPE_isxdigit:
+ return __C_isxdigit((unsigned int)(wc));
+ case _CTYPE_isspace:
+ return __C_isspace((unsigned int)(wc));
+ case _CTYPE_isprint:
+ return __C_isprint((unsigned int)(wc));
+ case _CTYPE_isgraph:
+ return __C_isgraph((unsigned int)(wc));
+ case _CTYPE_isblank:
+ return __C_isblank((unsigned int)(wc));
+ case _CTYPE_iscntrl:
+ return __C_iscntrl((unsigned int)(wc));
+ case _CTYPE_ispunct:
+ return __C_ispunct((unsigned int)(wc));
+ case _CTYPE_isalnum:
+ return __C_isalnum((unsigned int)(wc));
+ default:
+ break;
+ }
+ }
+ return 0;
+}
+
+#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
+
+#else /* __LOCALE_C_ONLY */
+
+#ifdef __UCLIBC_MJN3_ONLY__
+#ifdef L_iswctype
+#warning CONSIDER: Handle combining class?
+#endif
+#endif /* __UCLIBC_MJN3_ONLY__ */
+
+#ifdef L_iswctype
+#define ISWCTYPE(w,d) iswctype(w,d)
+#else /* L_iswctype */
+#define ISWCTYPE(w,d) iswctype_l(w,d, __locale_t locale)
+#undef __UCLIBC_CURLOCALE_DATA
+#undef __UCLIBC_CURLOCALE
+#define __UCLIBC_CURLOCALE_DATA (*locale)
+#define __UCLIBC_CURLOCALE (locale)
+#endif /* L_iswctype */
+
+#if defined(L_iswctype) && defined(__UCLIBC_HAS_XLOCALE__)
+
+int iswctype(wint_t wc, wctype_t desc)
+{
+ return iswctype_l(wc, desc, __UCLIBC_CURLOCALE);
+}
+
+#else /* defined(L_iswctype) && defined(__UCLIBC_HAS_XLOCALE__) */
+
+int ISWCTYPE(wint_t wc, wctype_t desc)
+{
+ unsigned int sc, n, i0, i1;
+ unsigned char d = __CTYPE_unclassified;
+
+ if ((ENCODING != __ctype_encoding_7_bit) || (((__uwchar_t) wc) <= 0x7f)){
+ if (desc < _CTYPE_iswxdigit) {
+ if (((__uwchar_t) wc) <= WC_TABLE_DOMAIN_MAX) {
+ /* From here on, we know wc > 0. */
+ sc = wc & WCctype_TI_MASK;
+ wc >>= WCctype_TI_SHIFT;
+ n = wc & WCctype_II_MASK;
+ wc >>= WCctype_II_SHIFT;
+
+ i0 = WCctype[wc];
+ i0 <<= WCctype_II_SHIFT;
+ i1 = WCctype[WCctype_II_LEN + i0 + n];
+ i1 <<= (WCctype_TI_SHIFT-1);
+ d = WCctype[WCctype_II_LEN + WCctype_TI_LEN + i1 + (sc >> 1)];
+
+ d = (sc & 1) ? (d >> 4) : (d & 0xf);
+ } else if ( ((((__uwchar_t)(wc - 0xe0020UL)) <= 0x5f)
+ || (wc == 0xe0001UL))
+ || ( (((__uwchar_t)(wc - 0xf0000UL)) < 0x20000UL)
+ && ((wc & 0xffffU) <= 0xfffdU))
+ ) {
+ d = __CTYPE_punct;
+ }
+
+#if 0
+ return ( ((unsigned char)(d - ctype_range[2*desc]))
+ <= ctype_range[2*desc + 1] )
+ && ((desc != _CTYPE_iswblank) || (d & 1));
+#else
+ return (__UCLIBC_CURLOCALE_DATA).code2flag[d] & desc2flag[desc];
+#endif
+ }
+
+#ifdef __UCLIBC_MJN3_ONLY__
+#warning TODO: xdigit really needs to be handled better. Remember only for ascii!
+#endif /* __UCLIBC_MJN3_ONLY__ */
+ /* TODO - Add locale-specific classifications. */
+ return (desc == _CTYPE_iswxdigit) ? __C_iswxdigit(wc) : 0;
+ }
+ return 0;
+}
+
+#endif /* defined(L_iswctype) && defined(__UCLIBC_HAS_XLOCALE__) */
+
+#ifdef L_iswctype_l
+libc_hidden_def(iswctype_l)
+#endif /* L_iswctype_l */
+
+#endif /* __LOCALE_C_ONLY */
+
+#ifdef L_iswctype
+libc_hidden_def(iswctype)
+#endif /* L_iswctype */
+
+#endif
+/**********************************************************************/
+#if defined(L_towctrans) || defined(L_towctrans_l)
+
+#ifdef __LOCALE_C_ONLY
+
+/* Minimal support for C/POSIX locale. */
+
+#ifndef _tolower
+#warning _tolower is undefined!
+#define _tolower(c) tolower(c)
+#endif
+#ifndef _toupper
+#warning _toupper is undefined!
+#define _toupper(c) toupper(c)
+#endif
+
+wint_t towctrans(wint_t wc, wctrans_t desc)
+{
+ if (((unsigned int)(desc - _CTYPE_tolower))
+ <= (_CTYPE_toupper - _CTYPE_tolower)
+ ) {
+ /* Transliteration is either tolower or toupper. */
+ if (((__uwchar_t) wc) <= 0x7f) {
+ return (desc == _CTYPE_tolower) ? _tolower(wc) : _toupper(wc);
+ }
+ } else {
+ __set_errno(EINVAL); /* Invalid transliteration. */
+ }
+ return wc;
+}
+
+#else /* __LOCALE_C_ONLY */
+
+#ifdef L_towctrans
+#define TOWCTRANS(w,d) towctrans(w,d)
+#else /* L_towctrans */
+#define TOWCTRANS(w,d) towctrans_l(w,d, __locale_t locale)
+#undef __UCLIBC_CURLOCALE_DATA
+#undef __UCLIBC_CURLOCALE
+#define __UCLIBC_CURLOCALE_DATA (*locale)
+#define __UCLIBC_CURLOCALE (locale)
+#endif /* L_towctrans */
+
+#ifdef __UCLIBC_HAS_XLOCALE__
+#define TOWLOWER(w,l) towlower_l(w,l)
+#define TOWUPPER(w,l) towupper_l(w,l)
+#else /* __UCLIBC_HAS_XLOCALE__ */
+#define TOWLOWER(w,l) towlower(w)
+#define TOWUPPER(w,l) towupper(w)
+#endif /* __UCLIBC_HAS_XLOCALE__ */
+
+#if defined(L_towctrans) && defined(__UCLIBC_HAS_XLOCALE__)
+
+wint_t towctrans(wint_t wc, wctrans_t desc)
+{
+ return towctrans_l(wc, desc, __UCLIBC_CURLOCALE);
+}
+
+#else /* defined(L_towctrans) && defined(__UCLIBC_HAS_XLOCALE__) */
+
+#ifdef SMALL_UPLOW
+
+wint_t TOWCTRANS(wint_t wc, wctrans_t desc)
+{
+ unsigned int sc, n, i;
+ __uwchar_t u = wc;
+
+ /* TODO - clean up */
+ if (ENCODING == __ctype_encoding_7_bit) {
+ if ((((__uwchar_t) wc) > 0x7f)
+ || (((unsigned int)(desc - _CTYPE_tolower))
+ > (_CTYPE_toupper - _CTYPE_tolower))
+ ){
+ /* We're in the C/POSIX locale, so ignore non-ASCII values
+ * as well an any mappings other than toupper or tolower. */
+ return wc;
+ }
+ }
+
+ if (((unsigned int)(desc - _CTYPE_tolower))
+ <= (_CTYPE_totitle - _CTYPE_tolower)
+ ) {
+ if (u <= WC_TABLE_DOMAIN_MAX) {
+ sc = u & ((1 << WCuplow_TI_SHIFT) - 1);
+ u >>= WCuplow_TI_SHIFT;
+ n = u & ((1 << WCuplow_II_SHIFT) - 1);
+ u >>= WCuplow_II_SHIFT;
+
+ i = ((unsigned int) WCuplow[u]) << WCuplow_II_SHIFT;
+ i = ((unsigned int) WCuplow[WCuplow_II_LEN + i + n])
+ << WCuplow_TI_SHIFT;
+ i = ((unsigned int) WCuplow[WCuplow_II_LEN + WCuplow_TI_LEN
+ + i + sc]) << 1;
+ if (desc == _CTYPE_tolower) {
+ ++i;
+ }
+ wc += WCuplow_diff[i];
+ if (desc == _CTYPE_totitle) {
+#ifdef __UCLIBC_MJN3_ONLY__
+#warning TODO: Verify totitle special cases!
+#endif /* __UCLIBC_MJN3_ONLY__ */
+ /* WARNING! These special cases work for glibc 2.2.4. Changes
+ * may be needed if the glibc locale tables are updated. */
+ if ( (((__uwchar_t)(wc - 0x1c4)) <= (0x1cc - 0x1c4))
+ || (wc == 0x1f1)
+ ) {
+ ++wc;
+ }
+ }
+ }
+ } else {
+ /* TODO - Deal with other transliterations. */
+ __set_errno(EINVAL);
+ }
+
+ return wc;
+}
+
+#else /* SMALL_UPLOW */
+
+wint_t TOWCTRANS(wint_t wc, wctrans_t desc)
+{
+ if (ENCODING == __ctype_encoding_7_bit) {
+ if ((((__uwchar_t) wc) > 0x7f)
+ || (((unsigned int)(desc - _CTYPE_tolower))
+ > (_CTYPE_toupper - _CTYPE_tolower))
+ ){
+ /* We're in the C/POSIX locale, so ignore non-ASCII values
+ * as well an any mappings other than toupper or tolower. */
+ return wc;
+ }
+ }
+
+ if (desc == _CTYPE_tolower) {
+ return TOWLOWER(wc, __UCLIBC_CURLOCALE);
+ } else if (((unsigned int)(desc - _CTYPE_toupper))
+ <= (_CTYPE_totitle - _CTYPE_toupper)
+ ) {
+ wc = TOWUPPER(wc, __UCLIBC_CURLOCALE);
+ if (desc == _CTYPE_totitle) {
+#ifdef __UCLIBC_MJN3_ONLY__
+#warning TODO: Verify totitle special cases!
+#endif /* __UCLIBC_MJN3_ONLY__ */
+ /* WARNING! These special cases work for glibc 2.2.4. Changes
+ * may be needed if the glibc locale tables are updated. */
+ if ( (((__uwchar_t)(wc - 0x1c4)) <= (0x1cc - 0x1c4))
+ || (wc == 0x1f1)
+ ) {
+ ++wc;
+ }
+ }
+ } else {
+ /* TODO - Deal with other transliterations. */
+ __set_errno(EINVAL);
+ }
+ return wc;
+}
+
+#endif /* SMALL_UPLOW */
+
+#endif /* defined(L_towctrans) && defined(__UCLIBC_HAS_XLOCALE__) */
+
+#ifdef L_towctrans_l
+libc_hidden_def(towctrans_l)
+#endif /* L_towctrans_l */
+
+#endif /* __LOCALE_C_ONLY */
+
+#ifndef L_towctrans_l
+libc_hidden_def(towctrans)
+#endif
+
+#endif
+/**********************************************************************/
+#ifdef L_wctrans
+
+static const char transstring[] = __CTYPE_TRANSTRING;
+
+libc_hidden_proto(wctrans)
+wctrans_t wctrans(const char *property)
+{
+ const unsigned char *p;
+ int i;
+
+ p = transstring;
+ i = 1;
+ do {
+ if (!strcmp(property, ++p)) {
+ return i;
+ }
+ ++i;
+ p += p[-1];
+ } while (*p);
+
+ /* TODO - Add locale-specific translations. */
+ return 0;
+}
+libc_hidden_def(wctrans)
+
+#endif
+/**********************************************************************/
+#ifdef L_wctrans_l
+
+#ifdef __UCLIBC_MJN3_ONLY__
+#warning REMINDER: Currently wctrans_l simply calls wctrans.
+#endif /* __UCLIBC_MJN3_ONLY__ */
+
+libc_hidden_proto(wctrans)
+
+wctrans_t wctrans_l(const char *property, __locale_t locale)
+{
+ return wctrans(property);
+}
+
+#endif
+/**********************************************************************/
diff --git a/libc/misc/wctype/iswalnum.c b/libc/misc/wctype/iswalnum.c
new file mode 100644
index 000000000..a85a03dc8
--- /dev/null
+++ b/libc/misc/wctype/iswalnum.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswalnum
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswalnum_l.c b/libc/misc/wctype/iswalnum_l.c
new file mode 100644
index 000000000..6e3cd7770
--- /dev/null
+++ b/libc/misc/wctype/iswalnum_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswalnum_l
+#define __UCLIBC_DO_XLOCALE
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswalpha.c b/libc/misc/wctype/iswalpha.c
new file mode 100644
index 000000000..6b829eb82
--- /dev/null
+++ b/libc/misc/wctype/iswalpha.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswalpha
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswalpha_l.c b/libc/misc/wctype/iswalpha_l.c
new file mode 100644
index 000000000..79b11cf72
--- /dev/null
+++ b/libc/misc/wctype/iswalpha_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswalpha_l
+#define __UCLIBC_DO_XLOCALE
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswblank.c b/libc/misc/wctype/iswblank.c
new file mode 100644
index 000000000..67862d59e
--- /dev/null
+++ b/libc/misc/wctype/iswblank.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswblank
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswblank_l.c b/libc/misc/wctype/iswblank_l.c
new file mode 100644
index 000000000..4c5709cf8
--- /dev/null
+++ b/libc/misc/wctype/iswblank_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswblank_l
+#define __UCLIBC_DO_XLOCALE
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswcntrl.c b/libc/misc/wctype/iswcntrl.c
new file mode 100644
index 000000000..50d72b46f
--- /dev/null
+++ b/libc/misc/wctype/iswcntrl.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswcntrl
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswcntrl_l.c b/libc/misc/wctype/iswcntrl_l.c
new file mode 100644
index 000000000..2fe64d744
--- /dev/null
+++ b/libc/misc/wctype/iswcntrl_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswcntrl_l
+#define __UCLIBC_DO_XLOCALE
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswctype.c b/libc/misc/wctype/iswctype.c
new file mode 100644
index 000000000..777d41048
--- /dev/null
+++ b/libc/misc/wctype/iswctype.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswctype
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswctype_l.c b/libc/misc/wctype/iswctype_l.c
new file mode 100644
index 000000000..71bce184e
--- /dev/null
+++ b/libc/misc/wctype/iswctype_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswctype_l
+#define __UCLIBC_DO_XLOCALE
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswdigit.c b/libc/misc/wctype/iswdigit.c
new file mode 100644
index 000000000..b2aa5d00a
--- /dev/null
+++ b/libc/misc/wctype/iswdigit.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswdigit
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswdigit_l.c b/libc/misc/wctype/iswdigit_l.c
new file mode 100644
index 000000000..4832c9c80
--- /dev/null
+++ b/libc/misc/wctype/iswdigit_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswdigit_l
+#define __UCLIBC_DO_XLOCALE
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswgraph.c b/libc/misc/wctype/iswgraph.c
new file mode 100644
index 000000000..8113054f5
--- /dev/null
+++ b/libc/misc/wctype/iswgraph.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswgraph
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswgraph_l.c b/libc/misc/wctype/iswgraph_l.c
new file mode 100644
index 000000000..db683156e
--- /dev/null
+++ b/libc/misc/wctype/iswgraph_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswgraph_l
+#define __UCLIBC_DO_XLOCALE
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswlower.c b/libc/misc/wctype/iswlower.c
new file mode 100644
index 000000000..016d8cc8e
--- /dev/null
+++ b/libc/misc/wctype/iswlower.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswlower
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswlower_l.c b/libc/misc/wctype/iswlower_l.c
new file mode 100644
index 000000000..5b9f82126
--- /dev/null
+++ b/libc/misc/wctype/iswlower_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswlower_l
+#define __UCLIBC_DO_XLOCALE
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswprint.c b/libc/misc/wctype/iswprint.c
new file mode 100644
index 000000000..8e47e88c1
--- /dev/null
+++ b/libc/misc/wctype/iswprint.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswprint
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswprint_l.c b/libc/misc/wctype/iswprint_l.c
new file mode 100644
index 000000000..148414c49
--- /dev/null
+++ b/libc/misc/wctype/iswprint_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswprint_l
+#define __UCLIBC_DO_XLOCALE
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswpunct.c b/libc/misc/wctype/iswpunct.c
new file mode 100644
index 000000000..1175e1ad6
--- /dev/null
+++ b/libc/misc/wctype/iswpunct.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswpunct
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswpunct_l.c b/libc/misc/wctype/iswpunct_l.c
new file mode 100644
index 000000000..a6d361650
--- /dev/null
+++ b/libc/misc/wctype/iswpunct_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswpunct_l
+#define __UCLIBC_DO_XLOCALE
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswspace.c b/libc/misc/wctype/iswspace.c
new file mode 100644
index 000000000..603f5cf4a
--- /dev/null
+++ b/libc/misc/wctype/iswspace.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswspace
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswspace_l.c b/libc/misc/wctype/iswspace_l.c
new file mode 100644
index 000000000..e389f8913
--- /dev/null
+++ b/libc/misc/wctype/iswspace_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswspace_l
+#define __UCLIBC_DO_XLOCALE
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswupper.c b/libc/misc/wctype/iswupper.c
new file mode 100644
index 000000000..4cfdebb1a
--- /dev/null
+++ b/libc/misc/wctype/iswupper.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswupper
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswupper_l.c b/libc/misc/wctype/iswupper_l.c
new file mode 100644
index 000000000..359aef984
--- /dev/null
+++ b/libc/misc/wctype/iswupper_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswupper_l
+#define __UCLIBC_DO_XLOCALE
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswxdigit.c b/libc/misc/wctype/iswxdigit.c
new file mode 100644
index 000000000..568f253fd
--- /dev/null
+++ b/libc/misc/wctype/iswxdigit.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswxdigit
+#include "_wctype.c"
diff --git a/libc/misc/wctype/iswxdigit_l.c b/libc/misc/wctype/iswxdigit_l.c
new file mode 100644
index 000000000..1d543abbd
--- /dev/null
+++ b/libc/misc/wctype/iswxdigit_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_iswxdigit_l
+#define __UCLIBC_DO_XLOCALE
+#include "_wctype.c"
diff --git a/libc/misc/wctype/towctrans.c b/libc/misc/wctype/towctrans.c
new file mode 100644
index 000000000..9ad0468ff
--- /dev/null
+++ b/libc/misc/wctype/towctrans.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_towctrans
+#include "_wctype.c"
diff --git a/libc/misc/wctype/towctrans_l.c b/libc/misc/wctype/towctrans_l.c
new file mode 100644
index 000000000..e179b50fe
--- /dev/null
+++ b/libc/misc/wctype/towctrans_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_towctrans_l
+#define __UCLIBC_DO_XLOCALE
+#include "_wctype.c"
diff --git a/libc/misc/wctype/towlower.c b/libc/misc/wctype/towlower.c
new file mode 100644
index 000000000..dffbff3d6
--- /dev/null
+++ b/libc/misc/wctype/towlower.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_towlower
+#include "_wctype.c"
diff --git a/libc/misc/wctype/towlower_l.c b/libc/misc/wctype/towlower_l.c
new file mode 100644
index 000000000..f1aa7e6ee
--- /dev/null
+++ b/libc/misc/wctype/towlower_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_towlower_l
+#define __UCLIBC_DO_XLOCALE
+#include "_wctype.c"
diff --git a/libc/misc/wctype/towupper.c b/libc/misc/wctype/towupper.c
new file mode 100644
index 000000000..1dab8fed0
--- /dev/null
+++ b/libc/misc/wctype/towupper.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_towupper
+#include "_wctype.c"
diff --git a/libc/misc/wctype/towupper_l.c b/libc/misc/wctype/towupper_l.c
new file mode 100644
index 000000000..cf05d5c87
--- /dev/null
+++ b/libc/misc/wctype/towupper_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_towupper_l
+#define __UCLIBC_DO_XLOCALE
+#include "_wctype.c"
diff --git a/libc/misc/wctype/wctrans.c b/libc/misc/wctype/wctrans.c
new file mode 100644
index 000000000..f99d9cd9d
--- /dev/null
+++ b/libc/misc/wctype/wctrans.c
@@ -0,0 +1,8 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wctrans
+#include "_wctype.c"
diff --git a/libc/misc/wctype/wctrans_l.c b/libc/misc/wctype/wctrans_l.c
new file mode 100644
index 000000000..79854c2d1
--- /dev/null
+++ b/libc/misc/wctype/wctrans_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wctrans_l
+#define __UCLIBC_DO_XLOCALE
+#include "_wctype.c"
diff --git a/libc/misc/wctype/wctype.c b/libc/misc/wctype/wctype.c
index 659000558..0dc1e6d70 100644
--- a/libc/misc/wctype/wctype.c
+++ b/libc/misc/wctype/wctype.c
@@ -1,938 +1,8 @@
-/* Copyright (C) 2002, 2003 Manuel Novoa III
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
*
- * This 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.
- *
- * This 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 this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-/* ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION!
- *
- * Besides uClibc, I'm using this code in my libc for elks, which is
- * a 16-bit environment with a fairly limited compiler. It would make
- * things much easier for me if this file isn't modified unnecessarily.
- * In particular, please put any new or replacement functions somewhere
- * else, and modify the makefile to use your version instead.
- * Thanks. Manuel
- *
- * ATTENTION! ATTENTION! ATTENTION! ATTENTION! ATTENTION! */
-
-#define _GNU_SOURCE
-#define __NO_CTYPE
-
-#include <wctype.h>
-#include <assert.h>
-#include <string.h>
-#include <errno.h>
-#include <locale.h>
-#include <ctype.h>
-#include <stdint.h>
-#include <bits/uClibc_uwchar.h>
-
-extern wctype_t __wctype (__const char *__property) attribute_hidden;
-extern wint_t __towlower (wint_t __wc) __THROW attribute_hidden;
-extern wint_t __towupper (wint_t __wc) __THROW attribute_hidden;
-
-#if defined(__LOCALE_C_ONLY) && defined(__UCLIBC_DO_XLOCALE)
-#error xlocale functionality is not supported in stub locale mode.
-#endif
-
-#ifdef __UCLIBC_HAS_XLOCALE__
-#include <xlocale.h>
-extern wint_t __towlower_l(wint_t __wc, __locale_t __locale) __THROW attribute_hidden;
-extern wint_t __towupper_l(wint_t __wc, __locale_t __locale) __THROW attribute_hidden;
-extern int __iswctype_l(wint_t __wc, wctype_t __desc, __locale_t __locale) __THROW attribute_hidden;
-extern wint_t __towctrans_l(wint_t __wc, wctrans_t __desc, __locale_t __locale) __THROW attribute_hidden;
-#endif /* __UCLIBC_HAS_XLOCALE__ */
-
-/* We know wide char support is enabled. We wouldn't be here otherwise. */
-
-/* Define this if you want to unify the towupper and towlower code in the
- * towctrans function. */
-/* #define SMALL_UPLOW */
-
-/**********************************************************************/
-#ifdef __UCLIBC_MJN3_ONLY__
-#ifdef L_iswspace
-/* generates one warning */
-#warning TODO: Fix the __CTYPE_* codes!
-#endif
-#endif /* __UCLIBC_MJN3_ONLY__ */
-
-#if 1
-/* Taking advantage of the C99 mutual-exclusion guarantees for the various
- * (w)ctype classes, including the descriptions of printing and control
- * (w)chars, we can place each in one of the following mutually-exlusive
- * subsets. Since there are less than 16, we can store the data for
- * each (w)chars in a nibble. In contrast, glibc uses an unsigned int
- * per (w)char, with one bit flag for each is* type. While this allows
- * a simple '&' operation to determine the type vs. a range test and a
- * little special handling for the "blank" and "xdigit" types in my
- * approach, it also uses 8 times the space for the tables on the typical
- * 32-bit archs we supported.*/
-enum {
- __CTYPE_unclassified = 0,
- __CTYPE_alpha_nonupper_nonlower,
- __CTYPE_alpha_lower,
- __CTYPE_alpha_upper_lower,
- __CTYPE_alpha_upper,
- __CTYPE_digit,
- __CTYPE_punct,
- __CTYPE_graph,
- __CTYPE_print_space_nonblank,
- __CTYPE_print_space_blank,
- __CTYPE_space_nonblank_noncntrl,
- __CTYPE_space_blank_noncntrl,
- __CTYPE_cntrl_space_nonblank,
- __CTYPE_cntrl_space_blank,
- __CTYPE_cntrl_nonspace
-};
-#endif
-
-
-/* The following is used to implement wctype(), but it is defined
- * here because the ordering must agree with that of the enumeration
- * below (ignoring unclassified). */
-#define __CTYPE_TYPESTRING \
- "\6alnum\0\6alpha\0\6blank\0\6cntrl\0\6digit\0\6graph\0\6lower\0" \
- "\6print\0\6punct\0\6space\0\6upper\0\7xdigit\0\0"
-
-
-/* The values for wctype_t. */
-enum {
- _CTYPE_unclassified = 0,
- _CTYPE_isalnum,
- _CTYPE_isalpha,
- _CTYPE_isblank,
- _CTYPE_iscntrl,
- _CTYPE_isdigit,
- _CTYPE_isgraph,
- _CTYPE_islower,
- _CTYPE_isprint,
- _CTYPE_ispunct,
- _CTYPE_isspace,
- _CTYPE_isupper,
- _CTYPE_isxdigit /* _MUST_ be last of the standard classes! */
-};
-
-/* The following is used to implement wctrans(). */
-
-#define __CTYPE_TRANSTRING "\10tolower\0\10toupper\0\10totitle\0\0"
-
-enum {
- _CTYPE_tolower = 1,
- _CTYPE_toupper,
- _CTYPE_totitle
-};
-
-/*--------------------------------------------------------------------*/
-
-#define _CTYPE_iswxdigit (_CTYPE_isxdigit)
-
-/*--------------------------------------------------------------------*/
-
-#ifdef __UCLIBC_MJN3_ONLY__
-#ifdef L_iswspace
-/* generates one warning */
-#warning TODO: Fix WC* defines!
-#endif
-#endif /* __UCLIBC_MJN3_ONLY__ */
-
-#define ENCODING ((__UCLIBC_CURLOCALE_DATA).encoding)
-
-#define WCctype ((__UCLIBC_CURLOCALE_DATA).tblwctype)
-#define WCuplow ((__UCLIBC_CURLOCALE_DATA).tblwuplow)
-#define WCcmob ((__UCLIBC_CURLOCALE_DATA).tblwcomb)
-#define WCuplow_diff ((__UCLIBC_CURLOCALE_DATA).tblwuplow_diff)
-
-
-#define WC_TABLE_DOMAIN_MAX __LOCALE_DATA_WC_TABLE_DOMAIN_MAX
-
-#define WCctype_II_LEN __LOCALE_DATA_WCctype_II_LEN
-#define WCctype_TI_LEN __LOCALE_DATA_WCctype_TI_LEN
-#define WCctype_UT_LEN __LOCALE_DATA_WCctype_UT_LEN
-#define WCctype_II_SHIFT __LOCALE_DATA_WCctype_II_SHIFT
-#define WCctype_TI_SHIFT __LOCALE_DATA_WCctype_TI_SHIFT
-
-#define WCuplow_II_LEN __LOCALE_DATA_WCuplow_II_LEN
-#define WCuplow_TI_LEN __LOCALE_DATA_WCuplow_TI_LEN
-#define WCuplow_UT_LEN __LOCALE_DATA_WCuplow_UT_LEN
-#define WCuplow_II_SHIFT __LOCALE_DATA_WCuplow_II_SHIFT
-#define WCuplow_TI_SHIFT __LOCALE_DATA_WCuplow_TI_SHIFT
-
-
-#define WCctype_TI_MASK ((1 << (WCctype_TI_SHIFT)) - 1)
-#define WCctype_II_MASK ((1 << (WCctype_II_SHIFT)) - 1)
-
-/**********************************************************************/
-
-#undef __PASTE2
-#undef __PASTE3
-#define __PASTE2(X,Y) X ## Y
-#define __PASTE3(X,Y,Z) X ## Y ## Z
-
-#ifdef __UCLIBC_DO_XLOCALE
-
-extern int __iswctype_l (wint_t __wc, wctype_t __desc, __locale_t __locale)
- __THROW attribute_hidden;
-
-#define ISW_FUNC_BODY(NAME) \
-int attribute_hidden __PASTE3(__isw,NAME,_l) (wint_t wc, __locale_t l) \
-{ \
- return __iswctype_l(wc, __PASTE2(_CTYPE_is,NAME), l); \
-} \
-weak_alias(__PASTE3(__isw,NAME,_l), __PASTE3(isw,NAME,_l))
-
-#else /* __UCLIBC_DO_XLOCALE */
-
-extern int __iswctype (wint_t __wc, wctype_t __desc) __THROW attribute_hidden;
-
-#define ISW_FUNC_BODY(NAME) \
-int attribute_hidden __PASTE2(__isw,NAME) (wint_t wc) \
-{ \
- return __iswctype(wc, __PASTE2(_CTYPE_is,NAME)); \
-} \
-weak_alias(__PASTE2(__isw,NAME), __PASTE2(isw,NAME))
-
-#endif /* __UCLIBC_DO_XLOCALE */
-/**********************************************************************/
-#if defined(L_iswalnum) || defined(L_iswalnum_l)
-
-ISW_FUNC_BODY(alnum);
-
-#endif
-/**********************************************************************/
-#if defined(L_iswalpha) || defined(L_iswalpha_l)
-
-ISW_FUNC_BODY(alpha);
-
-#endif
-/**********************************************************************/
-#if defined(L_iswblank) || defined(L_iswblank_l)
-
-ISW_FUNC_BODY(blank);
-
-#endif
-/**********************************************************************/
-#if defined(L_iswcntrl) || defined(L_iswcntrl_l)
-
-ISW_FUNC_BODY(cntrl);
-
-#endif
-/**********************************************************************/
-#if defined(L_iswdigit) || defined(L_iswdigit_l)
-
-ISW_FUNC_BODY(digit);
-
-#endif
-/**********************************************************************/
-#if defined(L_iswgraph) || defined(L_iswgraph_l)
-
-ISW_FUNC_BODY(graph);
-
-#endif
-/**********************************************************************/
-#if defined(L_iswlower) || defined(L_iswlower_l)
-
-ISW_FUNC_BODY(lower);
-
-#endif
-/**********************************************************************/
-#if defined(L_iswprint) || defined(L_iswprint_l)
-
-ISW_FUNC_BODY(print);
-
-#endif
-/**********************************************************************/
-#if defined(L_iswpunct) || defined(L_iswpunct_l)
-
-ISW_FUNC_BODY(punct);
-
-#endif
-/**********************************************************************/
-#if defined(L_iswspace) || defined(L_iswspace_l)
-
-ISW_FUNC_BODY(space);
-
-#endif
-/**********************************************************************/
-#if defined(L_iswupper) || defined(L_iswupper_l)
-
-ISW_FUNC_BODY(upper);
-
-#endif
-/**********************************************************************/
-#if defined(L_iswxdigit) || defined(L_iswxdigit_l)
-
-ISW_FUNC_BODY(xdigit);
-
-#endif
-/**********************************************************************/
-#if defined(L_towlower) || defined(L_towlower_l)
-
-#ifdef L_towlower
-#define TOWLOWER(w) __towlower(w)
-#else /* L_towlower */
-#define TOWLOWER(w) __towlower_l(w, __locale_t locale)
-#undef __UCLIBC_CURLOCALE_DATA
-#undef __UCLIBC_CURLOCALE
-#define __UCLIBC_CURLOCALE_DATA (*locale)
-#define __UCLIBC_CURLOCALE (locale)
-#endif /* L_towlower */
-
-#ifdef __UCLIBC_HAS_XLOCALE__
-#define TOWCTRANS(w,d) __towctrans_l(w,d, __UCLIBC_CURLOCALE)
-#else /* __UCLIBC_HAS_XLOCALE__ */
-#define TOWCTRANS(w,d) __towctrans(w,d)
-#endif /* __UCLIBC_HAS_XLOCALE__ */
-
-#define __C_towlower(wc) \
- ((((__uwchar_t)(wc)) <= 0x7f) ? (__C_ctype_tolower)[(wc)] : (wc))
-
-#ifdef __LOCALE_C_ONLY
-
-wint_t attribute_hidden __towlower(wint_t wc)
-{
-#ifdef __UCLIBC_HAS_CTYPE_TABLES__
- return __C_towlower(wc);
-#else
- return (wc == ((unsigned int)(wc)))
- ? __C_tolower(((unsigned int)(wc)))
- : 0;
-#endif
-}
-
-#else /* __LOCALE_C_ONLY */
-
-#ifdef SMALL_UPLOW
-
-#if defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__)
-
-wint_t attribute_hidden __towlower(wint_t wc)
-{
- return __towctrans_l(wc, _CTYPE_tolower, __UCLIBC_CURLOCALE);
-}
-
-#else /* defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__) */
-
-wint_t attribute_hidden TOWLOWER(wint_t wc)
-{
- return TOWCTRANS(wc, _CTYPE_tolower);
-}
-
-#endif /* defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__) */
-
-#else /* SMALL_UPLOW */
-
-#if defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__)
-
-wint_t attribute_hidden __towlower(wint_t wc)
-{
- return __towlower_l(wc, __UCLIBC_CURLOCALE);
-}
-
-#else /* defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__) */
-
-wint_t attribute_hidden TOWLOWER(wint_t wc)
-{
- unsigned int sc, n, i;
- __uwchar_t u = wc;
-
- if (ENCODING == __ctype_encoding_7_bit) {
- /* We're in the C/POSIX locale, so ignore the tables. */
- return __C_towlower(wc);
- }
-
- if (u <= WC_TABLE_DOMAIN_MAX) {
- sc = u & ((1 << WCuplow_TI_SHIFT) - 1);
- u >>= WCuplow_TI_SHIFT;
- n = u & ((1 << WCuplow_II_SHIFT) - 1);
- u >>= WCuplow_II_SHIFT;
-
- i = ((unsigned int) WCuplow[u]) << WCuplow_II_SHIFT;
- i = ((unsigned int) WCuplow[WCuplow_II_LEN + i + n])
- << WCuplow_TI_SHIFT;
- i = ((unsigned int) WCuplow[WCuplow_II_LEN + WCuplow_TI_LEN
- + i + sc]) << 1;
- wc += WCuplow_diff[i + 1];
- }
- return wc;
-}
-
-#endif /* defined(L_towlower) && defined(__UCLIBC_HAS_XLOCALE__) */
-
-#endif /* SMALL_UPLOW */
-
-#ifdef L_towlower_l
-strong_alias(__towlower_l,towlower_l)
-#endif /* L_towlower_l */
-
-#endif /* __LOCALE_C_ONLY */
-
-#ifndef L_towlower_l
-strong_alias(__towlower,towlower)
-#endif
-
-#endif
-/**********************************************************************/
-#if defined(L_towupper) || defined(L_towupper_l)
-
-#ifdef L_towupper
-#define TOWUPPER(w) __towupper(w)
-#else /* L_towupper */
-#define TOWUPPER(w) __towupper_l(w, __locale_t locale)
-#undef __UCLIBC_CURLOCALE_DATA
-#undef __UCLIBC_CURLOCALE
-#define __UCLIBC_CURLOCALE_DATA (*locale)
-#define __UCLIBC_CURLOCALE (locale)
-#endif /* L_towupper */
-
-#ifdef __UCLIBC_HAS_XLOCALE__
-#define TOWCTRANS(w,d) __towctrans_l(w,d, __UCLIBC_CURLOCALE)
-#else /* __UCLIBC_HAS_XLOCALE__ */
-#define TOWCTRANS(w,d) __towctrans(w,d)
-#endif /* __UCLIBC_HAS_XLOCALE__ */
-
-#define __C_towupper(wc) \
- ((((__uwchar_t)(wc)) <= 0x7f) ? (__C_ctype_toupper)[(wc)] : (wc))
-
-#ifdef __LOCALE_C_ONLY
-
-wint_t attribute_hidden __towupper(wint_t wc)
-{
-#ifdef __UCLIBC_HAS_CTYPE_TABLES__
- return __C_towupper(wc);
-#else
- return (wc == ((unsigned int)(wc)))
- ? __C_toupper(((unsigned int)(wc)))
- : 0;
-#endif
-
-}
-
-#else /* __LOCALE_C_ONLY */
-
-#ifdef SMALL_UPLOW
-
-#if defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__)
-
-wint_t attribute_hidden __towupper(wint_t wc)
-{
- return __towctrans_l(wc, _CTYPE_toupper, __UCLIBC_CURLOCALE);
-}
-
-#else /* defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__) */
-
-wint_t attribute_hidden TOWUPPER(wint_t wc)
-{
- return TOWCTRANS(wc, _CTYPE_toupper);
-}
-
-#endif /* defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__) */
-
-#else /* SMALL_UPLOW */
-
-#if defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__)
-
-wint_t attribute_hidden __towupper(wint_t wc)
-{
- return __towupper_l(wc, __UCLIBC_CURLOCALE);
-}
-
-#else /* defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__) */
-
-wint_t attribute_hidden TOWUPPER(wint_t wc)
-{
- unsigned int sc, n, i;
- __uwchar_t u = wc;
-
- if (ENCODING == __ctype_encoding_7_bit) {
- /* We're in the C/POSIX locale, so ignore the tables. */
- return __C_towupper(wc);
- }
-
- if (u <= WC_TABLE_DOMAIN_MAX) {
- sc = u & ((1 << WCuplow_TI_SHIFT) - 1);
- u >>= WCuplow_TI_SHIFT;
- n = u & ((1 << WCuplow_II_SHIFT) - 1);
- u >>= WCuplow_II_SHIFT;
-
- i = ((unsigned int) WCuplow[u]) << WCuplow_II_SHIFT;
- i = ((unsigned int) WCuplow[WCuplow_II_LEN + i + n])
- << WCuplow_TI_SHIFT;
- i = ((unsigned int) WCuplow[WCuplow_II_LEN + WCuplow_TI_LEN
- + i + sc]) << 1;
- wc += WCuplow_diff[i];
- }
- return wc;
-}
-
-#endif /* defined(L_towupper) && defined(__UCLIBC_HAS_XLOCALE__) */
-
-#endif /* SMALL_UPLOW */
-
-#ifdef L_towupper_l
-strong_alias(__towupper_l,towupper_l)
-#endif /* L_towupper_l */
-
-#endif /* __LOCALE_C_ONLY */
-
-#ifndef L_towupper_l
-strong_alias(__towupper,towupper)
-#endif
-
-#endif
-/**********************************************************************/
-#ifdef L_wctype
-
-static const unsigned char typestring[] = __CTYPE_TYPESTRING;
-/* extern const unsigned char typestring[]; */
-
-wctype_t attribute_hidden __wctype(const char *property)
-{
- const unsigned char *p;
- int i;
-
- p = typestring;
- i = 1;
- do {
- if (!__strcmp(property, ++p)) {
- return i;
- }
- ++i;
- p += p[-1];
- } while (*p);
-
- /* TODO - Add locale-specific classifications. */
- return 0;
-}
-strong_alias(__wctype,wctype)
-
-#endif
-/**********************************************************************/
-#ifdef L_wctype_l
-
-#ifdef __UCLIBC_MJN3_ONLY__
-#warning REMINDER: Currently wctype_l simply calls wctype.
-#endif /* __UCLIBC_MJN3_ONLY__ */
-
-wctype_t attribute_hidden __wctype_l (const char *property, __locale_t locale)
-{
- return __wctype(property);
-}
-
-weak_alias(__wctype_l, wctype_l)
-
-#endif
-/**********************************************************************/
-#if defined(L_iswctype) || defined(L_iswctype_l)
-
-#define __C_iswdigit(c) \
- ((sizeof(c) == sizeof(char)) \
- ? (((unsigned char)((c) - '0')) < 10) \
- : (((__uwchar_t)((c) - '0')) < 10))
-#define __C_iswxdigit(c) \
- (__C_iswdigit(c) \
- || ((sizeof(c) == sizeof(char)) \
- ? (((unsigned char)((((c)) | 0x20) - 'a')) < 6) \
- : (((__uwchar_t)((((c)) | 0x20) - 'a')) < 6)))
-
-#ifdef __UCLIBC_MJN3_ONLY__
-#ifdef L_iswctype
-#warning CONSIDER: Change to bit shift? would need to sync with wctype.h
-#endif
-#endif /* __UCLIBC_MJN3_ONLY__ */
-
-
-#ifdef __UCLIBC_HAS_CTYPE_TABLES__
-#if !defined(__UCLIBC_HAS_XLOCALE__) || defined(L_iswctype_l)
-
-static const unsigned short int desc2flag[] = {
- [_CTYPE_unclassified] = 0,
- [_CTYPE_isalnum] = (unsigned short int) _ISwalnum,
- [_CTYPE_isalpha] = (unsigned short int) _ISwalpha,
- [_CTYPE_isblank] = (unsigned short int) _ISwblank,
- [_CTYPE_iscntrl] = (unsigned short int) _ISwcntrl,
- [_CTYPE_isdigit] = (unsigned short int) _ISwdigit,
- [_CTYPE_isgraph] = (unsigned short int) _ISwgraph,
- [_CTYPE_islower] = (unsigned short int) _ISwlower,
- [_CTYPE_isprint] = (unsigned short int) _ISwprint,
- [_CTYPE_ispunct] = (unsigned short int) _ISwpunct,
- [_CTYPE_isspace] = (unsigned short int) _ISwspace,
- [_CTYPE_isupper] = (unsigned short int) _ISwupper,
- [_CTYPE_isxdigit] = (unsigned short int) _ISwxdigit,
-};
-
-#endif /* defined(L_iswctype_L) || defined(__LOCALE_C_ONLY) */
-#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
-
-#ifdef __LOCALE_C_ONLY
-
-#ifdef __UCLIBC_HAS_CTYPE_TABLES__
-
-int attribute_hidden __iswctype(wint_t wc, wctype_t desc)
-{
- /* Note... wctype_t is unsigned. */
-
- if ((((__uwchar_t) wc) <= 0x7f)
- && (desc < (sizeof(desc2flag)/sizeof(desc2flag[0])))
- ) {
- return __isctype(wc, desc2flag[desc]);
- }
- return 0;
-}
-
-#else /* __UCLIBC_HAS_CTYPE_TABLES__ */
-
-int attribute_hidden __iswctype(wint_t wc, wctype_t desc)
-{
- /* This is lame, but it is here just to get it working for now. */
-
- if (wc == ((unsigned int)(wc))) {
- switch(desc) {
- case _CTYPE_isupper:
- return __C_isupper((unsigned int)(wc));
- case _CTYPE_islower:
- return __C_islower((unsigned int)(wc));
- case _CTYPE_isalpha:
- return __C_isalpha((unsigned int)(wc));
- case _CTYPE_isdigit:
- return __C_isdigit((unsigned int)(wc));
- case _CTYPE_isxdigit:
- return __C_isxdigit((unsigned int)(wc));
- case _CTYPE_isspace:
- return __C_isspace((unsigned int)(wc));
- case _CTYPE_isprint:
- return __C_isprint((unsigned int)(wc));
- case _CTYPE_isgraph:
- return __C_isgraph((unsigned int)(wc));
- case _CTYPE_isblank:
- return __C_isblank((unsigned int)(wc));
- case _CTYPE_iscntrl:
- return __C_iscntrl((unsigned int)(wc));
- case _CTYPE_ispunct:
- return __C_ispunct((unsigned int)(wc));
- case _CTYPE_isalnum:
- return __C_isalnum((unsigned int)(wc));
- default:
- break;
- }
- }
- return 0;
-}
-
-#endif /* __UCLIBC_HAS_CTYPE_TABLES__ */
-
-#else /* __LOCALE_C_ONLY */
-
-#ifdef __UCLIBC_MJN3_ONLY__
-#ifdef L_iswctype
-#warning CONSIDER: Handle combining class?
-#endif
-#endif /* __UCLIBC_MJN3_ONLY__ */
-
-#ifdef L_iswctype
-#define ISWCTYPE(w,d) __iswctype(w,d)
-#else /* L_iswctype */
-#define ISWCTYPE(w,d) __iswctype_l(w,d, __locale_t locale)
-#undef __UCLIBC_CURLOCALE_DATA
-#undef __UCLIBC_CURLOCALE
-#define __UCLIBC_CURLOCALE_DATA (*locale)
-#define __UCLIBC_CURLOCALE (locale)
-#endif /* L_iswctype */
-
-#if defined(L_iswctype) && defined(__UCLIBC_HAS_XLOCALE__)
-
-int attribute_hidden __iswctype(wint_t wc, wctype_t desc)
-{
- return __iswctype_l(wc, desc, __UCLIBC_CURLOCALE);
-}
-
-#else /* defined(L_iswctype) && defined(__UCLIBC_HAS_XLOCALE__) */
-
-int attribute_hidden ISWCTYPE(wint_t wc, wctype_t desc)
-{
- unsigned int sc, n, i0, i1;
- unsigned char d = __CTYPE_unclassified;
-
- if ((ENCODING != __ctype_encoding_7_bit) || (((__uwchar_t) wc) <= 0x7f)){
- if (desc < _CTYPE_iswxdigit) {
- if (((__uwchar_t) wc) <= WC_TABLE_DOMAIN_MAX) {
- /* From here on, we know wc > 0. */
- sc = wc & WCctype_TI_MASK;
- wc >>= WCctype_TI_SHIFT;
- n = wc & WCctype_II_MASK;
- wc >>= WCctype_II_SHIFT;
-
- i0 = WCctype[wc];
- i0 <<= WCctype_II_SHIFT;
- i1 = WCctype[WCctype_II_LEN + i0 + n];
- i1 <<= (WCctype_TI_SHIFT-1);
- d = WCctype[WCctype_II_LEN + WCctype_TI_LEN + i1 + (sc >> 1)];
-
- d = (sc & 1) ? (d >> 4) : (d & 0xf);
- } else if ( ((((__uwchar_t)(wc - 0xe0020UL)) <= 0x5f)
- || (wc == 0xe0001UL))
- || ( (((__uwchar_t)(wc - 0xf0000UL)) < 0x20000UL)
- && ((wc & 0xffffU) <= 0xfffdU))
- ) {
- d = __CTYPE_punct;
- }
-
-#if 0
- return ( ((unsigned char)(d - ctype_range[2*desc]))
- <= ctype_range[2*desc + 1] )
- && ((desc != _CTYPE_iswblank) || (d & 1));
-#else
- return (__UCLIBC_CURLOCALE_DATA).code2flag[d] & desc2flag[desc];
-#endif
- }
-
-#ifdef __UCLIBC_MJN3_ONLY__
-#warning TODO: xdigit really needs to be handled better. Remember only for ascii!
-#endif /* __UCLIBC_MJN3_ONLY__ */
- /* TODO - Add locale-specific classifications. */
- return (desc == _CTYPE_iswxdigit) ? __C_iswxdigit(wc) : 0;
- }
- return 0;
-}
-
-#endif /* defined(L_iswctype) && defined(__UCLIBC_HAS_XLOCALE__) */
-
-#ifdef L_iswctype_l
-weak_alias(__iswctype_l, iswctype_l)
-#endif /* L_iswctype_l */
-
-#endif /* __LOCALE_C_ONLY */
-
-#ifdef L_iswctype
-weak_alias(__iswctype, iswctype)
-#endif /* L_iswctype */
-
-#endif
-/**********************************************************************/
-#if defined(L_towctrans) || defined(L_towctrans_l)
-
-#ifdef __LOCALE_C_ONLY
-
-/* Minimal support for C/POSIX locale. */
-
-#ifndef _tolower
-#warning _tolower is undefined!
-#define _tolower(c) __tolower(c)
-#endif
-#ifndef _toupper
-#warning _toupper is undefined!
-#define _toupper(c) __toupper(c)
-#endif
-
-wint_t attribute_hidden __towctrans(wint_t wc, wctrans_t desc)
-{
- if (((unsigned int)(desc - _CTYPE_tolower))
- <= (_CTYPE_toupper - _CTYPE_tolower)
- ) {
- /* Transliteration is either tolower or toupper. */
- if (((__uwchar_t) wc) <= 0x7f) {
- return (desc == _CTYPE_tolower) ? _tolower(wc) : _toupper(wc);
- }
- } else {
- __set_errno(EINVAL); /* Invalid transliteration. */
- }
- return wc;
-}
-
-#else /* __LOCALE_C_ONLY */
-
-#ifdef L_towctrans
-#define TOWCTRANS(w,d) __towctrans(w,d)
-#else /* L_towctrans */
-#define TOWCTRANS(w,d) __towctrans_l(w,d, __locale_t locale)
-#undef __UCLIBC_CURLOCALE_DATA
-#undef __UCLIBC_CURLOCALE
-#define __UCLIBC_CURLOCALE_DATA (*locale)
-#define __UCLIBC_CURLOCALE (locale)
-#endif /* L_towctrans */
-
-#ifdef __UCLIBC_HAS_XLOCALE__
-#define TOWLOWER(w,l) __towlower_l(w,l)
-#define TOWUPPER(w,l) __towupper_l(w,l)
-#else /* __UCLIBC_HAS_XLOCALE__ */
-#define TOWLOWER(w,l) __towlower(w)
-#define TOWUPPER(w,l) __towupper(w)
-#endif /* __UCLIBC_HAS_XLOCALE__ */
-
-#if defined(L_towctrans) && defined(__UCLIBC_HAS_XLOCALE__)
-
-wint_t attribute_hidden __towctrans(wint_t wc, wctrans_t desc)
-{
- return __towctrans_l(wc, desc, __UCLIBC_CURLOCALE);
-}
-
-#else /* defined(L_towctrans) && defined(__UCLIBC_HAS_XLOCALE__) */
-
-#ifdef SMALL_UPLOW
-
-wint_t attribute_hidden TOWCTRANS(wint_t wc, wctrans_t desc)
-{
- unsigned int sc, n, i;
- __uwchar_t u = wc;
-
- /* TODO - clean up */
- if (ENCODING == __ctype_encoding_7_bit) {
- if ((((__uwchar_t) wc) > 0x7f)
- || (((unsigned int)(desc - _CTYPE_tolower))
- > (_CTYPE_toupper - _CTYPE_tolower))
- ){
- /* We're in the C/POSIX locale, so ignore non-ASCII values
- * as well an any mappings other than toupper or tolower. */
- return wc;
- }
- }
-
- if (((unsigned int)(desc - _CTYPE_tolower))
- <= (_CTYPE_totitle - _CTYPE_tolower)
- ) {
- if (u <= WC_TABLE_DOMAIN_MAX) {
- sc = u & ((1 << WCuplow_TI_SHIFT) - 1);
- u >>= WCuplow_TI_SHIFT;
- n = u & ((1 << WCuplow_II_SHIFT) - 1);
- u >>= WCuplow_II_SHIFT;
-
- i = ((unsigned int) WCuplow[u]) << WCuplow_II_SHIFT;
- i = ((unsigned int) WCuplow[WCuplow_II_LEN + i + n])
- << WCuplow_TI_SHIFT;
- i = ((unsigned int) WCuplow[WCuplow_II_LEN + WCuplow_TI_LEN
- + i + sc]) << 1;
- if (desc == _CTYPE_tolower) {
- ++i;
- }
- wc += WCuplow_diff[i];
- if (desc == _CTYPE_totitle) {
-#ifdef __UCLIBC_MJN3_ONLY__
-#warning TODO: Verify totitle special cases!
-#endif /* __UCLIBC_MJN3_ONLY__ */
- /* WARNING! These special cases work for glibc 2.2.4. Changes
- * may be needed if the glibc locale tables are updated. */
- if ( (((__uwchar_t)(wc - 0x1c4)) <= (0x1cc - 0x1c4))
- || (wc == 0x1f1)
- ) {
- ++wc;
- }
- }
- }
- } else {
- /* TODO - Deal with other transliterations. */
- __set_errno(EINVAL);
- }
-
- return wc;
-}
-
-#else /* SMALL_UPLOW */
-
-wint_t attribute_hidden TOWCTRANS(wint_t wc, wctrans_t desc)
-{
- if (ENCODING == __ctype_encoding_7_bit) {
- if ((((__uwchar_t) wc) > 0x7f)
- || (((unsigned int)(desc - _CTYPE_tolower))
- > (_CTYPE_toupper - _CTYPE_tolower))
- ){
- /* We're in the C/POSIX locale, so ignore non-ASCII values
- * as well an any mappings other than toupper or tolower. */
- return wc;
- }
- }
-
- if (desc == _CTYPE_tolower) {
- return TOWLOWER(wc, __UCLIBC_CURLOCALE);
- } else if (((unsigned int)(desc - _CTYPE_toupper))
- <= (_CTYPE_totitle - _CTYPE_toupper)
- ) {
- wc = TOWUPPER(wc, __UCLIBC_CURLOCALE);
- if (desc == _CTYPE_totitle) {
-#ifdef __UCLIBC_MJN3_ONLY__
-#warning TODO: Verify totitle special cases!
-#endif /* __UCLIBC_MJN3_ONLY__ */
- /* WARNING! These special cases work for glibc 2.2.4. Changes
- * may be needed if the glibc locale tables are updated. */
- if ( (((__uwchar_t)(wc - 0x1c4)) <= (0x1cc - 0x1c4))
- || (wc == 0x1f1)
- ) {
- ++wc;
- }
- }
- } else {
- /* TODO - Deal with other transliterations. */
- __set_errno(EINVAL);
- }
- return wc;
-}
-
-#endif /* SMALL_UPLOW */
-
-#endif /* defined(L_towctrans) && defined(__UCLIBC_HAS_XLOCALE__) */
-
-#ifdef L_towctrans_l
-strong_alias(__towctrans_l, towctrans_l)
-#endif /* L_towctrans_l */
-
-#endif /* __LOCALE_C_ONLY */
-
-#ifndef L_towctrans_l
-strong_alias(__towctrans,towctrans)
-#endif
-
-#endif
-/**********************************************************************/
-#ifdef L_wctrans
-
-static const char transstring[] = __CTYPE_TRANSTRING;
-
-wctrans_t attribute_hidden __wctrans(const char *property)
-{
- const unsigned char *p;
- int i;
-
- p = transstring;
- i = 1;
- do {
- if (!__strcmp(property, ++p)) {
- return i;
- }
- ++i;
- p += p[-1];
- } while (*p);
-
- /* TODO - Add locale-specific translations. */
- return 0;
-}
-strong_alias(__wctrans,wctrans)
-
-#endif
-/**********************************************************************/
-#ifdef L_wctrans_l
-
-#ifdef __UCLIBC_MJN3_ONLY__
-#warning REMINDER: Currently wctrans_l simply calls wctrans.
-#endif /* __UCLIBC_MJN3_ONLY__ */
-
-extern wctrans_t __wctrans (__const char *__property) __THROW attribute_hidden;
-
-wctrans_t __wctrans_l(const char *property, __locale_t locale)
-{
- return __wctrans(property);
-}
-
-weak_alias(__wctrans_l, wctrans_l)
-
-#endif
-/**********************************************************************/
+#define L_wctype
+#include "_wctype.c"
diff --git a/libc/misc/wctype/wctype_l.c b/libc/misc/wctype/wctype_l.c
new file mode 100644
index 000000000..65f82e2b1
--- /dev/null
+++ b/libc/misc/wctype/wctype_l.c
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2002-2006 Manuel Novoa III <mjn3@uclibc.org>
+ *
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+#define L_wctype_l
+#define __UCLIBC_DO_XLOCALE
+#include "_wctype.c"
diff --git a/libc/misc/wordexp/Makefile.in b/libc/misc/wordexp/Makefile.in
index f4094d5c2..526807f25 100644
--- a/libc/misc/wordexp/Makefile.in
+++ b/libc/misc/wordexp/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:=wordexp.c
+CSRC := wordexp.c
-MISC_WORDEXP_DIR:=$(top_srcdir)libc/misc/wordexp
-MISC_WORDEXP_OUT:=$(top_builddir)libc/misc/wordexp
+MISC_WORDEXP_DIR := $(top_srcdir)libc/misc/wordexp
+MISC_WORDEXP_OUT := $(top_builddir)libc/misc/wordexp
-MISC_WORDEXP_SRC:=$(patsubst %.c,$(MISC_WORDEXP_DIR)/%.c,$(CSRC))
-MISC_WORDEXP_OBJ:=$(patsubst %.c,$(MISC_WORDEXP_OUT)/%.o,$(CSRC))
+MISC_WORDEXP_SRC := $(patsubst %.c,$(MISC_WORDEXP_DIR)/%.c,$(CSRC))
+MISC_WORDEXP_OBJ := $(patsubst %.c,$(MISC_WORDEXP_OUT)/%.o,$(CSRC))
-libc-a-$(UCLIBC_HAS_WORDEXP)+=$(MISC_WORDEXP_OBJ)
-libc-so-$(UCLIBC_HAS_WORDEXP)+=$(MISC_WORDEXP_OBJ:.o=.os)
+libc-$(UCLIBC_HAS_WORDEXP) += $(MISC_WORDEXP_OBJ)
-libc-multi-$(UCLIBC_HAS_WORDEXP)+=$(MISC_WORDEXP_SRC)
-
-objclean-y+=misc_wordexp_objclean
+objclean-y += misc_wordexp_objclean
misc_wordexp_objclean:
$(RM) $(MISC_WORDEXP_OUT)/*.{o,os}
diff --git a/libc/misc/wordexp/wordexp.c b/libc/misc/wordexp/wordexp.c
index a91e64e3c..1693d8b8a 100644
--- a/libc/misc/wordexp/wordexp.c
+++ b/libc/misc/wordexp/wordexp.c
@@ -19,26 +19,6 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#define mempcpy __mempcpy
-#define stpcpy __stpcpy
-#define strndup __strndup
-#define strspn __strspn
-#define strcspn __strcspn
-#define setenv __setenv
-#define unsetenv __unsetenv
-#define waitpid __waitpid
-#define kill __kill
-#define getuid __getuid
-#define getpwnam_r __getpwnam_r
-#define getpwuid_r __getpwuid_r
-#define execve __execve
-#define dup2 __dup2
-#define atoi __atoi
-#define fnmatch __fnmatch
-#define pipe __pipe
-#define fork __fork
-
-#define _GNU_SOURCE
#include <features.h>
#include <sys/types.h>
#include <sys/wait.h>
@@ -55,11 +35,46 @@
#include <glob.h>
#include <wordexp.h>
-extern void __wordfree (wordexp_t *__wordexp) __THROW 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(mempcpy)
+libc_hidden_proto(stpcpy)
+libc_hidden_proto(strchr)
+libc_hidden_proto(strcpy)
+libc_hidden_proto(strdup)
+libc_hidden_proto(strlen)
+libc_hidden_proto(strndup)
+libc_hidden_proto(strspn)
+libc_hidden_proto(strcspn)
+libc_hidden_proto(__environ)
+libc_hidden_proto(setenv)
+libc_hidden_proto(unsetenv)
+libc_hidden_proto(waitpid)
+libc_hidden_proto(kill)
+libc_hidden_proto(getuid)
+libc_hidden_proto(getpwnam_r)
+libc_hidden_proto(getpwuid_r)
+libc_hidden_proto(execve)
+libc_hidden_proto(dup2)
+libc_hidden_proto(atoi)
+libc_hidden_proto(fnmatch)
+libc_hidden_proto(pipe)
+libc_hidden_proto(fork)
+libc_hidden_proto(open)
+libc_hidden_proto(close)
+libc_hidden_proto(read)
+libc_hidden_proto(getenv)
+libc_hidden_proto(getpid)
+libc_hidden_proto(sprintf)
+libc_hidden_proto(fprintf)
+libc_hidden_proto(abort)
+libc_hidden_proto(stderr)
+libc_hidden_proto(glob)
+libc_hidden_proto(globfree)
+libc_hidden_proto(wordfree)
+#ifdef __UCLIBC_HAS_XLOCALE__
+libc_hidden_proto(__ctype_b_loc)
+#else
+libc_hidden_proto(__ctype_b)
+#endif
#define __WORDEXP_FULL
//#undef __WORDEXP_FULL
@@ -73,8 +88,8 @@ extern void __globfree (glob_t *__pglob) __THROW attribute_hidden;
//extern char **__libc_argv;
/* FIXME!!!! */
-int __libc_argc;
-char **__libc_argv;
+int attribute_hidden __libc_argc;
+char attribute_hidden **__libc_argv;
/* Some forward declarations */
static int parse_dollars(char **word, size_t * word_length,
@@ -155,7 +170,7 @@ static char *w_addstr(char *buffer, size_t * actlen, size_t * maxlen,
{
size_t len;
assert(str != NULL); /* w_addstr only called from this file */
- len = __strlen(str);
+ len = strlen(str);
return w_addmem(buffer, actlen, maxlen, str, len);
}
@@ -170,7 +185,7 @@ static int w_addword(wordexp_t * pwordexp, char *word)
* the caller sees them.
*/
if (word == NULL) {
- word = __strdup("");
+ word = strdup("");
if (word == NULL)
goto no_space;
}
@@ -272,7 +287,7 @@ parse_tilde(char **word, size_t * word_length, size_t * max_length,
if (*word_length != 0) {
if (!((*word)[*word_length - 1] == '=' && wordc == 0)) {
if (!((*word)[*word_length - 1] == ':'
- && __strchr(*word, '=') && wordc == 0)) {
+ && strchr(*word, '=') && wordc == 0)) {
*word = w_addchar(*word, word_length, max_length, '~');
return *word ? 0 : WRDE_NOSPACE;
}
@@ -303,7 +318,7 @@ parse_tilde(char **word, size_t * word_length, size_t * max_length,
results are unspecified. We do a lookup on the uid if
HOME is unset. */
- home = __getenv("HOME");
+ home = getenv("HOME");
if (home != NULL) {
*word = w_addstr(*word, word_length, max_length, home);
if (*word == NULL)
@@ -367,7 +382,7 @@ do_parse_glob(const char *glob_word, char **word, size_t * word_length,
int match;
glob_t globbuf;
- error = __glob(glob_word, GLOB_NOCHECK, NULL, &globbuf);
+ error = glob(glob_word, GLOB_NOCHECK, NULL, &globbuf);
if (error != 0) {
/* We can only run into memory problems. */
@@ -386,7 +401,7 @@ do_parse_glob(const char *glob_word, char **word, size_t * word_length,
globbuf.gl_pathv[match]);
}
- __globfree(&globbuf);
+ globfree(&globbuf);
return *word ? 0 : WRDE_NOSPACE;
}
@@ -397,15 +412,15 @@ do_parse_glob(const char *glob_word, char **word, size_t * word_length,
}
for (match = 0; match < globbuf.gl_pathc; ++match) {
- char *matching_word = __strdup(globbuf.gl_pathv[match]);
+ char *matching_word = strdup(globbuf.gl_pathv[match]);
if (matching_word == NULL || w_addword(pwordexp, matching_word)) {
- __globfree(&globbuf);
+ globfree(&globbuf);
return WRDE_NOSPACE;
}
}
- __globfree(&globbuf);
+ globfree(&globbuf);
return 0;
}
@@ -424,8 +439,8 @@ parse_glob(char **word, size_t * word_length, size_t * max_length,
glob_list.we_wordv = NULL;
glob_list.we_offs = 0;
for (; words[*offset] != '\0'; ++*offset) {
- if ((ifs && __strchr(ifs, words[*offset])) ||
- (!ifs && __strchr(" \t\n", words[*offset])))
+ if ((ifs && strchr(ifs, words[*offset])) ||
+ (!ifs && strchr(" \t\n", words[*offset])))
/* Reached IFS */
break;
@@ -488,7 +503,7 @@ parse_glob(char **word, size_t * word_length, size_t * max_length,
/* Now tidy up */
tidy_up:
- __wordfree(&glob_list);
+ wordfree(&glob_list);
return error;
}
@@ -515,7 +530,7 @@ static int eval_expr(char *expr, long int *result);
static char *_itoa(unsigned long long int value, char *buflim)
{
- __sprintf(buflim, "%llu", value);
+ sprintf(buflim, "%llu", value);
return buflim;
}
@@ -782,24 +797,24 @@ exec_comm_child(char *comm, int *fildes, int showerr, int noexec)
/* Redirect output. */
dup2(fildes[1], 1);
- __close(fildes[1]);
+ close(fildes[1]);
/* Redirect stderr to /dev/null if we have to. */
if (showerr == 0) {
int fd;
- __close(2);
- fd = __open(_PATH_DEVNULL, O_WRONLY);
+ close(2);
+ fd = open(_PATH_DEVNULL, O_WRONLY);
if (fd >= 0 && fd != 2) {
dup2(fd, 2);
- __close(fd);
+ close(fd);
}
}
/* Make sure the subshell doesn't field-split on our behalf. */
unsetenv("IFS");
- __close(fildes[0]);
+ close(fildes[0]);
execve(_PATH_BSHELL, (char *const *) args, __environ);
/* Bad. What now? */
@@ -832,8 +847,8 @@ exec_comm(char *comm, char **word, size_t * word_length,
if ((pid = fork()) < 0) {
/* Bad */
- __close(fildes[0]);
- __close(fildes[1]);
+ close(fildes[0]);
+ close(fildes[1]);
return WRDE_NOSPACE;
}
@@ -842,17 +857,17 @@ exec_comm(char *comm, char **word, size_t * word_length,
/* Parent */
- __close(fildes[1]);
+ close(fildes[1]);
buffer = alloca(bufsize);
if (!pwordexp)
/* Quoted - no field splitting */
{
while (1) {
- if ((buflen = __read(fildes[0], buffer, bufsize)) < 1) {
+ if ((buflen = read(fildes[0], buffer, bufsize)) < 1) {
if (waitpid(pid, &status, WNOHANG) == 0)
continue;
- if ((buflen = __read(fildes[0], buffer, bufsize)) < 1)
+ if ((buflen = read(fildes[0], buffer, bufsize)) < 1)
break;
}
@@ -875,17 +890,17 @@ exec_comm(char *comm, char **word, size_t * word_length,
*/
while (1) {
- if ((buflen = __read(fildes[0], buffer, bufsize)) < 1) {
+ if ((buflen = read(fildes[0], buffer, bufsize)) < 1) {
if (waitpid(pid, &status, WNOHANG) == 0)
continue;
- if ((buflen = __read(fildes[0], buffer, bufsize)) < 1)
+ if ((buflen = read(fildes[0], buffer, bufsize)) < 1)
break;
}
for (i = 0; i < buflen; ++i) {
- if (__strchr(ifs, buffer[i]) != NULL) {
+ if (strchr(ifs, buffer[i]) != NULL) {
/* Current character is IFS */
- if (__strchr(ifs_white, buffer[i]) == NULL) {
+ if (strchr(ifs_white, buffer[i]) == NULL) {
/* Current character is IFS but not whitespace */
if (copying == 2) {
/* current character
@@ -979,7 +994,7 @@ exec_comm(char *comm, char **word, size_t * word_length,
}
}
- __close(fildes[0]);
+ close(fildes[0]);
/* Check for syntax error (re-execute but with "-n" flag) */
if (buflen < 1 && status != 0) {
@@ -1002,7 +1017,7 @@ exec_comm(char *comm, char **word, size_t * word_length,
no_space:
kill(pid, SIGKILL);
waitpid(pid, NULL, 0);
- __close(fildes[0]);
+ close(fildes[0]);
return WRDE_NOSPACE;
}
@@ -1201,7 +1216,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
goto envsubst;
}
while (isdigit(words[++*offset]));
- } else if (__strchr("*@$", words[*offset]) != NULL) {
+ } else if (strchr("*@$", words[*offset]) != NULL) {
/* Special parameter. */
special = 1;
env = w_addchar(env, &env_length, &env_maxlen, words[*offset]);
@@ -1237,7 +1252,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
break;
case ':':
- if (__strchr("-=?+", words[1 + *offset]) == NULL)
+ if (strchr("-=?+", words[1 + *offset]) == NULL)
goto syntax;
colon_seen = 1;
@@ -1348,7 +1363,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
/* Is it `$$'? */
if (*env == '$') {
buffer[20] = '\0';
- value = _itoa(__getpid(), &buffer[20]);
+ value = _itoa(getpid(), &buffer[20]);
}
/* Is it `${#*}' or `${#@}'? */
else if ((*env == '*' || *env == '@') && seen_hash) {
@@ -1369,7 +1384,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
/* Build up value parameter by parameter (copy them) */
for (p = 1; __libc_argv[p]; ++p)
- plist_len += __strlen(__libc_argv[p]) + 1; /* for space */
+ plist_len += strlen(__libc_argv[p]) + 1; /* for space */
value = malloc(plist_len);
if (value == NULL)
goto no_space;
@@ -1399,7 +1414,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
goto no_space;
for (p = 2; __libc_argv[p + 1]; p++) {
- char *newword = __strdup(__libc_argv[p]);
+ char *newword = strdup(__libc_argv[p]);
if (newword == NULL || w_addword(pwordexp, newword))
goto no_space;
@@ -1415,7 +1430,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
}
}
} else
- value = __getenv(env);
+ value = getenv(env);
if (value == NULL && (flags & WRDE_UNDEF)) {
/* Variable not defined. */
@@ -1579,7 +1594,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
if (value == NULL || pattern == NULL || *pattern == '\0')
break;
- end = value + __strlen(value);
+ end = value + strlen(value);
switch (action) {
case ACT_RP_SHORT_LEFT:
@@ -1589,7 +1604,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
if (fnmatch(pattern, value, 0) != FNM_NOMATCH) {
*p = c;
if (free_value) {
- char *newval = __strdup(p);
+ char *newval = strdup(p);
if (newval == NULL) {
free(value);
@@ -1613,7 +1628,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
if (fnmatch(pattern, value, 0) != FNM_NOMATCH) {
*p = c;
if (free_value) {
- char *newval = __strdup(p);
+ char *newval = strdup(p);
if (newval == NULL) {
free(value);
@@ -1717,7 +1732,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
/* Substitute NULL */
goto success;
- value = pattern ? __strdup(pattern) : pattern;
+ value = pattern ? strdup(pattern) : pattern;
free_value = 1;
if (pattern && !value)
@@ -1730,7 +1745,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
if (free_value && value)
free(value);
- value = pattern ? __strdup(pattern) : pattern;
+ value = pattern ? strdup(pattern) : pattern;
free_value = 1;
if (pattern && !value)
@@ -1759,7 +1774,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
if (free_value && value)
free(value);
- value = pattern ? __strdup(pattern) : pattern;
+ value = pattern ? strdup(pattern) : pattern;
free_value = 1;
if (pattern && !value)
@@ -1783,7 +1798,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
param_length[20] = '\0';
*word = w_addstr(*word, word_length, max_length,
- _itoa(value ? __strlen(value) : 0,
+ _itoa(value ? strlen(value) : 0,
&param_length[20]));
if (free_value) {
assert(value != NULL);
@@ -1805,7 +1820,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
return *word ? 0 : WRDE_NOSPACE;
} else {
/* Need to field-split */
- char *value_copy = __strdup(value); /* Don't modify value */
+ char *value_copy = strdup(value); /* Don't modify value */
char *field_begin = value_copy;
int seen_nonws_ifs = 0;
@@ -1845,7 +1860,7 @@ parse_param(char **word, size_t * word_length, size_t * max_length,
/* Skip at most one non-whitespace IFS character after the field */
seen_nonws_ifs = 0;
- if (*next_field && __strchr(ifs, *next_field)) {
+ if (*next_field && strchr(ifs, *next_field)) {
seen_nonws_ifs = 1;
next_field++;
}
@@ -2028,7 +2043,7 @@ parse_dquote(char **word, size_t * word_length, size_t * max_length,
* wordfree() is to be called after pwordexp is finished with.
*/
-void attribute_hidden __wordfree(wordexp_t * pwordexp)
+void wordfree(wordexp_t * pwordexp)
{
/* wordexp can set pwordexp to NULL */
@@ -2042,7 +2057,7 @@ void attribute_hidden __wordfree(wordexp_t * pwordexp)
pwordexp->we_wordv = NULL;
}
}
-strong_alias(__wordfree,wordfree)
+libc_hidden_def(wordfree)
/*
* wordexp()
@@ -2061,7 +2076,7 @@ int wordexp(const char *words, wordexp_t * we, int flags)
if (flags & WRDE_REUSE) {
/* Minimal implementation of WRDE_REUSE for now */
- __wordfree(we);
+ wordfree(we);
old_word.we_wordv = NULL;
}
@@ -2088,11 +2103,11 @@ int wordexp(const char *words, wordexp_t * we, int flags)
/* Find out what the field separators are.
* There are two types: whitespace and non-whitespace.
*/
- ifs = __getenv("IFS");
+ ifs = getenv("IFS");
if (!ifs)
/* IFS unset - use <space><tab><newline>. */
- ifs = __strcpy(ifs_white, " \t\n");
+ ifs = strcpy(ifs_white, " \t\n");
else {
char *ifsch = ifs;
char *whch = ifs_white;
@@ -2211,11 +2226,11 @@ int wordexp(const char *words, wordexp_t * we, int flags)
default:
/* Is it a word separator? */
- if (__strchr(" \t", words[words_offset]) == NULL) {
+ if (strchr(" \t", words[words_offset]) == NULL) {
char ch = words[words_offset];
/* Not a word separator -- but is it a valid word char? */
- if (__strchr("\n|&;<>(){}", ch)) {
+ if (strchr("\n|&;<>(){}", ch)) {
/* Fail */
error = WRDE_BADCHAR;
goto do_error;
@@ -2263,7 +2278,7 @@ int wordexp(const char *words, wordexp_t * we, int flags)
return WRDE_NOSPACE;
if ((flags & WRDE_APPEND) == 0)
- __wordfree(we);
+ wordfree(we);
*we = old_word;
return error;