]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/string.cpp
* Fixed Async -> sync in wxExecute
[wxWidgets.git] / src / common / string.cpp
index 92573c4d4be8059fad1f371f0ee6ddc719ada6fd..2b95e23f128551afd99a87ba9d824463de4cd607 100644 (file)
@@ -153,7 +153,7 @@ wxString::wxString(char ch, size_t nLength)
 
   if ( nLength > 0 ) {
     AllocBuffer(nLength);
-    
+
     wxASSERT( sizeof(char) == 1 );  // can't use memset if not
 
     memset(m_pchData, ch, nLength);
@@ -282,14 +282,14 @@ void wxString::AllocBeforeWrite(size_t nLen)
   wxASSERT( nLen != 0 );  // doesn't make any sense
 
   // must not share string and must have enough space
-  register wxStringData* pData = GetStringData();  
+  register wxStringData* pData = GetStringData();
   if ( pData->IsShared() || (nLen > pData->nAllocLength) ) {
     // can't work with old buffer, get new one
     pData->Unlock();
     AllocBuffer(nLen);
   }
 
-  wxASSERT( !pData->IsShared() );  // we must be the only owner
+  wxASSERT( !GetStringData()->IsShared() );  // we must be the only owner
 }
 
 // get the pointer to writable buffer of (at least) nLen bytes
@@ -569,7 +569,7 @@ wxString wxString::Right(char ch) const
   if ( iPos == NOT_FOUND )
     str = *this;
   else
-    str = c_str() + iPos;
+    str = c_str() + iPos + 1;
 
   return str;
 }
@@ -862,6 +862,30 @@ int wxString::PrintfV(const char* pszFormat, va_list argptr)
   return iLen;
 }
 
+#if 0
+int wxString::Scanf(const char *pszFormat, ...) const
+{
+  va_list argptr;
+  va_start(argptr, pszFormat);
+
+  int iLen = ScanfV(pszFormat, argptr);
+
+  va_end(argptr);
+
+  return iLen;
+}
+
+int wxString::ScanfV(const char *pszFormat, va_list argptr) const
+{
+#ifdef __WINDOWS__
+  wxMessageBox("ScanfV not implemented");
+  return 0;
+#else
+  return vsscanf(c_str(), pszFormat, argptr);
+#endif
+}
+#endif
+
 // ---------------------------------------------------------------------------
 // standard C++ library string functions
 // ---------------------------------------------------------------------------
@@ -872,7 +896,7 @@ wxString& wxString::insert(size_t nPos, const wxString& str)
   wxASSERT( nPos <= Len() );
 
   wxString strTmp;
-  char *pc = strTmp.GetWriteBuf(Len() + str.Len() + 1);
+  char *pc = strTmp.GetWriteBuf(Len() + str.Len());
   strncpy(pc, c_str(), nPos);
   strcpy(pc + nPos, str);
   strcpy(pc + nPos + str.Len(), c_str() + nPos);
@@ -1132,7 +1156,7 @@ void wxArrayString::Alloc(size_t nSize)
 
 // searches the array for an item (forward or backwards)
 
-// Robert Roebling (changed to bool from Bool)
+// Robert Roebling (changed to bool from bool)
 
 int wxArrayString::Index(const char *sz, bool bCase, bool bFromEnd) const
 {
@@ -1169,7 +1193,7 @@ void wxArrayString::Add(const wxString& src)
 // add item at the given position
 void wxArrayString::Insert(const wxString& src, size_t nIndex)
 {
-  wxCHECK( nIndex <= m_nCount );
+  wxCHECK_RET( nIndex <= m_nCount, "bad index in wxArrayString::Insert" );
 
   Grow();
 
@@ -1185,7 +1209,7 @@ void wxArrayString::Insert(const wxString& src, size_t nIndex)
 // removes item from array (by index)
 void wxArrayString::Remove(size_t nIndex)
 {
-  wxCHECK( nIndex <= m_nCount );
+  wxCHECK_RET( nIndex <= m_nCount, "bad index in wxArrayString::Remove" );
 
   // release our lock
   Item(nIndex).GetStringData()->Unlock();
@@ -1200,15 +1224,14 @@ void wxArrayString::Remove(const char *sz)
 {
   int iIndex = Index(sz);
 
-  wxCHECK( iIndex != NOT_FOUND );
+  wxCHECK_RET( iIndex != NOT_FOUND,
+               "removing inexistent element in wxArrayString::Remove" );
 
   Remove((size_t)iIndex);
 }
 
 // sort array elements using passed comparaison function
 
-// Robert Roebling (changed to bool from Bool)
-
 void wxArrayString::Sort(bool bCase, bool bReverse)
 {
   //@@@@ TO DO