Commit 0d173e57 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Store the Unix codepage in a Wine-specific environment variable.

parent 5828d7c1
......@@ -42,8 +42,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(nls);
#define CALINFO_MAX_YEAR 2029
extern UINT CDECL __wine_get_unix_codepage(void);
extern const unsigned int collation_table[] DECLSPEC_HIDDEN;
static HANDLE kernel32_handle;
......@@ -568,6 +566,7 @@ struct norm_table
};
static NLSTABLEINFO nls_info;
static UINT unix_cp = CP_UTF8;
static UINT mac_cp = 10000;
static HKEY intl_key;
static HKEY nls_key;
......@@ -713,6 +712,9 @@ void init_locale(void)
SIZE_T size;
HKEY hkey;
if (GetEnvironmentVariableW( L"WINEUNIXCP", bufferW, ARRAY_SIZE(bufferW) ))
unix_cp = wcstoul( bufferW, NULL, 10 );
kernel32_handle = GetModuleHandleW( L"kernel32.dll" );
GetLocaleInfoW( LOCALE_SYSTEM_DEFAULT, LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER,
......@@ -5532,8 +5534,7 @@ INT WINAPI DECLSPEC_HOTPATCH MultiByteToWideChar( UINT codepage, DWORD flags, co
ret = mbstowcs_utf8( flags, src, srclen, dst, dstlen );
break;
case CP_UNIXCP:
codepage = __wine_get_unix_codepage();
if (codepage == CP_UTF8)
if (unix_cp == CP_UTF8)
{
ret = mbstowcs_utf8( flags, src, srclen, dst, dstlen );
#ifdef __APPLE__ /* work around broken Mac OS X filesystem that enforces decomposed Unicode */
......@@ -5541,6 +5542,7 @@ INT WINAPI DECLSPEC_HOTPATCH MultiByteToWideChar( UINT codepage, DWORD flags, co
#endif
break;
}
codepage = unix_cp;
/* fall through */
default:
ret = mbstowcs_codepage( codepage, flags, src, srclen, dst, dstlen );
......@@ -5829,13 +5831,13 @@ INT WINAPI DECLSPEC_HOTPATCH WideCharToMultiByte( UINT codepage, DWORD flags, LP
ret = wcstombs_utf8( flags, src, srclen, dst, dstlen, defchar, used );
break;
case CP_UNIXCP:
codepage = __wine_get_unix_codepage();
if (codepage == CP_UTF8)
if (unix_cp == CP_UTF8)
{
if (used) *used = FALSE;
ret = wcstombs_utf8( flags, src, srclen, dst, dstlen, NULL, NULL );
break;
}
codepage = unix_cp;
/* fall through */
default:
ret = wcstombs_codepage( codepage, flags, src, srclen, dst, dstlen, defchar, used );
......
......@@ -652,16 +652,6 @@ int ntdll_wcstoumbs( const WCHAR *src, DWORD srclen, char *dst, DWORD dstlen, BO
}
/******************************************************************
* __wine_get_unix_codepage (NTDLL.@)
*/
UINT CDECL __wine_get_unix_codepage(void)
{
if (!unix_table.CodePage) return CP_UTF8;
return unix_table.CodePage;
}
static NTSTATUS get_dummy_preferred_ui_language( DWORD flags, LANGID lang, ULONG *count,
WCHAR *buffer, ULONG *size )
{
......
......@@ -1625,9 +1625,6 @@
@ cdecl -syscall wine_get_build_id()
@ cdecl -syscall wine_get_host_version(ptr ptr)
# Codepages
@ cdecl __wine_get_unix_codepage()
# Filesystem
@ cdecl -syscall wine_nt_to_unix_file_name(ptr ptr ptr long)
@ cdecl -syscall wine_unix_to_nt_file_name(str ptr ptr)
......@@ -544,6 +544,7 @@ static BOOL is_dynamic_env_var( const char *var )
STARTS_WITH( var, "WINEBUILDDIR=" ) ||
STARTS_WITH( var, "WINECONFIGDIR=" ) ||
STARTS_WITH( var, "WINEDLLDIR" ) ||
STARTS_WITH( var, "WINEUNIXCP=" ) ||
STARTS_WITH( var, "WINEUSERNAME=" ) ||
STARTS_WITH( var, "WINEPRELOADRESERVE=" ) ||
STARTS_WITH( var, "WINELOADERNOEXEC=" ) ||
......@@ -1194,9 +1195,9 @@ static WCHAR *get_dynamic_environment( SIZE_T *size )
SIZE_T alloc, pos = 0;
WCHAR *buffer;
DWORD i;
char dlldir[22];
char str[22];
alloc = 20 * 7; /* 7 variable names */
alloc = 20 * 8; /* 8 variable names */
if (data_dir) alloc += strlen( data_dir ) + 9;
if (home_dir) alloc += strlen( home_dir ) + 9;
if (build_dir) alloc += strlen( build_dir ) + 9;
......@@ -1212,11 +1213,16 @@ static WCHAR *get_dynamic_environment( SIZE_T *size )
if (config_dir) add_path_var( buffer, &pos, "WINECONFIGDIR", config_dir );
for (i = 0; dll_paths[i]; i++)
{
sprintf( dlldir, "WINEDLLDIR%u", i );
add_path_var( buffer, &pos, dlldir, dll_paths[i] );
sprintf( str, "WINEDLLDIR%u", i );
add_path_var( buffer, &pos, str, dll_paths[i] );
}
if (user_name) append_envA( buffer, &pos, "WINEUSERNAME", user_name );
if (overrides) append_envA( buffer, &pos, "WINEDLLOVERRIDES", overrides );
if (unix_cp.data)
{
sprintf( str, "%u", unix_cp.data[1] );
append_envA( buffer, &pos, "WINEUNIXCP", str );
}
assert( pos <= alloc );
*size = pos * sizeof(WCHAR);
return buffer;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment