Commit fa8a9a81 authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

user32: Fix wsprintfW %S conversion.

parent c8f46313
...@@ -188,12 +188,11 @@ static void wsprintfWTest(void) ...@@ -188,12 +188,11 @@ static void wsprintfWTest(void)
memset(buf, 0x11, sizeof(buf)); memset(buf, 0x11, sizeof(buf));
rc = wsprintfW(buf, testcase[i].fmt, testcase[i].input); rc = wsprintfW(buf, testcase[i].fmt, testcase[i].input);
todo_wine_if (i == 2)
ok(rc == testcase[i].rc, ok(rc == testcase[i].rc,
"%u: expected %d, got %d\n", "%u: expected %d, got %d\n",
i, testcase[i].rc, rc); i, testcase[i].rc, rc);
todo_wine ok(!memcmp(buf, testcase[i].str, (testcase[i].rc + 1) * sizeof(WCHAR)), ok(!memcmp(buf, testcase[i].str, (testcase[i].rc + 1) * sizeof(WCHAR)),
"%u: expected %s, got %s\n", i, "%u: expected %s, got %s\n", i,
wine_dbgstr_wn(testcase[i].str, testcase[i].rc + 1), wine_dbgstr_wn(testcase[i].str, testcase[i].rc + 1),
wine_dbgstr_wn(buf, rc + 1)); wine_dbgstr_wn(buf, rc + 1));
......
...@@ -259,8 +259,22 @@ static UINT WPRINTF_GetLen( WPRINTF_FORMAT *format, WPRINTF_DATA *arg, ...@@ -259,8 +259,22 @@ static UINT WPRINTF_GetLen( WPRINTF_FORMAT *format, WPRINTF_DATA *arg,
return (format->precision = 1); return (format->precision = 1);
case WPR_STRING: case WPR_STRING:
if (!arg->lpcstr_view) arg->lpcstr_view = null_stringA; if (!arg->lpcstr_view) arg->lpcstr_view = null_stringA;
for (len = 0; !format->precision || (len < format->precision); len++) if (dst_is_wide)
if (!*(arg->lpcstr_view + len)) break; {
LPCSTR p = arg->lpcstr_view;
for (len = 0; (!format->precision || len < format->precision) && *p; p++)
{
/* This isn't applicable for UTF-8 and UTF-7 */
if (IsDBCSLeadByte( *p )) p++;
len++;
if (!*p) break;
}
}
else
{
for (len = 0; !format->precision || (len < format->precision); len++)
if (!*(arg->lpcstr_view + len)) break;
}
if (len > maxlen) len = maxlen; if (len > maxlen) len = maxlen;
return (format->precision = len); return (format->precision = len);
case WPR_WSTRING: case WPR_WSTRING:
...@@ -494,7 +508,14 @@ static INT wvsnprintfW( LPWSTR buffer, UINT maxlen, LPCWSTR spec, __ms_va_list a ...@@ -494,7 +508,14 @@ static INT wvsnprintfW( LPWSTR buffer, UINT maxlen, LPCWSTR spec, __ms_va_list a
case WPR_STRING: case WPR_STRING:
{ {
LPCSTR ptr = argData.lpcstr_view; LPCSTR ptr = argData.lpcstr_view;
for (i = 0; i < len; i++) *p++ = (BYTE)*ptr++; for (i = 0; i < len; i++)
{
WCHAR buf[2]; /* for LeadByte + NUL case, we need 2 WCHARs. */
int ret, mb_len = IsDBCSLeadByte( *ptr ) ? 2 : 1;
ret = MultiByteToWideChar( CP_ACP, 0, ptr, mb_len, buf, ARRAY_SIZE( buf ));
*p++ = buf[ret - 1];
ptr += mb_len;
}
} }
break; break;
case WPR_WSTRING: case WPR_WSTRING:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment