Alexandre Julliard : ntdll: Store the Unix codepage in a Wine-specific environment variable.
Alexandre Julliard
julliard at winehq.org
Mon Mar 1 15:54:03 CST 2021
Module: wine
Branch: master
Commit: 0d173e5710c71d90b1228857bfe4b89672d9d911
URL: https://source.winehq.org/git/wine.git/?a=commit;h=0d173e5710c71d90b1228857bfe4b89672d9d911
Author: Alexandre Julliard <julliard at winehq.org>
Date: Sun Feb 28 11:22:41 2021 +0100
ntdll: Store the Unix codepage in a Wine-specific environment variable.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernelbase/locale.c | 14 ++++++++------
dlls/ntdll/locale.c | 10 ----------
dlls/ntdll/ntdll.spec | 3 ---
dlls/ntdll/unix/env.c | 14 ++++++++++----
4 files changed, 18 insertions(+), 23 deletions(-)
diff --git a/dlls/kernelbase/locale.c b/dlls/kernelbase/locale.c
index d2f71c97ac7..ac473ccd63a 100644
--- a/dlls/kernelbase/locale.c
+++ b/dlls/kernelbase/locale.c
@@ -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 );
diff --git a/dlls/ntdll/locale.c b/dlls/ntdll/locale.c
index e4d90a8b1d5..892f3fe9e70 100644
--- a/dlls/ntdll/locale.c
+++ b/dlls/ntdll/locale.c
@@ -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 )
{
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 185dd6767eb..78f06881832 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -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)
diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c
index 845abd69a79..a8f490e8740 100644
--- a/dlls/ntdll/unix/env.c
+++ b/dlls/ntdll/unix/env.c
@@ -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;
More information about the wine-cvs
mailing list