Piotr Caban : ucrtbase: Fix away from 0 rounding in %a format.

Alexandre Julliard julliard at winehq.org
Thu Aug 6 16:33:46 CDT 2020


Module: wine
Branch: master
Commit: 04de6fe37e92b4bb4910a469e820ad8608ac79cf
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=04de6fe37e92b4bb4910a469e820ad8608ac79cf

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Thu Aug  6 13:18:07 2020 +0200

ucrtbase: Fix away from 0 rounding in %a format.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msvcrt/printf.h         |  4 ++--
 dlls/ucrtbase/tests/printf.c | 11 +++++++----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/dlls/msvcrt/printf.h b/dlls/msvcrt/printf.h
index b9b379f91e..4b47d65803 100644
--- a/dlls/msvcrt/printf.h
+++ b/dlls/msvcrt/printf.h
@@ -446,10 +446,10 @@ static inline int FUNC_NAME(pf_output_hex_fp)(FUNC_NAME(puts_clbk) pf_puts, void
         mant >>= 4;
     }
     if(!flags->Precision) {
-        if(p[0] > '8') p[-2]++;
+        if(p[0] >= '8') p[-2]++;
         if(!flags->Alternate) p--;
     }else if(flags->Precision>0 && flags->Precision<MANT_BITS/4) {
-        BOOL round_up = (p[flags->Precision] > '8');
+        BOOL round_up = (p[flags->Precision] >= '8');
         for(r=flags->Precision-1; r>=0 && round_up; r--) {
             round_up = FALSE;
             if(p[r]=='f' || p[r]=='F') {
diff --git a/dlls/ucrtbase/tests/printf.c b/dlls/ucrtbase/tests/printf.c
index f8446b8ac9..a26bd230e5 100644
--- a/dlls/ucrtbase/tests/printf.c
+++ b/dlls/ucrtbase/tests/printf.c
@@ -747,18 +747,21 @@ static void test_printf_fp(void)
         { "%.a", 0.1e-20, { "0x1p-70" }},
         { "%a", 0.1e-20, { "0x1.2e3b40a0e9b4fp-70" }},
         { "%a", 4.9406564584124654e-324, { "0x0.0000000000001p-1022" }},
-        { "%.0a", -1.5, { "-0x1p+0" }},
+        { "%.0a", -1.5, { "-0x2p+0" }, { "-0x1p+0" }},
         { "%.0a", -0.5, { "-0x1p-1" }},
         { "%.0a", 0.5, { "0x1p-1" }},
-        { "%.0a", 1.5, { "0x1p+0" }},
+        { "%.0a", 1.5, { "0x2p+0" }, { "0x1p+0" }},
         { "%.0a", 1.99, { "0x2p+0" }},
         { "%.0a", 2, { "0x1p+1" }},
         { "%.0a", 9.5, { "0x1p+3" }},
         { "%.0a", 10.5, { "0x1p+3" }},
-        { "%#.0a", -1.5, { "-0x1.p+0" }},
+        { "%#.0a", -1.5, { "-0x2.p+0" }, { "-0x1.p+0" }},
         { "%#.0a", -0.5, { "-0x1.p-1" }},
         { "%#.0a", 0.5, { "0x1.p-1" }},
-        { "%#.0a", 1.5, { "0x1.p+0" }},
+        { "%#.0a", 1.5, { "0x2.p+0" }, { "0x1.p+0" }},
+        { "%#.1a", 1.03125, { "0x1.1p+0" }, { "0x1.0p+0" }},
+        { "%#.1a", 1.09375, { "0x1.2p+0" }, { "0x1.1p+0" }},
+        { "%#.1a", 1.15625, { "0x1.3p+0" }, { "0x1.2p+0" }},
 
         { "%f", 0, { "0.000000" }},
         { "%e", 0, { "0.000000e+00", NULL, "0.000000e+000" }},




More information about the wine-cvs mailing list