summaryrefslogtreecommitdiff
path: root/source/fitz/error.c
diff options
context:
space:
mode:
authorSimon Reinhardt <simon.reinhardt@stud.uni-regensburg.de>2016-05-07 22:20:51 +0200
committerRobin Watts <robin.watts@artifex.com>2016-05-12 12:18:19 +0100
commitc99afdde9b0032daa5b64107bd063180ffc3ad3b (patch)
tree8585e0b0fa4e0484515dfdac0740f26788412f40 /source/fitz/error.c
parentea2b0bffaf8e5a8fbbe85a5dcfde2f95d29d5282 (diff)
downloadmupdf-c99afdde9b0032daa5b64107bd063180ffc3ad3b.tar.xz
Add variadic versions of fz_throw and fz_warn.
Diffstat (limited to 'source/fitz/error.c')
-rw-r--r--source/fitz/error.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/source/fitz/error.c b/source/fitz/error.c
index 6330b4ec..b72e3d9a 100644
--- a/source/fitz/error.c
+++ b/source/fitz/error.c
@@ -22,14 +22,11 @@ void fz_flush_warnings(fz_context *ctx)
ctx->warn->count = 0;
}
-void fz_warn(fz_context *ctx, const char *fmt, ...)
+void fz_vwarn(fz_context *ctx, const char *fmt, va_list ap)
{
- va_list ap;
char buf[sizeof ctx->warn->message];
- va_start(ap, fmt);
vsnprintf(buf, sizeof buf, fmt, ap);
- va_end(ap);
#ifdef USE_OUTPUT_DEBUG_STRING
OutputDebugStringA(buf);
OutputDebugStringA("\n");
@@ -49,6 +46,15 @@ void fz_warn(fz_context *ctx, const char *fmt, ...)
}
}
+void fz_warn(fz_context *ctx, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ fz_vwarn(ctx, fmt, ap);
+ va_end(ap);
+}
+
+
/* Error context */
/* When we first setjmp, code is set to 0. Whenever we throw, we add 2 to
@@ -155,13 +161,10 @@ const char *fz_caught_message(fz_context *ctx)
return ctx->error->message;
}
-void fz_throw(fz_context *ctx, int code, const char *fmt, ...)
+void fz_vthrow(fz_context *ctx, int code, const char *fmt, va_list ap)
{
- va_list args;
ctx->error->errcode = code;
- va_start(args, fmt);
- vsnprintf(ctx->error->message, sizeof ctx->error->message, fmt, args);
- va_end(args);
+ vsnprintf(ctx->error->message, sizeof ctx->error->message, fmt, ap);
if (code != FZ_ERROR_ABORT)
{
@@ -178,6 +181,14 @@ void fz_throw(fz_context *ctx, int code, const char *fmt, ...)
throw(ctx);
}
+void fz_throw(fz_context *ctx, int code, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ fz_vthrow(ctx, code, fmt, ap);
+ va_end(ap);
+}
+
void fz_rethrow(fz_context *ctx)
{
assert(ctx && ctx->error && ctx->error->errcode >= FZ_ERROR_NONE);