]> git.saurik.com Git - wxWidgets.git/commitdiff
Code symetry for both directions of trimming towards fixing bug #1472688.
authorWłodzimierz Skiba <abx@abx.art.pl>
Wed, 14 Jun 2006 16:42:35 +0000 (16:42 +0000)
committerWłodzimierz Skiba <abx@abx.art.pl>
Wed, 14 Jun 2006 16:42:35 +0000 (16:42 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39723 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/string.cpp

index 53a6e680fb176240036ca9a45273582667a50891..0a70d793a89f21d1b72ddfb95e5ec7b686dd2ce7 100644 (file)
@@ -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