]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/string.cpp
avoid using deprecated gdk_image_new_bitmap()
[wxWidgets.git] / src / common / string.cpp
index 53a6e680fb176240036ca9a45273582667a50891..99bb5a55a3514be94355fb29391f001ebd5c13db 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 ( (psz != rend()) && wxSafeIsspace(*psz) )
+                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 ( (psz != end()) && wxSafeIsspace(*psz) )
                 psz++;
 
             // fix up data and length