fix wxString::Replace when new strings are longer than old string
authorRyan Norton <wxprojects@comcast.net>
Mon, 11 Apr 2005 09:05:40 +0000 (09:05 +0000)
committerRyan Norton <wxprojects@comcast.net>
Mon, 11 Apr 2005 09:05:40 +0000 (09:05 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33494 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/string.cpp
tests/strings/strings.cpp

index 2d608d1eb8dae9a661e47e821148c52f963a61be..bd9857e5cce92f2e26ba32f28ec5172e9d6e8c54 100644 (file)
@@ -1551,8 +1551,8 @@ size_t wxString::Replace(const wxChar *szOld,
             //replace this occurance of the old string with the new one
             replace(dwPos, uiOldLen, szNew, uiNewLen);
 
-            //move up pos past the old string
-            dwPos += uiOldLen;
+            //move up pos past the string that was replaced
+            dwPos += uiNewLen;
 
             //increase replace count
             ++uiCount;
index 3ff5fde7ece59e9b9cdf1e692bc785a82fa4a93a..652dc86eb799a99eef9fea5b13ff0f994998257a 100644 (file)
@@ -476,8 +476,8 @@ void StringTestCase::Replace()
             CPPUNIT_ASSERT( s == wxString(r,rlen) ); \
         }
     
-    TEST_WXREPLACE( _T("null\0char"), 9, _T("c"), _T("d"), true,
-                          _T("null\0dhar"), 9 );   
+    TEST_WXREPLACE( _T("null\0char"), 9, _T("c"), _T("de"), true,
+                          _T("null\0dehar"), 10 );   
 
     #undef TEST_WXREPLACE
     #undef TEST_NULLCHARREPLACE