Module: wine Branch: master Commit: 2ffcf4402181e7e7e8c322b713924e5738506c88 URL: https://source.winehq.org/git/wine.git/?a=commit;h=2ffcf4402181e7e7e8c322b71...
Author: Piotr Caban piotr@codeweavers.com Date: Sat Jul 10 20:38:16 2021 +0200
msvcrt: Update round_limb on first limb length change in printf.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51435 Signed-off-by: Piotr Caban piotr@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/msvcrt/printf.h | 14 ++++++++++++++ dlls/ucrtbase/tests/printf.c | 1 + 2 files changed, 15 insertions(+)
diff --git a/dlls/msvcrt/printf.h b/dlls/msvcrt/printf.h index c6c074de795..d6b945e8ac7 100644 --- a/dlls/msvcrt/printf.h +++ b/dlls/msvcrt/printf.h @@ -704,11 +704,25 @@ static inline int FUNC_NAME(pf_output_fp)(FUNC_NAME(puts_clbk) pf_puts, void *pu if(i != first_limb_len) { first_limb_len = i; radix_pos++; + + round_pos++; + if (round_pos == LIMB_DIGITS) + { + round_pos = 0; + round_limb++; + } } } else if(i == b->e) { first_limb_len = 1; radix_pos++; b->e++; + + round_pos++; + if (round_pos == LIMB_DIGITS) + { + round_pos = 0; + round_limb++; + } } } } diff --git a/dlls/ucrtbase/tests/printf.c b/dlls/ucrtbase/tests/printf.c index 96241b22cf0..588e579cc7e 100644 --- a/dlls/ucrtbase/tests/printf.c +++ b/dlls/ucrtbase/tests/printf.c @@ -819,6 +819,7 @@ static void test_printf_fp(void) { "%.0f", 0.5, { "1", NULL, NULL, NULL, "0" }, {NULL, NULL, NULL, NULL, "1" }}, { "%.0f", 1.5, { "2" }}, { "%.0f", 2.5, { "3", NULL, NULL, NULL, "2" }, {NULL, NULL, NULL, NULL, "3" }}, + { "%g", 9.999999999999999e-5, { "0.0001" }}, };
const char *res = NULL;