Index: generic/nsfError.c =================================================================== diff -u -r880487204ff2da18d2d25ebd727b9b4bbda86c8e -r836e08bf2af69a30dcd2cf6bb2e19f97d798b98a --- generic/nsfError.c (.../nsfError.c) (revision 880487204ff2da18d2d25ebd727b9b4bbda86c8e) +++ generic/nsfError.c (.../nsfError.c) (revision 836e08bf2af69a30dcd2cf6bb2e19f97d798b98a) @@ -68,9 +68,13 @@ * buffer (rather than the number of required bytes as required by C99) and * upon other error conditions. This should not happen for the above size * estimation, however. Also, for MS VC runtimes, we use the vendor-specific - * _vscprintf() + * _vscprintf() + * + * Note: For MinGW and MinGW-w64, we assume that their ANSI-compliant + * version of vsnprintf() is used. See __USE_MINGW_ANSI_STDIO in nsfInt.h */ -#if defined(_WIN32) && defined(_MSC_VER) + +#if defined(_MSC_VER) failure = (result == -1 && errno == ERANGE); #else assert(result > -1); @@ -79,7 +83,7 @@ if (failure) { int addedStringLength; -#if defined(_WIN32) && defined(_MSC_VER) +#if defined(_MSC_VER) /* Compute the required size of the Tcl_DString */ va_copy(vargsCopy, vargs); addedStringLength = _vscprintf(fmt, vargsCopy); Index: generic/nsfInt.h =================================================================== diff -u -r880487204ff2da18d2d25ebd727b9b4bbda86c8e -r836e08bf2af69a30dcd2cf6bb2e19f97d798b98a --- generic/nsfInt.h (.../nsfInt.h) (revision 880487204ff2da18d2d25ebd727b9b4bbda86c8e) +++ generic/nsfInt.h (.../nsfInt.h) (revision 836e08bf2af69a30dcd2cf6bb2e19f97d798b98a) @@ -35,6 +35,21 @@ # define HAVE_UINTPTR_T #endif +/* + * MinGW and MinGW-w64 provide both MSCRT-compliant and ANSI-compliant + * implementations of certain I/O operations (e.g., *printf()). By + * setting __USE_MINGW_ANSI_STDIO to 1 explicitly, we can assume the + * ANSI versions. + * + * Note: It is sufficient to test for __MINGW32__ to trap all MinGW + * tool chains, including 64bit versions. See + * http://sourceforge.net/p/predef/wiki/Compilers/#mingw-and-mingw-w64 + */ + +#if defined(__MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO) +#define __USE_MINGW_ANSI_STDIO 1 +#endif + #include #include "nsf.h" @@ -1057,7 +1072,6 @@ #endif #endif - #if !defined(NDEBUG) /*# define NSF_INLINE*/ #endif