diff options
author | Robin Watts <robin.watts@artifex.com> | 2011-09-11 19:29:42 -0500 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2011-09-14 17:44:13 +0100 |
commit | 89ae81f651bfa112b8e07317eb6983beaf7cb212 (patch) | |
tree | 3f99dad1253b795629e66d45b915c1d72043242b /fitz/filt_basic.c | |
parent | cefb81f1886685580a40b17b5e495a8a8a1ebeaf (diff) | |
download | mupdf-89ae81f651bfa112b8e07317eb6983beaf7cb212.tar.xz |
Initial import of exception handling code
Import exception handling code from WSS, modified to fit into the
fitz world.
With this code we have 'real' fz_try/fz_catch/fz_rethrow functions,
handling a fz_except type. We therefore rename the existing fz_throw/
fz_catch/fz_rethrow to be fz_error_make/fz_error_handle/fz_error_note.
We don't actually use fz_try/fz_catch/fz_rethrow yet...
Diffstat (limited to 'fitz/filt_basic.c')
-rw-r--r-- | fitz/filt_basic.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/fitz/filt_basic.c b/fitz/filt_basic.c index feb13076..15c42137 100644 --- a/fitz/filt_basic.c +++ b/fitz/filt_basic.c @@ -23,7 +23,7 @@ read_null(fz_stream *stm, unsigned char *buf, int len) int amount = MIN(len, state->remain); int n = fz_read(state->chain, buf, amount); if (n < 0) - return fz_rethrow(n, "read error in null filter"); + return fz_error_note(n, "read error in null filter"); state->remain -= n; return n; } @@ -124,7 +124,7 @@ read_ahxd(fz_stream *stm, unsigned char *buf, int len) } else if (!iswhite(c)) { - return fz_throw("bad data in ahxd: '%c'", c); + return fz_error_make("bad data in ahxd: '%c'", c); } } @@ -228,7 +228,7 @@ read_a85d(fz_stream *stm, unsigned char *buf, int len) case 0: break; case 1: - return fz_throw("partial final byte in a85d"); + return fz_error_make("partial final byte in a85d"); case 2: word = word * (85 * 85 * 85) + 0xffffff; state->bp[0] = word >> 24; @@ -256,7 +256,7 @@ read_a85d(fz_stream *stm, unsigned char *buf, int len) else if (!iswhite(c)) { - return fz_throw("bad data in a85d: '%c'", c); + return fz_error_make("bad data in a85d: '%c'", c); } while (state->rp < state->wp && p < ep) @@ -322,7 +322,7 @@ read_rld(fz_stream *stm, unsigned char *buf, int len) state->n = 257 - state->run; state->c = fz_read_byte(state->chain); if (state->c < 0) - return fz_throw("premature end of data in run length decode"); + return fz_error_make("premature end of data in run length decode"); } } @@ -332,7 +332,7 @@ read_rld(fz_stream *stm, unsigned char *buf, int len) { int c = fz_read_byte(state->chain); if (c < 0) - return fz_throw("premature end of data in run length decode"); + return fz_error_make("premature end of data in run length decode"); *p++ = c; state->n--; } @@ -391,7 +391,7 @@ read_arc4(fz_stream *stm, unsigned char *buf, int len) n = fz_read(state->chain, buf, len); if (n < 0) - return fz_rethrow(n, "read error in arc4 filter"); + return fz_error_note(n, "read error in arc4 filter"); fz_arc4_encrypt(&state->arc4, buf, buf, n); @@ -443,7 +443,7 @@ read_aesd(fz_stream *stm, unsigned char *buf, int len) { int c = fz_read_byte(state->chain); if (c < 0) - return fz_throw("premature end in aes filter"); + return fz_error_make("premature end in aes filter"); state->iv[state->ivcount++] = c; } @@ -454,11 +454,11 @@ read_aesd(fz_stream *stm, unsigned char *buf, int len) { int n = fz_read(state->chain, state->bp, 16); if (n < 0) - return fz_rethrow(n, "read error in aes filter"); + return fz_error_note(n, "read error in aes filter"); else if (n == 0) return p - buf; else if (n < 16) - return fz_throw("partial block in aes filter"); + return fz_error_make("partial block in aes filter"); aes_crypt_cbc(&state->aes, AES_DECRYPT, 16, state->iv, state->bp, state->bp); state->rp = state->bp; @@ -469,7 +469,7 @@ read_aesd(fz_stream *stm, unsigned char *buf, int len) { int pad = state->bp[15]; if (pad < 1 || pad > 16) - return fz_throw("aes padding out of range: %d", pad); + return fz_error_make("aes padding out of range: %d", pad); state->wp -= pad; } |