X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3458e408ba53337baf1b0a56f3eff51a9b32c193..df1496e3eb11e87e15a29fd04c068cd6cd3b607e:/src/common/string.cpp diff --git a/src/common/string.cpp b/src/common/string.cpp index 53a6e680fb..0a70d793a8 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -1617,19 +1617,18 @@ wxString& wxString::Trim(bool bFromRight) if ( bFromRight ) { // find last non-space character - iterator psz = begin() + length() - 1; - while ( wxSafeIsspace(*psz) && (psz >= begin()) ) - psz--; - + reverse_iterator psz = rbegin(); + while ( wxSafeIsspace(*psz) && (psz != rend()) ) + psz++; + // truncate at trailing space start - *++psz = wxT('\0'); - erase(psz, end()); + erase(psz.base(), end()); } else { // find first non-space character iterator psz = begin(); - while ( wxSafeIsspace(*psz) ) + while ( wxSafeIsspace(*psz) && (psz != end()) ) psz++; // fix up data and length