dbertoni    01/02/01 10:32:08

  Modified:    c/src/XPath FunctionRound.cpp FunctionRound.hpp
                        FunctionSubstring.cpp
  Log:
  Moved rounding function to PlatformSupport/DoubleSupport.
  
  Revision  Changes    Path
  1.6       +2 -51     xml-xalan/c/src/XPath/FunctionRound.cpp
  
  Index: FunctionRound.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionRound.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- FunctionRound.cpp 2000/12/06 21:00:46     1.5
  +++ FunctionRound.cpp 2001/02/01 18:32:04     1.6
  @@ -98,8 +98,7 @@
   {
        assert(arg1.null() == false);   
   
  -     return executionContext.getXObjectFactory().createNumber(
  -             getRoundedValue(arg1->num()));
  +     return 
executionContext.getXObjectFactory().createNumber(DoubleSupport::round(arg1->num()));
   }
   
   
  @@ -159,56 +158,8 @@
   
   
   
  -double
  -FunctionRound::getRoundedValue(double        theValue)
  -{
  -     if (DoubleSupport::isNaN(theValue))
  -     {
  -             return DoubleSupport::getNaN();
  -     }
  -     else if (DoubleSupport::isPositiveInfinity(theValue))
  -     {
  -             return DoubleSupport::getPositiveInfinity();
  -     }
  -     if (DoubleSupport::isNegativeInfinity(theValue))
  -     {
  -             return DoubleSupport::getNegativeInfinity();
  -     }
  -     else if (theValue == 0)
  -     {
  -             return 0.0;
  -     }
  -     else if (theValue > 0)
  -     {
  -             return long(theValue + 0.5);
  -     }
  -     else
  -     {
  -             // Negative numbers are a special case.  Any time we
  -             // have -0.5 as the fractional part, we have to
  -             // round up (toward 0), rather than down.
  -             double                  intPart = 0;
  -
  -             const double    fracPart = modf(theValue, &intPart);
  -
  -             if (fracPart == -0.5)
  -             {
  -                     // special case -- we have have to round toward 0...
  -                     return long(theValue + 0.5);
  -             }
  -             else
  -             {
  -                     return long(theValue - 0.5);
  -             }
  -     }
  -}
  -
  -
  -
   const XalanDOMString
   FunctionRound::getError() const
   {
  -     return XALAN_STATIC_UCODE_STRING(
  -             "The round() function takes one argument!");
  +     return XALAN_STATIC_UCODE_STRING("The round() function takes one 
argument!");
   }
  -
  
  
  
  1.10      +0 -3      xml-xalan/c/src/XPath/FunctionRound.hpp
  
  Index: FunctionRound.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionRound.hpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- FunctionRound.hpp 2000/12/06 21:00:47     1.9
  +++ FunctionRound.hpp 2001/02/01 18:32:05     1.10
  @@ -127,9 +127,6 @@
   #endif
        clone() const;
   
  -     static double
  -     getRoundedValue(double  theValue);
  -
   private:
   
        virtual const XalanDOMString
  
  
  
  1.12      +7 -3      xml-xalan/c/src/XPath/FunctionSubstring.cpp
  
  Index: FunctionSubstring.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionSubstring.cpp,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- FunctionSubstring.cpp     2001/01/25 17:14:14     1.11
  +++ FunctionSubstring.cpp     2001/02/01 18:32:06     1.12
  @@ -58,6 +58,10 @@
   
   
   
  +#include <PlatformSupport/DoubleSupport.hpp>
  +
  +
  +
   #include "XObjectFactory.hpp"
   
   
  @@ -89,7 +93,7 @@
        }
        else
        {
  -             return 
unsigned(FunctionRound::getRoundedValue(theSecondArgValue)) - 1;
  +             return unsigned(DoubleSupport::round(theSecondArgValue)) - 1;
        }
   }
   
  @@ -139,7 +143,7 @@
        else
        {
                const double    theRoundedValue =
  -                     FunctionRound::getRoundedValue(theSecondArgValue + 
arg3->num());
  +                     DoubleSupport::round(theSecondArgValue + arg3->num());
   
                // If there's overflow, then we should return the length of the 
string + 1.
                if (DoubleSupport::isPositiveInfinity(theRoundedValue) == true)
  @@ -223,7 +227,7 @@
        {
                // Get the value of the second argument...
                const double    theSecondArgValue =
  -                     FunctionRound::getRoundedValue(arg2->num());
  +                     DoubleSupport::round(arg2->num());
   
                // XPath indexes from 1, so this is the first XPath index....
                const unsigned int      theStartIndex = 
getStartIndex(theSecondArgValue);
  
  
  

Reply via email to