XalanC
  1. XalanC
  2. XALANC-357

unexpected behaviour of XalanDOMString::erase(index, num) with default values

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: 1.6
    • Fix Version/s: None
    • Component/s: XalanC
    • Labels:
      None
    • Environment:
      Operating System: Other
      Platform: Other

      Description

      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();
      }

        Activity

        Hide
        David Bertoni added a comment -

        Fix is in CVS. Can you please verify? Thanks!

        Show
        David Bertoni added a comment - Fix is in CVS. Can you please verify? Thanks!

          People

          • Assignee:
            Unassigned
            Reporter:
            Tobias Schuette
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development