kernelbase: Reimplement LOCALE_SNATIVEDIGITS in GetLocaleInfoW/Ex using the locale.nls data.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2022-03-29 08:37:02 +02:00
parent f0d43939ff
commit ec5d3c9fe7
2 changed files with 31 additions and 6 deletions

View File

@ -896,6 +896,35 @@ static int locale_return_strarray( DWORD pos, WORD idx, LCTYPE type, WCHAR *buff
}
static int locale_return_strarray_concat( DWORD pos, LCTYPE type, WCHAR *buffer, int len )
{
WORD i, count = locale_strings[pos];
const DWORD *array = (const DWORD *)(locale_strings + pos + 1);
int ret;
if (type & LOCALE_RETURN_NUMBER)
{
SetLastError( ERROR_INVALID_FLAGS );
return 0;
}
for (i = 0, ret = 1; i < count; i++) ret += locale_strings[array[i]];
if (!len) return ret;
if (ret > len)
{
SetLastError( ERROR_INSUFFICIENT_BUFFER );
return 0;
}
for (i = 0; i < count; i++)
{
memcpy( buffer, locale_strings + array[i] + 1, locale_strings[array[i]] * sizeof(WCHAR) );
buffer += locale_strings[array[i]];
}
*buffer = 0;
return ret;
}
/* get locale information from the locale.nls file */
static int get_locale_info( const NLS_LOCALE_DATA *locale, LCID lcid, LCTYPE type,
WCHAR *buffer, int len )
@ -967,7 +996,7 @@ static int get_locale_info( const NLS_LOCALE_DATA *locale, LCID lcid, LCTYPE typ
return -1;
case LOCALE_SNATIVEDIGITS:
return -1;
return locale_return_strarray_concat( locale->snativedigits, type, buffer, len );
case LOCALE_SCURRENCY:
return locale_return_string( locale->scurrency, type, buffer, len );
@ -1285,7 +1314,7 @@ static int get_locale_info( const NLS_LOCALE_DATA *locale, LCID lcid, LCTYPE typ
return -1;
case LOCALE_IDIGITSUBSTITUTION:
return -1;
return locale_return_number( locale->idigitsubstitution, type, buffer, len );
}
SetLastError( ERROR_INVALID_FLAGS );
return 0;

View File

@ -3613,7 +3613,6 @@ static BOOL CALLBACK enum_proc(LGRPID group, LCID lcid, LPSTR locale, LONG_PTR l
SCRIPT_CONTROL sc;
SCRIPT_STATE ss;
LCID lcid_old;
BOOL todo;
if (!IsValidLocale(lcid, LCID_INSTALLED)) return TRUE;
@ -3624,10 +3623,7 @@ static BOOL CALLBACK enum_proc(LGRPID group, LCID lcid, LPSTR locale, LONG_PTR l
lcid_old = GetThreadLocale();
if (!SetThreadLocale(lcid)) return TRUE;
todo = !GetLocaleInfoW(lcid, LOCALE_IDIGITSUBSTITUTION | LOCALE_RETURN_NUMBER, NULL, 0);
hr = ScriptRecordDigitSubstitution(lcid, &sds);
todo_wine_if( todo )
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = ScriptApplyDigitSubstitution(&sds, &sc, &ss);