ntdll: Don't use WCHAR in unix_to_win_locale().

Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Gijs Vermeulen 2020-06-30 16:44:54 +02:00 committed by Alexandre Julliard
parent d324014d42
commit b6722aa752
1 changed files with 19 additions and 30 deletions

View File

@ -74,8 +74,8 @@ char **main_envp = NULL;
static WCHAR **main_wargv;
static CPTABLEINFO unix_table;
static WCHAR system_locale[LOCALE_NAME_MAX_LENGTH];
static WCHAR user_locale[LOCALE_NAME_MAX_LENGTH];
static char system_locale[LOCALE_NAME_MAX_LENGTH];
static char user_locale[LOCALE_NAME_MAX_LENGTH];
static void *read_nls_file( const char *name )
{
@ -649,18 +649,11 @@ static WCHAR **build_wargv( char **argv )
/* Unix format is: lang[_country][.charset][@modifier]
* Windows format is: lang[-script][-country][_modifier] */
static BOOL unix_to_win_locale( const char *unix_name, WCHAR *win_name )
static BOOL unix_to_win_locale( const char *unix_name, char *win_name )
{
static const WCHAR sepW[] = {'_','.','@',0};
static const WCHAR posixW[] = {'P','O','S','I','X',0};
static const WCHAR cW[] = {'C',0};
static const WCHAR euroW[] = {'e','u','r','o',0};
static const WCHAR latinW[] = {'l','a','t','i','n',0};
static const WCHAR latnW[] = {'-','L','a','t','n',0};
static const WCHAR enUSW[] = {'e','n','-','U','S',0};
WCHAR buffer[LOCALE_NAME_MAX_LENGTH];
WCHAR *p, *country = NULL, *modifier = NULL;
DWORD len;
static const char sep[] = "_.@";
char buffer[LOCALE_NAME_MAX_LENGTH];
char *p, *country = NULL, *modifier = NULL;
if (!unix_name || !unix_name[0] || !strcmp( unix_name, "C" ))
{
@ -668,16 +661,12 @@ static BOOL unix_to_win_locale( const char *unix_name, WCHAR *win_name )
if (!unix_name || !unix_name[0]) return FALSE;
}
len = ntdll_umbstowcs( unix_name, strlen(unix_name), buffer, ARRAY_SIZE(buffer) );
if (len == ARRAY_SIZE(buffer)) return FALSE;
buffer[len] = 0;
if (!(p = wcspbrk( buffer, sepW )))
if (!(p = strpbrk( buffer, sep )))
{
if (!wcscmp( buffer, posixW ) || !wcscmp( buffer, cW ))
wcscpy( win_name, enUSW );
if (!strcmp( buffer, "POSIX" ) || !strcmp( buffer, "C" ))
strcpy( win_name, "en-US" );
else
wcscpy( win_name, buffer );
strcpy( win_name, buffer );
return TRUE;
}
@ -685,13 +674,13 @@ static BOOL unix_to_win_locale( const char *unix_name, WCHAR *win_name )
{
*p++ = 0;
country = p;
p = wcspbrk( p, sepW + 1 );
p = strpbrk( p, sep + 1 );
}
if (p && *p == '.')
{
*p++ = 0;
/* charset, ignore */
p = wcschr( p, '@' );
p = strchr( p, '@' );
}
if (p)
{
@ -701,18 +690,18 @@ static BOOL unix_to_win_locale( const char *unix_name, WCHAR *win_name )
/* rebuild a Windows name */
wcscpy( win_name, buffer );
strcpy( win_name, buffer );
if (modifier)
{
if (!wcscmp( modifier, latinW )) wcscat( win_name, latnW );
else if (!wcscmp( modifier, euroW )) {} /* ignore */
if (!strcmp( modifier, "latin" )) strcat( win_name, "-Latn" );
else if (!strcmp( modifier, "euro" )) {} /* ignore */
else return FALSE;
}
if (country)
{
p = win_name + wcslen(win_name);
p = win_name + strlen(win_name);
*p++ = '-';
wcscpy( p, country );
strcpy( p, country );
}
return TRUE;
}
@ -1083,6 +1072,6 @@ void CDECL get_unix_codepage( CPTABLEINFO *table )
*/
void CDECL get_locales( WCHAR *sys, WCHAR *user )
{
wcscpy( sys, system_locale );
wcscpy( user, user_locale );
ntdll_umbstowcs( system_locale, ARRAY_SIZE(system_locale), sys, LOCALE_NAME_MAX_LENGTH * sizeof(WCHAR) );
ntdll_umbstowcs( user_locale, ARRAY_SIZE(user_locale), user, LOCALE_NAME_MAX_LENGTH * sizeof(WCHAR) );
}