X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5f1d3069010e74475d6b5887a59e242d452f4f2a..505f70dec68ba08ade903e8e9e0eb41ebd36531c:/src/common/wxchar.cpp diff --git a/src/common/wxchar.cpp b/src/common/wxchar.cpp index 2b4a5a90eb..2f030b8ed9 100644 --- a/src/common/wxchar.cpp +++ b/src/common/wxchar.cpp @@ -40,8 +40,6 @@ #include "wx/hash.h" #endif -#include "wx/msgdlg.h" - #if defined(__WIN32__) && defined(wxNEED_WX_CTYPE_H) #include #include @@ -335,6 +333,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)