From 8c264b23adf380bf9262b96dd8df3ed78fda74cd Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 10 Dec 1999 16:29:34 +0000 Subject: [PATCH 1/1] wxString::substr() bug fixed git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4892 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/string.h | 3 ++- src/common/string.cpp | 11 ----------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/include/wx/string.h b/include/wx/string.h index 29be6c6770..a47ca920c5 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -859,7 +859,8 @@ public: const wxChar* sz, size_t nCount = npos) const; // substring extraction - wxString substr(size_t nStart = 0, size_t nLen = npos) const; + wxString substr(size_t nStart = 0, size_t nLen = npos) const + { return Mid(nStart, nLen); } #endif // wxSTD_STRING_COMPATIBILITY }; diff --git a/src/common/string.cpp b/src/common/string.cpp index fe8480cd45..ed777353a7 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -1643,17 +1643,6 @@ size_t wxString::find_last_not_of(wxChar ch, size_t nStart) const return npos; } -wxString wxString::substr(size_t nStart, size_t nLen) const -{ - // npos means 'take all' - if ( nLen == npos ) - nLen = 0; - - wxASSERT( nStart + nLen <= Len() ); - - return wxString(c_str() + nStart, nLen == npos ? 0 : nLen); -} - wxString& wxString::erase(size_t nStart, size_t nLen) { wxString strTmp(c_str(), nStart); -- 2.45.2