Akihiro Sagawa : user32: Fix wsprintfA %C conversion.

Alexandre Julliard julliard at winehq.org
Wed Feb 19 15:35:48 CST 2020


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

Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date:   Wed Feb 19 23:21:35 2020 +0900

user32: Fix wsprintfA %C conversion.

Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/tests/wsprintf.c |  2 --
 dlls/user32/wsprintf.c       | 14 ++++++++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/dlls/user32/tests/wsprintf.c b/dlls/user32/tests/wsprintf.c
index 84dc0eb39b..79d2112cd2 100644
--- a/dlls/user32/tests/wsprintf.c
+++ b/dlls/user32/tests/wsprintf.c
@@ -111,12 +111,10 @@ static void wsprintfATest(void)
         memset(buf, 0x11, sizeof(buf));
         rc = wsprintfA(buf, testcase[i].fmt, testcase[i].input);
 
-        todo_wine_if( i == 7 )
         ok(rc == testcase[i].rc,
            "%u: expected %d, got %d\n",
            i, testcase[i].rc, rc);
 
-        todo_wine_if( i == 7 || i == 8 || i == 9 )
         ok(!strcmp(buf, testcase[i].str),
            "%u: expected %s, got %s\n",
            i, wine_dbgstr_a(testcase[i].str), wine_dbgstr_an(buf, rc));
diff --git a/dlls/user32/wsprintf.c b/dlls/user32/wsprintf.c
index e5e6c10dbb..b197b714f6 100644
--- a/dlls/user32/wsprintf.c
+++ b/dlls/user32/wsprintf.c
@@ -255,8 +255,11 @@ static UINT WPRINTF_GetLen( WPRINTF_FORMAT *format, WPRINTF_DATA *arg,
     switch(format->type)
     {
     case WPR_CHAR:
-    case WPR_WCHAR:
         return (format->precision = 1);
+    case WPR_WCHAR:
+        if (dst_is_wide) len = 1;
+        else len = WideCharToMultiByte( CP_ACP, 0, &arg->wchar_view, 1, NULL, 0, NULL, NULL );
+        return (format->precision = len);
     case WPR_STRING:
         if (!arg->lpcstr_view) arg->lpcstr_view = null_stringA;
         if (dst_is_wide)
@@ -387,7 +390,14 @@ static INT wvsnprintfA( LPSTR buffer, UINT maxlen, LPCSTR spec, __ms_va_list arg
         switch(format.type)
         {
         case WPR_WCHAR:
-            *p++ = argData.wchar_view;
+            {
+                CHAR mb[5];
+                if (WideCharToMultiByte( CP_ACP, 0, &argData.wchar_view, 1, mb, sizeof(mb), NULL, NULL ))
+                {
+                    memcpy( p, mb, len );
+                    p += len;
+                }
+            }
             break;
         case WPR_CHAR:
             *p++ = argData.char_view;




More information about the wine-cvs mailing list