mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
Fix bug in IsValidLocale(), GetNumberFormatW(), GetCurrencyFormatW()
patch by Zavyalov Alexey (reactos at ilimschool dot ru) See issue #2374 for more details. svn path=/trunk/; revision=28020
This commit is contained in:
parent
e137a5326a
commit
8fd67d96e0
2 changed files with 69 additions and 4 deletions
|
@ -1504,8 +1504,7 @@ IsValidLocale(LCID Locale,
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueData = (PWSTR)&KeyInfo->Data[0];
|
ValueData = (PWSTR)&KeyInfo->Data[0];
|
||||||
if ((dwFlags & LCID_INSTALLED) &&
|
if ((KeyInfo->Type == REG_SZ) &&
|
||||||
(KeyInfo->Type == REG_SZ) &&
|
|
||||||
(KeyInfo->DataLength == 2 * sizeof(WCHAR)) &&
|
(KeyInfo->DataLength == 2 * sizeof(WCHAR)) &&
|
||||||
(ValueData[0] == L'1'))
|
(ValueData[0] == L'1'))
|
||||||
{
|
{
|
||||||
|
@ -1849,3 +1848,4 @@ VerLanguageNameW (
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,53 @@ static RTL_CRITICAL_SECTION_DEBUG NLS_FormatsCS_debug =
|
||||||
};
|
};
|
||||||
static RTL_CRITICAL_SECTION NLS_FormatsCS = { &NLS_FormatsCS_debug, -1, 0, 0, 0, 0 };
|
static RTL_CRITICAL_SECTION NLS_FormatsCS = { &NLS_FormatsCS_debug, -1, 0, 0, 0, 0 };
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* NLS_isSystemLocale <internal>
|
||||||
|
*
|
||||||
|
* Return TRUE, if locale is system-type
|
||||||
|
*/
|
||||||
|
BOOL NLS_isSystemLocale(LCID lcid)
|
||||||
|
{
|
||||||
|
if(lcid == LOCALE_SYSTEM_DEFAULT ||
|
||||||
|
lcid == LOCALE_NEUTRAL ||
|
||||||
|
lcid == LOCALE_USER_DEFAULT)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* NLS_isSystemLocale <internal>
|
||||||
|
*
|
||||||
|
* Return default system or user locale
|
||||||
|
*/
|
||||||
|
LCID NLS_getDefaultLocale(LCID lcid)
|
||||||
|
{
|
||||||
|
LCID lcidTmp;
|
||||||
|
|
||||||
|
DPRINT("Called NLS_getDefaultLocale(0x%04lx)\n", lcid);
|
||||||
|
|
||||||
|
switch(lcid)
|
||||||
|
{
|
||||||
|
case LOCALE_SYSTEM_DEFAULT:
|
||||||
|
NtQueryDefaultLocale(FALSE, &lcidTmp);
|
||||||
|
return lcidTmp;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LOCALE_USER_DEFAULT:
|
||||||
|
case LOCALE_NEUTRAL:
|
||||||
|
NtQueryDefaultLocale(TRUE, &lcidTmp);
|
||||||
|
return lcidTmp;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
DPRINT1("FIXME: unknown system lcid\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return lcid;
|
||||||
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* NLS_GetLocaleNumber <internal>
|
* NLS_GetLocaleNumber <internal>
|
||||||
*
|
*
|
||||||
|
@ -968,8 +1015,17 @@ INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags,
|
||||||
TRACE("(0x%04lx,0x%08lx,%S,%p,%p,%d)\n", lcid, dwFlags, lpszValue,
|
TRACE("(0x%04lx,0x%08lx,%S,%p,%p,%d)\n", lcid, dwFlags, lpszValue,
|
||||||
lpFormat, lpNumberStr, cchOut);
|
lpFormat, lpNumberStr, cchOut);
|
||||||
|
|
||||||
|
if(NLS_isSystemLocale(lcid))
|
||||||
|
{
|
||||||
|
lcid = NLS_getDefaultLocale(lcid);
|
||||||
|
}
|
||||||
|
else if(!IsValidLocale(lcid, 0))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!lpszValue || cchOut < 0 || (cchOut > 0 && !lpNumberStr) ||
|
if (!lpszValue || cchOut < 0 || (cchOut > 0 && !lpNumberStr) ||
|
||||||
!IsValidLocale(lcid, 0) ||
|
|
||||||
(lpFormat && (dwFlags || !lpFormat->lpDecimalSep || !lpFormat->lpThousandSep)))
|
(lpFormat && (dwFlags || !lpFormat->lpDecimalSep || !lpFormat->lpThousandSep)))
|
||||||
{
|
{
|
||||||
GetNumberFormatW_Error:
|
GetNumberFormatW_Error:
|
||||||
|
@ -1334,8 +1390,17 @@ INT WINAPI GetCurrencyFormatW(LCID lcid, DWORD dwFlags,
|
||||||
TRACE("(0x%04lx,0x%08lx,%S,%p,%p,%d)\n", lcid, dwFlags, lpszValue,
|
TRACE("(0x%04lx,0x%08lx,%S,%p,%p,%d)\n", lcid, dwFlags, lpszValue,
|
||||||
lpFormat, lpCurrencyStr, cchOut);
|
lpFormat, lpCurrencyStr, cchOut);
|
||||||
|
|
||||||
|
if(NLS_isSystemLocale(lcid))
|
||||||
|
{
|
||||||
|
lcid = NLS_getDefaultLocale(lcid);
|
||||||
|
}
|
||||||
|
else if(!IsValidLocale(lcid, 0))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!lpszValue || cchOut < 0 || (cchOut > 0 && !lpCurrencyStr) ||
|
if (!lpszValue || cchOut < 0 || (cchOut > 0 && !lpCurrencyStr) ||
|
||||||
!IsValidLocale(lcid, 0) ||
|
|
||||||
(lpFormat && (dwFlags || !lpFormat->lpDecimalSep || !lpFormat->lpThousandSep ||
|
(lpFormat && (dwFlags || !lpFormat->lpDecimalSep || !lpFormat->lpThousandSep ||
|
||||||
!lpFormat->lpCurrencySymbol || lpFormat->NegativeOrder > 15 ||
|
!lpFormat->lpCurrencySymbol || lpFormat->NegativeOrder > 15 ||
|
||||||
lpFormat->PositiveOrder > 3)))
|
lpFormat->PositiveOrder > 3)))
|
||||||
|
|
Loading…
Reference in a new issue