Work around glibc bug, that does not handle latin-1 umlauts.

This commit is contained in:
Marcus Meissner 1999-11-14 19:43:05 +00:00 committed by Alexandre Julliard
parent eb94c7d2c4
commit 1077d0cd1c
1 changed files with 22 additions and 11 deletions

View File

@ -372,22 +372,33 @@ LPWSTR __cdecl CRTDLL_wcstok( LPWSTR str, LPCWSTR delim )
/********************************************************************* /*********************************************************************
* CRTDLL_wcstombs (CRTDLL.521) * CRTDLL_wcstombs (CRTDLL.521)
*
* FIXME: the reason I do not use wcstombs is that it seems to fail
* for any latin-1 valid character. Not good.
*/ */
INT __cdecl CRTDLL_wcstombs( LPSTR dst, LPCWSTR src, INT n ) INT __cdecl CRTDLL_wcstombs( LPSTR dst, LPCWSTR src, INT n )
{ {
wchar_t *buffer, *p; int copied=0;
int ret; while ((n>0) && *src) {
int ret;
int size = (CRTDLL_wcslen(src) + 1) * sizeof(wchar_t); /* FIXME: could potentially overflow if we ever have MB of 2 bytes*/
if (!(buffer = CRTDLL_malloc( size ))) return -1; ret = wctomb(dst,(wchar_t)*src);
p = buffer; if (ret<0) {
while ((*p++ = (wchar_t)*src++)); /* FIXME: sadly, some versions of glibc do not like latin characters
ret = wcstombs( dst, buffer, n ); * as UNICODE chars for some reason (like german umlauts). Just
CRTDLL_free( buffer ); * copy those anyway. MM 991106
return ret; */
*dst=*src;
ret = 1;
}
dst += ret;
n -= ret;
copied += ret;
src++;
}
return copied;
} }
/********************************************************************* /*********************************************************************
* CRTDLL_wctomb (CRTDLL.524) * CRTDLL_wctomb (CRTDLL.524)
*/ */