From: Eric Pouech <epouech@codeweavers.com> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=59403 Signed-off-by: Eric Pouech <epouech@codeweavers.com> --- dlls/msvcrt/printf.h | 4 ++-- dlls/msvcrt/tests/printf.c | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dlls/msvcrt/printf.h b/dlls/msvcrt/printf.h index be30d6ae719..cfcfd5be771 100644 --- a/dlls/msvcrt/printf.h +++ b/dlls/msvcrt/printf.h @@ -375,7 +375,7 @@ static inline int FUNC_NAME(pf_output_special_fp)(FUNC_NAME(puts_clbk) pf_puts, if(!flags->Alternate && (flags->Format == 'g' || flags->Format == 'G')) sfx_len = frac_len; else sfx_len = flags->Precision; - if(sfx_len == -1) { + if(sfx_len < 0) { if(strchr("fFeE", flags->Format)) sfx_len = 6; else if(flags->Format == 'a' || flags->Format == 'A') sfx_len = 13; } @@ -614,7 +614,7 @@ static inline int FUNC_NAME(pf_output_fp)(FUNC_NAME(puts_clbk) pf_puts, void *pu ULONGLONG m; DWORD l; - if(flags->Precision == -1) + if(flags->Precision < 0) flags->Precision = 6; v = frexp(v, &e2); diff --git a/dlls/msvcrt/tests/printf.c b/dlls/msvcrt/tests/printf.c index dc0038b3372..c21b1285275 100644 --- a/dlls/msvcrt/tests/printf.c +++ b/dlls/msvcrt/tests/printf.c @@ -377,6 +377,14 @@ static void test_sprintf( void ) ok(!strcmp(buffer,"foo "),"Negative field width ignored \"%s\"\n",buffer); ok( r==5, "return count wrong\n"); + r = p_sprintf(buffer, "%.*f", 0x80000000, 3.14); + ok(!strcmp(buffer,"3.140000"),"Negative precision ignored \"%s\"\n",buffer); + ok( r==8, "return count wrong\n"); + + r = p_sprintf(buffer, "%.*f", 0x80000000, NAN); + ok(!strcmp(buffer,"1.#QNAN0"),"Negative precision ignored \"%s\"\n",buffer); + ok( r==8, "return count wrong\n"); + x = 0; r = p_sprintf(buffer, "asdf%n", &x ); if (r == -1) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10107