From f06e307501df7c3af0bdde6298bdcbe263ef2ac1 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 17 Aug 2002 22:17:07 +0000 Subject: [PATCH] Put various #ifdefs vsnprintf() back in, they were lost in today's changes.. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16582 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/wxchar.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/common/wxchar.cpp b/src/common/wxchar.cpp index 2b4a5a90eb..e625460013 100644 --- a/src/common/wxchar.cpp +++ b/src/common/wxchar.cpp @@ -335,6 +335,43 @@ int wxVsprintf( wxChar *str, const wxChar *format, va_list ap ) } #endif +// we want to find out if the current platform supports vsnprintf()-like +// function: for Unix this is done with configure, for Windows we test the +// compiler explicitly. +// +// FIXME currently, this is only for ANSI (!Unicode) strings, so we call this +// function wxVsnprintfA (A for ANSI), should also find one for Unicode +// strings in Unicode build +#ifdef __WXMSW__ + #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 + #endif +#endif // Windows/!Windows + +#ifndef wxVsnprintfA + // in this case we'll use vsprintf() (which is ANSI and thus should be + // always available), but it's unsafe because it doesn't check for buffer + // size - so give a warning + #define wxVsnprintfA(buf, len, format, arg) vsprintf(buf, format, arg) + + #if defined(__VISUALC__) + #pragma message("Using sprintf() because no snprintf()-like function defined") + #elif defined(__GNUG__) + #warning "Using sprintf() because no snprintf()-like function defined" + #endif //compiler +#endif // no vsnprintf + +#if defined(_AIX) + // AIX has vsnprintf, but there's no prototype in the system headers. + extern "C" int vsnprintf(char* str, size_t n, const char* format, va_list ap); +#endif + #if !defined(wxVsnprintf) && !defined(wxHAS_VSNPRINTF) int WXDLLEXPORT wxVsnprintf(wxChar *buf, size_t len, const wxChar *format, va_list argptr)