[uClibc-cvs] uClibc/libc/misc/wchar Makefile, 1.9, 1.10 wchar.c, 1.12, 1.13 wstdio.c, 1.5, 1.6
Manuel Novoa III
mjn3 at uclibc.org
Wed Feb 11 23:48:44 UTC 2004
Update of /var/cvs/uClibc/libc/misc/wchar
In directory nail:/tmp/cvs-serv16121/libc/misc/wchar
Modified Files:
Makefile wchar.c wstdio.c
Log Message:
New stdio core. Should be more maintainable. Fixes a couple of bugs.
Codepaths streamlined. Improved performance for nonthreaded apps
when linked with a thread-enabled libc.
Minor iconv bug and some locale/thread related startup issues fixed.
These showed up in getting a gcj-compiled java helloworld app running.
Removed some old extension functions... _stdio_fdout and _stdio_fsfopen.
Index: Makefile
===================================================================
RCS file: /var/cvs/uClibc/libc/misc/wchar/Makefile,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- Makefile 4 Dec 2003 06:36:51 -0000 1.9
+++ Makefile 11 Feb 2004 23:48:41 -0000 1.10
@@ -33,17 +33,17 @@
MOBJ1 += iconv.o
endif
-MSRC2= wstdio.c
-MOBJ2= fwide.o \
- fgetwc.o getwchar.o fgetws.o \
- fputwc.o putwchar.o fputws.o \
- ungetwc.o
-# getwc (fgetwc alias) getwc_unlocked (fgetwc_unlocked alias)
-# putwc (fputwc alias) putwc_unlocked (fputwc_unlocked alias)
-
+# The stdio and time related wide functions are now built in the normal
+# directories.
+#
+# stdio:
+# fwide fgetwc getwchar fgetws fputwc putwchar fputws ungetwc
+# getwc (fgetwc alias) getwc_unlocked (fgetwc_unlocked alias)
+# putwc (fputwc alias) putwc_unlocked (fputwc_unlocked alias)
+# time:
# wcsftime
-OBJS=$(MOBJ1) $(MOBJ2)
+OBJS=$(MOBJ1)
all: $(OBJS) $(LIBC)
Index: wchar.c
===================================================================
RCS file: /var/cvs/uClibc/libc/misc/wchar/wchar.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- wchar.c 18 Aug 2003 21:14:27 -0000 1.12
+++ wchar.c 11 Feb 2004 23:48:41 -0000 1.13
@@ -1,5 +1,5 @@
-/* Copyright (C) 2002 Manuel Novoa III
+/* Copyright (C) 2002, 2003, 2004 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
@@ -92,6 +92,9 @@
* Aug 18, 2003
* Bug fix: _wchar_utf8sntowcs and _wchar_wcsntoutf8s now set errno if EILSEQ.
*
+ * Feb 11, 2004
+ * Bug fix: Fix size check for remaining output space in iconv().
+ *
* Manuel
*/
@@ -193,7 +196,7 @@
if (c != EOF) {
*buf = (unsigned char) c;
- mbstate.mask = 0; /* Initialize the mbstate. */
+ mbstate.__mask = 0; /* Initialize the mbstate. */
if (mbrtowc(&wc, buf, 1, &mbstate) <= 1) {
return wc;
}
@@ -251,7 +254,7 @@
int mbsinit(const mbstate_t *ps)
{
- return !ps || !ps->mask;
+ return !ps || !ps->__mask;
}
#endif
@@ -291,7 +294,8 @@
s = empty_string;
n = 1;
} else if (!n) {
- return (ps->mask && (ps->wc == 0xffffU)) /* TODO: change error code? */
+ /* TODO: change error code? */
+ return (ps->__mask && (ps->__wc == 0xffffU))
? ((size_t) -1) : ((size_t) -2);
}
@@ -434,15 +438,15 @@
return 0;
}
- if ((mask = (__uwchar_t) ps->mask) != 0) { /* A continuation... */
+ if ((mask = (__uwchar_t) ps->__mask) != 0) { /* A continuation... */
#ifdef DECODER
- wc = (__uwchar_t) ps->wc;
+ wc = (__uwchar_t) ps->__wc;
if (n) {
goto CONTINUE;
}
goto DONE;
#else
- if ((wc = (__uwchar_t) ps->wc) != 0xffffU) {
+ if ((wc = (__uwchar_t) ps->__wc) != 0xffffU) {
/* TODO: change error code here and below? */
if (n) {
goto CONTINUE;
@@ -472,8 +476,8 @@
wc = 0xfffdU;
goto COMPLETE;
#else
- ps->mask = mask;
- ps->wc = 0xffffU;
+ ps->__mask = mask;
+ ps->__wc = 0xffffU;
__set_errno(EILSEQ);
return (size_t) -1; /* Illegal start byte! */
#endif
@@ -532,8 +536,8 @@
} while ((mask >>= 5) >= 0x40);
goto DONE;
}
- ps->mask = (wchar_t) mask;
- ps->wc = (wchar_t) wc;
+ ps->__mask = (wchar_t) mask;
+ ps->__wc = (wchar_t) wc;
*src = s;
return (size_t) -2;
}
@@ -552,8 +556,8 @@
#endif
DONE:
- /* ps->wc is irrelavent here. */
- ps->mask = 0;
+ /* ps->__wc is irrelavent here. */
+ ps->__mask = 0;
if (pwc != wcbuf) {
*src = s;
}
@@ -1037,7 +1041,7 @@
else if (ENCODING == __ctype_encoding_8_bit) {
mbstate_t mbstate;
- mbstate.mask = 0; /* Initialize the mbstate. */
+ mbstate.__mask = 0; /* Initialize the mbstate. */
if (__wcsnrtombs(NULL, &pwcs, n, SIZE_MAX, &mbstate) == ((size_t) - 1)) {
return -1;
}
@@ -1282,7 +1286,8 @@
px->tobom0 = px->tobom = (tocodeset & 0x10) >> 4;
px->fromcodeset0 = px->fromcodeset = fromcodeset;
px->frombom0 = px->frombom = (fromcodeset & 0x10) >> 4;
- px->skip_invalid_input = px->tostate.mask = px->fromstate.mask = 0;
+ px->skip_invalid_input = px->tostate.__mask
+ = px->fromstate.__mask = 0;
return (iconv_t) px;
}
} else {
@@ -1316,7 +1321,7 @@
* shift sequence to return to initial state! */
if ((px->fromcodeset & 0xf0) == 0xe0) {
}
- px->tostate.mask = px->fromstate.mask = 0;
+ px->tostate.__mask = px->fromstate.__mask = 0;
px->fromcodeset = px->fromcodeset0;
px->tobom = px->tobom0;
px->frombom = px->frombom0;
@@ -1398,7 +1403,7 @@
INVALID:
__set_errno(EINVAL);
} else {
- px->fromstate.mask = 0;
+ px->fromstate.__mask = 0;
inci = 1;
ILLEGAL:
if (px->skip_invalid_input) {
@@ -1444,7 +1449,7 @@
if (px->tocodeset >= IC_MULTIBYTE) {
inco = (px->tocodeset == IC_WCHAR_T) ? 4: (px->tocodeset & 6);
- if (*outbytesleft < inci) goto TOO_BIG;
+ if (*outbytesleft < inco) goto TOO_BIG;
if (px->tocodeset != IC_WCHAR_T) {
if (((__uwchar_t) wc) > (((px->tocodeset & IC_UCS_4) == IC_UCS_4)
? 0x7fffffffUL : 0x10ffffUL)
Index: wstdio.c
===================================================================
RCS file: /var/cvs/uClibc/libc/misc/wchar/wstdio.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- wstdio.c 27 Dec 2003 23:30:37 -0000 1.5
+++ wstdio.c 11 Feb 2004 23:48:41 -0000 1.6
@@ -57,7 +57,7 @@
#include <errno.h>
#include <assert.h>
-#ifndef __STDIO_THREADSAFE
+#ifndef __UCLIBC_HAS_THREADS__
#ifdef __BCC__
#define UNLOCKED_STREAM(RETURNTYPE,NAME,PARAMS,ARGS,STREAM) \
@@ -85,7 +85,7 @@
#define __STDIO_THREADLOCK_OPENLIST
#define __STDIO_THREADUNLOCK_OPENLIST
-#else /* __STDIO_THREADSAFE */
+#else /* __UCLIBC_HAS_THREADS__ */
#include <pthread.h>
@@ -121,7 +121,7 @@
#define __STDIO_THREADTRYLOCK_OPENLIST \
__pthread_mutex_trylock(&_stdio_openlist_lock)
-#endif /* __STDIO_THREADSAFE */
+#endif /* __UCLIBC_HAS_THREADS__ */
#ifndef __STDIO_BUFFERS
#error stdio buffers are currently required for wide i/o
@@ -404,9 +404,9 @@
/* If can't read or c == WEOF or ungot slots already filled, then fail. */
if ((stream->modeflags
& (__MASK_UNGOT2|__FLAG_WRITEONLY
-#ifndef __STDIO_AUTO_RW_TRANSITION
+#ifndef __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__
|__FLAG_WRITING /* Note: technically no, but yes in spirit */
-#endif /* __STDIO_AUTO_RW_TRANSITION */
+#endif /* __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__ */
))
|| ((stream->modeflags & __MASK_UNGOT1) && (stream->ungot[1]))
|| (c == WEOF) ) {
@@ -417,11 +417,11 @@
/* ungot_width */
#ifdef __STDIO_BUFFERS
-#ifdef __STDIO_AUTO_RW_TRANSITION
+#ifdef __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__
if (stream->modeflags & __FLAG_WRITING) {
fflush_unlocked(stream); /* Commit any write-buffered chars. */
}
-#endif /* __STDIO_AUTO_RW_TRANSITION */
+#endif /* __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__ */
#endif /* __STDIO_BUFFERS */
/* Clear EOF and WRITING flags, and set READING FLAG */
More information about the uClibc-cvs
mailing list