oleaut32: Fix rounding

André Hentschel nerv at dawncrow.de
Thu Feb 11 10:17:35 CST 2010


---
 dlls/oleaut32/tests/varformat.c |   10 ++++++++--
 dlls/oleaut32/varformat.c       |    3 ++-
 dlls/oleaut32/variant.c         |    2 +-
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/dlls/oleaut32/tests/varformat.c b/dlls/oleaut32/tests/varformat.c
index 9d15fd9..d0975ed 100644
--- a/dlls/oleaut32/tests/varformat.c
+++ b/dlls/oleaut32/tests/varformat.c
@@ -381,8 +381,14 @@ static void test_VarFormat(void)
   VARFMT(VT_R8,V_R8,-0.1,".#",S_OK,"-.1");
   VARFMT(VT_R8,V_R8,0.099,"#.#",S_OK,".1");
   VARFMT(VT_R8,V_R8,0.0999,"#.##",S_OK,".1");
-  /* for large negative exponents, wine truncates instead of rounding */
-  todo_wine VARFMT(VT_R8,V_R8,0.099,"#.##",S_OK,".1");
+  VARFMT(VT_R8,V_R8,0.099,"#.##",S_OK,".1");
+  VARFMT(VT_R8,V_R8,0.0099,"#.##",S_OK,".01");
+  VARFMT(VT_R8,V_R8,0.0049,"#.##",S_OK,".");
+  VARFMT(VT_R8,V_R8,0.0094,"#.##",S_OK,".01");
+  VARFMT(VT_R8,V_R8,0.00099,"#.##",S_OK,".");
+  VARFMT(VT_R8,V_R8,0.0995,"#.##",S_OK,".1");
+  VARFMT(VT_R8,V_R8,8.0995,"#.##",S_OK,"8.1");
+  VARFMT(VT_R8,V_R8,0.0994,"#.##",S_OK,".1");
 
 
   /* 'out' is not cleared */
diff --git a/dlls/oleaut32/varformat.c b/dlls/oleaut32/varformat.c
index f6c142d..b47ac85 100644
--- a/dlls/oleaut32/varformat.c
+++ b/dlls/oleaut32/varformat.c
@@ -1290,7 +1290,8 @@ static HRESULT VARIANT_FormatNumber(LPVARIANT pVarIn, LPOLESTR lpszFormat,
     /* Rounding the number */
     if (have_frac > need_frac)
     {
-      prgbDig = &rgbDig[have_int + need_frac];
+      prgbDig = &rgbDig[have_int + need_frac?need_frac+1:0];
+      if (*prgbDig < 5) prgbDig--;
       have_frac = need_frac;
       if (*prgbDig >= 5)
       {
diff --git a/dlls/oleaut32/variant.c b/dlls/oleaut32/variant.c
index 450856f..55ec848 100644
--- a/dlls/oleaut32/variant.c
+++ b/dlls/oleaut32/variant.c
@@ -1798,7 +1798,7 @@ HRESULT WINAPI VarParseNumFromStr(OLECHAR *lpszStr, LCID lcid, ULONG dwFlags,
       /* If we have no digits so far, skip leading zeros */
       if (!pNumprs->cDig)
       {
-        while (lpszStr[1] == '0')
+        while (lpszStr[0] == '0')
         {
           dwState |= B_LEADING_ZERO;
           cchUsed++;
-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list