git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53144
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
size_t uiOldLen = strOld.length();
size_t uiNewLen = strNew.length();
size_t uiOldLen = strOld.length();
size_t uiNewLen = strNew.length();
- size_t dwPos = 0;
-
- while ( (*this)[dwPos] != wxT('\0') )
+ for ( size_t dwPos = 0; dwPos < length(); )
- //DO NOT USE STRSTR HERE
- //this string can contain embedded null characters,
- //so strstr will function incorrectly
dwPos = find(strOld, dwPos);
if ( dwPos == npos )
dwPos = find(strOld, dwPos);
if ( dwPos == npos )
- break; // exit the loop
- else
- {
- //replace this occurance of the old string with the new one
- replace(dwPos, uiOldLen, strNew, uiNewLen);
- //move up pos past the string that was replaced
- dwPos += uiNewLen;
+ // replace this occurance of the old string with the new one
+ replace(dwPos, uiOldLen, strNew, uiNewLen);
- //increase replace count
- ++uiCount;
+ // move up pos past the string that was replaced
+ dwPos += uiNewLen;
- // stop now?
- if ( !bReplaceAll )
- break; // exit the loop
- }
+ // increase replace count
+ ++uiCount;
+
+ // stop after the first one?
+ if ( !bReplaceAll )
+ break;