mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-01 19:33:38 +00:00
kernel32: Return correct buffer size when returning DBCS characters.
This commit is contained in:
parent
89a558fe8f
commit
80695cde4f
|
@ -667,7 +667,7 @@ static void test_GetCalendarInfo(void)
|
|||
char bufferA[20];
|
||||
WCHAR bufferW[20];
|
||||
DWORD val1, val2;
|
||||
int ret;
|
||||
int ret, ret2;
|
||||
|
||||
if (!pGetCalendarInfoA || !pGetCalendarInfoW)
|
||||
{
|
||||
|
@ -716,6 +716,21 @@ static void test_GetCalendarInfo(void)
|
|||
ret = pGetCalendarInfoW( 0x0409, CAL_GREGORIAN, CAL_ITWODIGITYEARMAX, NULL, 0, NULL );
|
||||
ok( ret, "GetCalendarInfoW failed err %u\n", GetLastError() );
|
||||
ok( ret == 5, "wrong size %u\n", ret );
|
||||
|
||||
ret = pGetCalendarInfoA( LANG_SYSTEM_DEFAULT, CAL_GREGORIAN, CAL_SDAYNAME1,
|
||||
bufferA, sizeof(bufferA), NULL);
|
||||
ok( ret, "GetCalendarInfoA failed err %u\n", GetLastError() );
|
||||
ret2 = pGetCalendarInfoA( LANG_SYSTEM_DEFAULT, CAL_GREGORIAN, CAL_SDAYNAME1,
|
||||
bufferA, 0, NULL);
|
||||
ok( ret2, "GetCalendarInfoA failed err %u\n", GetLastError() );
|
||||
ok( ret == ret2, "got %d, expected %d\n", ret2, ret );
|
||||
|
||||
ret2 = pGetCalendarInfoW( LANG_SYSTEM_DEFAULT, CAL_GREGORIAN, CAL_SDAYNAME1,
|
||||
bufferW, sizeof(bufferW), NULL);
|
||||
ok( ret2, "GetCalendarInfoW failed err %u\n", GetLastError() );
|
||||
ret2 = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL );
|
||||
ok( ret == ret2, "got %d, expected %d\n", ret, ret2 );
|
||||
|
||||
}
|
||||
|
||||
START_TEST(time)
|
||||
|
|
|
@ -614,7 +614,7 @@ BOOL WINAPI GetProcessTimes( HANDLE hprocess, LPFILETIME lpCreationTime,
|
|||
int WINAPI GetCalendarInfoA(LCID lcid, CALID Calendar, CALTYPE CalType,
|
||||
LPSTR lpCalData, int cchData, LPDWORD lpValue)
|
||||
{
|
||||
int ret;
|
||||
int ret, cchDataW = cchData;
|
||||
LPWSTR lpCalDataW = NULL;
|
||||
|
||||
if (NLS_IsUnicodeOnlyLcid(lcid))
|
||||
|
@ -623,13 +623,14 @@ int WINAPI GetCalendarInfoA(LCID lcid, CALID Calendar, CALTYPE CalType,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (cchData &&
|
||||
!(lpCalDataW = HeapAlloc(GetProcessHeap(), 0, cchData*sizeof(WCHAR))))
|
||||
return 0;
|
||||
if (!cchData && !(CalType & CAL_RETURN_NUMBER))
|
||||
cchDataW = GetCalendarInfoW(lcid, Calendar, CalType, NULL, 0, NULL);
|
||||
if (!(lpCalDataW = HeapAlloc(GetProcessHeap(), 0, cchDataW*sizeof(WCHAR))))
|
||||
return 0;
|
||||
|
||||
ret = GetCalendarInfoW(lcid, Calendar, CalType, lpCalDataW, cchData, lpValue);
|
||||
ret = GetCalendarInfoW(lcid, Calendar, CalType, lpCalDataW, cchDataW, lpValue);
|
||||
if(ret && lpCalDataW && lpCalData)
|
||||
WideCharToMultiByte(CP_ACP, 0, lpCalDataW, -1, lpCalData, cchData, NULL, NULL);
|
||||
ret = WideCharToMultiByte(CP_ACP, 0, lpCalDataW, -1, lpCalData, cchData, NULL, NULL);
|
||||
else if (CalType & CAL_RETURN_NUMBER)
|
||||
ret *= sizeof(WCHAR);
|
||||
HeapFree(GetProcessHeap(), 0, lpCalDataW);
|
||||
|
|
Loading…
Reference in a new issue