diff --git a/source/texk/web2c/luatexdir/font/luafont.w b/source/texk/web2c/luatexdir/font/luafont.w index fe623c243889e71c171988830c7a072a32091c00..2fc316e75b1260a42b7951f92b54390dbf44ff17 100644 --- a/source/texk/web2c/luatexdir/font/luafont.w +++ b/source/texk/web2c/luatexdir/font/luafont.w @@ -1137,9 +1137,8 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i, int *l_fonts, b set_charinfo_tag(co, ext_tag); set_charinfo_extensible(co, top, bot, mid, rep); } else { - luatex_warn - ("lua-loaded font %s char [U+%X] has an invalid extensible field!", - font_name(f), (int) i); + formatted_warning("font", "lua-loaded font %s char U+%X has an invalid extensible field", + font_name(f), (int) i); } } lua_pop(L, 1); @@ -1246,9 +1245,8 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i, int *l_fonts, b set_kern_item(ckerns[ctr], k, j); ctr++; } else { - luatex_warn - ("lua-loaded font %s char [U+%X] has an invalid kern field!", - font_name(f), (int) i); + formatted_warning("font", "lua-loaded font %s char U+%X has an invalid kern field", + font_name(f), (int) i); } lua_pop(L, 1); } @@ -1257,9 +1255,8 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i, int *l_fonts, b set_kern_item(ckerns[ctr], end_kern, 0); set_charinfo_kerns(co, ckerns); } else { - luatex_warn - ("lua-loaded font %s char [U+%X] has an invalid kerns field!", - font_name(f), (int) i); + formatted_warning("font", "lua-loaded font %s char U+%X has an invalid kerns field", + font_name(f), (int) i); } } lua_pop(L, 1); @@ -1312,9 +1309,8 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i, int *l_fonts, b set_ligature_item(cligs[ctr], (char) ((t * 2) + 1), k, r); ctr++; } else { - luatex_warn - ("lua-loaded font %s char [U+%X] has an invalid ligature field!", - font_name(f), (int) i); + formatted_warning("font", "lua-loaded font %s char U+%X has an invalid ligature field", + font_name(f), (int) i); } lua_pop(L, 1); /* iterator value */ } @@ -1323,9 +1319,8 @@ font_char_from_lua(lua_State * L, internal_font_number f, int i, int *l_fonts, b set_ligature_item(cligs[ctr], 0, end_ligature, 0); set_charinfo_ligatures(co, cligs); } else { - luatex_warn - ("lua-loaded font %s char [U+%X] has an invalid ligatures field!", - font_name(f), (int) i); + formatted_warning("font", "lua-loaded font %s char U+%X has an invalid ligatures field", + font_name(f), (int) i); } } lua_pop(L, 1); /* ligatures table */ @@ -1380,7 +1375,7 @@ int font_from_lua(lua_State * L, int f) set_font_fullname(f, s); if (s == NULL) { - luatex_fail("lua-loaded font [%d] has no name!", f); + formatted_error("font","lua-loaded font '%d' has no name!", f); return false; } s = n_string_field_copy(L, lua_key_index(psname), NULL); @@ -1476,14 +1471,14 @@ int font_from_lua(lua_State * L, int f) l_fonts[i] = find_font_id(ss, t); lua_settop(L, s_top); } else { - luatex_fail("Invalid local font in font %s!\n", font_name(f)); + formatted_error("font","invalid local font in lua-loaded font '%s'", font_name(f)); } lua_pop(L, 1); /* pop list entry */ } lua_pop(L, 1); /* pop list entry */ } else { if (font_type(f) == virtual_font_type) { - luatex_fail("Invalid local fonts in font %s!\n", font_name(f)); + formatted_error("font","invalid local fonts in lua-loaded font '%s'", font_name(f)); } else { l_fonts = xmalloc(3 * sizeof(int)); l_fonts[0] = 0; @@ -1594,7 +1589,7 @@ int font_from_lua(lua_State * L, int f) } else { /* jikes, no characters */ - luatex_warn("lua-loaded font [%d] (%s) has no characters!", f, font_name(f)); + formatted_warning("font","lua-loaded font '%d' with name '%s' has no characters", f, font_name(f)); } if (save_ref > 0) { @@ -1606,7 +1601,7 @@ int font_from_lua(lua_State * L, int f) } } else { /* jikes, no characters */ - luatex_warn("lua-loaded font [%d] (%s) has no character table!", f, font_name(f)); + formatted_warning("font","lua-loaded font '%d' with name '%s' has no character table", f, font_name(f)); } if (l_fonts != NULL) diff --git a/source/texk/web2c/luatexdir/font/mapfile.w b/source/texk/web2c/luatexdir/font/mapfile.w index 70abf22bf0d63b64b144976ff0f6f4fd284e3bf7..939468af4d89fb20f91957bdb755745afc3ad7a7 100644 --- a/source/texk/web2c/luatexdir/font/mapfile.w +++ b/source/texk/web2c/luatexdir/font/mapfile.w @@ -164,17 +164,13 @@ int avl_do_entry(fm_entry * fm, int mode) if (p != NULL) { switch (mode) { case FM_DUPIGNORE: - luatex_warn - ("fontmap entry for `%s' already exists, duplicates ignored", - fm->tfm_name); + formatted_warning("map file", "entry for '%s' already exists, duplicates ignored", fm->tfm_name); delete_new = 1; break; case FM_REPLACE: case FM_DELETE: if (is_inuse(p)) { - luatex_warn - ("fontmap entry for `%s' has been used, replace/delete not allowed", - fm->tfm_name); + formatted_warning("map file", "entry for '%s' has been used, replace/delete not allowed", fm->tfm_name); delete_new = 1; } else { a = avl_delete(tfm_tree, p); @@ -220,8 +216,8 @@ static int check_fm_entry(fm_entry * fm, boolean warn) if (is_fontfile(fm) && !is_included(fm)) { if (warn) - luatex_warn - ("ambiguous entry for `%s': font file present but not included, " + formatted_warning("map file", + "ambiguous entry for '%s': font file present but not included, " "will be treated as font file not present", fm->tfm_name); xfree(fm->ff_name); /* do not set variable |a| as this entry will be still accepted */ @@ -230,33 +226,27 @@ static int check_fm_entry(fm_entry * fm, boolean warn) /* if both ps_name and font file are missing, drop this entry */ if (fm->ps_name == NULL && !is_fontfile(fm)) { if (warn) - luatex_warn - ("invalid entry for `%s': both ps_name and font file missing", - fm->tfm_name); + formatted_warning("map file", "invalid entry for '%s': both ps_name and font file missing", fm->tfm_name); a += 1; } /* TrueType fonts cannot be reencoded without subsetting */ if (is_truetype(fm) && is_reencoded(fm) && !is_subsetted(fm)) { if (warn) - luatex_warn - ("invalid entry for `%s': only subsetted TrueType font can be reencoded", - fm->tfm_name); + formatted_warning("map file", "invalid entry for '%s': only subsetted TrueType font can be reencoded", fm->tfm_name); a += 2; } /* the value of SlantFont and ExtendFont must be reasonable */ if (fm->slant < FONT_SLANT_MIN || fm->slant > FONT_SLANT_MAX) { if (warn) - luatex_warn - ("invalid entry for `%s': too big value of SlantFont (%g)", + formatted_warning("map file", "invalid entry for '%s': value '%g' is to large for SlantFont", fm->tfm_name, fm->slant / 1000.0); a += 8; } if (fm->extend < FONT_EXTEND_MIN || fm->extend > FONT_EXTEND_MAX) { if (warn) - luatex_warn - ("invalid entry for `%s': too big value of ExtendFont (%g)", + formatted_warning("map file", "invalid entry for '%s': value '%g' is too large for ExtendFont", fm->tfm_name, fm->extend / 1000.0); a += 16; } @@ -265,8 +255,7 @@ static int check_fm_entry(fm_entry * fm, boolean warn) if (fm->pid != -1 && !(is_truetype(fm) && is_subsetted(fm) && !is_reencoded(fm))) { if (warn) - luatex_warn - ("invalid entry for `%s': PidEid can be used only with subsetted non-reencoded TrueType fonts", + formatted_warning("map file", "invalid entry for '%s': PidEid can be used only with subsetted non-reencoded TrueType fonts", fm->tfm_name); a += 32; } @@ -335,7 +324,7 @@ static void fm_scan_line(void) float d; fm_entry *fm; char fm_line[FM_BUF_SIZE], buf[FM_BUF_SIZE]; - char *p, *q, *s; + char *p, *q, *s; char *r = NULL; switch (mitem->type) { case MAPFILE: @@ -405,9 +394,7 @@ static void fm_scan_line(void) for (r = s; *r != ' ' && *r != '"' && *r != '\0'; r++); /* jump over name */ c = *r; /* remember char for temporary end of string */ *r = '\0'; - luatex_warn - ("invalid entry for `%s': unknown name `%s' ignored", - fm->tfm_name, s); + formatted_warning("map file", "invalid entry for '%s': unknown name '%s' ignored", fm->tfm_name, s); *r = (char) c; } } else @@ -417,9 +404,7 @@ static void fm_scan_line(void) if (*r == '"') /* closing quote */ r++; else { - luatex_warn - ("invalid entry for `%s': closing quote missing", - fm->tfm_name); + formatted_warning("map file", "invalid entry for '%s': closing quote missing", fm->tfm_name); goto bad_line; } break; @@ -525,14 +510,14 @@ static void fm_read_info(void) fm_file = NULL; } } else { - luatex_warn("cannot open font map file (%s)", cur_file_name); + formatted_warning("map file", "cannot open font map file '%s'", cur_file_name); } } else { - luatex_warn("cannot open font map file (%s)", cur_file_name); + formatted_warning("map file", "cannot open font map file '%s'", cur_file_name); } } else { if (!fm_open(cur_file_name)) { - luatex_warn("cannot open font map file (%s)", cur_file_name); + formatted_warning("map file", "cannot open font map file '%s'", cur_file_name); } else { fm_read_file(); report_start_file(filetype_map,cur_file_name); @@ -549,7 +534,7 @@ static void fm_read_info(void) } break; case MAPLINE: - cur_file_name = NULL; /* makes luatex_warn() shorter */ + cur_file_name = NULL; fm_scan_line(); break; default: diff --git a/source/texk/web2c/luatexdir/font/pkin.w b/source/texk/web2c/luatexdir/font/pkin.w index 18c96b20edc264863efa7e570ad6acaff392d98e..a5d3eb4bccb7af413248d73a791e5ea43b906972 100644 --- a/source/texk/web2c/luatexdir/font/pkin.w +++ b/source/texk/web2c/luatexdir/font/pkin.w @@ -56,14 +56,14 @@ typedef short shalfword; @ Now we have some routines to get stuff from the pk file. pkbyte returns the next byte from the pk file. - + @c static shalfword pkbyte(void) { register shalfword i; i = t3_getchar(); if (t3_eof()) - luatex_fail("unexpected eof in pk file"); + normal_error("type 3","unexpected EOF in pk file"); return (i); } @@ -200,7 +200,7 @@ static halfword rest(void) return (i); } } else { - luatex_fail("shouldn't happen"); + normal_error("type 3","pk issue that shouldn't happen"); return 0; /*NOTREACHED*/} } @@ -277,12 +277,6 @@ static void unpack(chardesc * cd) bitweight = 0; while (rowsleft > 0) { count = (*realfunc) (); -#ifdef DEBUG - if (turnon) - printf("(%d) ", (int) count); - else - printf("%d ", (int) count); -#endif while (count != 0) { if ((count < wordweight) && (count < hbit)) { if (turnon) @@ -319,7 +313,7 @@ static void unpack(chardesc * cd) turnon = !turnon; } if ((rowsleft != 0) || ((int) hbit != cd->cwidth)) - luatex_fail("error while unpacking; more bits than required"); + normal_error("type 3","error while unpacking, more bits than required"); } } @@ -341,9 +335,9 @@ int readchar(boolean check_preamble, chardesc * cd) */ if (check_preamble) { if (pkbyte() != 247) - luatex_fail("bad pk file, expected pre"); + normal_error("type 3","bad pk file, expected pre"); if (pkbyte() != 89) - luatex_fail("bad version of pk file"); + normal_error("type 3","bad version of pk file"); for (i = pkbyte(); i > 0; i--) /* creator of pkfile */ (void) pkbyte(); (void) pkquad(); /* design size */ @@ -399,7 +393,7 @@ int readchar(boolean check_preamble, chardesc * cd) cd->yoff = pkquad(); } if (length <= 0) - luatex_fail("packet length (%i) too small", (int) length); + formatted_error("type 3","pk packet length '%i' too small", (int) length); unpack(cd); return 1; } else { @@ -424,7 +418,7 @@ int readchar(boolean check_preamble, chardesc * cd) case 246: break; default: - luatex_fail("unexpected command (%i)", (int) flagbyte); + formatted_error("type 3","unexpected pk command '%i'", (int) flagbyte); } } } diff --git a/source/texk/web2c/luatexdir/font/sfnt.h b/source/texk/web2c/luatexdir/font/sfnt.h index 3fbdb001ea45a1e1e964fd83bb60671cd5bf6274..dce4248e981c684bc868c21c430b1b13eec12456 100644 --- a/source/texk/web2c/luatexdir/font/sfnt.h +++ b/source/texk/web2c/luatexdir/font/sfnt.h @@ -1,5 +1,5 @@ /* sfnt.h - + Copyright 2002 by Jin-Hwan Cho and Shunsaku Hirata, the dvipdfmx project team <dvipdfmx@project.ktug.or.kr> Copyright 2006-2008 Taco Hoekwater <taco@luatex.org> @@ -27,18 +27,6 @@ # include <w2c/config.h> # endif /* HAVE_CONFIG_H_ */ -# ifndef pdfTeX -# include "mfileio.h" -# include "numbers.h" -# include "pdfobj.h" -# endif - -# ifdef XETEX -# include "ft2build.h" -# include FT_FREETYPE_H -# include FT_TRUETYPE_TABLES_H -# endif - /* Data Types as described in Apple's TTRefMan */ typedef unsigned char BYTE; typedef signed char ICHAR; @@ -49,8 +37,7 @@ typedef signed long LONG; typedef unsigned long Fixed; /* 16.16-bit signed fixed-point number */ typedef short FWord; typedef unsigned short uFWord; -typedef short F2Dot14; /* 16-bit signed fixed number with the low - 14 bits representing fraction. */ +typedef short F2Dot14; /* 16-bit signed fixed number with the low 14 bits representing fraction. */ struct sfnt_table { /* table header */ @@ -182,9 +169,6 @@ typedef struct { # define RELEASE(a) free(a) # 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 luatex_fail -# define WARN printf - # endif diff --git a/source/texk/web2c/luatexdir/font/sfnt.w b/source/texk/web2c/luatexdir/font/sfnt.w index 939fd0bfe0c9e976535eeb704515c182c40994fe..83e38990dd94464b324a993c0437b454240bb865 100644 --- a/source/texk/web2c/luatexdir/font/sfnt.w +++ b/source/texk/web2c/luatexdir/font/sfnt.w @@ -142,7 +142,7 @@ static void convert_tag(char *tag, unsigned long u_tag) @ Computes the max power of 2 <= n - + @c static unsigned max2floor(unsigned n) { @@ -281,7 +281,7 @@ ULONG sfnt_locate_table(sfnt * sfont, const char *tag) offset = sfnt_find_table_pos(sfont, tag); if (offset == 0) - TT_ERROR("sfnt: table not found..."); + normal_error("ttf","sfnt table not found"); sfnt_seek_set(sfont, (long) offset); @@ -429,7 +429,7 @@ pdf_obj *sfnt_create_FontFile_stream(sfnt * sfont) if (!sfont->buffer) { pdf_release_obj(stream); - TT_ERROR("Font file not opened or already closed..."); + normal_error("ttf","file not opened or already closed"); return NULL; } @@ -439,7 +439,7 @@ pdf_obj *sfnt_create_FontFile_stream(sfnt * sfont) nb_read = sfnt_read(wbuf, (int) MIN(length, 1024), sfont); if (nb_read < 0) { pdf_release_obj(stream); - TT_ERROR("Reading file failed..."); + normal_error("ttf","reading file failed"); return NULL; } else if (nb_read > 0) { pdf_add_stream(stream, wbuf, nb_read); diff --git a/source/texk/web2c/luatexdir/font/subfont.w b/source/texk/web2c/luatexdir/font/subfont.w index ea139c4e48c50677b3688d22295dc3437d679748..0616bdad43ce631a79ffdc0954bb2d05fb6bbb56 100644 --- a/source/texk/web2c/luatexdir/font/subfont.w +++ b/source/texk/web2c/luatexdir/font/subfont.w @@ -105,7 +105,7 @@ static void sfd_getline(boolean expect_eof) *sfd_line = 10; return; } else - luatex_fail("unexpected end of file"); + normal_error("sub font","unexpected end of file"); } p = sfd_line; do { @@ -146,16 +146,15 @@ static sfd_entry *read_sfd(char *sfd_name) if (cur_file_name) { callback_id = callback_defined(read_sfd_file_callback); if (callback_id > 0) { - if (!(run_callback(callback_id, "S->bSd", cur_file_name, - &file_opened, &sfd_buffer, &sfd_size) && + if (!(run_callback(callback_id, "S->bSd", cur_file_name, &file_opened, &sfd_buffer, &sfd_size) && file_opened && sfd_size > 0)) { - luatex_warn("cannot open SFD file for reading (%s)", cur_file_name); + formatted_warning("ttf font","cannot open SFD file for reading '%s'", cur_file_name); cur_file_name = NULL; return NULL; } } else { if (!sfd_open(cur_file_name)) { - luatex_warn("cannot open SFD file for reading (%s)", cur_file_name); + formatted_warning("ttf font", "cannot open SFD file for reading '%s'", cur_file_name); cur_file_name = NULL; return NULL; } @@ -187,16 +186,16 @@ static sfd_entry *read_sfd(char *sfd_name) } else if (*p == 0) /* end of subfont */ break; if (sscanf(p, " %li %n", &i, &n) == 0) - luatex_fail("invalid token:\n%s", p); + formatted_error("sub font","invalid token: %s", p); p += n; if (*p == ':') { /* offset */ k = i; p++; } else if (*p == '_') { /* range */ if (sscanf(p + 1, " %li %n", &j, &n) == 0) - luatex_fail("invalid token:\n%s", p); + formatted_error("sub font","invalid token: %s", p); if (i > j || k + (j - i) > 255) - luatex_fail("invalid range:\n%s", p); + formatted_error("sub font","invalid range: %s", p); while (i <= j) sf->charcodes[k++] = i++; p += n + 1; diff --git a/source/texk/web2c/luatexdir/font/texfont.w b/source/texk/web2c/luatexdir/font/texfont.w index 580f0cbc13fab1763c105aa87d3a6a1a44437e60..a60ec97b0b8346f62430a5ff86c6e09f426cdfee 100644 --- a/source/texk/web2c/luatexdir/font/texfont.w +++ b/source/texk/web2c/luatexdir/font/texfont.w @@ -194,7 +194,7 @@ static void set_charinfo(internal_font_number f, int c, charinfo * ci) if (glyph) { font_tables[f]->charinfo[glyph] = *ci; } else { - luatex_fail("font: %s", "character insertion failed"); + normal_error("font","character insertion failed"); } } else if (c == left_boundarychar) { set_left_boundary(f, ci); @@ -1939,7 +1939,7 @@ void read_expand_font(void) normal_error("font expansion","font has been expanded with different auto expansion value"); } else { if (font_used(f)) - normal_warning("font expansion", "font should be expanded before its first use", true, true); + normal_warning("font expansion", "font should be expanded before its first use"); set_expand_params(f, auto_expand, stretch_limit, shrink_limit, font_step); } diff --git a/source/texk/web2c/luatexdir/font/tounicode.w b/source/texk/web2c/luatexdir/font/tounicode.w index fe57bbe7e4192af0b61dcdb6610659293aa81538..c213eee72c5d24ced03a6f8606e18e276fea72a3 100644 --- a/source/texk/web2c/luatexdir/font/tounicode.w +++ b/source/texk/web2c/luatexdir/font/tounicode.w @@ -95,9 +95,8 @@ void def_tounicode(str_number glyph, str_number unistr) break; } } - if (l == 0 || valid_unistr == 0 || strlen(buf) == 0 - || strcmp(buf, notdef) == 0) { - luatex_warn("ToUnicode: invalid parameter(s): `%s' => `%s'", buf, p); + if (l == 0 || valid_unistr == 0 || strlen(buf) == 0 || strcmp(buf, notdef) == 0) { + formatted_warning("tounicode", "invalid parameter(s): %s -> %s", buf, p); return; } if (glyph_unicode_tree == NULL) { @@ -308,9 +307,6 @@ int write_tounicode(PDF pdf, char **glyph_names, char *name) int bfchar_count, bfrange_count, subrange_count; assert(strlen(name) + strlen(builtin_suffix) < SMALL_BUF_SIZE); if (glyph_unicode_tree == NULL) { -#ifdef DEBUG - luatex_warn("no GlyphToUnicode entry has been inserted yet!"); -#endif pdf->gen_tounicode = 0; return 0; } diff --git a/source/texk/web2c/luatexdir/font/tt_glyf.w b/source/texk/web2c/luatexdir/font/tt_glyf.w index 0345db624418b2f928a195e69fbbfc9ddf28aaee..167d8df2038ac8bec44dd85e02ed22fb6e30169a 100644 --- a/source/texk/web2c/luatexdir/font/tt_glyf.w +++ b/source/texk/web2c/luatexdir/font/tt_glyf.w @@ -47,7 +47,7 @@ static USHORT find_empty_slot(struct tt_glyphs *g) break; } if (gid == NUM_GLYPH_LIMIT) - TT_ERROR("No empty glyph slot available."); + normal_error("ttf","no empty glyph slot available."); return gid; } @@ -89,10 +89,10 @@ USHORT tt_add_glyph(struct tt_glyphs * g, USHORT gid, USHORT new_gid) ASSERT(g); if (g->used_slot[new_gid / 8] & (1 << (7 - (new_gid % 8)))) { - WARN("Slot %u already used.", new_gid); + formatted_warning("ttf","slot %u already used", new_gid); } else { if (g->num_glyphs + 1 >= NUM_GLYPH_LIMIT) - TT_ERROR("Too many glyphs."); + normal_error("ttf","too many glyphs"); if (g->num_glyphs >= g->max_glyphs) { g->max_glyphs = (USHORT) (g->max_glyphs + GLYPH_ARRAY_ALLOC_SIZE); @@ -193,20 +193,20 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) ASSERT(g); if (sfont->type != SFNT_TYPE_TRUETYPE && sfont->type != SFNT_TYPE_TTC) - TT_ERROR("Invalid font type"); + normal_error("ttf","invalid font type"); if (g->num_glyphs > NUM_GLYPH_LIMIT) - TT_ERROR("Too many glyphs."); + normal_error("ttf","too many glyphs"); /* Read head, hhea, maxp, loca: - + unitsPerEm --> head numHMetrics --> hhea indexToLocFormat --> head - + numGlyphs --> maxp */ head = tt_read_head_table(sfont); @@ -214,7 +214,7 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) maxp = tt_read_maxp_table(sfont); if (hhea->metricDataFormat != 0) - TT_ERROR("Unknown metricDataFormat."); + normal_error("ttf","unknown metricDataFormat"); g->emsize = head->unitsPerEm; @@ -252,7 +252,7 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) for (i = 0; i <= maxp->numGlyphs; i++) location[i] = sfnt_get_ulong(sfont); } else { - TT_ERROR("Unknown IndexToLocFormat."); + normal_error("ttf","unknown IndexToLocFormat"); } w_stat = NEW(g->emsize + 2, USHORT); @@ -280,7 +280,7 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) gid = g->gd[i].ogid; if (gid >= maxp->numGlyphs) - TT_ERROR("Invalid glyph index (gid %u)", gid); + formatted_error("ttf","invalid glyph index (gid %u)", gid); loc = location[gid]; len = location[gid + 1] - loc; @@ -304,7 +304,7 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) if (len == 0) { /* Does not contains any data. */ continue; } else if (len < 10) { - TT_ERROR("Invalid TrueType glyph data (gid %u).", gid); + formatted_error("ttf","invalid glyph data (gid %u)", gid); } g->gd[i].data = p = NEW(len, BYTE); @@ -339,8 +339,7 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) USHORT flags, cgid, new_gid; /* flag, gid of a component */ do { if (p >= endptr) - TT_ERROR("Invalid TrueType glyph data (gid %u): %u bytes", - gid, (unsigned int) len); + formatted_error("ttf","invalid glyph data (gid %u): %u bytes", gid, (unsigned int) len); /* * Flags and gid of component glyph are both USHORT. */ @@ -348,8 +347,7 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) p += 2; cgid = (USHORT) (((*p) << 8) | *(p + 1)); if (cgid >= maxp->numGlyphs) { - TT_ERROR("Invalid gid (%u > %u) in composite glyph %u.", - cgid, maxp->numGlyphs, gid); + formatted_error("ttf","invalid gid (%u > %u) in composite glyph %u", cgid, maxp->numGlyphs, gid); } new_gid = tt_find_glyph(g, cgid); if (new_gid == 0) { @@ -371,7 +369,7 @@ int tt_build_tables(sfnt * sfont, struct tt_glyphs *g) TrueType instructions comes here: |length_of_instruction| (|ushort|) - + instruction (|byte * length_of_instruction|) */ } @@ -527,14 +525,14 @@ int tt_get_metrics(sfnt * sfont, struct tt_glyphs *g) sfont->stream == NULL #endif ) - TT_ERROR("File not opened."); + normal_error("ttf","file not opened"); if (sfont->type != SFNT_TYPE_TRUETYPE && sfont->type != SFNT_TYPE_TTC) - TT_ERROR("Invalid font type"); + normal_error("ttf","invalid font type"); /* Read head, hhea, maxp, loca: - + unitsPerEm --> head numHMetrics --> hhea @@ -548,7 +546,7 @@ int tt_get_metrics(sfnt * sfont, struct tt_glyphs *g) maxp = tt_read_maxp_table(sfont); if (hhea->metricDataFormat != 0) - TT_ERROR("Unknown metricDataFormat."); + normal_error("ttf","unknown metricDataFormat"); g->emsize = head->unitsPerEm; @@ -580,7 +578,7 @@ int tt_get_metrics(sfnt * sfont, struct tt_glyphs *g) for (i = 0; i <= maxp->numGlyphs; i++) location[i] = sfnt_get_ulong(sfont); } else { - TT_ERROR("Unknown IndexToLocFormat."); + normal_error("ttf","inknown IndexToLocFormat"); } w_stat = NEW(g->emsize + 2, USHORT); @@ -596,7 +594,7 @@ int tt_get_metrics(sfnt * sfont, struct tt_glyphs *g) gid = g->gd[i].ogid; if (gid >= maxp->numGlyphs) - TT_ERROR("Invalid glyph index (gid %u)", gid); + formatted_error("ttf","invalid glyph index (gid %u)", gid); loc = location[gid]; len = location[gid + 1] - loc; @@ -621,7 +619,7 @@ int tt_get_metrics(sfnt * sfont, struct tt_glyphs *g) if (len == 0) { /* Does not contains any data. */ continue; } else if (len < 10) { - TT_ERROR("Invalid TrueType glyph data (gid %u).", gid); + formatted_error("ttf","invalid glyph data (gid %u)", gid); } sfnt_seek_set(sfont, (long) (offset + loc)); diff --git a/source/texk/web2c/luatexdir/font/tt_table.w b/source/texk/web2c/luatexdir/font/tt_table.w index 3ebce2b99ca1599df2ea25322e56181315e2c145..8bd2f3b982d218d6cc99006735488e802ef9bf85 100644 --- a/source/texk/web2c/luatexdir/font/tt_table.w +++ b/source/texk/web2c/luatexdir/font/tt_table.w @@ -45,7 +45,7 @@ char *tt_pack_head_table(struct tt_head_table *table) char *p, *data; if (table == NULL) - TT_ERROR("passed NULL pointer\n"); + normal_error("ttf","passed NULL pointer"); p = data = NEW(TT_HEAD_TABLE_SIZE, char); p += sfnt_put_ulong(p, (LONG) table->version); @@ -205,13 +205,13 @@ struct tt_hhea_table *tt_read_hhea_table(sfnt * sfont) } table->metricDataFormat = sfnt_get_short(sfont); if (table->metricDataFormat != 0) - TT_ERROR("unknown metricDaraFormat"); + normal_error("ttf","unknown metricDaraFormat"); table->numberOfHMetrics = sfnt_get_ushort(sfont); return table; } -@ vhea +@ vhea @c char *tt_pack_vhea_table(struct tt_vhea_table *table) { @@ -279,7 +279,7 @@ struct tt_VORG_table *tt_read_VORG_table(sfnt * sfont) sfnt_locate_table(sfont, "VORG"); if (sfnt_get_ushort(sfont) != 1 || sfnt_get_ushort(sfont) != 0) - TT_ERROR("Unsupported VORG version."); + normal_error("ttf","unsupported VORG version"); vorg->defaultVertOriginY = sfnt_get_short(sfont); vorg->numVertOriginYMetrics = sfnt_get_ushort(sfont); @@ -325,7 +325,7 @@ struct tt_longMetrics *tt_read_longMetrics(sfnt * sfont, USHORT numGlyphs, @ OS/2 table -this table may not exist +this table may not exist @c struct tt_os2__table *tt_read_os2__table(sfnt * sfont) { @@ -398,7 +398,7 @@ tt_get_name(sfnt * sfont, char *dest, USHORT destlen, name_offset = sfnt_locate_table(sfont, "name"); if (sfnt_get_ushort(sfont)) - TT_ERROR("Expecting zero"); + normal_error("ttf","expecting zero"); num_names = sfnt_get_ushort(sfont); string_offset = sfnt_get_ushort(sfont); @@ -443,7 +443,7 @@ USHORT tt_get_ps_fontname(sfnt * sfont, char *dest, USHORT destlen) (namelen = tt_get_name(sfont, dest, destlen, 3, 5, 0x412u, 6)) != 0) return namelen; - fprintf(stderr, "\n** Warning: No valid PostScript name available **\n"); + normal_warning("ttf","no valid PostScript name available"); /* Wrokaround for some bad TTfonts: Language ID value 0xffffu for `accept any language ID' @@ -452,7 +452,7 @@ USHORT tt_get_ps_fontname(sfnt * sfont, char *dest, USHORT destlen) /* Finally falling back to Mac Roman name field. Warning: Some bad Japanese TTfonts using SJIS encoded string in the - Mac Roman name field. + Mac Roman name field. */ namelen = tt_get_name(sfont, dest, destlen, 1, 0, 0, 1); } diff --git a/source/texk/web2c/luatexdir/font/vfovf.w b/source/texk/web2c/luatexdir/font/vfovf.w index 4040f130b02f01029732726bb1f327e1eb4d1923..714ef0f87a9b9232da46aa85e12dd34efdbd5c5a 100644 --- a/source/texk/web2c/luatexdir/font/vfovf.w +++ b/source/texk/web2c/luatexdir/font/vfovf.w @@ -96,19 +96,21 @@ @ go out \.{VF} processing with an error message @c -#define bad_vf(a) { xfree(vf_buffer); print_nlp(); \ - tprint("Error in processing VF font ("); \ - tprint(font_name(f)); \ - tprint(".vf): "); \ - tprint(a); \ - tprint(", virtual font will be ignored"); \ - print_ln(); return; } - -#define lua_bad_vf(a) { xfree(vf_buffer); \ - lua_settop(L,s_top); \ - lua_pushnil(L); \ - lua_pushstring(L,a); \ - return 2; } +#define bad_vf(a) { \ + xfree(vf_buffer); \ + print_nlp(); \ + formatted_warning("virtual font","file '%s', %s, font will be ignored",font_name(f),a); \ + print_ln(); \ + return; \ +} + +#define lua_bad_vf(a) { \ + xfree(vf_buffer); \ + lua_settop(L,s_top); \ + lua_pushnil(L); \ + lua_pushstring(L,a); \ + return 2; \ +} #define tmp_b0 tmp_w.qqqq.b0 #define tmp_b1 tmp_w.qqqq.b1 @@ -129,9 +131,9 @@ typedef struct vf_stack_record { @c #define vf_byte(a) \ { \ - eight_bits vf_tmp_b; \ + eight_bits vf_tmp_b; \ if (vf_cur >= vf_size) { \ - luatex_fail("unexpected eof on virtual font"); \ + normal_error("virtual font","unexpected eof"); \ } \ vf_tmp_b = vf_buffer[vf_cur++]; \ a = vf_tmp_b; \ @@ -185,8 +187,7 @@ void pdf_check_vf(internal_font_number f) } static void -vf_local_font_warning(internal_font_number f, internal_font_number k, - const 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); @@ -267,10 +268,10 @@ vf_def_font(internal_font_number f, unsigned char *vf_buffer, int *vf_cr) append_char(junk); } if (level > 5) { - normal_warning("vf","quitting at recurse depth > 5",true,true); + normal_warning("vf","quitting at recurse depth > 5"); k = f ; } else if ((level > 1) && (fs > 65536*1024)) { - normal_warning("vf","quitting when recursing at size > 65536*1024",true,true); + normal_warning("vf","quitting when recursing at size > 65536*1024"); k = f ; } else { level += 1 ; @@ -284,11 +285,9 @@ 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", (int) checksum, - (int) 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)); + vf_local_font_warning(f, k, "design size mismatch", ds, font_dsize(k)); } } return k; diff --git a/source/texk/web2c/luatexdir/font/writecff.w b/source/texk/web2c/luatexdir/font/writecff.w index d6e05bca4dbfb7020df29d6abcca15024bd4f956..389eed8db76183ab4f47e4898a188a17d4765abf 100644 --- a/source/texk/web2c/luatexdir/font/writecff.w +++ b/source/texk/web2c/luatexdir/font/writecff.w @@ -49,9 +49,6 @@ static unsigned long get_unsigned(cff_font * cff, int n) } @ @c -#define CFF_ERROR luatex_fail -#undef WARN -#define WARN luatex_warn const char *const cff_stdstr[CFF_STDSTR_MAX] = { ".notdef", "space", "exclam", "quotedbl", "numbersign", @@ -163,18 +160,18 @@ cff_index *cff_get_index_header(cff_font * cff) if (count > 0) { idx->offsize = get_card8(cff); if (idx->offsize < 1 || idx->offsize > 4) - CFF_ERROR("invalid offsize data"); + normal_error("cff","invalid offsize data"); 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); - if (i == USHRT_MAX) + if (i == USHRT_MAX) break; } if (idx->offset[0] != 1) - CFF_ERROR("cff_get_index(): invalid index data"); + normal_error("cff","invalid index data"); idx->data = NULL; } else { @@ -201,7 +198,7 @@ cff_index *cff_get_index(cff_font * cff) if (count > 0) { idx->offsize = get_card8(cff); if (idx->offsize < 1 || idx->offsize > 4) - CFF_ERROR("invalid offsize data"); + normal_error("cff","invalid offsize data"); idx->offset = xmalloc((unsigned) (((unsigned) count + 1) * sizeof(l_offset))); @@ -210,7 +207,7 @@ cff_index *cff_get_index(cff_font * cff) } if (idx->offset[0] != 1) - CFF_ERROR("Invalid CFF Index offset data"); + normal_error("cff","invalid index offset data"); length = (size_t) (idx->offset[count] - idx->offset[0]); @@ -236,7 +233,7 @@ long cff_pack_index(cff_index * idx, card8 * dest, long destlen) if (idx->count < 1) { if (destlen < 2) - CFF_ERROR("Not enough space available..."); + normal_error("cff","not enough space available"); memset(dest, 0, 2); return 2; } @@ -245,7 +242,7 @@ long cff_pack_index(cff_index * idx, card8 * dest, long destlen) datalen = idx->offset[idx->count] - 1; if (destlen < len) - CFF_ERROR("Not enough space available..."); + normal_error("cff","not enough space available"); *(dest++) = (card8) ((idx->count >> 8) & 0xff); *(dest++) = (card8) (idx->count & 0xff); @@ -368,7 +365,7 @@ void cff_release_encoding(cff_encoding * encoding) xfree(encoding->data.range1); break; default: - CFF_ERROR("Unknown Encoding format."); + normal_error("cff","unknown encoding format"); } if (encoding->format & 0x80) xfree(encoding->supp); @@ -486,7 +483,7 @@ long cff_set_name(cff_font * cff, char *name) cff_index *idx; if (strlen(name) > 127) - CFF_ERROR("FontName string length too large..."); + normal_error("cff","FontName string length too large"); if (cff->name) cff_release_index(cff->name); @@ -506,7 +503,7 @@ long cff_set_name(cff_font * cff, char *name) long cff_put_header(cff_font * cff, card8 * dest, long destlen) { if (destlen < 4) - CFF_ERROR("Not enough space available..."); + normal_error("cff","not enough space available"); *(dest++) = cff->header_major; *(dest++) = cff->header_minor; @@ -863,9 +860,9 @@ cff_dict *cff_dict_unpack(card8 * data, card8 * endptr) } if (status != CFF_PARSE_OK) { - luatex_fail("Parsing CFF DICT failed. (error=%d)", status); + formatted_error("cff","parsing DICT failed (error=%d)", status); } else if (stack_top != 0) { - WARN("Garbage in CFF DICT data."); + normal_warning("cff","garbage in DICT data"); stack_top = 0; } @@ -899,13 +896,13 @@ double cff_dict_get(cff_dict * dict, const char *key, int idx) if ((dict->entries)[i].count > idx) value = (dict->entries)[i].values[idx]; else - luatex_fail("Invalid index number."); + normal_error("cff","invalid index number"); break; } } if (i == dict->count) - luatex_fail("DICT entry \"%s\" not found.", key); + formatted_error("cff","DICT entry '%s' not found", key); return value; } @@ -917,12 +914,12 @@ card8 cff_fdselect_lookup(cff_font * cff, card16 gid) cff_fdselect *fdsel; if (cff->fdselect == NULL) - CFF_ERROR("in cff_fdselect_lookup(): FDSelect not available"); + normal_error("cff","FDSelect not available"); fdsel = cff->fdselect; if (gid >= cff->num_glyphs) - CFF_ERROR("in cff_fdselect_lookup(): Invalid glyph index"); + normal_error("cff","invalid glyph index"); switch (fdsel->format) { case 0: @@ -943,12 +940,12 @@ card8 cff_fdselect_lookup(cff_font * cff, card16 gid) } break; default: - CFF_ERROR("in cff_fdselect_lookup(): Invalid FDSelect format"); + normal_error("cff","invalid FDSelect format"); break; } if (fd >= cff->num_fds) - CFF_ERROR("in cff_fdselect_lookup(): Invalid Font DICT index"); + normal_error("cff","invalid Font DICT index"); return fd; } @@ -1017,7 +1014,7 @@ long cff_read_fdarray(cff_font * cff) card16 i; if (cff->topdict == NULL) - CFF_ERROR("in cff_read_fdarray(): Top DICT not found"); + normal_error("cff","top DICT not found"); if (!(cff->flag & FONTTYPE_CIDFONT)) return 0; @@ -1117,12 +1114,12 @@ cff_font *read_cff(unsigned char *buf, long buflength, int n) cff->header_hdr_size = get_card8(cff); cff->header_offsize = get_card8(cff); if (cff->header_offsize < 1 || cff->header_offsize > 4) { - WARN("invalid offsize data"); + normal_warning("cff","invalid offsize data"); cff_close(cff); return NULL; } if (cff->header_major > 1) { - luatex_warn("CFF major version %u not supported.", cff->header_major); + formatted_warning("cff","major version %u not supported", cff->header_major); cff_close(cff); return NULL; } @@ -1131,7 +1128,7 @@ cff_font *read_cff(unsigned char *buf, long buflength, int n) /* Name INDEX */ idx = cff_get_index(cff); if (n > idx->count - 1) { - luatex_warn("Invalid CFF fontset index number."); + normal_warning("cff","invalid fontset index number"); cff_close(cff); return NULL; } @@ -1143,14 +1140,14 @@ cff_font *read_cff(unsigned char *buf, long buflength, int n) /* Top DICT INDEX */ idx = cff_get_index(cff); if (n > idx->count - 1) { - WARN("CFF Top DICT not exist..."); + normal_warning("cff","top DICT not exist"); cff_close(cff); return NULL; } cff->topdict = cff_dict_unpack(idx->data + idx->offset[n] - 1, idx->data + idx->offset[n + 1] - 1); if (!cff->topdict) { - WARN("Parsing CFF Top DICT data failed..."); + normal_warning("cff","parsing top DICT data failed"); cff_close(cff); return NULL; } @@ -1158,13 +1155,13 @@ cff_font *read_cff(unsigned char *buf, long buflength, int n) if (cff_dict_known(cff->topdict, "CharstringType") && cff_dict_get(cff->topdict, "CharstringType", 0) != 2) { - WARN("Only Type 2 Charstrings supported..."); + normal_warning("cff","only type 2 charstrings supported"); cff_close(cff); return NULL; } if (cff_dict_known(cff->topdict, "SyntheticBase")) { - WARN("CFF Synthetic font not supported."); + normal_warning("cff","synthetic font not supported"); cff_close(cff); return NULL; } @@ -1214,33 +1211,33 @@ static long pack_integer(card8 * dest, long destlen, long value) if (value >= -107 && value <= 107) { if (destlen < 1) - CFF_ERROR("Buffer overflow."); + normal_error("cff","buffer overflow"); dest[0] = (card8) ((value + 139) & 0xff); len = 1; } else if (value >= 108 && value <= 1131) { if (destlen < 2) - CFF_ERROR("Buffer overflow."); + normal_error("cff","buffer overflow"); value = (long) 0xf700u + value - 108; dest[0] = (card8) ((value >> 8) & 0xff); dest[1] = (card8) (value & 0xff); len = 2; } else if (value >= -1131 && value <= -108) { if (destlen < 2) - CFF_ERROR("Buffer overflow."); + normal_error("cff","buffer overflow"); value = (long) 0xfb00u - value - 108; dest[0] = (card8) ((value >> 8) & 0xff); dest[1] = (card8) (value & 0xff); len = 2; } else if (value >= -32768 && value <= 32767) { /* shortint */ if (destlen < 3) - CFF_ERROR("Buffer overflow."); + normal_error("cff","buffer overflow"); dest[0] = 28; dest[1] = (card8) ((value >> 8) & 0xff); dest[2] = (card8) (value & 0xff); len = 3; } else { /* longint */ if (destlen < 5) - CFF_ERROR("Buffer overflow."); + normal_error("cff","buffer overflow"); dest[0] = 29; dest[1] = (card8) ((value >> 24) & 0xff); dest[2] = (card8) ((value >> 16) & 0xff); @@ -1260,7 +1257,7 @@ static long pack_real(card8 * dest, long destlen, double value) #define CFF_REAL_MAX_LEN 17 if (destlen < 2) - CFF_ERROR("Buffer overflow."); + normal_error("cff","buffer overflow"); dest[0] = 30; @@ -1289,7 +1286,7 @@ static long pack_real(card8 * dest, long destlen, double value) } res=sprintf(work_buffer, "%1.14g", value); - if (res<0) CFF_ERROR("Invalid conversion."); + if (res<0) normal_error("cff","invalid conversion"); if (res>CFF_REAL_MAX_LEN) res=CFF_REAL_MAX_LEN; for (i = 0; i < res; i++) { @@ -1297,18 +1294,18 @@ static long pack_real(card8 * dest, long destlen, double value) if (work_buffer[i] == '\0') { /* res should prevent this. */ - /* CFF_ERROR("Cannot happen"); */ + /* normal_error("cff","cannot happen"); */ break; } else if (work_buffer[i] == '.') { ch = 0x0a; } else if (work_buffer[i] >= '0' && work_buffer[i] <= '9') { ch = (unsigned char) (work_buffer[i] - '0'); } else { - CFF_ERROR("Invalid character."); + normal_error("cff","invalid character"); } if (destlen < pos / 2 + 1) - CFF_ERROR("Buffer overflow."); + normal_error("cff","buffer overflow"); if (pos % 2) { dest[pos / 2] = (card8) (dest[pos / 2] + ch); @@ -1323,7 +1320,7 @@ static long pack_real(card8 * dest, long destlen, double value) dest[pos / 2] = (card8) (dest[pos / 2] + 0x0b); } else { if (destlen < pos / 2 + 1) - CFF_ERROR("Buffer overflow."); + normal_error("cff","buffer overflow"); dest[pos / 2] = (card8) (0xb0); } pos++; @@ -1332,7 +1329,7 @@ static long pack_real(card8 * dest, long destlen, double value) dest[pos / 2] = (card8) (dest[pos / 2] + 0x0c); } else { if (destlen < pos / 2 + 1) - CFF_ERROR("Buffer overflow."); + normal_error("cff","buffer overflow"); dest[pos / 2] = (card8) (0xc0); } e *= -1; @@ -1350,11 +1347,11 @@ static long pack_real(card8 * dest, long destlen, double value) } else if (work_buffer[i] >= '0' && work_buffer[i] <= '9') { ch = (unsigned char) (work_buffer[i] - '0'); } else { - CFF_ERROR("Invalid character."); + normal_error("cff","invalid character"); } if (destlen < pos / 2 + 1) - CFF_ERROR("Buffer overflow."); + normal_error("cff","buffer overflow"); if (pos % 2) { dest[pos / 2] = (card8) (dest[pos / 2] + ch); @@ -1370,7 +1367,7 @@ static long pack_real(card8 * dest, long destlen, double value) pos++; } else { if (destlen < pos / 2 + 1) - CFF_ERROR("Buffer overflow."); + normal_error("cff","buffer overflow"); dest[pos / 2] = (card8) (0xff); pos += 2; } @@ -1392,7 +1389,7 @@ static long cff_dict_put_number(double value, lvalue = (long) value; if (destlen < 5) - CFF_ERROR("Buffer overflow."); + normal_error("cff","buffer overflow"); dest[0] = 29; dest[1] = (card8) ((lvalue >> 24) & 0xff); dest[2] = (card8) ((lvalue >> 16) & 0xff); @@ -1428,15 +1425,15 @@ static long put_dict_entry(cff_dict_entry * de, card8 * dest, long destlen) } if (id >= 0 && id < CFF_LAST_DICT_OP1) { if (len + 1 > destlen) - CFF_ERROR("Buffer overflow."); + normal_error("cff","buffer overflow"); dest[len++] = (card8) id; } else if (id >= 0 && id < CFF_LAST_DICT_OP) { if (len + 2 > destlen) - CFF_ERROR("in cff_dict_pack(): Buffer overflow"); + normal_error("cff","buffer overflow"); dest[len++] = 12; dest[len++] = (card8) (id - CFF_LAST_DICT_OP1); } else { - CFF_ERROR("Invalid CFF DICT operator ID."); + normal_error("cff","invalid DICT operator ID"); } } @@ -1477,12 +1474,12 @@ void cff_dict_add(cff_dict * dict, const char *key, int count) } if (id == CFF_LAST_DICT_OP) - CFF_ERROR("Unknown CFF DICT operator."); + normal_error("cff","unknown DICT operator"); for (i = 0; i < dict->count; i++) { if ((dict->entries)[i].id == id) { if ((dict->entries)[i].count != count) - CFF_ERROR("Inconsistent DICT argument number."); + normal_error("cff","inconsistent DICT argument number"); return; } } @@ -1534,13 +1531,13 @@ void cff_dict_set(cff_dict * dict, const char *key, int idx, double value) if ((dict->entries)[i].count > idx) (dict->entries)[i].values[idx] = value; else - CFF_ERROR("Invalid index number."); + normal_error("cff","invalid index number"); break; } } if (i == dict->count) - luatex_fail("DICT entry \"%s\" not found.", key); + formatted_error("cff","DICT entry '%s' not found", key); } @@ -1601,7 +1598,7 @@ long cff_get_sid(cff_font * cff, const char *str) void cff_update_string(cff_font * cff) { if (cff == NULL) - CFF_ERROR("CFF font not opened."); + normal_error("cff","CFF font not opened"); if (cff->string) cff_release_index(cff->string); @@ -1618,7 +1615,7 @@ s_SID cff_add_string(cff_font * cff, const char *str) l_offset offset, size; if (cff == NULL) - CFF_ERROR("CFF font not opened."); + normal_error("cff","CFF font not opened"); if (cff->_string == NULL) cff->_string = cff_new_index(0); @@ -1693,7 +1690,7 @@ long cff_read_charsets(cff_font * cff) card16 count, i; if (cff->topdict == NULL) - CFF_ERROR("Top DICT not available"); + normal_error("cff","top DICT not available"); if (!cff_dict_known(cff->topdict, "charset")) { cff->flag |= CHARSETS_ISOADOBE; @@ -1773,13 +1770,13 @@ long cff_read_charsets(cff_font * cff) break; default: xfree(charset); - CFF_ERROR("Unknown Charset format"); + normal_error("cff","unknown charset format"); break; } if (count > 0) { /* fprintf(stdout, "count=%d\n", count); */ - WARN("Charset data possibly broken (num_glyphs too high)"); + normal_warning("cff","charset data possibly broken (too many glyphs)"); } return length; @@ -1796,7 +1793,7 @@ long cff_pack_charsets(cff_font * cff, card8 * dest, long destlen) return 0; if (destlen < 1) - CFF_ERROR("in cff_pack_charsets(): Buffer overflow"); + normal_error("cff","buffer overflow"); charset = cff->charsets; @@ -1804,7 +1801,7 @@ long cff_pack_charsets(cff_font * cff, card8 * dest, long destlen) switch (charset->format) { case 0: if (destlen < len + (charset->num_entries) * 2) - CFF_ERROR("in cff_pack_charsets(): Buffer overflow"); + normal_error("cff","buffer overflow"); for (i = 0; i < (charset->num_entries); i++) { s_SID sid = (charset->data).glyphs[i]; /* or CID */ dest[len++] = (card8) ((sid >> 8) & 0xff); @@ -1814,7 +1811,7 @@ long cff_pack_charsets(cff_font * cff, card8 * dest, long destlen) case 1: { if (destlen < len + (charset->num_entries) * 3) - CFF_ERROR("in cff_pack_charsets(): Buffer overflow"); + normal_error("cff","buffer overflow"); for (i = 0; i < (charset->num_entries); i++) { dest[len++] = (card8) (((charset->data).range1[i].first >> 8) & 0xff); @@ -1826,7 +1823,7 @@ long cff_pack_charsets(cff_font * cff, card8 * dest, long destlen) case 2: { if (destlen < len + (charset->num_entries) * 4) - CFF_ERROR("in cff_pack_charsets(): Buffer overflow"); + normal_error("cff","buffer overflow"); for (i = 0; i < (charset->num_entries); i++) { dest[len++] = (card8) (((charset->data).range2[i].first >> 8) & 0xff); @@ -1838,7 +1835,7 @@ long cff_pack_charsets(cff_font * cff, card8 * dest, long destlen) } break; default: - CFF_ERROR("Unknown Charset format"); + normal_error("cff","unknown charset format"); break; } @@ -2022,7 +2019,7 @@ static void clear_stack(card8 ** dest, card8 * limit) This number cannot be represented as a single operand. We must use `a b mul ...' or `a c div' to represent large values. */ - CFF_ERROR("Argument value too large. (This is bug)"); + normal_error("cff","argument value too large (this is bug)"); } else if (fabs(value - (double) ivalue) > 3.0e-5) { /* 16.16-bit signed fixed value */ DST_NEED(limit, *dest + 5); @@ -2053,7 +2050,7 @@ static void clear_stack(card8 ** dest, card8 * limit) *(*dest)++ = (card8) ((ivalue >> 8) & 0xff); *(*dest)++ = (card8) ((ivalue) & 0xff); } else { /* Shouldn't come here */ - CFF_ERROR("Unexpected error."); + normal_error("cff","unexpected error"); } } @@ -2144,11 +2141,11 @@ do_operator1(card8 ** dest, card8 * limit, card8 ** data, card8 * endptr) width = cs2_arg_stack[0]; clear_stack(dest, limit); } else if (cs2_stack_top == 4 || cs2_stack_top == 5) { - WARN("\"seac\" character deprecated in Type 2 charstring."); + normal_warning("cff","'seac' character deprecated in type 2 charstring"); status = CS_PARSE_CFF_ERROR; return; } else if (cs2_stack_top > 0) { - WARN("Operand stack not empty."); + normal_warning("cff","operand stack not empty"); } DST_NEED(limit, *dest + 1); *(*dest)++ = op; @@ -2166,7 +2163,7 @@ do_operator1(card8 ** dest, card8 * limit, card8 ** data, card8 * endptr) case cs_vhcurveto: case cs_hvcurveto: if (phase < 2) { - WARN("Broken Type 2 charstring."); + normal_warning("cff","broken type 2 charstring"); status = CS_PARSE_CFF_ERROR; return; } @@ -2179,11 +2176,11 @@ do_operator1(card8 ** dest, card8 * limit, card8 ** data, card8 * endptr) case cs_return: case cs_callgsubr: case cs_callsubr: - CFF_ERROR("Unexpected call(g)subr/return"); + normal_error("cff","unexpected call(g)subr/return"); break; default: /* no-op ? */ - WARN("%s: Unknown charstring operator: 0x%02x", CS_TYPE2_DEBUG_STR, op); + formatted_warning("cff","%s: unknown charstring operator: 0x%02x", CS_TYPE2_DEBUG_STR, op); status = CS_PARSE_CFF_ERROR; break; } @@ -2213,7 +2210,7 @@ do_operator2(card8 ** dest, card8 * limit, card8 ** data, card8 * endptr) switch (op) { case cs_dotsection: /* deprecated */ - WARN("Operator \"dotsection\" deprecated in Type 2 charstring."); + normal_warning("cff","Operator 'dotsection' deprecated in type 2 charstring"); status = CS_PARSE_CFF_ERROR; return; break; @@ -2222,7 +2219,7 @@ do_operator2(card8 ** dest, card8 * limit, card8 ** data, card8 * endptr) case cs_hflex1: case cs_flex1: if (phase < 2) { - WARN("%s: Broken Type 2 charstring.", CS_TYPE2_DEBUG_STR); + formatted_warning("cff","%s: broken type 2 charstring", CS_TYPE2_DEBUG_STR); status = CS_PARSE_CFF_ERROR; return; } @@ -2391,14 +2388,13 @@ do_operator2(card8 ** dest, card8 * limit, card8 ** data, card8 * endptr) } break; case cs_random: - WARN("%s: Charstring operator \"random\" found.", CS_TYPE2_DEBUG_STR); + formatted_warning("cff","%s: Charstring operator 'random' found.", CS_TYPE2_DEBUG_STR); NEED(CS_ARG_STACK_MAX, cs2_stack_top + 1); cs2_arg_stack[cs2_stack_top++] = 1.0; break; default: /* no-op ? */ - WARN("%s: Unknown charstring operator: 0x0c%02x", CS_TYPE2_DEBUG_STR, - op); + formatted_warning("cff","%s: unknown charstring operator: 0x0c%02x", CS_TYPE2_DEBUG_STR, op); status = CS_PARSE_CFF_ERROR; break; } @@ -2487,8 +2483,7 @@ static void get_subr(card8 ** subr, long *len, cff_index * subr_idx, long id) card16 count; if (subr_idx == NULL) - CFF_ERROR("%s: Subroutine called but no subroutine found.", - CS_TYPE2_DEBUG_STR); + formatted_error("cff","%s: subroutine called but no subroutine found",CS_TYPE2_DEBUG_STR); count = subr_idx->count; @@ -2502,8 +2497,7 @@ static void get_subr(card8 ** subr, long *len, cff_index * subr_idx, long id) } if (id > count) - CFF_ERROR("%s: Invalid Subr index: %ld (max=%u)", CS_TYPE2_DEBUG_STR, - id, count); + formatted_error("cff","%s: invalid subroutine index: %ld (max=%u)", CS_TYPE2_DEBUG_STR, id, count); *len = (long) ((subr_idx->offset)[id + 1] - (subr_idx->offset)[id]); *subr = subr_idx->data + (subr_idx->offset)[id] - 1; @@ -2527,7 +2521,7 @@ do_charstring(card8 ** dest, card8 * limit, long len; if (cs2_nest > CS_SUBR_NEST_MAX) - CFF_ERROR("%s: Subroutine nested too deeply.", CS_TYPE2_DEBUG_STR); + formatted_error("cff","%s: subroutine nested too deeply", CS_TYPE2_DEBUG_STR); cs2_nest++; @@ -2545,10 +2539,8 @@ do_charstring(card8 ** dest, card8 * limit, get_subr(&subr, &len, gsubr_idx, (long) cs2_arg_stack[cs2_stack_top]); if (*dest + len > limit) - CFF_ERROR("%s: Possible buffer overflow.", - CS_TYPE2_DEBUG_STR); - do_charstring(dest, limit, &subr, subr + len, gsubr_idx, - subr_idx); + formatted_error("cff","%s: possible buffer overflow", CS_TYPE2_DEBUG_STR); + do_charstring(dest, limit, &subr, subr + len, gsubr_idx, subr_idx); *data += 1; } } else if (b0 == cs_callsubr) { @@ -2559,10 +2551,8 @@ do_charstring(card8 ** dest, card8 * limit, get_subr(&subr, &len, subr_idx, (long) cs2_arg_stack[cs2_stack_top]); if (limit < *dest + len) - CFF_ERROR("%s: Possible buffer overflow.", - CS_TYPE2_DEBUG_STR); - do_charstring(dest, limit, &subr, subr + len, gsubr_idx, - subr_idx); + formatted_error("cff","%s: possible buffer overflow", CS_TYPE2_DEBUG_STR); + do_charstring(dest, limit, &subr, subr + len, gsubr_idx, subr_idx); *data += 1; } } else if (b0 == cs_escape) { @@ -2579,10 +2569,9 @@ do_charstring(card8 ** dest, card8 * limit, if (status == CS_SUBR_RETURN) { status = CS_PARSE_OK; } else if (status == CS_CHAR_END && *data < endptr) { - WARN("%s: Garbage after endchar.", CS_TYPE2_DEBUG_STR); + formatted_warning("cff","%s: garbage after endchar", CS_TYPE2_DEBUG_STR); } else if (status < CS_PARSE_OK) { /* error */ - CFF_ERROR("%s: Parsing charstring failed: (status=%d, stack=%d)", - CS_TYPE2_DEBUG_STR, status, cs2_stack_top); + formatted_error("cff","%s: parsing charstring failed: (status=%d, stack=%d)", CS_TYPE2_DEBUG_STR, status, cs2_stack_top); } cs2_nest--; @@ -2645,7 +2634,7 @@ long cff_read_encoding(cff_font * cff) card8 i; if (cff->topdict == NULL) { - CFF_ERROR("Top DICT data not found"); + normal_error("cff","top DICT data not found"); } if (!cff_dict_known(cff->topdict, "Encoding")) { @@ -2694,7 +2683,7 @@ long cff_read_encoding(cff_font * cff) break; default: xfree(encoding); - CFF_ERROR("Unknown Encoding format"); + normal_error("cff","unknown encoding format"); break; } @@ -2727,7 +2716,7 @@ long cff_pack_encoding(cff_font * cff, card8 * dest, long destlen) return 0; if (destlen < 2) - CFF_ERROR("in cff_pack_encoding(): Buffer overflow"); + normal_error("cff","buffer overflow"); encoding = cff->encoding; @@ -2736,7 +2725,7 @@ long cff_pack_encoding(cff_font * cff, card8 * dest, long destlen) switch (encoding->format & (~0x80)) { case 0: if (destlen < len + encoding->num_entries) - CFF_ERROR("in cff_pack_encoding(): Buffer overflow"); + normal_error("cff","buffer overflow"); for (i = 0; i < (encoding->num_entries); i++) { dest[len++] = (encoding->data).codes[i]; } @@ -2744,7 +2733,7 @@ long cff_pack_encoding(cff_font * cff, card8 * dest, long destlen) case 1: { if (destlen < len + (encoding->num_entries) * 2) - CFF_ERROR("in cff_pack_encoding(): Buffer overflow"); + normal_error("cff","buffer overflow"); for (i = 0; i < (encoding->num_entries); i++) { dest[len++] = (card8) ((encoding->data).range1[i].first & 0xff); dest[len++] = (card8) ((encoding->data).range1[i].n_left); @@ -2752,13 +2741,13 @@ long cff_pack_encoding(cff_font * cff, card8 * dest, long destlen) } break; default: - CFF_ERROR("Unknown Encoding format"); + normal_error("cff","unknown encoding format"); break; } if ((encoding->format) & 0x80) { if (destlen < len + (encoding->num_supps) * 3 + 1) - CFF_ERROR("in cff_pack_encoding(): Buffer overflow"); + normal_error("cff","buffer overflow"); dest[len++] = encoding->num_supps; for (i = 0; i < (encoding->num_supps); i++) { dest[len++] = (card8) ((encoding->supp)[i].code); @@ -2779,7 +2768,7 @@ long cff_read_fdselect(cff_font * cff) card16 i; if (cff->topdict == NULL) - CFF_ERROR("Top DICT not available"); + normal_error("cff","top DICT not available"); if (!(cff->flag & FONTTYPE_CIDFONT)) return 0; @@ -2811,15 +2800,15 @@ long cff_read_fdselect(cff_font * cff) ranges[i].fd = get_card8(cff); } if (ranges[0].first != 0) - CFF_ERROR("Range not starting with 0."); + normal_error("cff","range not starting with 0"); if (cff->num_glyphs != get_card16(cff)) - CFF_ERROR("Sentinel value mismatched with number of glyphs."); + normal_error("cff","sentinel value mismatched with number of glyphs"); length += (fdsel->num_entries) * 3 + 4; } break; default: xfree(fdsel); - CFF_ERROR("Unknown FDSelect format."); + normal_error("cff","unknown FDSelect format"); break; } @@ -2838,7 +2827,7 @@ long cff_pack_fdselect(cff_font * cff, card8 * dest, long destlen) return 0; if (destlen < 1) - CFF_ERROR("in cff_pack_fdselect(): Buffur overflow"); + normal_error("cff","buffer overflow"); fdsel = cff->fdselect; @@ -2846,9 +2835,9 @@ long cff_pack_fdselect(cff_font * cff, card8 * dest, long destlen) switch (fdsel->format) { case 0: if (fdsel->num_entries != cff->num_glyphs) - CFF_ERROR("in cff_pack_fdselect(): Invalid data"); + normal_error("cff","invalid data"); if (destlen < len + fdsel->num_entries) - CFF_ERROR("in cff_pack_fdselect(): Buffer overflow"); + normal_error("cff","buffer overflow"); for (i = 0; i < fdsel->num_entries; i++) { dest[len++] = (fdsel->data).fds[i]; } @@ -2856,18 +2845,18 @@ long cff_pack_fdselect(cff_font * cff, card8 * dest, long destlen) case 3: { if (destlen < len + 2) - CFF_ERROR("in cff_pack_fdselect(): Buffer overflow"); + normal_error("cff","buffer overflow"); len += 2; for (i = 0; i < (fdsel->num_entries); i++) { if (destlen < len + 3) - CFF_ERROR("in cff_pack_fdselect(): Buffer overflow"); + normal_error("cff","buffer overflow"); dest[len++] = (card8) (((fdsel->data).ranges[i].first >> 8) & 0xff); dest[len++] = (card8) ((fdsel->data).ranges[i].first & 0xff); dest[len++] = (card8) ((fdsel->data).ranges[i].fd); } if (destlen < len + 2) - CFF_ERROR("in cff_pack_fdselect(): Buffer overflow"); + normal_error("cff","buffer overflow"); dest[len++] = (card8) ((cff->num_glyphs >> 8) & 0xff); dest[len++] = (card8) (cff->num_glyphs & 0xff); dest[1] = (card8) (((len / 3 - 1) >> 8) & 0xff); @@ -2875,7 +2864,7 @@ long cff_pack_fdselect(cff_font * cff, card8 * dest, long destlen) } break; default: - CFF_ERROR("Unknown FDSelect format."); + normal_error("cff","unknown FDSelect format"); break; } @@ -3012,9 +3001,9 @@ static void write_fontfile(PDF pdf, cff_font * cffont, char *fullname) @c #define DO_COPY_CHARSTRING() \ if ((avl_find(fd->gl_tree,glyph) != NULL)) { \ - size = (long)(cs_idx->offset[code+1] - cs_idx->offset[code]); \ + size = (long)(cs_idx->offset[code+1] - cs_idx->offset[code]); \ if (size > CS_STR_LEN_MAX) { \ - luatex_fail("Charstring too long: gid=%u, %ld bytes", code, size); \ + formatted_error("cff","charstring too long: gid=%u, %ld bytes", code, size); \ } \ if (charstring_len + CS_STR_LEN_MAX >= max_len) { \ max_len = (long)(charstring_len + 2 * CS_STR_LEN_MAX); \ @@ -3154,7 +3143,7 @@ void write_cff(PDF pdf, cff_font * cffont, fd_entry * fd) offset = (long) cffont->offset; cs_count1 = cs_idx->count; if (cs_count1 < 2) { - CFF_ERROR("No valid charstring data found."); + normal_error("cff","no valid charstring data found"); } /* build the new charstrings entry */ @@ -3203,7 +3192,7 @@ void write_cff(PDF pdf, cff_font * cffont, fd_entry * fd) /* this happens if the internal metrics do not agree with the actual disk font */ if (gid < num_glyphs) { - WARN("embedded subset is smaller than expected: %d instead of %d glyphs.", gid, num_glyphs); + formatted_warning("cff","embedded subset is smaller than expected: %d instead of %d glyphs", gid, num_glyphs); num_glyphs = gid; } @@ -3268,7 +3257,7 @@ card16 cff_charsets_lookup(cff_font * cff, card16 cid) if (cff->flag & (CHARSETS_ISOADOBE | CHARSETS_EXPERT | CHARSETS_EXPSUB)) { ERROR("Predefined CFF charsets not supported yet"); } else if (cff->charsets == NULL) { - ERROR("Charsets data not available"); + normal_error("cff","charsets data not available"); } if (cid == 0) { @@ -3312,7 +3301,7 @@ card16 cff_charsets_lookup(cff_font * cff, card16 cid) } break; default: - ERROR("Unknown Charset format"); + normal_error("cff","unknown charset format"); } return 0; /* not found */ @@ -3425,7 +3414,7 @@ void write_cid_cff(PDF pdf, cff_font * cffont, fd_entry * fd) offset = (long) cffont->offset; cs_count1 = cs_idx->count; if (cs_count1 < 2) { - CFF_ERROR("No valid charstring data found."); + normal_error("cff","no valid charstring data found"); } charset = xcalloc(1, sizeof(cff_charsets)); @@ -3458,7 +3447,7 @@ void write_cid_cff(PDF pdf, cff_font * cffont, fd_entry * fd) (CIDToGIDMap[2 * cid + 1])); size = (long) (cs_idx->offset[gid_org + 1] - cs_idx->offset[gid_org]); if (size > CS_STR_LEN_MAX) { - luatex_fail("Charstring too long: gid=%u, %ld bytes", cid, size); + formatted_error("cff","charstring too long: gid=%u, %ld bytes", cid, size); } if (charstring_len + CS_STR_LEN_MAX >= max_len) { max_len = charstring_len + 2 * CS_STR_LEN_MAX; @@ -3492,7 +3481,7 @@ void write_cid_cff(PDF pdf, cff_font * cffont, fd_entry * fd) } if (gid != num_glyphs) - CFF_ERROR("Unexpected error: %i != %i", gid, num_glyphs); + formatted_error("cff","unexpected error: %i != %i", gid, num_glyphs); xfree(data); cff_release_index(cs_idx); diff --git a/source/texk/web2c/luatexdir/font/writefont.w b/source/texk/web2c/luatexdir/font/writefont.w index bbe2524b40b86f0c2ffd9c7af1041a551c88de6b..81a8b0f9b045372f05db753576dc633ebd581eff 100644 --- a/source/texk/web2c/luatexdir/font/writefont.w +++ b/source/texk/web2c/luatexdir/font/writefont.w @@ -41,7 +41,7 @@ const key_entry font_key[FONT_KEYS_NUM] = { , {"FontName", "FontName", 1} }; -@ +@ @c struct avl_table *fo_tree = NULL; /* tree of font dictionaries */ struct avl_table *fd_tree = NULL; /* tree of font descriptor objects */ @@ -62,7 +62,7 @@ static int comp_fd_entry(const void *pa, const void *pb, void *p) return strcmp(p1->fm->ff_name, p2->fm->ff_name); } -@ initialize data structure for /Type /Font +@ initialize data structure for /Type /Font @c static fo_entry *new_fo_entry(void) { @@ -187,7 +187,7 @@ static void write_fontmetrics(PDF pdf, fd_entry * fd) pdf_dict_add_int(pdf, font_key[i].pdfname, fd->font_dim[i].val); } -@ +@ @c static void preset_fontname(fo_entry * fo, internal_font_number f) { @@ -217,7 +217,7 @@ static void pdf_dict_add_fontname(PDF pdf, const char *key, fd_entry * fd) xfree(s); } -@ +@ @c fd_entry *lookup_fd_entry(char *s) { @@ -268,7 +268,7 @@ static void create_fontdescriptor(fo_entry * fo, internal_font_number f) assert(fo->fd->gl_tree != NULL); } -@ +@ For all used characters of \TeX font |f|, get corresponding glyph names from external reencoding (.enc) file and collect these in the glyph tree |gl_tree| of font descriptor |fd| referenced by font dictionary |fo|. @@ -431,7 +431,7 @@ static void write_fontfile(PDF pdf, fd_entry * fd) if (is_opentype(fd->fm)) { writetype0(pdf, fd); } else if (is_truetype(fd->fm)) { - if (!writetype2(pdf, fd)) { + if (!writetype2(pdf, fd)) { writetype0(pdf,fd); fd->fm->type |= F_OTF; fd->fm->type ^= F_TRUETYPE; } @@ -529,9 +529,8 @@ static void write_fontdescriptor(PDF pdf, fd_entry * fd) fd_flags = is_std_t1font(fd->fm) ? std_flags[check_std_t1font(fd->fm->ps_name)] : FD_FLAGS_DEFAULT_NON_EMBED; - luatex_warn - ("No flags specified for non-embedded font `%s' (%s) (I'm using %i): " - "fix your map entry.", + formatted_warning("map file", + "No flags specified for non-embedded font '%s' (%s), I'm using %i, fix your map entry", fd->fm->ps_name != NULL ? fd->fm->ps_name : "No name given", fd->fm->tfm_name, fd_flags); } @@ -720,9 +719,8 @@ static void create_fontdictionary(PDF pdf, internal_font_number f) create_fontdescriptor(fo, f); write_fontdescriptor(pdf, fo->fd); if (!is_std_t1font(fo->fm)) - luatex_warn("font `%s' is not a standard font; " - "I suppose it is available to your PDF viewer then", - fo->fm->ps_name); + formatted_warning("map file", "font '%s' is not a standard font; I suppose it is available to your PDF viewer then", + fo->fm->ps_name); } if (is_type1(fo->fm)) register_fo_entry(fo); @@ -784,9 +782,7 @@ void do_pdf_font(PDF pdf, internal_font_number f) fm->ff_name = s; del_file = 1; } else { - luatex_fail - ("writefont.c: The file (%s) does not contain font `%s'", - fm->ff_name, fm->ps_name); + formatted_error("font","file '%s' does not contain font '%s'",fm->ff_name, fm->ps_name); } } fm->encname = font_encodingname(f); /* for the CIDSystemInfo */ @@ -812,9 +808,8 @@ void do_pdf_font(PDF pdf, internal_font_number f) set_type1(fm); break; default: - luatex_fail - ("writefont.c: The file format (%s) for font `%s' is incompatible with wide characters\n", - font_format_name(f), font_name(f)); + formatted_error("font","file format '%s' for '%s' is incompatible with wide characters", + font_format_name(f), font_name(f)); } /* This makes "unknown" default to subsetted inclusion */ if (font_embedding(f) != no_embedding) { @@ -996,7 +991,7 @@ static void create_cid_fontdictionary(PDF pdf, internal_font_number f) avl_destroy(fo->fd->gl_tree,destroy_glw_cid_entry); } xfree(fo->fd); - } + } xfree(fo); } diff --git a/source/texk/web2c/luatexdir/font/writet1.w b/source/texk/web2c/luatexdir/font/writet1.w index 16dff008e73f56d34c7251ff0a08be8f383c895d..f328dbd17fc83c13854582b2e7acb2e9998b9c1f 100644 --- a/source/texk/web2c/luatexdir/font/writet1.w +++ b/source/texk/web2c/luatexdir/font/writet1.w @@ -254,7 +254,7 @@ static void enc_getline(void) char c; restart: if (enc_eof()) - luatex_fail("unexpected end of file"); + normal_error("type 1","unexpected end of file"); p = enc_line; do { c = (char) enc_getchar(); @@ -280,21 +280,20 @@ char **load_enc_file(char *enc_name) cur_file_name = luatex_find_file(enc_name, find_enc_file_callback); if (cur_file_name == NULL) { - luatex_fail("cannot find encoding file '%s' for reading", enc_name); + formatted_error("type 1","cannot find encoding file '%s' for reading", enc_name); } callback_id = callback_defined(read_enc_file_callback); enc_curbyte = 0; enc_size = 0; if (callback_id > 0) { - if (run_callback(callback_id, "S->bSd", cur_file_name, - &file_opened, &enc_buffer, &enc_size)) { + if (run_callback(callback_id, "S->bSd", cur_file_name, &file_opened, &enc_buffer, &enc_size)) { if ((!file_opened) || enc_size == 0) { - luatex_fail("cannot open encoding file '%s' for reading", cur_file_name); + formatted_error("type 1","cannot open encoding file '%s' for reading", cur_file_name); } } } else { if (!enc_open(cur_file_name)) { - luatex_fail("cannot open encoding file '%s' for reading", cur_file_name); + formatted_error("type 1","cannot open encoding file '%s' for reading", cur_file_name); } enc_read_file(); enc_close(); @@ -306,8 +305,7 @@ char **load_enc_file(char *enc_name) enc_getline(); if (*enc_line != '/' || (r = strchr(enc_line, '[')) == NULL) { remove_eol(r, enc_line); - luatex_fail - ("invalid encoding vector (a name or `[' missing): `%s'", enc_line); + formatted_error("type 1","invalid encoding vector (a name or '[' missing): '%s'", enc_line); } names_count = 0; r++; /* skip '[' */ @@ -319,7 +317,7 @@ char **load_enc_file(char *enc_name) *p = 0; skip(r, ' '); if (names_count >= 256) - luatex_fail("encoding vector contains more than 256 names"); + normal_error("type 1","encoding vector contains more than 256 names"); if (strcmp(buf, notdef) != 0) glyph_names[names_count] = xstrdup(buf); names_count++; @@ -329,9 +327,7 @@ char **load_enc_file(char *enc_name) goto done; else { remove_eol(r, enc_line); - luatex_fail - ("invalid encoding vector: a name or `] def' expected: `%s'", - enc_line); + formatted_error("type 1","invalid encoding vector: a name or '] def' expected: `%s'",enc_line); } } enc_getline(); @@ -371,7 +367,7 @@ static int t1_getbyte(void) return c; if (t1_block_length == 0) { if (c != 128) - luatex_fail("invalid marker"); + normal_error("type 1","invalid marker"); c = t1_getchar(); if (c == 3) { while (!t1_eof()) @@ -451,7 +447,7 @@ static float t1_scan_num(char *p, char **r) skip(p, ' '); if (sscanf(p, "%g", &f) != 1) { remove_eol(p, t1_line_array); - luatex_fail("a number expected: `%s'", t1_line_array); + formatted_error("type 1","a number expected: '%s'", t1_line_array); } if (r != NULL) { for (; isdigit((unsigned char)*p) || *p == '.' || @@ -483,7 +479,7 @@ static void t1_getline(void) static int eexec_len = 17; /* |strlen(eexec_str)| */ restart: if (t1_eof()) - luatex_fail("unexpected end of file"); + normal_error("type 1","unexpected end of file"); t1_line_ptr = t1_line_array; alloc_array(t1_line, 1, T1_BUF_SIZE); t1_cslen = 0; @@ -599,7 +595,7 @@ static void t1_check_block_len(boolean decrypt) c = edecrypt((byte) c); l = (int) t1_block_length; if (!(l == 0 && (c == 10 || c == 13))) { - luatex_fail("%i bytes more than expected were ignored", l + 1); + formatted_error("type 1","%i bytes more than expected were ignored", l + 1); } } @@ -636,7 +632,7 @@ static void t1_stop_eexec(PDF pdf) if (last_hexbyte == 0) t1_puts(pdf, "00"); else - luatex_fail("unexpected data after eexec"); + normal_error("type 1","unexpected data after eexec"); } } t1_cs = false; @@ -674,7 +670,7 @@ static void t1_scan_keys(PDF pdf) if (t1_prefix("/FontType")) { p = t1_line_array + strlen("FontType") + 1; if ((i = (int) t1_scan_num(p, 0)) != 1) - luatex_fail("Type%d fonts unsupported by pdfTeX", i); + formatted_error("type 1","Type%d fonts unsupported by backend", i); return; } for (key = (const key_entry *) font_key; key - font_key < FONT_KEYS_NUM; @@ -690,7 +686,7 @@ static void t1_scan_keys(PDF pdf) if ((k = (int) (key - font_key)) == FONTNAME_CODE) { if (*p != '/') { remove_eol(p, t1_line_array); - luatex_fail("a name expected: `%s'", t1_line_array); + formatted_error("type 1","a name expected: '%s'", t1_line_array); } r = ++p; /* skip the slash */ for (q = t1_buf_array; *p != ' ' && *p != 10; *q++ = *p++); @@ -732,7 +728,7 @@ static void t1_scan_param(PDF pdf) if (t1_prefix(lenIV)) { t1_lenIV = (short) t1_scan_num(t1_line_array + strlen(lenIV), 0); if (t1_lenIV < 0) - luatex_fail("negative value of lenIV is not supported"); + normal_error("type 1","negative value of lenIV is not supported"); return; } t1_scan_keys(pdf); @@ -770,9 +766,7 @@ static char **t1_builtin_enc(void) } return glyph_names; } else - luatex_fail - ("cannot subset font (unknown predefined encoding `%s')", - t1_buf_array); + formatted_error("type 1","cannot subset font (unknown predefined encoding '%s')",t1_buf_array); } /* At this moment \.{/Encoding} is the prefix of |t1_line_array|, and the encoding is not a predefined encoding. @@ -802,7 +796,7 @@ static char **t1_builtin_enc(void) *p = 0; skip(r, ' '); if (counter > 255) - luatex_fail("encoding vector contains more than 256 names"); + normal_error("type 1","encoding vector contains more than 256 names"); if (strcmp(t1_buf_array, notdef) != 0) glyph_names[counter] = xstrdup(t1_buf_array); counter++; @@ -812,9 +806,7 @@ static char **t1_builtin_enc(void) break; else { remove_eol(r, t1_line_array); - luatex_fail - ("a name or `] def' or `] readonly def' expected: `%s'", - t1_line_array); + formatted_error("type 1","a name or '] def' or '] readonly def' expected: '%s'", t1_line_array); } } t1_getline(); @@ -900,23 +892,19 @@ static boolean t1_open_fontfile(int open_name_prefix) t1_size = 0; ff = check_ff_exist(fd_cur->fm->ff_name, is_truetype(fd_cur->fm)); if (ff->ff_path == NULL) { - luatex_fail("cannot open Type 1 font file for reading (%s)", - fd_cur->fm->ff_name); + formatted_error("type 1","cannot open file for reading '%s'",fd_cur->fm->ff_name); return false; } cur_file_name = luatex_find_file(ff->ff_path, find_type1_file_callback); if (cur_file_name == NULL) { - luatex_fail("cannot open Type 1 font file for reading (%s)", - ff->ff_path); + formatted_error("type 1","cannot open file for reading '%s'", ff->ff_path); return false; } callback_id = callback_defined(read_type1_file_callback); if (callback_id > 0) { - if (!run_callback(callback_id, "S->bSd", cur_file_name, - &file_opened, &t1_buffer, &t1_size) + if (!run_callback(callback_id, "S->bSd", cur_file_name, &file_opened, &t1_buffer, &t1_size) && file_opened && t1_size > 0) { - luatex_warn("cannot open Type 1 font file for reading (%s)", - cur_file_name); + formatted_warning("type 1","cannot open file for reading '%s'",cur_file_name); return false; } } else { @@ -966,7 +954,7 @@ static void t1_include(PDF pdf) @c #define check_subr(subr) \ if (subr >= subr_size || subr < 0) \ - luatex_fail("Subrs array: entry index out of range (%i)", subr); + formatted_error("type 1","Subrs array: entry index out of range '%i'", subr); static const char **check_cs_token_pair(void) { @@ -992,8 +980,7 @@ static void cs_store(boolean is_subr) } else { ptr = cs_ptr++; if (cs_ptr - cs_tab > cs_size) - luatex_fail - ("CharStrings dict: more entries than dict size (%i)", cs_size); + formatted_error("type 1","CharStrings dict: more entries than dict size '%i'", cs_size); if (strcmp(t1_buf_array + 1, notdef) == 0) /* skip the slash */ ptr->name = (char *) notdef; else @@ -1018,25 +1005,23 @@ static void cs_store(boolean is_subr) @ @c -#define store_subr() cs_store(true) -#define store_cs() cs_store(false) +#define store_subr() cs_store(true) +#define store_cs() cs_store(false) -#define CC_STACK_SIZE 24 +#define CC_STACK_SIZE 24 static int cc_stack[CC_STACK_SIZE], *stack_ptr = cc_stack; static cc_entry cc_tab[CS_MAX]; static boolean is_cc_init = false; - -#define cc_pop(N) \ - if (stack_ptr - cc_stack < (N)) \ - stack_error(N); \ +#define cc_pop(N) \ + if (stack_ptr - cc_stack < (N)) \ + stack_error(N); \ stack_ptr -= N -#define stack_error(N) { \ - luatex_fail("CharString: invalid access (%i) to stack (%i entries)", \ - (int) N, (int)(stack_ptr - cc_stack)); \ - goto cs_error; \ +#define stack_error(N) { \ + formatted_error("type 1","CharString: invalid access '%i' to stack, '%i' entries", (int) N, (int)(stack_ptr - cc_stack)); \ + goto cs_error; \ } #define cc_get(N) ((N) < 0 ? *(stack_ptr + (N)) : *(cc_stack + (N))) @@ -1095,7 +1080,6 @@ static void cc_init(void) #define mark_subr(n) cs_mark(0, n) #define mark_cs(s) cs_mark(s, 0) -__attribute__ ((noreturn, format(printf, 3, 4))) static void cs_fail(const char *cs_name, int subr, const char *fmt, ...) { char buf[SMALL_BUF_SIZE]; @@ -1104,9 +1088,9 @@ static void cs_fail(const char *cs_name, int subr, const char *fmt, ...) vsprintf(buf, fmt, args); va_end(args); if (cs_name == NULL) - luatex_fail("Subr (%i): %s", (int) subr, buf); + formatted_error("type 1","Subr '%i': %s", (int) subr, buf); else - luatex_fail("CharString (/%s): %s", cs_name, buf); + formatted_error("type 1","CharString (/%s): %s", cs_name, buf); } @ fix a return-less subr by appending |CS_RETURN| @@ -1170,7 +1154,7 @@ static void cs_mark(const char *cs_name, int subr) if (strcmp(ptr->name, cs_name) == 0) break; if (ptr == cs_ptr) { - luatex_warn("glyph `%s' undefined", cs_name); + formatted_warning("type 1","glyph '%s' undefined", cs_name); return; } if (ptr->name == notdef) @@ -1215,8 +1199,7 @@ static void cs_mark(const char *cs_name, int subr) cs_len--; } if (b >= CS_MAX) { - cs_fail(cs_name, subr, "command value out of range: %i", - (int) b); + cs_fail(cs_name, subr, "command value out of range: %i", (int) b); goto cs_error; } cc = cc_tab + b; @@ -1227,11 +1210,11 @@ static void cs_mark(const char *cs_name, int subr) if (cc->bottom) { if (stack_ptr - cc_stack < cc->nargs) cs_fail(cs_name, subr, - "less arguments on stack (%i) than required (%i)", + "less arguments on stack '%i' than required '%i'", (int) (stack_ptr - cc_stack), (int) cc->nargs); else if (stack_ptr - cc_stack > cc->nargs) cs_fail(cs_name, subr, - "more arguments on stack (%i) than required (%i)", + "more arguments on stack '%i' than required '%i'", (int) (stack_ptr - cc_stack), (int) cc->nargs); } last_cmd = b; @@ -1241,7 +1224,7 @@ static void cs_mark(const char *cs_name, int subr) cc_pop(1); mark_subr(a1); if (!subr_tab[a1].valid) { - cs_fail(cs_name, subr, "cannot call subr (%i)", (int) a1); + cs_fail(cs_name, subr, "cannot call subr '%i'", (int) a1); goto cs_error; } break; @@ -1276,9 +1259,9 @@ static void cs_mark(const char *cs_name, int subr) } } if (cs_name == NULL && last_cmd != CS_RETURN) { - luatex_warn("last command in subr `%i' is not a RETURN; " - "I will add it now but please consider fixing the font", - (int) subr); + formatted_warning("type 1", + "last command in subr '%i' is not a RETURN; I will add it now but please consider fixing the font", + (int) subr); append_cs_return(ptr); } return; @@ -1676,8 +1659,7 @@ static void t1_subset_charstrings(PDF pdf) if (cs_token_pair == NULL) - luatex_fail - ("This Type 1 font uses mismatched subroutine begin/end token pairs."); + formatted_error("type 1","mismatched subroutine begin/end token pairs"); t1_subr_flush(); } diff --git a/source/texk/web2c/luatexdir/font/writet3.w b/source/texk/web2c/luatexdir/font/writet3.w index 3dda177040939ab00787f2b92e0cdd4b900f6ec8..1d33330716c3d91a8dd6abcbbaadd3b424c5ede6 100644 --- a/source/texk/web2c/luatexdir/font/writet3.w +++ b/source/texk/web2c/luatexdir/font/writet3.w @@ -48,7 +48,7 @@ int t3_curbyte = 0; #define t3_check_eof() \ if (t3_eof()) \ - luatex_fail("unexpected end of file"); + normal_error("type 3","unexpected end of file"); @ @c @@ -139,16 +139,13 @@ static boolean writepk(PDF pdf, internal_font_number f) if (name == NULL || !FILESTRCASEEQ(cur_file_name, font_ret.name) || !kpse_bitmap_tolerance((float) font_ret.dpi, (float) dpi)) { - luatex_fail("Font %s at %i not found", cur_file_name, (int) dpi); + formatted_error("type 3","font %s at %i not found", cur_file_name, (int) dpi); } } callback_id = callback_defined(read_pk_file_callback); if (callback_id > 0) { - if (! - (run_callback - (callback_id, "S->bSd", name, &file_opened, &t3_buffer, &t3_size) - && file_opened && t3_size > 0)) { - luatex_warn("Font %s at %i not found", cur_file_name, (int) dpi); + if (!(run_callback(callback_id, "S->bSd", name, &file_opened, &t3_buffer, &t3_size) && file_opened && t3_size > 0)) { + formatted_warning("font %s at %i not found", cur_file_name, (int) dpi); cur_file_name = NULL; return false; } diff --git a/source/texk/web2c/luatexdir/font/writettf.w b/source/texk/web2c/luatexdir/font/writettf.w index 77fef925507b269504efddc48d9235d252e6de7b..e1edea5e2ab0bc421fa3247dceabe720c0551df9 100644 --- a/source/texk/web2c/luatexdir/font/writettf.w +++ b/source/texk/web2c/luatexdir/font/writettf.w @@ -485,7 +485,7 @@ long ttf_getnum(int s) int c; while (s > 0) { if (ttf_eof()) - luatex_fail("unexpected EOF"); + normal_error("ttf font","unexpected EOF"); c = ttf_getchar(); i = (i << 8) + c; s--; @@ -516,7 +516,7 @@ dirtab_entry *ttf_name_lookup(const char *s, boolean required) } if (tab - dir_tab == ntabs) { if (required) - luatex_fail("can't find table `%s'", s); + formatted_error("ttf font","can't find table '%s'", s); else tab = NULL; } @@ -586,9 +586,7 @@ static void ttf_copy_encoding(void) e = ttfenc_tab + *q; e->code = charcodes[*q]; if (e->code == -1) - luatex_warn - ("character %i in subfont %s is not mapped to any charcode", - *q, fd_cur->fm->tfm_name); + formatted_warning("ttf font", "character %i in subfont %s is not mapped to any charcode", *q, fd_cur->fm->tfm_name); else { assert(e->code < 0x10000); sprintf(buf, "/c%4.4X", (int) e->code); @@ -816,8 +814,7 @@ void ttf_read_post(void) } break; default: - luatex_warn("unsupported format (%.8X) of `post' table, assuming 3.0", - (unsigned int) post_format); + formatted_warning("ttf font", "unsupported format '%.8X' of 'post' table, assuming 3.0", (unsigned int) post_format); case 0x00030000: for (glyph = glyph_tab; glyph - glyph_tab < NMACGLYPHS; glyph++) { glyph->name_index = (TTF_USHORT) (glyph - glyph_tab); @@ -915,14 +912,13 @@ static ttf_cmap_entry *ttf_read_cmap(char *ttf_name, int pid, int eid, goto read_cmap_format_4; else { if (warn) - luatex_warn("cmap format %i unsupported", format); + formatted_warning("ttf font", "cmap format %i unsupported", format); return NULL; } } } if (warn) - luatex_warn("cannot find cmap subtable for (pid,eid) = (%i, %i)", - pid, eid); + formatted_warning("ttf font", "cannot find cmap subtable for (pid,eid) = (%i,%i)", pid, eid); return NULL; read_cmap_format_4: /* initialize the new entry */ @@ -972,13 +968,13 @@ static ttf_cmap_entry *ttf_read_cmap(char *ttf_name, int pid, int eid, index = (index + s->idDelta) & 0xFFFF; } if (index >= glyphs_count) - luatex_fail("cmap: glyph index %li out of range [0..%i)", - index, glyphs_count); + formatted_error("ttf font", + "cmap issue, glyph index %li out of range [0..%i)", + index, glyphs_count); if (p->table[i] != -1) - luatex_warn - ("cmap: multiple glyphs are mapped to unicode %.4lX, " - "only %li will be used (glyph %li being ignored)", i, - p->table[i], index); + formatted_warning("ttf font", + "cmap issue, multiple glyphs are mapped to unicode %.4lX, %li will be used, %li is ignored)", + i, p->table[i], index); else p->table[i] = index; } @@ -991,7 +987,7 @@ static ttf_cmap_entry *ttf_read_cmap(char *ttf_name, int pid, int eid, return p; } -@ +@ @c static void ttf_read_font(void) { @@ -1021,7 +1017,7 @@ static void ttf_reset_chksm(PDF pdf, dirtab_entry * tab) tmp_ulong = 0; tab->offset = (TTF_ULONG) ttf_offset(); if (tab->offset % 4 != 0) - luatex_warn("offset of `%4.4s' is not a multiple of 4", tab->tag); + formatted_warning("ttf font","offset of `%4.4s' is not a multiple of 4", tab->tag); } @@ -1041,7 +1037,7 @@ static void ttf_copytab(PDF pdf, const char *name) ttf_set_chksm(pdf, tab); } -@ +@ @c #define BYTE_ENCODING_LENGTH \ ((256)*TTF_BYTE_SIZE + 3*TTF_USHORT_SIZE) @@ -1057,14 +1053,14 @@ static void ttf_byte_encoding(PDF pdf) put_byte(e->newindex); } else { if (e->name != notdef) - luatex_warn - ("glyph `%s' has been mapped to `%s' in `ttf_byte_encoding' cmap table", - e->name, notdef); + formatted_warning("ttf font", + "glyph '%s' has been mapped to '%s' in 'ttf_byte_encoding' cmap table", + e->name, notdef); put_byte(0); /* notdef */ } } -@ +@ @c #define TRIMMED_TABLE_MAP_LENGTH (TTF_USHORT_SIZE*(5 + (256))) @@ -1080,7 +1076,7 @@ static void ttf_trimmed_table_map(PDF pdf) (void) put_ushort(e->newindex); } -@ +@ @c #define SEG_MAP_DELTA_LENGTH ((16 + (256))*TTF_USHORT_SIZE) @@ -1107,7 +1103,7 @@ static void ttf_seg_map_delta(PDF pdf) (void) put_ushort(e->newindex); } -@ +@ @c #define CMAP_ENTRY_LENGTH (2*TTF_USHORT_SIZE + TTF_ULONG_SIZE) @@ -1146,7 +1142,7 @@ static void ttf_write_cmap(PDF pdf) offset += TRIMMED_TABLE_MAP_LENGTH; break; default: - luatex_fail("invalid format (it should not have happened)"); + normal_error("ttf font","invalid format (it should not have happened)"); } (void) put_ushort(ce->platform_id); (void) put_ushort(ce->encoding_id); @@ -1168,7 +1164,7 @@ static void ttf_write_cmap(PDF pdf) ttf_set_chksm(pdf, tab); } -@ +@ @c static int prepend_subset_tags(int index, char *p) { @@ -1249,7 +1245,7 @@ static void ttf_write_name(PDF pdf) xfree(new_name_buf); } -@ +@ @c static void ttf_write_dirtab(PDF pdf) { @@ -1290,7 +1286,7 @@ static void ttf_write_dirtab(PDF pdf) } } if (i % 4 != 0) { - luatex_warn("font length is not a multiple of 4 (%li)", i); + formatted_warning("ttf font","font length '%li' is not a multiple of 4", i); checksum <<= 8 * (4 - i % 4); } k = 0xB1B0AFBA - checksum; @@ -1299,7 +1295,7 @@ static void ttf_write_dirtab(PDF pdf) ttf_seek_outbuf(save_offset); } -@ +@ @c static void ttf_write_glyf(PDF pdf) { @@ -1323,7 +1319,7 @@ static void ttf_write_glyf(PDF pdf) if (glyph_tab[idx].newindex < 0) { glyph_tab[idx].newindex = (TTF_SHORT) new_glyphs_count; glyph_index[new_glyphs_count++] = idx; - /* + /* N.B.: Here we change |new_glyphs_count|, which appears in the condition of the |for| loop */ @@ -1356,7 +1352,7 @@ static void ttf_write_glyf(PDF pdf) while going through |ttfenc_tab|. After appending a new entry to |glyph_index| we set field |newindex| of corresponding entries in both |glyph_tab| and |ttfenc_tab| to the newly created index. - + @c static void ttf_reindex_glyphs(void) { @@ -1387,8 +1383,8 @@ static void ttf_reindex_glyphs(void) t = cmap->table; assert(t != NULL && e->code < 0x10000); if (t[e->code] < 0) { - luatex_warn - ("subfont %s: wrong mapping: character %li --> 0x%4.4lX --> .notdef", + formatted_warning("ttf font", + "subfont %s has a wrong mapping, character %li -> 0x%4.4lX -> .notdef", fd_cur->fm->tfm_name, (long) (e - ttfenc_tab), e->code); continue; } @@ -1403,8 +1399,7 @@ static void ttf_reindex_glyphs(void) /* scan form `index123' */ if (sscanf(e->name, GLYPH_PREFIX_INDEX "%i", &index) == 1) { if (index >= glyphs_count) { - luatex_warn("`%s' out of valid range [0..%i)", - e->name, glyphs_count); + formatted_warning("ttf font","'%s' out of valid range [0..%i)", e->name, glyphs_count); continue; } glyph = glyph_tab + index; @@ -1418,8 +1413,7 @@ static void ttf_reindex_glyphs(void) if (cmap == NULL) cmap = ttf_read_cmap(fd_cur->fm->ff_name, 0, 3, false); if (cmap == NULL) { - luatex_warn - ("no unicode mapping found, all `uniXXXX' names will be ignored"); + normal_warning("ttf font", "no unicode mapping found, all 'uniXXXX' names will be ignored"); cmap_not_found = true; /* once only */ } } @@ -1429,16 +1423,14 @@ static void ttf_reindex_glyphs(void) assert(t != NULL); if (t[index] != -1) { if (t[index] >= glyphs_count) { - luatex_warn - ("`%s' is mapped to index %li which is out of valid range [0..%i)", + formatted_warning("ttf font", "'%s' is mapped to index %li which is out of valid range [0..%i)", e->name, t[index], glyphs_count); continue; } glyph = glyph_tab + t[index]; goto append_new_glyph; } else { - luatex_warn("`unicode %s%.4X' is not mapped to any glyph", - GLYPH_PREFIX_UNICODE, index); + formatted_warning("ttf font","unicode %s%.4X is not mapped to any glyph", GLYPH_PREFIX_UNICODE, index); continue; } } @@ -1447,7 +1439,7 @@ static void ttf_reindex_glyphs(void) if (glyph->name != notdef && strcmp(glyph->name, e->name) == 0) break; if (!(glyph - glyph_tab < glyphs_count)) { - luatex_warn("glyph `%s' not found", e->name); + formatted_warning("ttf font","glyph '%s' not found", e->name); continue; } append_new_glyph: @@ -1502,7 +1494,7 @@ static void ttf_write_head(PDF pdf) ttf_set_chksm(pdf, tab); } -@ +@ @c static void ttf_write_hhea(PDF pdf) { @@ -1515,7 +1507,7 @@ static void ttf_write_hhea(PDF pdf) ttf_set_chksm(pdf, tab); } -@ +@ @c static void ttf_write_htmx(PDF pdf) { @@ -1529,7 +1521,7 @@ static void ttf_write_htmx(PDF pdf) ttf_set_chksm(pdf, tab); } -@ +@ @c static void ttf_write_loca(PDF pdf) { @@ -1557,7 +1549,7 @@ static void ttf_write_loca(PDF pdf) ttf_set_chksm(pdf, tab); } -@ +@ @c static void ttf_write_mapx(PDF pdf) { @@ -1569,7 +1561,7 @@ static void ttf_write_mapx(PDF pdf) ttf_set_chksm(pdf, tab); } -@ +@ @c static void ttf_write_OS2(PDF pdf) { @@ -1578,7 +1570,7 @@ static void ttf_write_OS2(PDF pdf) ttf_reset_chksm(pdf, tab); version = get_ushort(); if (version > 3) - luatex_fail("unknown version of OS/2 table (%.4X)", version); + formatted_error("ttf font","unknown version '%.4X' of OS/2 table", version); (void) put_ushort(0x0001); /* fix version to 1 */ ttf_ncopy(pdf, 2 * TTF_USHORT_SIZE + 13 * TTF_SHORT_SIZE + 10 * TTF_BYTE_SIZE); @@ -1598,7 +1590,7 @@ static void ttf_write_OS2(PDF pdf) ttf_set_chksm(pdf, tab); } -@ +@ @c static boolean unsafe_name(const char *s) { @@ -1647,7 +1639,7 @@ static void ttf_write_post(PDF pdf) ttf_set_chksm(pdf, tab); } -@ +@ @c static void ttf_init_font(PDF pdf, int n) { @@ -1661,7 +1653,7 @@ static void ttf_init_font(PDF pdf, int n) ttf_seek_outbuf(TABDIR_OFF + n * 4 * TTF_ULONG_SIZE); } -@ +@ @c static void ttf_subset_font(PDF pdf) { @@ -1688,7 +1680,7 @@ static void ttf_subset_font(PDF pdf) ttf_write_dirtab(pdf); } -@ +@ @c static void ttf_copy_font(PDF pdf) { @@ -1703,7 +1695,7 @@ static void ttf_copy_font(PDF pdf) ttf_write_dirtab(pdf); } -@ +@ @c void writettf(PDF pdf, fd_entry * fd) { @@ -1714,9 +1706,8 @@ void writettf(PDF pdf, fd_entry * fd) assert(is_truetype(fd_cur->fm)); assert(is_included(fd_cur->fm)); - if (is_subsetted(fd_cur->fm) && (fd_cur->fe == NULL) - && !is_subfont(fd_cur->fm)) { - luatex_fail("Subset TrueType must be a reencoded or a subfont"); + if (is_subsetted(fd_cur->fm) && (fd_cur->fe == NULL) && !is_subfont(fd_cur->fm)) { + normal_error("ttf font","subset must be a reencoded or a subfont"); } ttf_curbyte = 0; ttf_size = 0; @@ -1724,7 +1715,7 @@ void writettf(PDF pdf, fd_entry * fd) cur_file_name = luatex_find_file(fd_cur->fm->ff_name, find_truetype_file_callback); if (cur_file_name == NULL) { - luatex_fail("cannot find TrueType font file for reading (%s)", fd_cur->fm->ff_name); + formatted_error("ttf font","cannot find font file for reading '%s'", fd_cur->fm->ff_name); } callback_id = callback_defined(read_truetype_file_callback); if (callback_id > 0) { @@ -1732,11 +1723,11 @@ void writettf(PDF pdf, fd_entry * fd) &file_opened, &ttf_buffer, &ttf_size) && file_opened && ttf_size > 0) { } else { - luatex_fail("cannot open TrueType font file for reading (%s)", cur_file_name); + formatted_error("ttf font","cannot open font file for reading '%s'", cur_file_name); } } else { if (!ttf_open(cur_file_name)) { - luatex_fail("cannot open TrueType font file for reading (%s)", cur_file_name); + formatted_error("ttf font","cannot open font file for reading '%s'", cur_file_name); } ttf_read_file(); ttf_close(); @@ -1812,7 +1803,7 @@ static void do_writeotf(PDF pdf, fd_entry * fd) tex_printf(">>"); } -@ +@ @c void writeotf(PDF pdf, fd_entry * fd) { @@ -1829,7 +1820,7 @@ void writeotf(PDF pdf, fd_entry * fd) cur_file_name = luatex_find_file(fd_cur->fm->ff_name, find_opentype_file_callback); if (cur_file_name == NULL) { - luatex_fail("cannot find OpenType font file for reading (%s)", fd_cur->fm->ff_name); + formatted_error("otf font","cannot find font file for reading '%s'", fd_cur->fm->ff_name); } callback_id = callback_defined(read_opentype_file_callback); if (callback_id > 0) { @@ -1837,11 +1828,11 @@ void writeotf(PDF pdf, fd_entry * fd) &file_opened, &ttf_buffer, &ttf_size) && file_opened && ttf_size > 0) { } else { - luatex_fail("cannot open OpenType font file for reading (%s)", cur_file_name); + formatted_error("otf font","cannot open font file for reading '%s'", cur_file_name); } } else { if (!otf_open(cur_file_name)) { - luatex_fail("cannot open OpenType font file for reading (%s)", cur_file_name); + formatted_error("otf font","cannot open font file for reading '%s'", cur_file_name); } ttf_read_file(); ttf_close(); diff --git a/source/texk/web2c/luatexdir/font/writetype0.w b/source/texk/web2c/luatexdir/font/writetype0.w index 3f63b02ae12d2c68d25a0925ecdb8bd416e646aa..3053103c52465ad1198eb746531c8dbf4fbfee3c 100644 --- a/source/texk/web2c/luatexdir/font/writetype0.w +++ b/source/texk/web2c/luatexdir/font/writetype0.w @@ -51,8 +51,7 @@ void writetype0(PDF pdf, fd_entry * fd) cur_file_name = luatex_find_file(fd_cur->fm->ff_name, find_truetype_file_callback); if (cur_file_name == NULL) { - luatex_fail("cannot find OpenType font file for reading (%s)", - fd_cur->fm->ff_name); + formatted_error("type 0","cannot find file '%s'", fd_cur->fm->ff_name); } } callback_id = callback_defined(read_opentype_file_callback); @@ -61,13 +60,11 @@ void writetype0(PDF pdf, fd_entry * fd) &file_opened, &ttf_buffer, &ttf_size) && file_opened && ttf_size > 0) { } else { - luatex_fail("cannot open OpenType font file for reading (%s)", - cur_file_name); + formatted_error("type 0","cannot find file '%s'", cur_file_name); } } else { if (!otf_open(cur_file_name)) { - luatex_fail("cannot open OpenType font file for reading (%s)", - cur_file_name); + formatted_error("type 0","cannot find file '%s'", cur_file_name); } ttf_read_file(); ttf_close(); @@ -78,7 +75,7 @@ void writetype0(PDF pdf, fd_entry * fd) sfont = sfnt_open(ttf_buffer, ttf_size); if (sfont->type == SFNT_TYPE_TTC) i = ff_get_ttc_index(fd->fm->ff_name, fd->fm->ps_name); - + if (is_subsetted(fd_cur->fm)) { report_start_file(filetype_subset, cur_file_name); diff --git a/source/texk/web2c/luatexdir/font/writetype2.w b/source/texk/web2c/luatexdir/font/writetype2.w index 8980344afd77a816ce1135e472462dc1a30adad2..d5ce1aca40a1d7295e93646c8a1570c92f5016fd 100644 --- a/source/texk/web2c/luatexdir/font/writetype2.w +++ b/source/texk/web2c/luatexdir/font/writetype2.w @@ -152,7 +152,7 @@ boolean writetype2(PDF pdf, fd_entry * fd) cur_file_name = luatex_find_file(fd_cur->fm->ff_name, find_opentype_file_callback); if (cur_file_name == NULL) { - luatex_fail("cannot find OpenType font file for reading (%s)", fd_cur->fm->ff_name); + formatted_error("type 2","cannot find file '%s'", fd_cur->fm->ff_name); } callback_id = callback_defined(read_opentype_file_callback); if (callback_id > 0) { @@ -160,11 +160,11 @@ boolean writetype2(PDF pdf, fd_entry * fd) &file_opened, &ttf_buffer, &ttf_size) && file_opened && ttf_size > 0) { } else { - luatex_fail("cannot open OpenType font file for reading (%s)", cur_file_name); + formatted_error("type 2","cannot find file '%s'", cur_file_name); } } else { if (!otf_open(cur_file_name)) { - luatex_fail("cannot open OpenType font file for reading (%s)", cur_file_name); + formatted_error("type 2","cannot find file '%s'", cur_file_name); } ttf_read_file(); ttf_close(); diff --git a/source/texk/web2c/luatexdir/image/pdftoepdf.w b/source/texk/web2c/luatexdir/image/pdftoepdf.w index f58c0b12236cc322a18a65d62cd4e7a6ba7d11d5..b9d496ac9f0452dd84cce28d6dfc7a5309699098 100644 --- a/source/texk/web2c/luatexdir/image/pdftoepdf.w +++ b/source/texk/web2c/luatexdir/image/pdftoepdf.w @@ -50,7 +50,7 @@ static PdfDocument *findPdfDocument(char *file_path) { PdfDocument *pdf_doc, tmp; if (file_path == NULL) { - luatex_fail("empty filename when loading pdf file"); + normal_error("pdf backend","empty filename when loading pdf file"); } else if (PdfDocumentTree == NULL) { return NULL; } @@ -70,12 +70,12 @@ static char *get_file_checksum(const char *a, file_error_mode fe) time_t mtime = finfo.st_mtime; ck = (char *) malloc(PDF_CHECKSUM_SIZE); if (ck == NULL) - luatex_fail("PDF inclusion: out of memory while processing '%s'", a); + formatted_error("pdf inclusion","out of memory while processing '%s'", a); snprintf(ck, PDF_CHECKSUM_SIZE, "%" PRIu64 "_%" PRIu64, (uint64_t) size,(uint64_t) mtime); } else { switch (fe) { case FE_FAIL: - luatex_fail("PDF inclusion: could not stat() file '%s'", a); + formatted_error("pdf inclusion","could not stat() file '%s'", a); break; case FE_RETURN_NULL: if (ck != NULL) @@ -99,7 +99,7 @@ static char *get_stream_checksum (const char *str, unsigned long long str_size){ hash = 5381; ck = (char *) malloc(STRSTREAM_CHECKSUM_SIZE+1); if (ck == NULL) - luatex_fail("PDF inclusion: out of memory while processing a memstream"); + normal_error("pdf inclusion","out of memory while processing a memstream"); for(i=0; i<(unsigned int)(str_size); i++) { hash = ((hash << 5) + hash) + str[i]; /* hash * 33 + str[i] */ } @@ -137,7 +137,7 @@ PdfDocument *refPdfDocument(const char *file_path, file_error_mode fe) pdf_doc->pc = 0; } else { if (strncmp(pdf_doc->checksum, checksum, PDF_CHECKSUM_SIZE) != 0) { - luatex_fail("PDF inclusion: file has changed '%s'", file_path); + formatted_error("pdf inclusion","file has changed '%s'", file_path); } free(checksum); free(path_copy); @@ -150,7 +150,7 @@ PdfDocument *refPdfDocument(const char *file_path, file_error_mode fe) if (!doc->isOk() || !doc->okToPrint()) { switch (fe) { case FE_FAIL: - luatex_fail("PDF inclusion: reading PDF image failed"); + normal_error("pdf inclusion","reading image failed"); break; case FE_RETURN_NULL: delete doc; @@ -218,7 +218,7 @@ PdfDocument *refMemStreamPdfDocument(char *docstream, unsigned long long streams } else { /* As is now, checksum is in file_path, so this check should be useless. */ if (strncmp(pdf_doc->checksum, checksum, STRSTREAM_CHECKSUM_SIZE) != 0) { - luatex_fail("PDF inclusion: stream has changed '%s'", file_path); + formatted_error("pdf inclusion","stream has changed '%s'", file_path); } free(file_path); free(checksum); @@ -228,7 +228,7 @@ PdfDocument *refMemStreamPdfDocument(char *docstream, unsigned long long streams doc = new PDFDoc(docmemstream); /* takes ownership of docmemstream */ pdf_doc->pc++; if (!doc->isOk() || !doc->okToPrint()) { - luatex_fail("poppler: reading PDF Stream failed"); + normal_error("pdf inclusion","reading pdf Stream failed"); } pdf_doc->doc = doc; } @@ -304,8 +304,7 @@ static int addInObj(PDF pdf, PdfDocument * pdf_doc, Ref ref) ObjMap *obj_map; InObj *p, *q, *n; if (ref.num == 0) { - luatex_fail("PDF inclusion: reference to invalid object" - " (is the included pdf broken?)"); + normal_error("pdf inclusion","reference to invalid object (broken pdf)"); } if ((obj_map = findObjMap(pdf_doc, ref)) != NULL) return obj_map->out_num; @@ -495,7 +494,7 @@ static void copyObject(PDF pdf, PdfDocument * pdf_doc, Object * obj) case objError: case objEOF: case objNone: - luatex_fail("PDF inclusion: type <%s> cannot be copied", obj->getTypeName()); + formatted_error("pdf inclusion","type '%s' cannot be copied", obj->getTypeName()); break; default: /* poppler doesn't have any other types */ @@ -579,8 +578,8 @@ void flush_pdf_info(image_dict * idict) void read_pdf_info(image_dict * idict) { - PdfDocument *pdf_doc; - PDFDoc *doc; + PdfDocument *pdf_doc = NULL; + PDFDoc *doc = NULL; Catalog *catalog; Page *page; int rotate; @@ -599,7 +598,7 @@ void read_pdf_info(image_dict * idict) pdf_doc = findPdfDocument(img_filepath(idict)) ; pdf_doc->occurences++; } else { - luatex_fail("PDF inclusion: unknown document (1)"); + normal_error("pdf inclusion","unknown document"); } doc = pdf_doc->doc; catalog = doc->getCatalog(); @@ -611,11 +610,11 @@ void read_pdf_info(image_dict * idict) pdf_major_version_found = doc->getPDFMajorVersion(); pdf_minor_version_found = doc->getPDFMinorVersion(); if ((pdf_major_version_found > 1) || (pdf_minor_version_found > img_pdfminorversion(idict))) { - const char *msg = "PDF inclusion: found PDF version <%d.%d>, but at most version <1.%d> allowed"; + const char *msg = "PDF inclusion: found PDF version '%d.%d', but at most version '1.%d' allowed"; if (img_errorlevel(idict) > 0) { - luatex_fail(msg, pdf_major_version_found, pdf_minor_version_found, img_pdfminorversion(idict)); + formatted_error("pdf inclusion",msg, pdf_major_version_found, pdf_minor_version_found, img_pdfminorversion(idict)); } else { - luatex_warn(msg, pdf_major_version_found, pdf_minor_version_found, img_pdfminorversion(idict)); + formatted_warning("pdf inclusion",msg, pdf_major_version_found, pdf_minor_version_found, img_pdfminorversion(idict)); } } img_totalpages(idict) = catalog->getNumPages(); @@ -624,20 +623,17 @@ void read_pdf_info(image_dict * idict) GooString name(img_pagename(idict)); LinkDest *link = doc->findDest(&name); if (link == NULL || !link->isOk()) - luatex_fail("PDF inclusion: invalid destination <%s>", - img_pagename(idict)); + formatted_error("pdf inclusion","invalid destination '%s'",img_pagename(idict)); Ref ref = link->getPageRef(); img_pagenum(idict) = catalog->findPage(ref.num, ref.gen); if (img_pagenum(idict) == 0) - luatex_fail("PDF inclusion: destination is not a page <%s>", - img_pagename(idict)); + formatted_error("pdf inclusion","destination is not a page '%s'",img_pagename(idict)); delete link; } else { /* get page by number */ if (img_pagenum(idict) <= 0 || img_pagenum(idict) > img_totalpages(idict)) - luatex_fail("PDF inclusion: required page <%i> does not exist", - (int) img_pagenum(idict)); + formatted_error("pdf inclusion","required page '%i' does not exist",(int) img_pagenum(idict)); } /* get the required page */ page = catalog->getPage(img_pagenum(idict)); @@ -680,7 +676,7 @@ void read_pdf_info(image_dict * idict) img_rotation(idict) = 1; break; default: - luatex_warn("PDF inclusion: /Rotate parameter in PDF file not multiple of 90 degrees."); + formatted_warning("pdf inclusion","/Rotate parameter in PDF file not multiple of 90 degrees"); } /* currently unused info whether PDF contains a /Group */ if (page->getGroup() != NULL) @@ -713,8 +709,8 @@ void read_pdf_info(image_dict * idict) void write_epdf(PDF pdf, image_dict * idict) { - PdfDocument *pdf_doc; - PDFDoc *doc; + PdfDocument *pdf_doc = NULL; + PDFDoc *doc = NULL; Catalog *catalog; Page *page; Ref *pageref; @@ -724,9 +720,8 @@ void write_epdf(PDF pdf, image_dict * idict) int i, l; double bbox[4]; char s[256]; - const char *pagedictkeys[] = - { "Group", "LastModified", "Metadata", "PieceInfo", "Resources", - "SeparationInfo", NULL + const char *pagedictkeys[] = { + "Group", "LastModified", "Metadata", "PieceInfo", "Resources", "SeparationInfo", NULL }; /* open PDF file */ if (img_type(idict) == IMG_TYPE_PDF) { @@ -735,7 +730,7 @@ void write_epdf(PDF pdf, image_dict * idict) pdf_doc = findPdfDocument(img_filepath(idict)) ; pdf_doc->occurences++; } else { - luatex_fail("PDF inclusion: unknown document (2)"); + normal_error("pdf inclusion","unknown document"); } doc = pdf_doc->doc; catalog = doc->getCatalog(); @@ -788,7 +783,7 @@ void write_epdf(PDF pdf, image_dict * idict) */ pageDict->lookupNF("Metadata", &obj1); if (!obj1.isNull() && !obj1.isRef()) - luatex_warn("PDF inclusion: /Metadata must be indirect object"); + formatted_warning("pdf inclusion","/Metadata must be indirect object"); obj1.free(); /* copy selected items in Page dictionary */ for (i = 0; pagedictkeys[i] != NULL; i++) { @@ -826,7 +821,7 @@ void write_epdf(PDF pdf, image_dict * idict) op2->free(); }; if (!op1->isDict()) - luatex_warn("PDF inclusion: Page /Resources missing."); + formatted_warning("pdf inclusion","Page /Resources missing"); op1->free(); } obj1.free(); @@ -844,7 +839,7 @@ void write_epdf(PDF pdf, image_dict * idict) */ contents.streamGetDict()->lookup("F", &obj1); if (!obj1.isNull()) { - luatex_fail("PDF inclusion: Unsupported external stream"); + normal_error("pdf inclusion","unsupported external stream"); } obj1.free(); contents.streamGetDict()->lookup("Length", &obj1); @@ -945,7 +940,7 @@ void unrefPdfDocument(char *file_path) We either have a mismatch in ref and unref or we're somehow out of sync which can happen when we mess with the same file in lua and tex. */ - luatex_warn("PDF inclusion: there can be a mismatch in opening and closing file '%s'",file_path); + formatted_warning("pdf inclusion","there can be a mismatch in opening and closing file '%s'",file_path); } } diff --git a/source/texk/web2c/luatexdir/image/writeimg.w b/source/texk/web2c/luatexdir/image/writeimg.w index 62e4e33a723c9f24abc4947a3e01b064fc331d03..76ef593b67bf1720c1fe6ee3cf02d48bc187ec50 100644 --- a/source/texk/web2c/luatexdir/image/writeimg.w +++ b/source/texk/web2c/luatexdir/image/writeimg.w @@ -151,7 +151,7 @@ static void check_type_by_header(image_dict * idict) for (i = 0; (unsigned) i < MAX_HEADER; i++) { header[i] = (char) xgetc(file); if (feof(file)) - luatex_fail("reading image file failed"); + normal_error("pdf backend","reading image file failed"); } xfclose(file, img_filepath(idict)); /* tests */ @@ -295,7 +295,7 @@ void read_img(image_dict * idict) int callback_id; assert(idict != NULL); if (img_filename(idict) == NULL) { - luatex_fail("image file name missing"); + normal_error("pdf backend","image file name missing"); } callback_id = callback_defined(find_image_file_callback); if (img_filepath(idict) == NULL) { @@ -309,7 +309,7 @@ void read_img(image_dict * idict) img_filepath(idict) = kpse_find_file(img_filename(idict), kpse_tex_format, true); } if (img_filepath(idict) == NULL) { - luatex_fail("cannot find image file '%s'", img_filename(idict)); + formatted_error("pdf backend","cannot find image file '%s'", img_filename(idict)); } } recorder_record_input(img_filename(idict)); @@ -335,7 +335,7 @@ void read_img(image_dict * idict) read_jbig2_info(idict); break; default: - luatex_fail("internal error: unknown image type (2)"); + normal_error("pdf backend","internal error: unknown image type"); } cur_file_name = NULL; if (img_state(idict) < DICT_FILESCANNED) @@ -533,11 +533,11 @@ scaled_whd scale_img(image_dict * idict, scaled_whd alt_rule, int transform) xr = img_xres(idict); yr = img_yres(idict); if (x <= 0 || y <= 0 || xr < 0 || yr < 0) - luatex_fail("ext1: invalid image dimensions"); + normal_error("pdf backend","invalid image dimensions"); if (xr > 65535 || yr > 65535) { xr = 0; yr = 0; - luatex_warn("ext1: too large image resolution ignored"); + normal_warning("pdf backend","too large image resolution ignored"); } if (((transform - img_rotation(idict)) & 1) == 1) { tmp = x; @@ -596,7 +596,7 @@ void write_img(PDF pdf, image_dict * idict) write_pdfstream(pdf, idict); break; default: - luatex_fail("internal error: unknown image type (1)"); + normal_error("pdf backend","internal error: unknown image type"); } report_stop_file(filetype_image); if (img_type(idict) == IMG_TYPE_PNG) { @@ -619,7 +619,7 @@ void pdf_write_image(PDF pdf, int n) void check_pdfstream_dict(image_dict * idict) { if (!img_is_bbox(idict)) - luatex_fail("image.stream: no bbox given"); + normal_error("pdf backend","image.stream: no bbox given"); if (img_state(idict) < DICT_FILESCANNED) img_state(idict) = DICT_FILESCANNED; } diff --git a/source/texk/web2c/luatexdir/image/writejbig2.w b/source/texk/web2c/luatexdir/image/writejbig2.w index daeb93d8bf46e5dfb8f51e3b203a8d0c68b540ac..d1ed0a408d414459e60137aaa4597898f147307b 100644 --- a/source/texk/web2c/luatexdir/image/writejbig2.w +++ b/source/texk/web2c/luatexdir/image/writejbig2.w @@ -201,9 +201,9 @@ static int ygetc(FILE * stream) int c = getc(stream); if (c < 0) { if (c == EOF) - luatex_fail("readjbig2: getc() failed, premature end file"); + normal_error("readjbig2","premature end file"); else - luatex_fail("readjbig2: getc() failed, can't happen"); + normal_error("readjbig2","can't happen"); } return c; } @@ -376,8 +376,7 @@ static void readfilehdr(FILEINFO * fip) xfseek(fip->file, 0, SEEK_SET, fip->filepath); for (i = 0; i < 8; i++) if (ygetc(fip->file) != jbig2_id[i]) - luatex_fail - ("readfilehdr(): reading JBIG2 image file failed: ID string missing"); + normal_error("readjbig2","ID string missing"); /* Annex D.4.2 File header flags */ fip->filehdrflags = (unsigned int) ygetc(fip->file); fip->sequentialaccess = (fip->filehdrflags & 0x01) ? true : false; @@ -433,7 +432,7 @@ static void checkseghdrflags(SEGINFO * sip) case M_Extension: break; default: - luatex_fail("readjbig2: checkseghdrflags(), unknown segment type file"); + normal_error("readjbig2","unknown segment type file"); break; } } @@ -764,7 +763,7 @@ static void wr_jbig2(PDF pdf, image_dict * idict, FILEINFO * fip, boolean supported_jbig2(image_dict * idict) { if (img_pdfminorversion(idict) < 4) { - luatex_fail("readjbig2: you need to generate at least PDF 1.4"); + normal_error("readjbig2","you need to generate at least PDF 1.4"); return false; } else { return true; @@ -787,7 +786,7 @@ void read_jbig2_info(image_dict * idict) /* already an error done */ } if (img_pagenum(idict) < 1) { - luatex_fail("readjbig2: page must be > 0"); + normal_error("readjbig2","page must be > 0"); } if (file_tree == NULL) { file_tree = avl_create(comp_file_entry, NULL, &avl_xallocator); @@ -810,7 +809,7 @@ void read_jbig2_info(image_dict * idict) } pip = find_pageinfo(&(fip->pages), (unsigned long) img_pagenum(idict)); if (pip == NULL) { - luatex_fail("readjbig2: page %d not found in image file",(int) img_pagenum(idict)); + formatted_error("readjbig2","page %d not found in image file",(int) img_pagenum(idict)); } img_totalpages(idict) = (int) fip->numofpages; img_xsize(idict) = (int) pip->width; diff --git a/source/texk/web2c/luatexdir/image/writejp2.w b/source/texk/web2c/luatexdir/image/writejp2.w index b4be052f4c3aae9c6bc091128919a35fce7800fa..cb317e11928a4b6f9a147860ab4d8157bef78c51 100644 --- a/source/texk/web2c/luatexdir/image/writejp2.w +++ b/source/texk/web2c/luatexdir/image/writejp2.w @@ -66,7 +66,7 @@ static hdr_struct read_boxhdr(image_dict * idict) if (hdr.lbox == 1) hdr.lbox = read8bytes(img_file(idict)); if (hdr.lbox == 0 && hdr.tbox != BOX_JP2C) { - luatex_fail("readjp2: reading failed, LBox == 0"); + normal_error("readjp2","LBox == 0"); } return hdr; } @@ -125,18 +125,18 @@ static void scan_res(image_dict * idict, uint64_t epos_s) if (img_xres(idict) == 0 && img_yres(idict) == 0) { scan_resc_resd(idict); if (xftell(img_file(idict), img_filepath(idict)) != (long)epos) - luatex_fail("readjp2: reading image failed, resc box size inconsistent"); + normal_error("readjp2","resc box size inconsistent"); } break; case (BOX_RESD): scan_resc_resd(idict); if (xftell(img_file(idict), img_filepath(idict)) != (long)epos) - luatex_fail("readjp2: reading image failed, resd box size inconsistent"); + normal_error("readjp2","resd box size inconsistent"); break; default:; } if (epos > epos_s) - luatex_fail("reading JP2 image failed (res box size inconsistent)"); + normal_error("readjp2","res box size inconsistent"); if (epos == epos_s) break; xfseek(img_file(idict), (long) epos, SEEK_SET, img_filepath(idict)); @@ -159,7 +159,7 @@ static boolean scan_jp2h(image_dict * idict, uint64_t epos_s) case (BOX_IHDR): scan_ihdr(idict); if (xftell(img_file(idict), img_filepath(idict)) != (long)epos) - luatex_fail("readjp2: reading image failed, ihdr box size inconsistent"); + normal_error("readjp2","ihdr box size inconsistent"); ihdr_found = true; break; case (BOX_RES): @@ -168,7 +168,7 @@ static boolean scan_jp2h(image_dict * idict, uint64_t epos_s) default:; } if (epos > epos_s) - luatex_fail("readjp2: reading image failed, jp2h box size inconsistent"); + normal_error("readjp2","jp2h box size inconsistent"); if (epos == epos_s) break; xfseek(img_file(idict), (long) epos, SEEK_SET, img_filepath(idict)); @@ -199,10 +199,10 @@ void read_jp2_info(image_dict * idict) hdr_struct hdr; uint64_t spos, epos; if (img_type(idict) != IMG_TYPE_JP2) { - luatex_fail("readjp2: conflicting image dictionary"); + normal_error("readjp2","conflicting image dictionary"); } if (img_file(idict) != NULL) { - luatex_fail("readjp2: image data already read"); + normal_error("readjp2","image data already read"); } img_totalpages(idict) = 1; img_pagenum(idict) = 1; @@ -213,7 +213,7 @@ void read_jp2_info(image_dict * idict) img_jp2_ptr(idict)->length = (int) xftell(img_file(idict), img_filepath(idict)); xfseek(img_file(idict), 0, SEEK_SET, img_filepath(idict)); if (sizeof(uint64_t) < 8) { - luatex_fail("readjp2: reading image failed, size problem"); + normal_error("readjp2","size problem"); } spos = epos = 0; /* 1.5.1 JPEG 2000 Signature box */ @@ -224,7 +224,7 @@ void read_jp2_info(image_dict * idict) spos = epos; hdr = read_boxhdr(idict); if (hdr.tbox != BOX_FTYP) { - luatex_fail("readjp2: reading image failed, missing ftyp box"); + normal_error("readjp2","missing ftyp box"); } epos = spos + hdr.lbox; xfseek(img_file(idict), (long) epos, SEEK_SET, img_filepath(idict)); @@ -238,7 +238,7 @@ void read_jp2_info(image_dict * idict) break; case BOX_JP2C: if (!ihdr_found) - luatex_fail("readjp2: reading image failed, no ihdr box found"); + normal_error("readjp2","no ihdr box found"); break; default:; } @@ -263,7 +263,7 @@ static void reopen_jp2(image_dict * idict) read_jp2_info(idict); if (width != img_xsize(idict) || height != img_ysize(idict) || xres != img_xres(idict) || yres != img_yres(idict)) { - luatex_fail("writejp2: image dimensions have changed"); + normal_error("writejp2","image dimensions have changed"); } } @@ -289,7 +289,7 @@ void write_jp2(PDF pdf, image_dict * idict) l = (long unsigned int) img_jp2_ptr(idict)->length; xfseek(img_file(idict), 0, SEEK_SET, img_filepath(idict)); if (read_file_to_buf(pdf, img_file(idict), l) != l) - luatex_fail("writejp2: fread failed"); + normal_error("writejp2","fread failed"); pdf_end_stream(pdf); pdf_end_obj(pdf); /* always */ diff --git a/source/texk/web2c/luatexdir/image/writejpg.w b/source/texk/web2c/luatexdir/image/writejpg.w index ad7b99f941c400bcc67d522f580c95dde193c412..07c51f5e1d0c5ca92e27b7e23b9c0ef1cc5af94d 100644 --- a/source/texk/web2c/luatexdir/image/writejpg.w +++ b/source/texk/web2c/luatexdir/image/writejpg.w @@ -275,24 +275,24 @@ void read_jpg_info(image_dict * idict) unsigned short appmk, length; unsigned char jpg_id[] = "JFIF"; if (img_type(idict) != IMG_TYPE_JPG) { - luatex_fail("readjpg: conflicting image dictionary"); + normal_error("readjpg","conflicting image dictionary"); } if (img_file(idict) != NULL) { - luatex_fail("readjpg: image data already read"); + normal_error("readjpg","image data already read"); } img_totalpages(idict) = 1; img_pagenum(idict) = 1; img_xres(idict) = img_yres(idict) = 0; img_file(idict) = xfopen(img_filepath(idict), FOPEN_RBIN_MODE); if (img_file(idict) == NULL) { - luatex_fail("readjpg: unable to read image file"); + normal_error("readjpg","unable to read image file"); } img_jpg_ptr(idict) = xtalloc(1, jpg_img_struct); xfseek(img_file(idict), 0, SEEK_END, img_filepath(idict)); img_jpg_ptr(idict)->length = xftell(img_file(idict), img_filepath(idict)); xfseek(img_file(idict), 0, SEEK_SET, img_filepath(idict)); if ((unsigned int) read2bytes(img_file(idict)) != 0xFFD8) { - luatex_fail("readjpg: no header found"); + normal_error("readjpg","no header found"); } /* currently JFIF and Exif files allow extracting |img_xres| and |img_yres| */ appmk = read2bytes(img_file(idict)); @@ -313,8 +313,7 @@ void read_jpg_info(image_dict * idict) case 1: /* pixels per inch */ if ((img_xres(idict) == 1) || (img_yres(idict) == 1)) { - luatex_warn("readjpg: unusual resolution of %ddpi by %ddpi. ", - img_xres(idict), img_yres(idict)); + formatted_warning("readjpg","unusual resolution of %ddpi by %ddpi", img_xres(idict), img_yres(idict)); } break; case 2: @@ -355,9 +354,9 @@ void read_jpg_info(image_dict * idict) xfseek(img_file(idict), 0, SEEK_SET, img_filepath(idict)); while (1) { if (feof(img_file(idict))) { - luatex_fail("readjpg: premature file end"); + normal_error("readjpg","premature file end"); } else if (fgetc(img_file(idict)) != 0xFF) { - luatex_fail("readjpg: no marker found"); + normal_error("readjpg","no marker found"); } i = xgetc(img_file(idict)); switch (i) { @@ -371,11 +370,11 @@ void read_jpg_info(image_dict * idict) case M_SOF13: case M_SOF14: case M_SOF15: /* lossless */ - luatex_fail("readjpg: unsupported compression SOF_%d", i - M_SOF0); + formatted_error("readjpg","unsupported compression SOF_%d", i - M_SOF0); break; case M_SOF2: if (img_pdfminorversion(idict) <= 2) { - luatex_fail("readjpg: progressive DCT with PDF-1.2 is not permitted"); + normal_error("readjpg","progressive DCT with PDF-1.2 is not permitted"); } case M_SOF0: case M_SOF1: @@ -396,7 +395,7 @@ void read_jpg_info(image_dict * idict) img_procset(idict) |= PROCSET_IMAGE_C; break; default: - luatex_fail("readjpg: unsupported color space %i", (int) img_jpg_color(idict)); + formatted_error("readjpg","unsupported color space %i", (int) img_jpg_color(idict)); } /* So we can optionally keep open a file in img. @@ -424,7 +423,7 @@ void read_jpg_info(image_dict * idict) break; } } - luatex_fail("readjpg: unknown fatal error"); + normal_error("readjpg","unknown fatal error"); } @ @c @@ -440,7 +439,7 @@ static void reopen_jpg(image_dict * idict) img_keepopen(idict) = 1; read_jpg_info(idict); if (width != img_xsize(idict) || height != img_ysize(idict) || xres != img_xres(idict) || yres != img_yres(idict)) { - luatex_fail("writejpg: image dimensions have changed"); + normal_error("writejpg","image dimensions have changed"); } } @@ -488,7 +487,7 @@ void write_jpg(PDF pdf, image_dict * idict) pdf_end_array(pdf); break; default: - luatex_fail("writejpg: unsupported JPEG color space %i", (int) img_jpg_color(idict)); + formatted_error("writejpg","unsupported JPEG color space %i", (int) img_jpg_color(idict)); } } pdf_dict_add_name(pdf, "Filter", "DCTDecode"); @@ -497,7 +496,7 @@ void write_jpg(PDF pdf, image_dict * idict) l = (size_t) img_jpg_ptr(idict)->length; xfseek(img_file(idict), 0, SEEK_SET, img_filepath(idict)); if (read_file_to_buf(pdf, img_file(idict), l) != l) { - luatex_fail("writejpg: fread failed"); + normal_error("writejpg","fread failed"); } pdf_end_stream(pdf); pdf_end_obj(pdf); diff --git a/source/texk/web2c/luatexdir/image/writepng.w b/source/texk/web2c/luatexdir/image/writepng.w index a091c532ab53da33d6ab23c0859f9d74a4b9a6bc..412000c427faee62221aada995124b7be27c47df 100644 --- a/source/texk/web2c/luatexdir/image/writepng.w +++ b/source/texk/web2c/luatexdir/image/writepng.w @@ -58,10 +58,10 @@ void read_png_info(image_dict * idict) png_structp png_p; png_infop info_p; if (img_type(idict) != IMG_TYPE_PNG) { - luatex_fail("readpng: conflicting image dictionary"); + normal_error("readpng","conflicting image dictionary"); } if (img_file(idict) != NULL) { - luatex_fail("readpng: image data already read"); + normal_error("readpng","image data already read"); } img_totalpages(idict) = 1; img_pagenum(idict) = 1; @@ -69,15 +69,15 @@ void read_png_info(image_dict * idict) img_file(idict) = xfopen(img_filepath(idict), FOPEN_RBIN_MODE); img_png_ptr(idict) = xtalloc(1, png_img_struct); if ((png_p = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, warn)) == NULL) { - luatex_fail("readpng: png_create_read_struct() failed"); + normal_error("readpng","png_create_read_struct() failed"); } img_png_png_ptr(idict) = png_p; if ((info_p = png_create_info_struct(png_p)) == NULL) { - luatex_fail("readpng: png_create_info_struct() failed"); + normal_error("readpng","png_create_info_struct() failed"); } img_png_info_ptr(idict) = info_p; if (setjmp(png_jmpbuf(png_p))) { - luatex_fail("readpng: internal error"); + normal_error("readpng","internal error"); } #if PNG_LIBPNG_VER >= 10603 /* ignore possibly incorrect CMF bytes */ @@ -105,8 +105,7 @@ void read_png_info(image_dict * idict) img_procset(idict) |= PROCSET_IMAGE_C; break; default: - luatex_fail("readpng: unsupported type of color_type <%i>", - (int) png_get_color_type(png_p, info_p)); + formatted_error("readpng","unsupported type of color_type '%i'",(int) png_get_color_type(png_p, info_p)); } img_colordepth(idict) = png_get_bit_depth(png_p, info_p); /* @@ -245,7 +244,7 @@ static void write_png_gray(PDF pdf, image_dict * idict) xfree(row); } else { if (png_get_image_height(png_p, info_p) * png_get_rowbytes(png_p, info_p) >= 10240000L) { - luatex_warn("pngwrite: large interlaced bitmap might cause out of memory"); + formatted_warning("pngwrite","large interlaced bitmap might cause out of memory"); } rows = xtalloc(png_get_image_height(png_p, info_p), png_bytep); for (i = 0; i < (int) png_get_image_height(png_p, info_p); i++) { @@ -288,7 +287,7 @@ static void write_png_gray_alpha(PDF pdf, image_dict * idict) xfree(row); } else { if (png_get_image_height(png_p, info_p) * png_get_rowbytes(png_p, info_p) >= 10240000L) { - luatex_warn("pngwrite: large interlaced bitmap might cause out of memory"); + formatted_warning("pngwrite","large interlaced bitmap might cause out of memory"); } rows = xtalloc(png_get_image_height(png_p, info_p), png_bytep); for (i = 0; i < (int) png_get_image_height(png_p, info_p); i++) { @@ -337,7 +336,7 @@ static void write_png_rgb_alpha(PDF pdf, image_dict * idict) xfree(row); } else { if (png_get_image_height(png_p, info_p) * png_get_rowbytes(png_p, info_p) >= 10240000L) { - luatex_warn("pngwrite: large interlaced bitmap might cause out of memory"); + formatted_warning("pngwrite","large interlaced bitmap might cause out of memory"); } rows = xtalloc(png_get_image_height(png_p, info_p), png_bytep); for (i = 0; i < (int) png_get_image_height(png_p, info_p); i++) { @@ -375,7 +374,7 @@ static int spng_getint(FILE * f) { unsigned char buf[4]; if (fread(buf, 1, 4, f) != 4) { - luatex_fail("writepng: reading chunk type failed"); + normal_error("writepng", "reading chunk type failed"); } return ((((((int) buf[0] << 8) + buf[1]) << 8) + buf[2]) << 8) + buf[3]; } @@ -397,7 +396,7 @@ static void copy_png(PDF pdf, image_dict * idict) f = (FILE *) png_get_io_ptr(png_p); /* 1st pass to find overall stream /Length */ if (fseek(f, 8, SEEK_SET) != 0) - luatex_fail("writepng: fseek in file failed (1)"); + normal_error("writepng", "fseek in file failed"); do { len = spng_getint(f); type = spng_getint(f); @@ -409,7 +408,7 @@ static void copy_png(PDF pdf, image_dict * idict) streamlength += len; default: if (fseek(f, len + 4, SEEK_CUR) != 0) { - luatex_fail("writepng: fseek in file failed (2)"); + normal_error("writepng", "fseek in file failed"); } } } while (endflag == false); @@ -428,7 +427,7 @@ static void copy_png(PDF pdf, image_dict * idict) /* 2nd pass to copy data */ endflag = false; if (fseek(f, 8, SEEK_SET) != 0) - luatex_fail("writepng: fseek in file failed (3)"); + normal_error("writepng", "fseek in file failed"); do { len = spng_getint(f); type = spng_getint(f); @@ -436,13 +435,13 @@ static void copy_png(PDF pdf, image_dict * idict) case SPNG_CHUNK_IDAT: /* do copy */ if (idat == 2) { - luatex_fail("writepng: IDAT chunk sequence broken"); + normal_error("writepng", "IDAT chunk sequence broken"); } idat = 1; if (read_file_to_buf(pdf, f, len) != len) { - luatex_fail("writepng: fread failed"); + normal_error("writepng", "fread failed"); } else if (fseek(f, 4, SEEK_CUR) != 0) { - luatex_fail("writepng: fseek in file failed (4)"); + normal_error("writepng", "fseek in file failed"); } break; case SPNG_CHUNK_IEND: @@ -453,7 +452,7 @@ static void copy_png(PDF pdf, image_dict * idict) if (idat == 1) idat = 2; if (fseek(f, len + 4, SEEK_CUR) != 0) - luatex_fail("writepng: fseek in file failed (5)"); + normal_error("writepng", "fseek in file failed"); } } while (endflag == false); pdf_end_stream(pdf); @@ -474,7 +473,7 @@ static void reopen_png(image_dict * idict) img_keepopen(idict) = 1; read_png_info(idict); if (width != img_xsize(idict) || height != img_ysize(idict) || xres != img_xres(idict) || yres != img_yres(idict)) { - luatex_fail("writepng: image dimensions have changed"); + normal_error("writepng", "image dimensions have changed"); } } @@ -570,7 +569,7 @@ void write_png(PDF pdf, image_dict * idict) pdf_dict_add_name(pdf, "ColorSpace", "DeviceRGB"); break; default: - luatex_fail("writepng: unsupported color_type <%i>", png_get_color_type(png_p, info_p)); + formatted_error("writepng", "unsupported color_type '%i'", png_get_color_type(png_p, info_p)); } } if (png_copy @@ -592,34 +591,34 @@ void write_png(PDF pdf, image_dict * idict) } else { if (img_errorlevel(idict) > 1) { if (!png_copy) - luatex_warn("pngcopy: failed"); + normal_warning("pngcopy","failed"); if (!(pdf->minor_version > 1)) - luatex_warn("pngcopy: skipped because minorversion=%d ", pdf->minor_version); + formatted_warning("pngcopy","skipped because minorversion is '%d'", pdf->minor_version); if (!(png_get_interlace_type(png_p, info_p) == PNG_INTERLACE_NONE)) - luatex_warn("pngcopy: skipped because of interlacing"); + normal_warning("pngcopy","skipped because of interlacing"); if (!((png_get_color_type(png_p, info_p) == PNG_COLOR_TYPE_GRAY) || (png_get_color_type(png_p, info_p) == PNG_COLOR_TYPE_RGB))) - luatex_warn("pngcopy: skipped because of colortype"); + normal_warning("pngcopy","skipped because of colortype"); if (pdf->image_apply_gamma) - luatex_warn("pngcopy: skipped because of gamma (1)"); + normal_warning("pngcopy","skipped because of gamma (1)"); if (!(!png_get_valid(png_p, info_p, PNG_INFO_gAMA) || int_file_gamma == PNG_FP_1)) - luatex_warn("pngcopy: skipped because of gamma (2)"); + normal_warning("pngcopy","skipped because of gamma (2)"); if (png_get_valid(png_p, info_p, PNG_INFO_cHRM)) - luatex_warn("pngcopy: skipped because of cHRM"); + normal_warning("pngcopy","skipped because of cHRM"); if (png_get_valid(png_p, info_p, PNG_INFO_iCCP)) - luatex_warn("pngcopy: skipped because of iCCP"); + normal_warning("pngcopy","skipped because of iCCP"); if (png_get_valid(png_p, info_p, PNG_INFO_sBIT)) - luatex_warn("pngcopy: skipped because of sBIT"); + normal_warning("pngcopy","skipped because of sBIT"); if (png_get_valid(png_p, info_p, PNG_INFO_sRGB)) - luatex_warn("pngcopy: skipped because of sRGB"); + normal_warning("pngcopy","skipped because of sRGB"); if (png_get_valid(png_p, info_p, PNG_INFO_bKGD)) - luatex_warn("pngcopy: skipped because of bKGD"); + normal_warning("pngcopy","skipped because of bKGD"); if (png_get_valid(png_p, info_p, PNG_INFO_hIST)) - luatex_warn("pngcopy: skipped because of hIST"); + normal_warning("pngcopy","skipped because of hIST"); if (png_get_valid(png_p, info_p, PNG_INFO_tRNS)) - luatex_warn("pngcopy: skipped because of tRNS"); + normal_warning("pngcopy","skipped because of tRNS"); if (png_get_valid(png_p, info_p, PNG_INFO_sPLT)) - luatex_warn("pngcopy: skipped because of sPLT"); + normal_warning("pngcopy","skipped because of sPLT"); } switch (png_get_color_type(png_p, info_p)) { case PNG_COLOR_TYPE_PALETTE: diff --git a/source/texk/web2c/luatexdir/lua/lnewtokenlib.c b/source/texk/web2c/luatexdir/lua/lnewtokenlib.c index 1b17cf8542b23558d28ba95f2bfec33848f78443..9ba422d654a26b48f251502191691badc9265401 100644 --- a/source/texk/web2c/luatexdir/lua/lnewtokenlib.c +++ b/source/texk/web2c/luatexdir/lua/lnewtokenlib.c @@ -119,7 +119,7 @@ lua_token *check_istoken(lua_State * L, int ud) lua_token *p = maybe_istoken(L, ud); if (p != NULL) return p; - luatex_fail("There should have been a lua <token> here, not an object with type %s!", luaL_typename(L, ud)); + formatted_error("token lib","lua <token> expected, not an object with type %s", luaL_typename(L, ud)); return NULL; } diff --git a/source/texk/web2c/luatexdir/lua/lnodelib.c b/source/texk/web2c/luatexdir/lua/lnodelib.c index 8723bd7e4fcf29a15a47a7e2ae62c15255f871b9..e4d3dd253967d431f465e5fdee0c310b7fc29989 100644 --- a/source/texk/web2c/luatexdir/lua/lnodelib.c +++ b/source/texk/web2c/luatexdir/lua/lnodelib.c @@ -269,7 +269,7 @@ halfword *check_isnode(lua_State * L, int i) halfword *p = maybe_isnode(L, i); if (p != NULL) return p; - luatex_fail("There should have been a lua <node> here, not an object with type %s!", luaL_typename(L, i)); + formatted_error("node lib","lua <node> expected, not an object with type %s", luaL_typename(L, i)); return NULL; } @@ -4403,15 +4403,6 @@ static int lua_nodelib_direct_has_glyph(lua_State * L) return 1; } - -/* depricated */ - -static int lua_nodelib_first_character(lua_State * L) -{ - luatex_warn("node.first_character() is deprecated, please update to node.first_glyph()"); - return lua_nodelib_first_glyph(L); -} - /* this is too simplistic, but it helps Hans to get going */ static halfword do_ligature_n(halfword prev, halfword stop, halfword lig) @@ -4530,7 +4521,7 @@ static int lua_nodelib_currentattr(lua_State * L) return 1; } else { /* assign */ - luatex_warn("Assignment via node.current_attr(<list>) is not supported (yet)"); + normal_warning("node lib","assignment via node.current_attr(<list>) is not supported (yet)"); return 0; } } @@ -6656,7 +6647,6 @@ static const struct luaL_Reg direct_nodelib_f[] = { {"end_of_math", lua_nodelib_direct_end_of_math}, /* {"family_font", lua_nodelib_mfont}, */ /* no node argument */ /* {"fields", lua_nodelib_fields}, */ /* no node argument */ - /* {"first_character", lua_nodelib_first_character}, */ /* obsolete */ {"first_glyph", lua_nodelib_direct_first_glyph}, {"flush_list", lua_nodelib_direct_flush_list}, {"flush_node", lua_nodelib_direct_flush_node}, @@ -6746,7 +6736,6 @@ static const struct luaL_Reg nodelib_f[] = { {"family_font", lua_nodelib_mfont}, {"fields", lua_nodelib_fields}, {"subtypes", lua_nodelib_subtypes}, - {"first_character", lua_nodelib_first_character}, {"first_glyph", lua_nodelib_first_glyph}, {"flush_list", lua_nodelib_flush_list}, {"flush_node", lua_nodelib_flush_node}, diff --git a/source/texk/web2c/luatexdir/lua/luajitstuff.w b/source/texk/web2c/luatexdir/lua/luajitstuff.w index be0dcd3c37fca144dc9b070b5425a1c7d3e62020..e19338027b015832708e0107b70dbb6a0a4ff0cc 100644 --- a/source/texk/web2c/luatexdir/lua/luajitstuff.w +++ b/source/texk/web2c/luatexdir/lua/luajitstuff.w @@ -586,7 +586,7 @@ lua_State *luatex_error(lua_State * L, int is_fatal) lua_close(L); return (lua_State *) NULL; } else { - normal_warning("lua",err,true,true); + normal_warning("lua",err); return L; } } diff --git a/source/texk/web2c/luatexdir/lua/luastuff.w b/source/texk/web2c/luatexdir/lua/luastuff.w index 111e1516d5d156f062018e72c0d101e7e95a8c83..6fac3afbf3227349b2b2265412774a9e3811b79b 100644 --- a/source/texk/web2c/luatexdir/lua/luastuff.w +++ b/source/texk/web2c/luatexdir/lua/luastuff.w @@ -534,7 +534,7 @@ lua_State *luatex_error(lua_State * L, int is_fatal) lua_close(L); return (lua_State *) NULL; } else { - normal_warning("lua",err,true,true); + normal_warning("lua",err); return L; } } diff --git a/source/texk/web2c/luatexdir/luatex-common.h b/source/texk/web2c/luatexdir/luatex-common.h index 379c7b2f43c14c3cb32ef5bda2fbdf7eab1628dc..073d6ad1c5bce1e18561b74ca9c44c3f6c590c80 100644 --- a/source/texk/web2c/luatexdir/luatex-common.h +++ b/source/texk/web2c/luatexdir/luatex-common.h @@ -25,9 +25,11 @@ # define LUATEX_COMMON_H /* utils.c */ -__attribute__ ((format(printf, 1, 2))) -extern void luatex_warn(const char *fmt, ...); -__attribute__ ((noreturn, format(printf, 1, 2))) -extern void luatex_fail(const char *fmt, ...); + +extern void tex_error(const char *msg, const char **hlp); +extern void normal_error(const char *t, const char *p); +extern void normal_warning(const char *t, const char *p); +extern void formatted_error(const char *t, const char *fmt, ...); +extern void formatted_warning(const char *t, const char *fmt, ...); #endif /* LUATEX_COMMON_H */ diff --git a/source/texk/web2c/luatexdir/pdf/pdfannot.w b/source/texk/web2c/luatexdir/pdf/pdfannot.w index 67bcc69a40c68b79e632088a8432e6a98f4d6aa2..e98f60cf7b5513bbb6c7ce714a3c98e1e126692d 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfannot.w +++ b/source/texk/web2c/luatexdir/pdf/pdfannot.w @@ -30,7 +30,7 @@ void do_annot(PDF pdf, halfword p, halfword parent_box, scaledpos cur) scaled_whd alt_rule; int k; if (global_shipping_mode == SHIPPING_FORM) - normal_error("pdf backend", "annotations cannot be inside an XForm"); + normal_error("pdf backend", "annotations cannot be inside an xform"); if (doing_leaders) return; if (is_obj_scheduled(pdf, pdf_annot_objnum(p))) { diff --git a/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w b/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w index eb48ab89ca62b508c7950e52fc63de94129c9d44..4aeac4fcec583ceb7143a69d21fcce6f5a83dafb 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w +++ b/source/texk/web2c/luatexdir/pdf/pdfcolorstack.w @@ -233,8 +233,7 @@ int colorstackpop(int colstack_no) if (global_shipping_mode == SHIPPING_PAGE) { if (colstack->page_used == 0) { - luatex_warn("pop empty color page stack %u", - (unsigned int) colstack_no); + formatted_warning("pdf backend","pop empty color page stack %u",(unsigned int) colstack_no); return colstack->literal_mode; } xfree(colstack->page_current); @@ -242,8 +241,7 @@ int colorstackpop(int colstack_no) put_cstring_on_str_pool(colstack->page_current); } else { if (colstack->form_used == 0) { - luatex_warn("pop empty color form stack %u", - (unsigned int) colstack_no); + formatted_warning("pdf backend","pop empty color form stack %u",(unsigned int) colstack_no); return colstack->literal_mode; } xfree(colstack->form_current); diff --git a/source/texk/web2c/luatexdir/pdf/pdfdest.h b/source/texk/web2c/luatexdir/pdf/pdfdest.h index 4c2f1911931be4dcb61ac45df742df8193da6093..d57a4a0228ec8d126291ad4ae31c74ec013dd03f 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfdest.h +++ b/source/texk/web2c/luatexdir/pdf/pdfdest.h @@ -52,8 +52,6 @@ typedef enum { extern void append_dest_name(PDF, char *, int); extern void do_dest(PDF pdf, halfword p, halfword parent_box, scaledpos cur); -extern void warn_dest_dup(int id, small_number byname, const char *s1, - const char *s2); extern void write_out_pdf_mark_destinations(PDF); extern void scan_pdfdest(PDF); diff --git a/source/texk/web2c/luatexdir/pdf/pdfdest.w b/source/texk/web2c/luatexdir/pdf/pdfdest.w index cb4478a365fefc0511b1affb9fc49337fd66891a..ee55fdbfb314c032aae0a2fd4eb0a1990c122059 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfdest.w +++ b/source/texk/web2c/luatexdir/pdf/pdfdest.w @@ -38,8 +38,7 @@ void append_dest_name(PDF pdf, char *s, int n) { int a; if (pdf->dest_names_ptr == sup_dest_names_size) - overflow("number of destination names (dest_names_size)", - (unsigned) pdf->dest_names_size); + overflow("number of destination names (dest_names_size)",(unsigned) pdf->dest_names_size); if (pdf->dest_names_ptr == pdf->dest_names_size) { a = pdf->dest_names_size / 5; if (pdf->dest_names_size < sup_dest_names_size - a) @@ -60,23 +59,17 @@ void append_dest_name(PDF pdf, char *s, int n) with the same identifier already exists and give a warning if needed. @c -void warn_dest_dup(int id, small_number byname, const char *s1, const char *s2) +static void warn_dest_dup(int id, small_number byname) { - normal_warning(s1, "destination with the same identifier (", false, false); if (byname > 0) { - tprint("name"); - print_mark(id); + char *ss = tokenlist_to_cstring(id, true, NULL); + formatted_warning("pdf backend", "ignoring duplicate destination with the name '%s'",ss); } else { - tprint("num"); - print_int(id); + formatted_warning("pdf backend", "ignoring duplicate destination with the num '%d'",id); } - tprint(") "); - tprint(s2); - print_ln(); - show_context(); + /* no longer the annoying context */ } - @ @c void do_dest(PDF pdf, halfword p, halfword parent_box, scaledpos cur) { @@ -84,13 +77,12 @@ void do_dest(PDF pdf, halfword p, halfword parent_box, scaledpos cur) scaled_whd alt_rule; int k; if (global_shipping_mode == SHIPPING_FORM) - normal_error("pdf backend", "destinations cannot be inside an XForm"); + normal_error("pdf backend", "destinations cannot be inside an xform"); if (doing_leaders) return; k = pdf_get_obj(pdf, obj_type_dest, pdf_dest_id(p), pdf_dest_named_id(p)); if (obj_dest_ptr(pdf, k) != null) { - warn_dest_dup(pdf_dest_id(p), (small_number) pdf_dest_named_id(p), - "pdf backend", "has been already used, duplicate ignored"); + warn_dest_dup(pdf_dest_id(p), (small_number) pdf_dest_named_id(p)); return; } obj_dest_ptr(pdf, k) = p; @@ -271,13 +263,10 @@ void scan_pdfdest(PDF pdf) k = find_obj(pdf, obj_type_dest, i, true); flush_str(i); } else { - k = find_obj(pdf, obj_type_dest, pdf_dest_id(cur_list.tail_field), - false); + k = find_obj(pdf, obj_type_dest, pdf_dest_id(cur_list.tail_field), false); } if ((k != 0) && (obj_dest_ptr(pdf, k) != null)) { - warn_dest_dup(pdf_dest_id(cur_list.tail_field), - (small_number) pdf_dest_named_id(cur_list.tail_field), - "pdf backend", "has been already used, duplicate ignored"); + warn_dest_dup(pdf_dest_id(cur_list.tail_field),(small_number) pdf_dest_named_id(cur_list.tail_field)); flush_node_list(cur_list.tail_field); cur_list.tail_field = q; vlink(q) = null; diff --git a/source/texk/web2c/luatexdir/pdf/pdfgen.w b/source/texk/web2c/luatexdir/pdf/pdfgen.w index ffbc49d571c2a1396e54f731a23b93446abc120b..4a166e6a000982661def3ac780908b34bb14dd0b 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfgen.w +++ b/source/texk/web2c/luatexdir/pdf/pdfgen.w @@ -30,7 +30,7 @@ #define check_nprintf(size_get, size_want) \ if ((unsigned)(size_get) >= (unsigned)(size_want)) \ - luatex_fail ("snprintf failed: file %s, line %d", __FILE__, __LINE__); + formatted_error("pdf backend","snprintf() failed in file %s at line %d", __FILE__, __LINE__); PDF static_pdf = NULL; @@ -291,9 +291,9 @@ void fix_pdf_minorversion(PDF pdf) @ @c #define ZIP_BUF_SIZE 32768 -#define check_err(f, fn) \ - if (f != Z_OK) \ - luatex_fail("zlib: %s() failed (error code %d)", fn, f) +#define check_err(f, fn) \ + if (f != Z_OK) \ + formatted_error("pdf backend","zlib %s() failed (error code %d)", fn, f) @ @c static void write_zip(PDF pdf) @@ -304,11 +304,6 @@ static void write_zip(PDF pdf) z_stream *s = pdf->c_stream; boolean finish = pdf->zip_write_state == ZIP_FINISH; assert(pdf->compress_level > 0); - /* This was just to suppress the filename report in |luatex_fail| - but zlib errors are rare enough (especially now that the - compress level is fixed) that I don't care about the slightly - ugly error message that could result. - */ #if 0 cur_file_name = NULL; #endif @@ -354,7 +349,7 @@ static void write_zip(PDF pdf) } err = deflate(s, flush); if (err != Z_OK && err != Z_STREAM_END) - luatex_fail("zlib: deflate() failed (error code %d)", err); + formatted_error("pdf backend","zlib deflate() failed (error code %d)", err); } pdf->stream_length = (off_t) s->total_out; } @@ -778,11 +773,9 @@ void addto_page_resources(PDF pdf, pdf_obj_type t, int k) assert(re != NULL); assert(t <= PDF_OBJ_TYPE_MAX); if (re->resources_tree == NULL) { - re->resources_tree = - avl_create(comp_page_resources, NULL, &avl_xallocator); + re->resources_tree = avl_create(comp_page_resources, NULL, &avl_xallocator); if (re->resources_tree == NULL) - luatex_fail - ("addto_page_resources(): avl_create() page_resource_tree failed"); + formatted_error("pdf backend","addto_page_resources(): avl_create() page_resource_tree failed"); } tmp.obj_type = t; pr = (pr_entry *) avl_find(re->resources_tree, &tmp); @@ -792,8 +785,7 @@ void addto_page_resources(PDF pdf, pdf_obj_type t, int k) pr->list = NULL; pp = avl_probe(re->resources_tree, pr); if (pp == NULL) - luatex_fail - ("addto_page_resources(): avl_probe() out of memory in insertion"); + formatted_error("pdf backend","addto_page_resources(): avl_probe() out of memory in insertion"); } if (pr->list == NULL) { item = xtalloc(1, pdf_object_list); @@ -969,7 +961,7 @@ static void init_pdf_outputparameters(PDF pdf) pdf->os_enable = true; } else { if (pdf->objcompresslevel > 0) { - normal_warning("pdf backend","objcompresslevel > 0 requires minorversion > 4", true, true); + normal_warning("pdf backend","objcompresslevel > 0 requires minorversion > 4"); pdf->objcompresslevel = 0; } pdf->os_enable = false; @@ -1452,7 +1444,7 @@ static void print_ID(PDF pdf) md5_append(&state, (const md5_byte_t *) time_str, (int) size); /* get the file name */ if (getcwd(pwd, sizeof(pwd)) == NULL) - luatex_fail("getcwd() failed (%s), (path too long?)", strerror(errno)); + formatted_error("pdf backend","getcwd() failed (%s), (path too long?)", strerror(errno)); #ifdef WIN32 { char *p; @@ -1652,7 +1644,7 @@ void check_o_mode(PDF pdf, const char *s, int o_mode_bitpattern, boolean strict) if (strict) normal_error("pdf backend", warn_string); else - normal_warning("pdf backend", warn_string, true, true); + normal_warning("pdf backend", warn_string); } else if (strict) ensure_output_state(pdf, ST_HEADER_WRITTEN); } @@ -1719,8 +1711,7 @@ void pdf_begin_page(PDF pdf) pdf->page_resources = xtalloc(1, pdf_resource_struct); pdf->page_resources->resources_tree = NULL; } - pdf->page_resources->last_resources = - pdf_create_obj(pdf, obj_type_others, 0); + pdf->page_resources->last_resources = pdf_create_obj(pdf, obj_type_others, 0); reset_page_resources(pdf); if (global_shipping_mode == SHIPPING_PAGE) { @@ -1853,7 +1844,7 @@ void pdf_end_page(PDF pdf) /* Finish stream of page/form contents */ pdf_goto_pagemode(pdf); if (pos_stack_used > 0) { - luatex_fail("%u unmatched 'save' after %s shipout", (unsigned int) pos_stack_used, + formatted_error("pdf backend","%u unmatched 'save' after %s shipout", (unsigned int) pos_stack_used, ((global_shipping_mode == SHIPPING_PAGE) ? "page" : "form")); } pdf_end_stream(pdf); @@ -2126,19 +2117,12 @@ static void check_nonexisting_destinations(PDF pdf) int k; for (k = pdf->head_tab[obj_type_dest]; k != 0; k = obj_link(pdf, k)) { if (obj_dest_ptr(pdf, k) == null) { - normal_warning("pdf backend", "dest ", false, false); if (obj_info(pdf, k) < 0) { - tprint("name{"); - print(-obj_info(pdf, k)); - tprint("}"); + char *ss = makecstring(-obj_info(pdf, k)); + formatted_warning("pdf backend", "unreferenced destination with name '%s'",ss); } else { - tprint("num"); - print_int(obj_info(pdf, k)); + formatted_warning("pdf backend", "unreferenced destination with num '%d'",obj_info(pdf,k)); } - tprint - (" has been referenced but does not exist, replaced by a fixed one"); - print_ln(); - print_ln(); pdf_begin_obj(pdf, k, OBJSTM_ALWAYS); pdf_begin_array(pdf); @@ -2158,13 +2142,8 @@ static void check_nonexisting_pages(PDF pdf) struct avl_table *page_tree = pdf->obj_tree[obj_type_page]; avl_t_init(&t, page_tree); /* search from the end backward until the last real page is found */ - for (p = avl_t_last(&t, page_tree); - p != NULL && obj_aux(pdf, p->objptr) == 0; p = avl_t_prev(&t)) { - normal_warning("pdf backend", "Page ", false, false); - print_int(obj_info(pdf, p->objptr)); - tprint(" has been referenced but does not exist!"); - print_ln(); - print_ln(); + for (p = avl_t_last(&t, page_tree); p != NULL && obj_aux(pdf, p->objptr) == 0; p = avl_t_prev(&t)) { + formatted_warning("pdf backend", "page %s has been referenced but does not exist",obj_info(pdf, p->objptr)); } } @@ -2286,13 +2265,12 @@ void finish_pdf_file(PDF pdf, int luatexversion, str_number luatexrevision) if (total_pages == 0) { if (callback_id == 0) { - tprint_nl("No pages of output."); - print_ln(); + normal_warning("pdf backend","no pages of output."); } else if (callback_id > 0) { run_callback(callback_id, "->"); } if (pdf->gone > 0) - garbage_warning(); + normal_error("pdf backend","dangling objects discarded, no output file produced."); } else { if (pdf->draftmode == 0) { pdf_flush(pdf); /* to make sure that the output file name has been already created */ @@ -2313,23 +2291,10 @@ void finish_pdf_file(PDF pdf, int luatexversion, str_number luatexrevision) pdf_mark_char(i, j); if ((pdf_font_attr(i) == 0) && (pdf_font_attr(k) != 0)) { set_pdf_font_attr(i, pdf_font_attr(k)); - } else if ((pdf_font_attr(k) == 0) - && (pdf_font_attr(i) != 0)) { + } else if ((pdf_font_attr(k) == 0) && (pdf_font_attr(i) != 0)) { set_pdf_font_attr(k, pdf_font_attr(i)); - } else if ((pdf_font_attr(i) != 0) - && (pdf_font_attr(k) != 0) - && - (!str_eq_str - (pdf_font_attr(i), pdf_font_attr(k)))) { - normal_warning("pdf backend","fontattr in ", false, false); - print_font_identifier(i); - tprint(" and "); - print_font_identifier(k); - tprint(" have conflicting attributes; the attributes assigned to "); - print_font_identifier(i); - tprint(" are ignored"); - print_ln(); - print_ln(); + } else if ((pdf_font_attr(i) != 0) && (pdf_font_attr(k) != 0) && (!str_eq_str(pdf_font_attr(i), pdf_font_attr(k)))) { + formatted_warning("pdf backend","fontattr of font %d and %d are conflicting, %k is used",i,k,i); } } } @@ -2540,7 +2505,7 @@ void finish_pdf_file(PDF pdf, int luatexversion, str_number luatexrevision) if (pdf->draftmode == 0) close_file(pdf->file); else - normal_warning("pdf backend","draftmode enabled, not changing output pdf",true, true); + normal_warning("pdf backend","draftmode enabled, not changing output pdf"); } if (callback_id == 0) { diff --git a/source/texk/web2c/luatexdir/pdf/pdflink.w b/source/texk/web2c/luatexdir/pdf/pdflink.w index 89fb10575676588b17e3b099c9edfd1e8830b4ca..28e7998ef1e39a5cada1ee8189b1442a25eb2503 100644 --- a/source/texk/web2c/luatexdir/pdf/pdflink.w +++ b/source/texk/web2c/luatexdir/pdf/pdflink.w @@ -54,7 +54,7 @@ void do_link(PDF pdf, halfword p, halfword parent_box, scaledpos cur) if (type(p) == vlist_node) normal_error("pdf backend", "'startlink' ended up in vlist"); if (global_shipping_mode == SHIPPING_FORM) - normal_error("pdf backend", "link annotations cannot be inside an XForm"); + normal_error("pdf backend", "link annotations cannot be inside an xform"); assert(type(parent_box) == hlist_node); if (is_obj_scheduled(pdf, pdf_link_objnum(p))) pdf_link_objnum(p) = pdf_create_obj(pdf, obj_type_others, 0); diff --git a/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w b/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w index 4c88dec61822f688a325ba322071f967f9defdd1..01ec4f93feceffb1db69a988f22ebc34e86354d7 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w +++ b/source/texk/web2c/luatexdir/pdf/pdfsaverestore.w @@ -53,14 +53,14 @@ static void checkpdfrestore(scaledpos pos) { scaledpos diff; if (pos_stack_used == 0) { - luatex_warn("%s", "'restore' is missing a 'save'"); + normal_warning("pdf backend", "'restore' is missing a 'save'"); return; } pos_stack_used--; diff.h = pos.h - pos_stack[pos_stack_used].pos.h; diff.v = pos.v - pos_stack[pos_stack_used].pos.v; if (diff.h != 0 || diff.v != 0) { - luatex_warn("misplaced 'restore' by (%dsp, %dsp)", (int) diff.h, (int) diff.v); + formatted_warning("pdf backend","misplaced 'restore' by (%dsp, %dsp)", (int) diff.h, (int) diff.v); } if (global_shipping_mode == SHIPPING_PAGE) { matrix_stack_used = pos_stack[pos_stack_used].matrix_stack; diff --git a/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w b/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w index ba9317e776d27324db3f39c26fa7dcd815510e2c..725860175b0b8210cc149c32153c31c6ccdc4c02 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w +++ b/source/texk/web2c/luatexdir/pdf/pdfsetmatrix.w @@ -90,9 +90,8 @@ static void pdfsetmatrix(const char *in, scaledpos pos) matrix_entry x, *y, *z; if (global_shipping_mode == SHIPPING_PAGE) { - if (sscanf((const char *) in, " %lf %lf %lf %lf ", - &x.a, &x.b, &x.c, &x.d) != 4) { - luatex_warn("unrecognized format of setmatrix: {%s}", in); + if (sscanf((const char *) in, " %lf %lf %lf %lf ", &x.a, &x.b, &x.c, &x.d) != 4) { + formatted_warning("pdf backend","unrecognized format of setmatrix: %s", in); return; } /* calculate this transformation matrix */ diff --git a/source/texk/web2c/luatexdir/pdf/pdfshipout.w b/source/texk/web2c/luatexdir/pdf/pdfshipout.w index 8a297127e7adf8f5f77737c44c78440a2757e3ea..e6713db3dcfd82adf485c50097484b35f6a82b65 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfshipout.w +++ b/source/texk/web2c/luatexdir/pdf/pdfshipout.w @@ -103,7 +103,7 @@ void ship_out(PDF pdf, halfword p, shipping_mode_e shipping_mode) /* Ship box |p| out */ if (shipping_mode == SHIPPING_PAGE && box_dir(p) != page_direction) - normal_warning("backend","pagedir differs from bodydir, the output may be placed wrongly on the page", true, true); + normal_warning("backend","pagedir differs from bodydir, the output may be placed wrongly on the page"); /* Update the values of |max_h| and |max_v|; but if the page is too large, |goto done| */ /* Sometimes the user will generate a huge page because other error messages are being ignored. Such pages are not output to the \.{dvi} file, since they diff --git a/source/texk/web2c/luatexdir/pdf/pdftables.w b/source/texk/web2c/luatexdir/pdf/pdftables.w index 605bcdf65f9ef8fab1146875b0097c07ef4b46f0..dee13978766fa8a5859383656c04903de1e6c578 100644 --- a/source/texk/web2c/luatexdir/pdf/pdftables.w +++ b/source/texk/web2c/luatexdir/pdf/pdftables.w @@ -39,8 +39,7 @@ static int compare_info(const void *pa, const void *pb, void *param) b = (const oentry *) pb; if (a->u_type == b->u_type) { if (a->u_type == union_type_int) - return ((a->u.int0 < - b->u.int0 ? -1 : (a->u.int0 > b->u.int0 ? 1 : 0))); + return ((a->u.int0 < b->u.int0 ? -1 : (a->u.int0 > b->u.int0 ? 1 : 0))); else /* string type */ return strcmp(a->u.str0, b->u.str0); } else if (a->u_type == union_type_int) @@ -56,11 +55,11 @@ static void avl_put_obj(PDF pdf, int t, oentry * oe) if (pdf->obj_tree[t] == NULL) { pdf->obj_tree[t] = avl_create(compare_info, NULL, &avl_xallocator); if (pdf->obj_tree[t] == NULL) - luatex_fail("avlstuff.c: avl_create() pdf->obj_tree failed"); + formatted_error("pdf backend","avl_create() pdf->obj_tree failed"); } pp = avl_probe(pdf->obj_tree[t], oe); if (pp == NULL) - luatex_fail("avlstuff.c: avl_probe() out of memory in insertion"); + formatted_error("pdf backend","avl_probe() out of memory in insertion"); } static void avl_put_int_obj(PDF pdf, int int0, int objptr, int t) @@ -146,8 +145,7 @@ int pdf_create_obj(PDF pdf, int t, int i) obj_link(pdf, pdf->obj_ptr) = pdf->head_tab[t]; pdf->head_tab[t] = pdf->obj_ptr; if ((t == obj_type_dest) && (i < 0)) - append_dest_name(pdf, makecstring(-obj_info(pdf, pdf->obj_ptr)), - pdf->obj_ptr); + append_dest_name(pdf, makecstring(-obj_info(pdf, pdf->obj_ptr)), pdf->obj_ptr); /* why not just -i */ } return pdf->obj_ptr; } diff --git a/source/texk/web2c/luatexdir/pdf/pdfthread.w b/source/texk/web2c/luatexdir/pdf/pdfthread.w index 85f7007aa67a4375996ed2019e3b7e60ddc9b964..4a75dbc92e70aad7e6edd68312c942ca954700fc 100644 --- a/source/texk/web2c/luatexdir/pdf/pdfthread.w +++ b/source/texk/web2c/luatexdir/pdf/pdfthread.w @@ -32,9 +32,8 @@ void append_bead(PDF pdf, halfword p) { int a, b, c, t; if (global_shipping_mode == SHIPPING_FORM) - normal_error("pdf backend", "threads cannot be inside an XForm"); - t = pdf_get_obj(pdf, obj_type_thread, pdf_thread_id(p), - pdf_thread_named_id(p)); + normal_error("pdf backend", "threads cannot be inside an xform"); + t = pdf_get_obj(pdf, obj_type_thread, pdf_thread_id(p), pdf_thread_named_id(p)); b = pdf_create_obj(pdf, obj_type_others, 0); obj_bead_ptr(pdf, b) = pdf_get_mem(pdf, pdfmem_bead_size); set_obj_bead_page(pdf, b, pdf->last_page); @@ -154,18 +153,12 @@ void thread_title(PDF pdf, int t) void pdf_fix_thread(PDF pdf, int t) { halfword a; - normal_warning("pdf backend", "thread destination", false, false); if (obj_info(pdf, t) < 0) { - tprint("name{"); - print(-obj_info(pdf, t)); - tprint("}"); + char *ss = makecstring(-obj_info(pdf, t)); + formatted_warning("pdf backend", "unknown thread destination name '%s'",ss); } else { - tprint("num"); - print_int(obj_info(pdf, t)); + formatted_warning("pdf backend", "unknown thread destination num '%d'",obj_info(pdf, t)); } - tprint(" has been referenced but does not exist, replaced by a fixed one"); - print_ln(); - print_ln(); a = pdf_create_obj(pdf, obj_type_others, 0); pdf_begin_obj(pdf, a, OBJSTM_ALWAYS); pdf_begin_dict(pdf); diff --git a/source/texk/web2c/luatexdir/ptexlib.h b/source/texk/web2c/luatexdir/ptexlib.h index 7d5ebdd14dca9e2125639be6b5e0e2e0de3f52c2..2da9623dc48ac9376f942cd353a55e91ea0a1414 100644 --- a/source/texk/web2c/luatexdir/ptexlib.h +++ b/source/texk/web2c/luatexdir/ptexlib.h @@ -80,7 +80,7 @@ extern char **suffixlist; /* in luainit.w */ # define check_buf(size, buf_size) \ if ((unsigned)(size) > (unsigned)(buf_size)) \ - luatex_fail("buffer overflow: %d > %d at file %s, line %d", \ + formatted_error("internal","buffer overflow: %d > %d at file %s, line %d", \ (int)(size), (int)(buf_size), __FILE__, __LINE__ ) # define append_char_to_buf(c, p, buf, buf_size) do { \ diff --git a/source/texk/web2c/luatexdir/tex/errors.h b/source/texk/web2c/luatexdir/tex/errors.h index 101e78adb71cfbdc1f39b76ccb2745282524447f..6d06fe7395ceb94c3a508afa9661a84981b0dfa4 100644 --- a/source/texk/web2c/luatexdir/tex/errors.h +++ b/source/texk/web2c/luatexdir/tex/errors.h @@ -99,7 +99,9 @@ extern void pause_for_instructions(void); extern void tex_error(const char *msg, const char **hlp); extern void normal_error(const char *t, const char *p); -extern void normal_warning(const char *t, const char *p, boolean pr, boolean ap); +extern void normal_warning(const char *t, const char *p); +extern void formatted_error(const char *t, const char *fmt, ...); +extern void formatted_warning(const char *t, const char *fmt, ...); extern void back_error(void); extern void ins_error(void); diff --git a/source/texk/web2c/luatexdir/tex/errors.w b/source/texk/web2c/luatexdir/tex/errors.w index e11fcd908fe5d6e171811c84dd7d2500e36a90c8..d2f64f5d8098f5d87b3289d9f975863e22e67263 100644 --- a/source/texk/web2c/luatexdir/tex/errors.w +++ b/source/texk/web2c/luatexdir/tex/errors.w @@ -663,6 +663,11 @@ void normal_error(const char *t, const char *p) { normalize_selector(); print_err("error "); + if (cur_file_name) { + tprint(" (file "); + tprint(cur_file_name); + tprint(")"); + } if (t != NULL) { tprint(" ("); tprint(t); @@ -671,11 +676,12 @@ void normal_error(const char *t, const char *p) tprint(": "); if (p != NULL) tprint(p); + remove_pdffile(static_pdf); succumb(); } @ @c -void normal_warning(const char *t, const char *p, boolean prepend_nl, boolean append_nl) +void normal_warning(const char *t, const char *p) { int report_id ; if (strcmp(t,"lua") == 0) { @@ -704,9 +710,13 @@ void normal_warning(const char *t, const char *p, boolean prepend_nl, boolean ap strcpy(last_warning_tag,t); run_callback(report_id, "->"); } else { - if (prepend_nl) - print_ln(); + print_ln(); tprint("warning "); + if (cur_file_name) { + tprint(" (file "); + tprint(cur_file_name); + tprint(")"); + } if (t != NULL) { tprint(" ("); tprint(t); @@ -715,10 +725,30 @@ void normal_warning(const char *t, const char *p, boolean prepend_nl, boolean ap tprint(": "); if (p != NULL) tprint(p); - if (append_nl) - print_ln(); + print_ln(); } if (history == spotless) history = warning_issued; } } + +@ @c +static char print_buf[PRINTF_BUF_SIZE]; + +void formatted_error(const char *t, const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + vsnprintf(print_buf, PRINTF_BUF_SIZE, fmt, args); + normal_error(t,print_buf); + va_end(args); +} + +void formatted_warning(const char *t, const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + vsnprintf(print_buf, PRINTF_BUF_SIZE, fmt, args); + normal_warning(t,print_buf); + va_end(args); +} diff --git a/source/texk/web2c/luatexdir/tex/maincontrol.w b/source/texk/web2c/luatexdir/tex/maincontrol.w index 23848d3b197ff5284250d4646353a3cdd5623dd1..c2862a29bbc323176f619a19bb433fa687d0b6e0 100644 --- a/source/texk/web2c/luatexdir/tex/maincontrol.w +++ b/source/texk/web2c/luatexdir/tex/maincontrol.w @@ -729,7 +729,7 @@ static void run_option(void) { scan_int(); word_define(int_base+math_use_old_fraction_scaling_code, cur_val); } else { - normal_warning("mathoption","unknown key",false,false); + normal_warning("mathoption","unknown key"); } break; default: diff --git a/source/texk/web2c/luatexdir/tex/printing.w b/source/texk/web2c/luatexdir/tex/printing.w index f96cc85124d970f98faa8e9b9abba3ad71c0c841..774f3603ee0c1999459ab904f6a66e58e40b3438 100644 --- a/source/texk/web2c/luatexdir/tex/printing.w +++ b/source/texk/web2c/luatexdir/tex/printing.w @@ -265,10 +265,7 @@ void print(int s) } else if (s >= 0x110000) { int c = s - 0x110000; if (c >= 256) { - normal_warning("print", "bad raw byte to print (c=", true, false); - print_int(c); - tprint("), skipped."); - print_ln(); + formatted_warning("print", "bad raw byte to print (c=%d), skipped",c); } else { print_char(c); } diff --git a/source/texk/web2c/luatexdir/utils/utils.w b/source/texk/web2c/luatexdir/utils/utils.w index 75bd143ef44132d1b0c2bb4ea8b1090c351c85c8..2c23b1d3268550ff0b92c72a64bda89dbc13cad5 100644 --- a/source/texk/web2c/luatexdir/utils/utils.w +++ b/source/texk/web2c/luatexdir/utils/utils.w @@ -47,7 +47,7 @@ @ @c #define check_nprintf(size_get, size_want) \ if ((unsigned)(size_get) >= (unsigned)(size_want)) \ - luatex_fail ("snprintf failed: file %s, line %d", __FILE__, __LINE__); + formatted_error("internal","snprintf failed: file %s, line %d", __FILE__, __LINE__); char *cur_file_name = NULL; static char print_buf[PRINTF_BUF_SIZE]; @@ -113,9 +113,7 @@ void make_subset_tag(fd_entry * fd) aa = avl_probe(st_tree, fd->subset_tag); assert(aa != NULL); if (j > 2) - luatex_warn - ("\nmake_subset_tag(): subset-tag collision, resolved in round %d.\n", - j); + formatted_warning("subsets","subset-tag collision, resolved in round %d",j); } @ @c @@ -130,77 +128,11 @@ void tex_printf(const char *fmt, ...) va_end(args); } -@ |luatex_fail| may be called when a buffer overflow has happened/is - happening, therefore may not call mktexstring. However, with the - current implementation it appears that error messages are misleading, - possibly because pool overflows are detected too late. - - The output format of this fuction must be the same as |normal_error| in - pdftex.web! - -@c -__attribute__ ((noreturn, format(printf, 1, 2))) -void luatex_fail(const char *fmt, ...) -{ - va_list args; - va_start(args, fmt); - print_ln(); - tprint("!LuaTeX error"); - if (cur_file_name) { - tprint(" (file "); - tprint(cur_file_name); - tprint(")"); - } - tprint(": "); - vsnprintf(print_buf, PRINTF_BUF_SIZE, fmt, args); - tprint(print_buf); - va_end(args); - print_ln(); - remove_pdffile(static_pdf); - tprint(" ==> Fatal error occurred, no output PDF file produced!"); - print_ln(); - if (kpathsea_debug) { - abort(); - } else { - exit(EXIT_FAILURE); - } -} - -@ The output format of this fuction must be the same as |normal_warn| in - pdftex.web! -@c -__attribute__ ((format(printf, 1, 2))) -void luatex_warn(const char *fmt, ...) -{ - int old_selector = selector; - va_list args; - va_start(args, fmt); - selector = term_and_log; - print_ln(); - tex_printf("warning"); - if (cur_file_name) - tex_printf(" (file %s)", cur_file_name); - tex_printf(": "); - vsnprintf(print_buf, PRINTF_BUF_SIZE, fmt, args); - tprint(print_buf); - va_end(args); - print_ln(); - selector = old_selector; -} - -@ @c -void garbage_warning(void) -{ - luatex_warn("dangling objects discarded, no output file produced."); - remove_pdffile(static_pdf); -} - - @ @c size_t xfwrite(void *ptr, size_t size, size_t nmemb, FILE * stream) { if (fwrite(ptr, size, nmemb, stream) != nmemb) - luatex_fail("fwrite() failed"); + formatted_error("file io","fwrite() failed"); return nmemb; } @@ -208,7 +140,7 @@ size_t xfwrite(void *ptr, size_t size, size_t nmemb, FILE * stream) int xfflush(FILE * stream) { if (fflush(stream) != 0) - luatex_fail("fflush() failed (%s)", strerror(errno)); + formatted_error("file io","fflush() failed (%s)", strerror(errno)); return 0; } @@ -217,7 +149,7 @@ int xgetc(FILE * stream) { int c = getc(stream); if (c < 0 && c != EOF) - luatex_fail("getc() failed (%s)", strerror(errno)); + formatted_error("file io","getc() failed (%s)", strerror(errno)); return c; } @@ -226,7 +158,7 @@ int xputc(int c, FILE * stream) { int i = putc(c, stream); if (i < 0) - luatex_fail("putc() failed (%s)", strerror(errno)); + formatted_error("file io","putc() failed (%s)", strerror(errno)); return i; } @@ -239,7 +171,7 @@ scaled ext_xn_over_d(scaled x, scaled n, scaled d) else r -= 0.5; if (r >= (double) max_integer || r <= -(double) max_integer) - luatex_warn("arithmetic number too big"); + normal_warning("internal","arithmetic number too big"); return (scaled) r; }