wxString::replace() assert fixed, test for it added

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7164 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-04-14 18:08:35 +00:00
parent 27df708603
commit f568f52dd8
2 changed files with 52 additions and 5 deletions

View File

@@ -1717,13 +1717,15 @@ wxString& wxString::erase(size_t nStart, size_t nLen)
wxString& wxString::replace(size_t nStart, size_t nLen, const wxChar *sz)
{
wxASSERT( nStart + nLen <= wxStrlen(sz) );
wxASSERT_MSG( nStart + nLen <= Len(),
_T("index out of bounds in wxString::replace") );
wxString strTmp;
strTmp.Alloc(Len()); // micro optimisation to avoid multiple mem allocs
if ( nStart != 0 )
strTmp.append(c_str(), nStart);
strTmp += sz;
strTmp.append(c_str() + nStart + nLen);
strTmp << sz << c_str() + nStart + nLen;
*this = strTmp;
return *this;