graphics

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 1c57f2c3264bf319e76c0a9a6097694c8949bf20
parent c4bfb2d7d5a108b0c0b23429b7a5a2a9f5c5811a
Author: Brian Swetland <swetland@frotz.net>
Date:   Fri, 14 Jun 2013 23:45:18 -0700

fix formatted die() output

Diffstat:
Mcommon/io.cc | 26++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/common/io.cc b/common/io.cc @@ -64,18 +64,11 @@ int file_get_mtime(const char *fn) { return s.st_mtime; } -void die(const char *fmt, ...) { - printx("ERROR: %s\n", fmt); - exit(-1); -} -void printx(const char *fmt, ...) { +void vprintx(const char *fmt, va_list ap) { char buf[128]; - va_list ap; - va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); buf[127] = 0; - va_end(ap); #if defined(_WIN32) && defined(_DEBUG) OutputDebugString(buf); #else @@ -83,6 +76,23 @@ void printx(const char *fmt, ...) { #endif } +void printx(const char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + vprintx(fmt, ap); + va_end(ap); +} + +void die(const char *fmt, ...) { + va_list ap; + printx("ERROR: "); + va_start(ap, fmt); + vprintx(fmt, ap); + va_end(ap); + printx("\n"); + exit(-1); +} + void printmtx(float *m, const char *name) { printx("| %8.4f %8.4f %8.4f %8.4f | \"%s\"\n", m[0], m[1], m[2], m[3], name); printx("| %8.4f %8.4f %8.4f %8.4f |\n", m[4], m[5], m[6], m[7]);