]> 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 995433e317372e7b44136aa77909b4df72df61e4..4715f63154ab66df9062db9eb1c4bb892957d3db 100644 (file)
@@ -9,7 +9,7 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
   #pragma implementation "string.h"
 #endif
 
@@ -468,8 +468,6 @@ size_t wxStringBase::find(const wxChar* sz, size_t nStart, size_t n) const
   return find(wxStringBase(sz, n), nStart);
 }
 
-// Gives a duplicate symbol (presumably a case-insensitivity problem)
-#if !defined(__BORLANDC__)
 size_t wxStringBase::find(wxChar ch, size_t nStart) const
 {
   wxASSERT( nStart <= length() );
@@ -478,7 +476,6 @@ size_t wxStringBase::find(wxChar ch, size_t nStart) const
 
   return p == NULL ? npos : p - c_str();
 }
-#endif
 
 size_t wxStringBase::rfind(const wxStringBase& str, size_t nStart) const
 {
@@ -512,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
@@ -539,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();
@@ -1963,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)
 {