From 0ddadad7333a999ab3289fd6d47433e4984d182e Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Fri, 29 May 2015 20:47:36 +0200 Subject: Cope with broken snprintf on Windows On Windows, snprintf returns -1 if the output was truncated. Fall back to Windows-specific _scprintf. --- src/buffer.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/buffer.c') diff --git a/src/buffer.c b/src/buffer.c index 5ec8b49..2b7f062 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -175,6 +175,12 @@ int cmark_strbuf_vprintf(cmark_strbuf *buf, const char *format, va_list ap) buf->asize - buf->size, format, args ); +#ifndef HAVE_C99_SNPRINTF + // Assume we're on Windows. + if (len < 0) { + len = _vscprintf(format, args); + } +#endif va_end(args); -- cgit v1.2.3