From: Paul Gofman pgofman@codeweavers.com
--- dlls/shlwapi/tests/string.c | 11 +++++++++++ dlls/shlwapi/wsprintf.c | 38 +++++++++++++++++++++++-------------- 2 files changed, 35 insertions(+), 14 deletions(-)
diff --git a/dlls/shlwapi/tests/string.c b/dlls/shlwapi/tests/string.c index b0562bda6e0..9794b9b2024 100644 --- a/dlls/shlwapi/tests/string.c +++ b/dlls/shlwapi/tests/string.c @@ -1703,9 +1703,13 @@ static void test_printf_format(void) tests[] = { { "%qu", 0, "qu", NULL, 10 }, + { "%ll", 0, "", NULL, 10 }, { "%lu", sizeof(ULONG), "10", NULL, 10 }, { "%#lx", sizeof(ULONG), "0xa", NULL, 10 }, { "%hu", sizeof(ULONG), "10", NULL, 10 }, + { "%hhu", sizeof(ULONG), "10", NULL, 10 }, + { "%hwu", sizeof(ULONG), "10", NULL, 10 }, + { "%whu", sizeof(ULONG), "10", NULL, 10 }, { "%s", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)"str", L"str" }, { "%S", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str", "str" }, { "%ls", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str" }, @@ -1713,12 +1717,19 @@ static void test_printf_format(void) { "%hs", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)"str" }, { "%hS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)"str" }, { "%ws", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str" }, + { "%hhs", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)"str" }, + { "%hhS", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)"str" }, + { "%wwws", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)L"str" }, { "%c", sizeof(SHORT), "\xc8", L"\x95c8", 0x95c8 }, { "%lc", sizeof(SHORT), "\x3f", L"\x95c8", 0x95c8 }, { "%C", sizeof(SHORT), "\x3f", L"\xc8", 0x95c8 }, { "%lC", sizeof(SHORT), "\x3f", L"\x95c8", 0x95c8 }, { "%hc", sizeof(BYTE), "\xc8", L"\xc8", 0x95c8 }, + { "%hhc", sizeof(BYTE), "\xc8", L"\xc8", 0x95c8 }, + { "%hhhc", sizeof(BYTE), "\xc8", L"\xc8", 0x95c8 }, { "%I64u", sizeof(ULONG64), "10", NULL, 10 }, + { "%llI64u", sizeof(ULONG64), "10", NULL, 10 }, + { "%I64llu", sizeof(ULONG64), "10", NULL, 10 }, { "%I64s", sizeof(ULONG_PTR), "str", NULL, (ULONG_PTR)"str", L"str" }, { "%q%u", sizeof(ULONG), "q10", NULL, 10 }, }; diff --git a/dlls/shlwapi/wsprintf.c b/dlls/shlwapi/wsprintf.c index fbd2a7e75bf..ed385081821 100644 --- a/dlls/shlwapi/wsprintf.c +++ b/dlls/shlwapi/wsprintf.c @@ -110,14 +110,19 @@ static INT WPRINTF_ParseFormatA( LPCSTR format, WPRINTF_FORMAT *res ) p++; } } - if (*p == 'l') { res->flags |= WPRINTF_LONG; p++; } - else if (*p == 'h') { res->flags |= WPRINTF_SHORT; p++; } - else if (*p == 'w') { res->flags |= WPRINTF_WIDE; p++; } - else if (*p == 'I') + while (*p && strchr("lhwI", *p)) { - if (p[1] == '6' && p[2] == '4') { res->flags |= WPRINTF_I64; p += 3; } - else if (p[1] == '3' && p[2] == '2') p += 3; - else { res->flags |= WPRINTF_INTPTR; p++; } + switch (*p) + { + case 'l': res->flags |= WPRINTF_LONG; ++p; break; + case 'I': + if (p[1] == '6' && p[2] == '4') { res->flags |= WPRINTF_I64; p += 3; } + else if (p[1] == '3' && p[2] == '2') p += 3; + else { res->flags |= WPRINTF_INTPTR; p++; } + break; + case 'h': res->flags |= WPRINTF_SHORT; ++p; break; + case 'w': res->flags |= WPRINTF_WIDE; ++p; break; + } } switch(*p) { @@ -192,14 +197,19 @@ static INT WPRINTF_ParseFormatW( LPCWSTR format, WPRINTF_FORMAT *res ) p++; } } - if (*p == 'l') { res->flags |= WPRINTF_LONG; p++; } - else if (*p == 'h') { res->flags |= WPRINTF_SHORT; p++; } - else if (*p == 'w') { res->flags |= WPRINTF_WIDE; p++; } - else if (*p == 'I') + while (*p && strchr("lhwI", *p)) { - if (p[1] == '6' && p[2] == '4') { res->flags |= WPRINTF_I64; p += 3; } - else if (p[1] == '3' && p[2] == '2') p += 3; - else { res->flags |= WPRINTF_INTPTR; p++; } + switch (*p) + { + case 'l': res->flags |= WPRINTF_LONG; ++p; break; + case 'I': + if (p[1] == '6' && p[2] == '4') { res->flags |= WPRINTF_I64; p += 3; } + else if (p[1] == '3' && p[2] == '2') p += 3; + else { res->flags |= WPRINTF_INTPTR; p++; } + break; + case 'h': res->flags |= WPRINTF_SHORT; ++p; break; + case 'w': res->flags |= WPRINTF_WIDE; ++p; break; + } } switch(*p) {