Alex Villacís Lasso : oleaut32: VarBstrFromCy - Remove use of sprintfW by converting a CY

Alexandre Julliard julliard at wine.codeweavers.com
Thu Dec 21 10:36:28 CST 2006


Module: wine
Branch: master
Commit: 4a4effe3f7124e62f223dd20adfc38246950756d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4a4effe3f7124e62f223dd20adfc38246950756d

Author: Alex Villacís Lasso <a_villacis at palosanto.com>
Date:   Wed Dec 20 13:53:41 2006 -0500

oleaut32: VarBstrFromCy - Remove use of sprintfW by converting a CY
into a DECIMAL instead of a double as an intermediate step.

---

 dlls/oleaut32/vartype.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/dlls/oleaut32/vartype.c b/dlls/oleaut32/vartype.c
index 66f863d..2cccbec 100644
--- a/dlls/oleaut32/vartype.c
+++ b/dlls/oleaut32/vartype.c
@@ -6499,13 +6499,26 @@ HRESULT WINAPI VarBstrFromR8(double dblI
 HRESULT WINAPI VarBstrFromCy(CY cyIn, LCID lcid, ULONG dwFlags, BSTR *pbstrOut)
 {
   WCHAR buff[256];
-  double dblVal;
+  VARIANT_DI decVal;
 
   if (!pbstrOut)
     return E_INVALIDARG;
 
-  VarR8FromCy(cyIn, &dblVal);
-  sprintfW(buff, szDoubleFormatW, dblVal);
+  decVal.scale = 4;
+  decVal.sign = 0;
+  decVal.bitsnum[0] = cyIn.s.Lo;
+  decVal.bitsnum[1] = cyIn.s.Hi;
+  if (cyIn.s.Hi & 0x80000000UL) {
+    DWORD one = 1;
+
+    /* Negative number! */
+    decVal.sign = 1;
+    decVal.bitsnum[0] = ~decVal.bitsnum[0];
+    decVal.bitsnum[1] = ~decVal.bitsnum[1];
+    VARIANT_int_add(decVal.bitsnum, 3, &one, 1);
+  }
+  decVal.bitsnum[2] = 0;
+  VARIANT_DI_tostringW(&decVal, buff, sizeof(buff));
 
   if (dwFlags & LOCALE_USE_NLS)
   {




More information about the wine-cvs mailing list