* mingwex/wcrtomb.c (wcrtomb_cp): Test (wc > 255) only if C locale.

Use supplied codepage as arg to WideCharToMultiByte.
This commit is contained in:
Danny Smith 2006-05-17 07:49:39 +00:00
parent 9fa8d227d4
commit 01668fecd4
2 changed files with 13 additions and 10 deletions

View File

@ -1,3 +1,8 @@
2006-05-17 Danny Smith <dannysmith@users.sourceforge.net>
* mingwex/wcrtomb.c (wcrtomb_cp): Test (wc > 255) only if C locale.
Use supplied codepage as arg to WideCharToMultiByte.
2006-02-13 Earnie Boyd <earnie@users.sf.net>
* Makefile.in (libmsvcr80.a): Add import lib.

View File

@ -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;