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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user