diff options
author | bapt <bapt@FreeBSD.org> | 2015-11-01 21:02:30 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2015-11-01 21:02:30 +0000 |
commit | e29f1d2f891c995886c7e37be37546b3dfd29efd (patch) | |
tree | c7aed3cc395067010c10a944f955af1e97ba9646 /lib/libc | |
parent | 8abd49c1b547efe6b06146384ace2ea07f277e16 (diff) | |
download | FreeBSD-src-e29f1d2f891c995886c7e37be37546b3dfd29efd.zip FreeBSD-src-e29f1d2f891c995886c7e37be37546b3dfd29efd.tar.gz |
locales: Fix eucJP sorting (broken upstream?)
Sorting eucJP text with "sort" resulted in an illegal sequence while
"gsort" worked. This was traced back to mbrtowc handling which was
broken for eucJP (probably eucCN, eucKR, and eucTW as well). This
small fix took hours to figure out. The OR operation to build the
wide character requires an unsigned character to work correctly. The
euc wcrtowc conversion is probably broken upstream in Illumos as well.
Triggered by: misc/freebsd-doc-ja in ports (encoded in eucJP)
Submitted by: marino
Obtained from: DragonflyBSD
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/locale/euc.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libc/locale/euc.c b/lib/libc/locale/euc.c index 0e5f1bf..d92d31d 100644 --- a/lib/libc/locale/euc.c +++ b/lib/libc/locale/euc.c @@ -317,8 +317,8 @@ _EUC_mbrtowc_impl(wchar_t * __restrict pwc, const char * __restrict s, { _EucState *es; int i, want; - wchar_t wc; - unsigned char ch; + wchar_t wc = 0; + unsigned char ch, chs; es = (_EucState *)ps; @@ -367,7 +367,8 @@ _EUC_mbrtowc_impl(wchar_t * __restrict pwc, const char * __restrict s, for (i = 0; i < MIN(want, n); i++) { wc <<= 8; - wc |= *s; + chs = *s; + wc |= chs; s++; } if (i < want) { |