DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25693>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25693 unexpected behaviour of XalanDOMString::erase(index, num) with default values Summary: unexpected behaviour of XalanDOMString::erase(index, num) with default values Product: XalanC Version: 1.6 Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: XalanC AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] basic_string &erase( size_type index = 0, size_type num = npos ); The parameters index and num have default values, which means that erase() can be called with just index to erase all characters after index. if the num parameter is omitted, XalanDOMString::erase(index) behaves as if called with XalanDOMString::erase(index, length()), like stl string i think the expected behaviour is XalanDOMString::erase(index, length()-index) instead. #include <xalanc/Include/PlatformDefinitions.hpp> #include <xercesc/util/PlatformUtils.hpp> #include <xalanc/XalanDOM/XalanDOMString.hpp> #include <xalanc/XalanTransformer/XalanTransformer.hpp> #include <xalanc/PlatformSupport/DOMStringHelper.hpp> #include <iostream> #include <string> template<class myStr> void erase(myStr& theString, const unsigned int pos) { std::cout << "before erase: " << theString << std::endl; theString.erase(pos); // expected behavior: erase(pos, theString.length () - pos); std::cout << "after erase: " << theString << std::endl; } int main() { XALAN_USING_XERCES(XMLPlatformUtils) XALAN_USING_XALAN(XalanTransformer) XMLPlatformUtils::Initialize(); XalanTransformer::initialize(); XALAN_USING_XALAN(XalanDOMString) std::string theString("1234567890"); XalanDOMString theXalanString(theString.c_str()); const unsigned int pos(5); erase(theString, pos); erase(theXalanString, pos); XalanTransformer::terminate(); XMLPlatformUtils::Terminate(); }
