diff options
author | Peter Breitenlohner <peb@mppmu.mpg.de> | 2014-08-20 10:46:22 +0000 |
---|---|---|
committer | Peter Breitenlohner <peb@mppmu.mpg.de> | 2014-08-20 10:46:22 +0000 |
commit | 418eab4ae66c2d3f4d636feda4aa6e61bffad7f2 (patch) | |
tree | 68bcb3aaa4a67a9b58d5ec79bc62af9fe85e4fc0 /Build/source | |
parent | 53c39c070e16923aa7b27141d330883eee19f7eb (diff) |
texk/dvipdfm-x: Simplify handling of DVI commands. Clarify signed vs unsigned four byte numbers
git-svn-id: svn://tug.org/texlive/trunk@34990 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r-- | Build/source/texk/dvipdfm-x/ChangeLog | 10 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/config.h.in | 4 | ||||
-rwxr-xr-x | Build/source/texk/dvipdfm-x/configure | 11 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/configure.ac | 1 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/dvi.c | 483 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/numbers.c | 63 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/numbers.h | 23 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/vf.c | 6 |
8 files changed, 112 insertions, 489 deletions
diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog index f28522d58d2..1f2ffda5781 100644 --- a/Build/source/texk/dvipdfm-x/ChangeLog +++ b/Build/source/texk/dvipdfm-x/ChangeLog @@ -1,3 +1,13 @@ +2014-08-20 Peter Breitenlohner <peb@mppmu.mpg.de> + + * configure.ac: Add AC_TYPE_INT32_T for int32_t. + * numbers.c: Drop unused code. + * numbers.h: Drop unused code. + Include <inttypes.h> and <stdint.h> for int32_t and uint32_t. + Clarify signed vs unsigned four byte numbers from binary files. + * dvi.c: Simplify handling of DVI commands. + * vf.c: Replace 'Ubyte' => 'unsigned char'. + 2014-08-19 Peter Breitenlohner <peb@mppmu.mpg.de> * pngimage.c: Avoid PNG warnings. diff --git a/Build/source/texk/dvipdfm-x/config.h.in b/Build/source/texk/dvipdfm-x/config.h.in index f7d6d1ef177..d54ff0ec454 100644 --- a/Build/source/texk/dvipdfm-x/config.h.in +++ b/Build/source/texk/dvipdfm-x/config.h.in @@ -250,6 +250,10 @@ #undef inline #endif +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +#undef int32_t + /* Define to the type of a signed integer type of width exactly 64 bits if such a type exists and the standard includes do not define it. */ #undef int64_t diff --git a/Build/source/texk/dvipdfm-x/configure b/Build/source/texk/dvipdfm-x/configure index 3d4391e63f4..3b56e4bbef1 100755 --- a/Build/source/texk/dvipdfm-x/configure +++ b/Build/source/texk/dvipdfm-x/configure @@ -13638,6 +13638,17 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac +ac_fn_c_find_intX_t "$LINENO" "32" "ac_cv_c_int32_t" +case $ac_cv_c_int32_t in #( + no|yes) ;; #( + *) + +cat >>confdefs.h <<_ACEOF +#define int32_t $ac_cv_c_int32_t +_ACEOF +;; +esac + ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" case $ac_cv_c_uint32_t in #( no|yes) ;; #( diff --git a/Build/source/texk/dvipdfm-x/configure.ac b/Build/source/texk/dvipdfm-x/configure.ac index 60d998739e8..5593d291cb9 100644 --- a/Build/source/texk/dvipdfm-x/configure.ac +++ b/Build/source/texk/dvipdfm-x/configure.ac @@ -30,6 +30,7 @@ dnl Checks for typedefs, structures, and compiler characteristics. AC_STRUCT_TM AC_STRUCT_TIMEZONE AC_C_BIGENDIAN +AC_TYPE_INT32_T AC_TYPE_UINT32_T AC_CHECK_DECL([timezone], diff --git a/Build/source/texk/dvipdfm-x/dvi.c b/Build/source/texk/dvipdfm-x/dvi.c index 3cc17e8821b..8bae2dddf5b 100644 --- a/Build/source/texk/dvipdfm-x/dvi.c +++ b/Build/source/texk/dvipdfm-x/dvi.c @@ -212,6 +212,7 @@ static UNSIGNED_BYTE get_and_buffer_unsigned_byte (FILE *file) return (UNSIGNED_BYTE) ch; } +#ifdef XETEX static UNSIGNED_PAIR get_and_buffer_unsigned_pair (FILE *file) { int i; @@ -223,67 +224,7 @@ static UNSIGNED_PAIR get_and_buffer_unsigned_pair (FILE *file) } return pair; } - -static SIGNED_PAIR get_and_buffer_signed_pair (FILE *file) -{ - int i; - long pair = 0; - for (i=0; i<2; i++) { - pair = pair*0x100 + get_and_buffer_unsigned_byte(file); - } - if (pair >= 0x8000) { - pair -= 0x10000l; - } - return (SIGNED_PAIR) pair; -} - -static UNSIGNED_TRIPLE get_and_buffer_unsigned_triple(FILE *file) -{ - int i; - long triple = 0; - for (i=0; i<3; i++) { - triple = triple*0x100u + get_and_buffer_unsigned_byte(file); - } - return (UNSIGNED_TRIPLE) triple; -} - -static SIGNED_TRIPLE get_and_buffer_signed_triple(FILE *file) -{ - int i; - long triple = 0; - for (i=0; i<3; i++) { - triple = triple*0x100 + get_and_buffer_unsigned_byte(file); - } - if (triple >= 0x800000l) - triple -= 0x1000000l; - return (SIGNED_TRIPLE) triple; -} - -static SIGNED_QUAD get_and_buffer_signed_quad(FILE *file) -{ - int byte, i; - long quad = 0; - - /* Check sign on first byte before reading others */ - byte = get_and_buffer_unsigned_byte(file); - quad = byte; - if (quad >= 0x80) - quad = byte - 0x100; - for (i=0; i<3; i++) { - quad = quad*0x100 + get_and_buffer_unsigned_byte(file); - } - return (SIGNED_QUAD) quad; -} - -static UNSIGNED_QUAD get_and_buffer_unsigned_quad(FILE *file) -{ - int i; - unsigned long quad = 0; - for (i=0; i<4; i++) { - quad = quad*0x100u + get_and_buffer_unsigned_byte(file); - } - return (UNSIGNED_QUAD) quad; -} +#endif static void get_and_buffer_bytes(FILE *file, unsigned int count) { @@ -303,15 +244,7 @@ static UNSIGNED_BYTE get_buffered_unsigned_byte (void) return dvi_page_buffer[dvi_page_buf_index++]; } -static SIGNED_BYTE get_buffered_signed_byte (void) -{ - int byte; - byte = dvi_page_buffer[dvi_page_buf_index++]; - if (byte >= 0x80) - byte -= 0x100; - return (SIGNED_BYTE) byte; -} - +#ifdef XETEX static UNSIGNED_PAIR get_buffered_unsigned_pair (void) { int i; @@ -323,41 +256,7 @@ static UNSIGNED_PAIR get_buffered_unsigned_pair (void) } return pair; } - -static SIGNED_PAIR get_buffered_signed_pair (void) -{ - int i; - long pair = 0; - for (i=0; i<2; i++) { - pair = pair*0x100 + dvi_page_buffer[dvi_page_buf_index++]; - } - if (pair >= 0x8000) { - pair -= 0x10000l; - } - return (SIGNED_PAIR) pair; -} - -static UNSIGNED_TRIPLE get_buffered_unsigned_triple(void) -{ - int i; - long triple = 0; - for (i=0; i<3; i++) { - triple = triple*0x100u + dvi_page_buffer[dvi_page_buf_index++]; - } - return (UNSIGNED_TRIPLE) triple; -} - -static SIGNED_TRIPLE get_buffered_signed_triple(void) -{ - int i; - long triple = 0; - for (i=0; i<3; i++) { - triple = triple*0x100 + dvi_page_buffer[dvi_page_buf_index++]; - } - if (triple >= 0x800000l) - triple -= 0x1000000l; - return (SIGNED_TRIPLE) triple; -} +#endif static SIGNED_QUAD get_buffered_signed_quad(void) { @@ -375,16 +274,36 @@ static SIGNED_QUAD get_buffered_signed_quad(void) return (SIGNED_QUAD) quad; } -static UNSIGNED_QUAD get_buffered_unsigned_quad(void) +static SIGNED_QUAD get_buffered_signed_num(unsigned char num) { - int i; - unsigned long quad = 0; - for (i=0; i<4; i++) { - quad = quad*0x100u + dvi_page_buffer[dvi_page_buf_index++]; + long quad = dvi_page_buffer[dvi_page_buf_index++]; + if (quad > 0x7f) + quad -= 0x100; + switch (num) { + case 3: quad = quad * 0x100 + dvi_page_buffer[dvi_page_buf_index++]; + case 2: quad = quad * 0x100 + dvi_page_buffer[dvi_page_buf_index++]; + case 1: quad = quad * 0x100 + dvi_page_buffer[dvi_page_buf_index++]; + default: break; + } + return (SIGNED_QUAD) quad; +} + +static UNSIGNED_QUAD get_buffered_unsigned_num(unsigned char num) +{ + unsigned long quad = dvi_page_buffer[dvi_page_buf_index++]; + switch (num) { + case 3: quad = quad * 0x100u + dvi_page_buffer[dvi_page_buf_index++]; + if (quad > 0x7fff) + WARN("Unsigned number starting with %x exceeds 0x7fffffff", quad); + case 2: quad = quad * 0x100u + dvi_page_buffer[dvi_page_buf_index++]; + case 1: quad = quad * 0x100u + dvi_page_buffer[dvi_page_buf_index++]; + default: break; } return (UNSIGNED_QUAD) quad; } +#define skip_bufferd_bytes(n) dvi_page_buf_index += n + void dvi_set_verbose (void) { @@ -1303,24 +1222,6 @@ dvi_dir (UNSIGNED_BYTE dir) } static void -do_set1 (void) -{ - dvi_set(get_buffered_unsigned_byte()); -} - -static void -do_set2 (void) -{ - dvi_set(get_buffered_unsigned_pair()); -} - -static void -do_set3 (void) -{ - dvi_set(get_buffered_unsigned_triple()); -} - -static void do_setrule (void) { SIGNED_QUAD width, height; @@ -1363,24 +1264,6 @@ do_putrule (void) } } -static void -do_put1 (void) -{ - dvi_put(get_buffered_unsigned_byte()); -} - -static void -do_put2 (void) -{ - dvi_put(get_buffered_unsigned_pair()); -} - -static void -do_put3 (void) -{ - dvi_put(get_buffered_unsigned_triple()); -} - void dvi_push (void) { @@ -1402,30 +1285,6 @@ dvi_pop (void) } -static void -do_right1 (void) -{ - dvi_right(get_buffered_signed_byte()); -} - -static void -do_right2 (void) -{ - dvi_right(get_buffered_signed_pair()); -} - -static void -do_right3 (void) -{ - dvi_right(get_buffered_signed_triple()); -} - -static void -do_right4 (void) -{ - dvi_right(get_buffered_signed_quad()); -} - void dvi_w (SIGNED_QUAD ch) { @@ -1439,30 +1298,6 @@ dvi_w0 (void) dvi_right(dvi_state.w); } -static void -do_w1 (void) -{ - dvi_w(get_buffered_signed_byte()); -} - -static void -do_w2 (void) -{ - dvi_w(get_buffered_signed_pair()); -} - -static void -do_w3 (void) -{ - dvi_w(get_buffered_signed_triple()); -} - -static void -do_w4 (void) -{ - dvi_w(get_buffered_signed_quad()); -} - void dvi_x (SIGNED_QUAD ch) { @@ -1476,54 +1311,6 @@ dvi_x0 (void) dvi_right(dvi_state.x); } -static void -do_x1 (void) -{ - dvi_x(get_buffered_signed_byte()); -} - -static void -do_x2 (void) -{ - dvi_x(get_buffered_signed_pair()); -} - -static void -do_x3 (void) -{ - dvi_x(get_buffered_signed_triple()); -} - -static void -do_x4 (void) -{ - dvi_x(get_buffered_signed_quad()); -} - -static void -do_down1 (void) -{ - dvi_down(get_buffered_signed_byte()); -} - -static void -do_down2 (void) -{ - dvi_down(get_buffered_signed_pair()); -} - -static void -do_down3 (void) -{ - dvi_down(get_buffered_signed_triple()); -} - -static void -do_down4 (void) -{ - dvi_down(get_buffered_signed_quad()); -} - void dvi_y (SIGNED_QUAD ch) { @@ -1537,30 +1324,6 @@ dvi_y0 (void) dvi_down(dvi_state.y); } -static -void do_y1 (void) -{ - dvi_y(get_buffered_signed_byte()); -} - -static -void do_y2 (void) -{ - dvi_y(get_buffered_signed_pair()); -} - -static -void do_y3 (void) -{ - dvi_y(get_buffered_signed_triple()); -} - -static -void do_y4 (void) -{ - dvi_y(get_buffered_signed_quad()); -} - void dvi_z (SIGNED_QUAD ch) { @@ -1575,30 +1338,6 @@ dvi_z0 (void) } static void -do_z1 (void) -{ - dvi_z(get_buffered_signed_byte()); -} - -static void -do_z2 (void) -{ - dvi_z(get_buffered_signed_pair()); -} - -static void -do_z3 (void) -{ - dvi_z(get_buffered_signed_triple()); -} - -static void -do_z4 (void) -{ - dvi_z(get_buffered_signed_quad()); -} - -static void skip_fntdef (void) { int area_len, name_len, i; @@ -1697,42 +1436,6 @@ do_fnt (SIGNED_QUAD tex_id) } static void -do_fnt1 (void) -{ - SIGNED_QUAD tex_id; - - tex_id = get_buffered_unsigned_byte(); - do_fnt(tex_id); -} - -static void -do_fnt2 (void) -{ - SIGNED_QUAD tex_id; - - tex_id = get_buffered_unsigned_pair(); - do_fnt(tex_id); -} - -static void -do_fnt3 (void) -{ - SIGNED_QUAD tex_id; - - tex_id = get_buffered_unsigned_triple(); - do_fnt(tex_id); -} - -static void -do_fnt4 (void) -{ - SIGNED_QUAD tex_id; - - tex_id = get_buffered_signed_quad(); - do_fnt(tex_id); -} - -static void do_xxx (UNSIGNED_QUAD size) { if (lr_mode < SKIMMING) @@ -1741,42 +1444,6 @@ do_xxx (UNSIGNED_QUAD size) } static void -do_xxx1 (void) -{ - SIGNED_QUAD size; - - size = get_buffered_unsigned_byte(); - do_xxx(size); -} - -static void -do_xxx2 (void) -{ - SIGNED_QUAD size; - - size = get_buffered_unsigned_pair(); - do_xxx(size); -} - -static void -do_xxx3 (void) -{ - SIGNED_QUAD size; - - size = get_buffered_unsigned_triple(); - do_xxx(size); -} - -static void -do_xxx4 (void) -{ - SIGNED_QUAD size; - - size = get_buffered_unsigned_quad(); - do_xxx(size); -} - -static void do_bop (void) { int i; @@ -1786,12 +1453,12 @@ do_bop (void) /* For now, ignore TeX's count registers */ for (i = 0; i < 10; i++) { - get_buffered_signed_quad(); + skip_bufferd_bytes(4); } /* Ignore previous page pointer since we have already * saved this information */ - get_buffered_signed_quad(); + skip_bufferd_bytes(4); clear_state(); processing_page = 1; @@ -1909,9 +1576,9 @@ skip_glyphs (void) unsigned int i, slen = 0; slen = (unsigned int) get_buffered_unsigned_pair(); for (i = 0; i < slen; i++) { - get_buffered_signed_quad(); - get_buffered_signed_quad(); - get_buffered_unsigned_pair(); + skip_bufferd_bytes(4); + skip_bufferd_bytes(4); + skip_bufferd_bytes(2); } } @@ -2042,9 +1709,8 @@ dvi_do_page (double page_paper_height, double hmargin, double vmargin) } switch (opcode) { - case SET1: do_set1(); break; - case SET2: do_set2(); break; - case SET3: do_set3(); break; + case SET1: case SET2: case SET3: + dvi_set(get_buffered_unsigned_num(opcode-SET1)); break; case SET4: ERROR("Multibyte (>24 bits) character not supported!"); break; @@ -2053,9 +1719,8 @@ dvi_do_page (double page_paper_height, double hmargin, double vmargin) do_setrule(); break; - case PUT1: do_put1(); break; - case PUT2: do_put2(); break; - case PUT3: do_put3(); break; + case PUT1: case PUT2: case PUT3: + dvi_put(get_buffered_unsigned_num(opcode-PUT1)); break; case PUT4: ERROR("Multibyte (>24 bits) character not supported!"); break; @@ -2096,50 +1761,34 @@ dvi_do_page (double page_paper_height, double hmargin, double vmargin) dvi_mark_depth(); break; - case RIGHT1: do_right1(); break; - case RIGHT2: do_right2(); break; - case RIGHT3: do_right3(); break; - case RIGHT4: do_right4(); break; + case RIGHT1: case RIGHT2: case RIGHT3: case RIGHT4: + dvi_right(get_buffered_signed_num(opcode-RIGHT1)); break; case W0: dvi_w0(); break; - case W1: do_w1 (); break; - case W2: do_w2 (); break; - case W3: do_w3 (); break; - case W4: do_w4 (); break; + case W1: case W2: case W3: case W4: + dvi_w(get_buffered_signed_num(opcode-W1)); break; case X0: dvi_x0(); break; - case X1: do_x1 (); break; - case X2: do_x2 (); break; - case X3: do_x3 (); break; - case X4: do_x4 (); break; + case X1: case X2: case X3: case X4: + dvi_x(get_buffered_signed_num(opcode-X1)); break; - case DOWN1: do_down1(); break; - case DOWN2: do_down2(); break; - case DOWN3: do_down3(); break; - case DOWN4: do_down4(); break; + case DOWN1: case DOWN2: case DOWN3: case DOWN4: + dvi_down(get_buffered_signed_num(opcode-DOWN1)); break; case Y0: dvi_y0(); break; - case Y1: do_y1 (); break; - case Y2: do_y2 (); break; - case Y3: do_y3 (); break; - case Y4: do_y4 (); break; + case Y1: case Y2: case Y3: case Y4: + dvi_y(get_buffered_signed_num(opcode-Y1)); break; case Z0: dvi_z0(); break; - case Z1: do_z1 (); break; - case Z2: do_z2 (); break; - case Z3: do_z3 (); break; - case Z4: do_z4 (); break; + case Z1: case Z2: case Z3: case Z4: + dvi_z(get_buffered_signed_num(opcode-Z1)); break; - case FNT1: do_fnt1(); break; - case FNT2: do_fnt2(); break; - case FNT3: do_fnt3(); break; - case FNT4: do_fnt4(); break; + case FNT1: case FNT2: case FNT3: case FNT4: + do_fnt((SIGNED_QUAD)get_buffered_unsigned_num(opcode-FNT1)); break; /* Specials */ - case XXX1: do_xxx1(); break; - case XXX2: do_xxx2(); break; - case XXX3: do_xxx3(); break; - case XXX4: do_xxx4(); break; + case XXX1: case XXX2: case XXX3: case XXX4: + do_xxx(get_buffered_unsigned_num(opcode-XXX1)); break; /* Font definition - skipped except in linear mode. */ /* actually, these should not occur! */ @@ -2596,12 +2245,14 @@ dvi_scan_specials (long page_no, continue; else if (opcode == XXX1 || opcode == XXX2 || opcode == XXX3 || opcode == XXX4) { - UNSIGNED_QUAD size; + UNSIGNED_QUAD size = get_and_buffer_unsigned_byte(fp); switch (opcode) { - case XXX1: size = get_and_buffer_unsigned_byte(fp); break; - case XXX2: size = get_and_buffer_unsigned_pair(fp); break; - case XXX3: size = get_and_buffer_unsigned_triple(fp); break; - case XXX4: size = get_and_buffer_unsigned_quad(fp); break; + case XXX4: size = size * 0x100u + get_and_buffer_unsigned_byte(fp); + if (size > 0x7fff) + WARN("Unsigned number starting with %x exceeds 0x7fffffff", size); + case XXX3: size = size * 0x100u + get_and_buffer_unsigned_byte(fp); + case XXX2: size = size * 0x100u + get_and_buffer_unsigned_byte(fp); + default: break; } if (dvi_page_buf_index + size >= dvi_page_buf_size) { dvi_page_buf_size = (dvi_page_buf_index + size + DVI_PAGE_BUF_CHUNK); @@ -2629,22 +2280,22 @@ dvi_scan_specials (long page_no, break; case SET1: case PUT1: case RIGHT1: case DOWN1: case W1: case X1: case Y1: case Z1: case FNT1: - get_and_buffer_unsigned_byte(fp); + get_and_buffer_bytes(fp, 1); break; case SET2: case PUT2: case RIGHT2: case DOWN2: case W2: case X2: case Y2: case Z2: case FNT2: - get_and_buffer_signed_pair(fp); + get_and_buffer_bytes(fp, 2); break; case SET3: case PUT3: case RIGHT3: case DOWN3: case W3: case X3: case Y3: case Z3: case FNT3: - get_and_buffer_signed_triple(fp); + get_and_buffer_bytes(fp, 3); break; case SET4: case PUT4: case RIGHT4: case DOWN4: case W4: case X4: case Y4: case Z4: case FNT4: - get_and_buffer_signed_quad(fp); + get_and_buffer_bytes(fp, 4); break; case SET_RULE: case PUT_RULE: @@ -2658,7 +2309,7 @@ dvi_scan_specials (long page_no, #ifdef XETEX case XDV_GLYPHS: - get_and_buffer_unsigned_quad(fp); /* width */ + get_and_buffer_bytes(fp, 4); /* width */ len = get_and_buffer_unsigned_pair(fp); /* glyph count */ get_and_buffer_bytes(fp, len * 10); /* 2 bytes ID + 8 bytes x,y-location per glyph */ break; @@ -2671,7 +2322,7 @@ dvi_scan_specials (long page_no, break; case PTEXDIR: - get_and_buffer_unsigned_byte(fp); + get_and_buffer_bytes(fp, 1); break; case POST: diff --git a/Build/source/texk/dvipdfm-x/numbers.c b/Build/source/texk/dvipdfm-x/numbers.c index 35f19cd3975..bedc76c6e9e 100644 --- a/Build/source/texk/dvipdfm-x/numbers.c +++ b/Build/source/texk/dvipdfm-x/numbers.c @@ -37,13 +37,6 @@ UNSIGNED_BYTE get_unsigned_byte (FILE *file) return (UNSIGNED_BYTE) ch; } -#if 0 -UNSIGNED_BYTE sget_unsigned_byte (char *s) -{ - return *((unsigned char *) s); -} -#endif - SIGNED_BYTE get_signed_byte (FILE *file) { int byte; @@ -172,59 +165,3 @@ SIGNED_QUAD sqxfw (SIGNED_QUAD sq, fixword fw) return (sign > 0) ? result : result * -1L; } -#if 0 -SIGNED_QUAD axboverc (SIGNED_QUAD n1, SIGNED_QUAD n2, SIGNED_QUAD divide) -{ - int sign = 1; - unsigned long a, b, c, d, ad, bd, bc, ac, e, f, g, h, i, j, o; - unsigned long high, low; - SIGNED_QUAD result = 0; - /* Make positive. */ - if (n1 < 0) { - sign = -sign; - n1 = -n1; - } - if (n2 < 0) { - sign = -sign; - n2 = -n2; - } - if (divide < 0) { - sign = -sign; - divide = -divide; - } - a = ((unsigned long) n1) >> 16u; - b = ((unsigned long) n1) & 0xffffu; - c = ((unsigned long) n2) >> 16u; - d = ((unsigned long) n2) & 0xffffu; - ad = a*d; bd = b*d; bc = b*c; ac = a*c; - e = bd >> 16u; f = bd & 0xffffu; - g = ad >> 16u; h = ad & 0xffffu; - i = bc >> 16u; j = bc & 0xffffu; - o = e+h+j; - high = g+i+(o>>16u)+ac; o &= 0xffffu; - low = (o << 16) + f; - if (high >= divide) - ERROR ("Overflow in axboc"); - { - int k; - for (k=0; k<32; k++) { - high *= 2; - result *= 2; - if (low >= 0x80000000) { - low -= 0x80000000; - high += 1; - } - low *= 2; - if (high > divide) { - high -= divide; - result += 1; - } - } - } - high *= 2; - if (high >= divide) - result += 1; - return (sign>0)?result:-result; -} -#endif - diff --git a/Build/source/texk/dvipdfm-x/numbers.h b/Build/source/texk/dvipdfm-x/numbers.h index 6f03c980d75..06e987ca200 100644 --- a/Build/source/texk/dvipdfm-x/numbers.h +++ b/Build/source/texk/dvipdfm-x/numbers.h @@ -25,17 +25,29 @@ #include <stdio.h> #include <math.h> +#ifdef HAVE_INTTYPES_H +# include <inttypes.h> +#endif +#ifdef HAVE_STDINT_H +# include <stdint.h> +#endif + +/* When reading numbers from binary files 1, 2, or 3 bytes are + interpreted as either signed or unsigned. + + Four bytes from DVI, PK, TFM, or VF files always yield a signed + 32-bit integer (int32_t), but some of them must not be negative. + + Four byte numbers from JPEG2000, OpenType, or TrueType files are + mostly unsigned (uint32_t) and occasionally signed (int32_t). +*/ -typedef unsigned char Ubyte; typedef int UNSIGNED_BYTE, SIGNED_BYTE, SIGNED_PAIR; typedef unsigned UNSIGNED_PAIR; typedef long UNSIGNED_TRIPLE, SIGNED_TRIPLE, SIGNED_QUAD; typedef unsigned long UNSIGNED_QUAD; extern UNSIGNED_BYTE get_unsigned_byte (FILE *); -#if 0 -extern UNSIGNED_BYTE sget_unsigned_byte (char *); -#endif extern SIGNED_BYTE get_signed_byte (FILE *); extern UNSIGNED_PAIR get_unsigned_pair (FILE *); extern UNSIGNED_PAIR sget_unsigned_pair (unsigned char *); @@ -48,9 +60,6 @@ extern UNSIGNED_QUAD get_unsigned_quad (FILE *); typedef signed long fixword; extern SIGNED_QUAD sqxfw (SIGNED_QUAD sq, fixword fw); -#if 0 -extern SIGNED_QUAD axboverc (SIGNED_QUAD n1, SIGNED_QUAD n2, SIGNED_QUAD divide); -#endif #ifndef MAX # define MAX(a,b) ((a)>(b)?(a):(b)) diff --git a/Build/source/texk/dvipdfm-x/vf.c b/Build/source/texk/dvipdfm-x/vf.c index 6b16e98b816..0adc286c648 100644 --- a/Build/source/texk/dvipdfm-x/vf.c +++ b/Build/source/texk/dvipdfm-x/vf.c @@ -762,14 +762,14 @@ static void vf_fnt4(unsigned char **start, unsigned char *end, /* identical to do_xxx in dvi.c */ static void vf_xxx (SIGNED_QUAD len, unsigned char **start, unsigned char *end) { - Ubyte *buffer; + unsigned char *buffer; if (*start <= end - len) { - buffer = NEW(len+1, Ubyte); + buffer = NEW(len+1, unsigned char); memcpy(buffer, *start, len); buffer[len] = '\0'; { - Ubyte *p = buffer; + unsigned char *p = buffer; while (p < buffer+len && *p == ' ') p++; /* |