]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/string.cpp
Fixed several bugs in threading code for OS/2. Thread sample now working.
[wxWidgets.git] / src / common / string.cpp
index f02faad0daf1418a207fb04c078812b530b986cd..4715f63154ab66df9062db9eb1c4bb892957d3db 100644 (file)
@@ -9,7 +9,7 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
   #pragma implementation "string.h"
 #endif
 
@@ -509,13 +509,15 @@ size_t wxStringBase::rfind(wxChar ch, size_t nStart) const
         wxASSERT( nStart <= length() );
     }
 
-    const wxChar *p = wxStrrchr(c_str(), ch);
-
-    if ( p == NULL )
-        return npos;
+    const wxChar *actual;
+    for ( actual = c_str() + ( nStart == npos ? length() : nStart + 1 );
+          actual > c_str(); --actual )
+    {
+        if ( *(actual - 1) == ch )
+            return (actual - 1) - c_str();
+    }
 
-    size_t result = p - c_str();
-    return ( result > nStart ) ? npos : result;
+    return npos;
 }
 
 size_t wxStringBase::find_first_of(const wxChar* sz, size_t nStart) const
@@ -536,10 +538,11 @@ size_t wxStringBase::find_last_of(const wxChar* sz, size_t nStart) const
     }
     else
     {
-        wxASSERT( nStart <= length() );
+        wxASSERT_MSG( nStart <= length(),
+                        _T("invalid index in find_last_of()") );
     }
 
-    for ( const wxChar *p = c_str() + length() - 1; p >= c_str(); p-- )
+    for ( const wxChar *p = c_str() + nStart - 1; p >= c_str(); p-- )
     {
         if ( wxStrchr(sz, *p) )
             return p - c_str();
@@ -1960,6 +1963,11 @@ wxArrayString::~wxArrayString()
   wxDELETEA(m_pItems);
 }
 
+void wxArrayString::reserve(size_t nSize)
+{
+    Alloc(nSize);
+}
+
 // pre-allocates memory (frees the previous data!)
 void wxArrayString::Alloc(size_t nSize)
 {