From a79016198c859a3388584ac7782d760f349e2d67 Mon Sep 17 00:00:00 2001 From: Carmelo Amoroso Date: Tue, 9 Sep 2008 13:01:58 +0000 Subject: Fix some locale multibyte tests failures ad below: libc/stdlib/_strtod.c -> tst_wcstod; libc/stdlib/stdlib.c -> tst_mblen, tst_mbtowc, tst_wctomb; libc/stdio/_scanf.c -> tst_swscanf; libc/string/strncmp.c -> tst_wcsncmp; libc/misc/wchar/wchar.c -> tst_mbrlen, tst_mbrtowc, tst_wcswidth. Signed-off-by: Filippo Arcidiacono Signed-off-by: Carmelo Amoroso --- libc/misc/wchar/wchar.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'libc/misc') diff --git a/libc/misc/wchar/wchar.c b/libc/misc/wchar/wchar.c index 1a6586e91..567be8585 100644 --- a/libc/misc/wchar/wchar.c +++ b/libc/misc/wchar/wchar.c @@ -293,10 +293,17 @@ size_t mbrtowc(wchar_t *__restrict pwc, const char *__restrict s, empty_string[0] = 0; /* Init the empty string when necessary. */ s = empty_string; n = 1; + } else if (*s == '\0') { + /* According to the ISO C 89 standard this is the expected behaviour. */ + return 0; } else if (!n) { /* TODO: change error code? */ +#if 0 return (ps->__mask && (ps->__wc == 0xffffU)) ? ((size_t) -1) : ((size_t) -2); +#else + return 0; +#endif } p = s; @@ -865,7 +872,6 @@ size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src, + (wc & ((1 << Cwc2c_TT_SHIFT)-1))]; } -#define __WCHAR_REPLACEMENT_CHAR '?' #ifdef __WCHAR_REPLACEMENT_CHAR *dst = (unsigned char) ( u ? u : __WCHAR_REPLACEMENT_CHAR ); #else /* __WCHAR_REPLACEMENT_CHAR */ @@ -1045,7 +1051,7 @@ int wcswidth(const wchar_t *pwcs, size_t n) size_t i; for (i = 0 ; (i < n) && pwcs[i] ; i++) { - if (pwcs[i] != ((unsigned char)(pwcs[i]))) { + if (pwcs[i] != (pwcs[i] & 0x7f)) { return -1; } } -- cgit v1.2.3