Alexandre Julliard : win32u: Use character sizes in the codepage conversion functions.

Alexandre Julliard julliard at winehq.org
Tue Apr 12 15:35:15 CDT 2022


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Apr 12 10:10:34 2022 +0200

win32u: Use character sizes in the codepage conversion functions.

For consistency with ntdll.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/win32u/font.c           |  6 +++---
 dlls/win32u/freetype.c       | 10 ++++------
 dlls/win32u/win32u_private.h |  2 +-
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/dlls/win32u/font.c b/dlls/win32u/font.c
index 82daf9ad2ba..ac1e40ebf2f 100644
--- a/dlls/win32u/font.c
+++ b/dlls/win32u/font.c
@@ -3243,7 +3243,7 @@ DWORD win32u_wctomb( CPTABLEINFO *info, char *dst, DWORD dstlen, const WCHAR *sr
 
     if (!info && !(info = get_cptable( get_acp() ))) return 0;
 
-    RtlUnicodeToCustomCPN( info, dst, dstlen, &ret, src, srclen );
+    RtlUnicodeToCustomCPN( info, dst, dstlen, &ret, src, srclen * sizeof(WCHAR) );
     return ret;
 }
 
@@ -3253,8 +3253,8 @@ DWORD win32u_mbtowc( CPTABLEINFO *info, WCHAR *dst, DWORD dstlen, const char *sr
 
     if (!info && !(info = get_cptable( get_acp() ))) return 0;
 
-    RtlCustomCPToUnicodeN( info, dst, dstlen, &ret, src, srclen );
-    return ret;
+    RtlCustomCPToUnicodeN( info, dst, dstlen * sizeof(WCHAR), &ret, src, srclen );
+    return ret / sizeof(WCHAR);
 }
 
 static BOOL wc_to_index( UINT cp, WCHAR wc, unsigned char *dst, BOOL allow_default )
diff --git a/dlls/win32u/freetype.c b/dlls/win32u/freetype.c
index 0703d32740e..e0c98d9106a 100644
--- a/dlls/win32u/freetype.c
+++ b/dlls/win32u/freetype.c
@@ -782,9 +782,8 @@ static WCHAR *copy_name_table_string( const FT_SfntName *name )
     case TT_PLATFORM_MACINTOSH:
         if (!(cp = get_mac_code_page( name ))) return NULL;
         ret = malloc( (name->string_len + 1) * sizeof(WCHAR) );
-        i = win32u_mbtowc( cp, ret, name->string_len * sizeof(WCHAR),
-                           (char *)name->string, name->string_len );
-        ret[i / sizeof(WCHAR)] = 0;
+        i = win32u_mbtowc( cp, ret, name->string_len, (char *)name->string, name->string_len );
+        ret[i] = 0;
         return ret;
     }
     return NULL;
@@ -1142,8 +1141,7 @@ static WCHAR *decode_opentype_name( struct opentype_name *name )
     {
         CPTABLEINFO *cptable = get_cptable( name->codepage );
         if (!cptable) return NULL;
-        len = win32u_mbtowc( cptable, buffer, sizeof(buffer), name->bytes, name->length );
-        len /= sizeof(WCHAR);
+        len = win32u_mbtowc( cptable, buffer, ARRAY_SIZE(buffer), name->bytes, name->length );
     }
 
     buffer[ARRAY_SIZE(buffer) - 1] = 0;
@@ -2526,7 +2524,7 @@ static BOOL freetype_get_glyph_index( struct gdi_font *font, UINT *glyph, BOOL u
             DWORD len;
             char ch;
 
-            len = win32u_wctomb( NULL, &ch, 1, &wc, sizeof(wc) );
+            len = win32u_wctomb( NULL, &ch, 1, &wc, 1 );
             if (len) *glyph = get_glyph_index_symbol( font, (unsigned char)ch );
         }
         return TRUE;
diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h
index f570bde39fe..3adb30e8d5c 100644
--- a/dlls/win32u/win32u_private.h
+++ b/dlls/win32u/win32u_private.h
@@ -593,7 +593,7 @@ static inline WCHAR *towstr( const char *str )
 {
     DWORD len = strlen( str ) + 1;
     WCHAR *ret = malloc( len * sizeof(WCHAR) );
-    if (ret) win32u_mbtowc( NULL, ret, len * sizeof(WCHAR), str, len );
+    if (ret) win32u_mbtowc( NULL, ret, len, str, len );
     return ret;
 }
 




More information about the wine-cvs mailing list