From: Paul Gofman pgofman@codeweavers.com
--- dlls/ntdll/printf.h | 18 +++++++----------- dlls/ntdll/tests/string.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/dlls/ntdll/printf.h b/dlls/ntdll/printf.h index 43ed6bd23fc..e57cb01338b 100644 --- a/dlls/ntdll/printf.h +++ b/dlls/ntdll/printf.h @@ -200,19 +200,14 @@ static int FUNC_NAME(pf_handle_string_format)( FUNC_NAME(pf_output) *out, const if (str == NULL) /* catch NULL pointer */ return FUNC_NAME(pf_output_format)( out, APISTR("(null)"), -1, flags );
- /* prefixes take priority over %c,%s vs. %C,%S, so we handle them first */ - if (flags->WideString || flags->IntegerLength == LEN_LONG) - return FUNC_NAME(pf_output_format_wstr)( out, str, len, flags ); - if (flags->IntegerLength == LEN_SHORT) - return FUNC_NAME(pf_output_format_str)( out, str, len, flags ); - - /* %s,%c -> chars in ansi functions & wchars in unicode - * %S,%C -> wchars in ansi functions & chars in unicode */ - if (!inverted) return FUNC_NAME(pf_output_format)( out, str, len, flags); #ifdef PRINTF_WIDE - return FUNC_NAME(pf_output_format_str)( out, str, len, flags ); -#else + if (flags->IntegerLength == LEN_SHORT || (inverted && !flags->WideString)) + return FUNC_NAME(pf_output_format_str)( out, str, len, flags ); return FUNC_NAME(pf_output_format_wstr)( out, str, len, flags ); +#else + if (flags->WideString || (inverted && flags->IntegerLength != LEN_SHORT)) + return FUNC_NAME(pf_output_format_wstr)( out, str, len, flags ); + return FUNC_NAME(pf_output_format_str)( out, str, len, flags ); #endif }
@@ -378,6 +373,7 @@ static int FUNC_NAME(pf_vsnprintf)( FUNC_NAME(pf_output) *out, const APICHAR *fo else if( *p == 'l' ) { flags.IntegerLength = LEN_LONG; + flags.WideString = TRUE; p++; } else if( *p == 'L' ) diff --git a/dlls/ntdll/tests/string.c b/dlls/ntdll/tests/string.c index 43330b2006f..c9901c10883 100644 --- a/dlls/ntdll/tests/string.c +++ b/dlls/ntdll/tests/string.c @@ -1869,6 +1869,16 @@ static void test_printf_format(void) { "%wwS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str" }, { "%wwws", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str" }, { "%wwwS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str" }, + { "%hws", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" }, + { "%hwS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" }, + { "%whs", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" }, + { "%whS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" }, + { "%hwlls", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" }, + { "%hwllS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" }, + { "%lhws", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" }, + { "%llhws", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" }, + { "%lhwS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" }, + { "%llhwS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" }, { "%c", sizeof(SHORT), "\xc8", L"\x95c8", 0x95c8 }, { "%lc", sizeof(SHORT), "\x3f", L"\x95c8", 0x95c8 }, { "%llc", sizeof(SHORT), "\xc8", L"\x95c8", 0x95c8 }, @@ -1886,6 +1896,10 @@ static void test_printf_format(void) { "%hhhc", sizeof(BYTE), "\xc8", L"\xc8", 0x95c8 }, { "%wc", sizeof(BYTE), "\x3f", L"\x95c8", 0x95c8 }, { "%wC", sizeof(BYTE), "\x3f", L"\x95c8", 0x95c8 }, + { "%hwc", sizeof(BYTE), "\x3f", L"\xc8", 0x95c8 }, + { "%whc", sizeof(BYTE), "\x3f", L"\xc8", 0x95c8 }, + { "%hwC", sizeof(BYTE), "\x3f", L"\xc8", 0x95c8 }, + { "%whC", sizeof(BYTE), "\x3f", L"\xc8", 0x95c8 }, { "%I64u", sizeof(ULONG64), "10", NULL, 10 }, { "%llI64u", sizeof(ULONG64), "10", NULL, 10 }, { "%I64llu", sizeof(ULONG64), "10", NULL, 10 },