diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2015-12-01 00:50:11 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2015-12-01 00:50:11 -0700 |
| commit | 257cf09472ce5f4a51bf39808e119717fa0e4280 (patch) | |
| tree | 722cbc737134b1aa03fafac400f680f20007308a /src/buffer.cpp | |
| parent | 31cf43de54c012c3b6f4fa7a516e2aac0ae18b56 (diff) | |
| download | zig-257cf09472ce5f4a51bf39808e119717fa0e4280.tar.gz zig-257cf09472ce5f4a51bf39808e119717fa0e4280.zip | |
colored error messages that tell the source file
Diffstat (limited to 'src/buffer.cpp')
| -rw-r--r-- | src/buffer.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
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 <stdlib.h> #include <stdio.h> -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; |
