From f03f51dccf606bd9ba89991e67132bf58e6fcdf0 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 9 Apr 2009 08:20:10 +0000 Subject: * libc/stdlib/mbctype.h (_iseucjp1): Like _iseucjp, but also recognizes 0x8e and 0x8f lead bytes. (_iseucjp2): Rename from _iseucjp. * libc/stdlib/mbtowc_r.c (__eucjp_mbtowc): Convert JIS-X-0212 triplebyte sequences as well. * libc/stdlib/wctomb_r.c (__eucjp_wctomb): Convert to JIS-X-0212 triplebyte sequences as well. --- newlib/libc/stdlib/mbtowc_r.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'newlib/libc/stdlib/mbtowc_r.c') diff --git a/newlib/libc/stdlib/mbtowc_r.c b/newlib/libc/stdlib/mbtowc_r.c index 78bde4b78..010ce1da5 100644 --- a/newlib/libc/stdlib/mbtowc_r.c +++ b/newlib/libc/stdlib/mbtowc_r.c @@ -470,7 +470,7 @@ _DEFUN (__eucjp_mbtowc, (r, pwc, s, n, charset, state), ch = t[i++]; if (state->__count == 0) { - if (_iseucjp (ch)) + if (_iseucjp1 (ch)) { state->__value.__wchb[0] = ch; state->__count = 1; @@ -481,9 +481,35 @@ _DEFUN (__eucjp_mbtowc, (r, pwc, s, n, charset, state), } if (state->__count == 1) { - if (_iseucjp (ch)) + if (_iseucjp2 (ch)) { - *pwc = (((wchar_t)state->__value.__wchb[0]) << 8) + (wchar_t)ch; + if (state->__value.__wchb[0] == 0x8f) + { + state->__value.__wchb[1] = ch; + state->__count = 2; + if (n <= i) + return -2; + ch = t[i++]; + } + else + { + *pwc = (((wchar_t)state->__value.__wchb[0]) << 8) + (wchar_t)ch; + state->__count = 0; + return i; + } + } + else + { + r->_errno = EILSEQ; + return -1; + } + } + if (state->__count == 2) + { + if (_iseucjp2 (ch)) + { + *pwc = (((wchar_t)state->__value.__wchb[1]) << 8) + + (wchar_t)(ch & 0x7f); state->__count = 0; return i; } -- cgit v1.2.3