X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fb20fa43a07ce52feb43a4b26514fc7a6a11a6f5..d43088ee78dca3fc64f9d419b184844eb72384da:/src/common/string.cpp diff --git a/src/common/string.cpp b/src/common/string.cpp index f8d1fc4594..4fd4c02a14 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -116,6 +116,8 @@ extern const wxChar WXDLLEXPORT *wxEmptyString = &g_strEmpty.dummy; #if defined(__VISUALC__) || (defined(__MINGW32__) && wxUSE_NORLANDER_HEADERS) #define wxVsnprintfA _vsnprintf #endif +#elif defined(__WXMAC__) + #define wxVsnprintfA vsnprintf #else // !Windows #ifdef HAVE_VSNPRINTF #define wxVsnprintfA vsnprintf @@ -130,9 +132,7 @@ extern const wxChar WXDLLEXPORT *wxEmptyString = &g_strEmpty.dummy; #if defined(__VISUALC__) #pragma message("Using sprintf() because no snprintf()-like function defined") - #elif defined(__GNUG__) && !defined(__UNIX__) - #warning "Using sprintf() because no snprintf()-like function defined" - #elif defined(__MWERKS__) + #elif defined(__GNUG__) #warning "Using sprintf() because no snprintf()-like function defined" #endif //compiler #endif // no vsnprintf @@ -986,14 +986,22 @@ wxString& wxString::MakeLower() // trimming and padding // --------------------------------------------------------------------------- +// some compilers (VC++ 6.0 not to name them) return TRUE for a call to +// isspace('ê') in the C locale which seems to be broken to me, but we have to +// live with this by checking that the character is a 7 bit one - even if this +// may fail to detect some spaces (I don't know if Unicode doesn't have +// space-like symbols somewhere except in the first 128 chars), it is arguably +// still better than trimming away accented letters +inline int wxSafeIsspace(wxChar ch) { return (ch < 127) && wxIsspace(ch); } + // trims spaces (in the sense of isspace) from left or right side wxString& wxString::Trim(bool bFromRight) { // first check if we're going to modify the string at all if ( !IsEmpty() && ( - (bFromRight && wxIsspace(GetChar(Len() - 1))) || - (!bFromRight && wxIsspace(GetChar(0u))) + (bFromRight && wxSafeIsspace(GetChar(Len() - 1))) || + (!bFromRight && wxSafeIsspace(GetChar(0u))) ) ) { @@ -1004,7 +1012,7 @@ wxString& wxString::Trim(bool bFromRight) { // find last non-space character wxChar *psz = m_pchData + GetStringData()->nDataLength - 1; - while ( wxIsspace(*psz) && (psz >= m_pchData) ) + while ( wxSafeIsspace(*psz) && (psz >= m_pchData) ) psz--; // truncate at trailing space start @@ -1015,7 +1023,7 @@ wxString& wxString::Trim(bool bFromRight) { // find first non-space character const wxChar *psz = m_pchData; - while ( wxIsspace(*psz) ) + while ( wxSafeIsspace(*psz) ) psz++; // fix up data and length @@ -1402,7 +1410,7 @@ int wxString::PrintfV(const wxChar* pszFormat, va_list argptr) // NB: wxVsnprintf() may return either less than the buffer size or -1 if // there is not enough place depending on implementation - int iLen = wxVsnprintfA(szScratch, WXSIZEOF(szScratch), pszFormat, argptr); + int iLen = wxVsnprintfA(szScratch, WXSIZEOF(szScratch), (char *)pszFormat, argptr); if ( iLen != -1 ) { // the whole string is in szScratch *this = szScratch;