dbertoni    2002/11/13 16:09:26

  Modified:    c/src/PlatformSupport DOMStringHelper.cpp
  Log:
  Fixed bug where change in locale could cause conversions to fail.
  
  Revision  Changes    Path
  1.77      +34 -21    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.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- DOMStringHelper.cpp       7 Nov 2002 00:34:31 -0000       1.76
  +++ DOMStringHelper.cpp       14 Nov 2002 00:09:26 -0000      1.77
  @@ -591,12 +591,12 @@
   
   
   
  -template <class SizeType, class FunctionType>
  +template <class FunctionType>
   XalanDOMString
   TransformString(
  -                     const XalanDOMChar*             theInputString,
  -                     SizeType                                
theInputStringLength,
  -                     FunctionType                    theFunction)
  +                     const XalanDOMChar*                     theInputString,
  +                     XalanDOMString::size_type       theInputStringLength,
  +                     FunctionType                            theFunction)
   {
        assert(theInputString != 0);
   
  @@ -888,7 +888,6 @@
   {
        assert(theLHS != 0 && theRHS != 0);
   
  -#if 1
        if (theLength == 0)
        {
                return true;
  @@ -913,20 +912,6 @@
   
                return false;
        }
  -#else
  -     for(SizeType i = 0; i < theLength; ++i)
  -     {
  -             const Type      theLHSChar = theTransformFunction(theLHS[i]);
  -             const Type      theRHSChar = theTransformFunction(theRHS[i]);
  -
  -             if (theLHSChar != theRHSChar)
  -             {
  -                     return false;
  -             }
  -     }
  -
  -     return true;
  -#endif
   }
   
   
  @@ -1367,6 +1352,11 @@
   
   static const char* const     thePrintfStrings[] =
   {
  +     "%.10f",
  +     "%.11f",
  +     "%.12f",
  +     "%.13f",
  +     "%.14f",
        "%.15f",
        "%.16f",
        "%.17f",
  @@ -1475,7 +1465,7 @@
   
                const char* const *             thePrintfString = 
thePrintfStrings;
   
  -             unsigned int    theCharsWritten = 0;
  +             int             theCharsWritten = 0;
   
                do
                {
  @@ -1499,13 +1489,36 @@
                {
                }
   
  +             int             theCurrentIndex = theCharsWritten;
  +
                // If a decimal point stopped the loop, then
                // we don't want to preserve it.  Otherwise,
                // another digit stopped the loop, so we must
                // preserve it.
  -             if(theBuffer[theCharsWritten] != '.')
  +             if(isdigit(theBuffer[theCharsWritten]))
                {
                        ++theCharsWritten;
  +             }
  +
  +             // Some other character other than '.' can be the
  +             // separator.  This can happen if the locale is
  +             // not the "C" locale, etc.  If that's the case,
  +             // replace it with '.'.
  +             while(theCurrentIndex > 0)
  +             {
  +                     if (isdigit(theBuffer[theCurrentIndex]))
  +                     {
  +                             --theCurrentIndex;
  +                     }
  +                     else
  +                     {
  +                             if (theBuffer[theCurrentIndex] != '.')
  +                             {
  +                                     theBuffer[theCurrentIndex] = '.';
  +                             }
  +
  +                             break;
  +                     }
                }
   
                reserve(theResult, length(theResult) + theCharsWritten);
  
  
  

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

Reply via email to