diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2018-04-17 02:31:48 +0800 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2018-04-20 10:41:43 +0200 |
commit | 53a79b1be33adfe7109da837906a4ca22818bfe3 (patch) | |
tree | d53ec5e6c861d047ae8b85b3ac826dec7c72c98e /source | |
parent | 56a752c928146b94838b09c7269c50b0aa800e68 (diff) | |
download | mupdf-53a79b1be33adfe7109da837906a4ca22818bfe3.tar.xz |
Add isdigit convenience macro in xref parsing.
Diffstat (limited to 'source')
-rw-r--r-- | source/pdf/pdf-xref.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c index 8515090d..2d26cdd1 100644 --- a/source/pdf/pdf-xref.c +++ b/source/pdf/pdf-xref.c @@ -14,6 +14,8 @@ #define DEBUGMESS(A) do { } while (0) #endif +#define isdigit(c) (c >= '0' && c <= '9') + static inline int iswhite(int ch) { return @@ -626,7 +628,7 @@ pdf_read_start_xref(fz_context *ctx, pdf_document *doc) while (i < n && iswhite(buf[i])) i ++; doc->startxref = 0; - while (i < n && buf[i] >= '0' && buf[i] <= '9') + while (i < n && isdigit(buf[i])) { if (doc->startxref >= INT64_MAX/10) fz_throw(ctx, FZ_ERROR_GENERIC, "startxref too large"); @@ -696,7 +698,7 @@ pdf_xref_size_from_old_trailer(fz_context *ctx, pdf_document *doc, pdf_lexbuf *b while (1) { c = fz_peek_byte(ctx, doc->file); - if (!(c >= '0' && c <= '9')) + if (!isdigit(c)) break; fz_read_line(ctx, doc->file, buf->scratch, buf->size); @@ -843,7 +845,7 @@ pdf_read_old_xref(fz_context *ctx, pdf_document *doc, pdf_lexbuf *buf) while (1) { c = fz_peek_byte(ctx, file); - if (!(c >= '0' && c <= '9')) + if (!isdigit(c)) break; fz_read_line(ctx, file, buf->scratch, buf->size); @@ -1067,7 +1069,7 @@ pdf_read_xref(fz_context *ctx, pdf_document *doc, int64_t ofs, pdf_lexbuf *buf) c = fz_peek_byte(ctx, doc->file); if (c == 'x') trailer = pdf_read_old_xref(ctx, doc, buf); - else if (c >= '0' && c <= '9') + else if (isdigit(c)) trailer = pdf_read_new_xref(ctx, doc, buf); else fz_throw(ctx, FZ_ERROR_GENERIC, "cannot recognize xref format"); |