]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/string.cpp
Minor GTK fixes for wxGrid.
[wxWidgets.git] / src / common / string.cpp
index b0273c9dda34cbf97f1ba4f19e89f99cdaca4135..3f8cfe19fd3f990a112a267bf773fe46688b2ae9 100644 (file)
@@ -290,11 +290,11 @@ void wxString::InitWith(const wxChar *psz, size_t nPos, size_t nLength)
 {
   Init();
 
-  wxASSERT( nPos <= wxStrlen(psz) );
-
   if ( nLength == wxSTRING_MAXLEN )
     nLength = wxStrlen(psz + nPos);
 
+  wxASSERT_MSG( nPos + nLength <= wxStrlen(psz), _T("index out of bounds") );
+
   STATISTICS_ADD(InitialLength, nLength);
 
   if ( nLength > 0 ) {
@@ -528,6 +528,12 @@ void wxString::UngetWriteBuf()
   GetStringData()->Validate(TRUE);
 }
 
+void wxString::UngetWriteBuf(size_t nLen)
+{
+  GetStringData()->nDataLength = nLen;
+  GetStringData()->Validate(TRUE);
+}
+
 // ---------------------------------------------------------------------------
 // data access
 // ---------------------------------------------------------------------------
@@ -1596,7 +1602,7 @@ size_t wxString::find_first_of(const wxChar* sz, size_t nStart) const
     const wxChar *start = c_str() + nStart;
     const wxChar *firstOf = wxStrpbrk(start, sz);
     if ( firstOf )
-        return firstOf - start;
+        return firstOf - c_str();
     else
         return npos;
 }