msvcrt: Fix mbstowcs with empty strings.
Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com> Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
82bf4edf36
commit
967fb744e4
|
@ -2278,6 +2278,7 @@ MSVCRT_size_t CDECL MSVCRT__mbstowcs_l(MSVCRT_wchar_t *wcstr, const char *mbstr,
|
||||||
size += (MSVCRT__isleadbyte_l((unsigned char)mbstr[size], locale) ? 2 : 1);
|
size += (MSVCRT__isleadbyte_l((unsigned char)mbstr[size], locale) ? 2 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(size) {
|
||||||
size = MultiByteToWideChar(locinfo->lc_codepage, 0,
|
size = MultiByteToWideChar(locinfo->lc_codepage, 0,
|
||||||
mbstr, size, wcstr, count);
|
mbstr, size, wcstr, count);
|
||||||
if(!size) {
|
if(!size) {
|
||||||
|
@ -2285,6 +2286,7 @@ MSVCRT_size_t CDECL MSVCRT__mbstowcs_l(MSVCRT_wchar_t *wcstr, const char *mbstr,
|
||||||
*MSVCRT__errno() = MSVCRT_EILSEQ;
|
*MSVCRT__errno() = MSVCRT_EILSEQ;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(size<count && wcstr)
|
if(size<count && wcstr)
|
||||||
wcstr[size] = '\0';
|
wcstr[size] = '\0';
|
||||||
|
|
|
@ -1900,7 +1900,7 @@ static void test_mbstowcs(void)
|
||||||
ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut));
|
ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut));
|
||||||
|
|
||||||
ret = mbstowcs(wOut, mEmpty, 6);
|
ret = mbstowcs(wOut, mEmpty, 6);
|
||||||
todo_wine ok(ret == 0, "mbstowcs did not return 0, got %d\n", (int)ret);
|
ok(ret == 0, "mbstowcs did not return 0, got %d\n", (int)ret);
|
||||||
ok(!memcmp(wOut, wEmpty, sizeof(wEmpty)), "wOut = %s\n", wine_dbgstr_w(wOut));
|
ok(!memcmp(wOut, wEmpty, sizeof(wEmpty)), "wOut = %s\n", wine_dbgstr_w(wOut));
|
||||||
|
|
||||||
ret = wcstombs(mOut, wHiragana, 6);
|
ret = wcstombs(mOut, wHiragana, 6);
|
||||||
|
@ -1928,8 +1928,8 @@ static void test_mbstowcs(void)
|
||||||
ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut));
|
ok(!memcmp(wOut, wHiragana, sizeof(wHiragana)), "wOut = %s\n", wine_dbgstr_w(wOut));
|
||||||
|
|
||||||
err = pmbstowcs_s(&ret, wOut, 6, mEmpty, _TRUNCATE);
|
err = pmbstowcs_s(&ret, wOut, 6, mEmpty, _TRUNCATE);
|
||||||
todo_wine ok(err == 0, "err = %d\n", err);
|
ok(err == 0, "err = %d\n", err);
|
||||||
todo_wine ok(ret == 1, "mbstowcs_s did not return 1, got %d\n", (int)ret);
|
ok(ret == 1, "mbstowcs_s did not return 1, got %d\n", (int)ret);
|
||||||
ok(!memcmp(wOut, wEmpty, sizeof(wEmpty)), "wOut = %s\n", wine_dbgstr_w(wOut));
|
ok(!memcmp(wOut, wEmpty, sizeof(wEmpty)), "wOut = %s\n", wine_dbgstr_w(wOut));
|
||||||
|
|
||||||
err = pmbstowcs_s(&ret, NULL, 0, mHiragana, 1);
|
err = pmbstowcs_s(&ret, NULL, 0, mHiragana, 1);
|
||||||
|
|
Loading…
Reference in New Issue