X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6244848856584171db8cd74a7ff227250e46cc54..6c905cb7fdc856317f1e1db9c6d6aaa93c67920c:/src/common/string.cpp diff --git a/src/common/string.cpp b/src/common/string.cpp index dcd371e0d2..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 // ---------------------------------------------------------------------------