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 2003/05/05 22:32:54 UTC
cvs commit: xml-xalan/c/src/PlatformSupport DOMStringHelper.cpp DOMStringHelper.hpp
dbertoni 2003/05/05 13:32:54
Modified: c/src/PlatformSupport DOMStringHelper.cpp
DOMStringHelper.hpp
Log:
Fixed bug where -0 would be formatted with sign. Added more efficient implementation of indexOf().
Revision Changes Path
1.83 +13 -32 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.82
retrieving revision 1.83
diff -u -r1.82 -r1.83
--- DOMStringHelper.cpp 11 Feb 2003 01:38:15 -0000 1.82
+++ DOMStringHelper.cpp 5 May 2003 20:32:54 -0000 1.83
@@ -149,14 +149,7 @@
0
};
-static const XalanDOMChar theNegativeZeroString[] =
-{
- XalanUnicode::charHyphenMinus,
- XalanUnicode::charDigit_0,
- 0
-};
-
-static const XalanDOMChar thePositiveZeroString[] =
+static const XalanDOMChar theZeroString[] =
{
XalanUnicode::charDigit_0,
0
@@ -166,15 +159,14 @@
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString::size_type)
indexOf(
- const XalanDOMChar* theString,
- const XalanDOMChar* theSubstring)
+ const XalanDOMChar* theString,
+ XalanDOMString::size_type theStringLength,
+ const XalanDOMChar* theSubstring,
+ XalanDOMString::size_type theSubstringLength)
{
assert(theString != 0);
assert(theSubstring != 0);
- const XalanDOMString::size_type theStringLength = length(theString);
- const XalanDOMString::size_type theSubstringLength = length(theSubstring);
-
// If the substring is longer than the string, then
// it's not a substring.
if (theStringLength < theSubstringLength)
@@ -1418,19 +1410,13 @@
theNegativeInfinityString,
sizeof(theNegativeInfinityString) / sizeof(theNegativeInfinityString[0]) - 1);
}
- else if (DoubleSupport::isPositiveZero(theDouble) == true)
+ else if (DoubleSupport::isPositiveZero(theDouble) == true ||
+ DoubleSupport::isNegativeZero(theDouble) == true)
{
append(
theResult,
- thePositiveZeroString,
- sizeof(thePositiveZeroString) / sizeof(thePositiveZeroString[0]) - 1);
- }
- else if (DoubleSupport::isNegativeZero(theDouble) == true)
- {
- append(
- theResult,
- theNegativeZeroString,
- sizeof(theNegativeZeroString) / sizeof(theNegativeZeroString[0]) - 1);
+ theZeroString,
+ sizeof(theZeroString) / sizeof(theZeroString[0]) - 1);
}
else if (long(theDouble) == theDouble)
{
@@ -1541,17 +1527,12 @@
theNegativeInfinityString,
sizeof(theNegativeInfinityString) / sizeof(theNegativeInfinityString[0]) - 1);
}
- else if (DoubleSupport::isPositiveZero(theDouble) == true)
- {
- (formatterListener.*function)(
- thePositiveZeroString,
- sizeof(thePositiveZeroString) / sizeof(thePositiveZeroString[0]) - 1);
- }
- else if (DoubleSupport::isNegativeZero(theDouble) == true)
+ else if (DoubleSupport::isPositiveZero(theDouble) == true ||
+ DoubleSupport::isNegativeZero(theDouble) == true)
{
(formatterListener.*function)(
- theNegativeZeroString,
- sizeof(theNegativeZeroString) / sizeof(theNegativeZeroString[0]) - 1);
+ theZeroString,
+ sizeof(theZeroString) / sizeof(theZeroString[0]) - 1);
}
else if (long(theDouble) == theDouble)
{
1.68 +27 -1 xml-xalan/c/src/PlatformSupport/DOMStringHelper.hpp
Index: DOMStringHelper.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/PlatformSupport/DOMStringHelper.hpp,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- DOMStringHelper.hpp 2 Jan 2003 17:15:01 -0000 1.67
+++ DOMStringHelper.hpp 5 May 2003 20:32:54 -0000 1.68
@@ -478,15 +478,41 @@
* Simulates the java String method indexOf().
*
* @param theString string to search
+ * @param theStringLength length of the string to search
* @param theSubstring substring searched for
+ * @param theSubstringLength length of the substring searched for
* @return the index of theSubstring in theString,
* or length(theString) if the string is not
* found.
*/
XALAN_PLATFORMSUPPORT_EXPORT_FUNCTION(XalanDOMString::size_type)
indexOf(
+ const XalanDOMChar* theString,
+ XalanDOMString::size_type theStringLength,
+ const XalanDOMChar* theSubstring,
+ XalanDOMString::size_type theSubstringLength);
+
+
+
+/**
+ * Simulates the java String method indexOf().
+ *
+ * @param theString string to search
+ * @param theSubstring substring searched for
+ * @return the index of theSubstring in theString,
+ * or length(theString) if the string is not
+ * found.
+ */
+inline XalanDOMString::size_type
+indexOf(
const XalanDOMChar* theString,
- const XalanDOMChar* theSubstring);
+ const XalanDOMChar* theSubstring)
+{
+ assert(theString != 0 && theSubstring != 0);
+
+ return indexOf(theString, length(theString), theSubstring, length(theSubstring));
+}
+
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org