From c124c9679255ad759d3441c5fd946a249fd39be3 Mon Sep 17 00:00:00 2001 From: Frank Li Date: Sun, 16 Aug 2009 13:53:30 +0800 Subject: [PATCH] Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++ The Microsoft C runtime's vsnprintf function does not add NUL at the end of the buffer. Further, Microsoft deprecated vsnprintf in favor of _vsnprintf, so add a #define to that end. Signed-off-by: Frank Li Signed-off-by: Johannes Schindelin --- compat/snprintf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compat/snprintf.c b/compat/snprintf.c index e1e0e7543d..28b02c6837 100644 --- a/compat/snprintf.c +++ b/compat/snprintf.c @@ -9,7 +9,7 @@ * always have room for a trailing NUL byte. */ #ifndef SNPRINTF_SIZE_CORR -#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4) +#if defined(WIN32) && defined(__GNUC__) && __GNUC__ < 4 || defined(_MSC_VER) #define SNPRINTF_SIZE_CORR 1 #else #define SNPRINTF_SIZE_CORR 0 @@ -17,6 +17,11 @@ #endif #undef vsnprintf + +#if defined(_MSC_VER) +#define vsnprintf _vsnprintf +#endif + int git_vsnprintf(char *str, size_t maxsize, const char *format, va_list ap) { char *s;