diff options
author | Robin Watts <robin.watts@artifex.com> | 2011-11-14 16:42:43 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2011-11-14 16:45:45 +0000 |
commit | 60c0544742931da63db623ad7a79ba3758704cc1 (patch) | |
tree | e5d80b514bf41d0c9d134dfdb2759c677e03b5a1 | |
parent | 0a31674b1e78930e86d4d7408082f564bc550cf7 (diff) | |
download | mupdf-60c0544742931da63db623ad7a79ba3758704cc1.tar.xz |
Simplify fz_try/fz_catch by removing failed flag.
The failed flag can be removed by having the fz_throw (and fz_rethrow)
functions do the popping of the stack.
-rw-r--r-- | fitz/base_error.c | 6 | ||||
-rw-r--r-- | fitz/fitz.h | 7 |
2 files changed, 5 insertions, 8 deletions
diff --git a/fitz/base_error.c b/fitz/base_error.c index 3ef69a60..b844fb6a 100644 --- a/fitz/base_error.c +++ b/fitz/base_error.c @@ -36,9 +36,9 @@ void fz_warn(fz_context *ctx, char *fmt, ...) static void throw(fz_error_context *ex) { - if (ex->top >= 0) - longjmp(ex->stack[ex->top].buffer, 1); - else { + if (ex->top >= 0) { + longjmp(ex->stack[ex->top--].buffer, 1); + } else { fprintf(stderr, "uncaught exception: %s\n", ex->message); exit(EXIT_FAILURE); } diff --git a/fitz/fitz.h b/fitz/fitz.h index da39b04d..44d976cb 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -155,7 +155,6 @@ struct fz_error_context_s { int top; struct { - int failed; jmp_buf buffer; } stack[256]; char message[256]; @@ -168,11 +167,9 @@ struct fz_error_context_s #define fz_catch(ctx) \ } while(0); \ - ctx->error->stack[ctx->error->top].failed = 0; \ + ctx->error->top--; \ } \ - else \ - ctx->error->stack[ctx->error->top].failed = 1; \ - if (ctx->error->stack[ctx->error->top--].failed) + else void fz_push_try(fz_error_context *ex); void fz_throw(fz_context *, char *, ...) __printflike(2, 3); |