From 257cf09472ce5f4a51bf39808e119717fa0e4280 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 1 Dec 2015 00:50:11 -0700 Subject: colored error messages that tell the source file --- src/buffer.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/buffer.cpp') diff --git a/src/buffer.cpp b/src/buffer.cpp index 1978371034..a03ab333f3 100644 --- a/src/buffer.cpp +++ b/src/buffer.cpp @@ -3,9 +3,8 @@ #include #include -Buf *buf_sprintf(const char *format, ...) { - va_list ap, ap2; - va_start(ap, format); +Buf *buf_vprintf(const char *format, va_list ap) { + va_list ap2; va_copy(ap2, ap); int len1 = vsnprintf(nullptr, 0, format, ap); @@ -19,11 +18,18 @@ Buf *buf_sprintf(const char *format, ...) { assert(len2 == len1); va_end(ap2); - va_end(ap); return buf; } +Buf *buf_sprintf(const char *format, ...) { + va_list ap; + va_start(ap, format); + Buf *result = buf_vprintf(format, ap); + va_end(ap); + return result; +} + void buf_appendf(Buf *buf, const char *format, ...) { assert(buf->list.length); va_list ap, ap2; -- cgit v1.2.3