X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dbbd41ae33856d6c9dfe6c2bf19151b1ac0a18eb..c27bcbd5a7cec9f03b15c69824da99c5bb75924a:/src/common/string.cpp?ds=sidebyside diff --git a/src/common/string.cpp b/src/common/string.cpp index c95d6729e8..38351ff5f0 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -1796,46 +1796,43 @@ wxString wxString::FormatV(const wxChar *pszFormat, va_list argptr) int wxString::Printf(const wxChar *pszFormat, ...) { - va_list argptr; - va_start(argptr, pszFormat); + va_list argptr; + va_start(argptr, pszFormat); - int iLen = PrintfV(pszFormat, argptr); + int iLen = PrintfV(pszFormat, argptr); - va_end(argptr); + va_end(argptr); - return iLen; + return iLen; } int wxString::PrintfV(const wxChar* pszFormat, va_list argptr) { int size = 1024; - int len; for ( ;; ) { - { - wxStringBuffer tmp(*this, size + 1); - wxChar* buf = tmp; + wxStringBuffer tmp(*this, size + 1); + wxChar* buf = tmp; - if ( !buf ) - { - // out of memory - return -1; - } - - // wxVsnprintf() may modify the original arg pointer, so pass it - // only a copy - va_list argptrcopy; - wxVaCopy(argptrcopy, argptr); - len = wxVsnprintf(buf, size, pszFormat, argptrcopy); - va_end(argptrcopy); - - // some implementations of vsnprintf() don't NUL terminate - // the string if there is not enough space for it so - // always do it manually - buf[size] = _T('\0'); + if ( !buf ) + { + // out of memory + return -1; } + // wxVsnprintf() may modify the original arg pointer, so pass it + // only a copy + va_list argptrcopy; + wxVaCopy(argptrcopy, argptr); + int len = wxVsnprintf(buf, size, pszFormat, argptrcopy); + va_end(argptrcopy); + + // some implementations of vsnprintf() don't NUL terminate + // the string if there is not enough space for it so + // always do it manually + buf[size] = _T('\0'); + // 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