dbertoni 2003/02/21 11:37:08
Modified: c/src/XPath FunctionSubstringAfter.cpp
FunctionSubstringBefore.cpp
Log:
Fixes for errata.
Revision Changes Path
1.16 +33 -24 xml-xalan/c/src/XPath/FunctionSubstringAfter.cpp
Index: FunctionSubstringAfter.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionSubstringAfter.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- FunctionSubstringAfter.cpp 3 Jan 2003 21:45:23 -0000 1.15
+++ FunctionSubstringAfter.cpp 21 Feb 2003 19:37:08 -0000 1.16
@@ -111,37 +111,46 @@
{
const XalanDOMString& theSecondString = arg2->str();
- const XalanDOMString::size_type theIndex =
indexOf(theFirstString,
-
theSecondString);
+ const XalanDOMString::size_type theSecondStringLength =
length(theSecondString);
- if (theIndex == theFirstStringLength)
+ if (theSecondStringLength == 0)
{
- return createEmptyString(executionContext);
+ return arg1;
}
else
{
- const XalanDOMString::size_type
theSecondStringLength = length(theSecondString);
+ const XalanDOMString::size_type theIndex =
indexOf(theFirstString,
+
theSecondString);
- // Find the first character, which will be the offset
of the index of the
- // beginning of the second string, plus the length of
the second string.
- const XalanDOMChar* const theFirstCharacter =
- toCharArray(theFirstString) + theIndex +
theSecondStringLength;
+ if (theIndex == theFirstStringLength)
+ {
+ return createEmptyString(executionContext);
+ }
+ else
+ {
+ const XalanDOMString::size_type
theSecondStringLength = length(theSecondString);
+
+ // Find the first character, which will be the
offset of the index of the
+ // beginning of the second string, plus the
length of the second string.
+ const XalanDOMChar* const
theFirstCharacter =
+ toCharArray(theFirstString) + theIndex
+ theSecondStringLength;
+
+ // The remaining length is just the opposite --
the length of the string,
+ // minus the index, minus the length of the
second string.
+ const XalanDOMString::size_type
theSubstringLength =
+ theFirstStringLength - theIndex -
theSecondStringLength;
+
+
XPathExecutionContext::GetAndReleaseCachedString
theResult(executionContext);
+
+ XalanDOMString& theString =
theResult.get();
+
+ assign(
+ theString,
+ theFirstCharacter,
+ theSubstringLength);
- // The remaining length is just the opposite -- the
length of the string,
- // minus the index, minus the length of the second
string.
- const XalanDOMString::size_type
theSubstringLength =
- theFirstStringLength - theIndex -
theSecondStringLength;
-
- XPathExecutionContext::GetAndReleaseCachedString
theResult(executionContext);
-
- XalanDOMString& theString = theResult.get();
-
- assign(
- theString,
- theFirstCharacter,
- theSubstringLength);
-
- return
executionContext.getXObjectFactory().createString(theResult);
+ return
executionContext.getXObjectFactory().createString(theResult);
+ }
}
}
}
1.16 +19 -10 xml-xalan/c/src/XPath/FunctionSubstringBefore.cpp
Index: FunctionSubstringBefore.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionSubstringBefore.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- FunctionSubstringBefore.cpp 3 Jan 2003 21:45:23 -0000 1.15
+++ FunctionSubstringBefore.cpp 21 Feb 2003 19:37:08 -0000 1.16
@@ -111,25 +111,34 @@
{
const XalanDOMString& theSecondString
= arg2->str();
- const XalanDOMString::size_type theIndex =
indexOf(theFirstString,
-
theSecondString);
+ const XalanDOMString::size_type theSecondStringLength =
length(theSecondString);
- if (theIndex == theFirstStringLength)
+ if (theSecondStringLength == 0)
{
return createEmptyString(executionContext);
}
else
{
- XPathExecutionContext::GetAndReleaseCachedString
theResult(executionContext);
+ const XalanDOMString::size_type theIndex =
indexOf(theFirstString,
+
theSecondString);
- XalanDOMString& theString = theResult.get();
+ if (theIndex == theFirstStringLength)
+ {
+ return createEmptyString(executionContext);
+ }
+ else
+ {
+
XPathExecutionContext::GetAndReleaseCachedString
theResult(executionContext);
- theString.assign(
- toCharArray(theFirstString),
- theIndex);
+ XalanDOMString& theString =
theResult.get();
- // Create a string of the appropriate length...
- return
executionContext.getXObjectFactory().createString(theResult);
+ theString.assign(
+ toCharArray(theFirstString),
+ theIndex);
+
+ // Create a string of the appropriate length...
+ return
executionContext.getXObjectFactory().createString(theResult);
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]