diff --git a/source/texk/web2c/luatexdir/dvi/dvigen.c b/source/texk/web2c/luatexdir/dvi/dvigen.c index d42a77aa7c87fd7babd13ec79d5fe091b72fe4ab..2a4f50015b6e067a36db0de25abe276b13001787 100644 --- a/source/texk/web2c/luatexdir/dvi/dvigen.c +++ b/source/texk/web2c/luatexdir/dvi/dvigen.c @@ -889,7 +889,7 @@ void movement(scaled w, eight_bits o) k = location(p) - dvi_offset; if (k < 0) k = k + dvi_buf_size; - dvi_buf[k] = dvi_buf[k] + y1 - down1; + dvi_buf[k] = (eight_bits) (dvi_buf[k] + y1 - down1); vinfo(p) = y_here; goto FOUND; } @@ -904,7 +904,7 @@ void movement(scaled w, eight_bits o) k = location(p) - dvi_offset; if (k < 0) k = k + dvi_buf_size; - dvi_buf[k] = dvi_buf[k] + z1 - down1; + dvi_buf[k] = (eight_bits) (dvi_buf[k] + z1 - down1); vinfo(p) = z_here; goto FOUND; } @@ -1114,7 +1114,7 @@ void dvi_special(PDF pdf, halfword p) dvi_out(cur_length); } else { dvi_out(xxx4); - dvi_four(cur_length); + dvi_four((int) cur_length); } for (k = 0; k < cur_length; k++) dvi_out(cur_string[k]); @@ -1277,7 +1277,7 @@ void ensure_dvi_header_written(PDF pdf) prepare_mag(); dvi_four(mag); /* magnification factor is frozen */ if (output_comment) { - l = strlen(output_comment); + l = (unsigned) strlen(output_comment); dvi_out(l); for (s = 0; s <= l - 1; s++) dvi_out(output_comment[s]); diff --git a/source/texk/web2c/luatexdir/dvi/dvigen.h b/source/texk/web2c/luatexdir/dvi/dvigen.h index f26e2d797807a10c4ab252aeae96101c10e644f7..10dae335d4620e4481e5fbda672949c4cd09e319 100644 --- a/source/texk/web2c/luatexdir/dvi/dvigen.h +++ b/source/texk/web2c/luatexdir/dvi/dvigen.h @@ -51,7 +51,7 @@ each time, we use the macro |dvi_out|. */ # define dvi_out(A) do { \ - dvi_buf[dvi_ptr++]=A; \ + dvi_buf[dvi_ptr++]=(eight_bits)(A); \ if (dvi_ptr==dvi_limit) dvi_swap(); \ } while (0) diff --git a/source/texk/web2c/luatexdir/font/dofont.c b/source/texk/web2c/luatexdir/font/dofont.c index 85ad0fb0a0d1a340aaddba4edc14102ab14c2d18..12a41847c3979e72317320e15447159bbf148b70 100644 --- a/source/texk/web2c/luatexdir/font/dofont.c +++ b/source/texk/web2c/luatexdir/font/dofont.c @@ -30,7 +30,7 @@ static char *font_error_message(pointer u, char *nom, scaled s) { char *str = xmalloc(256); char *c = makecstring(cs_text(u)); - char *extra = "metric data not found or bad"; + const char *extra = "metric data not found or bad"; if (s >= 0) { snprintf(str, 255, "Font \\%s=%s at %gpt not loadable: %s", c, nom, (double) s / 65536, extra); @@ -44,7 +44,7 @@ static char *font_error_message(pointer u, char *nom, scaled s) return str; } -static int do_define_font(int f, char *cnom, scaled s, int natural_dir) +static int do_define_font(int f, const char *cnom, scaled s, int natural_dir) { boolean res; /* was the callback successful? */ diff --git a/source/texk/web2c/luatexdir/font/luafont.c b/source/texk/web2c/luatexdir/font/luafont.c index bb74cc7cf549480fcbf17662e7b4392ae32db9c5..3f30a7f36d6570c526b81a59377dbba03ac0d176 100644 --- a/source/texk/web2c/luatexdir/font/luafont.c +++ b/source/texk/web2c/luatexdir/font/luafont.c @@ -29,7 +29,8 @@ static const char _svn_version[] = const char *font_type_strings[] = { "unknown", "virtual", "real", NULL }; const char *font_format_strings[] = { "unknown", "type1", "type3", "truetype", "opentype", NULL }; -const char *font_embedding_strings[] = { "unknown", "no", "subset", "full", NULL }; +const char *font_embedding_strings[] = + { "unknown", "no", "subset", "full", NULL }; const char *ligature_type_strings[] = { "=:", "=:|", "|=:", "|=:|", "", "=:|>", "|=:>", "|=:|>", "", "", "", @@ -585,7 +586,8 @@ static int n_numeric_field(lua_State * L, int name_index, int dflt) } -static int enum_field(lua_State * L, const char *name, int dflt, const char **values) +static int enum_field(lua_State * L, const char *name, int dflt, + const char **values) { int k; const char *s; @@ -831,7 +833,7 @@ static int count_char_packet_bytes(lua_State * L) (void) lua_tolstring(L, -1, &len); lua_pop(L, 1); if (len > 0) { - l = (int)(l + 5 + (int)len); + l = (int) (l + 5 + (int) len); } } else if (luaS_ptr_eq(s, image)) { l += 5; @@ -878,7 +880,7 @@ read_char_packets(lua_State * L, int *l_fonts, charinfo * co, int atsize) while (l_fonts[(max_f + 1)] != 0) max_f++; - cpackets = xmalloc((unsigned)(pc + 1)); + cpackets = xmalloc((unsigned) (pc + 1)); for (i = 1; i <= (int) lua_objlen(L, -1); i++) { lua_rawgeti(L, -1, i); if (lua_istable(L, -1)) { @@ -899,10 +901,10 @@ read_char_packets(lua_State * L, int *l_fonts, charinfo * co, int atsize) } else if (luaS_ptr_eq(s, slot)) { cmd = packet_nop_code; lua_rawgeti(L, -2, 2); - n = (int)lua_tointeger(L, -1); + n = (int) lua_tointeger(L, -1); ff = (n > max_f ? l_fonts[1] : l_fonts[n]); lua_rawgeti(L, -3, 3); - n = (int)lua_tointeger(L, -1); + n = (int) lua_tointeger(L, -1); lua_pop(L, 2); append_packet(packet_font_code); do_store_four(ff); @@ -936,7 +938,7 @@ read_char_packets(lua_State * L, int *l_fonts, charinfo * co, int atsize) case packet_font_code: append_packet(cmd); lua_rawgeti(L, -2, 2); - n = (int)lua_tointeger(L, -1); + n = (int) lua_tointeger(L, -1); ff = (n > max_f ? l_fonts[1] : l_fonts[n]); do_store_four(ff); lua_pop(L, 1); @@ -951,7 +953,7 @@ read_char_packets(lua_State * L, int *l_fonts, charinfo * co, int atsize) case packet_char_code: append_packet(cmd); lua_rawgeti(L, -2, 2); - n = (int)lua_tointeger(L, -1); + n = (int) lua_tointeger(L, -1); do_store_four(n); lua_pop(L, 1); break; @@ -959,17 +961,17 @@ read_char_packets(lua_State * L, int *l_fonts, charinfo * co, int atsize) case packet_down_code: append_packet(cmd); lua_rawgeti(L, -2, 2); - n = (int)lua_tointeger(L, -1); + n = (int) lua_tointeger(L, -1); do_store_four(sp_to_dvi(n, atsize)); lua_pop(L, 1); break; case packet_rule_code: append_packet(cmd); lua_rawgeti(L, -2, 2); - n = (int)lua_tointeger(L, -1); + n = (int) lua_tointeger(L, -1); do_store_four(sp_to_dvi(n, atsize)); lua_rawgeti(L, -3, 3); - n = (int)lua_tointeger(L, -1); + n = (int) lua_tointeger(L, -1); do_store_four(sp_to_dvi(n, atsize)); lua_pop(L, 2); break; @@ -1075,7 +1077,7 @@ static void read_lua_parameters(lua_State * L, int f) lua_pushnil(L); /* first key */ while (lua_next(L, -2) != 0) { if (lua_isnumber(L, -2)) { - i = (int)lua_tointeger(L, -2); + i = (int) lua_tointeger(L, -2); if (i >= 8) { n = (lua_isnumber(L, -1) ? lua_roundnumber(L, -1) : 0); set_font_param(f, i, n); @@ -1135,7 +1137,7 @@ static void store_math_kerns(lua_State * L, charinfo * co, int id) { int l, k, i; scaled ht, krn; - if (lua_istable(L, -1) && ((k = (int)lua_objlen(L, -1)) > 0)) { + if (lua_istable(L, -1) && ((k = (int) lua_objlen(L, -1)) > 0)) { for (l = 0; l < k; l++) { lua_rawgeti(L, -1, (l + 1)); if (lua_istable(L, -1)) { @@ -1199,9 +1201,15 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i, k = n_boolean_field(L, luaS_used_index, 0); set_charinfo_used(co, k); s = n_string_field(L, luaS_name_index, NULL); - set_charinfo_name(co, s); + if (s != NULL) + set_charinfo_name(co, xstrdup(s)); + else + set_charinfo_name(co, NULL); s = n_string_field(L, luaS_tounicode_index, NULL); - set_charinfo_tounicode(co, s); + if (s != NULL) + set_charinfo_tounicode(co, xstrdup(s)); + else + set_charinfo_tounicode(co, NULL); if (has_math) { j = n_numeric_field(L, luaS_top_accent_index, 0); @@ -1316,7 +1324,7 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i, /* end of |has_math| */ nk = count_hash_items(L, luaS_index(kerns)); if (nk > 0) { - ckerns = xcalloc((unsigned)(nk + 1), sizeof(kerninfo)); + ckerns = xcalloc((unsigned) (nk + 1), sizeof(kerninfo)); lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(kerns)); lua_rawget(L, -2); if (lua_istable(L, -1)) { /* there are kerns */ @@ -1378,7 +1386,7 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i, nl = count_hash_items(L, luaS_index(ligatures)); if (nl > 0) { - cligs = xcalloc((unsigned)(nl + 1), sizeof(liginfo)); + cligs = xcalloc((unsigned) (nl + 1), sizeof(liginfo)); lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(ligatures)); lua_rawget(L, -2); if (lua_istable(L, -1)) { /* do ligs */ @@ -1407,7 +1415,8 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i, } if (r != -1 && k != non_boundarychar) { t = enum_field(L, "type", 0, ligature_type_strings); - set_ligature_item(cligs[ctr], (char)((t * 2) + 1), k, r); + set_ligature_item(cligs[ctr], (char) ((t * 2) + 1), k, + r); ctr++; } else { pdftex_warn @@ -1487,13 +1496,13 @@ int font_from_lua(lua_State * L, int f) i = numeric_field(L, "size", font_dsize(f)); set_font_size(f, i); i = numeric_field(L, "checksum", 0); - set_font_checksum(f, (unsigned)i); + set_font_checksum(f, (unsigned) i); i = numeric_field(L, "direction", 0); set_font_natural_dir(f, i); i = numeric_field(L, "encodingbytes", 0); - set_font_encodingbytes(f, (char)i); + set_font_encodingbytes(f, (char) i); i = numeric_field(L, "tounicode", 0); - set_font_tounicode(f, (char)i); + set_font_tounicode(f, (char) i); i = numeric_field(L, "extend", 1000); if (i < FONT_EXTEND_MIN) @@ -1513,7 +1522,7 @@ int font_from_lua(lua_State * L, int f) i = numeric_field(L, "skewchar", int_par(default_skew_char_code)); set_skew_char(f, i); i = boolean_field(L, "used", 0); - set_font_used(f, (char)i); + set_font_used(f, (char) i); s = string_field(L, "attributes", NULL); if (s != NULL && strlen(s) > 0) { @@ -1536,8 +1545,8 @@ int font_from_lua(lua_State * L, int f) /* now fetch the base fonts, if needed */ n = count_hash_items(L, luaS_index(fonts)); if (n > 0) { - l_fonts = xmalloc((unsigned)((unsigned)(n + 2) * sizeof(int))); - memset(l_fonts, 0, (size_t)((unsigned)(n + 2) * sizeof(int))); + l_fonts = xmalloc((unsigned) ((unsigned) (n + 2) * sizeof(int))); + memset(l_fonts, 0, (size_t) ((unsigned) (n + 2) * sizeof(int))); lua_rawgeti(L, LUA_REGISTRYINDEX, luaS_index(fonts)); lua_rawget(L, -2); for (i = 1; i <= n; i++) { @@ -1609,7 +1618,7 @@ int font_from_lua(lua_State * L, int f) lua_pushnil(L); /* first key */ while (lua_next(L, -2) != 0) { if (lua_isnumber(L, -2)) { - i = (int)lua_tointeger(L, -2); + i = (int) lua_tointeger(L, -2); if (i >= 0) { if (lua_istable(L, -1)) { num++; diff --git a/source/texk/web2c/luatexdir/font/mapfile.c b/source/texk/web2c/luatexdir/font/mapfile.c index 69f0d7b510c5cef45ccb007cade46bfee4772e44..8b45c035ba45c17f7a9a79ccd16bd3ce4367ed68 100644 --- a/source/texk/web2c/luatexdir/font/mapfile.c +++ b/source/texk/web2c/luatexdir/font/mapfile.c @@ -332,6 +332,7 @@ int check_std_t1font(char *s) static void fm_scan_line(void) { int a, b, c, j, u = 0, v = 0; + char cc; float d; fm_entry *fm; char fm_line[FM_BUF_SIZE], buf[FM_BUF_SIZE]; @@ -342,12 +343,12 @@ static void fm_scan_line(void) while (!fm_eof()) { if (fm_curbyte == fm_size) { fm_curbyte++; - c = 10; + cc = 10; } else { - c = fm_getchar(); + cc = (char) fm_getchar(); } - append_char_to_buf(c, p, fm_line, FM_BUF_SIZE); - if (c == 10) + append_char_to_buf(cc, p, fm_line, FM_BUF_SIZE); + if (cc == 10) break; } *(--p) = '\0'; @@ -391,12 +392,12 @@ static void fm_scan_line(void) if (*(s - 1) == 'E' || *(s - 1) == 'e') s--; /* e. g. 0.5ExtendFont: %f = 0.5E */ if (str_prefix(s, "SlantFont")) { - d *= 1000.0; /* correct rounding also for neg. numbers */ + d *= (float) 1000.0; /* correct rounding also for neg. numbers */ fm->slant = (int) (d > 0 ? d + 0.5 : d - 0.5); set_slantset(fm); r = s + strlen("SlantFont"); } else if (str_prefix(s, "ExtendFont")) { - d *= 1000.0; + d *= (float) 1000.0; fm->extend = (int) (d > 0 ? d + 0.5 : d - 0.5); set_extendset(fm); r = s + strlen("ExtendFont"); @@ -407,7 +408,7 @@ static void fm_scan_line(void) pdftex_warn ("invalid entry for `%s': unknown name `%s' ignored", fm->tfm_name, s); - *r = c; + *r = (char) c; } } else for (; *r != ' ' && *r != '"' && *r != '\0'; r++); @@ -424,8 +425,8 @@ static void fm_scan_line(void) break; case 'P': /* handle cases for subfonts like 'PidEid=3,1' */ if (sscanf(r, "PidEid=%i, %i %n", &a, &b, &c) >= 2) { - fm->pid = a; - fm->eid = b; + fm->pid = (short) a; + fm->eid = (short) b; r += c; break; } @@ -648,7 +649,7 @@ void pdfmapline(int t) free(s); } -void pdf_init_map_file(const char *map_name) +void pdf_init_map_file(char *map_name) { assert(mitem == NULL); mitem = xtalloc(1, mapitem); diff --git a/source/texk/web2c/luatexdir/font/mapfile.h b/source/texk/web2c/luatexdir/font/mapfile.h index b66eebde2e25ef2c9da4e0d1ea821a6346316cb3..1f2c27b783765e5b5d6532eba794a3255d2a68c1 100644 --- a/source/texk/web2c/luatexdir/font/mapfile.h +++ b/source/texk/web2c/luatexdir/font/mapfile.h @@ -36,29 +36,29 @@ typedef enum { MAPFILE, MAPLINE } maptype; -# define set_included(fm) ((fm)->type |= F_INCLUDED) -# define set_subsetted(fm) ((fm)->type |= F_SUBSETTED) -# define set_std_t1font(fm) ((fm)->type |= F_STDT1FONT) -# define set_subfont(fm) ((fm)->type |= F_SUBFONT) -# define set_type1(fm) ((fm)->type |= F_TYPE1) -# define set_truetype(fm) ((fm)->type |= F_TRUETYPE) -# define set_opentype(fm) ((fm)->type |= F_OTF) -# define set_cidkeyed(fm) ((fm)->type |= F_CIDKEYED) -# define set_slantset(fm) ((fm)->type |= F_SLANTSET) -# define set_extendset(fm) ((fm)->type |= F_EXTENDSET) -# define set_inuse(fm) ((fm)->type |= F_INUSE) - -# define unset_included(fm) ((fm)->type &= ~F_INCLUDED) -# define unset_subsetted(fm) ((fm)->type &= ~F_SUBSETTED) -# define unset_std_t1font(fm)((fm)->type &= ~F_STDT1FONT) -# define unset_subfont(fm) ((fm)->type &= ~F_SUBFONT) -# define unset_type1(fm) ((fm)->type &= ~F_TYPE1) -# define unset_truetype(fm) ((fm)->type &= ~F_TRUETYPE) -# define unset_opentype(fm) ((fm)->type &= ~F_OTF) -# define unset_cidkeyed(fm) ((fm)->type &= ~F_CIDKEYED) -# define unset_slantset(fm) ((fm)->type &= ~F_SLANTSET) -# define unset_extendset(fm) ((fm)->type &= ~F_EXTENDSET) -# define unset_inuse(fm) ((fm)->type &= ~F_INUSE) +# define set_included(fm) ((fm)->type = (unsigned short)((fm)->type | F_INCLUDED)) +# define set_subsetted(fm) ((fm)->type = (unsigned short)((fm)->type | F_SUBSETTED)) +# define set_std_t1font(fm) ((fm)->type = (unsigned short)((fm)->type | F_STDT1FONT)) +# define set_subfont(fm) ((fm)->type = (unsigned short)((fm)->type | F_SUBFONT)) +# define set_type1(fm) ((fm)->type = (unsigned short)((fm)->type | F_TYPE1)) +# define set_truetype(fm) ((fm)->type = (unsigned short)((fm)->type | F_TRUETYPE)) +# define set_opentype(fm) ((fm)->type = (unsigned short)((fm)->type | F_OTF)) +# define set_cidkeyed(fm) ((fm)->type = (unsigned short)((fm)->type | F_CIDKEYED)) +# define set_slantset(fm) ((fm)->type = (unsigned short)((fm)->type | F_SLANTSET)) +# define set_extendset(fm) ((fm)->type = (unsigned short)((fm)->type | F_EXTENDSET)) +# define set_inuse(fm) ((fm)->type = (unsigned short)((fm)->type | F_INUSE)) + +# define unset_included(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_INCLUDED)) +# define unset_subsetted(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_SUBSETTED)) +# define unset_std_t1font(fm)((fm)->type = (unsigned short)((fm)->type & ~F_STDT1FONT)) +# define unset_subfont(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_SUBFONT)) +# define unset_type1(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_TYPE1)) +# define unset_truetype(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_TRUETYPE)) +# define unset_opentype(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_OTF)) +# define unset_cidkeyed(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_CIDKEYED)) +# define unset_slantset(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_SLANTSET)) +# define unset_extendset(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_EXTENDSET)) +# define unset_inuse(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_INUSE)) # define is_included(fm) (((fm)->type & F_INCLUDED) != 0) # define is_subsetted(fm) (((fm)->type & F_SUBSETTED) != 0) @@ -119,7 +119,7 @@ void fm_free(void); ff_entry *check_ff_exist(char *, boolean); void pdfmapfile(int); void pdfmapline(int); -void pdf_init_map_file(const char *map_name); +void pdf_init_map_file(char *map_name); fm_entry *new_fm_entry(void); void delete_fm_entry(fm_entry *); int avl_do_entry(fm_entry *, int); diff --git a/source/texk/web2c/luatexdir/font/pkin.c b/source/texk/web2c/luatexdir/font/pkin.c index 0aa35d0456c941d244d57dc4b2e350e0e39d35fc..66b6d053f9d2daa65cae40901e1ea6c7590b374b 100644 --- a/source/texk/web2c/luatexdir/font/pkin.c +++ b/source/texk/web2c/luatexdir/font/pkin.c @@ -124,7 +124,7 @@ static shalfword getnyb(void) bitweight = 0; temp = inputbyte & 15; } - return (temp); + return (shalfword) (temp); } static boolean getbit(void) @@ -191,7 +191,7 @@ static halfword rest(void) pk_remainder = 4000 - pk_remainder; return (4000); } else { - i = pk_remainder; + i = (halfword) pk_remainder; pk_remainder = 0; realfunc = pkpackednum; return (i); @@ -234,14 +234,14 @@ static void unpack(chardesc * cd) halfword count; shalfword wordwidth; - wordwidth = (cd->cwidth + 15) / 16; - i = 2 * cd->cheight * (long) wordwidth; + wordwidth = (shalfword) ((cd->cwidth + 15) / 16); + i = (int) (2 * cd->cheight * (long) wordwidth); if (i <= 0) i = 2; if (i > cd->rastersize) { xfree(cd->raster); cd->rastersize = i; - cd->raster = xtalloc(cd->rastersize, halfword); + cd->raster = xtalloc((unsigned) cd->rastersize, halfword); } raster = cd->raster; realfunc = pkpackednum; @@ -266,8 +266,8 @@ static void unpack(chardesc * cd) *raster++ = word; } } else { - rowsleft = cd->cheight; - hbit = cd->cwidth; + rowsleft = (shalfword) cd->cheight; + hbit = (shalfword) cd->cwidth; repeatcount = 0; wordweight = 16; word = 0; @@ -284,7 +284,7 @@ static void unpack(chardesc * cd) if ((count < wordweight) && (count < hbit)) { if (turnon) word += gpower[wordweight] - gpower[wordweight - count]; - hbit -= count; + hbit = (shalfword) (hbit - count); wordweight -= count; count = 0; } else if ((count >= hbit) && (hbit <= wordweight)) { @@ -297,19 +297,19 @@ static void unpack(chardesc * cd) raster++; } } - rowsleft -= repeatcount + 1; + rowsleft = (shalfword) (rowsleft - repeatcount + 1); repeatcount = 0; word = 0; wordweight = 16; count -= hbit; - hbit = cd->cwidth; + hbit = (shalfword) cd->cwidth; } else { if (turnon) word += gpower[wordweight]; *raster++ = word; word = 0; count -= wordweight; - hbit -= wordweight; + hbit = (shalfword) (hbit - wordweight); wordweight = 16; } } @@ -380,8 +380,8 @@ int readchar(boolean check_preamble, chardesc * cd) case 4: case 5: case 6: - length = (flagbyte & 3) * 65536L + pkbyte() * 256L; - length = length + pkbyte() - 4L; + length = (int) ((flagbyte & 3) * 65536L + pkbyte() * 256L); + length = (int) (length + pkbyte() - 4L); cd->charcode = pkbyte(); (void) pktrio(); /* TFMwidth */ cd->xescape = pkduo(); /* pixelwidth */ @@ -391,7 +391,7 @@ int readchar(boolean check_preamble, chardesc * cd) cd->yoff = pkduo(); break; case 7: - length = pkquad() - 9L; + length = (int) (pkquad() - 9L); cd->charcode = pkquad(); (void) pkquad(); /* TFMwidth */ cd->xescape = pkquad(); /* pixelwidth */ diff --git a/source/texk/web2c/luatexdir/font/sfnt.c b/source/texk/web2c/luatexdir/font/sfnt.c index 6f43546bdbe5f001c3b78925d7e48498cbd3b671..7dea628d60b7fce4f63e8119e424aa613b68f5b6 100644 --- a/source/texk/web2c/luatexdir/font/sfnt.c +++ b/source/texk/web2c/luatexdir/font/sfnt.c @@ -296,7 +296,7 @@ static unsigned max2floor(unsigned n) val *= 2; } - return val; + return (unsigned) val; } /* @@ -318,12 +318,12 @@ static ULONG sfnt_calc_checksum(void *data, ULONG length) { ULONG chksum = 0; BYTE *p, *endptr; - int count = 0; + ULONG count = 0; p = (BYTE *) data; endptr = p + length; while (p < endptr) { - chksum += (p[0] << (8 * (3 - count))); + chksum = chksum + (ULONG) (p[0] << (8 * (3 - count))); count = ((count + 1) & 3); p++; } @@ -419,7 +419,7 @@ ULONG sfnt_locate_table(sfnt * sfont, const char *tag) if (offset == 0) TT_ERROR("sfnt: table not found..."); - sfnt_seek_set(sfont, offset); + sfnt_seek_set(sfont, (long) offset); return offset; } @@ -443,7 +443,7 @@ int sfnt_read_table_directory(sfnt * sfont, ULONG offset) ASSERT(sfont->stream); #endif - sfnt_seek_set(sfont, offset); + sfnt_seek_set(sfont, (long) offset); td->version = sfnt_get_ulong(sfont); td->num_tables = sfnt_get_ushort(sfont); @@ -534,9 +534,9 @@ pdf_obj *sfnt_create_FontFile_stream(sfnt * sfont) /* Header */ p = (char *) wbuf; - p += sfnt_put_ulong(p, td->version); + p += sfnt_put_ulong(p, (LONG) td->version); p += sfnt_put_ushort(p, td->num_kept_tables); - sr = max2floor(td->num_kept_tables) * 16; + sr = (int) (max2floor(td->num_kept_tables) * 16); p += sfnt_put_ushort(p, sr); p += sfnt_put_ushort(p, log2floor(td->num_kept_tables)); p += sfnt_put_ushort(p, td->num_kept_tables * 16 - sr); @@ -557,12 +557,12 @@ pdf_obj *sfnt_create_FontFile_stream(sfnt * sfont) p = (char *) wbuf; memcpy(p, td->tables[i].tag, 4); p += 4; - p += sfnt_put_ulong(p, td->tables[i].check_sum); + p += sfnt_put_ulong(p, (LONG) td->tables[i].check_sum); p += sfnt_put_ulong(p, offset); - p += sfnt_put_ulong(p, td->tables[i].length); + p += sfnt_put_ulong(p, (LONG) td->tables[i].length); pdf_add_stream(stream, wbuf, 16); - offset += td->tables[i].length; + offset = (long) (offset + (long) td->tables[i].length); } } @@ -588,10 +588,10 @@ pdf_obj *sfnt_create_FontFile_stream(sfnt * sfont) return NULL; } - length = td->tables[i].length; - sfnt_seek_set(sfont, td->tables[i].offset); + length = (long) td->tables[i].length; + sfnt_seek_set(sfont, (long) td->tables[i].offset); while (length > 0) { - nb_read = sfnt_read(wbuf, MIN(length, 1024), sfont); + nb_read = sfnt_read(wbuf, (int) MIN(length, 1024), sfont); if (nb_read < 0) { pdf_release_obj(stream); TT_ERROR("Reading file failed..."); @@ -604,12 +604,12 @@ pdf_obj *sfnt_create_FontFile_stream(sfnt * sfont) } else { pdf_add_stream(stream, (unsigned char *) td->tables[i].data, - td->tables[i].length); + (long) td->tables[i].length); RELEASE(td->tables[i].data); td->tables[i].data = NULL; } /* Set offset for next table */ - offset += td->tables[i].length; + offset = (long) (offset + (long) td->tables[i].length); } } diff --git a/source/texk/web2c/luatexdir/font/sfnt.h b/source/texk/web2c/luatexdir/font/sfnt.h index e1be9c801f609c104f87bd2252ecf581adea246a..f6ba6e2e1695dd145538bc0c8703d4442cb05ec4 100644 --- a/source/texk/web2c/luatexdir/font/sfnt.h +++ b/source/texk/web2c/luatexdir/font/sfnt.h @@ -181,8 +181,8 @@ typedef struct { # define ASSERT(a) assert(a) # define RELEASE(a) free(a) -# define NEW(a,b) xmalloc((a)*sizeof(b)) -# define RENEW(a,b,c) xrealloc(a, ((b)*sizeof(c))) +# define NEW(a,b) xmalloc((unsigned)((unsigned)(a)*sizeof(b))) +# define RENEW(a,b,c) xrealloc(a, (unsigned)((unsigned)(b)*sizeof(c))) # define TT_ERROR pdftex_fail # define WARN printf diff --git a/source/texk/web2c/luatexdir/font/subfont.c b/source/texk/web2c/luatexdir/font/subfont.c index ff2f7dc044255d480f82071e0c747ac52299ded4..b91310390fbfa38d6b3e1ccb412c6346546abd7a 100644 --- a/source/texk/web2c/luatexdir/font/subfont.c +++ b/source/texk/web2c/luatexdir/font/subfont.c @@ -96,7 +96,7 @@ void sfd_free(void) static void sfd_getline(boolean expect_eof) { char *p; - int c; + char c; restart: if (sfd_eof()) { if (expect_eof) @@ -106,7 +106,7 @@ static void sfd_getline(boolean expect_eof) } p = sfd_line; do { - c = sfd_getchar(); + c = (char) sfd_getchar(); append_char_to_buf(c, p, sfd_line, SFD_BUF_SIZE); } while (c != 10 && !sfd_eof()); append_eol(p, sfd_line, SFD_BUF_SIZE); @@ -225,7 +225,7 @@ boolean handle_subfont_fm(fm_entry * fm, int mode) if (q <= p || r <= q + 1 /* prefix or sfd name is empty */ || r - p != (int) strlen(p) - 1) /* or the second '@' is not the last char yet */ return false; - l = r - (q + 1); /* length of sfd name */ + l = (size_t) (r - (q + 1)); /* length of sfd name */ strncpy(buf, q + 1, l); buf[l] = 0; check_buf(strlen(buf) + 4, SMALL_BUF_SIZE); @@ -241,7 +241,7 @@ boolean handle_subfont_fm(fm_entry * fm, int mode) fm->pid = 3; fm->eid = 1; } - l = q - p; /* length of base tfm name (prefix) */ + l = (size_t) (q - p); /* length of base tfm name (prefix) */ for (sf = sfd->subfont; sf != NULL; sf = sf->next) { strncpy(buf, p, l); buf[l] = 0; diff --git a/source/texk/web2c/luatexdir/font/texfont.c b/source/texk/web2c/luatexdir/font/texfont.c index 70ccf7f3fe3c44f48c8cee0c667767e91831e32e..24045996edebf6beaffa00d273ebe4176a3807a6 100644 --- a/source/texk/web2c/luatexdir/font/texfont.c +++ b/source/texk/web2c/luatexdir/font/texfont.c @@ -41,7 +41,7 @@ static const char _svn_version[] = #define noDEBUG #define proper_char_index(c) (c<=font_ec(f) && c>=font_bc(f)) -#define do_realloc(a,b,d) a = xrealloc(a,(b)*sizeof(d)) +#define do_realloc(a,b,d) a = xrealloc(a,(unsigned)((unsigned)(b)*sizeof(d))) texfont **font_tables = NULL; @@ -52,8 +52,11 @@ static void grow_font_table(int id) { int j; if (id >= font_arr_max) { - font_bytes += (id + 8 - font_arr_max) * sizeof(texfont *); - font_tables = xrealloc(font_tables, (id + 8) * sizeof(texfont *)); + font_bytes += + (int) (((id + 8 - font_arr_max) * (int) sizeof(texfont *))); + font_tables = + xrealloc(font_tables, + (unsigned) (((unsigned) id + 8) * sizeof(texfont *))); j = 8; while (j--) { font_tables[id + j] = NULL; @@ -93,7 +96,7 @@ int new_font(void) int id; charinfo *ci; id = new_font_id(); - font_bytes += sizeof(texfont); + font_bytes += (int) sizeof(texfont); /* most stuff is zero */ font_tables[id] = xcalloc(1, sizeof(texfont)); font_tables[id]->_font_name = NULL; @@ -135,9 +138,10 @@ int new_font(void) void font_malloc_charinfo(internal_font_number f, int num) { int glyph = font_tables[f]->charinfo_size; - font_bytes += (num * sizeof(charinfo)); - do_realloc(font_tables[f]->charinfo, (glyph + num), charinfo); - memset(&(font_tables[f]->charinfo[glyph]), 0, (num * sizeof(charinfo))); + font_bytes += (int) (num * (int) sizeof(charinfo)); + do_realloc(font_tables[f]->charinfo, (unsigned) (glyph + num), charinfo); + memset(&(font_tables[f]->charinfo[glyph]), 0, + (size_t) (num * (int) sizeof(charinfo))); font_tables[f]->charinfo_size += num; } @@ -151,25 +155,26 @@ charinfo *get_charinfo(internal_font_number f, int c) glyph = get_sa_item(font_tables[f]->characters, c); if (!glyph) { - glyph = ++font_tables[f]->charinfo_count; - if (glyph >= (unsigned) font_tables[f]->charinfo_size) { + int tglyph = ++font_tables[f]->charinfo_count; + if (tglyph >= font_tables[f]->charinfo_size) { font_malloc_charinfo(f, 256); } - font_tables[f]->charinfo[glyph].ef = 1000; /* init */ - set_sa_item(font_tables[f]->characters, c, glyph, 1); /* 1= global */ + font_tables[f]->charinfo[tglyph].ef = 1000; /* init */ + set_sa_item(font_tables[f]->characters, c, (sa_tree_item) tglyph, 1); /* 1= global */ + glyph = (sa_tree_item) tglyph; } return &(font_tables[f]->charinfo[glyph]); } else if (c == left_boundarychar) { if (left_boundary(f) == NULL) { ci = xcalloc(1, sizeof(charinfo)); - font_bytes += sizeof(charinfo); + font_bytes += (int) sizeof(charinfo); set_left_boundary(f, ci); } return left_boundary(f); } else if (c == right_boundarychar) { if (right_boundary(f) == NULL) { ci = xcalloc(1, sizeof(charinfo)); - font_bytes += sizeof(charinfo); + font_bytes += (int) sizeof(charinfo); set_right_boundary(f, ci); } return right_boundary(f); @@ -226,8 +231,8 @@ charinfo *copy_charinfo(charinfo * ci) x++; } x++; - co->kerns = xmalloc(x * sizeof(kerninfo)); - memcpy(co->kerns, ci->kerns, (x * sizeof(kerninfo))); + co->kerns = xmalloc((unsigned) (x * (int) sizeof(kerninfo))); + memcpy(co->kerns, ci->kerns, (size_t) (x * (int) sizeof(kerninfo))); } /* ligs */ if ((lig = get_charinfo_ligatures(ci)) != NULL) { @@ -236,14 +241,15 @@ charinfo *copy_charinfo(charinfo * ci) x++; } x++; - co->ligatures = xmalloc(x * sizeof(liginfo)); - memcpy(co->ligatures, ci->ligatures, (x * sizeof(liginfo))); + co->ligatures = xmalloc((unsigned) (x * (int) sizeof(liginfo))); + memcpy(co->ligatures, ci->ligatures, + (size_t) (x * (int) sizeof(liginfo))); } /* packets */ if ((packet = get_charinfo_packets(ci)) != NULL) { x = vf_packet_bytes(ci); - co->packets = xmalloc(x); - memcpy(co->packets, ci->packets, x); + co->packets = xmalloc((unsigned) x); + memcpy(co->packets, ci->packets, (size_t) x); } /* horizontal and vertical extenders */ @@ -259,7 +265,8 @@ charinfo *copy_charinfo(charinfo * ci) x = ci->top_left_math_kerns; co->top_left_math_kerns = x; if (x > 0) { - co->top_left_math_kern_array = xmalloc(2 * sizeof(scaled) * x); + co->top_left_math_kern_array = + xmalloc((unsigned) (2 * (int) sizeof(scaled) * x)); for (k = 0; k < co->top_left_math_kerns; k++) { co->top_left_math_kern_array[(2 * k)] = ci->top_left_math_kern_array[(2 * k)]; @@ -270,7 +277,8 @@ charinfo *copy_charinfo(charinfo * ci) x = ci->top_right_math_kerns; co->top_right_math_kerns = x; if (x > 0) { - co->top_right_math_kern_array = xmalloc(2 * sizeof(scaled) * x); + co->top_right_math_kern_array = + xmalloc((unsigned) (2 * (int) sizeof(scaled) * x)); for (k = 0; k < co->top_right_math_kerns; k++) { co->top_right_math_kern_array[(2 * k)] = ci->top_right_math_kern_array[(2 * k)]; @@ -281,7 +289,8 @@ charinfo *copy_charinfo(charinfo * ci) x = ci->bottom_right_math_kerns; co->bottom_right_math_kerns = x; if (x > 0) { - co->bottom_right_math_kern_array = xmalloc(2 * sizeof(scaled) * x); + co->bottom_right_math_kern_array = + xmalloc((unsigned) (2 * (int) sizeof(scaled) * x)); for (k = 0; k < co->bottom_right_math_kerns; k++) { co->bottom_right_math_kern_array[(2 * k)] = ci->bottom_right_math_kern_array[(2 * k)]; @@ -292,7 +301,8 @@ charinfo *copy_charinfo(charinfo * ci) x = ci->bottom_left_math_kerns; co->bottom_left_math_kerns = x; if (x > 0) { - co->bottom_left_math_kern_array = xmalloc(2 * sizeof(scaled) * x); + co->bottom_left_math_kern_array = + xmalloc((unsigned) (2 * (int) sizeof(scaled) * x)); for (k = 0; k < co->bottom_left_math_kerns; k++) { co->bottom_left_math_kern_array[(2 * k)] = ci->bottom_left_math_kern_array[(2 * k)]; @@ -310,7 +320,7 @@ charinfo *char_info(internal_font_number f, int c) if (f > font_id_maxval) return 0; if (proper_char_index(c)) { - register int glyph = find_charinfo_id(f, c); + register int glyph = (int) find_charinfo_id(f, c); return &(font_tables[f]->charinfo[glyph]); } else if (c == left_boundarychar && left_boundary(f) != NULL) { return left_boundary(f); @@ -336,7 +346,7 @@ int char_exists(internal_font_number f, int c) if (f > font_id_maxval) return 0; if (proper_char_index(c)) { - return find_charinfo_id(f, c); + return (int) find_charinfo_id(f, c); } else if ((c == left_boundarychar) && has_left_boundary(f)) { return 1; } else if ((c == right_boundarychar) && has_right_boundary(f)) { @@ -531,7 +541,7 @@ void set_charinfo_bot_accent(charinfo * ci, scaled val) void set_charinfo_tag(charinfo * ci, scaled val) { - ci->tag = val; + ci->tag = (char) val; } void set_charinfo_remainder(charinfo * ci, scaled val) @@ -541,24 +551,24 @@ void set_charinfo_remainder(charinfo * ci, scaled val) void set_charinfo_used(charinfo * ci, scaled val) { - ci->used = val; + ci->used = (char) val; } void set_charinfo_index(charinfo * ci, scaled val) { - ci->index = val; + ci->index = (unsigned short) val; } -void set_charinfo_name(charinfo * ci, const char *val) +void set_charinfo_name(charinfo * ci, char *val) { xfree(ci->name); - ci->name = (char *) val; + ci->name = val; } -void set_charinfo_tounicode(charinfo * ci, const char *val) +void set_charinfo_tounicode(charinfo * ci, char *val) { xfree(ci->tounicode); - ci->tounicode = (char *) val; + ci->tounicode = val; } void set_charinfo_ligatures(charinfo * ci, liginfo * val) @@ -708,9 +718,10 @@ static void undump_math_kerns(charinfo * ci) int k; int x; undump_int(x); - ci->top_left_math_kerns = (int) x; + ci->top_left_math_kerns = x; if (x > 0) - ci->top_left_math_kern_array = xmalloc(2 * sizeof(scaled) * x); + ci->top_left_math_kern_array = + xmalloc((unsigned) (2 * (int) sizeof(scaled) * x)); for (k = 0; k < ci->top_left_math_kerns; k++) { undump_int(x); ci->top_left_math_kern_array[(2 * k)] = (scaled) x; @@ -718,9 +729,10 @@ static void undump_math_kerns(charinfo * ci) ci->top_left_math_kern_array[(2 * k) + 1] = (scaled) x; } undump_int(x); - ci->bottom_left_math_kerns = (int) x; + ci->bottom_left_math_kerns = x; if (x > 0) - ci->bottom_left_math_kern_array = xmalloc(2 * sizeof(scaled) * x); + ci->bottom_left_math_kern_array = + xmalloc((unsigned) (2 * (int) sizeof(scaled) * x)); for (k = 0; k < ci->bottom_left_math_kerns; k++) { undump_int(x); ci->bottom_left_math_kern_array[(2 * k)] = (scaled) x; @@ -728,9 +740,10 @@ static void undump_math_kerns(charinfo * ci) ci->bottom_left_math_kern_array[(2 * k) + 1] = (scaled) x; } undump_int(x); - ci->bottom_right_math_kerns = (int) x; + ci->bottom_right_math_kerns = x; if (x > 0) - ci->bottom_right_math_kern_array = xmalloc(2 * sizeof(scaled) * x); + ci->bottom_right_math_kern_array = + xmalloc((unsigned) (2 * (int) sizeof(scaled) * x)); for (k = 0; k < ci->bottom_right_math_kerns; k++) { undump_int(x); ci->bottom_right_math_kern_array[(2 * k)] = (scaled) x; @@ -738,9 +751,10 @@ static void undump_math_kerns(charinfo * ci) ci->bottom_right_math_kern_array[(2 * k) + 1] = (scaled) x; } undump_int(x); - ci->top_right_math_kerns = (int) x; + ci->top_right_math_kerns = x; if (x > 0) - ci->top_right_math_kern_array = xmalloc(2 * sizeof(scaled) * x); + ci->top_right_math_kern_array = + xmalloc((unsigned) (2 * (int) sizeof(scaled) * x)); for (k = 0; k < ci->top_right_math_kerns; k++) { undump_int(x); ci->top_right_math_kern_array[(2 * k)] = (scaled) x; @@ -996,7 +1010,8 @@ void set_font_params(internal_font_number f, int b) int i; i = font_params(f); if (i != b) { - font_bytes += (b - font_params(f) + 1) * sizeof(scaled); + font_bytes += + (int) ((b - (int) font_params(f) + 1) * (int) sizeof(scaled)); do_realloc(param_base(f), (b + 2), int); font_params(f) = b; if (b > i) { @@ -1013,7 +1028,8 @@ void set_font_math_params(internal_font_number f, int b) int i; i = font_math_params(f); if (i != b) { - font_bytes += (b - font_math_params(f) + 1) * sizeof(scaled); + font_bytes += + ((b - (int) font_math_params(f) + 1) * (int) sizeof(scaled)); do_realloc(math_param_base(f), (b + 2), int); font_math_params(f) = b; if (b > i) { @@ -1075,16 +1091,17 @@ int copy_font(int f) if (font_cidordering(f) != NULL) set_font_cidordering(k, xstrdup(font_cidordering(f))); - i = sizeof(*param_base(f)) * font_params(f); + i = (int) (sizeof(*param_base(f)) * (unsigned) font_params(f)); font_bytes += i; - param_base(k) = xmalloc(i); - memcpy(param_base(k), param_base(f), i); + param_base(k) = xmalloc((unsigned) i); + memcpy(param_base(k), param_base(f), (size_t) i); if (font_math_params(f) > 0) { - i = sizeof(*math_param_base(f)) * font_math_params(f); + i = (int) (sizeof(*math_param_base(f)) * + (unsigned) font_math_params(f)); font_bytes += i; - math_param_base(k) = xmalloc(i); - memcpy(math_param_base(k), math_param_base(f), i); + math_param_base(k) = xmalloc((unsigned) i); + memcpy(math_param_base(k), math_param_base(f), (size_t) i); } for (i = 0; i <= font_tables[f]->charinfo_count; i++) { @@ -1385,13 +1402,13 @@ scaled get_kern(internal_font_number f, int lc, int rc) /* dumping and undumping fonts */ -#define dump_string(a) \ - if (a!=NULL) { \ - x = strlen(a)+1; \ - dump_int(x); dump_things(*a, x); \ - } else { \ - x = 0; dump_int(x); \ - } +#define dump_string(a) \ + if (a!=NULL) { \ + x = (int)(strlen(a)+1); \ + dump_int(x); dump_things(*a, x); \ + } else { \ + x = 0; dump_int(x); \ + } void dump_charinfo(int f, int c) { @@ -1458,12 +1475,14 @@ void dump_charinfo(int f, int c) void dump_font_entry(texfont * f) { + int x; dump_int(f->_font_size); dump_int(f->_font_dsize); dump_int(f->_font_cidversion); dump_int(f->_font_cidsupplement); dump_int(f->_font_ec); - dump_int(f->_font_checksum); + x = (int) f->_font_checksum; + dump_int(x); dump_int(f->_font_used); dump_int(f->_font_touched); dump_int(f->_font_cache_id); @@ -1575,7 +1594,7 @@ int undump_charinfo(int f) undump_int(x); if (x > 0) { font_bytes += x; - s = xmalloc(x); + s = xmalloc((unsigned) x); undump_things(*s, x); } set_charinfo_name(co, s); @@ -1583,23 +1602,23 @@ int undump_charinfo(int f) undump_int(x); if (x > 0) { font_bytes += x; - s = xmalloc(x); + s = xmalloc((unsigned) x); undump_things(*s, x); } set_charinfo_tounicode(co, s); /* ligatures */ undump_int(x); if (x > 0) { - font_bytes += x * sizeof(liginfo); - lig = xmalloc(x * sizeof(liginfo)); + font_bytes += (int) ((unsigned) x * sizeof(liginfo)); + lig = xmalloc((unsigned) ((unsigned) x * sizeof(liginfo))); undump_things(*lig, x); } set_charinfo_ligatures(co, lig); /* kerns */ undump_int(x); if (x > 0) { - font_bytes += x * sizeof(kerninfo); - kern = xmalloc(x * sizeof(kerninfo)); + font_bytes += (int) ((unsigned) x * sizeof(kerninfo)); + kern = xmalloc((unsigned) ((unsigned) x * sizeof(kerninfo))); undump_things(*kern, x); } set_charinfo_kerns(co, kern); @@ -1608,7 +1627,7 @@ int undump_charinfo(int f) undump_int(x); if (x > 0) { font_bytes += x; - packet = xmalloc(x); + packet = xmalloc((unsigned) x); undump_things(*packet, x); } set_charinfo_packets(co, packet); @@ -1621,10 +1640,10 @@ int undump_charinfo(int f) return i; } -#define undump_font_string(a) undump_int (x); \ - if (x>0) { \ - font_bytes += x; \ - s = xmalloc(x); undump_things(*s,x); \ +#define undump_font_string(a) undump_int (x); \ + if (x>0) { \ + font_bytes += x; \ + s = xmalloc((unsigned)x); undump_things(*s,x); \ a(f,s); } @@ -1637,11 +1656,11 @@ void undump_font_entry(texfont * f) undump_int(x); f->_font_cidversion = x; undump_int(x); f->_font_cidsupplement = x; undump_int(x); f->_font_ec = x; - undump_int(x); f->_font_checksum = x; - undump_int(x); f->_font_used = x; - undump_int(x); f->_font_touched = x; + undump_int(x); f->_font_checksum = (unsigned)x; + undump_int(x); f->_font_used = (char)x; + undump_int(x); f->_font_touched = (char)x; undump_int(x); f->_font_cache_id = x; - undump_int(x); f->_font_encodingbytes = x; + undump_int(x); f->_font_encodingbytes = (char)x; undump_int(x); f->_font_slant = x; undump_int(x); f->_font_extend = x; undump_int(x); f->_font_expand_ratio = x; @@ -1649,7 +1668,7 @@ void undump_font_entry(texfont * f) undump_int(x); f->_font_stretch = x; undump_int(x); f->_font_step = x; undump_int(x); f->_font_auto_expand = x; - undump_int(x); f->_font_tounicode = x; + undump_int(x); f->_font_tounicode = (char)x; undump_int(x); f->_font_type = x; undump_int(x); f->_font_format = x; undump_int(x); f->_font_embedding = x; @@ -1678,7 +1697,7 @@ void undump_font(int f) grow_font_table(f); tt = xmalloc(sizeof(texfont)); memset(tt, 0, sizeof(texfont)); - font_bytes += sizeof(texfont); + font_bytes += (int) sizeof(texfont); undump_font_entry(tt); font_tables[f] = tt; @@ -1691,15 +1710,16 @@ void undump_font(int f) undump_font_string(set_font_cidregistry); undump_font_string(set_font_cidordering); - i = sizeof(*param_base(f)) * (font_params(f) + 1); + i = (int) (sizeof(*param_base(f)) * ((unsigned) font_params(f) + 1)); font_bytes += i; - param_base(f) = xmalloc(i); + param_base(f) = xmalloc((unsigned) i); undump_things(*param_base(f), (font_params(f) + 1)); if (font_math_params(f) > 0) { - i = sizeof(*math_param_base(f)) * (font_math_params(f) + 1); + i = (int) (sizeof(*math_param_base(f)) * + ((unsigned) font_math_params(f) + 1)); font_bytes += i; - math_param_base(f) = xmalloc(i); + math_param_base(f) = xmalloc((unsigned) i); undump_things(*math_param_base(f), (font_math_params(f) + 1)); } diff --git a/source/texk/web2c/luatexdir/font/texfont.h b/source/texk/web2c/luatexdir/font/texfont.h index 1905f9a8ffd1ae9a8d8bca37338b4ef3fc5296dd..ab6738d5481aff7f5e5f69cbb69190e4b70d00cf 100644 --- a/source/texk/web2c/luatexdir/font/texfont.h +++ b/source/texk/web2c/luatexdir/font/texfont.h @@ -416,8 +416,8 @@ extern void set_charinfo_tag(charinfo * ci, scaled val); extern void set_charinfo_remainder(charinfo * ci, scaled val); extern void set_charinfo_used(charinfo * ci, scaled val); extern void set_charinfo_index(charinfo * ci, scaled val); -extern void set_charinfo_name(charinfo * ci, const char *val); -extern void set_charinfo_tounicode(charinfo * ci, const char *val); +extern void set_charinfo_name(charinfo * ci, char *val); +extern void set_charinfo_tounicode(charinfo * ci, char *val); extern void set_charinfo_ligatures(charinfo * ci, liginfo * val); extern void set_charinfo_kerns(charinfo * ci, kerninfo * val); extern void set_charinfo_packets(charinfo * ci, eight_bits * val); diff --git a/source/texk/web2c/luatexdir/font/tfmofm.c b/source/texk/web2c/luatexdir/font/tfmofm.c index 526b2c656963077ffc1189fa26700fcc38674aa5..b0d65ac8a149283767da7aea54f1ae09a35dcfb0 100644 --- a/source/texk/web2c/luatexdir/font/tfmofm.c +++ b/source/texk/web2c/luatexdir/font/tfmofm.c @@ -375,7 +375,7 @@ additional parameter information, which is explained later. xfree(xligs); xfree(xkerns); return 1; } -int open_tfm_file(char *nom, unsigned char **tfm_buf, int *tfm_siz) +static int open_tfm_file(const char *nom, unsigned char **tfm_buf, int *tfm_siz) { boolean res; /* was the callback successful? */ boolean opened; /* was |tfm_file| successfully opened? */ @@ -455,7 +455,7 @@ int open_tfm_file(char *nom, unsigned char **tfm_buf, int *tfm_siz) ci._depth_index=b%256; \ fget; read_sixteen_unsigned(c); \ ci._italic_index=c>>8; \ - ci._tag=c%4; \ + ci._tag=(unsigned char)(c%4); \ fget; read_sixteen_unsigned(d); \ ci._remainder=d; \ } else { \ @@ -466,22 +466,22 @@ int open_tfm_file(char *nom, unsigned char **tfm_buf, int *tfm_siz) ci._depth_index=b%16; \ c=tfm_buffer[++tfm_byte]; \ ci._italic_index=c>>2; \ - ci._tag=c%4; \ + ci._tag=(unsigned char)(c%4); \ d=tfm_buffer[++tfm_byte]; \ ci._remainder=d; \ } } #define read_four_quarters(q) \ - { if (font_level!=-1) { \ - fget; read_sixteen_unsigned(a); q.b0=a; \ - fget; read_sixteen_unsigned(b); q.b1=b; \ - fget; read_sixteen_unsigned(c); q.b2=c; \ - fget; read_sixteen_unsigned(d); q.b3=d; \ - } else { \ - a=tfm_buffer[++tfm_byte]; q.b0=a; \ - b=tfm_buffer[++tfm_byte]; q.b1=b; \ - c=tfm_buffer[++tfm_byte]; q.b2=c; \ - d=tfm_buffer[++tfm_byte]; q.b3=d; \ + { if (font_level!=-1) { \ + fget; read_sixteen_unsigned(a); q.b0=(quarterword)a; \ + fget; read_sixteen_unsigned(b); q.b1=(quarterword)b; \ + fget; read_sixteen_unsigned(c); q.b2=(quarterword)c; \ + fget; read_sixteen_unsigned(d); q.b3=(quarterword)d; \ + } else { \ + a=tfm_buffer[++tfm_byte]; q.b0=(quarterword)a; \ + b=tfm_buffer[++tfm_byte]; q.b1=(quarterword)b; \ + c=tfm_buffer[++tfm_byte]; q.b2=(quarterword)c; \ + d=tfm_buffer[++tfm_byte]; q.b3=(quarterword)d; \ } } #define check_byte_range(z) { if ((z<bc)||(z>ec)) tfm_abort ; } @@ -531,22 +531,22 @@ scaled store_scaled_f(scaled sq, scaled z_in) alpha *= z; }; if (sq >= 0) { - d = sq % 256; /* any "mod 256" not really needed, would typecast alone be safe? */ + d = (eight_bits) (sq % 256); sq = sq / 256; - c = sq % 256; + c = (eight_bits) (sq % 256); sq = sq / 256; - b = sq % 256; + b = (eight_bits) (sq % 256); sq = sq / 256; - a = sq % 256; + a = (eight_bits) (sq % 256); } else { sq = (sq + 1073741824) + 1073741824; /* braces for optimizing compiler */ - d = sq % 256; + d = (eight_bits) (sq % 256); sq = sq / 256; - c = sq % 256; + c = (eight_bits) (sq % 256); sq = sq / 256; - b = sq % 256; + b = (eight_bits) (sq % 256); sq = sq / 256; - a = (sq + 128) % 256; + a = (eight_bits) ((sq + 128) % 256); } sw = (((((d * z) >> 8) + (c * z)) >> 8) + (b * z)) / beta; if (a == 0) @@ -604,6 +604,7 @@ int read_tfm_info(internal_font_number f, const char *cnom, scaled s) int saved_tfm_byte = 0; /* saved index into |tfm_buffer| */ unsigned char *tfm_buffer = NULL; /* byte buffer for tfm files */ int tfm_size = 0; /* total size of the tfm file */ + int tmp; widths = NULL; heights = NULL; @@ -722,13 +723,13 @@ int read_tfm_info(internal_font_number f, const char *cnom, scaled s) set_font_ec(f, ec); /* read the arrays first */ - widths = xmalloc(nw * sizeof(scaled)); - heights = xmalloc(nh * sizeof(scaled)); - depths = xmalloc(nd * sizeof(scaled)); - italics = xmalloc(ni * sizeof(scaled)); - extens = xmalloc(ne * sizeof(four_quarters)); - lig_kerns = xmalloc(nl * sizeof(four_quarters)); - kerns = xmalloc(nk * sizeof(scaled)); + widths = xmalloc((unsigned) ((unsigned) nw * sizeof(scaled))); + heights = xmalloc((unsigned) ((unsigned) nh * sizeof(scaled))); + depths = xmalloc((unsigned) ((unsigned) nd * sizeof(scaled))); + italics = xmalloc((unsigned) ((unsigned) ni * sizeof(scaled))); + extens = xmalloc((unsigned) ((unsigned) ne * sizeof(four_quarters))); + lig_kerns = xmalloc((unsigned) ((unsigned) nl * sizeof(four_quarters))); + kerns = xmalloc((unsigned) ((unsigned) nk * sizeof(scaled))); /* @<Read the {\.{TFM}} header@>; */ @@ -736,7 +737,8 @@ int read_tfm_info(internal_font_number f, const char *cnom, scaled s) slh = lh; if (lh < 2) tfm_abort; - store_four_bytes(font_checksum(f)); + store_four_bytes(tmp); + font_checksum(f) = (unsigned) tmp; fget; read_sixteen(z); /* this rejects a negative design size */ fget; @@ -774,7 +776,7 @@ int read_tfm_info(internal_font_number f, const char *cnom, scaled s) z = z >> 1; alpha = alpha + alpha; }; - beta = 256 / alpha; + beta = (char) (256 / alpha); alpha = alpha * z; /* @<Read box dimensions@>; */ @@ -898,9 +900,9 @@ int read_tfm_info(internal_font_number f, const char *cnom, scaled s) } if (fkerns > 0 || fligs > 0) { if (fligs > 0) - cligs = xcalloc((fligs + 1), sizeof(liginfo)); + cligs = xcalloc((unsigned) (fligs + 1), sizeof(liginfo)); if (fkerns > 0) - ckerns = xcalloc((fkerns + 1), sizeof(kerninfo)); + ckerns = xcalloc((unsigned) (fkerns + 1), sizeof(kerninfo)); fligs = 0; fkerns = 0; k = bch_label; @@ -916,7 +918,7 @@ int read_tfm_info(internal_font_number f, const char *cnom, scaled s) rem_byte(k)]); fkerns++; } else { /* lig */ - set_ligature_item(cligs[fligs], (op_byte(k) * 2 + 1), + set_ligature_item(cligs[fligs], (char) (op_byte(k) * 2 + 1), next_char(k), rem_byte(k)); fligs++; } @@ -1001,8 +1003,8 @@ int read_tfm_info(internal_font_number f, const char *cnom, scaled s) /* first pass: count ligs and kerns */ - xligs = xcalloc((ec + 1), sizeof(int)); - xkerns = xcalloc((ec + 1), sizeof(int)); + xligs = xcalloc((unsigned) (ec + 1), sizeof(int)); + xkerns = xcalloc((unsigned) (ec + 1), sizeof(int)); for (i = bc; i <= ec; i++) { if (char_tag(f, i) == lig_tag) { @@ -1045,9 +1047,9 @@ int read_tfm_info(internal_font_number f, const char *cnom, scaled s) k = lig_kern_restart(k); /* now k is the start index */ if (xligs[i] > 0) - cligs = xcalloc((xligs[i] + 1), sizeof(liginfo)); + cligs = xcalloc((unsigned) (xligs[i] + 1), sizeof(liginfo)); if (xkerns[i] > 0) - ckerns = xcalloc((xkerns[i] + 1), sizeof(kerninfo)); + ckerns = xcalloc((unsigned) (xkerns[i] + 1), sizeof(kerninfo)); while (1) { if (skip_byte(k) <= stop_flag) { if (op_byte(k) >= kern_flag) { /* kern */ @@ -1064,11 +1066,12 @@ int read_tfm_info(internal_font_number f, const char *cnom, scaled s) } else { /* lig */ if (next_char(k) == bchar) { set_ligature_item(cligs[fligs], - (op_byte(k) * 2 + 1), + (char) (op_byte(k) * 2 + 1), right_boundarychar, rem_byte(k)); fligs++; } - set_ligature_item(cligs[fligs], (op_byte(k) * 2 + 1), + set_ligature_item(cligs[fligs], + (char) (op_byte(k) * 2 + 1), next_char(k), rem_byte(k)); fligs++; } diff --git a/source/texk/web2c/luatexdir/font/tounicode.c b/source/texk/web2c/luatexdir/font/tounicode.c index fde8188e92ce390fb7ce5f0b9e7ea0d49d0361f3..f0c80136c60686b0d074570a2b7055ffa2402c13 100644 --- a/source/texk/web2c/luatexdir/font/tounicode.c +++ b/source/texk/web2c/luatexdir/font/tounicode.c @@ -80,7 +80,7 @@ void def_tounicode(str_number glyph, str_number unistr) ph = p; while (*p == ' ') p++; /* ignore leading spaces */ - l = strlen(p); + l = (int) strlen(p); while (l > 0 && p[l - 1] == ' ') l--; /* ignore traling spaces */ valid_unistr = 1; /* a unicode value is the most common case */ @@ -133,7 +133,7 @@ void def_tounicode(str_number glyph, str_number unistr) static long check_unicode_value(char *s, boolean multiple_value) { - int l = strlen(s); + int l = (int) strlen(s); int i; long code; @@ -180,8 +180,8 @@ static char *utf16be_str(long code) sprintf(buf, "%04lX", code); else { v = code - 0x10000; - vh = v / 0x400 + 0xD800; - vl = v % 0x400 + 0xDC00; + vh = (unsigned) (v / 0x400 + 0xD800); + vl = (unsigned) (v % 0x400 + 0xDC00); sprintf(buf, "%04X%04X", vh, vl); } return buf; @@ -206,7 +206,7 @@ static void set_glyph_unicode(char *s, glyph_unicode_entry * gp) p = strchr(s, '.'); if (p != NULL) { *buf = 0; - strncat(buf, s, p - s); + strncat(buf, s, (size_t) (p - s)); s = buf; } @@ -301,7 +301,7 @@ static void set_cid_glyph_unicode(long index, glyph_unicode_entry * gp, { char *s; if (font_tounicode(f) && - (s = get_charinfo_tounicode(char_info(f, index))) != NULL) { + (s = get_charinfo_tounicode(char_info(f, (int) index))) != NULL) { gp->code = UNI_EXTRA_STRING; gp->unicode_seq = xstrdup(s); } else { @@ -376,7 +376,7 @@ int write_tounicode(PDF pdf, char **glyph_names, char *name) i++; /* at this point i is the last entry of the subrange */ i++; /* move i to the next entry */ - range_size[j] = i - j; + range_size[j] = (short) (i - j); } } @@ -469,7 +469,7 @@ int write_cid_tounicode(PDF pdf, fo_entry * fo, internal_font_number f) char *buf; assert(fo->fd->fontname); - buf = xmalloc(strlen(fo->fd->fontname) + 8); + buf = xmalloc((unsigned) (strlen(fo->fd->fontname) + 8)); sprintf(buf, "%s-%s", (fo->fd->subset_tag != NULL ? fo->fd->subset_tag : "UCS"), fo->fd->fontname); diff --git a/source/texk/web2c/luatexdir/font/tt_glyf.c b/source/texk/web2c/luatexdir/font/tt_glyf.c index 76d3c683e42966009fac76076054e0bf39dc05c0..0808484afad69ce6503fae27cd4659fb6e63a35a 100644 --- a/source/texk/web2c/luatexdir/font/tt_glyf.c +++ b/source/texk/web2c/luatexdir/font/tt_glyf.c @@ -97,15 +97,18 @@ USHORT tt_add_glyph(struct tt_glyphs * g, USHORT gid, USHORT new_gid) TT_ERROR("Too many glyphs."); if (g->num_glyphs >= g->max_glyphs) { - g->max_glyphs += GLYPH_ARRAY_ALLOC_SIZE; + g->max_glyphs = (USHORT) (g->max_glyphs + GLYPH_ARRAY_ALLOC_SIZE); g->gd = RENEW(g->gd, g->max_glyphs, struct tt_glyph_desc); } g->gd[g->num_glyphs].gid = new_gid; g->gd[g->num_glyphs].ogid = gid; g->gd[g->num_glyphs].length = 0; g->gd[g->num_glyphs].data = NULL; - g->used_slot[new_gid / 8] |= (1 << (7 - (new_gid % 8))); - g->num_glyphs += 1; + g->used_slot[new_gid / 8] = + (unsigned char) (g-> + used_slot[new_gid / + 8] | (1 << (7 - (new_gid % 8)))); + g->num_glyphs++; } if (new_gid > g->last_gid) { @@ -158,10 +161,10 @@ void tt_build_finish(struct tt_glyphs *g) static int glyf_cmp(const void *v1, const void *v2) { int cmp = 0; - struct tt_glyph_desc *sv1, *sv2; + const struct tt_glyph_desc *sv1, *sv2; - sv1 = (struct tt_glyph_desc *) v1; - sv2 = (struct tt_glyph_desc *) v2; + sv1 = (const struct tt_glyph_desc *) v1; + sv2 = (const struct tt_glyph_desc *) v2; if (sv1->gid == sv2->gid) cmp = 0; @@ -219,8 +222,8 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) os2 = tt_read_os2__table(sfont); if (os2) { - g->default_advh = os2->sTypoAscender - os2->sTypoDescender; - g->default_tsb = g->default_advh - os2->sTypoAscender; + g->default_advh = (USHORT) (os2->sTypoAscender - os2->sTypoDescender); + g->default_tsb = (SHORT) (g->default_advh - os2->sTypoAscender); /* dvipdfmx does this elsewhere! */ fd_cur->font_dim[STEMV_CODE].val = @@ -252,7 +255,8 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) } w_stat = NEW(g->emsize + 2, USHORT); - memset(w_stat, 0, sizeof(USHORT) * (g->emsize + 2)); + memset(w_stat, 0, + (size_t) (sizeof(USHORT) * ((long unsigned) g->emsize + 2))); /* * Read glyf table. */ @@ -291,9 +295,9 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) g->gd[i].length = len; g->gd[i].data = NULL; if (g->gd[i].advw <= g->emsize) { - w_stat[g->gd[i].advw] += 1; + w_stat[g->gd[i].advw]++; } else { - w_stat[g->emsize + 1] += 1; /* larger than em */ + w_stat[g->emsize + 1]++; /* larger than em */ } if (len == 0) { /* Does not contains any data. */ @@ -305,7 +309,7 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) g->gd[i].data = p = NEW(len, BYTE); endptr = p + len; - sfnt_seek_set(sfont, offset + loc); + sfnt_seek_set(sfont, (long) (offset + loc)); number_of_contours = sfnt_get_short(sfont); p += sfnt_put_short(p, number_of_contours); @@ -317,7 +321,8 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) /* _FIXME_ */ #if 1 if (!vmtx) /* vertOriginY == sTypeAscender */ - g->gd[i].tsb = g->default_advh - g->default_tsb - g->gd[i].ury; + g->gd[i].tsb = + (SHORT) (g->default_advh - g->default_tsb - g->gd[i].ury); #endif p += sfnt_put_short(p, g->gd[i].llx); p += sfnt_put_short(p, g->gd[i].lly); @@ -325,7 +330,7 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) p += sfnt_put_short(p, g->gd[i].ury); /* Read evrything else. */ - sfnt_read(p, len - 10, sfont); + sfnt_read(p, (int) len - 10, sfont); /* * Fix GIDs of composite glyphs. */ @@ -338,9 +343,9 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) /* * Flags and gid of component glyph are both USHORT. */ - flags = ((*p) << 8) | *(p + 1); + flags = (USHORT) (((*p) << 8) | *(p + 1)); p += 2; - cgid = ((*p) << 8) | *(p + 1); + cgid = (USHORT) (((*p) << 8) | *(p + 1)); if (cgid >= maxp->numGlyphs) { TT_ERROR("Invalid gid (%u > %u) in composite glyph %u.", cgid, maxp->numGlyphs, gid); @@ -380,7 +385,7 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) for (i = 0; i < g->emsize + 1; i++) { if (w_stat[i] > max_count) { max_count = w_stat[i]; - g->dw = i; + g->dw = (USHORT) i; } } } @@ -396,10 +401,11 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) num_hm_known = 0; last_advw = g->gd[g->num_glyphs - 1].advw; for (i = g->num_glyphs - 1; i >= 0; i--) { - padlen = (g->gd[i].length % 4) ? (4 - (g->gd[i].length % 4)) : 0; - glyf_table_size += g->gd[i].length + padlen; + padlen = + (int) ((g->gd[i].length % 4) ? (4 - (g->gd[i].length % 4)) : 0); + glyf_table_size += (ULONG) (g->gd[i].length + (ULONG) padlen); if (!num_hm_known && last_advw != g->gd[i].advw) { - hhea->numberOfHMetrics = g->gd[i].gid + 2; + hhea->numberOfHMetrics = (USHORT) (g->gd[i].gid + 2); num_hm_known = 1; } } @@ -407,7 +413,8 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) if (!num_hm_known) { hhea->numberOfHMetrics = 1; } - hmtx_table_size = hhea->numberOfHMetrics * 2 + (g->last_gid + 1) * 2; + hmtx_table_size = + (ULONG) (hhea->numberOfHMetrics * 2 + (g->last_gid + 1) * 2); /* * Choosing short format does not always give good result @@ -415,10 +422,10 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) */ if (glyf_table_size < 0x20000UL) { head->indexToLocFormat = 0; - loca_table_size = (g->last_gid + 2) * 2; + loca_table_size = (ULONG) ((g->last_gid + 2) * 2); } else { head->indexToLocFormat = 1; - loca_table_size = (g->last_gid + 2) * 4; + loca_table_size = (ULONG) ((g->last_gid + 2) * 4); } hmtx_table_data = p = NEW(hmtx_table_size, char); @@ -440,10 +447,11 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) if (head->indexToLocFormat == 0) { q += sfnt_put_ushort(q, (USHORT) (offset / 2)); } else { - q += sfnt_put_ulong(q, offset); + q += sfnt_put_ulong(q, (LONG) offset); } } - padlen = (g->gd[i].length % 4) ? (4 - (g->gd[i].length % 4)) : 0; + padlen = + (int) ((g->gd[i].length % 4) ? (4 - (g->gd[i].length % 4)) : 0); if (g->gd[i].gid < hhea->numberOfHMetrics) { p += sfnt_put_ushort(p, g->gd[i].advw); } @@ -451,11 +459,12 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) if (head->indexToLocFormat == 0) { q += sfnt_put_ushort(q, (USHORT) (offset / 2)); } else { - q += sfnt_put_ulong(q, offset); + q += sfnt_put_ulong(q, (LONG) offset); } - memset(glyf_table_data + offset, 0, g->gd[i].length + padlen); + memset(glyf_table_data + offset, 0, + (size_t) (g->gd[i].length + (ULONG) padlen)); memcpy(glyf_table_data + offset, g->gd[i].data, g->gd[i].length); - offset += g->gd[i].length + padlen; + offset += (g->gd[i].length + (ULONG) padlen); prev = g->gd[i].gid; /* free data here since it consume much memory */ RELEASE(g->gd[i].data); @@ -465,7 +474,7 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) if (head->indexToLocFormat == 0) { q += sfnt_put_ushort(q, (USHORT) (offset / 2)); } else { - q += sfnt_put_ulong(q, offset); + q += sfnt_put_ulong(q, (LONG) offset); } sfnt_set_table(sfont, "hmtx", (char *) hmtx_table_data, @@ -477,7 +486,7 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) } head->checkSumAdjustment = 0; - maxp->numGlyphs = g->last_gid + 1; + maxp->numGlyphs = (USHORT) (g->last_gid + 1); /* TODO */ sfnt_set_table(sfont, "maxp", tt_pack_maxp_table(maxp), TT_MAXP_TABLE_SIZE); @@ -541,8 +550,8 @@ int tt_get_metrics(sfnt * sfont, struct tt_glyphs *g) hmtx = tt_read_longMetrics(sfont, maxp->numGlyphs, hhea->numberOfHMetrics); os2 = tt_read_os2__table(sfont); - g->default_advh = os2->sTypoAscender - os2->sTypoDescender; - g->default_tsb = g->default_advh - os2->sTypoAscender; + g->default_advh = (USHORT) (os2->sTypoAscender - os2->sTypoDescender); + g->default_tsb = (SHORT) (g->default_advh - os2->sTypoAscender); if (sfnt_find_table_pos(sfont, "vmtx") > 0) { struct tt_vhea_table *vhea; @@ -569,7 +578,7 @@ int tt_get_metrics(sfnt * sfont, struct tt_glyphs *g) } w_stat = NEW(g->emsize + 2, USHORT); - memset(w_stat, 0, sizeof(USHORT) * (g->emsize + 2)); + memset(w_stat, 0, (size_t) ((int) sizeof(USHORT) * (g->emsize + 2))); /* * Read glyf table. */ @@ -598,9 +607,9 @@ int tt_get_metrics(sfnt * sfont, struct tt_glyphs *g) g->gd[i].data = NULL; if (g->gd[i].advw <= g->emsize) { - w_stat[g->gd[i].advw] += 1; + w_stat[g->gd[i].advw]++; } else { - w_stat[g->emsize + 1] += 1; /* larger than em */ + w_stat[g->emsize + 1]++; /* larger than em */ } if (len == 0) { /* Does not contains any data. */ @@ -609,7 +618,7 @@ int tt_get_metrics(sfnt * sfont, struct tt_glyphs *g) TT_ERROR("Invalid TrueType glyph data (gid %u).", gid); } - sfnt_seek_set(sfont, offset + loc); + sfnt_seek_set(sfont, (long) (offset + loc)); number_of_contours = sfnt_get_short(sfont); /* BoundingBox: FWord x 4 */ @@ -620,7 +629,8 @@ int tt_get_metrics(sfnt * sfont, struct tt_glyphs *g) /* _FIXME_ */ #if 1 if (!vmtx) /* vertOriginY == sTypeAscender */ - g->gd[i].tsb = g->default_advh - g->default_tsb - g->gd[i].ury; + g->gd[i].tsb = + (SHORT) (g->default_advh - g->default_tsb - g->gd[i].ury); #endif } RELEASE(location); @@ -640,7 +650,7 @@ int tt_get_metrics(sfnt * sfont, struct tt_glyphs *g) for (i = 0; i < g->emsize + 1; i++) { if (w_stat[i] > max_count) { max_count = w_stat[i]; - g->dw = i; + g->dw = (USHORT) i; } } } diff --git a/source/texk/web2c/luatexdir/font/tt_table.c b/source/texk/web2c/luatexdir/font/tt_table.c index 2704ae152076f1059a3034b19d16e0ab72b1c6fb..bff1c1f0c4f45d1b756ec9bb9bd08ff91c77b78d 100644 --- a/source/texk/web2c/luatexdir/font/tt_table.c +++ b/source/texk/web2c/luatexdir/font/tt_table.c @@ -53,17 +53,17 @@ char *tt_pack_head_table(struct tt_head_table *table) TT_ERROR("passed NULL pointer\n"); p = data = NEW(TT_HEAD_TABLE_SIZE, char); - p += sfnt_put_ulong(p, table->version); - p += sfnt_put_ulong(p, table->fontRevision); - p += sfnt_put_ulong(p, table->checkSumAdjustment); - p += sfnt_put_ulong(p, table->magicNumber); + p += sfnt_put_ulong(p, (LONG) table->version); + p += sfnt_put_ulong(p, (LONG) table->fontRevision); + p += sfnt_put_ulong(p, (LONG) table->checkSumAdjustment); + p += sfnt_put_ulong(p, (LONG) table->magicNumber); p += sfnt_put_ushort(p, table->flags); p += sfnt_put_ushort(p, table->unitsPerEm); for (i = 0; i < 8; i++) { - *(p++) = (table->created)[i]; + *(p++) = (char) (table->created)[i]; } for (i = 0; i < 8; i++) { - *(p++) = (table->modified)[i]; + *(p++) = (char) (table->modified)[i]; } p += sfnt_put_short(p, table->xMin); p += sfnt_put_short(p, table->yMin); @@ -103,8 +103,8 @@ struct tt_head_table *tt_read_head_table(sfnt * sfont) table->yMin = sfnt_get_short(sfont); table->xMax = sfnt_get_short(sfont); table->yMax = sfnt_get_short(sfont); - table->macStyle = sfnt_get_short(sfont); - table->lowestRecPPEM = sfnt_get_short(sfont); + table->macStyle = (USHORT) sfnt_get_short(sfont); + table->lowestRecPPEM = (USHORT) sfnt_get_short(sfont); table->fontDirectionHint = sfnt_get_short(sfont); table->indexToLocFormat = sfnt_get_short(sfont); table->glyphDataFormat = sfnt_get_short(sfont); @@ -117,7 +117,7 @@ char *tt_pack_maxp_table(struct tt_maxp_table *table) char *p, *data; p = data = NEW(TT_MAXP_TABLE_SIZE, char); - p += sfnt_put_ulong(p, table->version); + p += sfnt_put_ulong(p, (LONG) table->version); p += sfnt_put_ushort(p, table->numGlyphs); p += sfnt_put_ushort(p, table->maxPoints); p += sfnt_put_ushort(p, table->maxContours); @@ -168,7 +168,7 @@ char *tt_pack_hhea_table(struct tt_hhea_table *table) char *p, *data; p = data = NEW(TT_HHEA_TABLE_SIZE, char); - p += sfnt_put_ulong(p, table->version); + p += sfnt_put_ulong(p, (LONG) table->version); p += sfnt_put_short(p, table->Ascender); p += sfnt_put_short(p, table->Descender); p += sfnt_put_short(p, table->LineGap); @@ -223,7 +223,7 @@ char *tt_pack_vhea_table(struct tt_vhea_table *table) char *p, *data; p = data = NEW(TT_VHEA_TABLE_SIZE, char); - p += sfnt_put_ulong(p, table->version); + p += sfnt_put_ulong(p, (LONG) table->version); p += sfnt_put_short(p, table->vertTypoAscender); p += sfnt_put_short(p, table->vertTypoDescender); p += sfnt_put_short(p, table->vertTypoLineGap); @@ -420,9 +420,9 @@ tt_get_name(sfnt * sfont, char *dest, USHORT destlen, if (length > destlen - 1) { fprintf(stderr, "\n** Notice: Name string too long. Truncating **\n"); - length = destlen - 1; + length = (USHORT) (destlen - 1); } - sfnt_seek_set(sfont, name_offset + string_offset + offset); + sfnt_seek_set(sfont, (long) (name_offset + string_offset + offset)); sfnt_read((unsigned char *) dest, length, sfont); dest[length] = '\0'; break; diff --git a/source/texk/web2c/luatexdir/font/vfovf.c b/source/texk/web2c/luatexdir/font/vfovf.c index 9bba14d754c5fde37b00c3563e4cce2a4d120caf..7976fb97151dfc7fcc48bfadd2d189ebf8926602 100644 --- a/source/texk/web2c/luatexdir/font/vfovf.c +++ b/source/texk/web2c/luatexdir/font/vfovf.c @@ -146,8 +146,8 @@ boolean auto_expand_vf(internal_font_number f); /* forward */ vf_z = vf_z / 2; \ vf_alpha += vf_alpha; \ } \ - vf_beta = 256 / vf_alpha; \ - vf_alpha = vf_alpha * vf_z; \ + vf_beta = (char)(256 / vf_alpha); \ + vf_alpha = (vf_alpha * vf_z); \ } /* read |k| bytes as an integer from \.{VF} file */ @@ -155,7 +155,7 @@ boolean auto_expand_vf(internal_font_number f); /* forward */ #define vf_read(k, l) \ { \ - int itmp = 0, dtmp = k, jtmp = 0; \ + int itmp = 0, dtmp = (int)(k), jtmp = 0; \ while (dtmp > 0) { \ vf_byte(jtmp); \ if ((dtmp == (int) k) && jtmp > 127) \ @@ -168,7 +168,8 @@ boolean auto_expand_vf(internal_font_number f); /* forward */ #define vf_read_u(k, l) \ { \ - unsigned int dtmp = k, itmp = 0, jtmp = 0; \ + int dtmp = (int)(k); \ + unsigned int itmp = 0, jtmp = 0; \ while (dtmp-- > 0) { \ vf_byte(jtmp); \ itmp = itmp * 256 + jtmp; \ @@ -183,8 +184,8 @@ void pdf_check_vf(internal_font_number f) } static void -vf_local_font_warning(internal_font_number f, internal_font_number k, char *s, - int a, int b) +vf_local_font_warning(internal_font_number f, internal_font_number k, + const char *s, int a, int b) { print_nlp(); tprint(s); @@ -217,8 +218,8 @@ vf_def_font(internal_font_number f, unsigned char *vf_buffer, int *vf_cr) cs.b2 = vf_buffer[(*vf_cr) + 2]; cs.b3 = vf_buffer[(*vf_cr) + 3]; (*vf_cr) += 4; - checksum = - cs.b0 * 256 * 256 * 256 + cs.b1 * 256 * 256 + cs.b2 * 256 + cs.b3; + checksum = (unsigned) + (cs.b0 * 256 * 256 * 256 + cs.b1 * 256 * 256 + cs.b2 * 256 + cs.b3); k = vf_buffer[(*vf_cr)]; (*vf_cr)++; if (k > 127) @@ -268,8 +269,8 @@ vf_def_font(internal_font_number f, unsigned char *vf_buffer, int *vf_cr) if (k != null_font) { if (checksum != 0 && font_checksum(k) != 0 && checksum != font_checksum(k)) - vf_local_font_warning(f, k, "checksum mismatch", checksum, - font_checksum(k)); + vf_local_font_warning(f, k, "checksum mismatch", (int) checksum, + (int) font_checksum(k)); if (ds != font_dsize(k)) vf_local_font_warning(f, k, "design size mismatch", ds, font_dsize(k)); @@ -283,13 +284,13 @@ vf_def_font(internal_font_number f, unsigned char *vf_buffer, int *vf_cr) } -int open_vf_file(char *fn, unsigned char **vbuffer, int *vsize) +static int open_vf_file(const char *fn, unsigned char **vbuffer, int *vsize) { boolean res; /* was the callback successful? */ int callback_id; boolean file_read = false; /* was |vf_file| successfully read? */ FILE *vf_file; - char *fname = luatex_find_file(fn, find_vf_file_callback); + const char *fname = luatex_find_file(fn, find_vf_file_callback); if (!fname) fname = fn; @@ -328,7 +329,7 @@ int open_vf_file(char *fn, unsigned char **vbuffer, int *vsize) process font definitions in virtual font we call |vf_def_font|. */ -#define append_packet(k) vpackets[vf_np++] = k +#define append_packet(k) vpackets[vf_np++] = (eight_bits)(k) /* life is easier if all internal font commands are fnt4 and all character commands are set4 or put4 */ @@ -376,13 +377,13 @@ int open_vf_file(char *fn, unsigned char **vbuffer, int *vsize) int count_packet_bytes(eight_bits * vf_buf, int cur_bute, int count) { - int k = 0; + unsigned k = 0; int ff = 0; int acc = 0; unsigned int cmd = 0; unsigned int d = 0; - while (k < count) { - cmd = vf_buf[cur_bute + k]; + while (k < (unsigned) count) { + cmd = vf_buf[cur_bute + (int) k]; k++; if (cmd < set1) { if (ff == 0) { @@ -584,40 +585,40 @@ int count_packet_bytes(eight_bits * vf_buf, int cur_bute, int count) k += 4; break; case xxx1: - d = vf_buf[cur_bute + k]; + d = vf_buf[cur_bute + (int) k]; k++; k += d; - acc += 5 + d; + acc += 5 + (int) d; break; case xxx2: - d = vf_buf[cur_bute + k]; + d = vf_buf[cur_bute + (int) k]; k++; - d = d * 256 + vf_buf[cur_bute + k]; + d = d * 256 + vf_buf[cur_bute + (int) k]; k++; k += d; - acc += 5 + d; + acc += 5 + (int) d; break; case xxx3: - d = vf_buf[cur_bute + k]; + d = vf_buf[cur_bute + (int) k]; k++; - d = d * 256 + vf_buf[cur_bute + k]; + d = d * 256 + vf_buf[cur_bute + (int) k]; k++; - d = d * 256 + vf_buf[cur_bute + k]; + d = d * 256 + vf_buf[cur_bute + (int) k]; k++; k += d; - acc += 5 + d; + acc += 5 + (int) d; break; case xxx4: - d = vf_buf[cur_bute + k]; + d = vf_buf[cur_bute + (int) k]; k++; - d = d * 256 + vf_buf[cur_bute + k]; + d = d * 256 + vf_buf[cur_bute + (int) k]; k++; - d = d * 256 + vf_buf[cur_bute + k]; + d = d * 256 + vf_buf[cur_bute + (int) k]; k++; - d = d * 256 + vf_buf[cur_bute + k]; + d = d * 256 + vf_buf[cur_bute + (int) k]; k++; k += d; - acc += 5 + d; + acc += 5 + (int) d; break; case w0: acc += 5; @@ -650,7 +651,8 @@ void do_vf(internal_font_number f) int k, i; unsigned cmd, n; scaled x, y, w, z, h, v; - int cc, cmd_length, packet_length; + int cc, cmd_length; + unsigned packet_length; charinfo *co; scaled tfm_width; int save_cur_byte; @@ -663,11 +665,12 @@ void do_vf(internal_font_number f) memory_word tmp_w; /* accumulator */ vf_stack_record vf_stack[256]; int junk; + unsigned utmp; unsigned char *vf_buffer; int vf_size; int vf_cur; - int *vf_local_fnts = NULL; /* external font ids */ - int *vf_real_fnts = NULL; /* internal font ids */ + unsigned *vf_local_fnts = NULL; /* external font ids */ + unsigned *vf_real_fnts = NULL; /* internal font ids */ unsigned vf_nf = 0; /* local font counter */ if (font_type(f) != unknown_font_type) @@ -704,7 +707,7 @@ void do_vf(internal_font_number f) save_cur_byte = vf_cur; vf_byte(cmd); while ((cmd >= fnt_def1) && (cmd <= (fnt_def1 + 3))) { - vf_read_u((cmd - fnt_def1 + 1), junk); + vf_read_u((cmd - fnt_def1 + 1), utmp); vf_read(4, junk); vf_read(4, junk); vf_read(4, junk); @@ -721,15 +724,15 @@ void do_vf(internal_font_number f) vf_byte(cmd); /* malloc and fill the local font arrays */ if (vf_nf > 0) { - i = vf_nf * sizeof(int); - vf_local_fnts = xmalloc(i); - memset(vf_local_fnts, 0, i); - vf_real_fnts = xmalloc(i); - memset(vf_real_fnts, 0, i); + unsigned ii = (unsigned) ((unsigned) vf_nf * sizeof(int)); + vf_local_fnts = xmalloc(ii); + memset(vf_local_fnts, 0, ii); + vf_real_fnts = xmalloc(ii); + memset(vf_real_fnts, 0, ii); vf_nf = 0; while ((cmd >= fnt_def1) && (cmd <= (fnt_def1 + 3))) { vf_read_u((cmd - fnt_def1 + 1), vf_local_fnts[vf_nf]); - vf_real_fnts[vf_nf] = vf_def_font(f, vf_buffer, &vf_cur); + vf_real_fnts[vf_nf] = (unsigned) vf_def_font(f, vf_buffer, &vf_cur); incr(vf_nf); vf_byte(cmd); } @@ -741,7 +744,8 @@ void do_vf(internal_font_number f) vf_np = 0; if (cmd == long_char) { vf_read_u(4, packet_length); - vf_read_u(4, cc); + vf_read_u(4, utmp); + cc = (int) utmp; if (!char_exists(f, cc)) { bad_vf("invalid character code"); } @@ -753,11 +757,12 @@ void do_vf(internal_font_number f) if (!char_exists(f, cc)) { bad_vf("invalid character code"); } - vf_read_u(3, k); /* cf. vftovp.web, line 1028 */ + vf_read_u(3, utmp); + k = (int) utmp; /* cf. vftovp.web, line 1028 */ tfm_width = store_scaled_f(k, font_size(f)); } - if (packet_length < 0) - bad_vf("negative packet length"); + + if (tfm_width != char_width(f, cc)) { if (tfm_width != char_width(f, cc)) { print_nlp(); @@ -766,8 +771,8 @@ void do_vf(internal_font_number f) tprint(".vf ignored"); } } - k = count_packet_bytes(vf_buffer, vf_cur, packet_length); - vpackets = xmalloc(k + 1); /* need one extra extra for packet_end */ + k = count_packet_bytes(vf_buffer, vf_cur, (int) packet_length); + vpackets = xmalloc((unsigned) (k + 1)); /* need one extra extra for packet_end */ co = get_charinfo(f, cc); k = 0; w = 0; @@ -780,7 +785,7 @@ void do_vf(internal_font_number f) if (cmd < set1) { if (k == 0) { - k = vf_real_fnts[0]; + k = (int) vf_real_fnts[0]; append_fnt_set(k); } append_packet(packet_char_code); @@ -791,20 +796,21 @@ void do_vf(internal_font_number f) } else if (((fnt_num_0 <= cmd) && (cmd <= fnt_num_0 + 63)) || ((fnt1 <= cmd) && (cmd <= fnt1 + 3))) { if (cmd >= fnt1) { - vf_read_u((cmd - fnt1 + 1), k); + vf_read_u((cmd - fnt1 + 1), utmp); + k = (int) utmp; packet_length -= (cmd - fnt1 + 1); } else { - k = cmd - fnt_num_0; + k = (int) cmd - fnt_num_0; } /* change from local to external font id */ n = 0; - while ((n < vf_nf) && (vf_local_fnts[n] != k)) + while ((n < vf_nf) && (vf_local_fnts[n] != (unsigned) k)) n++; if (n == vf_nf) bad_vf("undefined local font"); - k = vf_real_fnts[n]; + k = (int) vf_real_fnts[n]; append_fnt_set(k); cmd_length = 0; cmd = nop; @@ -833,10 +839,11 @@ void do_vf(internal_font_number f) case set3: case set4: if (k == 0) { - k = vf_real_fnts[0]; + k = (int) vf_real_fnts[0]; append_fnt_set(k); } - vf_read_u((cmd - set1 + 1), i); + vf_read_u((cmd - set1 + 1), utmp); + i = (int) utmp; append_packet(packet_char_code); append_four(i); packet_length -= (cmd - set1 + 1); @@ -846,10 +853,11 @@ void do_vf(internal_font_number f) case put3: case put4: if (k == 0) { - k = vf_real_fnts[0]; + k = (int) vf_real_fnts[0]; append_fnt_set(k); } - vf_read_u((cmd - put1 + 1), i); + vf_read_u((cmd - put1 + 1), utmp); + i = (int) utmp; append_packet(packet_push_code); append_packet(packet_char_code); append_four(i); @@ -914,11 +922,12 @@ void do_vf(internal_font_number f) case xxx2: case xxx3: case xxx4: - vf_read_u((cmd - xxx1 + 1), cmd_length); + vf_read_u((cmd - xxx1 + 1), utmp); + cmd_length = (int) utmp; packet_length -= (cmd - xxx1 + 1); if (cmd_length <= 0) bad_vf("special of negative length"); - packet_length -= cmd_length; + packet_length -= (unsigned) cmd_length; append_packet(packet_special_code); append_four(cmd_length); @@ -1032,13 +1041,14 @@ void do_vf(internal_font_number f) int make_vf_table(lua_State * L, const char *cnom, scaled atsize) { int cmd, k, i; - int cc, cmd_length, packet_length; + int cc; + unsigned cmd_length, packet_length; scaled tfm_width; vf_stack_index stack_level; int vf_z; /* multiplier */ int vf_alpha; /* correction for negative values */ char vf_beta; /* divisor */ - char *s; + eight_bits *s; scaled h, v; scaled w, x, y, z; int s_top; /* lua stack */ @@ -1050,6 +1060,7 @@ int make_vf_table(lua_State * L, const char *cnom, scaled atsize) unsigned char *vf_buffer; int vf_size; int vf_cur; + unsigned utmp; stack_level = 0; @@ -1076,10 +1087,10 @@ int make_vf_table(lua_State * L, const char *cnom, scaled atsize) vf_byte(cmd_length); s = xmalloc(cmd_length); - for (k = 1; k <= cmd_length; k++) + for (k = 1; k <= (int) cmd_length; k++) vf_byte(s[(k - 1)]); - lua_pushlstring(L, s, cmd_length); + lua_pushlstring(L, (char *) s, (size_t) cmd_length); free(s); lua_setfield(L, -2, "header"); @@ -1088,8 +1099,8 @@ int make_vf_table(lua_State * L, const char *cnom, scaled atsize) vf_byte(cs.b2); vf_byte(cs.b3); lua_pushnumber(L, - (unsigned long) (cs.b0 << 24) + (cs.b1 << 16) + - (cs.b2 << 8) + cs.b3); + (lua_Number) ((cs.b0 << 24) + (cs.b1 << 16) + + (cs.b2 << 8) + cs.b3)); lua_setfield(L, -2, "checksum"); vf_read(4, k); @@ -1116,7 +1127,8 @@ int make_vf_table(lua_State * L, const char *cnom, scaled atsize) while ((cmd >= fnt_def1) && (cmd <= fnt_def1 + 3)) { lua_newtable(L); - vf_read_u((cmd - fnt_def1 + 1), vf_nf); + vf_read_u((cmd - fnt_def1 + 1), utmp); + vf_nf = (int) utmp; vf_nf++; /* checksum */ vf_byte(cs.b0); @@ -1140,13 +1152,13 @@ int make_vf_table(lua_State * L, const char *cnom, scaled atsize) vf_byte(k); } /* skip the font path */ - s = xmalloc(tmp_b1 + 1); + s = xmalloc((unsigned) (tmp_b1 + 1)); k = 0; while (tmp_b1-- > 0) vf_byte(s[k++]); s[k] = 0; lua_pushstring(L, "name"); - lua_pushstring(L, xstrdup(s)); + lua_pushstring(L, xstrdup((char *) s)); free(s); lua_rawset(L, -3); @@ -1166,15 +1178,17 @@ int make_vf_table(lua_State * L, const char *cnom, scaled atsize) /* @<Build a character packet@>;@/ */ if (cmd == long_char) { vf_read_u(4, packet_length); - vf_read_u(4, cc); + vf_read_u(4, utmp); + cc = (int) utmp; vf_read(4, tfm_width); } else { - packet_length = cmd; + packet_length = (unsigned) cmd; vf_byte(cc); - vf_read_u(3, tfm_width); + vf_read_u(3, utmp); + tfm_width = (int) utmp; } - if (packet_length < 0) - lua_bad_vf("negative packet length"); + + lua_newtable(L); /* for this character */ @@ -1203,9 +1217,10 @@ int make_vf_table(lua_State * L, const char *cnom, scaled atsize) } else if (((fnt_num_0 <= cmd) && (cmd <= fnt_num_0 + 63)) || ((fnt1 <= cmd) && (cmd <= fnt1 + 3))) { if (cmd >= fnt1) { - vf_read_u((cmd - fnt1 + 1), vf_nf); + vf_read_u((cmd - fnt1 + 1), utmp); + vf_nf = (int) utmp; vf_nf++; - packet_length -= (cmd - fnt1 + 1); + packet_length -= (unsigned) (cmd - fnt1 + 1); } else { vf_nf = cmd - fnt_num_0 + 1; } @@ -1236,9 +1251,10 @@ int make_vf_table(lua_State * L, const char *cnom, scaled atsize) vf_nf = 1; make_command1("font", vf_nf, k); } - vf_read_u((cmd - set1 + 1), i); + vf_read_u((cmd - set1 + 1), utmp); + i = (int) utmp; make_command1("char", i, k); - packet_length -= (cmd - set1 + 1); + packet_length -= (unsigned) (cmd - set1 + 1); break; case put1: case put2: @@ -1248,11 +1264,12 @@ int make_vf_table(lua_State * L, const char *cnom, scaled atsize) vf_nf = 1; make_command1("font", vf_nf, k); } - vf_read_u((cmd - put1 + 1), i); + vf_read_u((cmd - put1 + 1), utmp); + i = (int) utmp; make_command0("push", k); make_command1("char", i, k); make_command0("pop", k); - packet_length -= (cmd - put1 + 1); + packet_length -= (unsigned) (cmd - put1 + 1); break; case right1: case right2: @@ -1260,7 +1277,7 @@ int make_vf_table(lua_State * L, const char *cnom, scaled atsize) case right4: vf_read((cmd - right1 + 1), i); make_command1("right", store_scaled_f(i, atsize), k); - packet_length -= (cmd - right1 + 1); + packet_length -= (unsigned) (cmd - right1 + 1); break; case w1: case w2: @@ -1268,7 +1285,7 @@ int make_vf_table(lua_State * L, const char *cnom, scaled atsize) case w4: vf_read((cmd - w1 + 1), w); make_command1("right", store_scaled_f(w, atsize), k); - packet_length -= (cmd - w1 + 1); + packet_length -= (unsigned) (cmd - w1 + 1); break; case x1: case x2: @@ -1276,7 +1293,7 @@ int make_vf_table(lua_State * L, const char *cnom, scaled atsize) case x4: vf_read((cmd - x1 + 1), x); make_command1("right", store_scaled_f(x, atsize), k); - packet_length -= (cmd - x1 + 1); + packet_length -= (unsigned) (cmd - x1 + 1); break; case down1: case down2: @@ -1284,7 +1301,7 @@ int make_vf_table(lua_State * L, const char *cnom, scaled atsize) case down4: vf_read((cmd - down1 + 1), i); make_command1("down", store_scaled_f(i, atsize), k); - packet_length -= (cmd - down1 + 1); + packet_length -= (unsigned) (cmd - down1 + 1); break; case y1: case y2: @@ -1292,7 +1309,7 @@ int make_vf_table(lua_State * L, const char *cnom, scaled atsize) case y4: vf_read((cmd - y1 + 1), y); make_command1("down", store_scaled_f(y, atsize), k); - packet_length -= (cmd - y1 + 1); + packet_length -= (unsigned) (cmd - y1 + 1); break; case z1: case z2: @@ -1300,19 +1317,19 @@ int make_vf_table(lua_State * L, const char *cnom, scaled atsize) case z4: vf_read((cmd - z1 + 1), z); make_command1("down", store_scaled_f(z, atsize), k); - packet_length -= (cmd - z1 + 1); + packet_length -= (unsigned) (cmd - z1 + 1); break; case xxx1: case xxx2: case xxx3: case xxx4: vf_read_u((cmd - xxx1 + 1), cmd_length); - packet_length -= (cmd - xxx1 + 1); + packet_length -= (unsigned) (cmd - xxx1 + 1); if (cmd_length <= 0) lua_bad_vf("special of negative length"); packet_length -= cmd_length; - s = xmalloc(cmd_length + 1); + s = xmalloc((cmd_length + 1)); i = 0; while (cmd_length > 0) { cmd_length--; @@ -1320,7 +1337,8 @@ int make_vf_table(lua_State * L, const char *cnom, scaled atsize) i++; } s[i] = 0; - make_commands("special", strdup(s), i, k); + make_commands("special", xstrdup((char *) s), (size_t) i, + k); free(s); break; case w0: @@ -1409,7 +1427,7 @@ boolean auto_expand_vf(internal_font_number f) vf_old_fonts = packet_local_fonts(bf, &num); if (num > 0) { - vf_new_fonts = xmalloc(num * sizeof(int)); + vf_new_fonts = xmalloc((unsigned) ((unsigned) num * sizeof(int))); for (k = 0; k < num; k++) { vf_new_fonts[k] = auto_expand_font(vf_old_fonts[k], e); copy_expand_params(vf_new_fonts[k], vf_old_fonts[k], e); @@ -1446,9 +1464,10 @@ internal_font_number auto_expand_font(internal_font_number f, int e) int i; scaled w; k = copy_font(f); - i = strlen(font_name(f)) + 12; - fn = xmalloc(i); - snprintf(fn, i, "%s%s%d", font_name(f), (e > 0 ? "+" : ""), (int) e); + i = (int) strlen(font_name(f)) + 12; + fn = xmalloc((unsigned) i); + snprintf(fn, (size_t) i, "%s%s%d", font_name(f), (e > 0 ? "+" : ""), + (int) e); set_font_name(k, fn); for (i = font_bc(k); i <= font_ec(k); i++) { if (quick_char_exists(k, i)) { @@ -1514,7 +1533,7 @@ letter_space_font(halfword u, internal_font_number f, int e) } */ /* append eg '+100ls' to font name */ - new_font_name = xmalloc(strlen(font_name(k)) + 8); /* |abs(e) <= 1000| */ + new_font_name = xmalloc((unsigned) (strlen(font_name(k)) + 8)); /* |abs(e) <= 1000| */ if (e > 0) { sprintf(new_font_name, "%s+%ils", font_name(k), (int) e); } else { @@ -1536,20 +1555,20 @@ letter_space_font(halfword u, internal_font_number f, int e) w = vf_alpha + w; } r = w * vf_beta; - tmp_b1 = r / vf_z; + tmp_b1 = (quarterword) (r / vf_z); r = r % vf_z; if (r == 0) { tmp_b2 = 0; } else { r = r * 256; - tmp_b2 = r / vf_z; + tmp_b2 = (quarterword) (r / vf_z); r = r % vf_z; } if (r == 0) { tmp_b3 = 0; } else { r = r * 256; - tmp_b3 = r / vf_z; + tmp_b3 = (quarterword) (r / vf_z); } /* vf_packet_base[k] = new_vf_packet(k); diff --git a/source/texk/web2c/luatexdir/font/vfpacket.c b/source/texk/web2c/luatexdir/font/vfpacket.c index 02b97eebee240bd7d7491671efcd7cd6d5fda85a..0e89426e126b0ee2b158166b31bd2af4e2374e86 100644 --- a/source/texk/web2c/luatexdir/font/vfpacket.c +++ b/source/texk/web2c/luatexdir/font/vfpacket.c @@ -99,7 +99,7 @@ int vf_packet_bytes(charinfo * co) break; case packet_special_code: packet_number(k); /* +4 */ - cur_packet_byte += k; + cur_packet_byte = (cur_packet_byte + (int) k); break; case packet_image_code: cur_packet_byte += 4; @@ -117,7 +117,7 @@ int vf_packet_bytes(charinfo * co) /* typeset the \.{DVI} commands in the character packet for character |c| in current font |f| */ -char *packet_command_names[] = { +const char *packet_command_names[] = { "char", "font", "pop", "push", "special", "image", "right", "down", "rule", "node", "nop", "end", NULL }; @@ -181,15 +181,15 @@ void do_vf_packet(PDF pdf, internal_font_number vf_f, int c) break; case packet_char_code: packet_number(k); - if (!char_exists(lf, k)) { - char_warning(lf, k); + if (!char_exists(lf, (int) k)) { + char_warning(lf, (int) k); } else { - if (has_packet(lf, k)) - do_vf_packet(pdf, lf, k); + if (has_packet(lf, (int) k)) + do_vf_packet(pdf, lf, (int) k); else - pdf_place_glyph(pdf, lf, k); + pdf_place_glyph(pdf, lf, (int) k); } - cur.h = cur.h + char_width(lf, k); + cur.h = cur.h + char_width(lf, (int) k); break; case packet_rule_code: packet_scaled(size.v, fs_f); /* height (where is depth?) */ @@ -223,7 +223,7 @@ void do_vf_packet(PDF pdf, internal_font_number vf_f, int c) break; case packet_node_code: packet_number(k); - hlist_out(pdf, k); + hlist_out(pdf, (halfword) k); break; case packet_nop_code: break; @@ -295,8 +295,8 @@ int *packet_local_fonts(internal_font_number f, int *num) } *num = k; if (k > 0) { - lfs = xmalloc(k * sizeof(int)); - memcpy(lfs, localfonts, k * sizeof(int)); + lfs = xmalloc((unsigned) ((unsigned) k * sizeof(int))); + memcpy(lfs, localfonts, (size_t) ((unsigned) k * sizeof(int))); return lfs; } return NULL; @@ -331,13 +331,14 @@ replace_packet_fonts(internal_font_number f, int *old_fontid, } if (l < count) { k = new_fontid[l]; - vf_packets[(cur_packet_byte - 4)] = - (k & 0xFF000000) >> 24; - vf_packets[(cur_packet_byte - 3)] = - (k & 0x00FF0000) >> 16; - vf_packets[(cur_packet_byte - 2)] = - (k & 0x0000FF00) >> 8; - vf_packets[(cur_packet_byte - 1)] = (k & 0x000000FF); + vf_packets[(cur_packet_byte - 4)] = (eight_bits) + ((k & 0xFF000000) >> 24); + vf_packets[(cur_packet_byte - 3)] = (eight_bits) + ((k & 0x00FF0000) >> 16); + vf_packets[(cur_packet_byte - 2)] = (eight_bits) + ((k & 0x0000FF00) >> 8); + vf_packets[(cur_packet_byte - 1)] = + (eight_bits) (k & 0x000000FF); } break; case packet_push_code: diff --git a/source/texk/web2c/luatexdir/font/writecff.c b/source/texk/web2c/luatexdir/font/writecff.c index b82bb9e0a5ac0645a8ea75d452f9d6c4a8d8599f..855685aadacc34b7fda85f3810d52f59b09f874b 100644 --- a/source/texk/web2c/luatexdir/font/writecff.c +++ b/source/texk/web2c/luatexdir/font/writecff.c @@ -162,7 +162,8 @@ cff_index *cff_get_index_header(cff_font * cff) if (idx->offsize < 1 || idx->offsize > 4) CFF_ERROR("invalid offsize data"); - idx->offset = xmalloc((unsigned) (count + 1) * sizeof(l_offset)); + idx->offset = + xmalloc((unsigned) (((unsigned) count + 1) * sizeof(l_offset))); for (i = 0; i < count + 1; i++) { (idx->offset)[i] = get_offset(cff, idx->offsize); } @@ -196,7 +197,8 @@ cff_index *cff_get_index(cff_font * cff) if (idx->offsize < 1 || idx->offsize > 4) CFF_ERROR("invalid offsize data"); - idx->offset = xmalloc((unsigned) (count + 1) * sizeof(l_offset)); + idx->offset = + xmalloc((unsigned) (((unsigned) count + 1) * sizeof(l_offset))); for (i = 0; i < count + 1; i++) { idx->offset[i] = get_offset(cff, idx->offsize); } @@ -776,7 +778,7 @@ static void add_dict(cff_dict * dict, if (stack_top > 0) { (dict->entries)[dict->count].count = stack_top; (dict->entries)[dict->count].values = - xmalloc((unsigned) stack_top * sizeof(double)); + xmalloc((unsigned) ((unsigned) stack_top * sizeof(double))); while (stack_top > 0) { stack_top--; (dict->entries)[dict->count].values[stack_top] = @@ -987,7 +989,7 @@ long cff_read_fdarray(cff_font * cff) cff->offset = (l_offset) offset; idx = cff_get_index(cff); cff->num_fds = (card8) idx->count; - cff->fdarray = xmalloc(idx->count * sizeof(cff_dict *)); + cff->fdarray = xmalloc((unsigned) (idx->count * sizeof(cff_dict *))); for (i = 0; i < idx->count; i++) { card8 *data = idx->data + (idx->offset)[i] - 1; size = (long) ((idx->offset)[i + 1] - (idx->offset)[i]); @@ -1016,7 +1018,7 @@ long cff_read_private(cff_font * cff) if (cff->fdarray == NULL) cff_read_fdarray(cff); - cff->private = xmalloc(cff->num_fds * sizeof(cff_dict *)); + cff->private = xmalloc((unsigned) (cff->num_fds * sizeof(cff_dict *))); for (i = 0; i < cff->num_fds; i++) { if (cff->fdarray[i] != NULL && cff_dict_known(cff->fdarray[i], "Private") && @@ -1669,7 +1671,8 @@ long cff_read_charsets(cff_font * cff) switch (charset->format) { case 0: charset->num_entries = (card16) (cff->num_glyphs - 1); /* no .notdef */ - charset->data.glyphs = xmalloc(charset->num_entries * sizeof(s_SID)); + charset->data.glyphs = + xmalloc((unsigned) (charset->num_entries * sizeof(s_SID))); length += (charset->num_entries) * 2; for (i = 0; i < (charset->num_entries); i++) { charset->data.glyphs[i] = get_card16(cff); @@ -3262,9 +3265,8 @@ void write_cid_cff(PDF pdf, cff_font * cffont, fd_entry * fd) cid_count = CFF_CIDCOUNT_DEFAULT; } cff_read_charsets(cffont); - CIDToGIDMap = - xmalloc((unsigned) - ((2 * (unsigned) cid_count) * sizeof(unsigned char))); + CIDToGIDMap = xmalloc((unsigned) + ((2 * (unsigned) cid_count) * sizeof(unsigned char))); memset(CIDToGIDMap, 0, (size_t) (2 * cid_count)); diff --git a/source/texk/web2c/luatexdir/image/writeimg.c b/source/texk/web2c/luatexdir/image/writeimg.c index c40274c7dde45738655bfdc5b5cb6dfd5633678b..bcbb59ee400ac03628d150247fb77c9bda37a1ef 100644 --- a/source/texk/web2c/luatexdir/image/writeimg.c +++ b/source/texk/web2c/luatexdir/image/writeimg.c @@ -133,7 +133,7 @@ static void check_type_by_header(image_dict * idict) /* read the header */ file = xfopen(img_filepath(idict), FOPEN_RBIN_MODE); for (i = 0; (unsigned) i < MAX_HEADER; i++) { - header[i] = (char)xgetc(file); + header[i] = (char) xgetc(file); if (feof(file)) pdftex_fail("reading image file failed"); } @@ -699,7 +699,7 @@ void dumpimagemeta(void) i = (int) idict_limit; dumpinteger(i); - cur_index = (int)(idict_ptr - idict_array); + cur_index = (int) (idict_ptr - idict_array); dumpinteger(cur_index); for (i = 1; i < cur_index; i++) { @@ -735,7 +735,7 @@ void undumpimagemeta(PDF pdf, int pdfversion, int pdfinclusionerrorlevel) assert(pdf != NULL); undumpinteger(i); - idict_limit = (size_t)i; + idict_limit = (size_t) i; idict_array = xtalloc(idict_limit, idict_entry); undumpinteger(cur_index); diff --git a/source/texk/web2c/luatexdir/image/writejbig2.c b/source/texk/web2c/luatexdir/image/writejbig2.c index 2216d38d9ef64953c6630acf6d0406d2a305e982..d3d83cf949de4e901d907aadf8ad1747dec91eb2 100644 --- a/source/texk/web2c/luatexdir/image/writejbig2.c +++ b/source/texk/web2c/luatexdir/image/writejbig2.c @@ -195,13 +195,15 @@ static int comp_file_entry(const void *pa, const void *pb, void *p) static int comp_page_entry(const void *pa, const void *pb, void *p) { (void) p; - return (int)(((const PAGEINFO *) pa)->pagenum - ((const PAGEINFO *) pb)->pagenum); + return (int) (((const PAGEINFO *) pa)->pagenum - + ((const PAGEINFO *) pb)->pagenum); } static int comp_segment_entry(const void *pa, const void *pb, void *p) { (void) p; - return (int)(((const SEGINFO *) pa)->segnum - ((const SEGINFO *) pb)->segnum); + return (int) (((const SEGINFO *) pa)->segnum - + ((const SEGINFO *) pb)->segnum); } /**********************************************************************/ @@ -353,8 +355,8 @@ static SEGINFO *find_seginfo(LIST * slp, unsigned long segnum) static unsigned int read2bytes(FILE * f) { - unsigned int c = (unsigned int)ygetc(f); - return (c << 8) + (unsigned int)ygetc(f); + unsigned int c = (unsigned int) ygetc(f); + return (c << 8) + (unsigned int) ygetc(f); } static unsigned long read4bytes(FILE * f) @@ -391,7 +393,7 @@ static void readfilehdr(FILEINFO * fip) pdftex_fail ("readfilehdr(): reading JBIG2 image file failed: ID string missing"); /* Annex D.4.2 File header flags */ - fip->filehdrflags = (unsigned int)ygetc(fip->file); + fip->filehdrflags = (unsigned int) ygetc(fip->file); fip->sequentialaccess = (fip->filehdrflags & 0x01) ? true : false; if (fip->sequentialaccess) { /* Annex D.1 vs. Annex D.2 */ xfseek(fip->file, 0, SEEK_END, fip->filepath); @@ -470,7 +472,7 @@ static boolean readseghdr(FILEINFO * fip, SEGINFO * sip) printf(" segnum %d\n", sip->segnum); #endif /* 7.2.3 Segment header flags */ - sip->seghdrflags = (unsigned int)ygetc(fip->file); + sip->seghdrflags = (unsigned int) ygetc(fip->file); #ifdef DEBUG printf(" hdrflags %d\n", sip->seghdrflags & 0x3f); #endif @@ -509,7 +511,7 @@ static boolean readseghdr(FILEINFO * fip, SEGINFO * sip) } /* 7.2.6 Segment page association */ if (sip->pageassocsizeflag) - sip->segpage = (long int)read4bytes(fip->file); + sip->segpage = (long int) read4bytes(fip->file); else sip->segpage = ygetc(fip->file); /* 7.2.7 Segment data length */ @@ -552,7 +554,7 @@ static void writeseghdr(PDF pdf, FILEINFO * fip, SEGINFO * sip) for (i = 0; i < sip->countofrefered; i++) { switch (sip->segnumwidth) { case 1: - referedseg = (unsigned long)ygetc(fip->file); + referedseg = (unsigned long) ygetc(fip->file); pdf_out(pdf, referedseg); break; case 2: @@ -580,7 +582,7 @@ static void writeseghdr(PDF pdf, FILEINFO * fip, SEGINFO * sip) pdf_out(pdf, 0); } (void) ygetc(fip->file); - pdf_out(pdf, (unsigned char)((sip->segpage > 0) ? 1 : 0)); + pdf_out(pdf, (unsigned char) ((sip->segpage > 0) ? 1 : 0)); /* 7.2.7 Segment data length */ for (i = 0; i < 4; i++) pdf_out(pdf, ygetc(fip->file)); @@ -602,7 +604,7 @@ static void checkseghdr(FILEINFO * fip, SEGINFO * sip) for (i = 0; i < sip->countofrefered; i++) { switch (sip->segnumwidth) { case 1: - referedseg = (unsigned long)ygetc(fip->file); + referedseg = (unsigned long) ygetc(fip->file); break; case 2: referedseg = read2bytes(fip->file); @@ -666,7 +668,7 @@ static void rd_jbig2_info(FILEINFO * fip) if (sip->segpage > (int) currentpage) { plp = litem_append(&(fip->pages)); plp->last->d = new_pageinfo(); - currentpage = (unsigned long)sip->segpage; + currentpage = (unsigned long) sip->segpage; } pip = fip->pages.last->d; } else { @@ -688,31 +690,31 @@ static void rd_jbig2_info(FILEINFO * fip) sip->dataend = sip->datastart + sip->segdatalen; if (!fip->sequentialaccess && (sip->pageinfoflag || sip->endofstripeflag)) - xfseeko(fip->file, (off_t)sip->datastart, SEEK_SET, fip->filepath); + xfseeko(fip->file, (off_t) sip->datastart, SEEK_SET, fip->filepath); seekdist = sip->segdatalen; /* 7.4.8 Page information segment syntax */ if (sip->pageinfoflag) { - pip->pagenum = (unsigned long)sip->segpage; - pip->width = (unsigned)read4bytes(fip->file); - pip->height = (unsigned)read4bytes(fip->file); - pip->xres = (unsigned)read4bytes(fip->file); - pip->yres = (unsigned)read4bytes(fip->file); - pip->pagesegmentflags = (unsigned)ygetc(fip->file); + pip->pagenum = (unsigned long) sip->segpage; + pip->width = (unsigned) read4bytes(fip->file); + pip->height = (unsigned) read4bytes(fip->file); + pip->xres = (unsigned) read4bytes(fip->file); + pip->yres = (unsigned) read4bytes(fip->file); + pip->pagesegmentflags = (unsigned) ygetc(fip->file); /* 7.4.8.6 Page striping information */ pip->stripinginfo = read2bytes(fip->file); seekdist -= 19; } if (sip->endofstripeflag) { - pip->stripedheight = (unsigned)read4bytes(fip->file); + pip->stripedheight = (unsigned) read4bytes(fip->file); seekdist -= 4; } if (!fip->sequentialaccess && (sip->pageinfoflag || sip->endofstripeflag)) - xfseeko(fip->file, (off_t)sip->hdrend, SEEK_SET, fip->filepath); + xfseeko(fip->file, (off_t) sip->hdrend, SEEK_SET, fip->filepath); if (!fip->sequentialaccess) streampos += sip->segdatalen; if (fip->sequentialaccess) - xfseeko(fip->file, (off_t)seekdist, SEEK_CUR, fip->filepath); + xfseeko(fip->file, (off_t) seekdist, SEEK_CUR, fip->filepath); if (sip->endofpageflag && currentpage && (pip->stripinginfo >> 15)) pip->height = pip->stripedheight; } @@ -744,7 +746,7 @@ static void wr_jbig2(PDF pdf, FILEINFO * fip, unsigned long page) if (fip->page0.last != NULL) { if (fip->pdfpage0objnum == 0) { pdf_create_obj(pdf, obj_type_others, 0); - fip->pdfpage0objnum = (unsigned long)pdf->obj_ptr; + fip->pdfpage0objnum = (unsigned long) pdf->obj_ptr; } pdf_printf(pdf, "/DecodeParms [<< /JBIG2Globals %lu 0 R >>]\n", fip->pdfpage0objnum); @@ -752,7 +754,7 @@ static void wr_jbig2(PDF pdf, FILEINFO * fip, unsigned long page) } else { pip = find_pageinfo(&(fip->page0), page); assert(pip != NULL); - pdf_begin_dict(pdf, (int)fip->pdfpage0objnum, 0); + pdf_begin_dict(pdf, (int) fip->pdfpage0objnum, 0); pdf_printf(pdf, "/Length %lu\n", getstreamlen(pip->segments.first, false)); } @@ -762,10 +764,10 @@ static void wr_jbig2(PDF pdf, FILEINFO * fip, unsigned long page) for (slip = pip->segments.first; slip != NULL; slip = slip->next) { /* loop over page segments */ sip = slip->d; if (sip->isrefered || page > 0) { - xfseeko(fip->file, (off_t)sip->hdrstart, SEEK_SET, fip->filepath); + xfseeko(fip->file, (off_t) sip->hdrstart, SEEK_SET, fip->filepath); /* mark refered-to page 0 segments, change segpages > 1 to 1 */ writeseghdr(pdf, fip, sip); - xfseeko(fip->file, (off_t)sip->datastart, SEEK_SET, fip->filepath); + xfseeko(fip->file, (off_t) sip->datastart, SEEK_SET, fip->filepath); for (i = sip->datastart; i < sip->dataend; i++) pdf_out(pdf, ygetc(fip->file)); } @@ -808,13 +810,13 @@ void read_jbig2_info(image_dict * idict) segments_maketree(&(pip->segments)); } } - pip = find_pageinfo(&(fip->pages), (unsigned long)img_pagenum(idict)); + pip = find_pageinfo(&(fip->pages), (unsigned long) img_pagenum(idict)); if (pip == NULL) pdftex_fail("read_jbig2_info(): page %d not found in JBIG2 image file", (int) img_pagenum(idict)); - img_totalpages(idict) = (int)fip->numofpages; - img_xsize(idict) = (int)pip->width; - img_ysize(idict) = (int)pip->height; + img_totalpages(idict) = (int) fip->numofpages; + img_xsize(idict) = (int) pip->width; + img_ysize(idict) = (int) pip->height; img_xres(idict) = (int) (pip->xres * 0.0254 + 0.5); img_yres(idict) = (int) (pip->yres * 0.0254 + 0.5); img_colordepth(idict) = 1; @@ -830,7 +832,7 @@ void write_jbig2(PDF pdf, image_dict * idict) fip = (FILEINFO *) avl_find(file_tree, &tmp); assert(fip != NULL); assert(fip->phase == HAVEINFO); /* don't write before rd_jbig2_info() call */ - pip = find_pageinfo(&(fip->pages), (unsigned long)img_pagenum(idict)); + pip = find_pageinfo(&(fip->pages), (unsigned long) img_pagenum(idict)); assert(pip != NULL); wr_jbig2(pdf, fip, pip->pagenum); img_file(idict) = NULL; diff --git a/source/texk/web2c/luatexdir/image/writejpg.c b/source/texk/web2c/luatexdir/image/writejpg.c index beb3da94be911f37a47c9a5dd6afda087ad074dd..f42dc43dcba1a87d08c0e132e7d0483a371eb1a8 100644 --- a/source/texk/web2c/luatexdir/image/writejpg.c +++ b/source/texk/web2c/luatexdir/image/writejpg.c @@ -100,7 +100,7 @@ typedef enum { /* JPEG marker codes */ static JPG_UINT16 read2bytes(FILE * f) { int c = xgetc(f); - return (JPG_UINT16)((c << 8) + (int)xgetc(f)); + return (JPG_UINT16) ((c << 8) + (int) xgetc(f)); } static void close_and_cleanup_jpg(image_dict * idict) @@ -143,14 +143,14 @@ void read_jpg_info(PDF pdf, image_dict * idict, img_readtype_e readtype) if (i == 5) { /* it's JFIF */ read2bytes(img_file(idict)); units = xgetc(img_file(idict)); - img_xres(idict) = (int)read2bytes(img_file(idict)); - img_yres(idict) = (int)read2bytes(img_file(idict)); + img_xres(idict) = (int) read2bytes(img_file(idict)); + img_yres(idict) = (int) read2bytes(img_file(idict)); switch (units) { case 1: break; /* pixels per inch */ case 2: - img_xres(idict) = (int)((double)img_xres(idict) * 2.54); - img_yres(idict) = (int)((double)img_yres(idict) * 2.54); + img_xres(idict) = (int) ((double) img_xres(idict) * 2.54); + img_yres(idict) = (int) ((double) img_yres(idict) * 2.54); break; /* pixels per cm */ default: img_xres(idict) = img_yres(idict) = 0; @@ -190,8 +190,8 @@ void read_jpg_info(PDF pdf, image_dict * idict, img_readtype_e readtype) case M_SOF3: (void) read2bytes(img_file(idict)); /* read segment length */ img_colordepth(idict) = xgetc(img_file(idict)); - img_ysize(idict) = (int)read2bytes(img_file(idict)); - img_xsize(idict) = (int)read2bytes(img_file(idict)); + img_ysize(idict) = (int) read2bytes(img_file(idict)); + img_xsize(idict) = (int) read2bytes(img_file(idict)); img_jpg_color(idict) = xgetc(img_file(idict)); xfseek(img_file(idict), 0, SEEK_SET, img_filepath(idict)); switch (img_jpg_color(idict)) { diff --git a/source/texk/web2c/luatexdir/image/writepng.c b/source/texk/web2c/luatexdir/image/writepng.c index 70f6e81eacb18c33b5f6b2d178bf979e1652456c..d6720e7cb3597e4c8fbf82256d2b9f774fc8167d 100644 --- a/source/texk/web2c/luatexdir/image/writepng.c +++ b/source/texk/web2c/luatexdir/image/writepng.c @@ -90,13 +90,13 @@ void read_png_info(PDF pdf, image_dict * idict, img_readtype_e readtype) /* reset structure */ png_read_update_info(png_p, info_p); /* resolution support */ - img_xsize(idict) = (int)info_p->width; - img_ysize(idict) = (int)info_p->height; + img_xsize(idict) = (int) info_p->width; + img_ysize(idict) = (int) info_p->height; if (info_p->valid & PNG_INFO_pHYs) { - img_xres(idict) = - round(0.0254 * (double)png_get_x_pixels_per_meter(png_p, info_p)); - img_yres(idict) = - round(0.0254 * (double)png_get_y_pixels_per_meter(png_p, info_p)); + img_xres(idict) = + round(0.0254 * (double) png_get_x_pixels_per_meter(png_p, info_p)); + img_yres(idict) = + round(0.0254 * (double) png_get_y_pixels_per_meter(png_p, info_p)); } switch (info_p->color_type) { case PNG_COLOR_TYPE_PALETTE: @@ -260,8 +260,8 @@ static void write_png_gray_alpha(PDF pdf, image_dict * idict) pdf_create_obj(pdf, obj_type_others, 0); smask_objnum = pdf->obj_ptr; pdf_printf(pdf, "/SMask %i 0 R\n", (int) smask_objnum); - smask_size = (int)((info_p->rowbytes / 2) * info_p->height); - smask = xtalloc((unsigned)smask_size, png_byte); + smask_size = (int) ((info_p->rowbytes / 2) * info_p->height); + smask = xtalloc((unsigned) smask_size, png_byte); pdf_begin_stream(pdf); if (info_p->interlace_type == PNG_INTERLACE_NONE) { row = xtalloc(info_p->rowbytes, png_byte); @@ -359,8 +359,8 @@ static void write_png_rgb_alpha(PDF pdf, image_dict * idict) pdf_create_obj(pdf, obj_type_others, 0); smask_objnum = pdf->obj_ptr; pdf_printf(pdf, "/SMask %i 0 R\n", (int) smask_objnum); - smask_size = (int)((info_p->rowbytes / 2) * info_p->height); - smask = xtalloc((unsigned)smask_size, png_byte); + smask_size = (int) ((info_p->rowbytes / 2) * info_p->height); + smask = xtalloc((unsigned) smask_size, png_byte); pdf_begin_stream(pdf); if (info_p->interlace_type == PNG_INTERLACE_NONE) { row = xtalloc(info_p->rowbytes, png_byte); @@ -487,7 +487,7 @@ static void copy_png(PDF pdf, image_dict * idict) while (len > 0) { i = (len > pdf->buf_size) ? pdf->buf_size : len; pdf_room(pdf, i); - fread(&pdf->buf[pdf->ptr], 1, (size_t)i, fp); + fread(&pdf->buf[pdf->ptr], 1, (size_t) i, fp); pdf->ptr += i; len -= i; } diff --git a/source/texk/web2c/luatexdir/lang/hyphen.c b/source/texk/web2c/luatexdir/lang/hyphen.c index 778c6ab8a3cbbcf71fcd7542249ccecaaf44ebce..e27de8b9ff20cec6a14743253e310a39b786b2ae 100644 --- a/source/texk/web2c/luatexdir/lang/hyphen.c +++ b/source/texk/web2c/luatexdir/lang/hyphen.c @@ -63,7 +63,7 @@ static unsigned char *hnj_strdup(const unsigned char *s) size_t l; l = strlen((const char *) s); - new = hnj_malloc((int)l + 1); + new = hnj_malloc((int) l + 1); memcpy(new, s, l); new[l] = 0; return new; @@ -252,7 +252,7 @@ static void state_insert(HashTab * hashtab, unsigned char *key, int state) int i; HashEntry *e; - i = (int)(hnj_string_hash(key) % HASH_SIZE); + i = (int) (hnj_string_hash(key) % HASH_SIZE); e = hnj_malloc(sizeof(HashEntry)); e->next = hashtab->entries[i]; e->key = key; @@ -267,7 +267,7 @@ static void hyppat_insert(HashTab * hashtab, unsigned char *key, char *hyppat) int i; HashEntry *e; - i = (int)(hnj_string_hash(key) % HASH_SIZE); + i = (int) (hnj_string_hash(key) % HASH_SIZE); for (e = hashtab->entries[i]; e; e = e->next) { if (strcmp((char *) e->key, (char *) key) == 0) { if (e->u.hyppat) { @@ -297,7 +297,7 @@ static int state_lookup(HashTab * hashtab, const unsigned char *key) int i; HashEntry *e; - i = (int)(hnj_string_hash(key) % HASH_SIZE); + i = (int) (hnj_string_hash(key) % HASH_SIZE); for (e = hashtab->entries[i]; e; e = e->next) { if (!strcmp((const char *) key, (const char *) e->key)) { return e->u.state; @@ -313,9 +313,9 @@ static char *hyppat_lookup(HashTab * hashtab, const unsigned char *chars, int l) int i; HashEntry *e; unsigned char key[128]; /* should be ample */ - strncpy((char *) key, (const char *) chars, (size_t)l); + strncpy((char *) key, (const char *) chars, (size_t) l); key[l] = 0; - i = (int)(hnj_string_hash(key) % HASH_SIZE); + i = (int) (hnj_string_hash(key) % HASH_SIZE); for (e = hashtab->entries[i]; e; e = e->next) { if (!strcmp((char *) key, (char *) e->key)) { return e->u.hyppat; @@ -338,7 +338,8 @@ static int hnj_get_state(HyphenDict * dict, /* predicate is true if dict->num_states is a power of two */ if (!(dict->num_states & (dict->num_states - 1))) { dict->states = hnj_realloc(dict->states, - (int)((dict->num_states << 1) * (int)sizeof(HyphenState))); + (int) ((dict->num_states << 1) * + (int) sizeof(HyphenState))); } dict->states[dict->num_states].match = NULL; dict->states[dict->num_states].fallback_state = -1; @@ -367,8 +368,8 @@ static void hnj_add_trans(HyphenDict * dict, int state1, int state2, int uni_ch) dict->states[state1].trans = hnj_malloc(sizeof(HyphenTrans)); } else if (!(num_trans & (num_trans - 1))) { dict->states[state1].trans = hnj_realloc(dict->states[state1].trans, - (int)(num_trans << 1 * - sizeof(HyphenTrans))); + (int) (num_trans << 1 * + sizeof(HyphenTrans))); } dict->states[state1].trans[num_trans].uni_ch = uni_ch; dict->states[state1].trans[num_trans].new_state = state2; @@ -405,13 +406,13 @@ static const unsigned char *next_pattern(size_t * length, here = rover; while (*rover) { if (isspace(*rover)) { - *length = (size_t)(rover - here); + *length = (size_t) (rover - here); *buf = rover; return here; } rover++; } - *length = (size_t)(rover - here); + *length = (size_t) (rover - here); *buf = rover; return *length ? here : NULL; /* zero sensed */ } @@ -616,8 +617,8 @@ void hnj_hyphen_load(HyphenDict * dict, const unsigned char *f) /* l-e => number of _characters_ not _bytes_ */ /* l-j => number of pattern bytes */ /* l-e-j => number of pattern characters */ - pat = (unsigned char *) malloc((1 + l - (size_t)j)); - org = (char *) malloc((size_t)(2 + l - (size_t)e - (size_t)j)); + pat = (unsigned char *) malloc((1 + l - (size_t) j)); + org = (char *) malloc((size_t) (2 + l - (size_t) e - (size_t) j)); /* remove hyphenation encoders (digits) from pat */ org[0] = '0'; for (i = 0, j = 0, e = 0; (unsigned) i < l; i++) { @@ -628,18 +629,18 @@ void hnj_hyphen_load(HyphenDict * dict, const unsigned char *f) pat[e + j++] = c; org[j] = '0'; } else { - org[j] = (char)c; + org[j] = (char) c; } } pat[e + j] = 0; org[j + 1] = 0; hyppat_insert(dict->patterns, pat, org); } - dict->pat_length += (int)((f - begin) + 2); /* 2 for spurious spaces */ + dict->pat_length += (int) ((f - begin) + 2); /* 2 for spurious spaces */ init_hash(&dict->merged); v = new_HashIter(dict->patterns); while (nextHash(v, &word)) { - int wordsize = (int)strlen((char *) word); + int wordsize = (int) strlen((char *) word); int j, l; for (l = 1; l <= wordsize; l++) { if (is_utf8_follow(word[l])) @@ -656,14 +657,14 @@ void hnj_hyphen_load(HyphenDict * dict, const unsigned char *f) hyppat_lookup(dict->merged, word, l)) == NULL) { char *neworg; unsigned char *newword = - (unsigned char *) malloc((size_t)(l + 1)); + (unsigned char *) malloc((size_t) (l + 1)); int e = 0; - strncpy((char *) newword, (char *) word, (size_t)l); + strncpy((char *) newword, (char *) word, (size_t) l); newword[l] = 0; for (i = 0; i < l; i++) if (is_utf8_follow(newword[i])) e++; - neworg = malloc((size_t)(l + 2 - e)); + neworg = malloc((size_t) (l + 2 - e)); sprintf(neworg, "%0*d", l + 1 - e, 0); /* fill with right amount of '0' */ hyppat_insert(dict->merged, newword, combine(neworg, subpat_pat)); @@ -681,7 +682,7 @@ void hnj_hyphen_load(HyphenDict * dict, const unsigned char *f) v = new_HashIter(dict->merged); while (nextHashStealPattern(v, &word, &pattern)) { static unsigned char mask[] = { 0x3F, 0x1F, 0xF, 0x7 }; - int j = (int)strlen((char *) word); + int j = (int) strlen((char *) word); #ifdef VERBOSE printf("word %s pattern %s, j = %d\n", word, pattern, j); #endif @@ -798,7 +799,7 @@ void hnj_hyphen_hyphenate(HyphenDict * dict, * 1 string length is one bigger than offset * 1 hyphenation starts before first character */ - int offset = (int)(char_num + 2 - (int)strlen(match)); + int offset = (int) (char_num + 2 - (int) strlen(match)); /* printf ("%*s%s\n", offset,"", match); */ int m; for (m = 0; match[m]; m++) { diff --git a/source/texk/web2c/luatexdir/lang/texlang.c b/source/texk/web2c/luatexdir/lang/texlang.c index da858fbdce9a07b27f9d5ed7824140b39969a050..46092f93dc198c4b1384002ba297db5dda30b40d 100644 --- a/source/texk/web2c/luatexdir/lang/texlang.c +++ b/source/texk/web2c/luatexdir/lang/texlang.c @@ -35,27 +35,27 @@ static char *uni2string(char *utf8_text, unsigned ch) return (utf8_text); if (ch <= 127) - *utf8_text++ = (char)ch; + *utf8_text++ = (char) ch; else if (ch <= 0x7ff) { - *utf8_text++ = (char)(0xc0 | (ch >> 6)); - *utf8_text++ = (char)(0x80 | (ch & 0x3f)); + *utf8_text++ = (char) (0xc0 | (ch >> 6)); + *utf8_text++ = (char) (0x80 | (ch & 0x3f)); } else if (ch <= 0xffff) { - *utf8_text++ = (char)(0xe0 | (ch >> 12)); - *utf8_text++ = (char)(0x80 | ((ch >> 6) & 0x3f)); - *utf8_text++ = (char)(0x80 | (ch & 0x3f)); + *utf8_text++ = (char) (0xe0 | (ch >> 12)); + *utf8_text++ = (char) (0x80 | ((ch >> 6) & 0x3f)); + *utf8_text++ = (char) (0x80 | (ch & 0x3f)); } else { unsigned val = ch - 0x10000; unsigned u = ((val & 0xf0000) >> 16) + 1, z = (val & 0x0f000) >> 12, y = (val & 0x00fc0) >> 6, x = val & 0x0003f; - *utf8_text++ = (char)(0xf0 | (u >> 2)); - *utf8_text++ = (char)(0x80 | ((u & 3) << 4) | z); - *utf8_text++ = (char)(0x80 | y); - *utf8_text++ = (char)(0x80 | x); + *utf8_text++ = (char) (0xf0 | (u >> 2)); + *utf8_text++ = (char) (0x80 | ((u & 3) << 4) | z); + *utf8_text++ = (char) (0x80 | y); + *utf8_text++ = (char) (0x80 | x); } return (utf8_text); } -static unsigned u_length(register unsigned int * str) +static unsigned u_length(register unsigned int *str) { register unsigned len = 0; while (*str++ != '\0') @@ -64,27 +64,30 @@ static unsigned u_length(register unsigned int * str) } -static void utf82u_strcpy(unsigned int * ubuf, const char *utf8buf) +static void utf82u_strcpy(unsigned int *ubuf, const char *utf8buf) { - int len = (int)strlen(utf8buf) + 1; + int len = (int) strlen(utf8buf) + 1; unsigned int *upt = ubuf, *uend = ubuf + len - 1; - const unsigned char *pt = (const unsigned char *) utf8buf, *end = pt + strlen(utf8buf); + const unsigned char *pt = (const unsigned char *) utf8buf, *end = + pt + strlen(utf8buf); int w, w2; while (pt < end && *pt != '\0' && upt < uend) { if (*pt <= 127) *upt = *pt++; else if (*pt <= 0xdf) { - *upt = (unsigned int)(((*pt & 0x1f) << 6) | (pt[1] & 0x3f)); + *upt = (unsigned int) (((*pt & 0x1f) << 6) | (pt[1] & 0x3f)); pt += 2; } else if (*pt <= 0xef) { - *upt = (unsigned int)(((*pt & 0xf) << 12) | ((pt[1] & 0x3f) << 6) | (pt[2] & 0x3f)); + *upt = + (unsigned int) (((*pt & 0xf) << 12) | ((pt[1] & 0x3f) << 6) | + (pt[2] & 0x3f)); pt += 3; } else { w = (((*pt & 0x7) << 2) | ((pt[1] & 0x30) >> 4)) - 1; w = (w << 6) | ((pt[1] & 0xf) << 2) | ((pt[2] & 0x30) >> 4); w2 = ((pt[2] & 0xf) << 6) | (pt[3] & 0x3f); - *upt = (unsigned int)(w * 0x400 + w2 + 0x10000); + *upt = (unsigned int) (w * 0x400 + w2 + 0x10000); pt += 4; } ++upt; @@ -113,12 +116,12 @@ struct tex_language *new_language(int n) } else { while (tex_languages[next_lang_id] != NULL) next_lang_id++; - l = (unsigned)next_lang_id++; + l = (unsigned) next_lang_id++; } if (l < (MAX_TEX_LANGUAGES - 1) && tex_languages[l] == NULL) { lang = xmalloc(sizeof(struct tex_language)); tex_languages[l] = lang; - lang->id = (int)l; + lang->id = (int) l; lang->exceptions = 0; lang->patterns = NULL; lang->pre_hyphen_char = '-'; @@ -210,7 +213,7 @@ int get_post_exhyphen_char(int n) void load_patterns(struct tex_language *lang, const unsigned char *buffer) { - if (lang == NULL || buffer == NULL || strlen((const char *)buffer) == 0) + if (lang == NULL || buffer == NULL || strlen((const char *) buffer) == 0) return; if (lang->patterns == NULL) { lang->patterns = hnj_hyphen_new(); @@ -320,7 +323,7 @@ void load_hyphenation(struct tex_language *lang, const unsigned char *buffer) if (cleaned != NULL) { if ((s - value) > 0) { lua_pushstring(L, cleaned); - lua_pushlstring(L, value, (size_t)(s - value)); + lua_pushlstring(L, value, (size_t) (s - value)); lua_rawset(L, -3); } free(cleaned); @@ -537,7 +540,10 @@ char *exception_strings(struct tex_language *lang) while (lua_next(L, -2) != 0) { value = lua_tolstring(L, -1, &l); if (current + 2 + l > size) { - ret = xrealloc(ret, (unsigned)((size + size / 5) + current + l + 1024)); + ret = + xrealloc(ret, + (unsigned) ((size + size / 5) + current + l + + 1024)); size = (size + size / 5) + current + l + 1024; } *(ret + current) = ' '; @@ -558,12 +564,12 @@ halfword find_exception_part(unsigned int *j, unsigned int *uword, int len) halfword g = null, gg = null; register unsigned i = *j; i++; /* this puts uword[i] on the '{' */ - while (i < (unsigned)len && uword[i + 1] != '}') { + while (i < (unsigned) len && uword[i + 1] != '}') { if (g == null) { - gg = new_char(0, (int)uword[i + 1]); + gg = new_char(0, (int) uword[i + 1]); g = gg; } else { - halfword s = new_char(0, (int)uword[i + 1]); + halfword s = new_char(0, (int) uword[i + 1]); couple_nodes(g, s); g = vlink(g); } @@ -578,7 +584,7 @@ int count_exception_part(unsigned int *j, unsigned int *uword, int len) int ret = 0; register unsigned i = *j; i++; /* this puts uword[i] on the '{' */ - while (i < (unsigned)len && uword[i + 1] != '}') { + while (i < (unsigned) len && uword[i + 1] != '}') { ret++; i++; } @@ -624,15 +630,15 @@ void do_exception(halfword wordstart, halfword r, char *replacement) } else if (uword[i + 1] == '{') { halfword gg, hh, replace = null; int repl; - gg = find_exception_part(&i, uword, (int)len); + gg = find_exception_part(&i, uword, (int) len); if (i == len || uword[i + 1] != '{') { tex_error("broken pattern 1", PAT_ERROR); } - hh = find_exception_part(&i, uword, (int)len); + hh = find_exception_part(&i, uword, (int) len); if (i == len || uword[i + 1] != '{') { tex_error("broken pattern 2", PAT_ERROR); } - repl = count_exception_part(&i, uword, (int)len); + repl = count_exception_part(&i, uword, (int) len); if (i == len) { tex_error("broken pattern 3", PAT_ERROR); } @@ -845,7 +851,7 @@ void hnj_hyphenation(halfword head, halfword tail) clang == char_lang(r) && (lchar = get_lc_code(character(r))) > 0) { wordlen++; - hy = uni2string(hy, (unsigned)lchar); + hy = uni2string(hy, (unsigned) lchar); /* this should not be needed any more */ /*if (vlink(r)!=null) alink(vlink(r))=r; */ end_word = r; @@ -997,7 +1003,7 @@ void undump_one_language(int i) /* patterns */ undump_int(x); if (x > 0) { - s = xmalloc((unsigned)x); + s = xmalloc((unsigned) x); undump_things(*s, x); load_patterns(lang, (unsigned char *) s); free(s); @@ -1005,7 +1011,7 @@ void undump_one_language(int i) /* exceptions */ undump_int(x); if (x > 0) { - s = xmalloc((unsigned)x); + s = xmalloc((unsigned) x); undump_things(*s, x); load_hyphenation(lang, (unsigned char *) s); free(s); diff --git a/source/texk/web2c/luatexdir/lua/lcallbacklib.c b/source/texk/web2c/luatexdir/lua/lcallbacklib.c index 2ee7a9608e14ed0aafbf3ec7fdd03a414df4aab3..95876fd0db46cc713fdd9b1dfbd334af71a7e589 100644 --- a/source/texk/web2c/luatexdir/lua/lcallbacklib.c +++ b/source/texk/web2c/luatexdir/lua/lcallbacklib.c @@ -264,7 +264,7 @@ int do_run_callback(int special, const char *values, va_list vl) } ss = index(values, '>'); assert(ss); - luaL_checkstack(L, (int)(ss - values + 1), "out of stack space"); + luaL_checkstack(L, (int) (ss - values + 1), "out of stack space"); ss = NULL; for (narg = 0; *values; narg++) { switch (*values++) { @@ -403,7 +403,7 @@ int do_run_callback(int special, const char *values, va_list vl) if (s == NULL) /* |len| can be zero */ *va_arg(vl, int *) = 0; else { - ss = xmalloc((unsigned)(len + 1)); + ss = xmalloc((unsigned) (len + 1)); (void) memcpy(ss, s, (len + 1)); *va_arg(vl, char **) = ss; } diff --git a/source/texk/web2c/luatexdir/lua/limglib.c b/source/texk/web2c/luatexdir/lua/limglib.c index a5ed9bc86525349024a6c486d715a779ebe05ec4..eb3fb717a45a802a79e631cfdd20d2075d3dd20e 100644 --- a/source/texk/web2c/luatexdir/lua/limglib.c +++ b/source/texk/web2c/luatexdir/lua/limglib.c @@ -114,7 +114,7 @@ static void image_to_lua(lua_State * L, image * a) if (!lua_isnumber(L, -1)) /* !i k u ... */ luaL_error(L, "image_to_lua(): %s is not a valid image key", lua_tostring(L, -2)); - i = (int)lua_tointeger(L, -1); /* i k u ... */ + i = (int) lua_tointeger(L, -1); /* i k u ... */ lua_pop(L, 2); /* u ... */ switch (i) { case P_WIDTH: @@ -275,14 +275,14 @@ static void lua_to_image(lua_State * L, image * a) if (!lua_isnumber(L, -1)) /* !i v k t ... */ luaL_error(L, "lua_to_image(): %s is not a valid image key", lua_tostring(L, -3)); - i = (int)lua_tointeger(L, -1); /* i v k t ... */ + i = (int) lua_tointeger(L, -1); /* i v k t ... */ lua_pop(L, 1); /* v k t ... */ switch (i) { case P_WIDTH: if (lua_isnil(L, -1)) set_wd_running(a); else if (lua_type(L, -1) == LUA_TNUMBER) - img_width(a) = (int)lua_tointeger(L, -1); + img_width(a) = (int) lua_tointeger(L, -1); else if (lua_type(L, -1) == LUA_TSTRING) img_width(a) = dimen_to_number(L, lua_tostring(L, -1)); else @@ -293,7 +293,7 @@ static void lua_to_image(lua_State * L, image * a) if (lua_isnil(L, -1)) set_ht_running(a); else if (lua_type(L, -1) == LUA_TNUMBER) - img_height(a) = (int)lua_tointeger(L, -1); + img_height(a) = (int) lua_tointeger(L, -1); else if (lua_type(L, -1) == LUA_TSTRING) img_height(a) = dimen_to_number(L, lua_tostring(L, -1)); else @@ -304,7 +304,7 @@ static void lua_to_image(lua_State * L, image * a) if (lua_isnil(L, -1)) set_dp_running(a); else if (lua_type(L, -1) == LUA_TNUMBER) - img_depth(a) = (int)lua_tointeger(L, -1); + img_depth(a) = (int) lua_tointeger(L, -1); else if (lua_type(L, -1) == LUA_TSTRING) img_depth(a) = dimen_to_number(L, lua_tostring(L, -1)); else @@ -313,7 +313,7 @@ static void lua_to_image(lua_State * L, image * a) break; case P_TRANSFORM: if (lua_isnumber(L, -1)) - img_transform(a) = (int)lua_tointeger(L, -1); + img_transform(a) = (int) lua_tointeger(L, -1); else luaL_error(L, "image.transform needs integer value"); break; @@ -347,7 +347,7 @@ static void lua_to_image(lua_State * L, image * a) img_pagename(d) = xstrdup(lua_tostring(L, -1)); img_pagenum(d) = 0; } else if (lua_type(L, -1) == LUA_TNUMBER) { - img_pagenum(d) = (int)lua_tointeger(L, -1); + img_pagenum(d) = (int) lua_tointeger(L, -1); xfree(img_pagename(d)); } else luaL_error(L, "image.page needs integer or string value"); @@ -358,7 +358,7 @@ static void lua_to_image(lua_State * L, image * a) if (lua_isnil(L, -1)) img_colorspace(d) = 0; else if (lua_isnumber(L, -1)) - img_colorspace(d) = (int)lua_tointeger(L, -1); + img_colorspace(d) = (int) lua_tointeger(L, -1); else luaL_error(L, "image.colorspace needs integer or nil value"); break; @@ -383,7 +383,7 @@ static void lua_to_image(lua_State * L, image * a) lua_pushinteger(L, i); /* idx v k t ... */ lua_gettable(L, -2); /* int v k t ... */ if (lua_type(L, -1) == LUA_TNUMBER) - img_bbox(d)[i - 1] = (int)lua_tointeger(L, -1); + img_bbox(d)[i - 1] = (int) lua_tointeger(L, -1); else if (lua_type(L, -1) == LUA_TSTRING) img_bbox(d)[i - 1] = dimen_to_number(L, lua_tostring(L, -1)); else diff --git a/source/texk/web2c/luatexdir/lua/liolib.c b/source/texk/web2c/luatexdir/lua/liolib.c index 607bc246bd7b7b7a9e80d6e14af29ec250da0201..826f10935bad279a72ad435f2d8c6d7d835b2ea5 100644 --- a/source/texk/web2c/luatexdir/lua/liolib.c +++ b/source/texk/web2c/luatexdir/lua/liolib.c @@ -415,16 +415,16 @@ static int read_chars(lua_State * L, FILE * f, size_t n) static int read_all(lua_State * L, FILE * f) { /* attempt to speed up reading whole files */ - long rlen; /* how much to read */ + long rlen; /* how much to read */ size_t nr; /* number of chars actually read */ - long old; /* old file location */ + long old; /* old file location */ char *p; old = ftell(f); if (old > 0 && (fseek(f, 0, SEEK_END) >= 0) && ((rlen = ftell(f)) > 0) && rlen < 1000 * 1000 * 100) { /* 100 MB */ fseek(f, old, SEEK_SET); - p = malloc((size_t)rlen); + p = malloc((size_t) rlen); if (p != NULL) { - nr = fread(p, sizeof(char), (size_t)rlen, f); + nr = fread(p, sizeof(char), (size_t) rlen, f); lua_pushlstring(L, p, nr); free(p); return 1; @@ -565,13 +565,13 @@ static int f_seek(lua_State * L) static int f_setvbuf(lua_State * L) { - int sz, op ,res; + int sz, op, res; static const int mode[] = { _IONBF, _IOFBF, _IOLBF }; static const char *const modenames[] = { "no", "full", "line", NULL }; FILE *f = tofile(L); op = luaL_checkoption(L, 2, NULL, modenames); lua_number2int(sz, luaL_optinteger(L, 3, LUAL_BUFFERSIZE)); - res = setvbuf(f, NULL, mode[op], (size_t)sz); + res = setvbuf(f, NULL, mode[op], (size_t) sz); return pushresult(L, res == 0, NULL); } diff --git a/source/texk/web2c/luatexdir/lua/llualib.c b/source/texk/web2c/luatexdir/lua/llualib.c index 4ddf6c97738e8a3712b9e0d6e38ce83d550741cd..9a62a8ad26da951ed8db1c461130115ff445e4fc 100644 --- a/source/texk/web2c/luatexdir/lua/llualib.c +++ b/source/texk/web2c/luatexdir/lua/llualib.c @@ -95,7 +95,7 @@ void undump_luac_registers(void) lua_fatal_error("Corrupt format file"); } lua_bytecode_registers = xmalloc((unsigned) (i * sizeof(bytecode))); - luabytecode_bytes = (unsigned)(i * sizeof(bytecode)); + luabytecode_bytes = (unsigned) (i * sizeof(bytecode)); for (i = 0; i <= (unsigned) luabytecode_max; i++) { lua_bytecode_registers[i].done = 0; lua_bytecode_registers[i].size = 0; @@ -169,7 +169,7 @@ int writer(lua_State * L, const void *b, size_t size, void *B) } memcpy(buf->buf + buf->size, b, size); buf->size += (int) size; - luabytecode_bytes += (unsigned)size; + luabytecode_bytes += (unsigned) size; return 0; } @@ -231,12 +231,15 @@ int set_bytecode(lua_State * L) lua_error(L); } if (k > luabytecode_max) { - i = (unsigned)(sizeof(bytecode) * ((unsigned) k + 1)); + i = (unsigned) (sizeof(bytecode) * ((unsigned) k + 1)); lua_bytecode_registers = xrealloc(lua_bytecode_registers, i); if (luabytecode_max == -1) { - luabytecode_bytes += (unsigned)(sizeof(bytecode) * (unsigned) (k + 1)); + luabytecode_bytes += + (unsigned) (sizeof(bytecode) * (unsigned) (k + 1)); } else { - luabytecode_bytes += (unsigned)(sizeof(bytecode) * (unsigned) (k + 1 - luabytecode_max)); + luabytecode_bytes += + (unsigned) (sizeof(bytecode) * + (unsigned) (k + 1 - luabytecode_max)); } for (i = (unsigned) (luabytecode_max + 1); i <= (unsigned) k; i++) { lua_bytecode_registers[i].buf = NULL; diff --git a/source/texk/web2c/luatexdir/lua/lnodelib.c b/source/texk/web2c/luatexdir/lua/lnodelib.c index 81ac287855bbc41ceb0384d23a440bf1323ec364..a1ccb67940bf2475afe3d64d8237e91b839483aa 100644 --- a/source/texk/web2c/luatexdir/lua/lnodelib.c +++ b/source/texk/web2c/luatexdir/lua/lnodelib.c @@ -75,7 +75,7 @@ int do_get_node_type_id(lua_State * L, int n, node_info * data) return j; } } else if (lua_type(L, n) == LUA_TNUMBER) { - register int i = (int)lua_tointeger(L, n); + register int i = (int) lua_tointeger(L, n); for (j = 0; data[j].id != -1; j++) { if (data[j].id == i) return j; @@ -134,7 +134,7 @@ void lua_nodelib_push(lua_State * L) halfword *a; n = -1; if (lua_isnumber(L, -1)) { - n = (int)lua_tointeger(L, -1); + n = (int) lua_tointeger(L, -1); } lua_pop(L, 1); if ((n == null) || (n < 0) || (n > var_mem_max)) { @@ -157,7 +157,7 @@ static void lua_nodelib_push_spec(lua_State * L) halfword *a; n = -1; if (lua_isnumber(L, -1)) { - n = (halfword)lua_tointeger(L, -1); + n = (halfword) lua_tointeger(L, -1); } lua_pop(L, 1); if ((n < 0) || (n > var_mem_max)) { @@ -244,7 +244,7 @@ static int lua_nodelib_new(lua_State * L) } else { j = 0; if (lua_gettop(L) > 1) { - j = (int)lua_tointeger(L, 2); + j = (int) lua_tointeger(L, 2); } } n = new_node(i, j); @@ -502,7 +502,7 @@ static int lua_nodelib_hpack(lua_State * L) int d = -1; n = *(check_isnode(L, 1)); if (lua_gettop(L) > 1) { - w = (int)lua_tointeger(L, 2); + w = (int) lua_tointeger(L, 2); if (lua_gettop(L) > 2) { if (lua_type(L, 3) == LUA_TSTRING) { s = lua_tostring(L, 3); @@ -592,7 +592,7 @@ static int lua_nodelib_vpack(lua_State * L) int d = -1; n = *(check_isnode(L, 1)); if (lua_gettop(L) > 1) { - w = (int)lua_tointeger(L, 2); + w = (int) lua_tointeger(L, 2); if (lua_gettop(L) > 2) { if (lua_type(L, 3) == LUA_TSTRING) { s = lua_tostring(L, 3); @@ -646,9 +646,9 @@ static int lua_nodelib_mlist_to_hlist(lua_State * L) static int lua_nodelib_mfont(lua_State * L) { int f, s; - f = (int)luaL_checkinteger(L, 1); + f = (int) luaL_checkinteger(L, 1); if (lua_gettop(L) == 2) - s = (int)lua_tointeger(L, 2); /* this should be a multiple of 256 ! */ + s = (int) lua_tointeger(L, 2); /* this should be a multiple of 256 ! */ else s = 0; lua_pushnumber(L, fam_fnt(f, s)); @@ -881,8 +881,8 @@ static int lua_nodelib_has_attribute(lua_State * L) int i, val; n = check_isnode(L, 1); if (n != NULL) { - i = (int)lua_tointeger(L, 2); - val = (int)luaL_optinteger(L, 3, UNUSED_ATTRIBUTE); + i = (int) lua_tointeger(L, 2); + val = (int) luaL_optinteger(L, 3, UNUSED_ATTRIBUTE); if ((val = has_attribute(*n, i, val)) > UNUSED_ATTRIBUTE) { lua_pushnumber(L, val); return 1; @@ -897,8 +897,8 @@ static int lua_nodelib_set_attribute(lua_State * L) halfword *n; int i, val; if (lua_gettop(L) == 3) { - i = (int)lua_tointeger(L, 2); - val = (int)lua_tointeger(L, 3); + i = (int) lua_tointeger(L, 2); + val = (int) lua_tointeger(L, 3); n = check_isnode(L, 1); if (val == UNUSED_ATTRIBUTE) { (void) unset_attribute(*n, i, val); @@ -946,7 +946,7 @@ static int nodelib_aux_nil(lua_State * L) static int nodelib_aux_next_filtered(lua_State * L) { register halfword t; /* traverser */ - register int i = (int)lua_tointeger(L, lua_upvalueindex(1)); + register int i = (int) lua_tointeger(L, lua_upvalueindex(1)); if (lua_isnil(L, 2)) { /* first call */ t = *check_isnode(L, 1); } else { @@ -1050,7 +1050,7 @@ static int lua_nodelib_count(lua_State * L) halfword n; halfword m = null; int i = -1; - i = (int)lua_tointeger(L, 1); + i = (int) lua_tointeger(L, 1); if (lua_isnil(L, 2)) { lua_pushnumber(L, 0); return 1; @@ -2156,7 +2156,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case open_node: switch (field) { case 4: - write_stream(n) = (halfword)lua_tointeger(L, 3); + write_stream(n) = (halfword) lua_tointeger(L, 3); break; case 5: open_name(n) = nodelib_getstring(L, 3); @@ -2174,7 +2174,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case write_node: switch (field) { case 4: - write_stream(n) = (halfword)lua_tointeger(L, 3); + write_stream(n) = (halfword) lua_tointeger(L, 3); break; case 5: write_tokens(n) = nodelib_gettoks(L, 3); @@ -2186,7 +2186,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case close_node: switch (field) { case 4: - write_stream(n) = (halfword)lua_tointeger(L, 3); + write_stream(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2204,10 +2204,10 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case local_par_node: switch (field) { case 4: - local_pen_inter(n) = (halfword)lua_tointeger(L, 3); + local_pen_inter(n) = (halfword) lua_tointeger(L, 3); break; case 5: - local_pen_broken(n) = (halfword)lua_tointeger(L, 3); + local_pen_broken(n) = (halfword) lua_tointeger(L, 3); break; case 6: local_par_dir(n) = nodelib_getdir(L, 3); @@ -2216,13 +2216,13 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) local_box_left(n) = nodelib_getlist(L, 3); break; case 8: - local_box_left_width(n) = (halfword)lua_tointeger(L, 3); + local_box_left_width(n) = (halfword) lua_tointeger(L, 3); break; case 9: local_box_right(n) = nodelib_getlist(L, 3); break; case 10: - local_box_right_width(n) = (halfword)lua_tointeger(L, 3); + local_box_right_width(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2234,13 +2234,13 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) dir_dir(n) = nodelib_getdir(L, 3); break; case 5: - dir_level(n) = (halfword)lua_tointeger(L, 3); + dir_level(n) = (halfword) lua_tointeger(L, 3); break; case 6: - dir_dvi_ptr(n) = (halfword)lua_tointeger(L, 3); + dir_dvi_ptr(n) = (halfword) lua_tointeger(L, 3); break; case 7: - dir_dvi_h(n) = (halfword)lua_tointeger(L, 3); + dir_dvi_h(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2267,7 +2267,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case pdf_refobj_node: switch (field) { case 4: - pdf_obj_objnum(n) = (halfword)lua_tointeger(L, 3); + pdf_obj_objnum(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2276,16 +2276,16 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case pdf_refxform_node: switch (field) { case 4: - width(n) = (halfword)lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: - depth(n) = (halfword)lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - height(n) = (halfword)lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: - pdf_xform_objnum(n) = (halfword)lua_tointeger(L, 3); + pdf_xform_objnum(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2294,19 +2294,19 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case pdf_refximage_node: switch (field) { case 4: - width(n) = (halfword)lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: - depth(n) = (halfword)lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - height(n) = (halfword)lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: - pdf_ximage_transform(n) = (halfword)lua_tointeger(L, 3); + pdf_ximage_transform(n) = (halfword) lua_tointeger(L, 3); break; case 8: - pdf_ximage_index(n) = (halfword)lua_tointeger(L, 3); + pdf_ximage_index(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2315,16 +2315,16 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case pdf_annot_node: switch (field) { case 4: - width(n) = (halfword)lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: - depth(n) = (halfword)lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - height(n) = (halfword)lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: - pdf_annot_objnum(n) = (halfword)lua_tointeger(L, 3); + pdf_annot_objnum(n) = (halfword) lua_tointeger(L, 3); break; case 8: pdf_annot_data(n) = nodelib_gettoks(L, 3); @@ -2336,16 +2336,16 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case pdf_start_link_node: switch (field) { case 4: - width(n) = (halfword)lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: - depth(n) = (halfword)lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - height(n) = (halfword)lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: - pdf_link_objnum(n) = (halfword)lua_tointeger(L, 3); + pdf_link_objnum(n) = (halfword) lua_tointeger(L, 3); break; case 8: pdf_link_attr(n) = nodelib_gettoks(L, 3); @@ -2366,13 +2366,13 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case pdf_dest_node: switch (field) { case 4: - width(n) = (halfword)lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: - depth(n) = (halfword)lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - height(n) = (halfword)lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: pdf_dest_named_id(n) = (quarterword) lua_tointeger(L, 3); @@ -2381,16 +2381,16 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) if (pdf_dest_named_id(n) == 1) pdf_dest_id(n) = nodelib_gettoks(L, 3); else - pdf_dest_id(n) = (halfword)lua_tointeger(L, 3); + pdf_dest_id(n) = (halfword) lua_tointeger(L, 3); break; case 9: pdf_dest_type(n) = (quarterword) lua_tointeger(L, 3); break; case 10: - pdf_dest_xyz_zoom(n) = (halfword)lua_tointeger(L, 3); + pdf_dest_xyz_zoom(n) = (halfword) lua_tointeger(L, 3); break; case 11: - pdf_dest_objnum(n) = (halfword)lua_tointeger(L, 3); + pdf_dest_objnum(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2400,13 +2400,13 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case pdf_start_thread_node: switch (field) { case 4: - width(n) = (halfword)lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: - depth(n) = (halfword)lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - height(n) = (halfword)lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: pdf_thread_named_id(n) = (quarterword) lua_tointeger(L, 3); @@ -2415,7 +2415,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) if (pdf_thread_named_id(n) == 1) pdf_thread_id(n) = nodelib_gettoks(L, 3); else - pdf_thread_id(n) = (halfword)lua_tointeger(L, 3); + pdf_thread_id(n) = (halfword) lua_tointeger(L, 3); break; case 9: pdf_thread_attr(n) = nodelib_gettoks(L, 3); @@ -2431,7 +2431,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case late_lua_node: switch (field) { case 4: - late_lua_reg(n) = (halfword)lua_tointeger(L, 3); + late_lua_reg(n) = (halfword) lua_tointeger(L, 3); break; case 5: late_lua_data(n) = nodelib_gettoks(L, 3); @@ -2446,7 +2446,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case close_lua_node: switch (field) { case 4: - late_lua_reg(n) = (halfword)lua_tointeger(L, 3); + late_lua_reg(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2455,10 +2455,10 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case pdf_colorstack_node: switch (field) { case 4: - pdf_colorstack_stack(n) = (halfword)lua_tointeger(L, 3); + pdf_colorstack_stack(n) = (halfword) lua_tointeger(L, 3); break; case 5: - pdf_colorstack_cmd(n) = (halfword)lua_tointeger(L, 3); + pdf_colorstack_cmd(n) = (halfword) lua_tointeger(L, 3); break; case 6: pdf_colorstack_data(n) = nodelib_gettoks(L, 3); @@ -2484,10 +2484,10 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) case user_defined_node: switch (field) { case 4: - user_node_id(n) = (halfword)lua_tointeger(L, 3); + user_node_id(n) = (halfword) lua_tointeger(L, 3); break; case 5: - user_node_type(n) = (halfword)lua_tointeger(L, 3); + user_node_type(n) = (halfword) lua_tointeger(L, 3); break; case 6: switch (user_node_type(n)) { @@ -2495,7 +2495,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) user_node_value(n) = nodelib_getlist(L, 3); break; case 'd': - user_node_value(n) = (halfword)lua_tointeger(L, 3); + user_node_value(n) = (halfword) lua_tointeger(L, 3); break; case 'n': user_node_value(n) = nodelib_getlist(L, 3); @@ -2507,7 +2507,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, int field) user_node_value(n) = nodelib_gettoks(L, 3); break; default: - user_node_value(n) = (halfword)lua_tointeger(L, 3); + user_node_value(n) = (halfword) lua_tointeger(L, 3); break; } break; @@ -2542,31 +2542,31 @@ static int lua_nodelib_setfield(lua_State * L) subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - character(n) = (halfword)lua_tointeger(L, 3); + character(n) = (halfword) lua_tointeger(L, 3); break; case 5: - font(n) = (halfword)lua_tointeger(L, 3); + font(n) = (halfword) lua_tointeger(L, 3); break; case 6: - set_char_lang(n, (halfword)lua_tointeger(L, 3)); + set_char_lang(n, (halfword) lua_tointeger(L, 3)); break; case 7: - set_char_lhmin(n, (halfword)lua_tointeger(L, 3)); + set_char_lhmin(n, (halfword) lua_tointeger(L, 3)); break; case 8: - set_char_rhmin(n, (halfword)lua_tointeger(L, 3)); + set_char_rhmin(n, (halfword) lua_tointeger(L, 3)); break; case 9: - set_char_uchyph(n, (halfword)lua_tointeger(L, 3)); + set_char_uchyph(n, (halfword) lua_tointeger(L, 3)); break; case 10: lig_ptr(n) = nodelib_getlist(L, 3); break; case 11: - x_displace(n) = (halfword)lua_tointeger(L, 3); + x_displace(n) = (halfword) lua_tointeger(L, 3); break; case 12: - y_displace(n) = (halfword)lua_tointeger(L, 3); + y_displace(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2580,19 +2580,19 @@ static int lua_nodelib_setfield(lua_State * L) subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - width(n) = (halfword)lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: - depth(n) = (halfword)lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - height(n) = (halfword)lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: box_dir(n) = nodelib_getdir(L, 3); break; case 8: - shift_amount(n) = (halfword)lua_tointeger(L, 3); + shift_amount(n) = (halfword) lua_tointeger(L, 3); break; case 9: glue_order(n) = (quarterword) lua_tointeger(L, 3); @@ -2615,19 +2615,19 @@ static int lua_nodelib_setfield(lua_State * L) case 2: /* dummy subtype */ break; case 4: - width(n) = (halfword)lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: - depth(n) = (halfword)lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - height(n) = (halfword)lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: - box_dir(n) = (halfword)lua_tointeger(L, 3); + box_dir(n) = (halfword) lua_tointeger(L, 3); break; case 8: - glue_shrink(n) = (halfword)lua_tointeger(L, 3); + glue_shrink(n) = (halfword) lua_tointeger(L, 3); break; case 9: glue_order(n) = (quarterword) lua_tointeger(L, 3); @@ -2636,7 +2636,7 @@ static int lua_nodelib_setfield(lua_State * L) glue_sign(n) = (quarterword) lua_tointeger(L, 3); break; case 11: - glue_stretch(n) = (halfword)lua_tointeger(L, 3); + glue_stretch(n) = (halfword) lua_tointeger(L, 3); break; case 12: span_count(n) = (quarterword) lua_tointeger(L, 3); @@ -2653,13 +2653,13 @@ static int lua_nodelib_setfield(lua_State * L) case 2: /* dummy subtype */ break; case 4: - width(n) = (halfword)lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: - depth(n) = (halfword)lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - height(n) = (halfword)lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: rule_dir(n) = nodelib_getdir(L, 3); @@ -2674,13 +2674,13 @@ static int lua_nodelib_setfield(lua_State * L) subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - float_cost(n) = (halfword)lua_tointeger(L, 3); + float_cost(n) = (halfword) lua_tointeger(L, 3); break; case 5: - depth(n) = (halfword)lua_tointeger(L, 3); + depth(n) = (halfword) lua_tointeger(L, 3); break; case 6: - height(n) = (halfword)lua_tointeger(L, 3); + height(n) = (halfword) lua_tointeger(L, 3); break; case 7: split_top_ptr(n) = nodelib_getspec(L, 3); @@ -2698,7 +2698,7 @@ static int lua_nodelib_setfield(lua_State * L) subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - mark_class(n) = (halfword)lua_tointeger(L, 3); + mark_class(n) = (halfword) lua_tointeger(L, 3); break; case 5: mark_ptr(n) = nodelib_gettoks(L, 3); @@ -2743,7 +2743,7 @@ static int lua_nodelib_setfield(lua_State * L) subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - surround(n) = (halfword)lua_tointeger(L, 3); + surround(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2769,13 +2769,13 @@ static int lua_nodelib_setfield(lua_State * L) case 2: /* dummy subtype */ break; case 3: - width(n) = (halfword)lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 4: - stretch(n) = (halfword)lua_tointeger(L, 3); + stretch(n) = (halfword) lua_tointeger(L, 3); break; case 5: - shrink(n) = (halfword)lua_tointeger(L, 3); + shrink(n) = (halfword) lua_tointeger(L, 3); break; case 6: stretch_order(n) = (quarterword) lua_tointeger(L, 3); @@ -2784,7 +2784,7 @@ static int lua_nodelib_setfield(lua_State * L) shrink_order(n) = (quarterword) lua_tointeger(L, 3); break; case 8: - glue_ref_count(n) = (halfword)lua_tointeger(L, 3); + glue_ref_count(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2796,7 +2796,7 @@ static int lua_nodelib_setfield(lua_State * L) subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - width(n) = (halfword)lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2807,7 +2807,7 @@ static int lua_nodelib_setfield(lua_State * L) case 2: /* dummy subtype */ break; case 4: - penalty(n) = (halfword)lua_tointeger(L, 3); + penalty(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2827,20 +2827,20 @@ static int lua_nodelib_setfield(lua_State * L) if (pdf_action_named_id(n) == 1) { pdf_action_id(n) = nodelib_gettoks(L, 3); } else { - pdf_action_id(n) = (halfword)lua_tointeger(L, 3); + pdf_action_id(n) = (halfword) lua_tointeger(L, 3); } break; case 6: pdf_action_file(n) = nodelib_gettoks(L, 3); break; case 7: - pdf_action_new_window(n) = (halfword)lua_tointeger(L, 3); + pdf_action_new_window(n) = (halfword) lua_tointeger(L, 3); break; case 8: pdf_action_tokens(n) = nodelib_gettoks(L, 3); break; case 9: - pdf_action_refcount(n) = (halfword)lua_tointeger(L, 3); + pdf_action_refcount(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -2928,7 +2928,7 @@ static int lua_nodelib_setfield(lua_State * L) subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - thickness(n) = (halfword)lua_tointeger(L, 3); + thickness(n) = (halfword) lua_tointeger(L, 3); break; case 5: numerator(n) = nodelib_getlist(L, 3); @@ -2989,10 +2989,10 @@ static int lua_nodelib_setfield(lua_State * L) subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - math_fam(n) = (halfword)lua_tointeger(L, 3); + math_fam(n) = (halfword) lua_tointeger(L, 3); break; case 5: - math_character(n) = (halfword)lua_tointeger(L, 3); + math_character(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -3017,16 +3017,16 @@ static int lua_nodelib_setfield(lua_State * L) subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - small_fam(n) = (halfword)lua_tointeger(L, 3); + small_fam(n) = (halfword) lua_tointeger(L, 3); break; case 5: - small_char(n) = (halfword)lua_tointeger(L, 3); + small_char(n) = (halfword) lua_tointeger(L, 3); break; case 6: - large_fam(n) = (halfword)lua_tointeger(L, 3); + large_fam(n) = (halfword) lua_tointeger(L, 3); break; case 7: - large_char(n) = (halfword)lua_tointeger(L, 3); + large_char(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); @@ -3038,7 +3038,7 @@ static int lua_nodelib_setfield(lua_State * L) subtype(n) = (quarterword) lua_tointeger(L, 3); break; case 4: - width(n) = (halfword)lua_tointeger(L, 3); + width(n) = (halfword) lua_tointeger(L, 3); break; case 5: margin_char(n) = nodelib_getlist(L, 3); @@ -3096,10 +3096,10 @@ static int lua_nodelib_setfield(lua_State * L) case 2: /* dummy subtype */ break; case 3: - attribute_id(n) = (halfword)lua_tointeger(L, 3); + attribute_id(n) = (halfword) lua_tointeger(L, 3); break; case 4: - attribute_value(n) = (halfword)lua_tointeger(L, 3); + attribute_value(n) = (halfword) lua_tointeger(L, 3); break; default: return nodelib_cantset(L, field, n); diff --git a/source/texk/web2c/luatexdir/lua/loslibext.c b/source/texk/web2c/luatexdir/lua/loslibext.c index 52c2c2ece16aa0d99330ef2c8e25a2a831941498..354dc06e316719fffbb0b3873d0e75a0c1d3dc00 100644 --- a/source/texk/web2c/luatexdir/lua/loslibext.c +++ b/source/texk/web2c/luatexdir/lua/loslibext.c @@ -575,7 +575,7 @@ static int os_setenv(lua_State * L) val = luaL_optstring(L, 2, NULL); if (key) { if (val) { - value = xmalloc((unsigned)(strlen(key) + strlen(val) + 2)); + value = xmalloc((unsigned) (strlen(key) + strlen(val) + 2)); sprintf(value, "%s=%s", key, val); if (putenv(value)) { return luaL_error(L, "unable to change environment"); @@ -637,7 +637,7 @@ static int ex_sleep(lua_State * L) #ifdef WIN32 Sleep(1e3 * interval / units); #else /* assumes posix or bsd */ - usleep((unsigned)(1e6 * interval / units)); + usleep((unsigned) (1e6 * interval / units)); #endif return 0; } diff --git a/source/texk/web2c/luatexdir/lua/lpdflib.c b/source/texk/web2c/luatexdir/lua/lpdflib.c index f84605f13738669b2807437be219a6f3f0016f52..e368bed1d297438af909693b0c570ead29cf2391 100644 --- a/source/texk/web2c/luatexdir/lua/lpdflib.c +++ b/source/texk/web2c/luatexdir/lua/lpdflib.c @@ -227,7 +227,7 @@ static int table_obj(lua_State * L) if (!lua_isnumber(L, -1)) /* !i vs t */ luaL_error(L, "pdf.obj(): \"%s\" is not a valid object type", lua_tostring(L, -2)); - type = (int)lua_tointeger(L, -1); /* i vs t */ + type = (int) lua_tointeger(L, -1); /* i vs t */ lua_pop(L, 1); /* vs t */ switch (type) { case P_RAW: @@ -256,7 +256,7 @@ static int table_obj(lua_State * L) if (!lua_isnil(L, -1)) { /* vi? t */ if (!lua_isnumber(L, -1)) /* !vi t */ luaL_error(L, "pdf.obj(): \"objnum\" must be integer"); - k = (int)lua_tointeger(L, -1); /* vi t */ + k = (int) lua_tointeger(L, -1); /* vi t */ check_obj_exists(static_pdf, obj_type_obj, k); if (is_obj_scheduled(static_pdf, k) || obj_data_ptr(static_pdf, k) != 0) luaL_error(L, "pdf.obj() object in use"); @@ -300,7 +300,7 @@ static int table_obj(lua_State * L) "pdf.obj(): \"compresslevel\" key not allowed for raw object"); if (!lua_isnumber(L, -1)) /* !vi t */ luaL_error(L, "pdf.obj(): \"compresslevel\" must be integer"); - compress_level = (int)lua_tointeger(L, -1); /* vi t */ + compress_level = (int) lua_tointeger(L, -1); /* vi t */ if (compress_level > 9) luaL_error(L, "pdf.obj(): \"compresslevel\" must be <= 9"); else if (compress_level < 0) @@ -544,7 +544,7 @@ static int l_registerannot(lua_State * L) case 1: if (!is_shipping_page) luaL_error(L, "pdf.registerannot() can only be used in late lua"); - i = (int)luaL_checkinteger(L, 1); + i = (int) luaL_checkinteger(L, 1); if (i <= 0) luaL_error(L, "pdf.registerannot() can only register positive object numbers"); diff --git a/source/texk/web2c/luatexdir/lua/ltexlib.c b/source/texk/web2c/luatexdir/lua/ltexlib.c index bf11b20350c2995f3d5b694f433ccb0f00b1d197..2cd3fefc000cb65f09f26de918d567340b3bb1cb 100644 --- a/source/texk/web2c/luatexdir/lua/ltexlib.c +++ b/source/texk/web2c/luatexdir/lua/ltexlib.c @@ -65,13 +65,13 @@ static void luac_store(lua_State * L, int i, int partial, int cattable) size_t tsize; rope *rn = NULL; sttemp = lua_tolstring(L, i, &tsize); - st = xmalloc((unsigned)(tsize + 1)); + st = xmalloc((unsigned) (tsize + 1)); memcpy(st, sttemp, (tsize + 1)); if (st) { luacstrings++; rn = (rope *) xmalloc(sizeof(rope)); rn->text = st; - rn->tsize = (unsigned)tsize; + rn->tsize = (unsigned) tsize; rn->partial = partial; rn->cattable = cattable; rn->next = NULL; @@ -197,7 +197,9 @@ void luacstring_start(int n) spindle_index++; if (spindle_size == spindle_index) { /* add a new one */ spindles = - xrealloc(spindles, (unsigned)(sizeof(spindle) * (unsigned) (spindle_size + 1))); + xrealloc(spindles, + (unsigned) (sizeof(spindle) * + (unsigned) (spindle_size + 1))); spindles[spindle_index].head = NULL; spindles[spindle_index].tail = NULL; spindles[spindle_index].complete = 0; @@ -1166,9 +1168,9 @@ int setlist(lua_State * L) if (lua_isstring(L, 2)) { str = lua_tostring(L, 2); if (strcmp(str, "best_size") == 0) { - best_size = (int)lua_tointeger(L, 3); + best_size = (int) lua_tointeger(L, 3); } else if (strcmp(str, "least_page_cost") == 0) { - least_page_cost = (int)lua_tointeger(L, 3); + least_page_cost = (int) lua_tointeger(L, 3); } else { if (!lua_isnil(L, 3)) { n_ptr = check_isnode(L, 3); @@ -1289,7 +1291,7 @@ static int tex_definefont(lua_State * L) i = 2; } csname = luaL_checklstring(L, i, &l); - f = (int)luaL_checkinteger(L, (i + 1)); + f = (int) luaL_checkinteger(L, (i + 1)); t = maketexlstring(csname, l); no_new_control_sequence = 0; u = string_lookup(csname, l); @@ -1424,12 +1426,12 @@ static int tex_enableprimitives(lua_State * L) halfword cur_chr = get_prim_equiv(prim_val); if (strncmp(pre, prim, l) != 0) { /* not a prefix */ newl = strlen(prim) + l; - newprim = (char *) xmalloc((unsigned)(newl + 1)); + newprim = (char *) xmalloc((unsigned) (newl + 1)); strcpy(newprim, pre); strcat(newprim + l, prim); } else { newl = strlen(prim); - newprim = (char *) xmalloc((unsigned)(newl + 1)); + newprim = (char *) xmalloc((unsigned) (newl + 1)); strcpy(newprim, prim); } val = string_lookup(newprim, newl); diff --git a/source/texk/web2c/luatexdir/lua/ltokenlib.c b/source/texk/web2c/luatexdir/lua/ltokenlib.c index 67b499384bb106ef927c42b6d3e122525db8a95f..1ffeeb290f36284319c4e4984aec45ef979e31fb 100644 --- a/source/texk/web2c/luatexdir/lua/ltokenlib.c +++ b/source/texk/web2c/luatexdir/lua/ltokenlib.c @@ -47,7 +47,7 @@ static int test_expandable(lua_State * L) if (is_valid_token(L, -1)) { get_token_cmd(L, -1); if (lua_isnumber(L, -1)) { - cmd = (int)lua_tointeger(L, -1); + cmd = (int) lua_tointeger(L, -1); } else if (lua_isstring(L, -1)) { cmd = get_command_id(lua_tostring(L, -1)); } @@ -69,7 +69,7 @@ static int test_protected(lua_State * L) if (is_valid_token(L, -1)) { get_token_chr(L, -1); if (lua_isnumber(L, -1)) { - chr = (int)lua_tointeger(L, -1); + chr = (int) lua_tointeger(L, -1); } else if (lua_isstring(L, -1)) { chr = get_command_id(lua_tostring(L, -1)); } @@ -91,7 +91,7 @@ static int test_activechar(lua_State * L) int cs = 0; get_token_cs(L, -1); if (lua_isnumber(L, -1)) { - cs = (int)lua_tointeger(L, -1); + cs = (int) lua_tointeger(L, -1); } lua_pop(L, 1); if (cs != 0 && ((s = get_cs_text(cs)) != (unsigned char *) NULL)) { @@ -114,7 +114,7 @@ static int run_get_command_name(lua_State * L) if (is_valid_token(L, -1)) { get_token_cmd(L, -1); if (lua_isnumber(L, -1)) { - cs = (int)lua_tointeger(L, -1); + cs = (int) lua_tointeger(L, -1); lua_pushstring(L, command_names[cs].cmd_name); } else { lua_pushstring(L, ""); @@ -133,13 +133,13 @@ static int run_get_csname_name(lua_State * L) if (is_valid_token(L, -1)) { get_token_cmd(L, -1); if (lua_isnumber(L, -1)) { - cmd = (int)lua_tointeger(L, -1); + cmd = (int) lua_tointeger(L, -1); } lua_pop(L, 1); cs = 0; get_token_cs(L, -1); if (lua_isnumber(L, -1)) { - cs = (int)lua_tointeger(L, -1); + cs = (int) lua_tointeger(L, -1); } lua_pop(L, 1); @@ -176,7 +176,7 @@ static int run_get_csname_id(lua_State * L) s = lua_tolstring(L, -1, &k); cs = (size_t) string_lookup(s, k); } - lua_pushnumber(L, (lua_Number)cs); + lua_pushnumber(L, (lua_Number) cs); return 1; } @@ -240,8 +240,8 @@ static int run_build(lua_State * L) int cmd, chr, cs; if (lua_isnumber(L, 1)) { cs = 0; - chr = (int)lua_tointeger(L, 1); - cmd = (int)luaL_optinteger(L, 2, get_char_cat_code(chr)); + chr = (int) lua_tointeger(L, 1); + cmd = (int) luaL_optinteger(L, 2, get_char_cat_code(chr)); if (cmd == 0 || cmd == 9 || cmd == 14 || cmd == 15) { fprintf(stdout, "\n\nluatex error: not a good token.\nCatcode %i can not be returned, so I replaced it by 12 (other)", diff --git a/source/texk/web2c/luatexdir/lua/luainit.c b/source/texk/web2c/luatexdir/lua/luainit.c index 662426cab01637bb8764655df1c1caa443ce7ad7..6a6dec1db1b42a6362411905929c332f0989b120 100644 --- a/source/texk/web2c/luatexdir/lua/luainit.c +++ b/source/texk/web2c/luatexdir/lua/luainit.c @@ -226,7 +226,7 @@ static void parse_options(int argc, char **argv) output_comment = optarg; } else { WARNING2("Comment truncated to 255 characters from %d. (%s)", - (int)len, optarg); + (int) len, optarg); output_comment = (string) xmalloc(256); strncpy(output_comment, optarg, 255); output_comment[255] = 0; @@ -383,7 +383,7 @@ static char *find_filename(char *name, const char *envkey) if (*(dirname + strlen(dirname) - 1) == '/') { *(dirname + strlen(dirname) - 1) = 0; } - filename = xmalloc((unsigned)(strlen(dirname) + strlen(name) + 2)); + filename = xmalloc((unsigned) (strlen(dirname) + strlen(name) + 2)); filename = concat3(dirname, "/", name); if (is_readable(filename)) { xfree(dirname); diff --git a/source/texk/web2c/luatexdir/lua/luastuff.c b/source/texk/web2c/luatexdir/lua/luastuff.c index c99ae8352334beaf04a89ba5c9344329aae9603a..1037905c20dfa9a61a593e7732e0027ce268bd26 100644 --- a/source/texk/web2c/luatexdir/lua/luastuff.c +++ b/source/texk/web2c/luatexdir/lua/luastuff.c @@ -394,7 +394,7 @@ lua_State *luatex_error(lua_State * L, int is_fatal) char *err = NULL; if (lua_isstring(L, -1)) { luaerr = lua_tolstring(L, -1, &len); - err = (char *) xmalloc((unsigned)(len + 1)); + err = (char *) xmalloc((unsigned) (len + 1)); len = (size_t) snprintf(err, (len + 1), "%s", luaerr); } if (is_fatal > 0) { diff --git a/source/texk/web2c/luatexdir/lua/luatex-api.h b/source/texk/web2c/luatexdir/lua/luatex-api.h index 6bb094e83712dfe7c512891ffc176c1e05d1422b..82c5df3aec63bec7905b4a33fc924e8f85e2ed64 100644 --- a/source/texk/web2c/luatexdir/lua/luatex-api.h +++ b/source/texk/web2c/luatexdir/lua/luatex-api.h @@ -187,7 +187,7 @@ extern char *luanames[]; extern int ff_get_ttc_index(char *ffname, char *psname); /* luafontloader/src/luafflib.c */ extern int ff_createcff(char *, unsigned char **, int *); /* luafontloader/src/luafflib.c */ -extern char *FindResourceTtfFont(char *filename, char *fontname); /* luafontloader/fontforge/fontforge/macbinary.c */ +extern char *FindResourceTtfFont(char *filename, char *fontname); /* luafontloader/fontforge/fontforge/macbinary.c */ extern char charsetstr[]; /* from mpdir/psout.w */ diff --git a/source/texk/web2c/luatexdir/lua/luatoken.c b/source/texk/web2c/luatexdir/lua/luatoken.c index c9b4dd155c541691e99a7185a74d255f1f21d67e..d8723d356c514afe41e0df030c2989d4beb49841 100644 --- a/source/texk/web2c/luatexdir/lua/luatoken.c +++ b/source/texk/web2c/luatexdir/lua/luatoken.c @@ -198,12 +198,12 @@ static int get_cur_cmd(lua_State * L) if (len == 3 || len == 2) { r = 1; lua_rawgeti(L, -1, 1); - cur_cmd = (int)lua_tointeger(L, -1); + cur_cmd = (int) lua_tointeger(L, -1); lua_rawgeti(L, -2, 2); - cur_chr = (halfword)lua_tointeger(L, -1); + cur_chr = (halfword) lua_tointeger(L, -1); if (len == 3) { lua_rawgeti(L, -3, 3); - cur_cs = (halfword)lua_tointeger(L, -1); + cur_cs = (halfword) lua_tointeger(L, -1); } lua_pop(L, (int) len); if (cur_cs == 0) @@ -222,12 +222,12 @@ static int token_from_lua(lua_State * L) size_t len = lua_objlen(L, -1); if (len == 3 || len == 2) { lua_rawgeti(L, -1, 1); - cmd = (int)lua_tointeger(L, -1); + cmd = (int) lua_tointeger(L, -1); lua_rawgeti(L, -2, 2); - chr = (int)lua_tointeger(L, -1); + chr = (int) lua_tointeger(L, -1); if (len == 3) { lua_rawgeti(L, -3, 3); - cs = (int)lua_tointeger(L, -1); + cs = (int) lua_tointeger(L, -1); } lua_pop(L, (int) len); if (cs == 0) { diff --git a/source/texk/web2c/luatexdir/ocp/ocp.c b/source/texk/web2c/luatexdir/ocp/ocp.c index 0b7d3920805eea197f518a97b98769c43de03bb6..d5f26c94009bb7b974fc866d9e9620863428bc97 100644 --- a/source/texk/web2c/luatexdir/ocp/ocp.c +++ b/source/texk/web2c/luatexdir/ocp/ocp.c @@ -130,7 +130,7 @@ void allocate_ocp_table(int ocp_number, int ocp_size) ocp_entries = 65536; } ocp_tables[ocp_number] = - (int *) xmalloc((unsigned) ((1 + (unsigned)ocp_size) * sizeof(int))); + (int *) xmalloc((unsigned) ((1 + (unsigned) ocp_size) * sizeof(int))); ocp_tables[ocp_number][0] = ocp_size; for (i = 1; i <= ocp_size; i++) { ocp_tables[ocp_number][i] = 0; @@ -178,7 +178,7 @@ static void undump_ocp_table(int ocp_number) } undump_things(sizeword, 1); ocp_tables[ocp_number] = - (int *) xmalloc((unsigned) ((1 + (unsigned)sizeword) * sizeof(int))); + (int *) xmalloc((unsigned) ((1 + (unsigned) sizeword) * sizeof(int))); ocp_tables[ocp_number][0] = sizeword; undump_things(ocp_tables[ocp_number][1], sizeword); } diff --git a/source/texk/web2c/luatexdir/ocp/readocp.c b/source/texk/web2c/luatexdir/ocp/readocp.c index 6ecf35179d2f372e2a17337c818362df48c0c5db..a8bd54753de76c73f7772c8ccba9ea63b9ea076c 100644 --- a/source/texk/web2c/luatexdir/ocp/readocp.c +++ b/source/texk/web2c/luatexdir/ocp/readocp.c @@ -124,7 +124,8 @@ read_ocp_info(pointer u, char *nom, char *aire, char *ext, boolean external_ocp) file_opened = false; if (external_ocp) { /* @<Check |ocp_file| exists@> */ - cnam = xmalloc((unsigned)(strlen(nom) + strlen(aire) + strlen(ext) + 1)); + cnam = + xmalloc((unsigned) (strlen(nom) + strlen(aire) + strlen(ext) + 1)); sprintf(cnam, "%s%s%s", aire, nom, ext); cnam = b_test_in(cnam); if (!cnam) @@ -148,7 +149,9 @@ read_ocp_info(pointer u, char *nom, char *aire, char *ext, boolean external_ocp) } else { /* @<Open |ocp_file| for input@>; */ - char *cname = xmalloc((unsigned)(strlen(nom) + strlen(aire) + strlen(".ocp") + 1)); + char *cname = + xmalloc((unsigned) + (strlen(nom) + strlen(aire) + strlen(".ocp") + 1)); sprintf(cname, "%s%s.ocp", aire, nom); xfree(ocp_buffer); ocp_cur = 0; diff --git a/source/texk/web2c/luatexdir/ocp/runocp.c b/source/texk/web2c/luatexdir/ocp/runocp.c index c97765674d4f76e5c2e564d0e97fc0a161048883..0c7dfb173d15b895655bed5b4a8ddfb296718b92 100644 --- a/source/texk/web2c/luatexdir/ocp/runocp.c +++ b/source/texk/web2c/luatexdir/ocp/runocp.c @@ -777,7 +777,7 @@ void run_ocp(void) /* k=0; ? */ char *cmd = makecstring(ocp_external(otp_input_ocp)); char *arg = makecstring(ocp_external_arg(otp_input_ocp)); - char *cmdline = xmalloc((unsigned)(strlen(cmd) + strlen(arg) + 3)); + char *cmdline = xmalloc((unsigned) (strlen(cmd) + strlen(arg) + 3)); strcpy(cmdline, cmd); strcat(cmdline, " "); strcat(cmdline, arg); diff --git a/source/texk/web2c/luatexdir/pdf/pdfgen.c b/source/texk/web2c/luatexdir/pdf/pdfgen.c index 77074e0863e7e0f5a7beee5e33b3fda74ac6b0f0..d9b9a1e95605eb30b7c382c9c0e36729aa045e65 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfgen.c +++ b/source/texk/web2c/luatexdir/pdf/pdfgen.c @@ -73,7 +73,7 @@ PDF init_pdf_struct(PDF pdf) /* Sometimes it is neccesary to allocate memory for PDF output that cannot be deallocated then, so we use |mem| for this purpose. */ pdf->mem_size = inf_pdf_mem_size; /* allocated size of |mem| array */ - pdf->mem = xmalloc((unsigned) ((unsigned)pdf->mem_size * sizeof(int))); + pdf->mem = xmalloc((unsigned) ((unsigned) pdf->mem_size * sizeof(int))); pdf->mem_ptr = 1; /* the first word is not used so we can use zero as a value for testing whether a pointer to |mem| is valid */ pdf->pstruct = NULL; @@ -85,7 +85,8 @@ PDF init_pdf_struct(PDF pdf) pdf->obj_tab_size = (unsigned) inf_obj_tab_size; /* allocated size of |obj_tab| array */ pdf->obj_tab = - xmalloc((unsigned) ((unsigned)(pdf->obj_tab_size + 1) * sizeof(obj_entry))); + xmalloc((unsigned) + ((unsigned) (pdf->obj_tab_size + 1) * sizeof(obj_entry))); memset(pdf->obj_tab, 0, sizeof(obj_entry)); pdf->minor_version = -1; /* unset */ @@ -441,7 +442,7 @@ void pdf_print_int(PDF pdf, longinteger n) n = m / 10; m = (m % 10) + 1; if (m < 10) { - dig[0] = (int)m; + dig[0] = (int) m; } else { dig[0] = 0; n++; @@ -451,7 +452,7 @@ void pdf_print_int(PDF pdf, longinteger n) } } do { - dig[k++] = (int)(n % 10); + dig[k++] = (int) (n % 10); n = n / 10; } while (n != 0); pdf_room(pdf, k); @@ -549,7 +550,8 @@ void pdf_end_stream(PDF pdf) pdf->stream_length = pdf_offset(pdf) - pdf_saved_offset(pdf); pdf_flush(pdf); if (pdf->seek_write_length) - write_stream_length(pdf, (int)pdf->stream_length, pdf->stream_length_offset); + write_stream_length(pdf, (int) pdf->stream_length, + pdf->stream_length_offset); pdf->seek_write_length = false; if (pdf->last_byte != pdf_new_line_char) pdf_out(pdf, pdf_new_line_char); @@ -782,7 +784,7 @@ void pdf_print_fw_int(PDF pdf, longinteger n, int w) int dig[24]; k = 0; do { - dig[k] = (int)(n % 10); + dig[k] = (int) (n % 10); n = n / 10; k++; } while (k != w); @@ -798,7 +800,7 @@ void pdf_out_bytes(PDF pdf, longinteger n, int w) int bytes[8]; /* digits in a number being output */ k = 0; do { - bytes[k] = (int)(n % 256); + bytes[k] = (int) (n % 256); n = n / 256; k++; } while (k != w); @@ -1445,7 +1447,7 @@ static void realloc_fb(PDF pdf) int fb_offset(PDF pdf) { - return (int)(pdf->fb_ptr - pdf->fb_array); + return (int) (pdf->fb_ptr - pdf->fb_array); } void fb_seek(PDF pdf, int offset) @@ -1467,7 +1469,7 @@ void fb_flush(PDF pdf) for (p = pdf->fb_array; p < pdf->fb_ptr;) { n = pdf->buf_size - pdf->ptr; if (pdf->fb_ptr - p < n) - n = (int)(pdf->fb_ptr - p); + n = (int) (pdf->fb_ptr - p); memcpy(pdf->buf + pdf->ptr, p, (unsigned) n); pdf->ptr += n; if (pdf->ptr == pdf->buf_size) @@ -1678,7 +1680,9 @@ char *get_resname_prefix(PDF pdf) short i; size_t base = strlen(name_str); crc = crc32(0L, Z_NULL, 0); - crc = crc32(crc, (Bytef *) pdf->job_id_string, (uInt)strlen(pdf->job_id_string)); + crc = + crc32(crc, (Bytef *) pdf->job_id_string, + (uInt) strlen(pdf->job_id_string)); for (i = 0; i < 6; i++) { prefix[i] = name_str[crc % base]; crc /= base; diff --git a/source/texk/web2c/luatexdir/pdf/pdfobj.c b/source/texk/web2c/luatexdir/pdf/pdfobj.c index c2e26fa035bfea2c10d9ac027fc9f7a131dd252b..977f06ac5afe59387d7861f5302d30213592574f 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfobj.c +++ b/source/texk/web2c/luatexdir/pdf/pdfobj.c @@ -67,7 +67,7 @@ void pdf_write_obj(PDF pdf, int k) st.l = li; if (obj_obj_is_file(pdf, k)) { boolean res = false; /* callback status value */ - const char *fnam = NULL; /* callback found filename */ + const char *fnam = NULL; /* callback found filename */ int callback_id; /* st.s is also '\0'-terminated, even as lstring */ fnam = luatex_find_file(st.s, find_data_file_callback); diff --git a/source/texk/web2c/luatexdir/pdf/pdfpage.c b/source/texk/web2c/luatexdir/pdf/pdfpage.c index dfb78029723e3e8599403dfb2dadafce7ac07095..d7da4215ee526f6d94544ec41421e4bb6a359169 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfpage.c +++ b/source/texk/web2c/luatexdir/pdf/pdfpage.c @@ -124,20 +124,24 @@ boolean calc_pdfpos(pdfstructure * p, scaledpos pos) case PMODE_CHARARRAY: switch (p->wmode) { case WMODE_H: - new.h = lround((pos.h * p->k1 - (double)p->pdf_tj_pos.h.m) * p->k2); + new.h = + lround((pos.h * p->k1 - (double) p->pdf_tj_pos.h.m) * p->k2); new.v = lround(pos.v * p->k1); p->tj_delta.m = - -lround((double)((new.h - p->cw.m) / ten_pow[p->cw.e - p->tj_delta.e])); + -lround((double) + ((new.h - p->cw.m) / ten_pow[p->cw.e - p->tj_delta.e])); p->tm[5].m = new.v - p->pdf_bt_pos.v.m; /* p->tm[4] is meaningless */ if (p->tj_delta.m != 0 || new.v != p->pdf.v.m) move_pdfpos = TRUE; break; case WMODE_V: new.h = lround(pos.h * p->k1); - new.v = lround(((double)p->pdf_tj_pos.v.m - pos.v * p->k1) * p->k2); + new.v = + lround(((double) p->pdf_tj_pos.v.m - pos.v * p->k1) * p->k2); p->tm[4].m = new.h - p->pdf_bt_pos.h.m; /* p->tm[5] is meaningless */ p->tj_delta.m = - -lround((double)((new.v - p->cw.m) / ten_pow[p->cw.e - p->tj_delta.e])); + -lround((double) + ((new.v - p->cw.m) / ten_pow[p->cw.e - p->tj_delta.e])); if (p->tj_delta.m != 0 || new.h != p->pdf.h.m) move_pdfpos = TRUE; break; diff --git a/source/texk/web2c/luatexdir/pdf/pdfrule.c b/source/texk/web2c/luatexdir/pdf/pdfrule.c index 368f363f73637920901562725b4a28a9bc91fbab..e0c068908ccda96d6e71f1c34e2fd5de19b200c5 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfrule.c +++ b/source/texk/web2c/luatexdir/pdf/pdfrule.c @@ -39,7 +39,7 @@ void pdf_place_rule(PDF pdf, halfword q dim.v.e = p->pdf.v.e; pdf_printf(pdf, "q\n"); if (size.v <= one_bp) { - pos.v += (int)lround(0.5 * size.v); + pos.v += (int) lround(0.5 * size.v); pdf_set_pos_temp(pdf, pos); pdf_printf(pdf, "[]0 d 0 J "); print_pdffloat(pdf, dim.v); @@ -47,7 +47,7 @@ void pdf_place_rule(PDF pdf, halfword q print_pdffloat(pdf, dim.h); pdf_printf(pdf, " 0 l S\n"); } else if (size.h <= one_bp) { - pos.h += (int)lround(0.5 * size.h); + pos.h += (int) lround(0.5 * size.h); pdf_set_pos_temp(pdf, pos); pdf_printf(pdf, "[]0 d 0 J "); print_pdffloat(pdf, dim.h); diff --git a/source/texk/web2c/luatexdir/tex/arithmetic.h b/source/texk/web2c/luatexdir/tex/arithmetic.h index 5566eb48c64fc5e293e4a84bddbcf596a30aab27..cef9a3fbba0772ae45acc9e551d3bc1d4030a3ed 100644 --- a/source/texk/web2c/luatexdir/tex/arithmetic.h +++ b/source/texk/web2c/luatexdir/tex/arithmetic.h @@ -24,8 +24,8 @@ /* |incr| and |decr| are in texmfmp.h */ - /* #define incr(A) (A)++ *//* increase a variable by unity */ - /* #define decr(A) (A)-- *//* decrease a variable by unity */ + /* #define incr(A) (A)++ *//* increase a variable by unity */ + /* #define decr(A) (A)-- *//* decrease a variable by unity */ # define negate(A) (A)=-(A) /* change the sign of a variable */ diff --git a/source/texk/web2c/luatexdir/tex/filename.c b/source/texk/web2c/luatexdir/tex/filename.c index 12936c06bed061df654fcffb0b746a59e9722165..be43c060f79c36f69661841573d1645933a49362 100644 --- a/source/texk/web2c/luatexdir/tex/filename.c +++ b/source/texk/web2c/luatexdir/tex/filename.c @@ -106,9 +106,9 @@ static void end_name(void) } else { s = (unsigned char *) xstrdup((char *) (cur_string + area_delimiter)); cur_string[area_delimiter] = '\0'; - cur_length = (unsigned)strlen((char *) cur_string); + cur_length = (unsigned) strlen((char *) cur_string); cur_area = make_string(); - cur_length = (unsigned)strlen((char *) s); + cur_length = (unsigned) strlen((char *) s); cur_string = s; } if (ext_delimiter == 0) { @@ -118,9 +118,9 @@ static void end_name(void) int l = (ext_delimiter - area_delimiter - 1); s = (unsigned char *) xstrdup((char *) (cur_string + l)); cur_string[l] = '\0'; - cur_length = (unsigned)strlen((char *) cur_string); + cur_length = (unsigned) strlen((char *) cur_string); cur_name = make_string(); - cur_length = (unsigned)strlen((char *) s); + cur_length = (unsigned) strlen((char *) s); cur_string = s; cur_ext = make_string(); } @@ -155,14 +155,14 @@ void scan_file_name(void) if (cur_chr > 127) { unsigned char *bytes; unsigned char *thebytes; - thebytes = uni2str((unsigned)cur_chr); + thebytes = uni2str((unsigned) cur_chr); bytes = thebytes; while (*bytes) { if (!more_name(*bytes)) break; bytes++; } - xfree(thebytes); + xfree(thebytes); } else { if (!more_name(cur_chr)) break; diff --git a/source/texk/web2c/luatexdir/tex/inputstack.c b/source/texk/web2c/luatexdir/tex/inputstack.c index 60d0f2ce1adb3d2292d7388f1714317addefba74..ad3b2f11daa20163edb2bcc9ea517fd8bf5aac15 100644 --- a/source/texk/web2c/luatexdir/tex/inputstack.c +++ b/source/texk/web2c/luatexdir/tex/inputstack.c @@ -657,7 +657,7 @@ static halfword string_to_pseudo(str_number str, int nl) int sz; halfword h = new_node(pseudo_file_node, 0); unsigned char *s = str_string(str); - len = (unsigned)str_length(str); + len = (unsigned) str_length(str); l = 0; while (l < len) { unsigned m = l; /* start of current line */ diff --git a/source/texk/web2c/luatexdir/tex/mainbody.c b/source/texk/web2c/luatexdir/tex/mainbody.c index 89fecac969f55eeccc189f5378a60d29d9ba214e..5498f383213a9214d2d7a2732fda9cd01fddde38 100644 --- a/source/texk/web2c/luatexdir/tex/mainbody.c +++ b/source/texk/web2c/luatexdir/tex/mainbody.c @@ -399,6 +399,7 @@ int main_initialize(void) void main_body(void) { + static char pdftex_map[] = "pdftex.map"; bad = main_initialize(); history = fatal_error_stop; /* in case we quit during initialization */ t_open_out(); /* open the terminal for output */ @@ -438,7 +439,7 @@ void main_body(void) int_par(pdf_output_code) = pdf_output_value; if (pdf_draftmode_option != 0) int_par(pdf_draftmode_code) = pdf_draftmode_value; - pdf_init_map_file("pdftex.map"); + pdf_init_map_file((char *) pdftex_map); if (end_line_char_inactive()) decr(ilimit); else diff --git a/source/texk/web2c/luatexdir/tex/primitive.c b/source/texk/web2c/luatexdir/tex/primitive.c index 5b82cf021900b045902de9269d3cd71ab526a626..218ff431976e6c4913a57803e47792d7d280992d 100644 --- a/source/texk/web2c/luatexdir/tex/primitive.c +++ b/source/texk/web2c/luatexdir/tex/primitive.c @@ -152,7 +152,7 @@ pointer prim_lookup(str_number s) } } else { j = str_string(s); - l = (unsigned)str_length(s); + l = (unsigned) str_length(s); h = compute_hash((char *) j, l, prim_prime); p = h + prim_base; /* we start searching here; note that |0<=h<hash_prime| */ while (1) { @@ -255,8 +255,10 @@ void undump_primitives(void) undump_int(prim_data[p].subids); if (prim_data[p].subids > 0) { prim_data[p].names = - (str_number *) xmalloc((unsigned) prim_data[p].subids * - sizeof(str_number *)); + (str_number *) + xmalloc((unsigned) + ((unsigned) prim_data[p].subids * + sizeof(str_number *))); for (q = 0; q < prim_data[p].subids; q++) undump_int(prim_data[p].names[q]); } diff --git a/source/texk/web2c/luatexdir/tex/printing.c b/source/texk/web2c/luatexdir/tex/printing.c index f4ae7a02cd855c83ee2daa7d4bdefb2cf37691d9..6843fe5bf15aba3b1a6edeaa4735d217a6dacd74 100644 --- a/source/texk/web2c/luatexdir/tex/printing.c +++ b/source/texk/web2c/luatexdir/tex/printing.c @@ -279,7 +279,7 @@ void print(int s) return; } if (selector == new_string) { - append_string(str_string(s), (unsigned)str_length(s)); + append_string(str_string(s), (unsigned) str_length(s)); return; } j = str_string(s); @@ -323,7 +323,7 @@ void tprint(const char *s) { const unsigned char *ss = (const unsigned char *) s; if (selector == new_string) { - append_string(ss, (unsigned)strlen(s)); + append_string(ss, (unsigned) strlen(s)); return; } while (*ss) @@ -478,7 +478,7 @@ void print_int(longinteger n) m = (m % 10) + 1; k = 1; if (m < 10) - dig[0] = (int)m; + dig[0] = (int) m; else { dig[0] = 0; incr(n); @@ -486,7 +486,7 @@ void print_int(longinteger n) } } do { - dig[k] = (int)(n % 10); + dig[k] = (int) (n % 10); n = n / 10; incr(k); } while (n != 0); diff --git a/source/texk/web2c/luatexdir/tex/stringpool.c b/source/texk/web2c/luatexdir/tex/stringpool.c index f60676067e3b8a3f2cf902b593c12d40155237c3..b3890e4786ed07f1a473cd3a75b0caf02e3ed881 100644 --- a/source/texk/web2c/luatexdir/tex/stringpool.c +++ b/source/texk/web2c/luatexdir/tex/stringpool.c @@ -349,7 +349,7 @@ boolean get_strings_started(void) str_number search_string(str_number search) { str_number s; /* running index */ - size_t len; /* length of searched string */ + size_t len; /* length of searched string */ len = str_length(search); if (len == 0) { return get_nullstr(); @@ -377,7 +377,7 @@ str_number maketexlstring(const char *s, size_t l) { if (s == NULL || l == 0) return get_nullstr(); - str_string(str_ptr) = xmalloc((unsigned)(l + 1)); + str_string(str_ptr) = xmalloc((unsigned) (l + 1)); memcpy(str_string(str_ptr), s, (l + 1)); str_length(str_ptr) = (unsigned) l; str_ptr++; @@ -389,7 +389,7 @@ void append_string(const unsigned char *s, unsigned l) { if (s == NULL || *s == 0) return; - l = (unsigned)strlen((const char *) s); + l = (unsigned) strlen((const char *) s); str_room(l); memcpy(cur_string + cur_length, s, l); cur_length += l; @@ -408,7 +408,7 @@ char *makeclstring(int s, size_t * len) *len = (size_t) utf8_size(s); return (char *) uni2str((unsigned) s); } else { - unsigned l = (unsigned)str_length(s); + unsigned l = (unsigned) str_length(s); char *cstrbuf = xmalloc(l + 1); memcpy(cstrbuf, str_string(s), l); cstrbuf[l] = '\0'; @@ -477,7 +477,7 @@ void flush_str(str_number s) { /* printf("Flushing a string: %s (s=%d,str_ptr=%d)\n", (char *)str_string(s), (int)s, (int)str_ptr); */ if (s > STRING_OFFSET) { /* don't ever delete the null string */ - pool_size -= (unsigned)str_length(s); + pool_size -= (unsigned) str_length(s); str_length(s) = 0; xfree(str_string(s)); } diff --git a/source/texk/web2c/luatexdir/tex/texfileio.c b/source/texk/web2c/luatexdir/tex/texfileio.c index f280de3721b3b7fc2f805b14a30233c8ceb188fb..160b6a53e72f394af978e36cab9f2d92414436df 100644 --- a/source/texk/web2c/luatexdir/tex/texfileio.c +++ b/source/texk/web2c/luatexdir/tex/texfileio.c @@ -1029,7 +1029,7 @@ int readbinfile(FILE * f, unsigned char **tfm_buffer, int *tfm_size) void *buf; int size; if (fseek(f, 0, SEEK_END) == 0) { - size = (int)ftell(f); + size = (int) ftell(f); if (size > 0) { buf = xmalloc((unsigned) size); if (fseek(f, 0, SEEK_SET) == 0) { @@ -1286,7 +1286,7 @@ boolean open_in_or_pipe(FILE ** f_ptr, char *fn, int filefmt, if (shellenabledp && *fn == '|') { /* the user requested a pipe */ *f_ptr = NULL; - fname = (string) xmalloc((unsigned)(strlen(fn) + 1)); + fname = (string) xmalloc((unsigned) (strlen(fn) + 1)); strcpy(fname, fn); if (fullnameoffile) free(fullnameoffile); @@ -1323,7 +1323,7 @@ boolean open_out_or_pipe(FILE ** f_ptr, char *fn, const_string fopen_mode) if (shellenabledp && *fn == '|') { /* the user requested a pipe */ - fname = (string) xmalloc((unsigned)(strlen(fn) + 1)); + fname = (string) xmalloc((unsigned) (strlen(fn) + 1)); strcpy(fname, fn); if (strchr(fname, ' ') == NULL && strchr(fname, '>') == NULL) { /* mp and mf currently do not use this code, but it diff --git a/source/texk/web2c/luatexdir/tex/texnodes.c b/source/texk/web2c/luatexdir/tex/texnodes.c index cd0fee1961c170fa6d028a645f9d5efb98851bd3..a981f75d417a2c4a73bbc5b8b0203d5165e5282a 100644 --- a/source/texk/web2c/luatexdir/tex/texnodes.c +++ b/source/texk/web2c/luatexdir/tex/texnodes.c @@ -1787,7 +1787,7 @@ char *sprint_node_mem_usage(void) snprintf(msg, 255, "%s%d %s", (b ? ", " : ""), (int) node_counts[i], get_node_name((i > last_normal_node ? whatsit_node : i), j)); - ss = xmalloc((unsigned)(strlen(s) + strlen(msg) + 1)); + ss = xmalloc((unsigned) (strlen(s) + strlen(msg) + 1)); strcpy(ss, s); strcat(ss, msg); free(s); diff --git a/source/texk/web2c/luatexdir/tex/textoken.c b/source/texk/web2c/luatexdir/tex/textoken.c index 810368153b475ee42e53992d7d0ce2413bc3d193..1fdc8cd296aca2acaef4faab7b34e50bdf8cc415 100644 --- a/source/texk/web2c/luatexdir/tex/textoken.c +++ b/source/texk/web2c/luatexdir/tex/textoken.c @@ -1667,7 +1667,8 @@ static boolean print_convert_string(halfword c, int i) print(job_name); break; case font_name_code: - append_string((unsigned char *) font_name(i), (unsigned)strlen(font_name(i))); + append_string((unsigned char *) font_name(i), + (unsigned) strlen(font_name(i))); if (font_size(i) != font_dsize(i)) { tprint(" at "); print_scaled(font_size(i)); diff --git a/source/texk/web2c/luatexdir/utils/avl.c b/source/texk/web2c/luatexdir/utils/avl.c index 26d9f038c0f166695c5370d3d25999c662a8c848..894203d476ec29c1aef1cae0732f40f04843949a 100644 --- a/source/texk/web2c/luatexdir/utils/avl.c +++ b/source/texk/web2c/luatexdir/utils/avl.c @@ -106,7 +106,8 @@ void **avl_probe(struct avl_table *tree, void *item) if (p->avl_balance != 0) z = q, y = p, k = 0; - da[k++] = dir = cmp > 0; + dir = cmp > 0; + da[k++] = (unsigned char)dir; } n = q->avl_link[dir] = @@ -217,6 +218,8 @@ void *avl_delete(struct avl_table *tree, const void *item) struct avl_node *p; /* Traverses tree to find node to delete. */ int cmp; /* Result of comparison between |item| and |p|. */ + void *res; + assert(tree != NULL && item != NULL); k = 0; @@ -226,13 +229,13 @@ void *avl_delete(struct avl_table *tree, const void *item) int dir = cmp > 0; pa[k] = p; - da[k++] = dir; + da[k++] = (unsigned char)dir; p = p->avl_link[dir]; if (p == NULL) return NULL; } - item = p->avl_data; + res = p->avl_data; if (p->avl_link[1] == NULL) pa[k - 1]->avl_link[da[k - 1]] = p->avl_link[0]; @@ -348,7 +351,7 @@ void *avl_delete(struct avl_table *tree, const void *item) tree->avl_count--; tree->avl_generation++; - return (void *) item; + return res; } /* Refreshes the stack of parent pointers in |trav| @@ -657,8 +660,7 @@ struct avl_table *avl_copy(const struct avl_table *org, avl_copy_func * copy, int height = 0; struct avl_table *new; - const struct avl_node *x; - struct avl_node *y; + struct avl_node org_head, *x, *y; assert(org != NULL); new = avl_create(org->avl_compare, org->avl_param, @@ -669,7 +671,8 @@ struct avl_table *avl_copy(const struct avl_table *org, avl_copy_func * copy, if (new->avl_count == 0) return new; - x = (const struct avl_node *) &org->avl_root; + org_head.avl_link[0] = (struct avl_node *) org->avl_root; + x = &org_head; y = (struct avl_node *) &new->avl_root; for (;;) { while (x->avl_link[0] != NULL) { @@ -688,7 +691,7 @@ struct avl_table *avl_copy(const struct avl_table *org, avl_copy_func * copy, return NULL; } - stack[height++] = (struct avl_node *) x; + stack[height++] = x; stack[height++] = y; x = x->avl_link[0]; y = y->avl_link[0]; diff --git a/source/texk/web2c/luatexdir/utils/avlstuff.c b/source/texk/web2c/luatexdir/utils/avlstuff.c index 7d15723526238738aeca0e23ebfdd19f09ca9aee..acae048dd5086d662245d39ae126b74583b1c858 100644 --- a/source/texk/web2c/luatexdir/utils/avlstuff.c +++ b/source/texk/web2c/luatexdir/utils/avlstuff.c @@ -31,7 +31,7 @@ static const char _svn_version[] = static void *avl_xmalloc(struct libavl_allocator *allocator, size_t size) { assert(allocator != NULL && size > 0); - return xmalloc((unsigned)size); + return xmalloc((unsigned) size); } static void avl_xfree(struct libavl_allocator *allocator, void *block) diff --git a/source/texk/web2c/luatexdir/utils/managed-sa.c b/source/texk/web2c/luatexdir/utils/managed-sa.c index c91b63c162421d4620c3b2fd730dc2f013d8506a..82097619b2c462f6ca8cbdfe9e6ba27bf78d4187 100644 --- a/source/texk/web2c/luatexdir/utils/managed-sa.c +++ b/source/texk/web2c/luatexdir/utils/managed-sa.c @@ -201,7 +201,8 @@ void dump_sa_tree(sa_tree a) int h, m, l; assert(a != NULL); dump_int(a->stack_step); - x = (int)a->dflt; dump_int(x); + x = (int) a->dflt; + dump_int(x); if (a->tree != NULL) { dump_int(1); for (h = 0; h < HIGHPART; h++) { @@ -213,7 +214,7 @@ void dump_sa_tree(sa_tree a) f = 1; dump_qqqq(f); for (l = 0; l < LOWPART; l++) { - x = (int)a->tree[h][m][l]; + x = (int) a->tree[h][m][l]; dump_int(x); } } else { @@ -242,7 +243,7 @@ sa_tree undump_sa_tree(void) a->stack_step = x; a->stack_size = x; undump_int(x); - a->dflt = (sa_tree_item)x; + a->dflt = (sa_tree_item) x; a->stack = Mxmalloc_array(sa_stack_item, a->stack_size); a->stack_ptr = 0; a->tree = NULL; diff --git a/source/texk/web2c/luatexdir/utils/synctex-common.h b/source/texk/web2c/luatexdir/utils/synctex-common.h index 41057363d4c13010bb8803b834237095c9651988..82d1199ece5f1067504ece6d12d4ab07bb799eb0 100644 --- a/source/texk/web2c/luatexdir/utils/synctex-common.h +++ b/source/texk/web2c/luatexdir/utils/synctex-common.h @@ -38,8 +38,8 @@ Latest Revision: Wed Jul 1 08:07:50 UTC 2009 */ -# ifndef __SYNCTEX_COMMON_HEADER__ -# define __SYNCTEX_COMMON_HEADER__ +#ifndef __SYNCTEX_COMMON_HEADER__ +# define __SYNCTEX_COMMON_HEADER__ /* Send this message to init the synctex command value to the command line option. * Sending this message too early will cause a bus error. */ @@ -48,4 +48,4 @@ extern void synctexinitcommand(void); /* Send this message to clean memory, and close the file. */ extern void synctexterminate(int log_opened); -# endif +#endif diff --git a/source/texk/web2c/luatexdir/utils/synctex-luatex.h b/source/texk/web2c/luatexdir/utils/synctex-luatex.h index c2ccb5e6585d5a9bd39c6435bc75167bf282edce..810d483815764f05be76067b992bbaf3e07c4b4a 100644 --- a/source/texk/web2c/luatexdir/utils/synctex-luatex.h +++ b/source/texk/web2c/luatexdir/utils/synctex-luatex.h @@ -37,7 +37,7 @@ authorization from the copyright holder. /* $Id$ */ #undef synchronization_field_size -# define synchronization_field_size 1 +#define synchronization_field_size 1 #undef width_offset #undef height_offset @@ -56,17 +56,17 @@ authorization from the copyright holder. #undef SYNCTEX_LINE_MODEL #undef SYNCTEX_VALUE -# define SYNCTEX_TAG_MODEL(NODE,SIZE)\ +#define SYNCTEX_TAG_MODEL(NODE,SIZE)\ vinfo(NODE+SIZE-synchronization_field_size) -# define SYNCTEX_LINE_MODEL(NODE,SIZE)\ +#define SYNCTEX_LINE_MODEL(NODE,SIZE)\ vlink(NODE+SIZE-synchronization_field_size) -# define SYNCTEX_TYPE(NODE) type(NODE) -# define SYNCTEX_SUBTYPE(NODE) subtype(NODE) -# define SYNCTEX_WIDTH(NODE) width(NODE) -# define SYNCTEX_DEPTH(NODE) depth(NODE) -# define SYNCTEX_HEIGHT(NODE) height(NODE) -# define SYNCTEX_VALUE int_par(synctex_code) +#define SYNCTEX_TYPE(NODE) type(NODE) +#define SYNCTEX_SUBTYPE(NODE) subtype(NODE) +#define SYNCTEX_WIDTH(NODE) width(NODE) +#define SYNCTEX_DEPTH(NODE) depth(NODE) +#define SYNCTEX_HEIGHT(NODE) height(NODE) +#define SYNCTEX_VALUE int_par(synctex_code) #define CURV static_pdf->posstruct->pos.v @@ -85,16 +85,15 @@ authorization from the copyright holder. #define synctextagfield synctex_tag_field #define namefield name_field -# include "ptexlib.h" +#include "ptexlib.h" /* We observe pdfoutputvalue in order to determine whether output mode is * pdf or dvi. * We will assume that pdf_output_value equals pdf_output before entering * the synctex_sheet function below. */ -# undef SYNCTEX_OFFSET_IS_PDF -# define SYNCTEX_OFFSET_IS_PDF (pdf_output_value>0) -# undef SYNCTEX_OUTPUT -# define SYNCTEX_OUTPUT ((pdf_output_value>0)?"pdf":"dvi") - -# define __SyncTeX__ 1 +#undef SYNCTEX_OFFSET_IS_PDF +#define SYNCTEX_OFFSET_IS_PDF (pdf_output_value>0) +#undef SYNCTEX_OUTPUT +#define SYNCTEX_OUTPUT ((pdf_output_value>0)?"pdf":"dvi") +#define __SyncTeX__ 1 diff --git a/source/texk/web2c/luatexdir/utils/synctex.c b/source/texk/web2c/luatexdir/utils/synctex.c index 139134c291e408efcc2baae0ab06b9414f2722c1..a2c022b6e441cfd7f65650a8f3d1183bfa6360a3 100644 --- a/source/texk/web2c/luatexdir/utils/synctex.c +++ b/source/texk/web2c/luatexdir/utils/synctex.c @@ -110,23 +110,23 @@ Latest Revision: Wed Jul 1 08:15:44 UTC 2009 */ -# define SYNCTEX_VERSION 1 +#define SYNCTEX_VERSION 1 -# define SYNCTEX_DEBUG 0 +#define SYNCTEX_DEBUG 0 /* Debugging: define the next macro to "return;" in order to disable the synctex code * only suplemental function calls will be used. The compiler may optimize them. */ -# define SYNCTEX_RETURN_IF_DISABLED ; +#define SYNCTEX_RETURN_IF_DISABLED ; -# define SYNCTEX_NOERR 0 +#define SYNCTEX_NOERR 0 -# define EXTERN extern +#define EXTERN extern -# ifdef xfree -# define SYNCTEX_FREE xfree -# else -# define SYNCTEX_FREE(x) free(x) -# endif +#ifdef xfree +# define SYNCTEX_FREE xfree +#else +# define SYNCTEX_FREE(x) free(x) +#endif /* the macros defined below do the same job than their almost eponym * counterparts of *tex.web, the memory access is sometimes more direct @@ -136,26 +136,26 @@ Latest Revision: Wed Jul 1 08:15:44 UTC 2009 * and *tex.web for details, the synctex_ prefix prevents name conflicts, it * is some kind of namespace */ -# warning These structures MUST be kept in synchronization with the main program +#warning These structures MUST be kept in synchronization with the main program /* synctexoption is a global integer variable defined in *tex.web * it is set to 1 by texmfmp.c if the command line has the '-synctex=1' * option. */ -# define synctex_options synctexoption -# define SYNCTEX_NO_OPTION INT_MAX +#define synctex_options synctexoption +#define SYNCTEX_NO_OPTION INT_MAX /* if synctex_options is set to SYNCTEX_NO_OPTION, no command line option was provided. */ /* glue code: really define the main memory, * this is exactly the same "mem" as in *tex.web. */ -# define mem zmem +#define mem zmem /* glue code: synctexoffset is a global integer variable defined in *tex.web * it is set to the offset where the primitive \synctex reads and writes its * value. */ -# define SYNCTEX_VALUE zeqtb[synctexoffset].cint +#define SYNCTEX_VALUE zeqtb[synctexoffset].cint /* if there were a mean to share the value of synctex_code between *tex.web * and this file, it would be great. */ -# define SYNCTEX_UNIT_FACTOR 1 -# define UNIT / synctex_ctxt.unit +#define SYNCTEX_UNIT_FACTOR 1 +#define UNIT / synctex_ctxt.unit /* UNIT is the scale. TeX coordinates are very accurate and client won't need * that, at leat in a first step. 1.0 <-> 2^16 = 65536. * The TeX unit is sp (scaled point) or pt/65536 which means that the scale @@ -182,7 +182,7 @@ Latest Revision: Wed Jul 1 08:15:44 UTC 2009 The 9 definitions below must be in sync with their eponym declarations in the proper synctex-*.ch* file. */ -# define synchronization_field_size 2 +#define synchronization_field_size 2 /* The default value is 2, it is suitable for original TeX and alike, * but it is too big for XeTeX. * The tag and the line are just the two last words of the node. This is a @@ -191,35 +191,35 @@ Latest Revision: Wed Jul 1 08:15:44 UTC 2009 * XeTeX redefines synchronization_field_size, * SYNCTEX_TAG_MODEL and SYNCTEX_LINE_MODEL * All the default values are targeted to TeX or e-TeX. */ -# define SYNCTEX_TAG_MODEL(NODE,SIZE)\ +#define SYNCTEX_TAG_MODEL(NODE,SIZE)\ mem[NODE+SIZE-synchronization_field_size].cint -# define SYNCTEX_LINE_MODEL(NODE,SIZE)\ +#define SYNCTEX_LINE_MODEL(NODE,SIZE)\ mem[NODE+SIZE-synchronization_field_size+1].cint /* SYNCTEX_TAG_MODEL and SYNCTEX_LINE_MODEL are used to define * SYNCTEX_TAG and SYNCTEX_LINE in a model independant way * Both are tag and line accessors */ -# define box_node_size (7+synchronization_field_size) +#define box_node_size (7+synchronization_field_size) /* see: @d box_node_size=... * There should be an automatic process here because these definitions * are redundant. However, this process would certainly be overcomplicated * (building then parsing the *tex.web file would be a pain) */ -# define width_offset 1 +#define width_offset 1 /* see: @d width_offset=... */ -# define depth_offset 2 +#define depth_offset 2 /* see: @d depth_offset=... */ -# define height_offset 3 +#define height_offset 3 /* see: @d height_offset=... */ /* Now define the local version of width(##), height(##) and depth(##) macros These only depend on the 3 macros above. */ -# define SYNCTEX_TYPE(NODE) mem[NODE].hh.b0 -# define rule_node 2 -# define glue_node 10 -# define kern_node 11 -# define SYNCTEX_SUBTYPE(NODE) mem[NODE].hh.b1 -# define SYNCTEX_WIDTH(NODE) mem[NODE+width_offset].cint -# define SYNCTEX_DEPTH(NODE) mem[NODE+depth_offset].cint -# define SYNCTEX_HEIGHT(NODE) mem[NODE+height_offset].cint +#define SYNCTEX_TYPE(NODE) mem[NODE].hh.b0 +#define rule_node 2 +#define glue_node 10 +#define kern_node 11 +#define SYNCTEX_SUBTYPE(NODE) mem[NODE].hh.b1 +#define SYNCTEX_WIDTH(NODE) mem[NODE+width_offset].cint +#define SYNCTEX_DEPTH(NODE) mem[NODE+depth_offset].cint +#define SYNCTEX_HEIGHT(NODE) mem[NODE+height_offset].cint /* When an hlist ships out, it can contain many different kern/glue nodes with * exactly the same sync tag and line. To reduce the size of the .synctex @@ -232,127 +232,128 @@ Latest Revision: Wed Jul 1 08:15:44 UTC 2009 * a change in the context, this is the macro SYNCTEX_CONTEXT_DID_CHANGE. The * SYNCTEX_IGNORE macro is used to detect unproperly initialized nodes. See * details in the implementation of the functions below. */ -# define SYNCTEX_IGNORE(NODE) SYNCTEX_IS_OFF || !SYNCTEX_VALUE || !SYNCTEX_FILE +#define SYNCTEX_IGNORE(NODE) SYNCTEX_IS_OFF || !SYNCTEX_VALUE || !SYNCTEX_FILE /* Some parts of the code may differ depending on the ouput mode, * dvi or xdv vs pdf, in particular the management of magnification. * The default is dvi mode. * Also, if pdftex is used, the origin of the coordinates is at 0, not at 1in * Default values are suitable for TeX */ -# define SYNCTEX_OUTPUT "dvi" -# define SYNCTEX_OFFSET_IS_PDF 0 +#define SYNCTEX_OUTPUT "dvi" +#define SYNCTEX_OFFSET_IS_PDF 0 -# define SYNCTEX_TRUE 1 -# define SYNCTEX_YES (-1) -# define SYNCTEX_NO (0) -# define SYNCTEX_NO_ERROR (0) +#define SYNCTEX_TRUE 1 +#define SYNCTEX_YES (-1) +#define SYNCTEX_NO (0) +#define SYNCTEX_NO_ERROR (0) -# include "synctex-luatex.h" +#include "synctex-luatex.h" -# include "synctex.h" +#include "synctex.h" -# if defined(__SyncTeX__) +#if defined(__SyncTeX__) -# include <stdio.h> -# include <stdarg.h> -# include "zlib.h" +# include <stdio.h> +# include <stdarg.h> +# include "zlib.h" -typedef void (*synctex_recorder_t)(halfword); /* recorders know how to record a node */ -typedef int (*synctex_fprintf_t)(void *, const char * , ...); /* print formatted to either FILE * or gzFile */ +typedef void (*synctex_recorder_t) (halfword); /* recorders know how to record a node */ +typedef int (*synctex_fprintf_t) (void *, const char *, ...); /* print formatted to either FILE * or gzFile */ -# define SYNCTEX_BITS_PER_BYTE 8 +# define SYNCTEX_BITS_PER_BYTE 8 /* Here are all the local variables gathered in one "synchronization context" */ static struct { void *file; /* the foo.synctex or foo.synctex.gz I/O identifier */ - synctex_fprintf_t fprintf; /* either fprintf or gzprintf */ + synctex_fprintf_t fprintf; /* either fprintf or gzprintf */ char *busy_name; /* the real "foo.synctex(busy)" or "foo.synctex.gz(busy)" name */ char *root_name; /* in general jobname.tex */ integer count; /* The number of interesting records in "foo.synctex" */ /* next concern the last sync record encountered */ halfword node; /* the last synchronized node, must be set * before the recorder */ - synctex_recorder_t recorder;/* the recorder of the node above, the - * routine that knows how to record the - * node to the .synctex file */ + synctex_recorder_t recorder; /* the recorder of the node above, the + * routine that knows how to record the + * node to the .synctex file */ integer tag, line; /* current tag and line */ integer curh, curv; /* current point */ integer magnification; /* The magnification as given by \mag */ integer unit; /* The unit, defaults to 1, use 8192 to produce shorter but less accurate info */ integer total_length; /* The total length of the bytes written since the last check point */ struct _flags { - unsigned int option_read:1; /* Command line option read (in case of problem or at the end) */ - unsigned int off:1; /* Definitely turn off synctex, corresponds to cli option -synctex=0 */ - unsigned int no_gz:1; /* Whether zlib is used or not */ - unsigned int not_void:1; /* Whether it really contains synchronization material */ - unsigned int warn:1; /* One shot warning flag */ - unsigned int quoted:1; /* Whether the input file name was quoted by tex or not, for example "\"my input file.tex\"", unused by XeTeX */ - unsigned int reserved:SYNCTEX_BITS_PER_BYTE*sizeof(int)-6; /* Align */ - } flags; + unsigned int option_read:1; /* Command line option read (in case of problem or at the end) */ + unsigned int off:1; /* Definitely turn off synctex, corresponds to cli option -synctex=0 */ + unsigned int no_gz:1; /* Whether zlib is used or not */ + unsigned int not_void:1; /* Whether it really contains synchronization material */ + unsigned int warn:1; /* One shot warning flag */ + unsigned int quoted:1; /* Whether the input file name was quoted by tex or not, for example "\"my input file.tex\"", unused by XeTeX */ + unsigned int reserved:SYNCTEX_BITS_PER_BYTE * sizeof(int) - 6; /* Align */ + } flags; } synctex_ctxt = { -NULL, NULL, NULL, NULL, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, {0,0,0,0,0,0,0}}; + NULL, NULL, NULL, NULL, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, { +0, 0, 0, 0, 0, 0, 0}}; -#define SYNCTEX_FILE synctex_ctxt.file -#define SYNCTEX_IS_OFF (synctex_ctxt.flags.off) -#define SYNCTEX_NO_GZ (synctex_ctxt.flags.no_gz) -#define SYNCTEX_NOT_VOID (synctex_ctxt.flags.not_void) -#define SYNCTEX_WARNING_DISABLE (synctex_ctxt.flags.warn) -#define SYNCTEX_fprintf (*synctex_ctxt.fprintf) +# define SYNCTEX_FILE synctex_ctxt.file +# define SYNCTEX_IS_OFF (synctex_ctxt.flags.off) +# define SYNCTEX_NO_GZ (synctex_ctxt.flags.no_gz) +# define SYNCTEX_NOT_VOID (synctex_ctxt.flags.not_void) +# define SYNCTEX_WARNING_DISABLE (synctex_ctxt.flags.warn) +# define SYNCTEX_fprintf (*synctex_ctxt.fprintf) /* Initialize the options, synchronize the variables. * This is sent by *tex.web before any TeX macro is used. * */ void synctexinitcommand(void) { - /* This is a one shot function, any subsequent call is void */ - if (synctex_ctxt.flags.option_read) { - return; - } + /* This is a one shot function, any subsequent call is void */ + if (synctex_ctxt.flags.option_read) { + return; + } if (SYNCTEX_NO_OPTION == synctex_options) { /* No option given from the command line */ SYNCTEX_VALUE = 0; } else if (synctex_options == 0) { /* -synctex=0 was given: SyncTeX must be definitely disabled, - * any subsequent \synctex=1 will have no effect at all */ + * any subsequent \synctex=1 will have no effect at all */ SYNCTEX_IS_OFF = SYNCTEX_TRUE; SYNCTEX_VALUE = 0; } else { /* the command line options are not ignored */ - if(synctex_options < 0) { - SYNCTEX_NO_GZ = SYNCTEX_TRUE; - } - /* Initialize the content of the \synctex primitive */ - SYNCTEX_VALUE = synctex_options; + if (synctex_options < 0) { + SYNCTEX_NO_GZ = SYNCTEX_TRUE; + } + /* Initialize the content of the \synctex primitive */ + SYNCTEX_VALUE = synctex_options; } - synctex_ctxt.flags.option_read = SYNCTEX_TRUE; - return; + synctex_ctxt.flags.option_read = SYNCTEX_TRUE; + return; } /* Free all memory used, close and remove the file if any, * It is sent locally when there is a problem with synctex output. * It is sent by pdftex when a fatal error occurred in pdftex.web. */ -void synctexabort(boolean log_opened __attribute__((unused))) +void synctexabort(boolean log_opened __attribute__ ((unused))) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctex_abort\n"); -#endif +# endif if (SYNCTEX_FILE) { - if (SYNCTEX_NO_GZ) { - xfclose((FILE *)SYNCTEX_FILE, synctex_ctxt.busy_name); - } else { - gzclose((gzFile)SYNCTEX_FILE); - } - SYNCTEX_FILE = NULL; - remove(synctex_ctxt.busy_name); + if (SYNCTEX_NO_GZ) { + xfclose((FILE *) SYNCTEX_FILE, synctex_ctxt.busy_name); + } else { + gzclose((gzFile) SYNCTEX_FILE); + } + SYNCTEX_FILE = NULL; + remove(synctex_ctxt.busy_name); SYNCTEX_FREE(synctex_ctxt.busy_name); synctex_ctxt.busy_name = NULL; } - if(NULL != synctex_ctxt.root_name) { - SYNCTEX_FREE(synctex_ctxt.root_name); - synctex_ctxt.root_name = NULL; - } - SYNCTEX_IS_OFF = SYNCTEX_TRUE; /* disable synctex */ + if (NULL != synctex_ctxt.root_name) { + SYNCTEX_FREE(synctex_ctxt.root_name); + synctex_ctxt.root_name = NULL; + } + SYNCTEX_IS_OFF = SYNCTEX_TRUE; /* disable synctex */ } static inline int synctex_record_preamble(void); @@ -372,112 +373,120 @@ static const char *synctex_suffix_busy = "(busy)"; */ static void *synctex_dot_open(void) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nwarning: Synchronize DEBUG: synctex_dot_open\n"); printf("\nwarning: SYNCTEX_VALUE=%0X\n", SYNCTEX_VALUE); printf("\nwarning: synctex_options=%0X\n", synctex_options); -# endif +# endif if (SYNCTEX_IS_OFF || !SYNCTEX_VALUE) { - return NULL; /* synchronization is disabled: do nothing */ + return NULL; /* synchronization is disabled: do nothing */ } if (SYNCTEX_FILE) { - return SYNCTEX_FILE; /* synchronization is alerady enabled */ + return SYNCTEX_FILE; /* synchronization is alerady enabled */ } -#if SYNCTEX_DEBUG +# if SYNCTEX_DEBUG printf("\nwarning: Synchronize DEBUG: synctex_dot_open 1\n"); -# endif - /* this is the first time we are asked to open the file - this part of code is executed only once: - either SYNCTEX_FILE is nonnegative or synchronization is - definitely disabled. */ - { - size_t len; - char *tmp = GETJOBNAME(); - /* jobname was set by the \jobname command on the *TeX side */ - char * the_busy_name = xmalloc((unsigned)(strlen(tmp) + strlen(synctex_suffix) + strlen(synctex_suffix_gz) + strlen(synctex_suffix_busy) + 1)); - if(!the_busy_name) { - SYNCTEX_FREE(tmp); - synctexabort(0); - return NULL; - } -# if defined(XeTeX) - synctex_ctxt.flags.quoted = 0; - strcpy(the_busy_name, tmp); -# else - len = strlen(tmp); - if(len>0 && tmp[0]=='"' && tmp[len-1]=='"') { - /* We are certainly on a pdftex like engine and the input file name did contain spaces inside. - Quotes where added around that file name. We prefer to remove the quotes to have a human readable name. - As of Fri Sep 19 14:00:01 UTC 2008, the file names containing quotes are not supported by pdfTeX - nor SyncTeX. */ - synctex_ctxt.flags.quoted = 1;/* we will have to add quotes around the file name in the log file. */ - strcpy(the_busy_name, tmp+1);/* only copy what follows the leading " character */ - len = strlen(the_busy_name); - if((len>0) && (the_busy_name[len-1]=='"')) { - the_busy_name[len-1]='\0'; - } - } else { - synctex_ctxt.flags.quoted = 0; - strcpy(the_busy_name, tmp); - } -# endif - SYNCTEX_FREE(tmp); - tmp = NULL; - strcat(the_busy_name, synctex_suffix); - /* Initialize SYNCTEX_NO_GZ with the content of \synctex to let the user choose the format. */ - if (SYNCTEX_VALUE<0) { SYNCTEX_NO_GZ = SYNCTEX_TRUE; } - else { SYNCTEX_NO_GZ = SYNCTEX_NO;} - if (!SYNCTEX_NO_GZ) { - strcat(the_busy_name, synctex_suffix_gz); - } - strcat(the_busy_name, synctex_suffix_busy); - if (SYNCTEX_NO_GZ) { - SYNCTEX_FILE = xfopen(the_busy_name, FOPEN_WBIN_MODE); - synctex_ctxt.fprintf = (synctex_fprintf_t)(&fprintf); - } else { - SYNCTEX_FILE = gzopen(the_busy_name, FOPEN_WBIN_MODE); - synctex_ctxt.fprintf = (synctex_fprintf_t)(&gzprintf); - } -#if SYNCTEX_DEBUG - printf("\nwarning: Synchronize DEBUG: synctex_dot_open 2\n"); -#endif - if (SYNCTEX_FILE) { - if(SYNCTEX_NO_ERROR != synctex_record_preamble()) { - synctexabort(0); - return NULL; - } - /* Initialization of the context */ - synctex_ctxt.magnification = 1000; - synctex_ctxt.unit = SYNCTEX_UNIT_FACTOR; - /* synctex_ctxt.busy_name was NULL before, it now owns the_busy_name */ - synctex_ctxt.busy_name = the_busy_name; - the_busy_name = NULL; - /* print the preamble, this is an quite an UTF8 file */ - if (NULL != synctex_ctxt.root_name) { - synctex_record_input(1,synctex_ctxt.root_name); - SYNCTEX_FREE(synctex_ctxt.root_name); - synctex_ctxt.root_name = NULL; - } - synctex_ctxt.count = 0; -#if SYNCTEX_DEBUG - fprintf(stdout, - "\nwarning: Synchronize DEBUG: synctex_dot_open SYNCTEX AVAILABLE\n"); -#endif - } else { - /* no .synctex file available, so disable synchronization */ - SYNCTEX_IS_OFF = SYNCTEX_TRUE; - SYNCTEX_VALUE = 0; - printf("\nSyncTeX warning: no synchronization, problem with %s\n",the_busy_name); - /* and free the_busy_name */ - SYNCTEX_FREE(the_busy_name); - the_busy_name = NULL; -#if SYNCTEX_DEBUG - fprintf(stdout, - "\nwarning: Synchronize DEBUG: synctex_dot_open SYNCTEX DISABLED\n"); -#endif - } - } +# endif + /* this is the first time we are asked to open the file + this part of code is executed only once: + either SYNCTEX_FILE is nonnegative or synchronization is + definitely disabled. */ + { + size_t len; + char *tmp = GETJOBNAME(); + /* jobname was set by the \jobname command on the *TeX side */ + char *the_busy_name = + xmalloc((unsigned) + (strlen(tmp) + strlen(synctex_suffix) + + strlen(synctex_suffix_gz) + strlen(synctex_suffix_busy) + + 1)); + if (!the_busy_name) { + SYNCTEX_FREE(tmp); + synctexabort(0); + return NULL; + } +# if defined(XeTeX) + synctex_ctxt.flags.quoted = 0; + strcpy(the_busy_name, tmp); +# else + len = strlen(tmp); + if (len > 0 && tmp[0] == '"' && tmp[len - 1] == '"') { + /* We are certainly on a pdftex like engine and the input file name did contain spaces inside. + Quotes where added around that file name. We prefer to remove the quotes to have a human readable name. + As of Fri Sep 19 14:00:01 UTC 2008, the file names containing quotes are not supported by pdfTeX + nor SyncTeX. */ + synctex_ctxt.flags.quoted = 1; /* we will have to add quotes around the file name in the log file. */ + strcpy(the_busy_name, tmp + 1); /* only copy what follows the leading " character */ + len = strlen(the_busy_name); + if ((len > 0) && (the_busy_name[len - 1] == '"')) { + the_busy_name[len - 1] = '\0'; + } + } else { + synctex_ctxt.flags.quoted = 0; + strcpy(the_busy_name, tmp); + } +# endif + SYNCTEX_FREE(tmp); + tmp = NULL; + strcat(the_busy_name, synctex_suffix); + /* Initialize SYNCTEX_NO_GZ with the content of \synctex to let the user choose the format. */ + if (SYNCTEX_VALUE < 0) { + SYNCTEX_NO_GZ = SYNCTEX_TRUE; + } else { + SYNCTEX_NO_GZ = SYNCTEX_NO; + } + if (!SYNCTEX_NO_GZ) { + strcat(the_busy_name, synctex_suffix_gz); + } + strcat(the_busy_name, synctex_suffix_busy); + if (SYNCTEX_NO_GZ) { + SYNCTEX_FILE = xfopen(the_busy_name, FOPEN_WBIN_MODE); + synctex_ctxt.fprintf = (synctex_fprintf_t) (&fprintf); + } else { + SYNCTEX_FILE = gzopen(the_busy_name, FOPEN_WBIN_MODE); + synctex_ctxt.fprintf = (synctex_fprintf_t) (&gzprintf); + } +# if SYNCTEX_DEBUG + printf("\nwarning: Synchronize DEBUG: synctex_dot_open 2\n"); +# endif + if (SYNCTEX_FILE) { + if (SYNCTEX_NO_ERROR != synctex_record_preamble()) { + synctexabort(0); + return NULL; + } + /* Initialization of the context */ + synctex_ctxt.magnification = 1000; + synctex_ctxt.unit = SYNCTEX_UNIT_FACTOR; + /* synctex_ctxt.busy_name was NULL before, it now owns the_busy_name */ + synctex_ctxt.busy_name = the_busy_name; + the_busy_name = NULL; + /* print the preamble, this is an quite an UTF8 file */ + if (NULL != synctex_ctxt.root_name) { + synctex_record_input(1, synctex_ctxt.root_name); + SYNCTEX_FREE(synctex_ctxt.root_name); + synctex_ctxt.root_name = NULL; + } + synctex_ctxt.count = 0; +# if SYNCTEX_DEBUG + fprintf(stdout, + "\nwarning: Synchronize DEBUG: synctex_dot_open SYNCTEX AVAILABLE\n"); +# endif + } else { + /* no .synctex file available, so disable synchronization */ + SYNCTEX_IS_OFF = SYNCTEX_TRUE; + SYNCTEX_VALUE = 0; + printf("\nSyncTeX warning: no synchronization, problem with %s\n", + the_busy_name); + /* and free the_busy_name */ + SYNCTEX_FREE(the_busy_name); + the_busy_name = NULL; +# if SYNCTEX_DEBUG + fprintf(stdout, + "\nwarning: Synchronize DEBUG: synctex_dot_open SYNCTEX DISABLED\n"); +# endif + } + } return SYNCTEX_FILE; } @@ -503,13 +512,13 @@ void synctexstartinput(void) { static unsigned int synctex_tag_counter = 0; - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nwarning: Synchronize DEBUG: synctexstartinput %i", - synctex_tag_counter); + synctex_tag_counter); printf("\nwarning: SYNCTEX_VALUE=%i", SYNCTEX_VALUE); printf("\nwarning: synctex_options=%0X", synctex_options); -#endif +# endif if (SYNCTEX_IS_OFF) { return; @@ -527,30 +536,31 @@ void synctexstartinput(void) curinput.synctextagfield = 0; return; } - curinput.synctextagfield = (int)synctex_tag_counter; /* -> *TeX.web */ + curinput.synctextagfield = (int) synctex_tag_counter; /* -> *TeX.web */ if (synctex_tag_counter == 1) { /* this is the first file TeX ever opens, in general \jobname.tex we * do not know yet if synchronization will ever be enabled so we have * to store the file name, because we will need it later. - * This is necessary because \jobname can be different */ + * This is necessary because \jobname can be different */ synctex_ctxt.root_name = gettexstring(curinput.namefield); - /* we could initialize the unit field to 1 to avoid floating point exception - * when accidentaly dividing by the unit. - * This occurs when some SYNCTEX_IGNORE macro is not used. - * But this must not happen unexpectedly, so we leave the unit to 0 */ -#if SYNCTEX_DEBUG + /* we could initialize the unit field to 1 to avoid floating point exception + * when accidentaly dividing by the unit. + * This occurs when some SYNCTEX_IGNORE macro is not used. + * But this must not happen unexpectedly, so we leave the unit to 0 */ +# if SYNCTEX_DEBUG printf("\nwarning: Synchronize DEBUG: synctexstartinput first END\n"); -# endif +# endif return; } - if (SYNCTEX_FILE || (SYNCTEX_VALUE && (SYNCTEX_NO_ERROR != synctex_dot_open()))) { + if (SYNCTEX_FILE + || (SYNCTEX_VALUE && (SYNCTEX_NO_ERROR != synctex_dot_open()))) { char *tmp = gettexstring(curinput.namefield); - synctex_record_input(curinput.synctextagfield,tmp); + synctex_record_input(curinput.synctextagfield, tmp); SYNCTEX_FREE(tmp); } -#if SYNCTEX_DEBUG +# if SYNCTEX_DEBUG printf("\nwarning: Synchronize DEBUG: synctexstartinput END\n"); -# endif +# endif return; } @@ -577,127 +587,135 @@ static inline int synctex_record_postamble(void); */ void synctexterminate(boolean log_opened) { - char *tmp = NULL; - char * the_real_syncname = NULL; - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + char *tmp = NULL; + char *the_real_syncname = NULL; + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexterminate\n"); -#endif - if(log_opened && (tmp = GETLOGNAME())) { - /* In version 1, the jobname was used but it caused problems regarding spaces in file names. */ - the_real_syncname = xmalloc((unsigned)(strlen(tmp) + strlen(synctex_suffix) + strlen(synctex_suffix_gz) + 1)); - if(!the_real_syncname) { - SYNCTEX_FREE(tmp); - synctexabort(0); - return; - } - strcpy(the_real_syncname, tmp); - SYNCTEX_FREE(tmp); - tmp = NULL; - /* now remove the last path extension which is in general log */ - tmp = the_real_syncname + strlen(the_real_syncname); - while(tmp>the_real_syncname) { - --tmp; - if(*tmp == '.') { - *tmp = '\0';/* end the string here */ - break; - } - } - strcat(the_real_syncname, synctex_suffix); - if (!SYNCTEX_NO_GZ) { - /* Remove any uncompressed synctex file, from a previous build. */ - remove(the_real_syncname); - strcat(the_real_syncname, synctex_suffix_gz); - } - /* allways remove the synctex output file before renaming it, windows requires it. */ - if(0 != remove(the_real_syncname) && errno == EACCES) { - fprintf(stderr,"SyncTeX: Can't remove %s (file is open or read only)\n",the_real_syncname); - } - if (SYNCTEX_FILE) { - if (SYNCTEX_NOT_VOID) { - synctex_record_postamble(); - /* close the synctex file*/ - if (SYNCTEX_NO_GZ) { - xfclose((FILE *)SYNCTEX_FILE, synctex_ctxt.busy_name); - } else { - gzclose((gzFile)SYNCTEX_FILE); - } - SYNCTEX_FILE = NULL; - /* renaming the working synctex file */ - if(0 == rename(synctex_ctxt.busy_name,the_real_syncname)) { - if(log_opened) { - printf((synctex_ctxt.flags.quoted?"\nSyncTeX written on \"%s\"":"\nSyncTeX written on %s"), - the_real_syncname); /* SyncTeX also refers to the contents */ - } - } else { - fprintf(stderr,"SyncTeX: Can't rename %s to %s\n",synctex_ctxt.busy_name,the_real_syncname); - remove(synctex_ctxt.busy_name); - } - } else { - /* close and remove the synctex file because there are no pages of output */ - if (SYNCTEX_NO_GZ) { - xfclose((FILE *)SYNCTEX_FILE, synctex_ctxt.busy_name); - } else { - gzclose((gzFile)SYNCTEX_FILE); - } - SYNCTEX_FILE = NULL; - remove(synctex_ctxt.busy_name); - } - } - if (SYNCTEX_NO_GZ) { - /* Remove any compressed synctex file, from a previous build. */ - strcat(the_real_syncname, synctex_suffix_gz); - remove(the_real_syncname); - } - } else if((tmp = GETJOBNAME())) { - size_t len; - /* There was a problem with the output. - We just try to remove existing synctex output files - including the busy one. */ - the_real_syncname = xmalloc((unsigned)(strlen(tmp) + strlen(synctex_suffix) + strlen(synctex_suffix_gz) + 1)); - if(!the_real_syncname) { - SYNCTEX_FREE(tmp); - synctexabort(0); - return; - } -# if defined(XeTeX) - strcpy(the_real_syncname, tmp); -# else - len = strlen(tmp); - if(len>0 && tmp[0]=='"' && tmp[len-1]=='"') { - /* See above a similar situation. */ - strcpy(the_real_syncname, tmp+1);/* only copy what follows the leading " character */ - len = strlen(the_real_syncname); - if((len>0) && (the_real_syncname[len-1]=='"')) { - the_real_syncname[len-1]='\0'; - } - } else { - strcpy(the_real_syncname, tmp); - } -# endif - SYNCTEX_FREE(tmp); - tmp = NULL; - strcat(the_real_syncname, synctex_suffix); - remove(the_real_syncname); - strcat(the_real_syncname, synctex_suffix_gz); - remove(the_real_syncname); - if (SYNCTEX_FILE) { - /* close the synctex file*/ - if (SYNCTEX_NO_GZ) { - xfclose((FILE *)SYNCTEX_FILE, synctex_ctxt.busy_name); - } else { - gzclose((gzFile)SYNCTEX_FILE); - } - SYNCTEX_FILE = NULL; - /* removing the working synctex file */ - remove(synctex_ctxt.busy_name); - } - } - SYNCTEX_FREE(synctex_ctxt.busy_name); - synctex_ctxt.busy_name = NULL; - SYNCTEX_FREE(the_real_syncname); - the_real_syncname = NULL; - synctexabort(0); +# endif + if (log_opened && (tmp = GETLOGNAME())) { + /* In version 1, the jobname was used but it caused problems regarding spaces in file names. */ + the_real_syncname = + xmalloc((unsigned) + (strlen(tmp) + strlen(synctex_suffix) + + strlen(synctex_suffix_gz) + 1)); + if (!the_real_syncname) { + SYNCTEX_FREE(tmp); + synctexabort(0); + return; + } + strcpy(the_real_syncname, tmp); + SYNCTEX_FREE(tmp); + tmp = NULL; + /* now remove the last path extension which is in general log */ + tmp = the_real_syncname + strlen(the_real_syncname); + while (tmp > the_real_syncname) { + --tmp; + if (*tmp == '.') { + *tmp = '\0'; /* end the string here */ + break; + } + } + strcat(the_real_syncname, synctex_suffix); + if (!SYNCTEX_NO_GZ) { + /* Remove any uncompressed synctex file, from a previous build. */ + remove(the_real_syncname); + strcat(the_real_syncname, synctex_suffix_gz); + } + /* allways remove the synctex output file before renaming it, windows requires it. */ + if (0 != remove(the_real_syncname) && errno == EACCES) { + fprintf(stderr, + "SyncTeX: Can't remove %s (file is open or read only)\n", + the_real_syncname); + } + if (SYNCTEX_FILE) { + if (SYNCTEX_NOT_VOID) { + synctex_record_postamble(); + /* close the synctex file */ + if (SYNCTEX_NO_GZ) { + xfclose((FILE *) SYNCTEX_FILE, synctex_ctxt.busy_name); + } else { + gzclose((gzFile) SYNCTEX_FILE); + } + SYNCTEX_FILE = NULL; + /* renaming the working synctex file */ + if (0 == rename(synctex_ctxt.busy_name, the_real_syncname)) { + if (log_opened) { + printf((synctex_ctxt.flags.quoted ? "\nSyncTeX written on \"%s\"" : "\nSyncTeX written on %s"), the_real_syncname); /* SyncTeX also refers to the contents */ + } + } else { + fprintf(stderr, "SyncTeX: Can't rename %s to %s\n", + synctex_ctxt.busy_name, the_real_syncname); + remove(synctex_ctxt.busy_name); + } + } else { + /* close and remove the synctex file because there are no pages of output */ + if (SYNCTEX_NO_GZ) { + xfclose((FILE *) SYNCTEX_FILE, synctex_ctxt.busy_name); + } else { + gzclose((gzFile) SYNCTEX_FILE); + } + SYNCTEX_FILE = NULL; + remove(synctex_ctxt.busy_name); + } + } + if (SYNCTEX_NO_GZ) { + /* Remove any compressed synctex file, from a previous build. */ + strcat(the_real_syncname, synctex_suffix_gz); + remove(the_real_syncname); + } + } else if ((tmp = GETJOBNAME())) { + size_t len; + /* There was a problem with the output. + We just try to remove existing synctex output files + including the busy one. */ + the_real_syncname = + xmalloc((unsigned) + (strlen(tmp) + strlen(synctex_suffix) + + strlen(synctex_suffix_gz) + 1)); + if (!the_real_syncname) { + SYNCTEX_FREE(tmp); + synctexabort(0); + return; + } +# if defined(XeTeX) + strcpy(the_real_syncname, tmp); +# else + len = strlen(tmp); + if (len > 0 && tmp[0] == '"' && tmp[len - 1] == '"') { + /* See above a similar situation. */ + strcpy(the_real_syncname, tmp + 1); /* only copy what follows the leading " character */ + len = strlen(the_real_syncname); + if ((len > 0) && (the_real_syncname[len - 1] == '"')) { + the_real_syncname[len - 1] = '\0'; + } + } else { + strcpy(the_real_syncname, tmp); + } +# endif + SYNCTEX_FREE(tmp); + tmp = NULL; + strcat(the_real_syncname, synctex_suffix); + remove(the_real_syncname); + strcat(the_real_syncname, synctex_suffix_gz); + remove(the_real_syncname); + if (SYNCTEX_FILE) { + /* close the synctex file */ + if (SYNCTEX_NO_GZ) { + xfclose((FILE *) SYNCTEX_FILE, synctex_ctxt.busy_name); + } else { + gzclose((gzFile) SYNCTEX_FILE); + } + SYNCTEX_FILE = NULL; + /* removing the working synctex file */ + remove(synctex_ctxt.busy_name); + } + } + SYNCTEX_FREE(synctex_ctxt.busy_name); + synctex_ctxt.busy_name = NULL; + SYNCTEX_FREE(the_real_syncname); + the_real_syncname = NULL; + synctexabort(0); } static inline int synctex_record_content(void); @@ -709,39 +727,41 @@ static inline int synctex_record_sheet(integer sheet); */ void synctexsheet(integer mag) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG - printf("\nSynchronize DEBUG: synctexsheet %i\n",mag); -#endif + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG + printf("\nSynchronize DEBUG: synctexsheet %i\n", mag); +# endif if (SYNCTEX_IS_OFF) { - if(SYNCTEX_VALUE && !SYNCTEX_WARNING_DISABLE) { - SYNCTEX_WARNING_DISABLE = SYNCTEX_TRUE; - printf("\nSyncTeX warning: Synchronization was disabled from\nthe command line with -synctex=0\nChanging the value of \\synctex has no effect."); - } + if (SYNCTEX_VALUE && !SYNCTEX_WARNING_DISABLE) { + SYNCTEX_WARNING_DISABLE = SYNCTEX_TRUE; + printf + ("\nSyncTeX warning: Synchronization was disabled from\nthe command line with -synctex=0\nChanging the value of \\synctex has no effect."); + } return; } - if (SYNCTEX_FILE || (SYNCTEX_VALUE && (SYNCTEX_NO_ERROR != synctex_dot_open()))) { + if (SYNCTEX_FILE + || (SYNCTEX_VALUE && (SYNCTEX_NO_ERROR != synctex_dot_open()))) { /* First possibility: the .synctex file is already open because SyncTeX was activated on the CLI - * or it was activated with the \synctex macro and the first page is already shipped out. - * Second possibility: tries to open the .synctex, useful if synchronization was enabled + * or it was activated with the \synctex macro and the first page is already shipped out. + * Second possibility: tries to open the .synctex, useful if synchronization was enabled * from the source file and not from the CLI. * totalpages is defined in tex.web */ if (totalpages == 0) { /* Now it is time to properly set up the scale factor. */ - if(mag>0) { + if (mag > 0) { synctex_ctxt.magnification = mag; } - if(SYNCTEX_NO_ERROR != synctex_record_settings() - || SYNCTEX_NO_ERROR != synctex_record_content()) { - synctexabort(0); - return; - } + if (SYNCTEX_NO_ERROR != synctex_record_settings() + || SYNCTEX_NO_ERROR != synctex_record_content()) { + synctexabort(0); + return; + } } - synctex_record_sheet(totalpages+1); + synctex_record_sheet(totalpages + 1); } -#if SYNCTEX_DEBUG +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexsheet END\n"); -#endif +# endif return; } @@ -752,17 +772,17 @@ static inline int synctex_record_teehs(integer sheet); */ void synctexteehs(void) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexteehs\n"); -#endif - if (SYNCTEX_IS_OFF || !SYNCTEX_FILE ) { +# endif + if (SYNCTEX_IS_OFF || !SYNCTEX_FILE) { return; } - synctex_record_teehs(totalpages);/* not totalpages+1*/ -#if SYNCTEX_DEBUG + synctex_record_teehs(totalpages); /* not totalpages+1 */ +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexteehs END\n"); -#endif +# endif return; } @@ -774,19 +794,19 @@ static inline void synctex_record_vlist(halfword p); * address of the vlist We assume that p is really a vlist node! */ void synctexvlist(halfword this_box) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexhlist\n"); -#endif +# endif if (SYNCTEX_IGNORE(this_box)) { return; } - synctex_ctxt.node = this_box; /* 0 to reset */ - synctex_ctxt.recorder = NULL; /* reset */ - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(this_box,box_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(this_box,box_node_size); - synctex_ctxt.curh = CURH; - synctex_ctxt.curv = CURV; + synctex_ctxt.node = this_box; /* 0 to reset */ + synctex_ctxt.recorder = NULL; /* reset */ + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(this_box, box_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(this_box, box_node_size); + synctex_ctxt.curh = CURH; + synctex_ctxt.curv = CURV; synctex_record_vlist(this_box); } @@ -798,19 +818,19 @@ static inline void synctex_record_tsilv(halfword p); * synctex_vlist sent at the beginning of that procedure. */ void synctextsilv(halfword this_box) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctextsilv\n"); -#endif +# endif if (SYNCTEX_IGNORE(this_box)) { return; } /* Ignoring any pending info to be recorded */ - synctex_ctxt.node = this_box; /* 0 to reset */ - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(this_box,box_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(this_box,box_node_size); - synctex_ctxt.curh = CURH; - synctex_ctxt.curv = CURV; + synctex_ctxt.node = this_box; /* 0 to reset */ + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(this_box, box_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(this_box, box_node_size); + synctex_ctxt.curh = CURH; + synctex_ctxt.curv = CURV; synctex_ctxt.recorder = NULL; synctex_record_tsilv(this_box); } @@ -819,21 +839,21 @@ static inline void synctex_record_void_vlist(halfword p); /* This message is sent when a void vlist will be shipped out. * There is no need to balance a void vlist. */ -void synctexvoidvlist(halfword p, halfword this_box __attribute__((unused))) +void synctexvoidvlist(halfword p, halfword this_box __attribute__ ((unused))) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexvoidvlist\n"); -#endif +# endif if (SYNCTEX_IGNORE(p)) { return; } - synctex_ctxt.node = p; /* reset */ - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p,box_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(p,box_node_size); - synctex_ctxt.curh = CURH; - synctex_ctxt.curv = CURV; - synctex_ctxt.recorder = NULL; /* reset */ + synctex_ctxt.node = p; /* reset */ + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p, box_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(p, box_node_size); + synctex_ctxt.curh = CURH; + synctex_ctxt.curv = CURV; + synctex_ctxt.recorder = NULL; /* reset */ synctex_record_void_vlist(p); } @@ -845,19 +865,19 @@ static inline void synctex_record_hlist(halfword p); * address of the hlist We assume that p is really an hlist node! */ void synctexhlist(halfword this_box) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexhlist\n"); -#endif +# endif if (SYNCTEX_IGNORE(this_box)) { return; } - synctex_ctxt.node = this_box; /* 0 to reset */ - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(this_box,box_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(this_box,box_node_size); - synctex_ctxt.curh = CURH; - synctex_ctxt.curv = CURV; - synctex_ctxt.recorder = NULL; /* reset */ + synctex_ctxt.node = this_box; /* 0 to reset */ + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(this_box, box_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(this_box, box_node_size); + synctex_ctxt.curh = CURH; + synctex_ctxt.curv = CURV; + synctex_ctxt.recorder = NULL; /* reset */ synctex_record_hlist(this_box); } @@ -869,20 +889,20 @@ static inline void synctex_record_tsilh(halfword p); * synctex_hlist sent at the beginning of that procedure. */ void synctextsilh(halfword this_box) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctextsilh\n"); -#endif +# endif if (SYNCTEX_IGNORE(this_box)) { return; } /* Ignoring any pending info to be recorded */ - synctex_ctxt.node = this_box; /* 0 to force next node to be recorded! */ - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(this_box,box_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(this_box,box_node_size); - synctex_ctxt.curh = CURH; - synctex_ctxt.curv = CURV; - synctex_ctxt.recorder = NULL; /* reset */ + synctex_ctxt.node = this_box; /* 0 to force next node to be recorded! */ + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(this_box, box_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(this_box, box_node_size); + synctex_ctxt.curh = CURH; + synctex_ctxt.curv = CURV; + synctex_ctxt.recorder = NULL; /* reset */ synctex_record_tsilh(this_box); } @@ -890,39 +910,39 @@ static inline void synctex_record_void_hlist(halfword p); /* This message is sent when a void hlist will be shipped out. * There is no need to balance a void hlist. */ -void synctexvoidhlist(halfword p, halfword this_box __attribute__((unused))) +void synctexvoidhlist(halfword p, halfword this_box __attribute__ ((unused))) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexvoidhlist\n"); -#endif +# endif if (SYNCTEX_IGNORE(p)) { return; } - /* the sync context has changed */ - if (synctex_ctxt.recorder != NULL) { - /* but was not yet recorded */ - (*synctex_ctxt.recorder) (synctex_ctxt.node); - } - synctex_ctxt.node = p; /* 0 to reset */ - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p,box_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(p,box_node_size); - synctex_ctxt.curh = CURH; - synctex_ctxt.curv = CURV; - synctex_ctxt.recorder = NULL; /* reset */ + /* the sync context has changed */ + if (synctex_ctxt.recorder != NULL) { + /* but was not yet recorded */ + (*synctex_ctxt.recorder) (synctex_ctxt.node); + } + synctex_ctxt.node = p; /* 0 to reset */ + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p, box_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(p, box_node_size); + synctex_ctxt.curh = CURH; + synctex_ctxt.curv = CURV; + synctex_ctxt.recorder = NULL; /* reset */ synctex_record_void_hlist(p); } /* glue code: these only work with nodes of size medium_node_size */ -# define small_node_size 3 +# define small_node_size 3 /* see: @d small_node_size=2 {number of words to allocate for most node types} */ -# define medium_node_size (small_node_size+synchronization_field_size) +# define medium_node_size (small_node_size+synchronization_field_size) /* see: @d rule_node_size=4 */ /* # define rule_node_size (4+synchronization_field_size) */ /* IN THE SEQUEL, ALL NODE ARE medium_node_size'd, UNTIL THE CONTRARY IS MENTIONNED */ -# undef SYNCTEX_IGNORE -# define SYNCTEX_IGNORE(NODE) SYNCTEX_IS_OFF || !SYNCTEX_VALUE \ +# undef SYNCTEX_IGNORE +# define SYNCTEX_IGNORE(NODE) SYNCTEX_IS_OFF || !SYNCTEX_VALUE \ || (0 >= SYNCTEX_TAG_MODEL(NODE,medium_node_size)) \ || (0 >= SYNCTEX_LINE_MODEL(NODE,medium_node_size)) @@ -930,7 +950,7 @@ void synctexvoidhlist(halfword p, halfword this_box __attribute__((unused))) * the synchronization context remains the same, there is no need to write * synchronization info: it would not help more. The synchronization context * has changed when either the line number or the file tag has changed. */ -# define SYNCTEX_CONTEXT_DID_CHANGE(NODE) ((0 == synctex_ctxt.node)\ +# define SYNCTEX_CONTEXT_DID_CHANGE(NODE) ((0 == synctex_ctxt.node)\ || (SYNCTEX_TAG_MODEL(NODE,medium_node_size) != synctex_ctxt.tag)\ || (SYNCTEX_LINE_MODEL(NODE,medium_node_size) != synctex_ctxt.line)) @@ -938,12 +958,12 @@ void synctex_math_recorder(halfword p); /* glue code this message is sent whenever an inline math node will ship out See: @ @<Output the non-|char_node| |p| for... */ -void synctexmath(halfword p, halfword this_box __attribute__((unused))) +void synctexmath(halfword p, halfword this_box __attribute__ ((unused))) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexmath\n"); -#endif +# endif if (SYNCTEX_IGNORE(p)) { return; } @@ -952,12 +972,12 @@ void synctexmath(halfword p, halfword this_box __attribute__((unused))) (*synctex_ctxt.recorder) (synctex_ctxt.node); } synctex_ctxt.node = p; - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p,medium_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(p,medium_node_size); - synctex_ctxt.curh = CURH; - synctex_ctxt.curv = CURV; - synctex_ctxt.recorder = NULL;/* no need to record once more */ - synctex_math_recorder(p);/* always record synchronously */ + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p, medium_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(p, medium_node_size); + synctex_ctxt.curh = CURH; + synctex_ctxt.curv = CURV; + synctex_ctxt.recorder = NULL; /* no need to record once more */ + synctex_math_recorder(p); /* always record synchronously */ } static inline void synctex_record_glue(halfword p); @@ -966,48 +986,48 @@ static inline void synctex_record_rule(halfword p); /* this message is sent whenever an horizontal glue node or rule node ships out See: move_past:... */ -# define SYNCTEX_IGNORE_RULE(NODE) SYNCTEX_IS_OFF || !SYNCTEX_VALUE \ +# define SYNCTEX_IGNORE_RULE(NODE) SYNCTEX_IS_OFF || !SYNCTEX_VALUE \ || (0 >= SYNCTEX_TAG_MODEL(NODE,rule_node_size)) \ || (0 >= SYNCTEX_LINE_MODEL(NODE,rule_node_size)) -void synctexhorizontalruleorglue(halfword p, halfword this_box __attribute__((unused))) +void synctexhorizontalruleorglue(halfword p, halfword this_box + __attribute__ ((unused))) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexglue\n"); -#endif - if (SYNCTEX_TYPE(p) == rule_node) { /* not medium_node_size so we can't use SYNCTEX_IGNORE */ - if (SYNCTEX_IGNORE_RULE(p)) { - return; - } - } - else { - if (SYNCTEX_IGNORE(p)) { - return; - } - } - synctex_ctxt.node = p; - synctex_ctxt.curh = CURH; - synctex_ctxt.curv = CURV; - synctex_ctxt.recorder = NULL; - switch(SYNCTEX_TYPE(p)) { - case rule_node: - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p,rule_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(p,rule_node_size); - synctex_record_rule(p);/* always record synchronously: maybe some text is outside the box */ - break; - case glue_node: - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p,medium_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(p,medium_node_size); - synctex_record_glue(p);/* always record synchronously: maybe some text is outside the box */ - break; - case kern_node: - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p,medium_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(p,medium_node_size); - synctex_record_kern(p);/* always record synchronously: maybe some text is outside the box */ - break; - default: - printf("\nSynchronize ERROR: unknown node type %i\n",SYNCTEX_TYPE(p)); - } +# endif + if (SYNCTEX_TYPE(p) == rule_node) { /* not medium_node_size so we can't use SYNCTEX_IGNORE */ + if (SYNCTEX_IGNORE_RULE(p)) { + return; + } + } else { + if (SYNCTEX_IGNORE(p)) { + return; + } + } + synctex_ctxt.node = p; + synctex_ctxt.curh = CURH; + synctex_ctxt.curv = CURV; + synctex_ctxt.recorder = NULL; + switch (SYNCTEX_TYPE(p)) { + case rule_node: + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p, rule_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(p, rule_node_size); + synctex_record_rule(p); /* always record synchronously: maybe some text is outside the box */ + break; + case glue_node: + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p, medium_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(p, medium_node_size); + synctex_record_glue(p); /* always record synchronously: maybe some text is outside the box */ + break; + case kern_node: + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p, medium_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(p, medium_node_size); + synctex_record_kern(p); /* always record synchronously: maybe some text is outside the box */ + break; + default: + printf("\nSynchronize ERROR: unknown node type %i\n", SYNCTEX_TYPE(p)); + } } void synctex_kern_recorder(halfword p); @@ -1016,10 +1036,10 @@ void synctex_kern_recorder(halfword p); See: @ @<Output the non-|char_node| |p| for... */ void synctexkern(halfword p, halfword this_box) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexkern\n"); -#endif +# endif if (SYNCTEX_IGNORE(p)) { return; } @@ -1028,46 +1048,46 @@ void synctexkern(halfword p, halfword this_box) if (synctex_ctxt.recorder != NULL) { /* but was not yet recorded */ (*synctex_ctxt.recorder) (synctex_ctxt.node); - } - if(synctex_ctxt.node == this_box) { + } + if (synctex_ctxt.node == this_box) { /* first node in the list */ synctex_ctxt.node = p; - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p,medium_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(p,medium_node_size); + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p, medium_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(p, medium_node_size); synctex_ctxt.recorder = &synctex_kern_recorder; } else { synctex_ctxt.node = p; - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p,medium_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(p,medium_node_size); + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p, medium_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(p, medium_node_size); synctex_ctxt.recorder = NULL; /* always record when the context has just changed * and when not the first node */ synctex_kern_recorder(p); } } else { - /* just update the geometry and type (for future improvements) */ + /* just update the geometry and type (for future improvements) */ synctex_ctxt.node = p; - synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p,medium_node_size); - synctex_ctxt.line = SYNCTEX_LINE_MODEL(p,medium_node_size); + synctex_ctxt.tag = SYNCTEX_TAG_MODEL(p, medium_node_size); + synctex_ctxt.line = SYNCTEX_LINE_MODEL(p, medium_node_size); synctex_ctxt.recorder = &synctex_kern_recorder; } } /* This last part is used as a tool to infer TeX behaviour, * but not for direct synchronization. */ -# undef SYNCTEX_IGNORE -# define SYNCTEX_IGNORE(NODE) SYNCTEX_IS_OFF || !SYNCTEX_VALUE || !SYNCTEX_FILE \ +# undef SYNCTEX_IGNORE +# define SYNCTEX_IGNORE(NODE) SYNCTEX_IS_OFF || !SYNCTEX_VALUE || !SYNCTEX_FILE \ || (synctex_ctxt.count>2000) void synctex_char_recorder(halfword p); /* this message is sent whenever a char node ships out */ -void synctexchar(halfword p, halfword this_box __attribute__((unused))) +void synctexchar(halfword p, halfword this_box __attribute__ ((unused))) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexchar\n"); -#endif +# endif if (SYNCTEX_IGNORE(p)) { return; } @@ -1085,18 +1105,18 @@ void synctexchar(halfword p, halfword this_box __attribute__((unused))) void synctex_node_recorder(halfword p); -# undef SYNCTEX_IGNORE -# define SYNCTEX_IGNORE(NODE) (SYNCTEX_IS_OFF || !SYNCTEX_VALUE || !SYNCTEX_FILE) +# undef SYNCTEX_IGNORE +# define SYNCTEX_IGNORE(NODE) (SYNCTEX_IS_OFF || !SYNCTEX_VALUE || !SYNCTEX_FILE) /* this message should be sent to record information for a node of an unknown type */ -void synctexnode(halfword p, halfword this_box __attribute__((unused))) +void synctexnode(halfword p, halfword this_box __attribute__ ((unused))) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexnode\n"); -#endif - if (SYNCTEX_IGNORE(p)) { +# endif + if (SYNCTEX_IGNORE(p)) { return; } /* always record, not very usefull yet */ @@ -1107,464 +1127,463 @@ void synctexnode(halfword p, halfword this_box __attribute__((unused))) synchronously for the current location */ void synctexcurrent(void) { - SYNCTEX_RETURN_IF_DISABLED; -#if SYNCTEX_DEBUG + SYNCTEX_RETURN_IF_DISABLED; +# if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexcurrent\n"); -#endif - if (SYNCTEX_IGNORE(nothing)) { +# endif + if (SYNCTEX_IGNORE(nothing)) { return; } else { - integer len = SYNCTEX_fprintf(SYNCTEX_FILE,"x%i,%i:%i,%i\n", - synctex_ctxt.tag,synctex_ctxt.line, - CURH UNIT,CURV UNIT); - if(len>0) { - synctex_ctxt.total_length += len; - return; - } - } + integer len = SYNCTEX_fprintf(SYNCTEX_FILE, "x%i,%i:%i,%i\n", + synctex_ctxt.tag, synctex_ctxt.line, + CURH UNIT, CURV UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; + return; + } + } synctexabort(0); - return; + return; } -#pragma mark - -#pragma mark Glue code Recorders +# pragma mark - +# pragma mark Glue code Recorders /* Recording the settings */ static inline int synctex_record_settings(void) { -#if SYNCTEX_DEBUG > 999 +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_settings\n"); -#endif - if(NULL == SYNCTEX_FILE) { +# endif + if (NULL == SYNCTEX_FILE) { return SYNCTEX_NOERR; } - if(SYNCTEX_FILE) { - integer len = SYNCTEX_fprintf(SYNCTEX_FILE,"Output:%s\nMagnification:%i\nUnit:%i\nX Offset:%i\nY Offset:%i\n", - SYNCTEX_OUTPUT,synctex_ctxt.magnification,synctex_ctxt.unit, - ((SYNCTEX_OFFSET_IS_PDF != 0) ? 0 : 4736287 UNIT), - ((SYNCTEX_OFFSET_IS_PDF != 0) ? 0 : 4736287 UNIT)); - if(len>0) { - synctex_ctxt.total_length += len; - return SYNCTEX_NOERR; - } - } - synctexabort(0); - return -1; + if (SYNCTEX_FILE) { + integer len = + SYNCTEX_fprintf(SYNCTEX_FILE, + "Output:%s\nMagnification:%i\nUnit:%i\nX Offset:%i\nY Offset:%i\n", + SYNCTEX_OUTPUT, synctex_ctxt.magnification, + synctex_ctxt.unit, + ((SYNCTEX_OFFSET_IS_PDF != 0) ? 0 : 4736287 UNIT), + ((SYNCTEX_OFFSET_IS_PDF != 0) ? 0 : 4736287 UNIT)); + if (len > 0) { + synctex_ctxt.total_length += len; + return SYNCTEX_NOERR; + } + } + synctexabort(0); + return -1; } /* Recording a "SyncTeX..." line */ static inline int synctex_record_preamble(void) { - integer len = 0; -#if SYNCTEX_DEBUG > 999 + integer len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_preamble\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"SyncTeX Version:%i\n",SYNCTEX_VERSION); - if(len>0) { - synctex_ctxt.total_length = len; - return SYNCTEX_NOERR; - } +# endif + len = + SYNCTEX_fprintf(SYNCTEX_FILE, "SyncTeX Version:%i\n", SYNCTEX_VERSION); + if (len > 0) { + synctex_ctxt.total_length = len; + return SYNCTEX_NOERR; + } synctexabort(0); - return -1; + return -1; } /* Recording a "Input:..." line */ static inline int synctex_record_input(integer tag, char *name) { - integer len = 0; -#if SYNCTEX_DEBUG > 999 + integer len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_input\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"Input:%i:%s\n",tag,name); - if(len>0) { - synctex_ctxt.total_length += len; - return SYNCTEX_NOERR; - } - synctexabort(0); - return -1; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "Input:%i:%s\n", tag, name); + if (len > 0) { + synctex_ctxt.total_length += len; + return SYNCTEX_NOERR; + } + synctexabort(0); + return -1; } /* Recording a "!..." line */ static inline int synctex_record_anchor(void) { - integer len = 0; -#if SYNCTEX_DEBUG > 999 + integer len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_anchor\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"!%i\n",synctex_ctxt.total_length); - if(len>0) { - synctex_ctxt.total_length = len; - ++synctex_ctxt.count; - return SYNCTEX_NOERR; - } - synctexabort(0); - return -1; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "!%i\n", synctex_ctxt.total_length); + if (len > 0) { + synctex_ctxt.total_length = len; + ++synctex_ctxt.count; + return SYNCTEX_NOERR; + } + synctexabort(0); + return -1; } /* Recording a "Content" line */ static inline int synctex_record_content(void) { - integer len = 0; -#if SYNCTEX_DEBUG > 999 + integer len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_content\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"Content:\n"); - if(len>0) { - synctex_ctxt.total_length += len; - return SYNCTEX_NOERR; - } - synctexabort(0); - return -1; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "Content:\n"); + if (len > 0) { + synctex_ctxt.total_length += len; + return SYNCTEX_NOERR; + } + synctexabort(0); + return -1; } /* Recording a "{..." line */ static inline int synctex_record_sheet(integer sheet) { -#if SYNCTEX_DEBUG > 999 +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_sheet\n"); -#endif - if(SYNCTEX_NOERR == synctex_record_anchor()) { - integer len = SYNCTEX_fprintf(SYNCTEX_FILE,"{%i\n",sheet); - if(len>0) { - synctex_ctxt.total_length += len; - ++synctex_ctxt.count; - return SYNCTEX_NOERR; - } - } - synctexabort(0); - return -1; +# endif + if (SYNCTEX_NOERR == synctex_record_anchor()) { + integer len = SYNCTEX_fprintf(SYNCTEX_FILE, "{%i\n", sheet); + if (len > 0) { + synctex_ctxt.total_length += len; + ++synctex_ctxt.count; + return SYNCTEX_NOERR; + } + } + synctexabort(0); + return -1; } /* Recording a "}..." line */ static inline int synctex_record_teehs(integer sheet) { -#if SYNCTEX_DEBUG > 999 +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_teehs\n"); -#endif - if(SYNCTEX_NOERR == synctex_record_anchor()) { - integer len = SYNCTEX_fprintf(SYNCTEX_FILE,"}%i\n",sheet); - if(len>0) { - synctex_ctxt.total_length += len; - ++synctex_ctxt.count; - return SYNCTEX_NOERR; - } - } - synctexabort(0); - return -1; +# endif + if (SYNCTEX_NOERR == synctex_record_anchor()) { + integer len = SYNCTEX_fprintf(SYNCTEX_FILE, "}%i\n", sheet); + if (len > 0) { + synctex_ctxt.total_length += len; + ++synctex_ctxt.count; + return SYNCTEX_NOERR; + } + } + synctexabort(0); + return -1; } /* Recording a "v..." line */ static inline void synctex_record_void_vlist(halfword p) { - integer len = 0; -#if SYNCTEX_DEBUG > 999 + integer len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_void_vlist\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"v%i,%i:%i,%i:%i,%i,%i\n", - SYNCTEX_TAG_MODEL(p,box_node_size), - SYNCTEX_LINE_MODEL(p,box_node_size), - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, - SYNCTEX_WIDTH(p) UNIT, - SYNCTEX_HEIGHT(p) UNIT, - SYNCTEX_DEPTH(p) UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "v%i,%i:%i,%i:%i,%i,%i\n", + SYNCTEX_TAG_MODEL(p, box_node_size), + SYNCTEX_LINE_MODEL(p, box_node_size), + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, + SYNCTEX_WIDTH(p) UNIT, + SYNCTEX_HEIGHT(p) UNIT, SYNCTEX_DEPTH(p) UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a "[..." line */ static inline void synctex_record_vlist(halfword p) { - integer len = 0; - SYNCTEX_NOT_VOID = SYNCTEX_TRUE; -#if SYNCTEX_DEBUG > 999 + integer len = 0; + SYNCTEX_NOT_VOID = SYNCTEX_TRUE; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_vlist\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"[%i,%i:%i,%i:%i,%i,%i\n", - SYNCTEX_TAG_MODEL(p,box_node_size), - SYNCTEX_LINE_MODEL(p,box_node_size), - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, - SYNCTEX_WIDTH(p) UNIT, - SYNCTEX_HEIGHT(p) UNIT, - SYNCTEX_DEPTH(p) UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "[%i,%i:%i,%i:%i,%i,%i\n", + SYNCTEX_TAG_MODEL(p, box_node_size), + SYNCTEX_LINE_MODEL(p, box_node_size), + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, + SYNCTEX_WIDTH(p) UNIT, + SYNCTEX_HEIGHT(p) UNIT, SYNCTEX_DEPTH(p) UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a "]..." line */ -static inline void synctex_record_tsilv(halfword p __attribute__((unused))) +static inline void synctex_record_tsilv(halfword p __attribute__ ((unused))) { - integer len = 0; -#if SYNCTEX_DEBUG > 999 + integer len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_tsilv\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"]\n"); - if(len>0) { - synctex_ctxt.total_length += len; - return; - } - synctexabort(0); - return; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "]\n"); + if (len > 0) { + synctex_ctxt.total_length += len; + return; + } + synctexabort(0); + return; } /* Recording a "h..." line */ static inline void synctex_record_void_hlist(halfword p) { - integer len = 0; -#if SYNCTEX_DEBUG > 999 + integer len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_void_hlist\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"h%i,%i:%i,%i:%i,%i,%i\n", - SYNCTEX_TAG_MODEL(p,box_node_size), - SYNCTEX_LINE_MODEL(p,box_node_size), - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, - SYNCTEX_WIDTH(p) UNIT, - SYNCTEX_HEIGHT(p) UNIT, - SYNCTEX_DEPTH(p) UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "h%i,%i:%i,%i:%i,%i,%i\n", + SYNCTEX_TAG_MODEL(p, box_node_size), + SYNCTEX_LINE_MODEL(p, box_node_size), + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, + SYNCTEX_WIDTH(p) UNIT, + SYNCTEX_HEIGHT(p) UNIT, SYNCTEX_DEPTH(p) UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a "(..." line */ static inline void synctex_record_hlist(halfword p) { - integer len = 0; - SYNCTEX_NOT_VOID = SYNCTEX_TRUE; -#if SYNCTEX_DEBUG > 999 + integer len = 0; + SYNCTEX_NOT_VOID = SYNCTEX_TRUE; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_hlist\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"(%i,%i:%i,%i:%i,%i,%i\n", - SYNCTEX_TAG_MODEL(p,box_node_size), - SYNCTEX_LINE_MODEL(p,box_node_size), - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, - SYNCTEX_WIDTH(p) UNIT, - SYNCTEX_HEIGHT(p) UNIT, - SYNCTEX_DEPTH(p) UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "(%i,%i:%i,%i:%i,%i,%i\n", + SYNCTEX_TAG_MODEL(p, box_node_size), + SYNCTEX_LINE_MODEL(p, box_node_size), + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, + SYNCTEX_WIDTH(p) UNIT, + SYNCTEX_HEIGHT(p) UNIT, SYNCTEX_DEPTH(p) UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a ")..." line */ -static inline void synctex_record_tsilh(halfword p __attribute__((unused))) +static inline void synctex_record_tsilh(halfword p __attribute__ ((unused))) { - integer len = 0; -#if SYNCTEX_DEBUG > 999 + integer len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_tsilh\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,")\n"); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, ")\n"); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a "Count..." line */ -static inline int synctex_record_count(void) { - integer len = 0; -#if SYNCTEX_DEBUG > 999 +static inline int synctex_record_count(void) +{ + integer len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_count\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"Count:%i\n",synctex_ctxt.count); - if(len>0) { - synctex_ctxt.total_length += len; - return SYNCTEX_NOERR; - } - synctexabort(0); - return -1; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "Count:%i\n", synctex_ctxt.count); + if (len > 0) { + synctex_ctxt.total_length += len; + return SYNCTEX_NOERR; + } + synctexabort(0); + return -1; } /* Recording a "Postamble" section */ static inline int synctex_record_postamble(void) { -#if SYNCTEX_DEBUG > 999 +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_postamble\n"); -#endif - if(SYNCTEX_NOERR == synctex_record_anchor()) { - integer len = SYNCTEX_fprintf(SYNCTEX_FILE,"Postamble:\n"); - if(len>0) { - synctex_ctxt.total_length += len; - if(synctex_record_count() || synctex_record_anchor()) { - } else { - len = SYNCTEX_fprintf(SYNCTEX_FILE,"Post scriptum:\n"); - if(len>0) { - synctex_ctxt.total_length += len; - return SYNCTEX_NOERR; - } - } - } - } - synctexabort(0); - return -1; +# endif + if (SYNCTEX_NOERR == synctex_record_anchor()) { + integer len = SYNCTEX_fprintf(SYNCTEX_FILE, "Postamble:\n"); + if (len > 0) { + synctex_ctxt.total_length += len; + if (synctex_record_count() || synctex_record_anchor()) { + } else { + len = SYNCTEX_fprintf(SYNCTEX_FILE, "Post scriptum:\n"); + if (len > 0) { + synctex_ctxt.total_length += len; + return SYNCTEX_NOERR; + } + } + } + } + synctexabort(0); + return -1; } /* Recording a "g..." line */ static inline void synctex_record_glue(halfword p) { - integer len = 0; -#if SYNCTEX_DEBUG > 999 + integer len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_glue_recorder\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"g%i,%i:%i,%i\n", - SYNCTEX_TAG_MODEL(p,medium_node_size), - SYNCTEX_LINE_MODEL(p,medium_node_size), - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "g%i,%i:%i,%i\n", + SYNCTEX_TAG_MODEL(p, medium_node_size), + SYNCTEX_LINE_MODEL(p, medium_node_size), + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a "k..." line */ static inline void synctex_record_kern(halfword p) { - integer len = 0; -#if SYNCTEX_DEBUG > 999 + integer len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_kern_recorder\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"k%i,%i:%i,%i:%i\n", - SYNCTEX_TAG_MODEL(p,medium_node_size), - SYNCTEX_LINE_MODEL(p,medium_node_size), - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, - SYNCTEX_WIDTH(p) UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "k%i,%i:%i,%i:%i\n", + SYNCTEX_TAG_MODEL(p, medium_node_size), + SYNCTEX_LINE_MODEL(p, medium_node_size), + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, + SYNCTEX_WIDTH(p) UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a "r..." line */ static inline void synctex_record_rule(halfword p) { - integer len = 0; -#if SYNCTEX_DEBUG > 999 + integer len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_tsilh\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"r%i,%i:%i,%i:%i,%i,%i\n", - SYNCTEX_TAG_MODEL(p,rule_node_size), - SYNCTEX_LINE_MODEL(p,rule_node_size), - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, - rulewd UNIT, - ruleht UNIT, - ruledp UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "r%i,%i:%i,%i:%i,%i,%i\n", + SYNCTEX_TAG_MODEL(p, rule_node_size), + SYNCTEX_LINE_MODEL(p, rule_node_size), + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, + rulewd UNIT, ruleht UNIT, ruledp UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } -#pragma mark - -#pragma mark Recorders +# pragma mark - +# pragma mark Recorders /* Recording a "$..." line */ void synctex_math_recorder(halfword p) { - integer len = 0; -#if SYNCTEX_DEBUG > 999 + integer len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_math_recorder\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"$%i,%i:%i,%i\n", - SYNCTEX_TAG_MODEL(p,medium_node_size), - SYNCTEX_LINE_MODEL(p,medium_node_size), - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "$%i,%i:%i,%i\n", + SYNCTEX_TAG_MODEL(p, medium_node_size), + SYNCTEX_LINE_MODEL(p, medium_node_size), + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a "k..." line */ void synctex_kern_recorder(halfword p) { - integer len = 0; -#if SYNCTEX_DEBUG > 999 + integer len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_kern_recorder\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"k%i,%i:%i,%i:%i\n", - SYNCTEX_TAG_MODEL(p,medium_node_size), - SYNCTEX_LINE_MODEL(p,medium_node_size), - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, - SYNCTEX_WIDTH(p) UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "k%i,%i:%i,%i:%i\n", + SYNCTEX_TAG_MODEL(p, medium_node_size), + SYNCTEX_LINE_MODEL(p, medium_node_size), + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, + SYNCTEX_WIDTH(p) UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a "c..." line */ -void synctex_char_recorder(halfword p __attribute__((unused))) +void synctex_char_recorder(halfword p __attribute__ ((unused))) { - integer len = 0; -#if SYNCTEX_DEBUG > 999 + integer len = 0; +# if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_char_recorder\n"); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"c%i,%i\n", - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT); - if(len>0) { - synctex_ctxt.total_length += len; +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "c%i,%i\n", + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } /* Recording a "?..." line, type, subtype and position */ void synctex_node_recorder(halfword p) { - integer len = 0; -#if SYNCTEX_DEBUG > 999 - printf("\nSynchronize DEBUG: synctex_node_recorder(0x%x)\n",p); -#endif - len = SYNCTEX_fprintf(SYNCTEX_FILE,"?%i,%i:%i,%i\n", - synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, - type(p),subtype(p)); - if(len>0) { - synctex_ctxt.total_length += len; + integer len = 0; +# if SYNCTEX_DEBUG > 999 + printf("\nSynchronize DEBUG: synctex_node_recorder(0x%x)\n", p); +# endif + len = SYNCTEX_fprintf(SYNCTEX_FILE, "?%i,%i:%i,%i\n", + synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, + type(p), subtype(p)); + if (len > 0) { + synctex_ctxt.total_length += len; ++synctex_ctxt.count; - return; - } - synctexabort(0); - return; + return; + } + synctexabort(0); + return; } -# else -# warning "SyncTeX is disabled" -# endif +#else +# warning "SyncTeX is disabled" +#endif diff --git a/source/texk/web2c/luatexdir/utils/synctex.h b/source/texk/web2c/luatexdir/utils/synctex.h index 96e03c84cd99e433d04dcc3c026db233d694d68a..70d8b8058666c31362556bad8ac8d5be0f117d8a 100644 --- a/source/texk/web2c/luatexdir/utils/synctex.h +++ b/source/texk/web2c/luatexdir/utils/synctex.h @@ -40,10 +40,10 @@ Latest Revision: Wed Jul 1 08:17:50 UTC 2009 */ -# ifndef __SYNCTEX_HEADER__ -# define __SYNCTEX_HEADER__ +#ifndef __SYNCTEX_HEADER__ +# define __SYNCTEX_HEADER__ -#include "synctex-common.h" +# include "synctex-common.h" /* Free all memory used, close and remove the file if any. */ void synctexabort(boolean log_opened); @@ -110,4 +110,4 @@ extern void synctexnode(halfword p, halfword this_box); /* For debugging purpose only */ extern void synctexcurrent(void); -# endif +#endif diff --git a/source/texk/web2c/luatexdir/utils/utils.c b/source/texk/web2c/luatexdir/utils/utils.c index 5b416f39af7bb7b40b6dcc789137daf82c69c8d3..b3f5252d2e6cb4c9c57d9b59ba5cd4f8f2374644 100644 --- a/source/texk/web2c/luatexdir/utils/utils.c +++ b/source/texk/web2c/luatexdir/utils/utils.c @@ -38,7 +38,7 @@ #include "ptexlib.h" #include "md5.h" -#include "lua/luatex-api.h" /* for ptexbanner */ +#include "lua/luatex-api.h" /* for ptexbanner */ #include "png.h" #ifdef POPPLER_VERSION @@ -93,17 +93,18 @@ void make_subset_tag(fd_entry * fd) glw_glyph != NULL; glw_glyph = (glw_entry *) avl_t_next(&t)) { glyph = malloc(24); sprintf(glyph, "%05u%05u ", glw_glyph->id, glw_glyph->wd); - md5_append(&pms, (md5_byte_t *) glyph, (int)strlen(glyph)); + md5_append(&pms, (md5_byte_t *) glyph, (int) strlen(glyph)); free(glyph); } } else { for (glyph = (char *) avl_t_first(&t, fd->gl_tree); glyph != NULL; glyph = (char *) avl_t_next(&t)) { - md5_append(&pms, (md5_byte_t *) glyph, (int)strlen(glyph)); + md5_append(&pms, (md5_byte_t *) glyph, (int) strlen(glyph)); md5_append(&pms, (const md5_byte_t *) " ", 1); } } - md5_append(&pms, (md5_byte_t *) fd->fontname, (int)strlen(fd->fontname)); + md5_append(&pms, (md5_byte_t *) fd->fontname, + (int) strlen(fd->fontname)); md5_append(&pms, (md5_byte_t *) & j, sizeof(int)); /* to resolve collision */ md5_finish(&pms, digest); for (a[0] = 0, i = 0; i < 13; i++) @@ -111,7 +112,7 @@ void make_subset_tag(fd_entry * fd) for (i = 1; i < SUBSET_TAG_LENGTH; i++) a[i] = a[i - 1] - digest[i - 1] + digest[(i + 12) % 16]; for (i = 0; i < SUBSET_TAG_LENGTH; i++) - fd->subset_tag[i] = (char)(a[i] % 26 + 'A'); + fd->subset_tag[i] = (char) (a[i] % 26 + 'A'); fd->subset_tag[SUBSET_TAG_LENGTH] = '\0'; j++; assert(j < 100); @@ -207,9 +208,10 @@ void make_pdftex_banner(void) if (pdftex_banner != NULL) return; - slen = (unsigned int)(SMALL_BUF_SIZE + - strlen(ptexbanner) + - strlen(versionstring) + strlen(kpathsea_version_string)); + slen = (unsigned int) (SMALL_BUF_SIZE + + strlen(ptexbanner) + + strlen(versionstring) + + strlen(kpathsea_version_string)); s = xtalloc(slen, char); /* The Web2c version string starts with a space. */ i = snprintf(s, slen, @@ -342,11 +344,12 @@ void initversionstring(char **versions) void check_buffer_overflow(int wsize) { if (wsize > buf_size) { - int nsize = buf_size + buf_size / 5 + 5; + int nsize = buf_size + buf_size / 5 + 5; if (nsize < wsize) { nsize = wsize + 5; } - buffer = (unsigned char *) xreallocarray(buffer, char, (unsigned)nsize); + buffer = + (unsigned char *) xreallocarray(buffer, char, (unsigned) nsize); buf_size = nsize; } }