dbertoni    2002/06/19 18:13:48

  Modified:    c/src/PlatformSupport DOMStringHelper.cpp
  Log:
  Better support for double-to-string conversions.
  
  Revision  Changes    Path
  1.71      +42 -2     xml-xalan/c/src/PlatformSupport/DOMStringHelper.cpp
  
  Index: DOMStringHelper.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DOMStringHelper.cpp,v
  retrieving revision 1.70
  retrieving revision 1.71
  diff -u -r1.70 -r1.71
  --- DOMStringHelper.cpp       6 May 2002 05:16:56 -0000       1.70
  +++ DOMStringHelper.cpp       20 Jun 2002 01:13:48 -0000      1.71
  @@ -1400,6 +1400,35 @@
   
   
   
  +static const char* const     thePrintfStrings[] =
  +{
  +     "%.15f",
  +     "%.16f",
  +     "%.17f",
  +     "%.18f",
  +     "%.19f",
  +     "%.20f",
  +     "%.21f",
  +     "%.22f",
  +     "%.23f",
  +     "%.24f",
  +     "%.25f",
  +     "%.26f",
  +     "%.27f",
  +     "%.28f",
  +     "%.29f",
  +     "%.30f",
  +     "%.31f",
  +     "%.32f",
  +     "%.33f",
  +     "%.34f",
  +     "%.35f",
  +     0
  +};
  +
  +
  +
  +
   XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString)&
   PointerToDOMString(
                        const void*                     theValue,
  @@ -1461,10 +1490,21 @@
   
   #if defined(XALAN_STRICT_ANSI_HEADERS)
                using std::sprintf;
  +             using std::atof;
   #endif
   
  -             unsigned int    theCharsWritten = sprintf(theBuffer, "%f", 
theDouble);
  -             assert(theCharsWritten != 0);
  +             const char* const *             thePrintfString = 
thePrintfStrings;
  +
  +             unsigned int    theCharsWritten = 0;
  +
  +             do
  +             {
  +                     theCharsWritten = sprintf(theBuffer, *thePrintfString, 
theDouble);
  +                     assert(theCharsWritten != 0);
  +
  +                     ++thePrintfString;
  +             }
  +             while(atof(theBuffer) != theDouble && *thePrintfString != 0);
   
                // First, cleanup the output to conform to the XPath standard,
                // which says no trailing '0's for the decimal portion.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to