X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/79a773ba60af80fece4ddbd346340ef5d4f24a10..ad5c34f309074eefe625b82e1203eec5b91247f5:/src/common/string.cpp?ds=inline diff --git a/src/common/string.cpp b/src/common/string.cpp index 77026933c0..e00c818033 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -106,8 +106,10 @@ extern const char *g_szNul = &g_strEmpty.dummy; // always available), but it's unsafe because it doesn't check for buffer // size - so give a warning #define wxVsprintf(buffer,len,format,argptr) vsprintf(buffer,format, argptr) +#ifndef __SC__ #pragma message("Using sprintf() because no snprintf()-like function defined") #endif +#endif // ---------------------------------------------------------------------------- // global functions @@ -345,6 +347,10 @@ void wxString::AllocBeforeWrite(size_t nLen) pData->Unlock(); AllocBuffer(nLen); } + else { + // update the string length + pData->nDataLength = nLen; + } wxASSERT( !GetStringData()->IsShared() ); // we must be the only owner } @@ -1075,6 +1081,19 @@ bool wxString::Matches(const char *pszMask) const return *pszTxt == '\0'; } +// Count the number of chars +int wxString::Freq(char ch) const +{ + int count = 0; + int len = Len(); + for (int i = 0; i < len; i++) + { + if (GetChar(i) == ch) + count ++; + } + return count; +} + // --------------------------------------------------------------------------- // standard C++ library string functions // --------------------------------------------------------------------------- @@ -1116,6 +1135,8 @@ size_t wxString::find(const char* sz, size_t nStart, size_t n) const } #endif +// Gives a duplicate symbol (presumably a case-insensitivity problem) +#if !defined(__BORLANDC__) size_t wxString::find(char ch, size_t nStart) const { wxASSERT( nStart <= Len() ); @@ -1124,6 +1145,7 @@ size_t wxString::find(char ch, size_t nStart) const return p == NULL ? npos : p - c_str(); } +#endif size_t wxString::rfind(const wxString& str, size_t nStart) const {