don't stop on NULs in Replace()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53144 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1239,18 +1239,12 @@ size_t wxString::Replace(const wxString& strOld,
|
|||||||
size_t uiOldLen = strOld.length();
|
size_t uiOldLen = strOld.length();
|
||||||
size_t uiNewLen = strNew.length();
|
size_t uiNewLen = strNew.length();
|
||||||
|
|
||||||
size_t dwPos = 0;
|
for ( size_t dwPos = 0; dwPos < length(); )
|
||||||
|
|
||||||
while ( (*this)[dwPos] != wxT('\0') )
|
|
||||||
{
|
{
|
||||||
//DO NOT USE STRSTR HERE
|
|
||||||
//this string can contain embedded null characters,
|
|
||||||
//so strstr will function incorrectly
|
|
||||||
dwPos = find(strOld, dwPos);
|
dwPos = find(strOld, dwPos);
|
||||||
if ( dwPos == npos )
|
if ( dwPos == npos )
|
||||||
break; // exit the loop
|
break;
|
||||||
else
|
|
||||||
{
|
|
||||||
// replace this occurance of the old string with the new one
|
// replace this occurance of the old string with the new one
|
||||||
replace(dwPos, uiOldLen, strNew, uiNewLen);
|
replace(dwPos, uiOldLen, strNew, uiNewLen);
|
||||||
|
|
||||||
@@ -1260,10 +1254,9 @@ size_t wxString::Replace(const wxString& strOld,
|
|||||||
// increase replace count
|
// increase replace count
|
||||||
++uiCount;
|
++uiCount;
|
||||||
|
|
||||||
// stop now?
|
// stop after the first one?
|
||||||
if ( !bReplaceAll )
|
if ( !bReplaceAll )
|
||||||
break; // exit the loop
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return uiCount;
|
return uiCount;
|
||||||
|
Reference in New Issue
Block a user