Win32: Use _vsprintf_p instead of v(a)s(n)printf (#1892)

This makes it possible to use positional parameters in format strings on
all platforms.
alut-include-path
Nicolas Hake 2017-02-19 11:37:04 +01:00
parent 45676eaa8b
commit 168824a603
5 changed files with 4 additions and 17 deletions

View File

@ -194,7 +194,6 @@ REQUIRE_CXX_SOURCE_COMPILES("template<class... T> class C; int main() { return 0
# time, so the test below works.
REQUIRE_CXX_SOURCE_COMPILES("#include <regex>\nint main() { std::cregex_iterator ri; }" HAVE_WORKING_REGEX " If you are using gcc, please update to gcc 4.9.")
check_cxx_symbol_exists(vasprintf stdio.h HAVE_VASPRINTF)
check_cxx_symbol_exists(__mingw_vasprintf stdio.h HAVE___MINGW_VASPRINTF)
############################################################################
# Check for required system headers

View File

@ -74,9 +74,6 @@
/* Define to 1 if you have the `vasprintf' function. */
#cmakedefine HAVE_VASPRINTF 1
/* Define to 1 if you have the `__mingw_vasprintf' function. */
#cmakedefine HAVE___MINGW_VASPRINTF 1
/* Define to 1 if you have the <X11/extensions/Xrandr.h> header file. */
#cmakedefine HAVE_X11_EXTENSIONS_XRANDR_H 1

View File

@ -155,6 +155,10 @@ bool SWildcardMatchEx(const char *szString, const char *szWildcard);
#include <cstdio>
#include <cstdarg>
#ifdef _WIN32
#define vsnprintf _vsprintf_p
#endif
// old, insecure sprintf
inline int osprintf(char *str, const char *fmt, ...) GNUC_FORMAT_ATTRIBUTE_O;
inline int osprintf(char *str, const char *fmt, ...)

View File

@ -24,7 +24,6 @@
#ifdef _WIN32
#include <io.h>
#include "platform/C4windowswrapper.h"
#define vsnprintf _vsprintf_p
#else
#define O_BINARY 0
#define O_SEQUENTIAL 0
@ -35,14 +34,6 @@
#include <fcntl.h>
#include <sys/stat.h>
#if !defined(HAVE_VASPRINTF) && defined(HAVE___MINGW_VASPRINTF)
// MinGW declares a vasprintf-compatible function as __mingw_vasprintf.
// Rename it for our use.
#define vasprintf __mingw_vasprintf
#define HAVE_VASPRINTF
#endif
// *** StdBuf
bool StdBuf::LoadFromFile(const char *szFile)

View File

@ -29,10 +29,6 @@
#define C4AUL_SafeInherited "_inherited"
#define C4AUL_DebugBreak "__debugbreak"
#ifdef _MSC_VER
#define vsnprintf _vsprintf_p
#endif
static std::string vstrprintf(const char *format, va_list args)
{
va_list argcopy;