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:
parent
d324014d42
commit
b6722aa752
|
@ -74,8 +74,8 @@ char **main_envp = NULL;
|
||||||
static WCHAR **main_wargv;
|
static WCHAR **main_wargv;
|
||||||
|
|
||||||
static CPTABLEINFO unix_table;
|
static CPTABLEINFO unix_table;
|
||||||
static WCHAR system_locale[LOCALE_NAME_MAX_LENGTH];
|
static char system_locale[LOCALE_NAME_MAX_LENGTH];
|
||||||
static WCHAR user_locale[LOCALE_NAME_MAX_LENGTH];
|
static char user_locale[LOCALE_NAME_MAX_LENGTH];
|
||||||
|
|
||||||
static void *read_nls_file( const char *name )
|
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]
|
/* Unix format is: lang[_country][.charset][@modifier]
|
||||||
* Windows format is: lang[-script][-country][_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 char sep[] = "_.@";
|
||||||
static const WCHAR posixW[] = {'P','O','S','I','X',0};
|
char buffer[LOCALE_NAME_MAX_LENGTH];
|
||||||
static const WCHAR cW[] = {'C',0};
|
char *p, *country = NULL, *modifier = NULL;
|
||||||
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;
|
|
||||||
|
|
||||||
if (!unix_name || !unix_name[0] || !strcmp( unix_name, "C" ))
|
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;
|
if (!unix_name || !unix_name[0]) return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = ntdll_umbstowcs( unix_name, strlen(unix_name), buffer, ARRAY_SIZE(buffer) );
|
if (!(p = strpbrk( buffer, sep )))
|
||||||
if (len == ARRAY_SIZE(buffer)) return FALSE;
|
|
||||||
buffer[len] = 0;
|
|
||||||
|
|
||||||
if (!(p = wcspbrk( buffer, sepW )))
|
|
||||||
{
|
{
|
||||||
if (!wcscmp( buffer, posixW ) || !wcscmp( buffer, cW ))
|
if (!strcmp( buffer, "POSIX" ) || !strcmp( buffer, "C" ))
|
||||||
wcscpy( win_name, enUSW );
|
strcpy( win_name, "en-US" );
|
||||||
else
|
else
|
||||||
wcscpy( win_name, buffer );
|
strcpy( win_name, buffer );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -685,13 +674,13 @@ static BOOL unix_to_win_locale( const char *unix_name, WCHAR *win_name )
|
||||||
{
|
{
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
country = p;
|
country = p;
|
||||||
p = wcspbrk( p, sepW + 1 );
|
p = strpbrk( p, sep + 1 );
|
||||||
}
|
}
|
||||||
if (p && *p == '.')
|
if (p && *p == '.')
|
||||||
{
|
{
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
/* charset, ignore */
|
/* charset, ignore */
|
||||||
p = wcschr( p, '@' );
|
p = strchr( p, '@' );
|
||||||
}
|
}
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
|
@ -701,18 +690,18 @@ static BOOL unix_to_win_locale( const char *unix_name, WCHAR *win_name )
|
||||||
|
|
||||||
/* rebuild a Windows name */
|
/* rebuild a Windows name */
|
||||||
|
|
||||||
wcscpy( win_name, buffer );
|
strcpy( win_name, buffer );
|
||||||
if (modifier)
|
if (modifier)
|
||||||
{
|
{
|
||||||
if (!wcscmp( modifier, latinW )) wcscat( win_name, latnW );
|
if (!strcmp( modifier, "latin" )) strcat( win_name, "-Latn" );
|
||||||
else if (!wcscmp( modifier, euroW )) {} /* ignore */
|
else if (!strcmp( modifier, "euro" )) {} /* ignore */
|
||||||
else return FALSE;
|
else return FALSE;
|
||||||
}
|
}
|
||||||
if (country)
|
if (country)
|
||||||
{
|
{
|
||||||
p = win_name + wcslen(win_name);
|
p = win_name + strlen(win_name);
|
||||||
*p++ = '-';
|
*p++ = '-';
|
||||||
wcscpy( p, country );
|
strcpy( p, country );
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1083,6 +1072,6 @@ void CDECL get_unix_codepage( CPTABLEINFO *table )
|
||||||
*/
|
*/
|
||||||
void CDECL get_locales( WCHAR *sys, WCHAR *user )
|
void CDECL get_locales( WCHAR *sys, WCHAR *user )
|
||||||
{
|
{
|
||||||
wcscpy( sys, system_locale );
|
ntdll_umbstowcs( system_locale, ARRAY_SIZE(system_locale), sys, LOCALE_NAME_MAX_LENGTH * sizeof(WCHAR) );
|
||||||
wcscpy( user, user_locale );
|
ntdll_umbstowcs( user_locale, ARRAY_SIZE(user_locale), user, LOCALE_NAME_MAX_LENGTH * sizeof(WCHAR) );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue