You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@apache.org on 2008/03/18 06:31:37 UTC
svn commit: r638221 [9/9] - in /xalan/c/trunk: ./
Projects/Win32/Res/AllInOne/ Projects/Win32/VC6/AllInOne/
Projects/Win32/VC6/ApacheModuleXSLT/ Projects/Win32/VC6/CompileStylesheet/
Projects/Win32/VC6/DocumentBuilder/ Projects/Win32/VC6/ExternalFuncti...
Modified: xalan/c/trunk/src/xalanc/XMLSupport/XMLSupportDefinitions.hpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XMLSupport/XMLSupportDefinitions.hpp?rev=638221&r1=638220&r2=638221&view=diff
==============================================================================
--- xalan/c/trunk/src/xalanc/XMLSupport/XMLSupportDefinitions.hpp (original)
+++ xalan/c/trunk/src/xalanc/XMLSupport/XMLSupportDefinitions.hpp Mon Mar 17 22:31:10 2008
@@ -24,7 +24,7 @@
-#if defined(XALAN_XMLSUPPORT_BUILD_DLL)
+#if defined(XALAN_BUILD_DLL)
#define XALAN_XMLSUPPORT_EXPORT XALAN_PLATFORM_EXPORT
Modified: xalan/c/trunk/src/xalanc/XPath/FunctionSubstring.cpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XPath/FunctionSubstring.cpp?rev=638221&r1=638220&r2=638221&view=diff
==============================================================================
--- xalan/c/trunk/src/xalanc/XPath/FunctionSubstring.cpp (original)
+++ xalan/c/trunk/src/xalanc/XPath/FunctionSubstring.cpp Mon Mar 17 22:31:10 2008
@@ -49,28 +49,51 @@
/*
- * Get the value for the start index (C-style, not XPath).
+ * Get the value for the start index (C-style, not XPath). This
+ * function expects theSecondArgValue to be already rounded.
*/
inline XalanDOMString::size_type
getStartIndex(
double theSecondArgValue,
XalanDOMString::size_type theStringLength)
{
- // We always subtract 1 for C-style index, since XPath indexes from 1.
-
- // Anything less than, or equal to 1 is 0.
- if (theSecondArgValue <= 1 ||
- DoubleSupport::isNaN(theSecondArgValue) == true)
+ // We always subtract 1 for C-style index, since
+ // XPath indexes from 1.
+
+ // If we end up with NaN, INF, or -INF, then no possible index
+ // can be greater than or equal to that, so just return
+ // the start index as the length of the string. That
+ // will result in an empty string, which is what we want.
+ if (DoubleSupport::isNaN(theSecondArgValue) == true ||
+ DoubleSupport::isPositiveInfinity(theSecondArgValue) == true ||
+ DoubleSupport::isNegativeInfinity(theSecondArgValue) == true)
{
- return 0;
+ return theStringLength;
}
- else if (DoubleSupport::isPositiveInfinity(theSecondArgValue) == true)
+ // Anything less than, or equal to 1 is 0.
+ else if (DoubleSupport::lessThanOrEqual(theSecondArgValue, 1) == true)
{
- return theStringLength;
+ assert(DoubleSupport::round(theSecondArgValue) == theSecondArgValue);
+
+ return 0;
}
else
{
- return XalanDOMString::size_type(DoubleSupport::round(theSecondArgValue)) - 1;
+ assert(DoubleSupport::round(theSecondArgValue) == theSecondArgValue);
+
+ // Since we have filtered out anything less than
+ // 1, and any special values, we can do this without
+ // calling DoubleSupport::subtract().
+ const double theResult = theSecondArgValue - 1;
+
+ assert(
+ DoubleSupport::equal(
+ DoubleSupport::subtract(
+ theSecondArgValue,
+ 1),
+ theResult));
+
+ return XalanDOMString::size_type(theResult);
}
}
@@ -82,55 +105,83 @@
inline XalanDOMString::size_type
getSubstringLength(
XalanDOMString::size_type theSourceStringLength,
- XalanDOMString::size_type theStartIndex,
- double theThirdArgValue)
+ XalanDOMString::size_type theStartIndex,
+ double theSecondArgValue,
+ const XObjectPtr& arg3)
{
- // The last index must be less than theThirdArgValue. Since it has
- // already been rounded, subtracting 1 will do the job.
- const XalanDOMString::size_type theLastIndex = XalanDOMString::size_type(theThirdArgValue - 1);
-
- if (theLastIndex >= theSourceStringLength)
- {
- return theSourceStringLength - theStartIndex;
- }
- else
- {
- return theLastIndex - theStartIndex;
- }
-}
+ assert(theStartIndex < theSourceStringLength);
+ assert(DoubleSupport::isNaN(theSecondArgValue) == false);
+ assert(DoubleSupport::isNegativeInfinity(theSecondArgValue) == false);
+ assert(DoubleSupport::isPositiveInfinity(theSecondArgValue) == false);
+ typedef XalanDOMString::size_type size_type;
+ const size_type theMaxLength =
+ theSourceStringLength - theStartIndex;
-/*
- * Get the total of the second and third arguments.
- */
-inline double
-getTotal(
- XalanDOMString::size_type theSourceStringLength,
- double theSecondArgValue,
- const XObjectPtr& arg3)
-{
// Total the second and third arguments. If the third argument is
// missing, make it the length of the string + 1 (for XPath
// indexing style).
if (arg3.null() == true)
{
- return double(theSourceStringLength + 1);
+ return theMaxLength;
}
else
{
- const double theRoundedValue =
- DoubleSupport::round(DoubleSupport::add(theSecondArgValue, arg3->num()));
+ const double theThirdArgValue = arg3->num();
- // If there's overflow, then we should return the length of the string + 1.
- if (DoubleSupport::isPositiveInfinity(theRoundedValue) == true)
- {
- return double(theSourceStringLength + 1);
- }
- else
- {
- return theRoundedValue;
- }
+ if (DoubleSupport::isNaN(theThirdArgValue) == true ||
+ DoubleSupport::isNegativeInfinity(theThirdArgValue) == true)
+ {
+ return 0;
+ }
+ else if (DoubleSupport::isPositiveInfinity(theThirdArgValue) == true)
+ {
+ return theMaxLength;
+ }
+ else
+ {
+ const double theRoundedValue =
+ DoubleSupport::round(theThirdArgValue);
+ assert(DoubleSupport::isNaN(theRoundedValue) == false);
+ assert(DoubleSupport::isNegativeInfinity(theRoundedValue) == false);
+ assert(DoubleSupport::isPositiveInfinity(theRoundedValue) == false);
+
+ // The XPath recommendation states that following:
+ //
+ // http://www.w3.org/TR/xpath#function-substring
+ //
+ // "The returned substring contains those characters for which the
+ // position of the character is greater than or equal to the rounded
+ // value of the second argument and, if the third argument is specified,
+ // less than the sum of the rounded value of the second argument and the
+ // rounded value of the third argument; the comparisons and addition used
+ // for the above follow the standard IEEE 754 rules; rounding is done as
+ // if by a call to the round function."
+ //
+ // Note that this is indexing from 1.
+ const double theTotal =
+ theRoundedValue + theSecondArgValue;
+
+ const size_type theXPathStartIndex =
+ theStartIndex + 1;
+
+ // If the total is less than or equal to
+ // the starting index, or greater
+ // than or equal to the starting index, the
+ // substring is empty.
+ if (theTotal <= theXPathStartIndex)
+ {
+ return 0;
+ }
+ else
+ {
+ const size_type theSubstringLength =
+ size_type(theTotal) - theXPathStartIndex;
+
+ return theSubstringLength > theMaxLength ? theMaxLength : theSubstringLength;
+ }
+ }
}
}
@@ -186,8 +237,9 @@
const double theSecondArgValue =
DoubleSupport::round(arg2->num());
- // XPath indexes from 1, so this is the first XPath index....
- const XalanDOMString::size_type theStartIndex = getStartIndex(theSecondArgValue, theSourceStringLength);
+ // XPath indexes from 1, so this is the first XPath index....
+ const XalanDOMString::size_type theStartIndex =
+ getStartIndex(theSecondArgValue, theSourceStringLength);
if (theStartIndex >= theSourceStringLength)
{
@@ -195,25 +247,22 @@
}
else
{
- const double theTotal =
- getTotal( theSourceStringLength, theSecondArgValue, arg3);
+ assert(DoubleSupport::isNaN(theSecondArgValue) == false);
+ assert(DoubleSupport::isPositiveInfinity(theSecondArgValue) == false);
+
+ const XalanDOMString::size_type theSubstringLength =
+ getSubstringLength(
+ theSourceStringLength,
+ theStartIndex,
+ theSecondArgValue,
+ arg3);
- if (DoubleSupport::isNaN(theSecondArgValue) == true ||
- DoubleSupport::isNaN(theTotal) == true ||
- DoubleSupport::isNegativeInfinity(theTotal) == true ||
- theTotal == 0.0 ||
- theTotal < double(theStartIndex))
+ if (theSubstringLength == 0)
{
return createEmptyString(executionContext);
}
else
{
- const XalanDOMString::size_type theSubstringLength =
- getSubstringLength(
- theSourceStringLength,
- theStartIndex,
- theTotal);
-
XPathExecutionContext::GetAndReleaseCachedString theResult(executionContext);
XalanDOMString& theString = theResult.get();
Modified: xalan/c/trunk/src/xalanc/XPath/XPathDefinitions.hpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XPath/XPathDefinitions.hpp?rev=638221&r1=638220&r2=638221&view=diff
==============================================================================
--- xalan/c/trunk/src/xalanc/XPath/XPathDefinitions.hpp (original)
+++ xalan/c/trunk/src/xalanc/XPath/XPathDefinitions.hpp Mon Mar 17 22:31:10 2008
@@ -24,7 +24,7 @@
-#if defined(XALAN_XPATH_BUILD_DLL)
+#if defined(XALAN_BUILD_DLL)
#define XALAN_XPATH_EXPORT XALAN_PLATFORM_EXPORT
Modified: xalan/c/trunk/src/xalanc/XPathCAPI/XPathCAPI.cpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XPathCAPI/XPathCAPI.cpp?rev=638221&r1=638220&r2=638221&view=diff
==============================================================================
--- xalan/c/trunk/src/xalanc/XPathCAPI/XPathCAPI.cpp (original)
+++ xalan/c/trunk/src/xalanc/XPathCAPI/XPathCAPI.cpp Mon Mar 17 22:31:10 2008
@@ -36,9 +36,7 @@
#include <xalanc/XPath/XObjectFactory.hpp>
#include <xalanc/XPath/XPath.hpp>
-#if defined(XALAN_ALLINONE_BUILD_DLL)
#include <xalanc/XPath/XPathConstructionContextDefault.hpp>
-#endif
#include <xalanc/XPath/XPathEvaluator.hpp>
#include <xalanc/XPath/XPathExecutionContextDefault.hpp>
#include <xalanc/XPath/XPathFactoryDefault.hpp>
Modified: xalan/c/trunk/src/xalanc/XPathCAPI/XPathCAPI.h
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XPathCAPI/XPathCAPI.h?rev=638221&r1=638220&r2=638221&view=diff
==============================================================================
--- xalan/c/trunk/src/xalanc/XPathCAPI/XPathCAPI.h (original)
+++ xalan/c/trunk/src/xalanc/XPathCAPI/XPathCAPI.h Mon Mar 17 22:31:10 2008
@@ -22,7 +22,7 @@
#if defined(_MSC_VER)
-#if defined(XALAN_XPATHCAPI_BUILD_DLL)
+#if defined(XALAN_BUILD_DLL)
#define XALAN_XPATHCAPI_EXPORT __declspec(dllexport)
#define XALAN_XPATHCAPI_EXPORT_FUNCTION(T) T __declspec(dllexport)
Modified: xalan/c/trunk/src/xalanc/XSLT/FunctionDocument.cpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XSLT/FunctionDocument.cpp?rev=638221&r1=638220&r2=638221&view=diff
==============================================================================
--- xalan/c/trunk/src/xalanc/XSLT/FunctionDocument.cpp (original)
+++ xalan/c/trunk/src/xalanc/XSLT/FunctionDocument.cpp Mon Mar 17 22:31:10 2008
@@ -373,7 +373,9 @@
const XalanDOMString::size_type indexOfColon = indexOf(ref, XalanUnicode::charColon);
XalanDOMString::size_type indexOfSlash = indexOf(ref, XalanUnicode::charSolidus);
-#if defined(WIN32)
+#if defined(XALAN_WINDOWS)
+ // $$$TODO
+ // Note this is hackish code for Windows, and we should try to remove it.
const XalanDOMString::size_type indexOfBackSlash = indexOf(ref, XalanUnicode::charReverseSolidus);
if(indexOfBackSlash > indexOfSlash && indexOfBackSlash < theLength)
Modified: xalan/c/trunk/src/xalanc/XSLT/StylesheetConstructionContextDefault.hpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XSLT/StylesheetConstructionContextDefault.hpp?rev=638221&r1=638220&r2=638221&view=diff
==============================================================================
--- xalan/c/trunk/src/xalanc/XSLT/StylesheetConstructionContextDefault.hpp (original)
+++ xalan/c/trunk/src/xalanc/XSLT/StylesheetConstructionContextDefault.hpp Mon Mar 17 22:31:10 2008
@@ -35,7 +35,7 @@
-#if defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION) || (XALAN_ALLINONE_BUILD_DLL)
+#if defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION) || defined(XALAN_BUILD_DLL)
#include <xalanc/XPath/XPathProcessor.hpp>
#endif
Modified: xalan/c/trunk/src/xalanc/XSLT/XSLTDefinitions.hpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XSLT/XSLTDefinitions.hpp?rev=638221&r1=638220&r2=638221&view=diff
==============================================================================
--- xalan/c/trunk/src/xalanc/XSLT/XSLTDefinitions.hpp (original)
+++ xalan/c/trunk/src/xalanc/XSLT/XSLTDefinitions.hpp Mon Mar 17 22:31:10 2008
@@ -20,7 +20,7 @@
#include <xalanc/Include/PlatformDefinitions.hpp>
-#if defined(XALAN_XSLT_BUILD_DLL)
+#if defined(XALAN_BUILD_DLL)
# define XALAN_XSLT_EXPORT XALAN_PLATFORM_EXPORT
# define XALAN_XSLT_EXPORT_FUNCTION(T) XALAN_PLATFORM_EXPORT_FUNCTION(T)
#else
Modified: xalan/c/trunk/src/xalanc/XalanDOM/XalanDOMDefinitions.hpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XalanDOM/XalanDOMDefinitions.hpp?rev=638221&r1=638220&r2=638221&view=diff
==============================================================================
--- xalan/c/trunk/src/xalanc/XalanDOM/XalanDOMDefinitions.hpp (original)
+++ xalan/c/trunk/src/xalanc/XalanDOM/XalanDOMDefinitions.hpp Mon Mar 17 22:31:10 2008
@@ -26,7 +26,7 @@
-#if defined(XALAN_DOM_BUILD_DLL)
+#if defined(XALAN_BUILD_DLL)
#define XALAN_DOM_EXPORT XALAN_PLATFORM_EXPORT
Modified: xalan/c/trunk/src/xalanc/XalanEXSLT/XalanEXSLTDefinitions.hpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XalanEXSLT/XalanEXSLTDefinitions.hpp?rev=638221&r1=638220&r2=638221&view=diff
==============================================================================
--- xalan/c/trunk/src/xalanc/XalanEXSLT/XalanEXSLTDefinitions.hpp (original)
+++ xalan/c/trunk/src/xalanc/XalanEXSLT/XalanEXSLTDefinitions.hpp Mon Mar 17 22:31:10 2008
@@ -24,7 +24,7 @@
-#if defined(XALAN_EXSLT_BUILD_DLL)
+#if defined(XALAN_BUILD_DLL)
#define XALAN_EXSLT_EXPORT XALAN_PLATFORM_EXPORT
Modified: xalan/c/trunk/src/xalanc/XalanExe/XalanExe.cpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XalanExe/XalanExe.cpp?rev=638221&r1=638220&r2=638221&view=diff
==============================================================================
--- xalan/c/trunk/src/xalanc/XalanExe/XalanExe.cpp (original)
+++ xalan/c/trunk/src/xalanc/XalanExe/XalanExe.cpp Mon Mar 17 22:31:10 2008
@@ -829,7 +829,7 @@
-#if defined(_WINDOWS)
+#if defined(XALAN_WINDOWS)
class WindowsMemoryManager : public XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager
{
@@ -907,7 +907,7 @@
XALAN_USING_XERCES(XMLPlatformUtils)
-#if defined(_WINDOWS) && defined(NDEBUG)
+#if defined(XALAN_WINDOWS) && defined(NDEBUG)
WindowsMemoryManager theMemoryManager;
// Call the static initializer for Xerces...
@@ -980,7 +980,7 @@
int argc,
char* argv[])
{
-#if !defined(NDEBUG) && defined(_MSC_VER)
+#if defined(_DEBUG) && defined(_MSC_VER)
_CrtSetDbgFlag(
_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
Modified: xalan/c/trunk/src/xalanc/XalanExtensions/XalanExtensionsDefinitions.hpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XalanExtensions/XalanExtensionsDefinitions.hpp?rev=638221&r1=638220&r2=638221&view=diff
==============================================================================
--- xalan/c/trunk/src/xalanc/XalanExtensions/XalanExtensionsDefinitions.hpp (original)
+++ xalan/c/trunk/src/xalanc/XalanExtensions/XalanExtensionsDefinitions.hpp Mon Mar 17 22:31:10 2008
@@ -24,7 +24,7 @@
-#if defined(XALAN_XALANEXTENSIONS_BUILD_DLL)
+#if defined(XALAN_BUILD_DLL)
#define XALAN_XALANEXTENSIONS_EXPORT XALAN_PLATFORM_EXPORT
Modified: xalan/c/trunk/src/xalanc/XalanSourceTree/XalanSourceTreeDefinitions.hpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XalanSourceTree/XalanSourceTreeDefinitions.hpp?rev=638221&r1=638220&r2=638221&view=diff
==============================================================================
--- xalan/c/trunk/src/xalanc/XalanSourceTree/XalanSourceTreeDefinitions.hpp (original)
+++ xalan/c/trunk/src/xalanc/XalanSourceTree/XalanSourceTreeDefinitions.hpp Mon Mar 17 22:31:10 2008
@@ -24,7 +24,7 @@
-#if defined(XALAN_XALANSOURCETREE_BUILD_DLL)
+#if defined(XALAN_BUILD_DLL)
#define XALAN_XALANSOURCETREE_EXPORT XALAN_PLATFORM_EXPORT
Modified: xalan/c/trunk/src/xalanc/XalanTransformer/XalanTransformerDefinitions.hpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XalanTransformer/XalanTransformerDefinitions.hpp?rev=638221&r1=638220&r2=638221&view=diff
==============================================================================
--- xalan/c/trunk/src/xalanc/XalanTransformer/XalanTransformerDefinitions.hpp (original)
+++ xalan/c/trunk/src/xalanc/XalanTransformer/XalanTransformerDefinitions.hpp Mon Mar 17 22:31:10 2008
@@ -28,7 +28,7 @@
-#if defined(XALAN_TRANSFORMER_BUILD_DLL)
+#if defined(XALAN_BUILD_DLL)
#define XALAN_TRANSFORMER_EXPORT XALAN_PLATFORM_EXPORT
Modified: xalan/c/trunk/src/xalanc/XercesParserLiaison/XercesParserLiaisonDefinitions.hpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XercesParserLiaison/XercesParserLiaisonDefinitions.hpp?rev=638221&r1=638220&r2=638221&view=diff
==============================================================================
--- xalan/c/trunk/src/xalanc/XercesParserLiaison/XercesParserLiaisonDefinitions.hpp (original)
+++ xalan/c/trunk/src/xalanc/XercesParserLiaison/XercesParserLiaisonDefinitions.hpp Mon Mar 17 22:31:10 2008
@@ -28,7 +28,7 @@
-#if defined(XALAN_XERCESPARSERLIAISON_BUILD_DLL)
+#if defined(XALAN_BUILD_DLL)
#define XALAN_XERCESPARSERLIAISON_EXPORT XALAN_PLATFORM_EXPORT
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org