diff options
author | Sebastian Rasmussen <sebras@hotmail.com> | 2008-04-09 08:53:33 +0200 |
---|---|---|
committer | Sebastian Rasmussen <sebras@hotmail.com> | 2008-04-09 08:53:33 +0200 |
commit | 757b0345a8a55fcf0af5e12b17cdab15ca8de1d6 (patch) | |
tree | a661d7ea0ed3cd5957f3bf6fa7c5fe2d548cfc7e | |
parent | 0e9cf380af7c206ec7b9f0631beaa254efe21db8 (diff) | |
download | mupdf-757b0345a8a55fcf0af5e12b17cdab15ca8de1d6.tar.xz |
Changed token enum into proper type, easing debugging.
-rw-r--r-- | include/mupdf/syntax.h | 6 | ||||
-rw-r--r-- | mupdf/pdf_cmap.c | 120 | ||||
-rw-r--r-- | mupdf/pdf_function.c | 14 | ||||
-rw-r--r-- | mupdf/pdf_interpret.c | 21 | ||||
-rw-r--r-- | mupdf/pdf_lex.c | 40 | ||||
-rw-r--r-- | mupdf/pdf_open.c | 30 | ||||
-rw-r--r-- | mupdf/pdf_parse.c | 12 | ||||
-rw-r--r-- | mupdf/pdf_repair.c | 6 |
8 files changed, 129 insertions, 120 deletions
diff --git a/include/mupdf/syntax.h b/include/mupdf/syntax.h index f9602c35..5f5e7d9f 100644 --- a/include/mupdf/syntax.h +++ b/include/mupdf/syntax.h @@ -2,7 +2,7 @@ * tokenizer and low-level object parser */ -enum +typedef enum pdf_token_e { PDF_TERROR, PDF_TEOF, PDF_TOARRAY, PDF_TCARRAY, @@ -14,10 +14,10 @@ enum PDF_TSTREAM, PDF_TENDSTREAM, PDF_TXREF, PDF_TTRAILER, PDF_TSTARTXREF, PDF_NTOKENS -}; +} pdf_token_e; /* lex.c */ -fz_error *pdf_lex(int *token, fz_stream *f, unsigned char *buf, int n, int *len); +fz_error *pdf_lex(pdf_token_e *tok, fz_stream *f, unsigned char *buf, int n, int *len); /* parse.c */ fz_error *pdf_parsearray(fz_obj **op, fz_stream *f, char *buf, int cap); diff --git a/mupdf/pdf_cmap.c b/mupdf/pdf_cmap.c index 33de4454..5b3f7769 100644 --- a/mupdf/pdf_cmap.c +++ b/mupdf/pdf_cmap.c @@ -573,7 +573,7 @@ enum TENDCIDRANGE }; -static int tokenfromkeyword(char *key) +static pdf_token_e tokenfromkeyword(char *key) { if (!strcmp(key, "usecmap")) return TUSECMAP; if (!strcmp(key, "begincodespacerange")) return TBEGINCODESPACERANGE; @@ -597,12 +597,12 @@ static int codefromstring(unsigned char *buf, int len) return a; } -static fz_error *lexcmap(int *token, fz_stream *file, char *buf, int n, int *sl) +static fz_error *lexcmap(pdf_token_e *tok, fz_stream *file, char *buf, int n, int *sl) { fz_error *error; - error = pdf_lex(token, file, buf, n, sl); - if (!error && *token == PDF_TKEYWORD) - *token = tokenfromkeyword(buf); + error = pdf_lex(tok, file, buf, n, sl); + if (!error && *tok == PDF_TKEYWORD) + *tok = tokenfromkeyword(buf); if (error) return fz_rethrow(error, "cannot parse cmap token"); return nil; @@ -612,14 +612,14 @@ static fz_error *parsecmapname(pdf_cmap *cmap, fz_stream *file) { fz_error *error; char buf[256]; - int token; + pdf_token_e tok; int len; - error = lexcmap(&token, file, buf, sizeof buf, &len); + error = lexcmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (token == PDF_TNAME) + if (tok == PDF_TNAME) { strlcpy(cmap->cmapname, buf, sizeof(cmap->cmapname)); return fz_okay; @@ -632,14 +632,14 @@ static fz_error *parsewmode(pdf_cmap *cmap, fz_stream *file) { fz_error *error; char buf[256]; - int token; + pdf_token_e tok; int len; - error = lexcmap(&token, file, buf, sizeof buf, &len); + error = lexcmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (token == PDF_TINT) + if (tok == PDF_TINT) { pdf_setwmode(cmap, atoi(buf)); return fz_okay; @@ -652,26 +652,26 @@ static fz_error *parsecodespacerange(pdf_cmap *cmap, fz_stream *file) { fz_error *error; char buf[256]; - int token; + pdf_token_e tok; int len; int lo, hi; while (1) { - error = lexcmap(&token, file, buf, sizeof buf, &len); + error = lexcmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (token == TENDCODESPACERANGE) + if (tok == TENDCODESPACERANGE) return fz_okay; - else if (token == PDF_TSTRING) + else if (tok == PDF_TSTRING) { lo = codefromstring(buf, len); - error = lexcmap(&token, file, buf, sizeof buf, &len); + error = lexcmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (token == PDF_TSTRING) + if (tok == PDF_TSTRING) { hi = codefromstring(buf, len); error = pdf_addcodespace(cmap, lo, hi, len); @@ -691,36 +691,36 @@ static fz_error *parsecidrange(pdf_cmap *cmap, fz_stream *file) { fz_error *error; char buf[256]; - int token; + pdf_token_e tok; int len; int lo, hi, dst; while (1) { - error = lexcmap(&token, file, buf, sizeof buf, &len); + error = lexcmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (token == TENDCIDRANGE) + if (tok == TENDCIDRANGE) return fz_okay; - else if (token != PDF_TSTRING) + else if (tok != PDF_TSTRING) return fz_throw("expected string or endcidrange"); lo = codefromstring(buf, len); - error = lexcmap(&token, file, buf, sizeof buf, &len); + error = lexcmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (token != PDF_TSTRING) + if (tok != PDF_TSTRING) return fz_throw("expected string"); hi = codefromstring(buf, len); - error = lexcmap(&token, file, buf, sizeof buf, &len); + error = lexcmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (token != PDF_TINT) + if (tok != PDF_TINT) return fz_throw("expected integer"); dst = atoi(buf); @@ -735,28 +735,28 @@ static fz_error *parsecidchar(pdf_cmap *cmap, fz_stream *file) { fz_error *error; char buf[256]; - int token; + pdf_token_e tok; int len; int src, dst; while (1) { - error = lexcmap(&token, file, buf, sizeof buf, &len); + error = lexcmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (token == TENDCIDCHAR) + if (tok == TENDCIDCHAR) return fz_okay; - else if (token != PDF_TSTRING) + else if (tok != PDF_TSTRING) return fz_throw("expected string or endcidchar"); src = codefromstring(buf, len); - error = lexcmap(&token, file, buf, sizeof buf, &len); + error = lexcmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (token != PDF_TINT) + if (tok != PDF_TINT) return fz_throw("expected integer"); dst = atoi(buf); @@ -771,22 +771,22 @@ static fz_error *parsebfrangearray(pdf_cmap *cmap, fz_stream *file, int lo, int { fz_error *error; char buf[256]; - int token; + pdf_token_e tok; int len; int dst[256]; int i; while (1) { - error = lexcmap(&token, file, buf, sizeof buf, &len); + error = lexcmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (token == PDF_TCARRAY) + if (tok == PDF_TCARRAY) return fz_okay; /* Note: does not handle [ /Name /Name ... ] */ - else if (token != PDF_TSTRING) + else if (tok != PDF_TSTRING) return fz_throw("expected string or ]"); if (len / 2) @@ -807,37 +807,37 @@ static fz_error *parsebfrange(pdf_cmap *cmap, fz_stream *file) { fz_error *error; char buf[256]; - int token; + pdf_token_e tok; int len; int lo, hi, dst; while (1) { - error = lexcmap(&token, file, buf, sizeof buf, &len); + error = lexcmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (token == TENDBFRANGE) + if (tok == TENDBFRANGE) return fz_okay; - else if (token != PDF_TSTRING) + else if (tok != PDF_TSTRING) return fz_throw("expected string or endbfrange"); lo = codefromstring(buf, len); - error = lexcmap(&token, file, buf, sizeof buf, &len); + error = lexcmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (token != PDF_TSTRING) + if (tok != PDF_TSTRING) return fz_throw("expected string"); hi = codefromstring(buf, len); - error = lexcmap(&token, file, buf, sizeof buf, &len); + error = lexcmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (token == PDF_TSTRING) + if (tok == PDF_TSTRING) { if (len == 2) { @@ -868,7 +868,7 @@ static fz_error *parsebfrange(pdf_cmap *cmap, fz_stream *file) } } - else if (token == PDF_TOARRAY) + else if (tok == PDF_TOARRAY) { error = parsebfrangearray(cmap, file, lo, hi); if (error) @@ -886,7 +886,7 @@ static fz_error *parsebfchar(pdf_cmap *cmap, fz_stream *file) { fz_error *error; char buf[256]; - int token; + pdf_token_e tok; int len; int dst[256]; int src; @@ -894,23 +894,23 @@ static fz_error *parsebfchar(pdf_cmap *cmap, fz_stream *file) while (1) { - error = lexcmap(&token, file, buf, sizeof buf, &len); + error = lexcmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (token == TENDBFCHAR) + if (tok == TENDBFCHAR) return fz_okay; - else if (token != PDF_TSTRING) + else if (tok != PDF_TSTRING) return fz_throw("expected string or endbfchar"); src = codefromstring(buf, len); - error = lexcmap(&token, file, buf, sizeof buf, &len); + error = lexcmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); /* Note: does not handle /dstName */ - if (token != PDF_TSTRING) + if (tok != PDF_TSTRING) return fz_throw("expected string"); if (len / 2) @@ -932,7 +932,7 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file) pdf_cmap *cmap; char key[64]; char buf[256]; - int token; + pdf_token_e tok; int len; error = pdf_newcmap(&cmap); @@ -943,17 +943,17 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file) while (1) { - error = lexcmap(&token, file, buf, sizeof buf, &len); + error = lexcmap(&tok, file, buf, sizeof buf, &len); if (error) { error = fz_rethrow(error, "syntaxerror in cmap"); goto cleanup; } - if (token == PDF_TEOF) + if (tok == PDF_TEOF) break; - else if (token == PDF_TNAME) + else if (tok == PDF_TNAME) { if (!strcmp(buf, "CMapName")) { @@ -977,12 +977,12 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file) strlcpy(key, buf, sizeof key); } - else if (token == TUSECMAP) + else if (tok == TUSECMAP) { strlcpy(cmap->usecmapname, key, sizeof(cmap->usecmapname)); } - else if (token == TBEGINCODESPACERANGE) + else if (tok == TBEGINCODESPACERANGE) { error = parsecodespacerange(cmap, file); if (error) @@ -992,7 +992,7 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file) } } - else if (token == TBEGINBFCHAR) + else if (tok == TBEGINBFCHAR) { error = parsebfchar(cmap, file); if (error) @@ -1002,7 +1002,7 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file) } } - else if (token == TBEGINCIDCHAR) + else if (tok == TBEGINCIDCHAR) { error = parsecidchar(cmap, file); if (error) @@ -1012,7 +1012,7 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file) } } - else if (token == TBEGINBFRANGE) + else if (tok == TBEGINBFRANGE) { error = parsebfrange(cmap, file); if (error) @@ -1022,7 +1022,7 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file) } } - else if (token == TBEGINCIDRANGE) + else if (tok == TBEGINCIDRANGE) { error = parsecidrange(cmap, file); if (error) diff --git a/mupdf/pdf_function.c b/mupdf/pdf_function.c index 76142d8b..49ff1514 100644 --- a/mupdf/pdf_function.c +++ b/mupdf/pdf_function.c @@ -329,7 +329,7 @@ parsecode(pdf_function *func, fz_stream *stream, int *codeptr) fz_error *error; char buf[64]; int len; - int token; + pdf_token_e tok; int opptr, elseptr; int a, b, mid, cmp; @@ -337,11 +337,11 @@ parsecode(pdf_function *func, fz_stream *stream, int *codeptr) while (1) { - error = pdf_lex(&token, stream, buf, sizeof buf, &len); + error = pdf_lex(&tok, stream, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "calculator function lexical error"); - switch(token) + switch(tok) { case PDF_TEOF: return fz_throw("truncated calculator function"); @@ -376,18 +376,18 @@ parsecode(pdf_function *func, fz_stream *stream, int *codeptr) if (error) return fz_rethrow(error, "error in 'if' branch"); - error = pdf_lex(&token, stream, buf, sizeof buf, &len); + error = pdf_lex(&tok, stream, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "calculator function syntax error"); - if (token == PDF_TOBRACE) + if (tok == PDF_TOBRACE) { elseptr = *codeptr; error = parsecode(func, stream, codeptr); if (error) return fz_rethrow(error, "error in 'else' branch"); - error = pdf_lex(&token, stream, buf, sizeof buf, &len); + error = pdf_lex(&tok, stream, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "calculator function syntax error"); } @@ -396,7 +396,7 @@ parsecode(pdf_function *func, fz_stream *stream, int *codeptr) elseptr = -1; } - if (token == PDF_TKEYWORD) + if (tok == PDF_TKEYWORD) { if (!strcmp(buf, "if")) { diff --git a/mupdf/pdf_interpret.c b/mupdf/pdf_interpret.c index 700b5c8f..ca564d87 100644 --- a/mupdf/pdf_interpret.c +++ b/mupdf/pdf_interpret.c @@ -220,21 +220,21 @@ runinlineimage(pdf_csi *csi, pdf_xref *xref, fz_obj *rdb, fz_stream *file, fz_ob fz_error *error; pdf_image *img; char buf[256]; - int token; + pdf_token_e tok; int len; error = pdf_loadinlineimage(&img, xref, rdb, dict, file); if (error) return fz_rethrow(error, "cannot load inline image"); - error = pdf_lex(&token, file, (unsigned char *)buf, sizeof buf, &len); + error = pdf_lex(&tok, file, (unsigned char *)buf, sizeof buf, &len); if (error) { fz_dropimage((fz_image*)img); return fz_rethrow(error, "syntax error after inline image"); } - if (token != PDF_TKEYWORD || strcmp("EI", buf)) + if (tok != PDF_TKEYWORD || strcmp("EI", buf)) { fz_dropimage((fz_image*)img); return fz_throw("syntax error after inline image"); @@ -1162,7 +1162,8 @@ pdf_runcsi(pdf_csi *csi, pdf_xref *xref, fz_obj *rdb, fz_stream *file) { fz_error *error; char buf[65536]; - int token, len; + pdf_token_e tok; + int len; fz_obj *obj; while (1) @@ -1170,19 +1171,19 @@ pdf_runcsi(pdf_csi *csi, pdf_xref *xref, fz_obj *rdb, fz_stream *file) if (csi->top == 31) return fz_throw("stack overflow"); - error = pdf_lex(&token, file, (unsigned char *)buf, sizeof buf, &len); + error = pdf_lex(&tok, file, (unsigned char *)buf, sizeof buf, &len); if (error) return fz_rethrow(error, "lexical error in content stream"); if (csi->array) { - if (token == PDF_TCARRAY) + if (tok == PDF_TCARRAY) { csi->stack[csi->top] = csi->array; csi->array = nil; csi->top ++; } - else if (token == PDF_TINT || token == PDF_TREAL) + else if (tok == PDF_TINT || tok == PDF_TREAL) { error = fz_newreal(&obj, atof(buf)); if (error) return fz_rethrow(error, "cannot create number"); @@ -1190,7 +1191,7 @@ pdf_runcsi(pdf_csi *csi, pdf_xref *xref, fz_obj *rdb, fz_stream *file) fz_dropobj(obj); if (error) return fz_rethrow(error, "cannot add number to array"); } - else if (token == PDF_TSTRING) + else if (tok == PDF_TSTRING) { error = fz_newstring(&obj, buf, len); if (error) return fz_rethrow(error, "cannot create string"); @@ -1198,7 +1199,7 @@ pdf_runcsi(pdf_csi *csi, pdf_xref *xref, fz_obj *rdb, fz_stream *file) fz_dropobj(obj); if (error) return fz_rethrow(error, "cannot add string to array"); } - else if (token == PDF_TEOF) + else if (tok == PDF_TEOF) { return fz_okay; } @@ -1209,7 +1210,7 @@ pdf_runcsi(pdf_csi *csi, pdf_xref *xref, fz_obj *rdb, fz_stream *file) } } - else switch (token) + else switch (tok) { case PDF_TEOF: return fz_okay; diff --git a/mupdf/pdf_lex.c b/mupdf/pdf_lex.c index 3af88497..94faad99 100644 --- a/mupdf/pdf_lex.c +++ b/mupdf/pdf_lex.c @@ -232,7 +232,7 @@ lexhexstring(fz_stream *f, unsigned char *buf, int n) return s - buf; } -static int +static pdf_token_e tokenfromkeyword(char *key) { if (!strcmp(key, "R")) return PDF_TR; @@ -253,7 +253,7 @@ tokenfromkeyword(char *key) } fz_error * -pdf_lex(int *ret, fz_stream *f, unsigned char *buf, int n, int *sl) +pdf_lex(pdf_token_e *tok, fz_stream *f, unsigned char *buf, int n, int *sl) { fz_error *error; int c; @@ -264,7 +264,7 @@ pdf_lex(int *ret, fz_stream *f, unsigned char *buf, int n, int *sl) if (c == EOF) { - *ret = PDF_TEOF; + *tok = PDF_TEOF; goto cleanupokay; } @@ -279,7 +279,7 @@ pdf_lex(int *ret, fz_stream *f, unsigned char *buf, int n, int *sl) fz_readbyte(f); lexname(f, buf, n); *sl = strlen(buf); - *ret = PDF_TNAME; + *tok = PDF_TNAME; goto cleanupokay; } @@ -287,7 +287,7 @@ pdf_lex(int *ret, fz_stream *f, unsigned char *buf, int n, int *sl) { fz_readbyte(f); *sl = lexstring(f, buf, n); - *ret = PDF_TSTRING; + *tok = PDF_TSTRING; goto cleanupokay; } @@ -298,13 +298,13 @@ pdf_lex(int *ret, fz_stream *f, unsigned char *buf, int n, int *sl) if (c == '<') { fz_readbyte(f); - *ret = PDF_TODICT; + *tok = PDF_TODICT; goto cleanupokay; } else { *sl = lexhexstring(f, buf, n); - *ret = PDF_TSTRING; + *tok = PDF_TSTRING; goto cleanupokay; } } @@ -315,38 +315,38 @@ pdf_lex(int *ret, fz_stream *f, unsigned char *buf, int n, int *sl) c = fz_readbyte(f); if (c == '>') { - *ret = PDF_TCDICT; + *tok = PDF_TCDICT; goto cleanupokay; } - *ret = PDF_TERROR; + *tok = PDF_TERROR; goto cleanuperror; } else if (c == '[') { fz_readbyte(f); - *ret = PDF_TOARRAY; + *tok = PDF_TOARRAY; goto cleanupokay; } else if (c == ']') { fz_readbyte(f); - *ret = PDF_TCARRAY; + *tok = PDF_TCARRAY; goto cleanupokay; } else if (c == '{') { fz_readbyte(f); - *ret = PDF_TOBRACE; + *tok = PDF_TOBRACE; goto cleanupokay; } else if (c == '}') { fz_readbyte(f); - *ret = PDF_TCBRACE; + *tok = PDF_TCBRACE; goto cleanupokay; } @@ -356,10 +356,10 @@ pdf_lex(int *ret, fz_stream *f, unsigned char *buf, int n, int *sl) *sl = strlen(buf); if (strchr(buf, '.')) { - *ret = PDF_TREAL; + *tok = PDF_TREAL; goto cleanupokay; } - *ret = PDF_TINT; + *tok = PDF_TINT; goto cleanupokay; } @@ -367,13 +367,13 @@ pdf_lex(int *ret, fz_stream *f, unsigned char *buf, int n, int *sl) { lexname(f, buf, n); *sl = strlen(buf); - *ret = tokenfromkeyword(buf); + *tok = tokenfromkeyword(buf); goto cleanupokay; } else { - *ret = PDF_TERROR; + *tok = PDF_TERROR; goto cleanuperror; } } @@ -382,7 +382,7 @@ cleanupokay: error = fz_readerror(f); if (error) { - *ret = PDF_TERROR; + *tok = PDF_TERROR; return fz_rethrow(error, "cannot read token"); } return fz_okay; @@ -391,10 +391,10 @@ cleanuperror: error = fz_readerror(f); if (error) { - *ret = PDF_TERROR; + *tok = PDF_TERROR; return fz_rethrow(error, "cannot read token"); } - *ret = PDF_TERROR; + *tok = PDF_TERROR; return fz_throw("lexical error"); } diff --git a/mupdf/pdf_open.c b/mupdf/pdf_open.c index 9b7dfeb5..3232fa4c 100644 --- a/mupdf/pdf_open.c +++ b/mupdf/pdf_open.c @@ -83,6 +83,7 @@ readoldtrailer(pdf_xref *xref, char *buf, int cap) char *s; int n; int t; + pdf_token_e tok; int c; pdf_logxref("load old xref format trailer\n"); @@ -128,16 +129,16 @@ readoldtrailer(pdf_xref *xref, char *buf, int cap) if (error) return fz_rethrow(error, "cannot read from file"); - error = pdf_lex(&t, xref->file, buf, cap, &n); + error = pdf_lex(&tok, xref->file, buf, cap, &n); if (error) return fz_rethrow(error, "cannot parse trailer"); - if (t != PDF_TTRAILER) + if (tok != PDF_TTRAILER) return fz_throw("expected trailer marker"); - error = pdf_lex(&t, xref->file, buf, cap, &n); + error = pdf_lex(&tok, xref->file, buf, cap, &n); if (error) return fz_rethrow(error, "cannot parse trailer"); - if (t != PDF_TODICT) + if (tok != PDF_TODICT) return fz_throw("expected trailer dictionary"); error = pdf_parsedict(&xref->trailer, xref->file, buf, cap); @@ -205,7 +206,7 @@ readoldxref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap) int ofs, len; char *s; int n; - int t; + pdf_token_e tok; int i; int c; @@ -255,16 +256,16 @@ readoldxref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap) } } - error = pdf_lex(&t, xref->file, buf, cap, &n); + error = pdf_lex(&tok, xref->file, buf, cap, &n); if (error) return fz_rethrow(error, "cannot parse trailer"); - if (t != PDF_TTRAILER) + if (tok != PDF_TTRAILER) return fz_throw("expected trailer marker"); - error = pdf_lex(&t, xref->file, buf, cap, &n); + error = pdf_lex(&tok, xref->file, buf, cap, &n); if (error) return fz_rethrow(error, "cannot parse trailer"); - if (t != PDF_TODICT) + if (tok != PDF_TODICT) return fz_throw("expected trailer dictionary"); error = pdf_parsedict(trailerp, xref->file, buf, cap); @@ -479,7 +480,8 @@ pdf_loadobjstm(pdf_xref *xref, int oid, int gen, char *buf, int cap) fz_obj *obj; int first; int count; - int i, n, t; + int i, n; + pdf_token_e tok; pdf_logxref("loadobjstm %d %d\n", oid, gen); @@ -515,16 +517,16 @@ pdf_loadobjstm(pdf_xref *xref, int oid, int gen, char *buf, int cap) for (i = 0; i < count; i++) { - error = pdf_lex(&t, stm, buf, cap, &n); - if (error || t != PDF_TINT) + error = pdf_lex(&tok, stm, buf, cap, &n); + if (error || tok != PDF_TINT) { error = fz_rethrow(error, "corrupt object stream"); goto cleanupstm; } oidbuf[i] = atoi(buf); - error = pdf_lex(&t, stm, buf, cap, &n); - if (error || t != PDF_TINT) + error = pdf_lex(&tok, stm, buf, cap, &n); + if (error || tok != PDF_TINT) { error = fz_rethrow(error, "corrupt object stream"); goto cleanupstm; diff --git a/mupdf/pdf_parse.c b/mupdf/pdf_parse.c index 2353ba4e..428a5d03 100644 --- a/mupdf/pdf_parse.c +++ b/mupdf/pdf_parse.c @@ -113,7 +113,8 @@ pdf_parsearray(fz_obj **op, fz_stream *file, char *buf, int cap) fz_obj *ary = nil; fz_obj *obj = nil; int a = 0, b = 0, n = 0; - int tok, len; + pdf_token_e tok; + int len; error = fz_newarray(op, 4); if (error) @@ -222,7 +223,8 @@ pdf_parsedict(fz_obj **op, fz_stream *file, char *buf, int cap) fz_obj *dict = nil; fz_obj *key = nil; fz_obj *val = nil; - int tok, len; + pdf_token_e tok; + int len; int a, b; error = fz_newdict(op, 8); @@ -318,7 +320,8 @@ fz_error * pdf_parsestmobj(fz_obj **op, fz_stream *file, char *buf, int cap) { fz_error *error; - int tok, len; + pdf_token_e tok; + int len; error = pdf_lex(&tok, file, buf, cap, &len); if (error) @@ -350,7 +353,8 @@ pdf_parseindobj(fz_obj **op, fz_stream *file, char *buf, int cap, fz_error *error = nil; fz_obj *obj = nil; int oid = 0, gid = 0, stmofs; - int tok, len; + pdf_token_e tok; + int len; int a, b; error = pdf_lex(&tok, file, buf, cap, &len); diff --git a/mupdf/pdf_repair.c b/mupdf/pdf_repair.c index ecdbf530..0e28ea2b 100644 --- a/mupdf/pdf_repair.c +++ b/mupdf/pdf_repair.c @@ -23,7 +23,8 @@ parseobj(fz_stream *file, char *buf, int cap, int *stmofs, int *stmlen, fz_obj *length; fz_obj *filter; fz_obj *type; - int tok, len; + pdf_token_e tok; + int len; int n; *stmlen = -1; @@ -152,7 +153,8 @@ pdf_repairxref(pdf_xref *xref, char *filename) int isroot, rootoid = 0, rootgen = 0; int isinfo, infooid = 0, infogen = 0; int stmofs, stmlen; - int tok, len; + pdf_token_e tok; + int len; int next; int i; |