X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=compat%2Fsnprintf.c;h=e1e0e7543d9414726122c121b7909bf73809a81a;hb=0adc030615fbec4ca20b5fe0b61ed118e82122dc;hp=6c0fb056a571b30627e404d7f164de31ed1a8699;hpb=7d1b50981277c59a788298751f121567a1e75202;p=git.git diff --git a/compat/snprintf.c b/compat/snprintf.c index 6c0fb056a..e1e0e7543 100644 --- a/compat/snprintf.c +++ b/compat/snprintf.c @@ -2,11 +2,14 @@ /* * The size parameter specifies the available space, i.e. includes - * the trailing NUL byte; but Windows's vsnprintf expects the - * number of characters to write without the trailing NUL. + * the trailing NUL byte; but Windows's vsnprintf uses the entire + * buffer and avoids the trailing NUL, should the buffer be exactly + * big enough for the result. Defining SNPRINTF_SIZE_CORR to 1 will + * therefore remove 1 byte from the reported buffer size, so we + * always have room for a trailing NUL byte. */ #ifndef SNPRINTF_SIZE_CORR -#if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ < 4 +#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4) #define SNPRINTF_SIZE_CORR 1 #else #define SNPRINTF_SIZE_CORR 0