Huw Davies : netapi32: Default to CP_UTF8 when WINEUNIXCP is not set.

Alexandre Julliard julliard at winehq.org
Tue Jul 20 15:11:04 CDT 2021


Module: wine
Branch: master
Commit: 4c10543b6a54cdcc57b5ce7efd839b17d60471e6
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=4c10543b6a54cdcc57b5ce7efd839b17d60471e6

Author: Huw Davies <huw at codeweavers.com>
Date:   Tue Jul 20 08:44:19 2021 +0100

netapi32: Default to CP_UTF8 when WINEUNIXCP is not set.

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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);




More information about the wine-cvs mailing list