diff options
Diffstat (limited to 'libc/misc')
-rw-r--r-- | libc/misc/assert/__assert.c | 33 | ||||
-rw-r--r-- | libc/misc/locale/locale.c | 4 | ||||
-rw-r--r-- | libc/misc/time/time.c | 2 | ||||
-rw-r--r-- | libc/misc/wchar/Makefile | 18 | ||||
-rw-r--r-- | libc/misc/wchar/wchar.c | 41 | ||||
-rw-r--r-- | libc/misc/wchar/wstdio.c | 14 |
6 files changed, 44 insertions, 68 deletions
diff --git a/libc/misc/assert/__assert.c b/libc/misc/assert/__assert.c index 74b5ee86f..2949b75f0 100644 --- a/libc/misc/assert/__assert.c +++ b/libc/misc/assert/__assert.c @@ -27,10 +27,11 @@ * and is useful in debugging the stdio code. */ -#define _STDIO_UTILITY /* For _stdio_fdout and _int10tostr. */ +#define _ISOC99_SOURCE #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include <bits/uClibc_uintmaxtostr.h> /* Get the prototype from assert.h as a double-check. */ #undef NDEBUG @@ -44,8 +45,6 @@ extern const char *__progname; #endif -#if 1 - static int in_assert; /* bss inits to 0. */ void __assert(const char *assertion, const char * filename, @@ -69,31 +68,3 @@ void __assert(const char *assertion, const char * filename, } abort(); } - -#else - -void __assert(const char *assertion, const char * filename, - int linenumber, register const char * function) -{ - char buf[__BUFLEN_INT10TOSTR]; - - _stdio_fdout(STDERR_FILENO, -#ifdef ASSERT_SHOW_PROGNAME - __progname, - ": ", -#endif - filename, - ":", - _int10tostr(buf+sizeof(buf)-1, linenumber), - ": ", - /* Function name isn't available with some compilers. */ - ((function == NULL) ? "?function?" : function), - ": Assertion `", - assertion, - "' failed.\n", - NULL - ); - abort(); -} - -#endif diff --git a/libc/misc/locale/locale.c b/libc/misc/locale/locale.c index cf058ce3e..c6a1a2dd0 100644 --- a/libc/misc/locale/locale.c +++ b/libc/misc/locale/locale.c @@ -346,7 +346,7 @@ struct lconv *localeconv(void) /**********************************************************************/ #if defined(L__locale_init) && !defined(__LOCALE_C_ONLY) -static __uclibc_locale_t __global_locale_data; +__uclibc_locale_t __global_locale_data; __locale_t __global_locale = &__global_locale_data; @@ -1420,7 +1420,7 @@ int __locale_mbrtowc_l(wchar_t *__restrict dst, mbstate_t ps; const char *p = src; size_t r; - ps.mask = 0; + ps.__mask = 0; r = _wchar_utf8sntowcs(dst, 1, &p, SIZE_MAX, &ps, 1); return (r == 1) ? (p-src) : r; /* Need to return 0 if nul char. */ } diff --git a/libc/misc/time/time.c b/libc/misc/time/time.c index e2f1f6c6d..8176e071a 100644 --- a/libc/misc/time/time.c +++ b/libc/misc/time/time.c @@ -135,7 +135,6 @@ */ #define _GNU_SOURCE -#define _STDIO_UTILITY #include <stdio.h> #include <stdlib.h> #include <stddef.h> @@ -147,6 +146,7 @@ #include <ctype.h> #include <langinfo.h> #include <locale.h> +#include <bits/uClibc_uintmaxtostr.h> #ifdef __UCLIBC_HAS_XLOCALE__ #include <xlocale.h> diff --git a/libc/misc/wchar/Makefile b/libc/misc/wchar/Makefile index a96dae2b4..b1db37293 100644 --- a/libc/misc/wchar/Makefile +++ b/libc/misc/wchar/Makefile @@ -33,17 +33,17 @@ ifeq ($(UCLIBC_HAS_LOCALE),y) 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) diff --git a/libc/misc/wchar/wchar.c b/libc/misc/wchar/wchar.c index 4fc96f430..d1383c99f 100644 --- a/libc/misc/wchar/wchar.c +++ b/libc/misc/wchar/wchar.c @@ -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 @@ wint_t btowc(int c) 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 wctob(wint_t c) int mbsinit(const mbstate_t *ps) { - return !ps || !ps->mask; + return !ps || !ps->__mask; } #endif @@ -291,7 +294,8 @@ size_t mbrtowc(wchar_t *__restrict pwc, const char *__restrict s, 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 @@ size_t _wchar_utf8sntowcs(wchar_t *__restrict pwc, size_t wn, 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 @@ size_t _wchar_utf8sntowcs(wchar_t *__restrict pwc, size_t wn, 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 @@ size_t _wchar_utf8sntowcs(wchar_t *__restrict pwc, size_t wn, } 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 @@ size_t _wchar_utf8sntowcs(wchar_t *__restrict pwc, size_t wn, #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 @@ int wcswidth(const wchar_t *pwcs, size_t n) 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 @@ iconv_t weak_function iconv_open(const char *tocode, const char *fromcode) 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 @@ size_t weak_function iconv(iconv_t cd, char **__restrict inbuf, * 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 @@ size_t weak_function iconv(iconv_t cd, char **__restrict inbuf, 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 @@ size_t weak_function iconv(iconv_t cd, char **__restrict inbuf, 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) diff --git a/libc/misc/wchar/wstdio.c b/libc/misc/wchar/wstdio.c index e984bf837..b49494f35 100644 --- a/libc/misc/wchar/wstdio.c +++ b/libc/misc/wchar/wstdio.c @@ -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 @@ void NAME PARAMS #define __STDIO_THREADLOCK_OPENLIST #define __STDIO_THREADUNLOCK_OPENLIST -#else /* __STDIO_THREADSAFE */ +#else /* __UCLIBC_HAS_THREADS__ */ #include <pthread.h> @@ -121,7 +121,7 @@ void NAME##_unlocked PARAMS #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 @@ wint_t ungetwc(wint_t c, register FILE *stream) /* 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 @@ wint_t ungetwc(wint_t c, register FILE *stream) /* 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 */ |