From 78e6050be8686ba15a6969aedf434a18f59cc6ee Mon Sep 17 00:00:00 2001 From: Mattia Barbon Date: Thu, 4 Sep 2003 21:59:48 +0000 Subject: [PATCH] Fix and testcase for wxString::rfind bug I introduced. Patch by Robert Vazan. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23386 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/console/console.cpp | 2 ++ src/common/string.cpp | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/samples/console/console.cpp b/samples/console/console.cpp index 4f7d0d4519..5cf447428d 100644 --- a/samples/console/console.cpp +++ b/samples/console/console.cpp @@ -6807,6 +6807,7 @@ void TestStdString() // 01234567890123456789012345 s1 = _T("abcdefgABCDEFGabcABCabcABC"); s2 = _T("gAB"); + s3 = _T("ab"); is_nom( s1.rfind(_T('A')), 23u ); is_nom( s1.rfind(_T('A'), 7), 7u ); @@ -6823,6 +6824,7 @@ void TestStdString() is_nom( s1.rfind(s2), 6u ); is_nom( s1.rfind(s2, 5), wxString::npos ); is_nom( s1.rfind(s2, 6), 6u ); + is_nom( s1.rfind(s3, 1), 0u ); // resize s1 = s2 = s3 = s4 = _T("abcABCdefDEF"); diff --git a/src/common/string.cpp b/src/common/string.cpp index 76a89a88a3..8415f0c3f3 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -504,8 +504,7 @@ size_t wxStringBase::rfind(const wxStringBase& str, size_t nStart) const { return cursor - c_str(); } - --cursor; - } while ( cursor > c_str() ); + } while ( cursor-- > c_str() ); } return npos; -- 2.45.2