summaryrefslogtreecommitdiff
path: root/Build/source/texk
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk')
-rw-r--r--Build/source/texk/web2c/luatexdir/ChangeLog40
-rw-r--r--Build/source/texk/web2c/luatexdir/font/luatexfont.h11
-rw-r--r--Build/source/texk/web2c/luatexdir/font/tounicode.c60
-rw-r--r--Build/source/texk/web2c/luatexdir/font/writefont.c18
-rw-r--r--Build/source/texk/web2c/luatexdir/font/writet3.c182
-rw-r--r--Build/source/texk/web2c/luatexdir/image/pdftoepdf.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/image/writeimg.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/liolibext.c184
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c41
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/ltexlib.c183
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luatex-api.h9
-rw-r--r--Build/source/texk/web2c/luatexdir/luatex_svnversion.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/luatexcallbackids.h1
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfgen.c42
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/errors.c20
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/extensions.c15
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/mlist.c37
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/scanning.c4
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/texmath.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/texnodes.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/textoken.c16
21 files changed, 650 insertions, 223 deletions
diff --git a/Build/source/texk/web2c/luatexdir/ChangeLog b/Build/source/texk/web2c/luatexdir/ChangeLog
index 92bcb391a3d..441b3e06ff7 100644
--- a/Build/source/texk/web2c/luatexdir/ChangeLog
+++ b/Build/source/texk/web2c/luatexdir/ChangeLog
@@ -1,3 +1,43 @@
+2020-07-26 Luigi Scarso <luigi.scarso@gmail.com>
+ * fixed: \tracinglostchars>=3 is an error (no fatal error)
+
+2020-07-26 Luigi Scarso <luigi.scarso@gmail.com>
+ * New value for \tracinglostchars: \tracinglostchars>=3 is a fatal error
+
+2020-07-12 Luigi Scarso <luigi.scarso@gmail.com>
+ * Original reports:
+ https://tex.stackexchange.com/questions/551313/
+ https://tug.org/pipermail/tex-live/2020-June/045876.html
+
+ This will probably be fixed by DEK in the 2021 tuneup in a different
+ way (so we'll have to remove or alter this change), but the interaction
+ sequence in the reports above causes a segmentation fault in web2c -
+ writing to the closed \write15 stream because we wrongly decrement
+ selector from 16 to 15 in term_input, due to the lack of this check in
+ recursive error() call (K. Berry)
+
+
+2020-07-04 Luigi Scarso <luigi.scarso@gmail.com>
+ * little endian variants for readers. (HH)
+ * The keyword \type {norule} will hide the rule with the above variants while
+ keeping the rule related spacing. (HH)
+
+2020-06-21 Luigi Scarso <luigi.scarso@gmail.com>
+ * pending better is_defined check plus an extra option in a scanner; also the \cs case. (HH)
+ * tex.getmark(what,wherefrom) added (HH)
+
+2020-05-01 Luigi Scarso <luigi.scarso@gmail.com>
+ * added tex.interlinepenalties tex.clubpenalties tex.widowpenalties
+ tex.displaywidowpenalties to complement tex.parshape (HH)
+
+2020-04-28 Luigi Scarso <luigi.scarso@gmail.com>
+ * less strict lastnode testing (HH)
+ * some experimental math delimiter code removed (HH)
+
+2020-04-27 Luigi Scarso <luigi.scarso@gmail.com>
+ * similar treatment for shiftdown as shiftup in operators (no
+ checking) (HH)
+
2020-04-07 Luigi Scarso <luigi.scarso@gmail.com>
* Version 1.13.0.
getstring extra argument to pdfe.getstring (triggers unencoded or flag
diff --git a/Build/source/texk/web2c/luatexdir/font/luatexfont.h b/Build/source/texk/web2c/luatexdir/font/luatexfont.h
index 5eb6a5bd94e..c60fc4a91f9 100644
--- a/Build/source/texk/web2c/luatexdir/font/luatexfont.h
+++ b/Build/source/texk/web2c/luatexdir/font/luatexfont.h
@@ -119,9 +119,10 @@ typedef struct {
/* tounicode.c */
int write_cid_tounicode(PDF, fo_entry *, internal_font_number);
-void glyph_unicode_free(void);
-void def_tounicode(str_number, str_number);
int write_tounicode(PDF, char **, char *);
+int write_raw_tounicode(PDF, internal_font_number, char *);
+void def_tounicode(str_number, str_number);
+void glyph_unicode_free(void);
/* vfpacket.c */
@@ -143,6 +144,7 @@ void writetype0(PDF pdf, fd_entry * fd);
/* writefont.c */
void do_pdf_font(PDF, internal_font_number);
+int do_pdf_preroll_font(PDF, internal_font_number);
fd_entry *lookup_fd_entry(char *);
fd_entry *new_fd_entry(internal_font_number);
void write_fontstuff(PDF);
@@ -194,7 +196,10 @@ internal_font_number copy_font_info(internal_font_number f);
/* writet3.c */
extern FILE *t3_file;
-void writet3(PDF, internal_font_number);
+
+void writet3pk(PDF, internal_font_number);
+void prerollt3user(PDF, internal_font_number);
+void writet3user(PDF, internal_font_number);
extern unsigned char *t3_buffer;
extern int t3_size;
diff --git a/Build/source/texk/web2c/luatexdir/font/tounicode.c b/Build/source/texk/web2c/luatexdir/font/tounicode.c
index 32210600c21..b1e08e7cebd 100644
--- a/Build/source/texk/web2c/luatexdir/font/tounicode.c
+++ b/Build/source/texk/web2c/luatexdir/font/tounicode.c
@@ -305,22 +305,30 @@ static void set_cid_glyph_unicode(long index, glyph_unicode_entry * gp, internal
}
*/
-int write_tounicode(PDF pdf, char **glyph_names, char *name)
+static int do_write_tounicode(PDF pdf, char **glyph_names, char *name, internal_font_number f)
{
- char buf[SMALL_BUF_SIZE], *p;
+ char buf[SMALL_BUF_SIZE], *p, *s;
static char builtin_suffix[] = "-builtin";
short range_size[257];
glyph_unicode_entry gtab[257];
int objnum;
int i, j;
int bfchar_count, bfrange_count, subrange_count;
- assert(strlen(name) + strlen(builtin_suffix) < SMALL_BUF_SIZE);
if (glyph_unicode_tree == NULL) {
pdf->gen_tounicode = 0;
return 0;
}
- strcpy(buf, name);
- if ((p = strrchr(buf, '.')) != NULL && strcmp(p, ".enc") == 0) {
+ if (name == NULL) {
+ strcpy(buf, "no-name");
+ } else {
+ strcpy(buf, name);
+ }
+ if (f) {
+ /*tex
+ Always.
+ */
+ strcat(buf, builtin_suffix);
+ } else if ((p = strrchr(buf, '.')) != NULL && strcmp(p, ".enc") == 0) {
/*tex
Strip |.enc| from encoding name.
*/
@@ -332,6 +340,29 @@ int write_tounicode(PDF pdf, char **glyph_names, char *name)
*/
strcat(buf, builtin_suffix);
}
+ /*tex Set gtab: */
+ if (f) {
+ int done = 0 ;
+ for (i = 0; i < 256; ++i) {
+ if ((s = get_charinfo_tounicode(char_info(f,(int)i))) != NULL) {
+ gtab[i].code = UNI_EXTRA_STRING;
+ gtab[i].unicode_seq = xstrdup(s);
+ done = 1 ;
+ } else {
+ gtab[i].code = UNI_UNDEF;
+ }
+ }
+ if (! done) {
+ return 0;
+ }
+ } else {
+ for (i = 0; i < 256; ++i) {
+ gtab[i].code = UNI_UNDEF;
+ set_glyph_unicode(glyph_names[i], &gtab[i]);
+ }
+ }
+ gtab[256].code = UNI_UNDEF;
+ /* */
objnum = pdf_create_obj(pdf, obj_type_others, 0);
pdf_begin_obj(pdf, objnum, OBJSTM_NEVER);
pdf_begin_dict(pdf);
@@ -359,12 +390,6 @@ int write_tounicode(PDF pdf, char **glyph_names, char *name)
"1 begincodespacerange\n"
"<00> <FF>\n" "endcodespacerange\n",
buf, buf, buf, buf, buf);
- /*tex Set gtab: */
- for (i = 0; i < 256; ++i) {
- gtab[i].code = UNI_UNDEF;
- set_glyph_unicode(glyph_names[i], &gtab[i]);
- }
- gtab[256].code = UNI_UNDEF;
/*tex Set |range_size|: */
for (i = 0; i < 256;) {
if (gtab[i].code == UNI_STRING || gtab[i].code == UNI_EXTRA_STRING) {
@@ -414,8 +439,7 @@ int write_tounicode(PDF pdf, char **glyph_names, char *name)
while (range_size[i] <= 1 && i < 256)
i++;
assert(i < 256);
- pdf_printf(pdf, "<%02X> <%02X> <%s>\n", i, i + range_size[i] - 1,
- utf16be_str(gtab[i].code));
+ pdf_printf(pdf, "<%02X> <%02X> <%s>\n", i, i + range_size[i] - 1, utf16be_str(gtab[i].code));
i += range_size[i];
}
pdf_printf(pdf, "endbfrange\n");
@@ -467,6 +491,16 @@ int write_tounicode(PDF pdf, char **glyph_names, char *name)
return objnum;
}
+int write_tounicode(PDF pdf, char **glyph_names, char *name)
+{
+ return do_write_tounicode(pdf, glyph_names, name, 0);
+}
+
+int write_raw_tounicode(PDF pdf, internal_font_number f, char *name)
+{
+ return do_write_tounicode(pdf, NULL, name, f);
+}
+
int write_cid_tounicode(PDF pdf, fo_entry * fo, internal_font_number f)
{
static int range_size[65537];
diff --git a/Build/source/texk/web2c/luatexdir/font/writefont.c b/Build/source/texk/web2c/luatexdir/font/writefont.c
index b367fa2bf85..13fa8b7543d 100644
--- a/Build/source/texk/web2c/luatexdir/font/writefont.c
+++ b/Build/source/texk/web2c/luatexdir/font/writefont.c
@@ -851,13 +851,27 @@ void do_pdf_font(PDF pdf, internal_font_number f)
create_cid_fontdictionary(pdf, f);
} else {
/*tex By now |font_map(f)|, if any, should have been set via |pdf_init_font|. */
- if ((fm = font_map(f)) == NULL || (fm->ps_name == NULL && fm->ff_name == NULL))
- writet3(pdf, f);
+ if (font_psname(f) != NULL && strstr(font_psname(f),"none"))
+ writet3user(pdf, f);
+ else if ((fm = font_map(f)) == NULL || (fm->ps_name == NULL && fm->ff_name == NULL))
+ writet3pk(pdf, f);
else
create_fontdictionary(pdf, f);
}
}
+int do_pdf_preroll_font(PDF pdf, internal_font_number f)
+{
+ if (!font_has_subset(f)) {
+ return 0;
+ } else if (font_encodingbytes(f) != 2 && font_psname(f) != NULL && strstr(font_psname(f),"none")) {
+ prerollt3user(pdf, f);
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
/*tex
The glyph width is included in |glw_entry|, because that width depends on the
diff --git a/Build/source/texk/web2c/luatexdir/font/writet3.c b/Build/source/texk/web2c/luatexdir/font/writet3.c
index 6121c24a1f0..693bb0c6ef9 100644
--- a/Build/source/texk/web2c/luatexdir/font/writet3.c
+++ b/Build/source/texk/web2c/luatexdir/font/writet3.c
@@ -31,14 +31,12 @@ typedef char t3_line_entry;
define_array(t3_line);
FILE *t3_file;
-static boolean t3_image_used;
static int t3_char_procs[256];
-static float t3_char_widths[256];
+static double t3_char_widths[256];
static int t3_glyph_num;
-static float t3_font_scale;
+static double t3_font_scale;
static int t3_b0, t3_b1, t3_b2, t3_b3;
-static boolean is_pk_font;
/*tex Not static because used elsewhere. */
@@ -135,8 +133,6 @@ static boolean writepk(PDF pdf, internal_font_number f)
t3_read_file();
t3_close();
}
- t3_image_used = true;
- is_pk_font = true;
report_start_file(filetype_font,(char *) name);
cd.rastersize = 256;
cd.raster = xtalloc((unsigned long) cd.rastersize, halfword);
@@ -150,7 +146,7 @@ static boolean writepk(PDF pdf, internal_font_number f)
check_preamble = false;
if (!pdf_char_marked(f, cd.charcode))
continue;
- t3_char_widths[cd.charcode] = (float) pk_char_width(pdf, f, get_charwidth(f, cd.charcode), pdf->pk_scale_factor);
+ t3_char_widths[cd.charcode] = (double) pk_char_width(pdf, f, get_charwidth(f, cd.charcode), pdf->pk_scale_factor);
if (cd.cwidth < 1 || cd.cheight < 1) {
cd.xescape = cd.cwidth = round(t3_char_widths[cd.charcode] / 100.0);
cd.cheight = 1;
@@ -206,35 +202,86 @@ static boolean writepk(PDF pdf, internal_font_number f)
return true;
}
-void writet3(PDF pdf, internal_font_number f)
+/*tex
+
+ Mode |0| is traditional pk with map file lookup, while mode |1| listens to
+ the callback. The callback gets a font id and character number and returns an
+ object number of a stream object plus the width that ends up in the widths
+ array. The stream can of course refer to another xform but it has to start
+ with the right sequence for being a character. As there are different
+ situations this is more flexible that hardcoding all kind of variants that
+ will never suit all possible purposes.
+
+ The next ones are a bit strange. We could as well have had one callback that
+ just generates the whole type 3 but I think that the assumption is that
+ \LUATEX\ should do the work. So, instead we have one callback that is invoked
+ with several intentions as indicated by the first argument.
+
+*/
+
+static void writet3(PDF pdf, internal_font_number f, int callback_id)
{
int i;
char s[32];
int wptr, eptr, cptr;
int first_char, last_char;
int pk_font_scale;
+ int tounicode_objnum = 0;
pdffloat pf;
boolean is_notdef;
t3_glyph_num = 0;
- t3_image_used = false;
for (i = 0; i < 256; i++) {
t3_char_procs[i] = 0;
t3_char_widths[i] = 0;
}
- is_pk_font = false;
xfree(t3_buffer);
t3_curbyte = 0;
t3_size = 0;
- if (!writepk(pdf, f))
- return;
- for (i = font_bc(f); i <= font_ec(f); i++)
- if (pdf_char_marked(f, i))
+ for (i = font_bc(f); i <= font_ec(f); i++) {
+ if (pdf_char_marked(f, i)) {
break;
+ }
+ }
first_char = i;
- for (i = font_ec(f); i > first_char; i--)
- if (pdf_char_marked(f, i))
+ for (i = font_ec(f); i > first_char; i--) {
+ if (pdf_char_marked(f, i)) {
break;
+ }
+ }
last_char = i;
+ if (callback_id > 0) {
+ /*tex We assume a user font. */
+ for (i = first_char; i <= last_char; i++) {
+ if (pdf_char_marked(f, i)) {
+ int r = 0;
+ double w = 0;
+ /*tex
+ We pass |2|, the font id, the character index, and we expect
+ back a width in basepoints, an object number of a stream, and
+ an objectnumber of an xobject used where zero means nothing is
+ used.
+ */
+ run_callback(callback_id, "ddd->df", 2, f, i, &r, &w);
+ if (r > 0) {
+ t3_char_procs[i] = r;
+ t3_char_widths[i] = w;
+ }
+ }
+ }
+ t3_font_scale = 0.001;
+ t3_b0 = 0;
+ t3_b1 = 0;
+ t3_b2 = 0;
+ t3_b3 = 0;
+ } else if (writepk(pdf, f)) {
+ /*tex We assume a pk font. */
+ } else {
+ /*tex We just quit. */
+ return;
+ }
+ if (pdf->gen_tounicode > 0) {
+ tounicode_objnum = write_raw_tounicode(pdf, f, font_fullname(f));
+ }
/*tex We create a |Type3| font dictionary: */
pdf_begin_obj(pdf, pdf_font_num(f), OBJSTM_ALWAYS);
pdf_begin_dict(pdf);
@@ -247,22 +294,6 @@ void writet3(PDF pdf, internal_font_number f)
pdf_print(pdf, pdf_font_attr(f));
pdf_out(pdf, '\n');
}
- if (is_pk_font) {
- pk_font_scale = get_pk_font_scale(pdf,f,pdf->pk_scale_factor);
- pdf_add_name(pdf, "FontMatrix");
- pdf_begin_array(pdf);
- setpdffloat(pf, (int64_t) pk_font_scale, 5);
- print_pdffloat(pdf, pf);
- pdf_puts(pdf, " 0 0 ");
- print_pdffloat(pdf, pf);
- pdf_puts(pdf, " 0 0");
- pdf_end_array(pdf);
- } else {
- pdf_add_name(pdf, "FontMatrix");
- pdf_begin_array(pdf);
- pdf_printf(pdf, "%g 0 0 %g 0 0", (double) t3_font_scale, (double) t3_font_scale);
- pdf_end_array(pdf);
- }
pdf_add_name(pdf, font_key[FONTBBOX1_CODE].pdfname);
pdf_begin_array(pdf);
pdf_add_int(pdf, (int) t3_b0);
@@ -271,15 +302,56 @@ void writet3(PDF pdf, internal_font_number f)
pdf_add_int(pdf, (int) t3_b3);
pdf_end_array(pdf);
pdf_add_name(pdf, "Resources");
+ /*tex
+ This is not mandate but we just set them all. They are ignored anyway. In
+ PDF version 2 they are even obsolete but then, unknown entries are again
+ ignored.
+ */
pdf_begin_dict(pdf);
pdf_add_name(pdf, "ProcSet");
pdf_begin_array(pdf);
pdf_add_name(pdf, "PDF");
- if (t3_image_used) {
- pdf_add_name(pdf, "ImageB");
+ pdf_add_name(pdf, "ImageB");
+ if (callback_id) {
+ pdf_add_name(pdf, "ImageC");
+ pdf_add_name(pdf, "ImageI");
+ pdf_add_name(pdf, "Text");
}
pdf_end_array(pdf);
- pdf_end_dict(pdf);
+ /*tex
+ A previous version had two calls that dealt with adding font resources and
+ xform references and a separate one for the font matrix but we now delegate
+ some stupid work to the caller and have all in one: we expect a matrix and
+ a resource string.
+ */
+ if (callback_id > 0) {
+ char *str = NULL;
+ double s = t3_font_scale;
+ run_callback(callback_id, "dd->fR", 3, f, &s, &str);
+ t3_font_scale = s;
+ if (str != NULL) {
+ pdf_out(pdf, ' ');
+ pdf_puts(pdf, str);
+ free(str);
+ }
+ pdf_end_dict(pdf); /*tex The resources. */
+ pdf_add_name(pdf, "FontMatrix");
+ pdf_begin_array(pdf);
+ pdf_printf(pdf, "%g 0 0 %g 0 0", t3_font_scale, t3_font_scale);
+ pdf_end_array(pdf);
+ } else {
+ pdf_end_dict(pdf); /*tex The resources. */
+ pk_font_scale = get_pk_font_scale(pdf,f,pdf->pk_scale_factor);
+ pdf_add_name(pdf, "FontMatrix");
+ pdf_begin_array(pdf);
+ setpdffloat(pf, (int64_t) pk_font_scale, 5);
+ print_pdffloat(pdf, pf);
+ pdf_puts(pdf, " 0 0 ");
+ print_pdffloat(pdf, pf);
+ pdf_puts(pdf, " 0 0");
+ pdf_end_array(pdf);
+ }
+ /*tex Some preparations. */
pdf_dict_add_int(pdf, "FirstChar", first_char);
pdf_dict_add_int(pdf, "LastChar", last_char);
wptr = pdf_create_obj(pdf, obj_type_others, 0);
@@ -288,20 +360,23 @@ void writet3(PDF pdf, internal_font_number f)
pdf_dict_add_ref(pdf, "Widths", (int) wptr);
pdf_dict_add_ref(pdf, "Encoding", (int) eptr);
pdf_dict_add_ref(pdf, "CharProcs", (int) cptr);
+ if (tounicode_objnum) {
+ pdf_dict_add_ref(pdf, "ToUnicode", tounicode_objnum);
+ }
pdf_end_dict(pdf);
pdf_end_obj(pdf);
/*tex The |Widths| array: */
pdf_begin_obj(pdf, wptr, OBJSTM_ALWAYS);
pdf_begin_array(pdf);
- if (is_pk_font) {
+ if (callback_id) {
for (i = first_char; i <= last_char; i++) {
- setpdffloat(pf, (int64_t) t3_char_widths[i], 2);
- print_pdffloat(pdf, pf);
- pdf_out(pdf, ' ');
+ pdf_printf(pdf, " %g", t3_char_widths[i]);
}
} else {
for (i = first_char; i <= last_char; i++) {
- pdf_add_int(pdf, (int) t3_char_widths[i]);
+ setpdffloat(pf, (int64_t) t3_char_widths[i], 2);
+ print_pdffloat(pdf, pf);
+ pdf_out(pdf, ' ');
}
}
pdf_end_array(pdf);
@@ -354,3 +429,30 @@ void writet3(PDF pdf, internal_font_number f)
report_stop_file(filetype_font);
cur_file_name = NULL;
}
+
+void writet3pk(PDF pdf, internal_font_number f)
+{
+ writet3(pdf, f, 0);
+}
+
+void prerollt3user(PDF pdf, internal_font_number f)
+{
+ int callback_id = callback_defined(provide_charproc_data_callback);
+ if (callback_id > 0) {
+ int i;
+ for (i = font_bc(f); i <= font_ec(f); i++) {
+ if (pdf_char_marked(f, i)) {
+ /*tex We pass |true|, the font id and the character index. */
+ run_callback(callback_id, "ddd->", 1, f, i);
+ }
+ }
+ }
+}
+
+void writet3user(PDF pdf, internal_font_number f)
+{
+ int callback_id = callback_defined(provide_charproc_data_callback);
+ if (callback_id) {
+ writet3(pdf, f, callback_id);
+ }
+}
diff --git a/Build/source/texk/web2c/luatexdir/image/pdftoepdf.c b/Build/source/texk/web2c/luatexdir/image/pdftoepdf.c
index a43f1dac4cc..78dab3a37b3 100644
--- a/Build/source/texk/web2c/luatexdir/image/pdftoepdf.c
+++ b/Build/source/texk/web2c/luatexdir/image/pdftoepdf.c
@@ -665,7 +665,7 @@ void read_pdf_info(image_dict * idict)
then have to changed drastically anyway.
*/
pdf_major_version_found = ppdoc_version_number(pdfe,&pdf_minor_version_found);
- if ((100 * pdf_major_version_found + pdf_major_version_found) > (100 * img_pdfmajorversion(idict) + img_pdfminorversion(idict))) {
+ if ((100 * pdf_major_version_found + pdf_minor_version_found) > (100 * img_pdfmajorversion(idict) + img_pdfminorversion(idict))) {
const char *msg = "PDF inclusion: found PDF version '%d.%d', but at most version '%d.%d' allowed";
if (img_errorlevel(idict) > 0) {
formatted_error("pdf inclusion",msg, pdf_major_version_found, pdf_minor_version_found, img_pdfmajorversion(idict), img_pdfminorversion(idict));
diff --git a/Build/source/texk/web2c/luatexdir/image/writeimg.c b/Build/source/texk/web2c/luatexdir/image/writeimg.c
index 7fe8444bced..f544e6b6814 100644
--- a/Build/source/texk/web2c/luatexdir/image/writeimg.c
+++ b/Build/source/texk/web2c/luatexdir/image/writeimg.c
@@ -130,7 +130,7 @@ static void check_type_by_header(image_dict * idict)
static void check_type_by_extension(image_dict * idict)
{
char *image_suffix;
- if (idict != NULL)
+ if (idict == NULL)
return;
if (img_type(idict) != IMG_TYPE_NONE)
return;
diff --git a/Build/source/texk/web2c/luatexdir/lua/liolibext.c b/Build/source/texk/web2c/luatexdir/lua/liolibext.c
index 2de67f8fe29..ce1e78f6c73 100644
--- a/Build/source/texk/web2c/luatexdir/lua/liolibext.c
+++ b/Build/source/texk/web2c/luatexdir/lua/liolibext.c
@@ -145,6 +145,17 @@ static int readcardinal2(lua_State *L) {
lua_pushinteger(L, 0x100 * a + b);
return 1;
}
+static int readcardinal2_le(lua_State *L) {
+ FILE *f = tofile(L);
+ int b = getc(f);
+ int a = getc(f);
+ if (a == EOF)
+ lua_pushnil(L);
+ else
+ /* (a<<8) | b */
+ lua_pushinteger(L, 0x100 * a + b);
+ return 1;
+}
static int readcardinal2_s(lua_State *L) {
size_t l;
@@ -159,6 +170,19 @@ static int readcardinal2_s(lua_State *L) {
}
return 1;
}
+static int readcardinal2_s_le(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ if (p+1 >= l) {
+ lua_pushnil(L);
+ } else {
+ int b = uchar(s[p++]);
+ int a = uchar(s[p]);
+ lua_pushinteger(L, 0x100 * a + b);
+ }
+ return 1;
+}
static int readcardinal3(lua_State *L) {
FILE *f = tofile(L);
@@ -172,6 +196,18 @@ static int readcardinal3(lua_State *L) {
lua_pushinteger(L, 0x10000 * a + 0x100 * b + c);
return 1;
}
+static int readcardinal3_le(lua_State *L) {
+ FILE *f = tofile(L);
+ int c = getc(f);
+ int b = getc(f);
+ int a = getc(f);
+ if (a == EOF)
+ lua_pushnil(L);
+ else
+ /* (a<<16) | (b<<8) | c */
+ lua_pushinteger(L, 0x10000 * a + 0x100 * b + c);
+ return 1;
+}
static int readcardinal3_s(lua_State *L) {
size_t l;
@@ -187,6 +223,20 @@ static int readcardinal3_s(lua_State *L) {
}
return 1;
}
+static int readcardinal3_s_le(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ if (p+2 >= l) {
+ lua_pushnil(L);
+ } else {
+ int c = uchar(s[p++]);
+ int b = uchar(s[p++]);
+ int a = uchar(s[p]);
+ lua_pushinteger(L, 0x10000 * a + 0x100 * b + c);
+ }
+ return 1;
+}
static int readcardinal4(lua_State *L) {
FILE *f = tofile(L);
@@ -201,6 +251,19 @@ static int readcardinal4(lua_State *L) {
lua_pushinteger(L,0x1000000 * a + 0x10000 * b + 0x100 * c + d);
return 1;
}
+static int readcardinal4_le(lua_State *L) {
+ FILE *f = tofile(L);
+ int d = getc(f);
+ int c = getc(f);
+ int b = getc(f);
+ int a = getc(f);
+ if (a == EOF)
+ lua_pushnil(L);
+ else
+ /* (a<<24) | (b<<16) | (c<<8) | d */
+ lua_pushinteger(L,0x1000000 * a + 0x10000 * b + 0x100 * c + d);
+ return 1;
+}
static int readcardinal4_s(lua_State *L) {
size_t l;
@@ -217,6 +280,21 @@ static int readcardinal4_s(lua_State *L) {
}
return 1;
}
+static int readcardinal4_s_le(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ if (p+3 >= l) {
+ lua_pushnil(L);
+ } else {
+ int d = uchar(s[p++]);
+ int c = uchar(s[p++]);
+ int b = uchar(s[p++]);
+ int a = uchar(s[p]);
+ lua_pushinteger(L,0x1000000 * a + 0x10000 * b + 0x100 * c + d);
+ }
+ return 1;
+}
static int readcardinaltable(lua_State *L) {
FILE *f = tofile(L);
@@ -391,6 +469,18 @@ static int readinteger2(lua_State *L) {
lua_pushinteger(L, 0x100 * a + b);
return 1;
}
+static int readinteger2_le(lua_State *L) {
+ FILE *f = tofile(L);
+ int b = getc(f);
+ int a = getc(f);
+ if (a == EOF)
+ lua_pushnil(L);
+ else if (a >= 0x80)
+ lua_pushinteger(L, 0x100 * a + b - 0x10000);
+ else
+ lua_pushinteger(L, 0x100 * a + b);
+ return 1;
+}
static int readinteger2_s(lua_State *L) {
size_t l;
@@ -408,6 +498,22 @@ static int readinteger2_s(lua_State *L) {
}
return 1;
}
+static int readinteger2_s_le(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ if (p+1 >= l) {
+ lua_pushnil(L);
+ } else {
+ int b = uchar(s[p++]);
+ int a = uchar(s[p]);
+ if (a >= 0x80)
+ lua_pushinteger(L, 0x100 * a + b - 0x10000);
+ else
+ lua_pushinteger(L, 0x100 * a + b);
+ }
+ return 1;
+}
static int readinteger3(lua_State *L) {
FILE *f = tofile(L);
@@ -422,6 +528,19 @@ static int readinteger3(lua_State *L) {
lua_pushinteger(L, 0x10000 * a + 0x100 * b + c);
return 1;
}
+static int readinteger3_le(lua_State *L) {
+ FILE *f = tofile(L);
+ int c = getc(f);
+ int b = getc(f);
+ int a = getc(f);
+ if (a == EOF)
+ lua_pushnil(L);
+ else if (a >= 0x80)
+ lua_pushinteger(L, 0x10000 * a + 0x100 * b + c - 0x1000000);
+ else
+ lua_pushinteger(L, 0x10000 * a + 0x100 * b + c);
+ return 1;
+}
static int readinteger3_s(lua_State *L) {
size_t l;
@@ -440,6 +559,23 @@ static int readinteger3_s(lua_State *L) {
}
return 1;
}
+static int readinteger3_s_le(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ if (p+2 >= l) {
+ lua_pushnil(L);
+ } else {
+ int c = uchar(s[p++]);
+ int b = uchar(s[p++]);
+ int a = uchar(s[p]);
+ if (a >= 0x80)
+ lua_pushinteger(L, 0x10000 * a + 0x100 * b + c - 0x1000000);
+ else
+ lua_pushinteger(L, 0x10000 * a + 0x100 * b + c);
+ }
+ return 1;
+}
static int readinteger4(lua_State *L) {
FILE *f = tofile(L);
@@ -455,6 +591,20 @@ static int readinteger4(lua_State *L) {
lua_pushinteger(L, 0x1000000 * a + 0x10000 * b + 0x100 * c + d);
return 1;
}
+static int readinteger4_le(lua_State *L) {
+ FILE *f = tofile(L);
+ int d = getc(f);
+ int c = getc(f);
+ int b = getc(f);
+ int a = getc(f);
+ if (a == EOF)
+ lua_pushnil(L);
+ else if (a >= 0x80)
+ lua_pushinteger(L, 0x1000000 * a + 0x10000 * b + 0x100 * c + d - 0x100000000);
+ else
+ lua_pushinteger(L, 0x1000000 * a + 0x10000 * b + 0x100 * c + d);
+ return 1;
+}
static int readinteger4_s(lua_State *L) {
size_t l;
@@ -474,6 +624,24 @@ static int readinteger4_s(lua_State *L) {
}
return 1;
}
+static int readinteger4_s_le(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ if (p+3 >= l) {
+ lua_pushnil(L);
+ } else {
+ int d = uchar(s[p++]);
+ int c = uchar(s[p++]);
+ int b = uchar(s[p++]);
+ int a = uchar(s[p]);
+ if (a >= 0x80)
+ lua_pushinteger(L, 0x1000000 * a + 0x10000 * b + 0x100 * c + d - 0x100000000);
+ else
+ lua_pushinteger(L, 0x1000000 * a + 0x10000 * b + 0x100 * c + d);
+ }
+ return 1;
+}
static int readintegertable(lua_State *L) {
FILE *f = tofile(L);
@@ -869,11 +1037,19 @@ static const luaL_Reg fiolib[] = {
{ "readcardinal2", readcardinal2 },
{ "readcardinal3", readcardinal3 },
{ "readcardinal4", readcardinal4 },
+ { "readcardinal1le", readcardinal1 },
+ { "readcardinal2le", readcardinal2_le },
+ { "readcardinal3le", readcardinal3_le },
+ { "readcardinal4le", readcardinal4_le },
{ "readcardinaltable", readcardinaltable },
{ "readinteger1", readinteger1 },
{ "readinteger2", readinteger2 },
{ "readinteger3", readinteger3 },
{ "readinteger4", readinteger4 },
+ { "readinteger1le", readinteger1 },
+ { "readinteger2le", readinteger2_le },
+ { "readinteger3le", readinteger3_le },
+ { "readinteger4le", readinteger4_le },
{ "readintegertable", readintegertable },
{ "readfixed2", readfixed2 },
{ "readfixed4", readfixed4 },
@@ -893,11 +1069,19 @@ static const luaL_Reg siolib[] = {
{ "readcardinal2", readcardinal2_s },
{ "readcardinal3", readcardinal3_s },
{ "readcardinal4", readcardinal4_s },
+ { "readcardinal1le", readcardinal1_s },
+ { "readcardinal2le", readcardinal2_s_le },
+ { "readcardinal3le", readcardinal3_s_le },
+ { "readcardinal4le", readcardinal4_s_le },
{ "readcardinaltable", readcardinaltable_s },
{ "readinteger1", readinteger1_s },
{ "readinteger2", readinteger2_s },
{ "readinteger3", readinteger3_s },
{ "readinteger4", readinteger4_s },
+ { "readinteger1le", readinteger1_s },
+ { "readinteger2le", readinteger2_s_le },
+ { "readinteger3le", readinteger3_s_le },
+ { "readinteger4le", readinteger4_s_le },
{ "readintegertable", readintegertable_s },
{ "readfixed2", readfixed2_s },
{ "readfixed4", readfixed4_s },
diff --git a/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c b/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c
index 6af006a53c8..d0047919c7f 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c
@@ -614,23 +614,35 @@ static int run_scan_argument(lua_State * L) /* HH */
get_token();
} while ((cur_cmd == spacer_cmd) || (cur_cmd == relax_cmd));
if (cur_cmd == left_brace_cmd) {
+ int exp = 1;
+ if (lua_type(L, 1) == LUA_TBOOLEAN) {
+ exp = lua_toboolean(L, 1);
+ }
back_input();
saved_defref = def_ref;
- (void) scan_toks(false, true);
+ (void) scan_toks(false, exp);
t = def_ref;
def_ref = saved_defref;
tokenlist_to_luastring(L,t);
flush_list(t);
} else if (cur_cmd == call_cmd) {
halfword saved_cur_tok = cur_tok;
+ int exp = 1;
+ if (lua_type(L, 1) == LUA_TBOOLEAN) {
+ exp = lua_toboolean(L, 1);
+ }
cur_tok = right_brace_token + '}';
back_input();
- cur_tok = saved_cur_tok;
- back_input();
+ if (exp) {
+ cur_tok = saved_cur_tok;
+ back_input();
+ } else {
+ expand();
+ }
cur_tok = left_brace_token + '{';
back_input();
saved_defref = def_ref;
- (void) scan_toks(false, true);
+ (void) scan_toks(false, exp);
t = def_ref;
def_ref = saved_defref;
tokenlist_to_luastring(L,t);
@@ -740,6 +752,7 @@ static int run_lookup(lua_State * L)
return 1;
}
+/*
static int lua_tokenlib_is_defined(lua_State * L)
{
const char *s;
@@ -754,6 +767,26 @@ static int lua_tokenlib_is_defined(lua_State * L)
lua_pushnil(L);
return 1;
}
+*/
+
+static int lua_tokenlib_is_defined(lua_State * L)
+{
+ int b = 0;
+ if (lua_type(L, 1) == LUA_TSTRING) {
+ size_t l;
+ const char *s = lua_tolstring(L, 1, &l);
+ if (l > 0) {
+ int cs = string_lookup(s, l);
+ if (lua_toboolean(L, 2)) {
+ b = cs != undefined_control_sequence;
+ } else {
+ b = eq_type(cs) != undefined_cs_cmd;
+ }
+ }
+ }
+ lua_pushboolean(L, b);
+ return 1;
+}
static int run_build(lua_State * L)
{
diff --git a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
index 5187bc89c01..deb77555178 100644
--- a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
@@ -149,106 +149,6 @@ static int do_luacprint(lua_State * L, int partial, int deftable)
return 0;
}
-/* the next one writes a raw token (number) */
-
-/*
-
-int luatwrite(lua_State * L)
-{
- int top = lua_gettop(L);
- if (top>0) {
- rope *rn = xmalloc(sizeof(rope)); // overkill
- int i = 1 ;
- luacstrings++; // should be luactokens
- rn->text = NULL;
- rn->tsize = 0;
- rn->partial = 0;
- rn->cattable = DEFAULT_CAT_TABLE;
- rn->next = NULL;
- rn->tok = 0;
- rn->nod = 0;
- if (write_spindle.head == NULL) {
- write_spindle.head = rn;
- } else {
- write_spindle.tail->next = rn;
- }
- write_spindle.tail = rn;
- write_spindle.complete = 0;
- while (1) {
- rn->tok = lua_tointeger(L,i);
- if (i<top) {
- rope *r = xmalloc(sizeof(rope)); // overkill
- r->text = NULL;
- r->tsize = 0;
- r->partial = 0;
- r->cattable = DEFAULT_CAT_TABLE;
- r->next = NULL;
- r->tok = 0;
- r->nod = 0;
- rn->next = r;
- rn = r;
- write_spindle.tail = rn;
- i++;
- } else {
- break;
- }
- }
- }
- return 0;
-}
-
-*/
-
-/* the next one writes a raw node (number) */
-
-/*
-
-int luanwrite(lua_State * L)
-{
- int top = lua_gettop(L);
- if (top>0) {
- rope *rn = xmalloc(sizeof(rope)); // overkill
- int i = 1 ;
- luacstrings++; // should be luactokens
- rn->text = NULL;
- rn->tsize = 0;
- rn->partial = 0;
- rn->cattable = DEFAULT_CAT_TABLE;
- rn->next = NULL;
- rn->tok = 0;
- rn->nod = 0;
- if (write_spindle.head == NULL) {
- write_spindle.head = rn;
- } else {
- write_spindle.tail->next = rn;
- }
- write_spindle.tail = rn;
- write_spindle.complete = 0;
- while (1) {
- rn->nod = lua_tointeger(L,i);
- if (i<top) {
- rope *r = xmalloc(sizeof(rope)); // overkill
- r->text = NULL;
- r->tsize = 0;
- r->partial = 0;
- r->cattable = DEFAULT_CAT_TABLE;
- r->next = NULL;
- r->tok = 0;
- r->nod = 0;
- rn->next = r;
- rn = r;
- write_spindle.tail = rn;
- i++;
- } else {
- break;
- }
- }
- }
- return 0;
-}
-
-*/
-
/* lua.write */
static int luacwrite(lua_State * L)
@@ -1308,6 +1208,39 @@ static int gettoks(lua_State * L)
return 1;
}
+static int getmark(lua_State *L)
+{
+ if (lua_gettop(L) == 0) {
+ lua_pushinteger(L, biggest_used_mark);
+ return 1;
+ } else if (lua_type(L, 1) == LUA_TSTRING) {
+ int num = luaL_optinteger(L, 2, 0);
+ if (num >= 0 && num <= biggest_used_mark) {
+ int ptr = null;
+ const char *s = lua_tostring(L, 1);
+ if (lua_key_eq(s, top)) {
+ ptr = top_marks_array[num];
+ } else if (lua_key_eq(s, first)) {
+ ptr = first_marks_array[num];
+ } else if (lua_key_eq(s, bottom)) {
+ ptr = bot_marks_array[num];
+ } else if (lua_key_eq(s, splitfirst)) {
+ ptr = split_first_marks_array[num];
+ } else if (lua_key_eq(s, splitbottom)) {
+ ptr = split_bot_marks_array[num];
+ }
+ if (ptr) {
+ char *str = tokenlist_to_cstring(ptr, 1, NULL);
+ lua_pushstring(L, str);
+ free(str);
+ return 1;
+ }
+ }
+ }
+ lua_pushnil(L);
+ return 1;
+}
+
static int get_box_id(lua_State * L, int i, boolean report)
{
const char *s;
@@ -2133,16 +2066,16 @@ static int getromannumeral(lua_State * L)
static int get_parshape(lua_State * L)
{
- halfword par_shape_ptr = par_shape_par_ptr;
- if (par_shape_ptr != 0) {
+ halfword ptr = par_shape_par_ptr;
+ if (ptr != null) {
int m = 1;
- int n = vinfo(par_shape_ptr + 1);
+ int n = vinfo(ptr + 1);
lua_createtable(L, n, 0);
while (m <= n) {
lua_createtable(L, 2, 0);
- lua_pushinteger(L, vlink((par_shape_ptr) + (2 * (m - 1)) + 2));
+ lua_pushinteger(L, vlink((ptr) + (2 * (m - 1)) + 2));
lua_rawseti(L, -2, 1);
- lua_pushinteger(L, vlink((par_shape_ptr) + (2 * (m - 1)) + 3));
+ lua_pushinteger(L, vlink((ptr) + (2 * (m - 1)) + 3));
lua_rawseti(L, -2, 2);
lua_rawseti(L, -2, m);
m++;
@@ -2153,6 +2086,38 @@ static int get_parshape(lua_State * L)
return 1;
}
+static int get_etex_parshape(lua_State * L, int code)
+{
+ halfword ptr = null;
+ switch (code) {
+ case inter_line_penalties_loc:
+ ptr = inter_line_penalties_par_ptr;
+ break;
+ case club_penalties_loc:
+ ptr = club_penalties_par_ptr;
+ break;
+ case widow_penalties_loc:
+ ptr = widow_penalties_par_ptr;
+ break;
+ case display_widow_penalties_loc:
+ ptr = display_widow_penalties_par_ptr;
+ break;
+ }
+ if (ptr != null) {
+ int m = 1;
+ int n = vinfo(ptr + 1) + 1;
+ lua_createtable(L, n, 0);
+ while (m <= n) {
+ lua_pushinteger(L, penalty(ptr + m));
+ lua_rawseti(L, -2, m);
+ m++;
+ }
+ } else {
+ lua_pushnil(L);
+ }
+ return 1;
+}
+
static int gettex(lua_State * L)
{
int cur_cs1 = -1;
@@ -2222,6 +2187,9 @@ static int gettex(lua_State * L)
case set_tex_shape_cmd:
retval = get_parshape(L);
break;
+ case set_etex_shape_cmd:
+ retval = get_etex_parshape(L, cur_code);
+ break;
default:
lua_pushnil(L);
break;
@@ -3608,10 +3576,6 @@ static const struct luaL_Reg texlib[] = {
{ "sprint", luacsprint },
{ "tprint", luactprint },
{ "cprint", luaccprint },
- /*
- { "twrite", luatwrite },
- { "nwrite", luanwrite },
- */
{ "error", texerror },
{ "set", settex },
{ "get", gettex },
@@ -3640,6 +3604,7 @@ static const struct luaL_Reg texlib[] = {
{ "settoks", settoks },
{ "scantoks", scantoks },
{ "gettoks", gettoks },
+ { "getmark", getmark },
{ "isbox", isbox },
{ "setbox", setbox },
{ "getbox", getbox },
diff --git a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h
index 14650ffdcee..06692cb0202 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h
+++ b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h
@@ -610,6 +610,8 @@ make_lua_key(best_size);\
make_lua_key(bin);\
make_lua_key(bleed);\
make_lua_key(bot);\
+make_lua_key(bottom);\
+make_lua_key(splitbottom);\
make_lua_key(bot_accent);\
make_lua_key(bothflexible);\
make_lua_key(bottom_left);\
@@ -761,6 +763,7 @@ make_lua_key(fin_row);\
make_lua_key(finalhyphendemerits);\
make_lua_key(finalpenalty);\
make_lua_key(first);\
+make_lua_key(splitfirst);\
make_lua_key(fit);\
make_lua_key(fitb);\
make_lua_key(fitbh);\
@@ -1317,6 +1320,8 @@ init_lua_key(best_size);\
init_lua_key(bin);\
init_lua_key(bleed);\
init_lua_key(bot);\
+init_lua_key(bottom);\
+init_lua_key(splitbottom);\
init_lua_key(bot_accent);\
init_lua_key(bothflexible);\
init_lua_key(bottom_left);\
@@ -1467,6 +1472,7 @@ init_lua_key(fin_row);\
init_lua_key(finalhyphendemerits);\
init_lua_key(finalpenalty);\
init_lua_key(first);\
+init_lua_key(splitfirst);\
init_lua_key(fit);\
init_lua_key(fitb);\
init_lua_key(fitbh);\
@@ -2073,6 +2079,8 @@ use_lua_key(best_size);
use_lua_key(bin);
use_lua_key(bleed);
use_lua_key(bot);
+use_lua_key(bottom);
+use_lua_key(splitbottom);
use_lua_key(bot_accent);
use_lua_key(bothflexible);
use_lua_key(bottom_left);
@@ -2224,6 +2232,7 @@ use_lua_key(fin_row);
use_lua_key(finalhyphendemerits);
use_lua_key(finalpenalty);
use_lua_key(first);
+use_lua_key(splitfirst);
use_lua_key(fit);
use_lua_key(fitb);
use_lua_key(fitbh);
diff --git a/Build/source/texk/web2c/luatexdir/luatex_svnversion.h b/Build/source/texk/web2c/luatexdir/luatex_svnversion.h
index dbe2c11de1b..3218d05e711 100644
--- a/Build/source/texk/web2c/luatexdir/luatex_svnversion.h
+++ b/Build/source/texk/web2c/luatexdir/luatex_svnversion.h
@@ -1 +1 @@
-#define luatex_svn_revision 7353
+#define luatex_svn_revision 7381
diff --git a/Build/source/texk/web2c/luatexdir/luatexcallbackids.h b/Build/source/texk/web2c/luatexdir/luatexcallbackids.h
index dc2f05ca955..f06d5e0e094 100644
--- a/Build/source/texk/web2c/luatexdir/luatexcallbackids.h
+++ b/Build/source/texk/web2c/luatexdir/luatexcallbackids.h
@@ -76,6 +76,7 @@ typedef enum {
page_order_index_callback,
make_extensible_callback,
process_pdf_image_content_callback,
+ provide_charproc_data_callback,
total_callbacks,
} callback_callback_types;
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.c b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.c
index 3d37102b29a..63736787ec5 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.c
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.c
@@ -2187,6 +2187,7 @@ void pdf_finish_file(PDF pdf, int fatal_error) {
int outlines = 0;
int threads = 0;
int names_tree = 0;
+ int prerolled = 0;
size_t xref_offset_width;
int luatexversion = luatex_version;
str_number luatexrevision = get_luatexrevision();
@@ -2215,13 +2216,46 @@ void pdf_finish_file(PDF pdf, int fatal_error) {
check_nonexisting_pages(pdf);
check_nonexisting_destinations(pdf);
}
- /*tex Output fonts definition. */
+ /*tex
+ Output fonts definition.
+ */
+ pdf->gen_tounicode = pdf_gen_tounicode;
+ pdf->omit_cidset = pdf_omit_cidset;
+ pdf->omit_charset = pdf_omit_charset;
+ /*tex
+ The first pass over the list will flag the slots that are
+ used so that we can do a preroll for type 3 fonts.
+ */
for (k = 1; k <= max_font_id(); k++) {
if (font_used(k) && (pdf_font_num(k) < 0)) {
i = -pdf_font_num(k);
for (j = font_bc(k); j <= font_ec(k); j++)
if (quick_char_exists(k, j) && pdf_char_marked(k, j))
pdf_mark_char(i, j);
+ }
+ }
+ k = pdf->head_tab[obj_type_font];
+ while (k != 0) {
+ int f = obj_info(pdf, k);
+ if (do_pdf_preroll_font(pdf, f)) {
+ prerolled = 1;
+ }
+ k = obj_link(pdf, k);
+ }
+ /*tex
+ Just in case the user type 3 font has used fonts, we need to
+ do a second pass. We also collect some additional data here.
+ */
+ for (k = 1; k <= max_font_id(); k++) {
+ if (font_used(k) && (pdf_font_num(k) < 0)) {
+ i = -pdf_font_num(k);
+ if (prerolled) {
+ for (j = font_bc(k); j <= font_ec(k); j++)
+ if (quick_char_exists(k, j) && pdf_char_marked(k, j))
+ pdf_mark_char(i, j);
+ } else {
+ /*tex No need to waste time on checking again. */
+ }
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)) {
@@ -2231,9 +2265,6 @@ void pdf_finish_file(PDF pdf, int fatal_error) {
}
}
}
- pdf->gen_tounicode = pdf_gen_tounicode;
- pdf->omit_cidset = pdf_omit_cidset;
- pdf->omit_charset = pdf_omit_charset;
k = pdf->head_tab[obj_type_font];
while (k != 0) {
int f = obj_info(pdf, k);
@@ -2241,6 +2272,9 @@ void pdf_finish_file(PDF pdf, int fatal_error) {
k = obj_link(pdf, k);
}
write_fontstuff(pdf);
+ /*tex
+ We're done with the fonts.
+ */
if (total_pages > 0) {
pdf->last_pages = output_pages_tree(pdf);
/*tex Output outlines. */
diff --git a/Build/source/texk/web2c/luatexdir/tex/errors.c b/Build/source/texk/web2c/luatexdir/tex/errors.c
index 0c64927cea2..0c8f564236e 100644
--- a/Build/source/texk/web2c/luatexdir/tex/errors.c
+++ b/Build/source/texk/web2c/luatexdir/tex/errors.c
@@ -441,6 +441,21 @@ void error(void)
/*tex Get user's advice and |return|. */
while (1) {
CONTINUE:
+ /*tex
+ Original reports:
+
+ https://tex.stackexchange.com/questions/551313/
+ https://tug.org/pipermail/tex-live/2020-June/045876.html
+
+ This will probably be fixed by DEK in the 2021 tuneup in a different
+ way (so we'll have to remove or alter this change), but the interaction
+ sequence in the reports above causes a segmentation fault in web2c -
+ writing to the closed \write15 stream because we wrongly decrement
+ selector from 16 to 15 in term_input, due to the lack of this check in
+ recursive error() call.
+ */
+ if (interaction !=error_stop_mode)
+ return;
clear_for_error_prompt();
prompt_input("? ");
if (last == first)
@@ -879,6 +894,8 @@ When \TeX\ wants to typeset a character that doesn't exist, the character node i
not created; thus the output routine can assume that characters exist when it
sees them. The following procedure prints a warning message unless the user has
suppressed it.
+If |tracing_lost_chars_par| (i.e. \.{\\tracinglostchar}) is greater than 2,
+it's considered as an error.
*/
@@ -915,6 +932,9 @@ void char_warning(internal_font_number f, int c)
end_diagnostic(false);
tracing_online_par = old_setting;
}
+ if (tracing_lost_chars_par > 2) {
+ error();
+ }
}
void wrapup_backend(void) {
diff --git a/Build/source/texk/web2c/luatexdir/tex/extensions.c b/Build/source/texk/web2c/luatexdir/tex/extensions.c
index d24bee13b3f..60deb747a85 100644
--- a/Build/source/texk/web2c/luatexdir/tex/extensions.c
+++ b/Build/source/texk/web2c/luatexdir/tex/extensions.c
@@ -563,8 +563,9 @@ void write_out(halfword p)
int old_setting;
/*tex write stream number */
int j;
- /*tex line to be written, as a C string */
- char *s, *ss;
+ /*tex line to be written, as a Lua string */
+ lstring *ss = NULL;
+ lstring *s = NULL;
int callback_id;
int lua_retval;
expand_macros_in_tokenlist(p);
@@ -579,21 +580,21 @@ void write_out(halfword p)
} else {
tprint_nl("");
}
- s = tokenlist_to_cstring(def_ref, false, NULL);
+ s = tokenlist_to_lstring(def_ref, false);
if (selector < no_print) {
/*tex selector is a file */
callback_id = callback_defined(process_output_buffer_callback);
if (callback_id > 0) {
/*tex fix up the output buffer using callbacks */
- lua_retval = run_callback(callback_id, "S->S", s, &ss);
+ lua_retval = run_callback(callback_id, "L->L", s, &ss);
if ((lua_retval == true) && (ss != NULL)) {
- xfree(s);
+ free_lstring(s);
s = ss;
}
}
}
- tprint(s);
- xfree(s);
+ lprint(s);
+ free_lstring(s);
print_ln();
flush_list(def_ref);
selector = old_setting;
diff --git a/Build/source/texk/web2c/luatexdir/tex/mlist.c b/Build/source/texk/web2c/luatexdir/tex/mlist.c
index 43db6adbbb2..c34dee48839 100644
--- a/Build/source/texk/web2c/luatexdir/tex/mlist.c
+++ b/Build/source/texk/web2c/luatexdir/tex/mlist.c
@@ -1248,13 +1248,6 @@ static void stack_glue_into_box(pointer b, scaled min, scaled max) {
int cur_size = 0;
-/*tex A few state variables: */
-
-halfword del_height = 0;
-halfword del_depth = 0;
-halfword del_width = 0;
-halfword del_shift = 0;
-
static pointer get_delim_box(internal_font_number fnt, halfword chr, scaled v, scaled min_overlap, int horizontal, halfword att)
{
int callback_id = callback_defined(make_extensible_callback);
@@ -1549,10 +1542,8 @@ static pointer do_delimiter(pointer q, pointer d, int s, scaled v, boolean flat,
if (d && ! small_fam(d) && ! large_fam(d) && ! small_char(d) && ! large_char(d)) {
halfword b = new_null_box();
subtype(b) = math_v_delimiter_list;
- height(b) = del_height;
- depth(b) = del_depth;
- width(b) = del_width;
- shift_amount(b) = del_shift;
+ if (! flat)
+ width(b) = null_delimiter_space_par;
node_attr(b) = node_attr(d);
node_attr(d) = null;
flush_node(d);
@@ -1709,12 +1700,6 @@ static pointer do_delimiter(pointer q, pointer d, int s, scaled v, boolean flat,
}
DONE:
delete_attribute_ref(att);
-
- del_height = height(b);
- del_depth = depth(b);
- del_width = width(b);
- del_shift = shift_amount(b);
-
return b;
}
@@ -3003,10 +2988,7 @@ static void make_fraction(pointer q, int cur_style)
/*tex This also equals |width(z)|. */
width(v) = width(x);
reset_attributes(v, node_attr(q));
- if (thickness(q) == 0) {
- p = new_kern((shift_up - depth(x)) - (height(z) - shift_down));
- couple_nodes(p,z);
- } else {
+ if (thickness(q) && ! fractionnorule(q)) {
y = do_fraction_rule(thickness(q), node_attr(q), math_fraction_rule, cur_size, used_fam);
p = new_kern((math_axis_size(cur_size) - delta) - (height(z) - shift_down));
reset_attributes(p, node_attr(q));
@@ -3014,6 +2996,9 @@ static void make_fraction(pointer q, int cur_style)
couple_nodes(p,z);
p = new_kern((shift_up - depth(x)) - (math_axis_size(cur_size) + delta));
couple_nodes(p,y);
+ } else {
+ p = new_kern((shift_up - depth(x)) - (height(z) - shift_down));
+ couple_nodes(p,z);
}
reset_attributes(p, node_attr(q));
couple_nodes(x,p);
@@ -3321,12 +3306,10 @@ static scaled make_op(pointer q, int cur_style)
shift_down = limit_below_bgap(cur_style) - height(z);
if (shift_down < limit_below_vgap(cur_style))
shift_down = limit_below_vgap(cur_style);
- if (shift_down > 0) {
- p = new_kern(shift_down);
- reset_attributes(p, node_attr(q));
- couple_nodes(y,p);
- couple_nodes(p,z);
- }
+ p = new_kern(shift_down);
+ reset_attributes(p, node_attr(q));
+ couple_nodes(y,p);
+ couple_nodes(p,z);
p = new_kern(limit_below_kern(cur_style));
reset_attributes(p, node_attr(q));
couple_nodes(z,p);
diff --git a/Build/source/texk/web2c/luatexdir/tex/scanning.c b/Build/source/texk/web2c/luatexdir/tex/scanning.c
index 66f28a18b13..2ecb54bc2f6 100644
--- a/Build/source/texk/web2c/luatexdir/tex/scanning.c
+++ b/Build/source/texk/web2c/luatexdir/tex/scanning.c
@@ -536,9 +536,7 @@ static boolean short_scan_something_internal(int cmd, int chr, int level, boolea
/*tex assumes identical values */
cur_val_level = cur_chr;
}
- if ((cur_list.tail_field != contrib_head) &&
- !is_char_node(cur_list.tail_field) &&
- (cur_list.mode_field != 0)) {
+ if ((cur_list.tail_field != contrib_head) && (cur_list.mode_field != 0)) {
switch (cur_chr) {
case lastpenalty_code:
if (type(cur_list.tail_field) == penalty_node)
diff --git a/Build/source/texk/web2c/luatexdir/tex/texmath.c b/Build/source/texk/web2c/luatexdir/tex/texmath.c
index fd04e2a5c11..4d2bf80ecd6 100644
--- a/Build/source/texk/web2c/luatexdir/tex/texmath.c
+++ b/Build/source/texk/web2c/luatexdir/tex/texmath.c
@@ -1926,6 +1926,8 @@ void math_fraction(void)
while (1) {
if (scan_keyword("exact")) {
options = options | noad_option_exact ;
+ } else if (scan_keyword("norule")) {
+ options = options | noad_option_no_rule ;
} else {
break;
}
diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.h b/Build/source/texk/web2c/luatexdir/tex/texnodes.h
index 848f9ea4799..121511bc098 100644
--- a/Build/source/texk/web2c/luatexdir/tex/texnodes.h
+++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.h
@@ -597,6 +597,7 @@ typedef enum {
noad_option_no_sub_script = 0x21 + 0x08,
noad_option_no_super_script = 0x22 + 0x08,
noad_option_no_script = 0x23 + 0x08,
+ noad_option_no_rule = 0x24 + 0x08,
} delimiter_options ;
# define delimiteroptionset(a) ((delimiteroptions(a) & noad_option_set ) == noad_option_set )
@@ -657,6 +658,7 @@ typedef enum {
# define fractionoptionset(a) ((fractionoptions(a) & noad_option_set ) == noad_option_set )
# define fractionexact(a) ((fractionoptions(a) & noad_option_exact ) == noad_option_exact )
# define fractionnoaxis(a) ((fractionoptions(a) & noad_option_no_axis) == noad_option_no_axis)
+# define fractionnorule(a) ((fractionoptions(a) & noad_option_no_rule) == noad_option_no_rule)
/* radical noads */
/* this is like a fraction, but it only stores a |left_delimiter| */
diff --git a/Build/source/texk/web2c/luatexdir/tex/textoken.c b/Build/source/texk/web2c/luatexdir/tex/textoken.c
index a59e650df42..e28626bbd26 100644
--- a/Build/source/texk/web2c/luatexdir/tex/textoken.c
+++ b/Build/source/texk/web2c/luatexdir/tex/textoken.c
@@ -2352,6 +2352,8 @@ void ins_the_toks(void)
*/
+# define immediate_permitted(n,target) ((eq_level(toks_base + n) == cur_level) && (token_ref_count(target) == 0))
+
void combine_the_toks(void)
{
halfword how = cur_chr;
@@ -2395,7 +2397,7 @@ void combine_the_toks(void)
token_link(source) = null;
} else if (append) {
/*tex Append. */
- if (token_ref_count(target) == 0) {
+ if (immediate_permitted(nt,target)) {
p = t;
while (token_link(p) != null) {
p = token_link(p);
@@ -2405,13 +2407,12 @@ void combine_the_toks(void)
s = token_link(s);
}
} else {
- token_ref_count(target)--;
append_copied_toks_list(t,s);
set_toks_register(nt,temp_token_head,global);
}
} else {
/* prepend */
- if (token_ref_count(target) == 0) {
+ if (immediate_permitted(nt,target)) {
h = null;
p = null ;
while (s != null) {
@@ -2424,7 +2425,6 @@ void combine_the_toks(void)
set_token_link(p,t);
set_token_link(target,h);
} else {
- token_ref_count(target)--;
append_copied_toks_list(s,t);
set_toks_register(nt,temp_token_head,global);
}
@@ -2455,7 +2455,7 @@ void combine_the_toks(void)
t = token_link(target);
if (append) {
/*tex Append. */
- if (token_ref_count(target) == 0) {
+ if (immediate_permitted(nt,target)) {
p = t;
while (token_link(p) != null) {
p = token_link(p);
@@ -2465,13 +2465,12 @@ void combine_the_toks(void)
s = token_link(s);
}
} else {
- token_ref_count(target)--;
append_copied_toks_list(t,s);
set_toks_register(nt,temp_token_head,global);
}
} else {
/*tex Prepend. */
- if (token_ref_count(target) == 0) {
+ if (immediate_permitted(nt,target)) {
h = null;
p = null;
while (s != null) {
@@ -2484,7 +2483,6 @@ void combine_the_toks(void)
set_token_link(p,t);
set_token_link(target,h);
} else {
- token_ref_count(target)--;
append_copied_toks_list(s,t);
set_toks_register(nt,temp_token_head,global);
}
@@ -2873,6 +2871,8 @@ void conv_toks(void)
warning_index = save_warning_index;
scanner_status = save_scanner_status;
ins_list(token_link(def_ref));
+ token_link(def_ref) = null;
+ free_avail(def_ref);
def_ref = save_def_ref;
restore_cur_string(u);
/*tex No further action. */