[PATCH] netapi32: Default to CP_UTF8 when WINEUNIXCP is not set.
Huw Davies
huw at codeweavers.com
Tue Jul 20 02:44:19 CDT 2021
Signed-off-by: Huw Davies <huw at codeweavers.com>
---
dlls/netapi32/unixlib.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/dlls/netapi32/unixlib.c b/dlls/netapi32/unixlib.c
index 6a8999a6de4..cd04a1116ce 100644
--- a/dlls/netapi32/unixlib.c
+++ b/dlls/netapi32/unixlib.c
@@ -68,9 +68,9 @@ static NET_API_STATUS (*pNetShareDel)( const char *, const char *, unsigned int
static NET_API_STATUS (*pNetWkstaGetInfo)( const char *, unsigned int, unsigned char ** );
static CPTABLEINFO unix_cptable;
-static ULONG unix_cp;
+static ULONG unix_cp = CP_UTF8;
-static BOOL get_unix_codepage(void)
+static DWORD WINAPI get_unix_codepage_once( RTL_RUN_ONCE *once, void *param, void **context )
{
static const WCHAR wineunixcpW[] = {'W','I','N','E','U','N','I','X','C','P',0};
UNICODE_STRING name, value;
@@ -78,19 +78,23 @@ static BOOL get_unix_codepage(void)
SIZE_T size;
void *ptr;
- if (unix_cp) return TRUE;
-
RtlInitUnicodeString( &name, wineunixcpW );
value.Buffer = value_buffer;
value.MaximumLength = sizeof(value_buffer);
if (!RtlQueryEnvironmentVariable_U( NULL, &name, &value ))
RtlUnicodeStringToInteger( &value, 10, &unix_cp );
- if (NtGetNlsSectionPtr( 11, unix_cp, NULL, &ptr, &size ))
- return FALSE;
- RtlInitCodePageTable( ptr, &unix_cptable );
+ if (unix_cp != CP_UTF8 && !NtGetNlsSectionPtr( 11, unix_cp, NULL, &ptr, &size ))
+ RtlInitCodePageTable( ptr, &unix_cptable );
return TRUE;
}
+static BOOL get_unix_codepage( void )
+{
+ static RTL_RUN_ONCE once = RTL_RUN_ONCE_INIT;
+
+ return !RtlRunOnceExecuteOnce( &once, get_unix_codepage_once, NULL, NULL );
+}
+
static DWORD netapi_wcstoumbs( const WCHAR *src, char *dst, DWORD dstlen )
{
DWORD srclen = (strlenW( src ) + 1) * sizeof(WCHAR);
--
2.23.0
More information about the wine-devel
mailing list