X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c8cfb486fbb0b901295ab19c4e0b31bc6526f7a3..7798a18ec81d3733082bc60a958fac1d4510faca:/src/common/string.cpp diff --git a/src/common/string.cpp b/src/common/string.cpp index 10e64bad12..2b95e23f12 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -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 @@ -837,7 +837,7 @@ int wxString::Find(const char *pszSub) const } // --------------------------------------------------------------------------- -// formatted input/output +// formatted output // --------------------------------------------------------------------------- int wxString::Printf(const char *pszFormat, ...) { @@ -853,7 +853,7 @@ int wxString::Printf(const char *pszFormat, ...) int wxString::PrintfV(const char* pszFormat, va_list argptr) { - static char s_szScratch[1024]; // @@@@ shouldn't use fixed-size buffer! + static char s_szScratch[1024]; int iLen = vsprintf(s_szScratch, pszFormat, argptr); AllocBeforeWrite(iLen); @@ -862,6 +862,7 @@ int wxString::PrintfV(const char* pszFormat, va_list argptr) return iLen; } +#if 0 int wxString::Scanf(const char *pszFormat, ...) const { va_list argptr; @@ -876,8 +877,14 @@ int wxString::Scanf(const char *pszFormat, ...) const 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 @@ -889,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); @@ -1149,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 { @@ -1186,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(); @@ -1202,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(); @@ -1217,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