diff options
author | Nick Wellnhofer <[email protected]> | 2015-05-29 20:47:36 +0200 |
---|---|---|
committer | Nick Wellnhofer <[email protected]> | 2015-05-29 21:42:46 +0200 |
commit | 0ddadad7333a999ab3289fd6d47433e4984d182e (patch) | |
tree | fc7f9c49a365d713d7a972ce4de4041e7641bb55 /src/buffer.c | |
parent | b4599a48694b78a5db144f17c2ab281a6d9f17d1 (diff) |
Cope with broken snprintf on Windows
On Windows, snprintf returns -1 if the output was truncated. Fall back to
Windows-specific _scprintf.
Diffstat (limited to 'src/buffer.c')
-rw-r--r-- | src/buffer.c | 6 |
1 files changed, 6 insertions, 0 deletions
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); |