summaryrefslogtreecommitdiff
path: root/libc/misc/wchar/wchar.c
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2008-09-09 13:01:58 +0000
committerCarmelo Amoroso <carmelo.amoroso@st.com>2008-09-09 13:01:58 +0000
commita79016198c859a3388584ac7782d760f349e2d67 (patch)
treead74465aca5c92984b7314970818cbb775dc80c3 /libc/misc/wchar/wchar.c
parentd673a24ff2e988888cabfd37d48dc72cbada95a5 (diff)
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 <filippo.arcidiacono@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'libc/misc/wchar/wchar.c')
-rw-r--r--libc/misc/wchar/wchar.c10
1 files changed, 8 insertions, 2 deletions
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;
}
}