diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2014-05-13 14:19:57 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2014-05-13 14:44:18 +0200 |
commit | 4a1d6f9886c141e165c281f127c0cb387c6407d6 (patch) | |
tree | d031c88c4485731e1f06e52235fe24d7b48e8f4b | |
parent | 11366353e1e88805f25053825cfd99be035cd245 (diff) | |
download | mupdf-4a1d6f9886c141e165c281f127c0cb387c6407d6.tar.xz |
Fix signedness in cmap interface.
-rw-r--r-- | include/mupdf/pdf/cmap.h | 12 | ||||
-rw-r--r-- | source/pdf/pdf-cmap.c | 16 | ||||
-rw-r--r-- | source/pdf/pdf-op-run.c | 3 | ||||
-rw-r--r-- | source/pdf/pdf-unicode.c | 17 |
4 files changed, 26 insertions, 22 deletions
diff --git a/include/mupdf/pdf/cmap.h b/include/mupdf/pdf/cmap.h index 5396ebbc..b4080b8e 100644 --- a/include/mupdf/pdf/cmap.h +++ b/include/mupdf/pdf/cmap.h @@ -40,7 +40,7 @@ struct pdf_cmap_s int codespace_len; struct { - unsigned int n; + int n; unsigned int low; unsigned int high; } codespace[40]; @@ -65,15 +65,15 @@ int pdf_cmap_wmode(fz_context *ctx, pdf_cmap *cmap); void pdf_set_cmap_wmode(fz_context *ctx, pdf_cmap *cmap, int wmode); void pdf_set_usecmap(fz_context *ctx, pdf_cmap *cmap, pdf_cmap *usecmap); -void pdf_add_codespace(fz_context *ctx, pdf_cmap *cmap, int low, int high, int n); -void pdf_map_range_to_table(fz_context *ctx, pdf_cmap *cmap, int low, int *map, int len); -void pdf_map_range_to_range(fz_context *ctx, pdf_cmap *cmap, int srclo, int srchi, int dstlo); -void pdf_map_one_to_many(fz_context *ctx, pdf_cmap *cmap, int one, int *many, int len); +void pdf_add_codespace(fz_context *ctx, pdf_cmap *cmap, unsigned int low, unsigned int high, int n); +void pdf_map_range_to_table(fz_context *ctx, pdf_cmap *cmap, unsigned int low, int *map, int len); +void pdf_map_range_to_range(fz_context *ctx, pdf_cmap *cmap, unsigned int srclo, unsigned int srchi, int dstlo); +void pdf_map_one_to_many(fz_context *ctx, pdf_cmap *cmap, unsigned int one, int *many, int len); void pdf_sort_cmap(fz_context *ctx, pdf_cmap *cmap); int pdf_lookup_cmap(pdf_cmap *cmap, unsigned int cpt); int pdf_lookup_cmap_full(pdf_cmap *cmap, unsigned int cpt, int *out); -int pdf_decode_cmap(pdf_cmap *cmap, unsigned char *s, unsigned char *e, int *cpt); +int pdf_decode_cmap(pdf_cmap *cmap, unsigned char *s, unsigned char *e, unsigned int *cpt); pdf_cmap *pdf_new_identity_cmap(fz_context *ctx, int wmode, int bytes); pdf_cmap *pdf_load_cmap(fz_context *ctx, fz_stream *file); diff --git a/source/pdf/pdf-cmap.c b/source/pdf/pdf-cmap.c index db628f23..e9eb25b2 100644 --- a/source/pdf/pdf-cmap.c +++ b/source/pdf/pdf-cmap.c @@ -73,7 +73,7 @@ pdf_set_cmap_wmode(fz_context *ctx, pdf_cmap *cmap, int wmode) * multi-byte encoded strings. */ void -pdf_add_codespace(fz_context *ctx, pdf_cmap *cmap, int low, int high, int n) +pdf_add_codespace(fz_context *ctx, pdf_cmap *cmap, unsigned int low, unsigned int high, int n) { if (cmap->codespace_len + 1 == nelem(cmap->codespace)) { @@ -153,7 +153,7 @@ add_mrange(fz_context *ctx, pdf_cmap *cmap, unsigned int low, int *out, int len) * Add a range-to-table mapping. */ void -pdf_map_range_to_table(fz_context *ctx, pdf_cmap *cmap, int low, int *table, int len) +pdf_map_range_to_table(fz_context *ctx, pdf_cmap *cmap, unsigned int low, int *table, int len) { int i; for (i = 0; i < len; i++) @@ -164,7 +164,7 @@ pdf_map_range_to_table(fz_context *ctx, pdf_cmap *cmap, int low, int *table, int * Add a range of contiguous one-to-one mappings (ie 1..5 maps to 21..25) */ void -pdf_map_range_to_range(fz_context *ctx, pdf_cmap *cmap, int low, int high, int out) +pdf_map_range_to_range(fz_context *ctx, pdf_cmap *cmap, unsigned int low, unsigned int high, int out) { add_range(ctx, cmap, low, high, out); } @@ -173,7 +173,7 @@ pdf_map_range_to_range(fz_context *ctx, pdf_cmap *cmap, int low, int high, int o * Add a single one-to-many mapping. */ void -pdf_map_one_to_many(fz_context *ctx, pdf_cmap *cmap, int low, int *values, int len) +pdf_map_one_to_many(fz_context *ctx, pdf_cmap *cmap, unsigned int low, int *values, int len) { if (len == 1) { @@ -315,7 +315,8 @@ pdf_lookup_cmap_full(pdf_cmap *cmap, unsigned int cpt, int *out) pdf_range *ranges = cmap->ranges; pdf_xrange *xranges = cmap->xranges; pdf_mrange *mranges = cmap->mranges; - int l, r, m, i; + unsigned int i; + int l, r, m; l = 0; r = cmap->rlen - 1; @@ -377,9 +378,10 @@ pdf_lookup_cmap_full(pdf_cmap *cmap, unsigned int cpt, int *out) * multi-byte encoded string. */ int -pdf_decode_cmap(pdf_cmap *cmap, unsigned char *buf, unsigned char *end, int *cpt) +pdf_decode_cmap(pdf_cmap *cmap, unsigned char *buf, unsigned char *end, unsigned int *cpt) { - int k, n, c; + unsigned int c; + int k, n; int len = end - buf; if (len > 4) diff --git a/source/pdf/pdf-op-run.c b/source/pdf/pdf-op-run.c index ab1bf246..2f4a8c0a 100644 --- a/source/pdf/pdf-op-run.c +++ b/source/pdf/pdf-op-run.c @@ -1197,7 +1197,8 @@ pdf_show_string(pdf_csi *csi, pdf_run_state *pr, unsigned char *buf, int len) pdf_gstate *gstate = pr->gstate + pr->gtop; pdf_font_desc *fontdesc = gstate->font; unsigned char *end = buf + len; - int cpt, cid; + unsigned int cpt; + int cid; if (!fontdesc) { diff --git a/source/pdf/pdf-unicode.c b/source/pdf/pdf-unicode.c index c241dbc7..a6891655 100644 --- a/source/pdf/pdf-unicode.c +++ b/source/pdf/pdf-unicode.c @@ -7,10 +7,10 @@ pdf_load_to_unicode(pdf_document *doc, pdf_font_desc *font, char **strings, char *collection, pdf_obj *cmapstm) { pdf_cmap *cmap; + unsigned int cpt; int cid; int ucsbuf[8]; int ucslen; - int i; fz_context *ctx = doc->ctx; if (pdf_is_stream(doc, pdf_to_num(cmapstm), pdf_to_gen(cmapstm))) @@ -19,12 +19,13 @@ pdf_load_to_unicode(pdf_document *doc, pdf_font_desc *font, font->to_unicode = pdf_new_cmap(ctx); - for (i = 0; i < (strings ? 256 : 65536); i++) + /* TODO: use codespace ranges */ + for (cpt = 0; cpt < (strings ? 256 : 65536); cpt++) { - cid = pdf_lookup_cmap(font->encoding, i); + cid = pdf_lookup_cmap(font->encoding, cpt); if (cid >= 0) { - ucslen = pdf_lookup_cmap_full(cmap, i, ucsbuf); + ucslen = pdf_lookup_cmap_full(cmap, cpt, ucsbuf); if (ucslen == 1) pdf_map_range_to_range(ctx, font->to_unicode, cid, cid, ucsbuf[0]); if (ucslen > 1) @@ -60,12 +61,12 @@ pdf_load_to_unicode(pdf_document *doc, pdf_font_desc *font, font->cid_to_ucs = fz_malloc_array(ctx, 256, sizeof(unsigned short)); font->size += 256 * sizeof(unsigned short); - for (i = 0; i < 256; i++) + for (cpt = 0; cpt < 256; cpt++) { - if (strings[i]) - font->cid_to_ucs[i] = pdf_lookup_agl(strings[i]); + if (strings[cpt]) + font->cid_to_ucs[cpt] = pdf_lookup_agl(strings[cpt]); else - font->cid_to_ucs[i] = '?'; + font->cid_to_ucs[cpt] = '?'; } } |