From 01668fecd4ef7be84b666ae3c789ec9c12078580 Mon Sep 17 00:00:00 2001 From: Danny Smith Date: Wed, 17 May 2006 07:49:39 +0000 Subject: [PATCH] * mingwex/wcrtomb.c (wcrtomb_cp): Test (wc > 255) only if C locale. Use supplied codepage as arg to WideCharToMultiByte. --- winsup/mingw/ChangeLog | 5 +++++ winsup/mingw/mingwex/wcrtomb.c | 18 ++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog index 2eb768921..c47fb7e36 100644 --- a/winsup/mingw/ChangeLog +++ b/winsup/mingw/ChangeLog @@ -1,3 +1,8 @@ +2006-05-17 Danny Smith + + * mingwex/wcrtomb.c (wcrtomb_cp): Test (wc > 255) only if C locale. + Use supplied codepage as arg to WideCharToMultiByte. + 2006-02-13 Earnie Boyd * Makefile.in (libmsvcr80.a): Add import lib. diff --git a/winsup/mingw/mingwex/wcrtomb.c b/winsup/mingw/mingwex/wcrtomb.c index 08a5fccae..454f035c0 100755 --- a/winsup/mingw/mingwex/wcrtomb.c +++ b/winsup/mingw/mingwex/wcrtomb.c @@ -11,14 +11,13 @@ static int __MINGW_ATTRIB_NONNULL(1) __wcrtomb_cp (char *dst, wchar_t wc, const unsigned int cp, const unsigned int mb_max) { - if (wc > 255) - { - errno = EILSEQ; - return -1; - } - if (cp == 0) { + if (wc > 255) + { + errno = EILSEQ; + return -1; + } *dst = (char) wc; return 1; } @@ -26,10 +25,9 @@ static int __MINGW_ATTRIB_NONNULL(1) { int invalid_char = 0; - int size = WideCharToMultiByte(get_cp_from_locale(), - 0 /* Is this correct flag? */, - &wc, 1, dst, mb_max, - NULL, &invalid_char); + int size = WideCharToMultiByte (cp, 0 /* Is this correct flag? */, + &wc, 1, dst, mb_max, + NULL, &invalid_char); if (size == 0 || invalid_char) { errno = EILSEQ;