Fix Q_vsnprintf for mingw-w64

By default mingw-w64 uses Microsoft's broken _vsnprintf() in msvcrt.dll.
It can be overriden by defining __USE_MINGW_ANSI_STDIO but let's just
use the same behavior for both MSVC and mingw-w64.

Reported by @birdstakes.
This commit is contained in:
Zack Middleton 2018-02-04 08:03:51 -06:00
parent ad10e6610c
commit 83119a990a
2 changed files with 8 additions and 5 deletions

View file

@ -746,13 +746,14 @@ qboolean Q_isintegral( float f )
return (int)f == f;
}
#ifdef _MSC_VER
#ifdef _WIN32
/*
=============
Q_vsnprintf
Special wrapper function for Microsoft's broken _vsnprintf() function.
MinGW comes with its own snprintf() which is not broken.
MinGW comes with its own vsnprintf() which is not broken. mingw-w64
however, uses Microsoft's broken _vsnprintf() function.
=============
*/

View file

@ -177,13 +177,15 @@ typedef int intptr_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int8 uint8_t;
#else
#include <stdint.h>
#endif
#ifdef _WIN32
// vsnprintf is ISO/IEC 9899:1999
// abstracting this to make it portable
int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap);
#else
#include <stdint.h>
#define Q_vsnprintf vsnprintf
#endif