From 78d5e4dfbb4e39d90910d88eae8404287fa2d078 Mon Sep 17 00:00:00 2001 From: Stelios Bounanos Date: Fri, 27 Nov 2009 11:21:29 +0000 Subject: [PATCH] Disable win32 snprintf workaround This is not needed with gcc 4.x. --- m4/np-compat.m4 | 6 ------ src/compat/mingw.c | 2 ++ src/include/compat.h | 6 ++++++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/m4/np-compat.m4 b/m4/np-compat.m4 index f36cc51a..bd16c640 100644 --- a/m4/np-compat.m4 +++ b/m4/np-compat.m4 @@ -4,12 +4,6 @@ AC_DEFUN([AC_FLDIGI_NP_COMPAT], [ AM_CONDITIONAL([COMPAT_REGEX], [test "x$ac_cv_header_regex_h" != "xyes"]) - if test "x$target_mingw32" = "xyes"; then - AC_DEFINE([SNPRINTF_RETURNS_BOGUS], 1, [Defined if snprintf returns -1 when out of buffer space]) - else - AC_DEFINE([SNPRINTF_RETURNS_BOGUS], 0, [Defined if snprintf returns -1 when out of buffer space]) - fi - if test "x$target_mingw32" = "xyes"; then sem_libs="pthreadGC2" else diff --git a/src/compat/mingw.c b/src/compat/mingw.c index 4adfe63c..7c7dc147 100644 --- a/src/compat/mingw.c +++ b/src/compat/mingw.c @@ -36,6 +36,7 @@ unsigned int _CRT_fmode = _O_BINARY; /******************************************************************************/ +#if SNPRINTF_RETURNS_BOGUS /* * The size parameter specifies the available space, i.e. includes * the trailing NUL byte; but Windows's vsnprintf expects the @@ -88,6 +89,7 @@ int git_snprintf(char *str, size_t maxsize, const char *format, ...) return ret; } +#endif /* SNPRINTF_RETURNS_BOGUS */ unsigned sleep(unsigned seconds) { diff --git a/src/include/compat.h b/src/include/compat.h index a987c0b0..91a04447 100644 --- a/src/include/compat.h +++ b/src/include/compat.h @@ -37,6 +37,12 @@ extern "C" { #endif +#if defined(__WOE32__) && (!defined(__GNUC__) || __GNUC__ < 4) +# define SNPRINTF_RETURNS_BOGUS 1 +#else +# define SNPRINTF_RETURNS_BOGUS 0 +#endif + #if SNPRINTF_RETURNS_BOGUS #define snprintf git_snprintf extern int git_snprintf(char *str, size_t maxsize,