Commit 2ca3b9e0 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Fix mbstowcs_l implementation.

parent 7b8243e5
...@@ -1725,22 +1725,29 @@ MSVCRT_size_t CDECL _mbstrlen(const char* str) ...@@ -1725,22 +1725,29 @@ MSVCRT_size_t CDECL _mbstrlen(const char* str)
MSVCRT_size_t CDECL MSVCRT__mbstowcs_l(MSVCRT_wchar_t *wcstr, const char *mbstr, MSVCRT_size_t CDECL MSVCRT__mbstowcs_l(MSVCRT_wchar_t *wcstr, const char *mbstr,
MSVCRT_size_t count, MSVCRT__locale_t locale) MSVCRT_size_t count, MSVCRT__locale_t locale)
{ {
MSVCRT_size_t tmp; MSVCRT_size_t i, size;
if(!locale) if(!locale)
locale = get_locale(); locale = get_locale();
tmp = _mbstrlen_l(mbstr, locale); /* Ignore count parameter */
if(tmp>count && wcstr) if(!wcstr)
tmp = count; return MultiByteToWideChar(locale->locinfo->lc_codepage, 0, mbstr, -1, NULL, 0)-1;
tmp = MultiByteToWideChar(locale->locinfo->lc_codepage, 0, for(i=0, size=0; i<count; i++) {
mbstr, tmp, wcstr, count); if(mbstr[size] == '\0')
break;
size += (MSVCRT_isleadbyte(mbstr[size]) ? 2 : 1);
}
size = MultiByteToWideChar(locale->locinfo->lc_codepage, 0,
mbstr, size, wcstr, count);
if(tmp<count && wcstr) if(size<count && wcstr)
wcstr[tmp] = '\0'; wcstr[size] = '\0';
return tmp; return size;
} }
/********************************************************************* /*********************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment