use _snprintf() in system_sprintf() for the compilers which have it; really fix warning about unused maxlen in wxPrintfConvSpec::ReplaceAsteriskWith()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41430 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -196,7 +196,6 @@ bool WXDLLEXPORT wxOKlibc()
|
|||||||
// implemented later in this file using wxVsnprintf() and that would
|
// implemented later in this file using wxVsnprintf() and that would
|
||||||
// result in an endless recursion and thus in a stack overflow
|
// result in an endless recursion and thus in a stack overflow
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
|
|
||||||
#if defined(__WINDOWS__)
|
#if defined(__WINDOWS__)
|
||||||
// all compilers under Windows should have swprintf()
|
// all compilers under Windows should have swprintf()
|
||||||
#define HAVE_SWPRINTF
|
#define HAVE_SWPRINTF
|
||||||
@@ -213,17 +212,16 @@ bool WXDLLEXPORT wxOKlibc()
|
|||||||
#define HAVE_BROKEN_SWPRINTF_DECL
|
#define HAVE_BROKEN_SWPRINTF_DECL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// problem: on some systems swprintf takes the 'max' argument while on
|
||||||
// problem: on some systems swprintf takes the 'max' argument while on others
|
// others it doesn't
|
||||||
// it doesn't
|
|
||||||
#if defined(HAVE_BROKEN_SWPRINTF_DECL)
|
#if defined(HAVE_BROKEN_SWPRINTF_DECL)
|
||||||
|
// like when using sprintf(), since 'max' is not used, wxVsnprintf()
|
||||||
// like when using sprintf(), since 'max' is not used, wxVsnprintf() should
|
// should always ensure that 'buff' is big enough for all common needs
|
||||||
// always ensure that 'buff' is big enough for all common needs
|
|
||||||
#define system_sprintf(buff, max, flags, data) \
|
#define system_sprintf(buff, max, flags, data) \
|
||||||
::swprintf(buff, flags, data)
|
::swprintf(buff, flags, data)
|
||||||
#else
|
|
||||||
|
|
||||||
|
#define SYSTEM_SPRINTF_IS_UNSAFE
|
||||||
|
#else
|
||||||
#if !defined(HAVE_SWPRINTF)
|
#if !defined(HAVE_SWPRINTF)
|
||||||
#error wxVsnprintf() needs a system swprintf() implementation!
|
#error wxVsnprintf() needs a system swprintf() implementation!
|
||||||
#endif
|
#endif
|
||||||
@@ -231,24 +229,24 @@ bool WXDLLEXPORT wxOKlibc()
|
|||||||
#define system_sprintf(buff, max, flags, data) \
|
#define system_sprintf(buff, max, flags, data) \
|
||||||
::swprintf(buff, max, flags, data)
|
::swprintf(buff, max, flags, data)
|
||||||
#endif
|
#endif
|
||||||
|
#else // !wxUSE_UNICODE
|
||||||
#else
|
#if defined(__VISUALC__) || \
|
||||||
|
(defined(__BORLANDC__) && __BORLANDC__ >= 0x540)
|
||||||
#if defined(HAVE_SNPRINTF)
|
#define system_sprintf(buff, max, flags, data) \
|
||||||
|
::_snprintf(buff, max, flags, data)
|
||||||
|
#elif defined(HAVE_SNPRINTF)
|
||||||
#define system_sprintf(buff, max, flags, data) \
|
#define system_sprintf(buff, max, flags, data) \
|
||||||
::snprintf(buff, max, flags, data)
|
::snprintf(buff, max, flags, data)
|
||||||
|
#else // NB: at least sprintf() should always be available
|
||||||
#else // NB: at least sprintf() should *always* be available
|
// since 'max' is not used in this case, wxVsnprintf() should always
|
||||||
|
// ensure that 'buff' is big enough for all common needs
|
||||||
// since 'max' is not used in this case, wxVsnprintf() should always ensure
|
|
||||||
// that 'buff' is big enough for all common needs
|
|
||||||
// (see wxMAX_SVNPRINTF_FLAGBUFFER_LEN and wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN)
|
// (see wxMAX_SVNPRINTF_FLAGBUFFER_LEN and wxMAX_SVNPRINTF_SCRATCHBUFFER_LEN)
|
||||||
#define system_sprintf(buff, max, flags, data) \
|
#define system_sprintf(buff, max, flags, data) \
|
||||||
::sprintf(buff, flags, data)
|
::sprintf(buff, flags, data)
|
||||||
|
|
||||||
|
#define SYSTEM_SPRINTF_IS_UNSAFE
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -678,12 +676,11 @@ void wxPrintfConvSpec::ReplaceAsteriskWith(int width)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// replace * with the actual integer given as width
|
// replace * with the actual integer given as width
|
||||||
int maxlen = (m_szFlags + wxMAX_SVNPRINTF_FLAGBUFFER_LEN - pwidth) / sizeof(wxChar);
|
#ifndef SYSTEM_SPRINTF_IS_UNSAFE
|
||||||
int offset = system_sprintf(pwidth, maxlen, wxT("%d"), abs(width));
|
int maxlen = (m_szFlags + wxMAX_SVNPRINTF_FLAGBUFFER_LEN - pwidth) /
|
||||||
|
sizeof(wxChar);
|
||||||
#ifdef HAVE_BROKEN_SWPRINTF_DECL
|
|
||||||
wxUnusedVar(maxlen); // avoid dummy warnings
|
|
||||||
#endif
|
#endif
|
||||||
|
int offset = system_sprintf(pwidth, maxlen, wxT("%d"), abs(width));
|
||||||
|
|
||||||
// restore after the expanded * what was following it
|
// restore after the expanded * what was following it
|
||||||
wxStrcpy(pwidth+offset, temp);
|
wxStrcpy(pwidth+offset, temp);
|
||||||
|
Reference in New Issue
Block a user