1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2025-08-05 23:35:48 +03:00

Fix vsnprintf in Python bindings on Windows

- Fix vsnprintf on older MSVC versions
- Stop using _vsnprintf on MinGW
This commit is contained in:
Nick Wellnhofer
2019-01-30 14:56:54 +01:00
parent 1ffe17a071
commit d5d511f0b7

View File

@@ -23,8 +23,29 @@
#include <stdio.h> #include <stdio.h>
#include <stddef.h> #include <stddef.h>
#if (defined(_MSC_VER) || defined(__MINGW32__)) && !defined(vsnprintf) #ifdef _MSC_VER
#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
/* snprintf emulation taken from http://stackoverflow.com/a/8712996/1956010 */
#if _MSC_VER < 1900
#include <stdarg.h>
#define vsnprintf c99_vsnprintf
__inline int c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)
{
int count = -1;
if (size != 0)
count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
if (count == -1)
count = _vscprintf(format, ap);
return count;
}
#endif /* _MSC_VER < 1900 */
#elif defined(XSLT_NEED_TRIO) #elif defined(XSLT_NEED_TRIO)
#include "trio.h" #include "trio.h"
#define vsnprintf trio_vsnprintf #define vsnprintf trio_vsnprintf