Alexandre Julliard : kernelbase: Reimplement LOCALE_ILANGUAGE/IDEFAULTLANGUAGE in GetLocaleInfoW/Ex using the locale.nls data.
Alexandre Julliard
julliard at winehq.org
Mon Mar 28 15:53:40 CDT 2022
Module: wine
Branch: master
Commit: 956c88db183402caf5f1bc4c45af5e667eef41e4
URL: https://source.winehq.org/git/wine.git/?a=commit;h=956c88db183402caf5f1bc4c45af5e667eef41e4
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Mar 28 12:15:30 2022 +0200
kernelbase: Reimplement LOCALE_ILANGUAGE/IDEFAULTLANGUAGE in GetLocaleInfoW/Ex using the locale.nls data.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernelbase/locale.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 43 insertions(+), 2 deletions(-)
diff --git a/dlls/kernelbase/locale.c b/dlls/kernelbase/locale.c
index 8b137cdf90a..7cb16e5b387 100644
--- a/dlls/kernelbase/locale.c
+++ b/dlls/kernelbase/locale.c
@@ -850,16 +850,57 @@ static int locale_return_string( DWORD pos, LCTYPE type, WCHAR *buffer, int len
}
+static int locale_return_number( UINT val, LCTYPE type, WCHAR *buffer, int len )
+{
+ int ret;
+ WCHAR tmp[80];
+
+ if (!(type & LOCALE_RETURN_NUMBER))
+ {
+ switch (LOWORD(type))
+ {
+ case LOCALE_ILANGUAGE:
+ case LOCALE_IDEFAULTLANGUAGE:
+ ret = swprintf( tmp, ARRAY_SIZE(tmp), L"%04x", val ) + 1;
+ break;
+ case LOCALE_IDEFAULTEBCDICCODEPAGE:
+ ret = swprintf( tmp, ARRAY_SIZE(tmp), L"%03u", val ) + 1;
+ break;
+ default:
+ ret = swprintf( tmp, ARRAY_SIZE(tmp), L"%u", val ) + 1;
+ break;
+ }
+ }
+ else ret = sizeof(UINT) / sizeof(WCHAR);
+
+ if (!len) return ret;
+ if (ret > len)
+ {
+ SetLastError( ERROR_INSUFFICIENT_BUFFER );
+ return 0;
+ }
+
+ if (type & LOCALE_RETURN_NUMBER) memcpy( buffer, &val, sizeof(val) );
+ else wcscpy( buffer, tmp );
+
+ 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 )
{
+ UINT val;
+
if (locale != user_locale) type |= LOCALE_NOUSEROVERRIDE;
switch (LOWORD(type))
{
case LOCALE_ILANGUAGE:
- return -1;
+ /* return default language for neutral locales */
+ val = locale->inotneutral ? locale->ilanguage : locale->idefaultlanguage;
+ return locale_return_number( val, type, buffer, len );
case LOCALE_SLOCALIZEDDISPLAYNAME:
return -1;
@@ -883,7 +924,7 @@ static int get_locale_info( const NLS_LOCALE_DATA *locale, LCID lcid, LCTYPE typ
return -1;
case LOCALE_IDEFAULTLANGUAGE:
- return -1;
+ return locale_return_number( locale->idefaultlanguage, type, buffer, len );
case LOCALE_IDEFAULTCOUNTRY:
return -1;
More information about the wine-cvs
mailing list