Fail GetCalendarInfoA for Unicode-only locales.

This commit is contained in:
Jon Griffiths 2003-12-01 22:47:28 +00:00 committed by Alexandre Julliard
parent 87ae5ba84e
commit d9339f83ec
3 changed files with 24 additions and 13 deletions

View File

@ -56,6 +56,8 @@ extern VOID SYSLEVEL_CheckNotLevel( INT level );
extern DWORD INSTR_EmulateInstruction( EXCEPTION_RECORD *rec, CONTEXT86 *context );
extern void INSTR_CallBuiltinHandler( CONTEXT86 *context, BYTE intnum );
extern BOOL NLS_IsUnicodeOnlyLcid(LCID);
extern WORD SELECTOR_AllocBlock( const void *base, DWORD size, unsigned char flags );
extern WORD SELECTOR_ReallocBlock( WORD sel, const void *base, DWORD size );
extern void SELECTOR_FreeBlock( WORD sel );

View File

@ -95,7 +95,7 @@ static CRITICAL_SECTION NLS_FormatsCS = { &NLS_FormatsCS_debug, -1, 0, 0, 0, 0 }
*
* Get a numeric locale format value.
*/
static WINAPI DWORD NLS_GetLocaleNumber(LCID lcid, DWORD dwFlags)
static DWORD NLS_GetLocaleNumber(LCID lcid, DWORD dwFlags)
{
WCHAR szBuff[80];
DWORD dwVal = 0;
@ -120,7 +120,7 @@ static WINAPI DWORD NLS_GetLocaleNumber(LCID lcid, DWORD dwFlags)
*
* Get a string locale format value.
*/
static WINAPI WCHAR* NLS_GetLocaleString(LCID lcid, DWORD dwFlags)
static WCHAR* NLS_GetLocaleString(LCID lcid, DWORD dwFlags)
{
WCHAR szBuff[80], *str;
DWORD dwLen;
@ -145,7 +145,7 @@ static WINAPI WCHAR* NLS_GetLocaleString(LCID lcid, DWORD dwFlags)
*
* Calculate (and cache) the number formats for a locale.
*/
static WINAPI const NLS_FORMAT_NODE *NLS_GetFormats(LCID lcid, DWORD dwFlags)
static const NLS_FORMAT_NODE *NLS_GetFormats(LCID lcid, DWORD dwFlags)
{
/* GetLocaleInfo() identifiers for cached formatting strings */
static const USHORT NLS_LocaleIndices[] = {
@ -295,7 +295,7 @@ static WINAPI const NLS_FORMAT_NODE *NLS_GetFormats(LCID lcid, DWORD dwFlags)
*
* Determine if a locale is Unicode only, and thus invalid in ASCII calls.
*/
BOOL WINAPI NLS_IsUnicodeOnlyLcid(LCID lcid)
BOOL NLS_IsUnicodeOnlyLcid(LCID lcid)
{
switch (PRIMARYLANGID(lcid))
{
@ -666,9 +666,9 @@ NLS_GetDateTimeFormatW_Overrun:
*
* ASCII wrapper for GetDateFormatA/GetTimeFormatA.
*/
static INT WINAPI NLS_GetDateTimeFormatA(LCID lcid, DWORD dwFlags,
const SYSTEMTIME* lpTime,
LPCSTR lpFormat, LPSTR lpStr, INT cchOut)
static INT NLS_GetDateTimeFormatA(LCID lcid, DWORD dwFlags,
const SYSTEMTIME* lpTime,
LPCSTR lpFormat, LPSTR lpStr, INT cchOut)
{
DWORD cp = CP_ACP;
WCHAR szFormat[128], szOut[128];

View File

@ -39,6 +39,7 @@
#include "winternl.h"
#include "winerror.h"
#include "winnls.h"
#include "kernel_private.h"
#include "wine/unicode.h"
#include "wine/debug.h"
@ -530,20 +531,28 @@ BOOL WINAPI GetProcessTimes(
* GetCalendarInfoA (KERNEL32.@)
*
*/
int WINAPI GetCalendarInfoA(LCID Locale, CALID Calendar, CALTYPE CalType,
int WINAPI GetCalendarInfoA(LCID lcid, CALID Calendar, CALTYPE CalType,
LPSTR lpCalData, int cchData, LPDWORD lpValue)
{
int ret;
LPWSTR lpCalDataW = NULL;
FIXME("(%08lx,%08lx,%08lx,%p,%d,%p): quarter-stub\n",
Locale, Calendar, CalType, lpCalData, cchData, lpValue);
/* FIXME: Should verify if Locale is allowable in ANSI, as per MSDN */
lcid, Calendar, CalType, lpCalData, cchData, lpValue);
if(cchData)
if(!(lpCalDataW = HeapAlloc(GetProcessHeap(), 0, cchData*sizeof(WCHAR)))) return 0;
lcid = ConvertDefaultLocale(lcid);
ret = GetCalendarInfoW(Locale, Calendar, CalType, lpCalDataW, cchData, lpValue);
if (NLS_IsUnicodeOnlyLcid(lcid))
{
SetLastError(ERROR_INVALID_PARAMETER);
return 0;
}
if (cchData &&
!(lpCalDataW = HeapAlloc(GetProcessHeap(), 0, cchData*sizeof(WCHAR))))
return 0;
ret = GetCalendarInfoW(lcid, Calendar, CalType, lpCalDataW, cchData, lpValue);
if(ret && lpCalDataW && lpCalData)
WideCharToMultiByte(CP_ACP, 0, lpCalDataW, cchData, lpCalData, cchData, NULL, NULL);
if(lpCalDataW)