X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/17a1ebd101f0653e69736416a2a28d0ada423141..dc497201eb08e3de1402480e2ab97a6405335ecb:/src/common/string.cpp diff --git a/src/common/string.cpp b/src/common/string.cpp index 12c4204759..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 @@ -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