X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7448de8d8d697f8f208515a1fc96c88ed009dd56..dc497201eb08e3de1402480e2ab97a6405335ecb:/src/common/string.cpp?ds=sidebyside diff --git a/src/common/string.cpp b/src/common/string.cpp index 9e72b8aa59..5bb461cb17 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -39,10 +39,6 @@ #include #include -#ifndef __WXMSW__ -#include -#endif - #ifdef __SALFORDC__ #include #endif @@ -365,8 +361,8 @@ bool wxStringBase::Alloc(size_t nLen) if ( pData->IsEmpty() ) { nLen += EXTRA_ALLOC; - wxStringData* pData = (wxStringData*) - malloc(sizeof(wxStringData) + (nLen + 1)*sizeof(wxChar)); + pData = (wxStringData *) + malloc(sizeof(wxStringData) + (nLen + 1)*sizeof(wxChar)); if ( pData == NULL ) { // allocation failure handled by caller @@ -1817,7 +1813,7 @@ int wxString::PrintfV(const wxChar* pszFormat, va_list argptr) for ( ;; ) { wxStringBuffer tmp(*this, size + 1); - wxChar* buf = tmp; + wxChar *buf = tmp; if ( !buf ) { @@ -1839,25 +1835,21 @@ int wxString::PrintfV(const wxChar* pszFormat, va_list argptr) // vsnprintf() may return either -1 (traditional Unix behaviour) or the // total number of characters which would have been written if the - // buffer were large enough - if ( len >= 0 && len <= size ) + // buffer were large enough (newer standards such as Unix98) + if ( len < 0 ) { - // ok, there was enough space - break; + // still not enough, as we don't know how much we need, double the + // current size of the buffer + size *= 2; } - -#ifdef EOVERFLOW - // if the error is not due to not having enough space (it could be e.g. - // EILSEQ), break too -- we'd just eat all available memory uselessly - if ( errno != EOVERFLOW ) + else if ( len > size ) + { + size = len; + } + else // ok, there was enough space { - // no sense in continuing break; } -#endif // EOVERFLOW - - // still not enough, double it again - size *= 2; } // we could have overshot @@ -2497,7 +2489,11 @@ void wxArrayString::Sort(CompareFunction compareFunction) END_SORT(); } -typedef int (wxC_CALLING_CONV * wxStringCompareFn)(const void *first, const void *second); +extern "C" +{ + typedef int (wxC_CALLING_CONV * wxStringCompareFn)(const void *first, + const void *second); +} void wxArrayString::Sort(CompareFunction2 compareFunction) {