summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c
diff options
context:
space:
mode:
authorLuigi Scarso <luigi.scarso@gmail.com>2018-01-09 23:43:20 +0000
committerLuigi Scarso <luigi.scarso@gmail.com>2018-01-09 23:43:20 +0000
commitaa5d0e8bf3515c424ba0594a2d4e06ae31da7796 (patch)
treee56fd10d89732547ddb207c1998a1ded4360382e /Build/source/texk/web2c
parentd33684eeca435784c95c62c7981dd02f7818b263 (diff)
Imported Luatex 1.06.3 (Lua 5.2.4)
git-svn-id: svn://tug.org/texlive/trunk@46269 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c')
-rw-r--r--Build/source/texk/web2c/luatexdir/ChangeLog75
-rw-r--r--Build/source/texk/web2c/luatexdir/am/luatex.am3
-rw-r--r--Build/source/texk/web2c/luatexdir/font/luafont.w270
-rw-r--r--Build/source/texk/web2c/luatexdir/font/texfont.h10
-rw-r--r--Build/source/texk/web2c/luatexdir/font/texfont.w27
-rw-r--r--Build/source/texk/web2c/luatexdir/font/vfpacket.w24
-rw-r--r--Build/source/texk/web2c/luatexdir/font/writefont.w35
-rw-r--r--Build/source/texk/web2c/luatexdir/font/writetype2.w34
-rw-r--r--Build/source/texk/web2c/luatexdir/image/image.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/image/pdftoepdf.w70
-rw-r--r--Build/source/texk/web2c/luatexdir/image/writeimg.w5
-rw-r--r--Build/source/texk/web2c/luatexdir/image/writejbig2.w2
-rw-r--r--Build/source/texk/web2c/luatexdir/image/writejpg.w14
-rw-r--r--Build/source/texk/web2c/luatexdir/lang/hyphen.w22
-rw-r--r--Build/source/texk/web2c/luatexdir/lang/texlang.h4
-rw-r--r--Build/source/texk/web2c/luatexdir/lang/texlang.w283
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lauxlib_bridge.h1
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c3
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lepdflib.cc348
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lfontlib.c72
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/liolibext.c274
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/llualib.c11
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lnodelib.c600
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lpdflib.c21
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc2
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lstatslib.c13
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lstrlibext.c130
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/ltexlib.c223
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luainit.w70
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luanode.w13
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luastuff.w28
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luatex-api.h10
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luatex-core.c460
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luatex-core.lua442
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luatoken.w1
-rw-r--r--Build/source/texk/web2c/luatexdir/luaffi/ctype.c2
-rw-r--r--Build/source/texk/web2c/luatexdir/luaffi/ffi.c7
-rw-r--r--Build/source/texk/web2c/luatexdir/luaffi/ffi.h6
-rw-r--r--Build/source/texk/web2c/luatexdir/luapeg/lpeg.c150
-rw-r--r--Build/source/texk/web2c/luatexdir/luapeg/lpeg.h106
-rw-r--r--Build/source/texk/web2c/luatexdir/luatex.c24
-rw-r--r--Build/source/texk/web2c/luatexdir/luatex_svnversion.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/luatexcallbackids.h3
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdffont.w3
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfgen.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfgen.w80
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w7
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w23
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdftables.h3
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdftypes.h1
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfxform.h4
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfxform.w6
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/commands.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/commands.w17
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/conditional.w3
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/dumpdata.w2
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/equivalents.h20
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/errors.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/errors.w4
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/expand.w2
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/linebreak.w25
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/mainbody.h2
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/mainbody.w19
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/maincontrol.w37
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/mlist.w722
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/printing.w67
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/texfileio.w9
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/texmath.h1
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/texmath.w99
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/texnodes.h108
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/texnodes.w187
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/textoken.w9
-rw-r--r--Build/source/texk/web2c/luatexdir/utils/utils.w32
73 files changed, 3691 insertions, 1709 deletions
diff --git a/Build/source/texk/web2c/luatexdir/ChangeLog b/Build/source/texk/web2c/luatexdir/ChangeLog
index 24f4d69dff5..89c26f5ce1e 100644
--- a/Build/source/texk/web2c/luatexdir/ChangeLog
+++ b/Build/source/texk/web2c/luatexdir/ChangeLog
@@ -1,24 +1,65 @@
-2017-09-18 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+2017-10-03 Luigi Scarso <luigi.scarso@gmail.com>
+ A not exhaustive list of changes:
- * luatex.c : Import comment from the upstream.
+ * luaffi/: Fix to compile with gcc 7.1,
+ patch for callbacks.
+ * lpeg/: version 1.0.1
+
+ * luatex.c: We conform to the way Web2c does handle trailing tabs and spaces. This
+ decade old behaviour was changed in September 2017 and can introduce
+ compatibility issues in existing workflows. Because we don't want too
+ many differences with upstream TeXlive we just follow up on that patch
+ and it's up to macro packages to deal with possible issues (which can be
+ done via the usual callbacks. One can wonder why we then still prune
+ spaces but we leave that to the reader.
+
+ * option to set exit code (status.setexitcode) (HH). Changed paths:
+ luatexdir/tex/errors.h, luatexdir/tex/errors.w
+
+ * missing_glyph callback (HH). Changed paths:
+ luatexdir/font/texfont.h, luatexdir/font/texfont.w,luatexdir/lua/lcallbacklib.c
+ luatexdir/luatexcallbackids.h, luatexdir/pdf/pdffont.w, luatexdir/pdf/pdfglyph.w;
+
+ * \mathdelimitersmode (see manual) (HH). Changed paths:
+ luatexdir/tex/mlist.w, luatexdir/tex/texnodes.h
+
+ * fixes in protect/unprotect and list support in set/getglue (HH). Changed paths:
+ luatexdir/lua/lnodelib.c
+
+ * 'class' string in pdf vf command optional (HH). Changed paths:
+ luatexdir/font/luafont.w
+
+ * cleanup expansion (HH). Changed paths:
+ luatexdir/font/luafont.w, luatexdir/font/texfont.h, luatexdir/font/texfont.w
+ luatexdir/lua/lfontlib.c, luatexdir/lua/luatex-api.h, luatexdir/tex/dumpdata.w
+
+ * possibly better fix for extended font embedding (HH). Changed paths:
+ luatexdir/font/writefont.w
+
+ * protect_glyphs accepts range and also made consistent with manual (HH). Changed path:
+ luatexdir/lua/lnodelib.c
+
+ * some more control over syntex fields (HH). Changed paths:
+ luatexdir/tex/texnodes.w
+
+ * fix for neg display skips (HH). Changed paths:
+ luatexdir/tex/texmath.w
+
+ * \breakafterdirmode (value 1 will honor glue breaks after a dir node) (HH). Changed paths:
+ luatexdir/tex/commands.w, luatexdir/tex/dumpdata.w, luatexdir/tex/equivalents.h,
+ luatexdir/tex/linebreak.w, luatexdir/tex/texnodes.h
+
+ * fix width array of extended font (shared with normal)(HH). Changed paths:
+ luatexdir/font/writefont.w
-2017-09-05 Karl Berry <karl@tug.org>
- and Akira Kakuto <kakuto@fuk.kindai.ac.jp>
- * luatex.c (IS_SPC_OR_EOL): new macro.
- (topenin): use it, instead of ISBLANK.
- (input_line): remove only trailing space characters
- instead of using ISBLANK.
- See also analogous change in lib/texmfmp.c.
- Original bug report from Evan Aad,
- http://tug.org/pipermail/tex-k/2017-August/002801.html.
- Fix a bug to skip BOM (w32 only).
2017-02-07 Luigi Scarso <luigi.scarso@gmail.com>
* luaffi/: First attempt to implement the ffi module in lua
compatible with the ffi module of luajit.
+
2015-11-01 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
* luatex.c: Improve a little (w32 only).
@@ -529,11 +570,11 @@
* lua/lepdflib.cc: No need to test for Annot::decRefCnt with
poppler 0.18 or better.
-2012-11-06 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+2012-11-06 Akira Kakuto <kakuto@fuk.kinidai.ac.jp>
* pdf/pdflistout.w: sync with r4471 (a bug fix by H. Henkel).
-2012-10-13 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+2012-10-13 Akira Kakuto <kakuto@fuk.kinidai.ac.jp>
* tex/texfileio.w: input by pipe was impossible. enable it.
@@ -541,7 +582,7 @@
* lua/luainit.w (lua_initialize): Free two malloc()ed strings.
-2012-10-10 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+2012-10-10 Akira Kakuto <kakuto@fuk.kinidai.ac.jp>
* luatex.c: Modify determination of fullpath for restricted shell
escape commands.
@@ -567,7 +608,7 @@
* lua/luainit.w (parse_options): Avoid cast const => non-const.
-2012-09-13 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+2012-09-13 Akira Kakuto <kakuto@fuk.kinidai.ac.jp>
* lua/luainit.w (parse_options): allow lualatex "\input" "a b" on
Windows.
@@ -577,7 +618,7 @@
* luatex-api.h: Avoid conflicting extern declaration of environ,
declared in <stdlib.h> for WIN32 (from W32TeX).
-2012-08-21 Akira Kakuto <kakuto@fuk.kindai.ac.jp>
+2012-08-21 Akira Kakuto <kakuto@fuk.kinidai.ac.jp>
* tex/texdeffont.w (tex_def_font): Recover the old code, because the
new code seems not to work.
diff --git a/Build/source/texk/web2c/luatexdir/am/luatex.am b/Build/source/texk/web2c/luatexdir/am/luatex.am
index 2436d8891d4..41b8610a251 100644
--- a/Build/source/texk/web2c/luatexdir/am/luatex.am
+++ b/Build/source/texk/web2c/luatexdir/am/luatex.am
@@ -72,8 +72,7 @@ luatex_sources = \
mplibdir/lmplib.c
EXTRA_DIST += \
- $(luatex_sources) \
- luatexdir/getluatexsvnversion.sh
+ $(luatex_sources)
call_luatex_CPPFLAGS = -DEXEPROG=\"luatex.exe\"
nodist_call_luatex_SOURCES = callexe.c
diff --git a/Build/source/texk/web2c/luatexdir/font/luafont.w b/Build/source/texk/web2c/luatexdir/font/luafont.w
index 4e874d9becb..7065f96d904 100644
--- a/Build/source/texk/web2c/luatexdir/font/luafont.w
+++ b/Build/source/texk/web2c/luatexdir/font/luafont.w
@@ -461,9 +461,6 @@ int font_to_lua(lua_State * L, int f)
if (font_step(f) != 0) {
dump_intfield(L,step,font_step(f));
}
- if (font_auto_expand(f) != 0) {
- dump_booleanfield(L,auto_expand,font_auto_expand(f));
- }
if (pdf_font_attr(f) != 0) {
char *s = makecstring(pdf_font_attr(f));
dump_stringfield(L,attributes,s);
@@ -623,6 +620,7 @@ static int n_some_field(lua_State * L, int name_index)
static int count_char_packet_bytes(lua_State * L)
{
register int i;
+ register int ts;
register int l = 0;
int ff = 0;
for (i = 1; i <= (int) lua_rawlen(L, -1); i++) {
@@ -642,39 +640,57 @@ static int count_char_packet_bytes(lua_State * L)
ff = 1;
} else if (lua_key_eq(s, slot)) {
l += 10;
- ff = 1;
} else if (lua_key_eq(s, comment) || lua_key_eq(s, nop)) {
;
} else if (lua_key_eq(s, push) || lua_key_eq(s, pop)) {
l++;
} else if (lua_key_eq(s, rule)) {
l += 9;
- } else if (lua_key_eq(s, right) || lua_key_eq(s, node)
- || lua_key_eq(s, down) || lua_key_eq(s, image)) {
+ } else if (lua_key_eq(s, right) || lua_key_eq(s, node) || lua_key_eq(s, down) || lua_key_eq(s, image)) {
l += 5;
} else if (lua_key_eq(s, scale)) {
l += sizeof(float) + 1;
+ } else if (lua_key_eq(s, pdf)) {
+ size_t len;
+ l += 5;
+ ts = lua_rawlen(L, -2);
+ lua_rawgeti(L, -2, 2);
+ if (ts == 3) {
+ if (lua_type(L,-1) == LUA_TSTRING) {
+ /* no need to do something */
+ } else if (lua_type(L,-1) == LUA_TNUMBER) {
+ /* no need to do something */
+ } else {
+ normal_error("vf command","invalid packet pdf literal category");
+ }
+ lua_rawgeti(L, -3, 3);
+ }
+ if (lua_type(L,-1) == LUA_TSTRING) {
+ (void) lua_tolstring(L, -1, &len);
+ if (len > 0) {
+ l = (int) (l + 5 + (int) len);
+ }
+ } else {
+ normal_error("vf command","invalid packet pdf literal");
+ }
+ lua_pop(L, ts == 3 ? 2 : 1);
} else if (lua_key_eq(s, special) || lua_key_eq(s, lua)) {
size_t len;
lua_rawgeti(L, -2, 2);
if (lua_type(L,-1) == LUA_TSTRING) {
(void) lua_tolstring(L, -1, &len);
- lua_pop(L, 1);
if (len > 0) {
l = (int) (l + 5 + (int) len);
}
} else {
- lua_pop(L, 1);
normal_error("vf command","invalid packet special");
- /* fprintf(stdout, "invalid packet special!\n"); */
}
+ lua_pop(L, 1);
} else {
normal_error("vf command","unknown packet command");
- /* fprintf(stdout, "unknown packet command %s!\n", s); */
}
} else {
normal_error("vf command","no packet command");
- /* fprintf(stdout, "no packet command!\n"); */
}
lua_pop(L, 1); /* command name */
}
@@ -700,6 +716,8 @@ static void read_char_packets(lua_State * L, int *l_fonts, charinfo * co, intern
const char *s;
eight_bits *cpackets, *cp;
int ff = 0;
+ int sf = 0;
+ int ts = 0;
int max_f = 0;
int pc = count_char_packet_bytes(L);
if (pc <= 0)
@@ -725,19 +743,20 @@ static void read_char_packets(lua_State * L, int *l_fonts, charinfo * co, intern
do_store_four(ff);
}
} else if (lua_key_eq(s, slot)) {
+ /* we could be sparse but no real reason */
cmd = packet_nop_code;
lua_rawgeti(L, -2, 2);
- n = (int) luaL_checkinteger(L, -1);
- if (n ==0) {
- ff = f;
+ n = (int) lua_roundnumber(L, -1);
+ if (n == 0) {
+ sf = f;
} else {
- ff = (n > max_f ? l_fonts[1] : l_fonts[n]);
+ sf = (n > max_f ? l_fonts[1] : l_fonts[n]);
}
lua_rawgeti(L, -3, 3);
- n = (int) luaL_checkinteger(L, -1);
+ n = (int) lua_roundnumber(L, -1);
lua_pop(L, 2);
append_packet(packet_font_code);
- do_store_four(ff);
+ do_store_four(sf);
append_packet(packet_char_code);
do_store_four(n);
} else if (lua_key_eq(s, comment) || lua_key_eq(s, nop)) {
@@ -754,6 +773,8 @@ static void read_char_packets(lua_State * L, int *l_fonts, charinfo * co, intern
cmd = packet_right_code;
} else if (lua_key_eq(s, down)) {
cmd = packet_down_code;
+ } else if (lua_key_eq(s, pdf)) {
+ cmd = packet_pdf_code;
} else if (lua_key_eq(s, special)) {
cmd = packet_special_code;
} else if (lua_key_eq(s, image)) {
@@ -771,7 +792,7 @@ static void read_char_packets(lua_State * L, int *l_fonts, charinfo * co, intern
case packet_font_code:
append_packet(cmd);
lua_rawgeti(L, -2, 2);
- n = (int) luaL_checkinteger(L, -1);
+ n = (int) lua_roundnumber(L, -1);
if (n == 0) {
ff = n;
} else {
@@ -790,7 +811,7 @@ static void read_char_packets(lua_State * L, int *l_fonts, charinfo * co, intern
case packet_char_code:
append_packet(cmd);
lua_rawgeti(L, -2, 2);
- n = (int) luaL_checkinteger(L, -1);
+ n = (int) lua_roundnumber(L, -1);
do_store_four(n);
lua_pop(L, 1);
break;
@@ -798,20 +819,62 @@ static void read_char_packets(lua_State * L, int *l_fonts, charinfo * co, intern
case packet_down_code:
append_packet(cmd);
lua_rawgeti(L, -2, 2);
- n = (int) luaL_checkinteger(L, -1);
+ n = (int) lua_roundnumber(L, -1);
do_store_four(sp_to_dvi(n, atsize));
lua_pop(L, 1);
break;
case packet_rule_code:
append_packet(cmd);
lua_rawgeti(L, -2, 2);
- n = (int) luaL_checkinteger(L, -1);
+ n = (int) lua_roundnumber(L, -1);
do_store_four(sp_to_dvi(n, atsize));
lua_rawgeti(L, -3, 3);
- n = (int) luaL_checkinteger(L, -1);
+ n = (int) lua_roundnumber(L, -1);
do_store_four(sp_to_dvi(n, atsize));
lua_pop(L, 2);
break;
+ case packet_pdf_code:
+ append_packet(cmd);
+ ts = (int) lua_rawlen(L, -2);
+ lua_rawgeti(L, -2, 2);
+ if (ts == 3) {
+ if (lua_type(L, -1) == LUA_TSTRING) {
+ s = lua_tostring(L, -1);
+ if (lua_key_eq(s, direct)) {
+ n = direct_always;
+ } else if (lua_key_eq(s, page)) {
+ n = direct_page;
+ } else if (lua_key_eq(s, raw)) {
+ n = direct_raw;
+ } else if (lua_key_eq(s, origin)) {
+ n = set_origin;
+ } else {
+ /* normal_warning("vf command","invalid pdf literal type"); */
+ n = set_origin ;
+ }
+ } else {
+ n = (int) lua_roundnumber(L, -1);
+ if (n < set_origin || n > direct_raw) {
+ n = set_origin ;
+ }
+ }
+ lua_rawgeti(L, -3, 3);
+ } else {
+ n = set_origin;
+ }
+ do_store_four(n);
+ s = luaL_checklstring(L, -1, &l);
+ if (l > 0) {
+ do_store_four(l);
+ m = (int) l;
+ while (m > 0) {
+ n = *s++;
+ m--;
+ append_packet(n);
+ }
+ }
+ lua_pop(L,ts == 3 ? 2 : 1);
+ break;
case packet_special_code:
case packet_lua_code:
append_packet(cmd);
@@ -1144,8 +1207,7 @@ static void font_char_from_lua(lua_State * L, internal_font_number f, int i, int
set_charinfo_tag(co, ext_tag);
set_charinfo_extensible(co, top, bot, mid, rep);
} else {
- formatted_warning("font", "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);
@@ -1248,8 +1310,7 @@ static void font_char_from_lua(lua_State * L, internal_font_number f, int i, int
set_kern_item(ckerns[ctr], k, j);
ctr++;
} else {
- formatted_warning("font", "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);
}
@@ -1258,13 +1319,13 @@ static void font_char_from_lua(lua_State * L, internal_font_number f, int i, int
set_kern_item(ckerns[ctr], end_kern, 0);
set_charinfo_kerns(co, ckerns);
} else {
- formatted_warning("font", "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);
}
/* packet commands */
+
lua_key_rawgeti(commands);
if (lua_istable(L, -1)) {
lua_pushnil(L); /* first key */
@@ -1307,8 +1368,7 @@ static void font_char_from_lua(lua_State * L, internal_font_number f, int i, int
set_ligature_item(cligs[ctr], (char) ((t * 2) + 1), k, r);
ctr++;
} else {
- formatted_warning("font", "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 */
}
@@ -1317,8 +1377,7 @@ static void font_char_from_lua(lua_State * L, internal_font_number f, int i, int
set_ligature_item(cligs[ctr], 0, end_ligature, 0);
set_charinfo_ligatures(co, cligs);
} else {
- formatted_warning("font", "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 */
}
@@ -1353,7 +1412,6 @@ int font_from_lua(lua_State * L, int f)
lua_pop(L,1);
/* the table is at stack index -1 */
-
s = n_string_field_copy(L,lua_key_index(area), "");
set_font_area(f, s);
s = n_string_field_copy(L, lua_key_index(filename), NULL);
@@ -1468,20 +1526,19 @@ int font_from_lua(lua_State * L, int f)
l_fonts[i] = find_font_id(ss, t);
lua_settop(L, s_top);
} else {
- formatted_error("font","invalid local font in lua-loaded font '%s'", font_name(f));
+ formatted_error("font","invalid local font at index %i in lua-loaded font '%s' (1)",i,font_name(f));
}
lua_pop(L, 1); /* pop list entry */
}
lua_pop(L, 1); /* pop font table */
} else if (font_type(f) == virtual_font_type) {
- formatted_error("font","invalid local fonts in lua-loaded font '%s'", font_name(f));
+ formatted_error("font","invalid local fonts in lua-loaded font '%s' (2)", font_name(f));
} else {
l_fonts = xmalloc(3 * sizeof(int));
l_fonts[0] = 0;
l_fonts[1] = f;
l_fonts[2] = 0;
}
-
/* parameters */
no_math = n_boolean_field(L, lua_key_index(nomath), 0);
read_lua_parameters(L, f);
@@ -1536,11 +1593,9 @@ int font_from_lua(lua_State * L, int f)
} else if (lt == LUA_TSTRING) {
const char *ss1 = lua_tostring(L, -2);
if (lua_key_eq(ss1, left_boundary)) {
- font_char_from_lua(L, f, left_boundarychar, l_fonts,
- !no_math);
+ font_char_from_lua(L, f, left_boundarychar, l_fonts, !no_math);
} else if (lua_key_eq(ss1, right_boundary)) {
- font_char_from_lua(L, f, right_boundarychar, l_fonts,
- !no_math);
+ font_char_from_lua(L, f, right_boundarychar, l_fonts, !no_math);
}
}
lua_pop(L, 1);
@@ -1561,7 +1616,6 @@ int font_from_lua(lua_State * L, int f)
if (fstep != 0) {
int fshrink = lua_numeric_field_by_index(L, lua_key_index(shrink), 0);
int fstretch =lua_numeric_field_by_index(L, lua_key_index(stretch), 0);
- int fexpand = n_boolean_field(L, lua_key_index(auto_expand), 0);
if (fshrink < 0)
fshrink = 0;
if (fshrink > 500)
@@ -1576,7 +1630,7 @@ int font_from_lua(lua_State * L, int f)
fstretch -= (fstretch % fstep);
if (fstretch < 0)
fstretch = 0;
- set_expand_params(f, fexpand, fstretch, fshrink, fstep);
+ set_expand_params(f, fstretch, fshrink, fstep);
}
}
@@ -1601,6 +1655,129 @@ int font_from_lua(lua_State * L, int f)
return true;
}
+int characters_from_lua(lua_State * L, int f)
+{
+ int i, n, t, lt;
+ int *l_fonts = NULL;
+ int s_top;
+ const char *ss;
+ boolean no_math = false;
+ /* speedup */
+ no_math = n_boolean_field(L, lua_key_index(nomath), 0);
+ /* type */
+ i = n_enum_field(L, lua_key_index(type), font_type(f), font_type_strings);
+ set_font_type(f, i);
+ /* fonts */
+ count_hash_items(L, fonts, n);
+ if (n > 0) {
+ /* font table still on stack */
+ l_fonts = xmalloc((unsigned) ((unsigned) (n + 2) * sizeof(int)));
+ memset(l_fonts, 0, (size_t) ((unsigned) (n + 2) * sizeof(int)));
+ for (i = 1; i <= n; i++) {
+ lua_rawgeti(L, -1, i);
+ if (lua_istable(L, -1)) {
+ lua_key_rawgeti(id);
+ if (lua_isnumber(L, -1)) {
+ l_fonts[i] = (int) lua_tointeger(L, -1);
+ if (l_fonts[i] == 0) {
+ l_fonts[i] = (int) f;
+ }
+ lua_pop(L, 2); /* pop id and entry */
+ continue;
+ }
+ lua_pop(L, 1); /* pop id */
+ };
+ ss = NULL;
+ if (lua_istable(L, -1)) {
+ ss = n_string_field(L, lua_key_index(name));
+ /* string is anchored */
+ lua_pop(L,1);
+ }
+ if (ss != NULL) {
+ t = lua_numeric_field_by_index(L, lua_key_index(size), -1000);
+ /* TODO: the stack is messed up, otherwise this explicit resizing would not be needed */
+ s_top = lua_gettop(L);
+ if (strcmp(font_name(f), ss) == 0)
+ l_fonts[i] = f;
+ else
+ l_fonts[i] = find_font_id(ss, t);
+ lua_settop(L, s_top);
+ } else {
+ formatted_error("font","invalid local font in lua-loaded font '%s' (3)", font_name(f));
+ }
+ lua_pop(L, 1); /* pop list entry */
+ }
+ lua_pop(L, 1); /* pop font table */
+ } else if (font_type(f) == virtual_font_type) {
+ formatted_error("font","invalid local fonts in lua-loaded font '%s' (4)", font_name(f));
+ } else {
+ l_fonts = xmalloc(3 * sizeof(int));
+ l_fonts[0] = 0;
+ l_fonts[1] = f;
+ l_fonts[2] = 0;
+ }
+ /* characters */
+ lua_key_rawgeti(characters);
+ if (lua_istable(L, -1)) {
+ /* find the array size values */
+ int num = 0; /* number of charinfo's to add */
+ int todo = 0;
+ int bc = font_bc(f);
+ int ec = font_ec(f);
+ lua_pushnil(L); /* first key */
+ while (lua_next(L, -2) != 0) {
+ if (lua_isnumber(L, -2)) {
+ i = (int) lua_tointeger(L, -2);
+ if (i >= 0) {
+ if (lua_istable(L, -1)) {
+ todo++;
+ if (! quick_char_exists(f,i)) {
+ num++;
+ if (i > ec)
+ ec = i;
+ if (bc < 0)
+ bc = i;
+ if (bc >= 0 && i < bc)
+ bc = i;
+ }
+ }
+ }
+ }
+ lua_pop(L, 1);
+ }
+ if (todo > 0) {
+ font_malloc_charinfo(f, num);
+ set_font_bc(f, bc);
+ set_font_ec(f, ec);
+ lua_pushnil(L); /* first key */
+ while (lua_next(L, -2) != 0) {
+ lt = lua_type(L,-2);
+ if (lt == LUA_TNUMBER) {
+ i = (int) lua_tointeger(L, -2);
+ if (i >= 0) {
+ if (quick_char_exists(f,i)) {
+ charinfo *co = char_info(f, i);
+ set_charinfo_name(co, NULL);
+ set_charinfo_tounicode(co, NULL);
+ set_charinfo_packets(co, NULL);
+ set_charinfo_ligatures(co, NULL);
+ set_charinfo_kerns(co, NULL);
+ set_charinfo_vert_variants(co, NULL);
+ set_charinfo_hor_variants(co, NULL);
+ }
+ font_char_from_lua(L, f, i, l_fonts, !no_math);
+ }
+ }
+ lua_pop(L, 1);
+ }
+ lua_pop(L, 1);
+ }
+ }
+ if (l_fonts != NULL)
+ free(l_fonts);
+ return true;
+}
+
@* Ligaturing.
@c
@@ -1995,8 +2172,9 @@ halfword handle_ligaturing(halfword head, halfword tail)
vlink(tail) = null;
}
- /* |if (fix_node_lists)| */
- fix_node_list(head);
+ if (fix_node_lists) {
+ fix_node_list(head);
+ }
prev = head;
cur = vlink(prev);
@@ -2184,7 +2362,9 @@ static halfword run_lua_ligkern_callback(halfword head, halfword tail, int callb
luatex_error(Luas, (i == LUA_ERRRUN ? 0 : 1));
return tail;
}
- fix_node_list(head);
+ if (fix_node_lists) {
+ fix_node_list(head);
+ }
lua_settop(Luas, top);
return tail;
}
diff --git a/Build/source/texk/web2c/luatexdir/font/texfont.h b/Build/source/texk/web2c/luatexdir/font/texfont.h
index 98557992f97..d415460b1e1 100644
--- a/Build/source/texk/web2c/luatexdir/font/texfont.h
+++ b/Build/source/texk/web2c/luatexdir/font/texfont.h
@@ -144,7 +144,6 @@ typedef struct texfont {
int font_max_shrink;
int font_max_stretch;
int _font_step; /* amount of one step of expansion */
- boolean _font_auto_expand; /* this font is auto-expanded? */
char _font_tounicode; /* 1 if info is present */
fm_entry *_font_map;
@@ -345,9 +344,6 @@ boolean cmp_font_area(int, str_number);
# define font_step(a) font_tables[a]->_font_step
# define set_font_step(a,b) font_step(a) = b
-# define font_auto_expand(a) font_tables[a]->_font_auto_expand
-# define set_font_auto_expand(a,b) font_auto_expand(a) = b
-
# define font_tounicode(a) font_tables[a]->_font_tounicode
# define set_font_tounicode(a,b) font_tounicode(a) = b
@@ -439,6 +435,7 @@ typedef enum {
extern charinfo *get_charinfo(internal_font_number f, int c);
extern int char_exists(internal_font_number f, int c);
+extern int lua_glyph_not_found_callback(internal_font_number f, int c);
extern charinfo *char_info(internal_font_number f, int c);
/*
@@ -627,6 +624,7 @@ typedef enum { packet_char_code,
packet_end_code,
packet_scale_code,
packet_lua_code,
+ packet_pdf_code,
} packet_command_codes;
extern scaled store_scaled_f(scaled sq, int fw);
@@ -655,9 +653,7 @@ extern internal_font_number tfm_lookup(char *s, scaled fs);
extern int fix_expand_value(internal_font_number f, int e);
-extern void set_expand_params(internal_font_number f, boolean auto_expand,
- int stretch_limit, int shrink_limit,
- int font_step);
+extern void set_expand_params(internal_font_number f, int stretch_limit, int shrink_limit, int font_step);
extern void read_expand_font(void);
extern void new_letterspaced_font(small_number a);
diff --git a/Build/source/texk/web2c/luatexdir/font/texfont.w b/Build/source/texk/web2c/luatexdir/font/texfont.w
index 0c64045752e..ce463326a86 100644
--- a/Build/source/texk/web2c/luatexdir/font/texfont.w
+++ b/Build/source/texk/web2c/luatexdir/font/texfont.w
@@ -348,12 +348,11 @@ int char_exists(internal_font_number f, int c)
}
@ @c
-#if 0
-static int lua_char_exists_callback(internal_font_number f, int c)
+int lua_glyph_not_found_callback(internal_font_number f, int c)
{
int callback_id;
int ret = 0;
- callback_id = callback_defined(char_exists_callback);
+ callback_id = callback_defined(glyph_not_found_callback);
if (callback_id != 0) {
if (!get_callback(Luas, callback_id)) {
lua_pop(Luas, 2);
@@ -368,10 +367,11 @@ static int lua_char_exists_callback(internal_font_number f, int c)
} else {
ret = lua_toboolean(Luas, -1);
}
+ } else {
+ char_warning(f,c);
}
return ret;
}
-#endif
@ @c
extinfo *new_variant(int glyph, int startconnect, int endconnect,
@@ -1535,7 +1535,6 @@ static void dump_font_entry(texfont * f)
dump_int(f->font_max_shrink);
dump_int(f->font_max_stretch);
dump_int(f->_font_step);
- dump_int(f->_font_auto_expand);
dump_int(f->_font_tounicode);
dump_int(f->_font_type);
dump_int(f->_font_format);
@@ -1715,7 +1714,6 @@ static void undump_font_entry(texfont * f)
undump_int(x); f->font_max_shrink = x;
undump_int(x); f->font_max_stretch = x;
undump_int(x); f->_font_step = x;
- undump_int(x); f->_font_auto_expand = x;
undump_int(x); f->_font_tounicode = (char)x;
undump_int(x); f->_font_type = x;
undump_int(x); f->_font_format = x;
@@ -1845,11 +1843,9 @@ int fix_expand_value(internal_font_number f, int e)
}
@ @c
-void set_expand_params(internal_font_number f, boolean auto_expand,
- int stretch_limit, int shrink_limit, int font_step)
-{ /* expand a font with given parameters */
+void set_expand_params(internal_font_number f, int stretch_limit, int shrink_limit, int font_step)
+{
set_font_step(f, font_step);
- set_font_auto_expand(f, auto_expand);
set_font_max_shrink(f, shrink_limit);
set_font_max_stretch(f, stretch_limit);
}
@@ -1859,7 +1855,6 @@ void read_expand_font(void)
{ /* read font expansion spec and load expanded font */
int shrink_limit, stretch_limit, font_step;
internal_font_number f;
- boolean auto_expand;
/* read font expansion parameters */
scan_font_ident();
f = cur_val;
@@ -1885,15 +1880,13 @@ void read_expand_font(void)
shrink_limit = 0;
if ((stretch_limit == 0) && (shrink_limit == 0))
normal_error("font expansion", "invalid limit(s)");
- auto_expand = false;
if (scan_keyword("autoexpand")) {
- auto_expand = true;
+ normal_warning("font expansion", "autoexpand not supported");
/* Scan an optional space */
get_x_token();
if (cur_cmd != spacer_cmd)
back_input();
}
-
if (font_step(f) != 0) {
/* this font has been expanded, ensure the expansion parameters are identical */
if (font_step(f) != font_step)
@@ -1908,14 +1901,10 @@ void read_expand_font(void)
((font_max_shrink(f) > 0)
&& (font_max_shrink(f) != shrink_limit)))
normal_error("font expansion","font has been expanded with different shrink limit");
-
- if (font_auto_expand(f) != auto_expand)
- 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");
- set_expand_params(f, auto_expand, stretch_limit, shrink_limit,
- font_step);
+ set_expand_params(f, stretch_limit, shrink_limit, font_step);
}
}
diff --git a/Build/source/texk/web2c/luatexdir/font/vfpacket.w b/Build/source/texk/web2c/luatexdir/font/vfpacket.w
index 5b76eb81f40..14a6ca61169 100644
--- a/Build/source/texk/web2c/luatexdir/font/vfpacket.w
+++ b/Build/source/texk/web2c/luatexdir/font/vfpacket.w
@@ -88,6 +88,9 @@ int vf_packet_bytes(charinfo * co)
case packet_rule_code:
vfp += 8;
break;
+ case packet_pdf_code:
+ vfp += 4;
+ /* plus a string so we fall through */
case packet_special_code:
packet_number(k); /* +4 */
vfp += (int) k;
@@ -104,7 +107,7 @@ int vf_packet_bytes(charinfo * co)
@c
const char *packet_command_names[] = {
"char", "font", "pop", "push", "special", "image",
- "right", "down", "rule", "node", "nop", "end", "scale", "lua", NULL
+ "right", "down", "rule", "node", "nop", "end", "scale", "lua", "pdf", NULL
};
@ @c
@@ -135,7 +138,7 @@ void do_vf_packet(PDF pdf, internal_font_number vf_f, int c, int ex_glyph)
eight_bits *vfp;
posstructure *save_posstruct, localpos;
vf_struct *save_vfstruct, localvfstruct, *vp;
- int cmd, w;
+ int cmd, w, mode;
unsigned k;
scaledpos size;
scaled i;
@@ -218,7 +221,7 @@ void do_vf_packet(PDF pdf, internal_font_number vf_f, int c, int ex_glyph)
packet_scaled(size.h, vp->fs_f);
if (size.h > 0 && size.v > 0)
backend_out[rule_node](pdf, 0, size); /* the 0 is unused */
- mat_p->pos.h += size.h;
+ mat_p->pos.h += size.h;
break;
case packet_right_code:
packet_scaled(i, vp->fs_f);
@@ -228,6 +231,18 @@ void do_vf_packet(PDF pdf, internal_font_number vf_f, int c, int ex_glyph)
packet_scaled(i, vp->fs_f);
mat_p->pos.v += i;
break;
+ case packet_pdf_code:
+ packet_number(mode);
+ packet_number(k);
+ str_room(k);
+ while (k > 0) {
+ k--;
+ append_char(*(vfp++));
+ }
+ s = make_string();
+ pdf_literal(pdf, s, mode, false);
+ flush_str(s);
+ break;
case packet_special_code:
packet_number(k);
str_room(k);
@@ -387,6 +402,9 @@ replace_packet_fonts(internal_font_number f, int *old_fontid,
case packet_rule_code:
vfp += 8;
break;
+ case packet_pdf_code:
+ vfp += 4;
+ /* plus a string so we fall through */
case packet_special_code:
packet_number(k);
vfp += k;
diff --git a/Build/source/texk/web2c/luatexdir/font/writefont.w b/Build/source/texk/web2c/luatexdir/font/writefont.w
index 76d88b68bc4..2ba81d61749 100644
--- a/Build/source/texk/web2c/luatexdir/font/writefont.w
+++ b/Build/source/texk/web2c/luatexdir/font/writefont.w
@@ -578,7 +578,7 @@ static void write_fontdescriptor(PDF pdf, fd_entry * fd)
assert(0);
}
}
- if ((! pdf->omit_cidset) && (cidset != 0)) {
+ if ((! pdf->omit_cidset) && (pdf->major_version == 1) && (cidset != 0) ) {
pdf_dict_add_ref(pdf, "CIDSet", cidset);
}
/*
@@ -901,6 +901,13 @@ ids, but the strings that are written out use CID indexes, and those are
limited to 16-bit values.
@c
+/*
+ This is old code ... it fails when the order of using the same font at
+ different extends changes. Probably because widths get overwritten or
+ set wrong. The loop also looks kind of weird (why a loop).
+*/
+
+/*
static void mark_cid_subset_glyphs(fo_entry * fo, internal_font_number f)
{
int i, k, l;
@@ -925,6 +932,32 @@ static void mark_cid_subset_glyphs(fo_entry * fo, internal_font_number f)
}
}
}
+*/
+
+/*
+ So, let's try the following.
+*/
+
+static void mark_cid_subset_glyphs(fo_entry * fo, internal_font_number f)
+{
+ glw_entry *j;
+ void *aa;
+ int l = font_size(f);
+ int i;
+ for (i = font_bc(f); i <= font_ec(f); i++) {
+ if (quick_char_exists(f, i) && char_used(f, i)) {
+ j = xtalloc(1, glw_entry);
+ j->id = (unsigned) char_index(f, i);
+ j->wd = divide_scaled_n(char_width(f, i), l, 10000.0);
+ if ((glw_entry *) avl_find(fo->fd->gl_tree, j) == NULL) {
+ aa = avl_probe(fo->fd->gl_tree, j);
+ assert(aa != NULL);
+ } else {
+ xfree(j);
+ }
+ }
+ }
+}
@ It is possible to compress the widths array even better, by using the
alternate 'range' syntax and possibly even using /DW to set a default
diff --git a/Build/source/texk/web2c/luatexdir/font/writetype2.w b/Build/source/texk/web2c/luatexdir/font/writetype2.w
index dc1821c5e5f..81aefb1fb69 100644
--- a/Build/source/texk/web2c/luatexdir/font/writetype2.w
+++ b/Build/source/texk/web2c/luatexdir/font/writetype2.w
@@ -387,24 +387,26 @@ boolean make_tt_subset(PDF pdf, fd_entry * fd, unsigned char *buff, int buflen)
/* CIDSet: a table of bits indexed by cid, bytes with high order bit first,
each (set) bit is a (present) CID. */
if (is_subsetted(fd->fm)) {
- cidset = pdf_create_obj(pdf, obj_type_others, 0);
- if (cidset != 0) {
- size_t l = (last_cid / 8) + 1;
- char *stream = xmalloc(l);
- memset(stream, 0, l);
- for (cid = 1; cid <= (long) last_cid; cid++) {
- if (used_chars[cid]) {
- stream[(cid / 8)] |= (1 << (7 - (cid % 8)));
+ if ((! pdf->omit_cidset) && (pdf->major_version == 1)) {
+ cidset = pdf_create_obj(pdf, obj_type_others, 0);
+ if (cidset != 0) {
+ size_t l = (last_cid / 8) + 1;
+ char *stream = xmalloc(l);
+ memset(stream, 0, l);
+ for (cid = 1; cid <= (long) last_cid; cid++) {
+ if (used_chars[cid]) {
+ stream[(cid / 8)] |= (1 << (7 - (cid % 8)));
+ }
}
+ pdf_begin_obj(pdf, cidset, OBJSTM_NEVER);
+ pdf_begin_dict(pdf);
+ pdf_dict_add_streaminfo(pdf);
+ pdf_end_dict(pdf);
+ pdf_begin_stream(pdf);
+ pdf_out_block(pdf, stream, l);
+ pdf_end_stream(pdf);
+ pdf_end_obj(pdf);
}
- pdf_begin_obj(pdf, cidset, OBJSTM_NEVER);
- pdf_begin_dict(pdf);
- pdf_dict_add_streaminfo(pdf);
- pdf_end_dict(pdf);
- pdf_begin_stream(pdf);
- pdf_out_block(pdf, stream, l);
- pdf_end_stream(pdf);
- pdf_end_obj(pdf);
}
}
diff --git a/Build/source/texk/web2c/luatexdir/image/image.h b/Build/source/texk/web2c/luatexdir/image/image.h
index 2ff07d448bd..7c79723f1df 100644
--- a/Build/source/texk/web2c/luatexdir/image/image.h
+++ b/Build/source/texk/web2c/luatexdir/image/image.h
@@ -126,6 +126,7 @@ typedef struct {
int luaref ;
boolean keepopen;
int errorlevel;
+ int pdfmajorversion;
int pdfminorversion;
union {
pdf_stream_struct *pdfstream;
@@ -171,6 +172,7 @@ typedef struct {
# define img_luaref(N) ((N)->luaref)
# define img_keepopen(N) ((N)->keepopen)
# define img_errorlevel(N) ((N)->errorlevel)
+# define img_pdfmajorversion(N) ((N)->pdfmajorversion)
# define img_pdfminorversion(N) ((N)->pdfminorversion)
# define img_pdfstream_ptr(N) ((N)->img_struct.pdfstream)
diff --git a/Build/source/texk/web2c/luatexdir/image/pdftoepdf.w b/Build/source/texk/web2c/luatexdir/image/pdftoepdf.w
index 0f3e75d002c..09dcd251584 100644
--- a/Build/source/texk/web2c/luatexdir/image/pdftoepdf.w
+++ b/Build/source/texk/web2c/luatexdir/image/pdftoepdf.w
@@ -27,6 +27,10 @@
/*
This file is mostly C and not very much C++; it's just used to interface
the functions of poppler, which happens to be written in C++.
+ Patches for the new poppler 0.59 from
+ https://www.mail-archive.com/arch-commits@archlinux.org/msg357548.html
+ with some modifications to comply the poppler API.
+
*/
extern void md5(Guchar *msg, int msgLen, Guchar *digest);
@@ -71,7 +75,7 @@ static char *get_file_checksum(const char *a, file_error_mode fe)
ck = (char *) malloc(PDF_CHECKSUM_SIZE);
if (ck == NULL)
formatted_error("pdf inclusion","out of memory while processing '%s'", a);
- snprintf(ck, PDF_CHECKSUM_SIZE, "%" PRIu64 "_%" PRIu64, (uint64_t) size,(uint64_t) mtime);
+ snprintf(ck, PDF_CHECKSUM_SIZE, "%"@= @>PRIu64@= @>"_%"@= @>PRIu64, (uint64_t) size,(uint64_t) mtime);
} else {
switch (fe) {
case FE_FAIL:
@@ -224,7 +228,7 @@ PdfDocument *refMemStreamPdfDocument(char *docstream, unsigned long long streams
free(checksum);
}
if (pdf_doc->doc == NULL) {
- docmemstream = new MemStream( docstream,0,streamsize, obj.initNull() );
+ docmemstream = new MemStream( docstream,0,streamsize, Object(objNull) );
doc = new PDFDoc(docmemstream); /* takes ownership of docmemstream */
pdf_doc->pc++;
if (!doc->isOk() || !doc->okToPrint()) {
@@ -408,9 +412,8 @@ static void copyArray(PDF pdf, PdfDocument * pdf_doc, Array * array)
Object obj1;
pdf_begin_array(pdf);
for (i = 0, l = array->getLength(); i < l; ++i) {
- array->getNF(i, &obj1);
+ obj1 = array->getNF(i);
copyObject(pdf, pdf_doc, &obj1);
- obj1.free();
}
pdf_end_array(pdf);
}
@@ -422,9 +425,8 @@ static void copyDict(PDF pdf, PdfDocument * pdf_doc, Dict * dict)
pdf_begin_dict(pdf);
for (i = 0, l = dict->getLength(); i < l; ++i) {
copyName(pdf, dict->getKey(i));
- dict->getValNF(i, &obj1);
+ obj1 = dict->getValNF(i);
copyObject(pdf, pdf_doc, &obj1);
- obj1.free();
}
pdf_end_dict(pdf);
}
@@ -510,13 +512,12 @@ static void writeRefs(PDF pdf, PdfDocument * pdf_doc)
PDFDoc *doc = pdf_doc->doc;
xref = doc->getXRef();
for (r = pdf_doc->inObjList; r != NULL;) {
- xref->fetch(r->ref.num, r->ref.gen, &obj1);
+ obj1 = xref->fetch(r->ref.num, r->ref.gen);
if (obj1.isStream())
pdf_begin_obj(pdf, r->num, OBJSTM_NEVER);
else
pdf_begin_obj(pdf, r->num, 2);
copyObject(pdf, pdf_doc, &obj1);
- obj1.free();
pdf_end_obj(pdf);
n = r->next;
delete r;
@@ -596,7 +597,7 @@ void read_pdf_info(image_dict * idict)
pdf_doc = refPdfDocument(img_filepath(idict), FE_FAIL);
else if (img_type(idict) == IMG_TYPE_PDFMEMSTREAM) {
pdf_doc = findPdfDocument(img_filepath(idict)) ;
- if (pdf_doc == NULL )
+ if (pdf_doc == NULL )
normal_error("pdf inclusion", "memstream not initialized");
if (pdf_doc->doc == NULL)
normal_error("pdf inclusion", "memstream document is empty");
@@ -613,12 +614,12 @@ 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";
+ if ((100 * pdf_major_version_found + pdf_major_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_pdfminorversion(idict));
+ formatted_error("pdf inclusion",msg, pdf_major_version_found, pdf_minor_version_found, img_pdfmajorversion(idict), img_pdfminorversion(idict));
} else {
- formatted_warning("pdf inclusion",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_pdfmajorversion(idict), img_pdfminorversion(idict));
}
}
img_totalpages(idict) = catalog->getNumPages();
@@ -740,7 +741,7 @@ void write_epdf(PDF pdf, image_dict * idict, int suppress_optional_info)
catalog = doc->getCatalog();
page = catalog->getPage(img_pagenum(idict));
pageref = catalog->getPageRef(img_pagenum(idict));
- doc->getXRef()->fetch(pageref->num, pageref->gen, &pageobj);
+ pageobj = doc->getXRef()->fetch(pageref->num, pageref->gen);
pageDict = pageobj.getDict();
/* write the Page header */
pdf_begin_obj(pdf, img_objnum(idict), OBJSTM_NEVER);
@@ -757,12 +758,11 @@ void write_epdf(PDF pdf, image_dict * idict, int suppress_optional_info)
pdf_dict_add_int(pdf, "PTEX.PageNumber", (int) img_pagenum(idict));
}
if ((suppress_optional_info & 8) == 0) {
- doc->getDocInfoNF(&obj1);
+ obj1 = doc->getDocInfoNF();
if (obj1.isRef()) {
/* the info dict must be indirect (PDF Ref p. 61) */
pdf_dict_add_ref(pdf, "PTEX.InfoDict", addInObj(pdf, pdf_doc, obj1.getRef()));
}
- obj1.free();
}
if (img_is_bbox(idict)) {
bbox[0] = sp2bp(img_bbox(idict)[0]);
@@ -788,19 +788,17 @@ void write_epdf(PDF pdf, image_dict * idict, int suppress_optional_info)
Now all relevant parts of the Page dictionary are copied. Metadata validity
check is needed(as a stream it must be indirect).
*/
- pageDict->lookupNF("Metadata", &obj1);
+ obj1 = pageDict->lookupNF("Metadata");
if (!obj1.isNull() && !obj1.isRef())
formatted_warning("pdf inclusion","/Metadata must be indirect object");
- obj1.free();
/* copy selected items in Page dictionary */
for (i = 0; pagedictkeys[i] != NULL; i++) {
- pageDict->lookupNF(pagedictkeys[i], &obj1);
+ obj1 = pageDict->lookupNF(pagedictkeys[i]);
if (!obj1.isNull()) {
pdf_add_name(pdf, pagedictkeys[i]);
/* preserves indirection */
copyObject(pdf, pdf_doc, &obj1);
}
- obj1.free();
}
/*
If there are no Resources in the Page dict of the embedded page,
@@ -808,32 +806,28 @@ void write_epdf(PDF pdf, image_dict * idict, int suppress_optional_info)
PDF file, climbing up the tree until the Resources are found.
(This fixes a problem with Scribus 1.3.3.14.)
*/
- pageDict->lookupNF("Resources", &obj1);
+ obj1 = pageDict->lookupNF("Resources");
if (obj1.isNull()) {
op1 = &pagesobj1;
op2 = &pagesobj2;
- pageDict->lookup("Parent", op1);
+ *op1 = pageDict->lookup("Parent");
while (op1->isDict()) {
- obj1.free();
- op1->dictLookupNF("Resources", &obj1);
+ obj1 = op1->dictLookupNF("Resources");
if (!obj1.isNull()) {
pdf_add_name(pdf, "Resources");
copyObject(pdf, pdf_doc, &obj1);
break;
}
- op1->dictLookup("Parent", op2);
+ *op2 = op1->dictLookup("Parent");
optmp = op1;
op1 = op2;
op2 = optmp;
- op2->free();
};
if (!op1->isDict())
formatted_warning("pdf inclusion","Page /Resources missing");
- op1->free();
}
- obj1.free();
/* Write the Page contents. */
- page->getContents(&contents);
+ contents = page->getContents();
if (contents.isStream()) {
/*
Variant A: get stream and recompress under control of \pdfcompresslevel
@@ -844,27 +838,23 @@ void write_epdf(PDF pdf, image_dict * idict, int suppress_optional_info)
Variant B: copy stream without recompressing
*/
- contents.streamGetDict()->lookup("F", &obj1);
+ obj1 = contents.streamGetDict()->lookup("F");
if (!obj1.isNull()) {
normal_error("pdf inclusion","unsupported external stream");
}
- obj1.free();
- contents.streamGetDict()->lookup("Length", &obj1);
+ obj1 = contents.streamGetDict()->lookup("Length");
pdf_add_name(pdf, "Length");
copyObject(pdf, pdf_doc, &obj1);
- obj1.free();
- contents.streamGetDict()->lookup("Filter", &obj1);
+ obj1 = contents.streamGetDict()->lookup("Filter");
if (!obj1.isNull()) {
pdf_add_name(pdf, "Filter");
copyObject(pdf, pdf_doc, &obj1);
- obj1.free();
- contents.streamGetDict()->lookup("DecodeParms", &obj1);
+ obj1 = contents.streamGetDict()->lookup("DecodeParms");
if (!obj1.isNull()) {
pdf_add_name(pdf, "DecodeParms");
copyObject(pdf, pdf_doc, &obj1);
}
}
- obj1.free();
pdf_end_dict(pdf);
pdf_begin_stream(pdf);
copyStreamStream(pdf, contents.getStream()->getUndecodedStream());
@@ -875,8 +865,8 @@ void write_epdf(PDF pdf, image_dict * idict, int suppress_optional_info)
pdf_end_dict(pdf);
pdf_begin_stream(pdf);
for (i = 0, l = contents.arrayGetLength(); i < l; ++i) {
- copyStreamStream(pdf, (contents.arrayGet(i, &obj1))->getStream());
- obj1.free();
+ obj1 = contents.arrayGet(i);
+ copyStreamStream(pdf, obj1.getStream());
if (i < (l - 1)) {
/*
Put a space between streams to be on the safe side (streams
@@ -897,8 +887,6 @@ void write_epdf(PDF pdf, image_dict * idict, int suppress_optional_info)
}
/* write out all indirect objects */
writeRefs(pdf, pdf_doc);
- contents.free();
- pageobj.free();
/*
unrefPdfDocument() must come after contents.free() and pageobj.free()!
TH: The next line makes repeated pdf inclusion unacceptably slow
diff --git a/Build/source/texk/web2c/luatexdir/image/writeimg.w b/Build/source/texk/web2c/luatexdir/image/writeimg.w
index 0944509c044..95e1ec3049d 100644
--- a/Build/source/texk/web2c/luatexdir/image/writeimg.w
+++ b/Build/source/texk/web2c/luatexdir/image/writeimg.w
@@ -100,7 +100,7 @@ that a type has been found.
#define HEADER_PNG "\x89PNG\r\n\x1A\n"
#define HEADER_JBIG2 "\x97\x4A\x42\x32\x0D\x0A\x1A\x0A"
#define HEADER_JP2 "\x6A\x50\x20\x20"
-#define HEADER_PDF "%PDF-1."
+#define HEADER_PDF "%PDF-"
#define MAX_HEADER (sizeof(HEADER_PNG)-1)
#define HEADER_PDF_MEMSTREAM "data:application/pdf," /* see epdf.h */
#define LEN_PDF_MEMSTREAM 21 /* see epdf.h */
@@ -217,7 +217,8 @@ image_dict *new_image_dict(void)
img_index(p) = -1; /* -1 = unused, used count from 0 */
img_luaref(p) = 0;
img_errorlevel(p) = pdf_inclusion_errorlevel;
- fix_pdf_minorversion(static_pdf);
+ fix_pdf_version(static_pdf);
+ img_pdfmajorversion(p) = pdf_major_version;
img_pdfminorversion(p) = pdf_minor_version;
return p;
}
diff --git a/Build/source/texk/web2c/luatexdir/image/writejbig2.w b/Build/source/texk/web2c/luatexdir/image/writejbig2.w
index d1ed0a408d4..a58313ce8d8 100644
--- a/Build/source/texk/web2c/luatexdir/image/writejbig2.w
+++ b/Build/source/texk/web2c/luatexdir/image/writejbig2.w
@@ -762,7 +762,7 @@ static void wr_jbig2(PDF pdf, image_dict * idict, FILEINFO * fip,
@ @c
boolean supported_jbig2(image_dict * idict)
{
- if (img_pdfminorversion(idict) < 4) {
+ if (img_pdfmajorversion(idict) < 2 && img_pdfminorversion(idict) < 4) {
normal_error("readjbig2","you need to generate at least PDF 1.4");
return false;
} else {
diff --git a/Build/source/texk/web2c/luatexdir/image/writejpg.w b/Build/source/texk/web2c/luatexdir/image/writejpg.w
index 7d463b77374..54ed47f0f92 100644
--- a/Build/source/texk/web2c/luatexdir/image/writejpg.w
+++ b/Build/source/texk/web2c/luatexdir/image/writejpg.w
@@ -132,9 +132,9 @@ static unsigned int read_exif_bytes(unsigned char **p, int n, int b)
XResolution, YResolution and ResolutionUnit (tag 282, 283 and 296)
as well as PixelPerUnitX, PixelPerUnitY and PixelUnit (tag 0x5111,
0x5112 and 0x5110). Tags 282, 293 and 296 have the priority,
-with ResolutionUnit set to inch by default, then
+with ResolutionUnit set to inch by default, then
tag 0x5110, 0x5111 and 0x5112, where the only valid value for PixelUnit is 0.0254,
-and finally the given value xx and yy,
+and finally the given value xx and yy,
choosen if the Exif x and y resolution are not strictly positive.
@@ -256,7 +256,7 @@ static void read_APP1_Exif (FILE *fp, unsigned short length, int *xx, int *yy, i
res_unit_ms = 0.0254; /* Unit is meter */
break;
default:
- res_unit_ms = 0;
+ res_unit_ms = 0;
}
case 0x5111: /* PixelPerUnitX */
found_x_ms = true ;
@@ -269,13 +269,13 @@ static void read_APP1_Exif (FILE *fp, unsigned short length, int *xx, int *yy, i
}
- }
+ }
if (found_x && found_y && res_unit>0) {
- found_res = true;
+ found_res = true;
tempx = (int)(xres * res_unit+0.5);
tempy = (int)(yres * res_unit+0.5);
} else if (found_x_ms && found_y_ms && res_unit_ms==0.0254) {
- found_res = true;
+ found_res = true;
tempx = (int)(xres_ms * res_unit_ms+0.5);
tempy = (int)(yres_ms * res_unit_ms+0.5);
}
@@ -394,7 +394,7 @@ void read_jpg_info(image_dict * idict)
formatted_error("readjpg","unsupported compression SOF_%d", i - M_SOF0);
break;
case M_SOF2:
- if (img_pdfminorversion(idict) <= 2) {
+ if (img_pdfmajorversion(idict) < 2 && img_pdfminorversion(idict) <= 2) {
normal_error("readjpg","progressive DCT with PDF-1.2 is not permitted");
}
case M_SOF0:
diff --git a/Build/source/texk/web2c/luatexdir/lang/hyphen.w b/Build/source/texk/web2c/luatexdir/lang/hyphen.w
index 8e13896090d..35befb743de 100644
--- a/Build/source/texk/web2c/luatexdir/lang/hyphen.w
+++ b/Build/source/texk/web2c/luatexdir/lang/hyphen.w
@@ -776,6 +776,8 @@ void hnj_hyphen_load(HyphenDict * dict, const unsigned char *f)
}
@ @c
+extern halfword insert_syllable_discretionary(halfword t, lang_variables * lan);
+
void hnj_hyphen_hyphenate(HyphenDict * dict,
halfword first1,
halfword last1,
@@ -791,9 +793,9 @@ void hnj_hyphen_hyphenate(HyphenDict * dict,
char *hyphens = hnj_malloc(hyphen_len + 1);
/* Add a '.' to beginning and end to facilitate matching */
- set_vlink(begin_point, first1);
- set_vlink(end_point, get_vlink(last1));
- set_vlink(last1, end_point);
+ vlink(begin_point) = first1;
+ vlink(end_point) = vlink(last1);
+ vlink(last1) = end_point;
for (char_num = 0; char_num < hyphen_len; char_num++) {
hyphens[char_num] = '0';
@@ -801,16 +803,16 @@ void hnj_hyphen_hyphenate(HyphenDict * dict,
hyphens[hyphen_len] = 0;
/* now, run the finite state machine */
- for (char_num = 0, here = begin_point; here != get_vlink(end_point);
- here = get_vlink(here)) {
+ for (char_num = 0, here = begin_point; here != vlink(end_point);
+ here = vlink(here)) {
int ch;
if (here == begin_point || here == end_point) {
ch = '.';
} else {
- ch = get_hj_code(char_lang(here),get_character(here));
+ ch = get_hj_code(char_lang(here),character(here));
if (ch <= 32) {
- ch = get_character(here);
+ ch = character(here);
}
}
while (state != -1) {
@@ -857,14 +859,14 @@ void hnj_hyphen_hyphenate(HyphenDict * dict,
}
/* restore the correct pointers */
- set_vlink(last1, get_vlink(end_point));
+ vlink(last1) = vlink(end_point);
/* pattern is \.{\^.\^w\^o\^r\^d\^.\^} |word_len|=4, |ext_word_len|=6, |hyphens|=7
* check \.{ \^ \^ \^ } so drop first two and stop after |word_len-1|
*/
- for (here = first1, char_num = 2; here != left; here = get_vlink(here))
+ for (here = first1, char_num = 2; here != left; here = vlink(here))
char_num++;
- for (; here != right; here = get_vlink(here)) {
+ for (; here != right; here = vlink(here)) {
if (hyphens[char_num] & 1)
here = insert_syllable_discretionary(here, lan);
char_num++;
diff --git a/Build/source/texk/web2c/luatexdir/lang/texlang.h b/Build/source/texk/web2c/luatexdir/lang/texlang.h
index 5e7a046195f..0fa11d4c82f 100644
--- a/Build/source/texk/web2c/luatexdir/lang/texlang.h
+++ b/Build/source/texk/web2c/luatexdir/lang/texlang.h
@@ -67,7 +67,7 @@ extern int get_post_exhyphen_char(int lan);
extern void set_hyphenation_min(int lan, int val);
extern int get_hyphenation_min(int lan);
-extern halfword compound_word_break(halfword t, int clang);
+/* extern halfword compound_word_break(halfword t, int clang); */
extern void dump_language_data(void);
extern void undump_language_data(void);
@@ -82,5 +82,7 @@ extern void new_post_exhyphen_char(void);
extern void new_hyphenation_min(void);
extern void new_hj_code(void);
+extern void set_disc_field(halfword f, halfword t);
+extern halfword insert_syllable_discretionary(halfword t, lang_variables * lan);
#endif
diff --git a/Build/source/texk/web2c/luatexdir/lang/texlang.w b/Build/source/texk/web2c/luatexdir/lang/texlang.w
index bd519af632a..337d2eca51d 100644
--- a/Build/source/texk/web2c/luatexdir/lang/texlang.w
+++ b/Build/source/texk/web2c/luatexdir/lang/texlang.w
@@ -60,7 +60,8 @@ struct tex_language *new_language(int n)
lang->post_exhyphen_char = 0;
lang->hyphenation_min = -1;
if (saving_hyph_codes_par) {
- hj_codes_from_lc_codes(l); /* for now, we might just use specific value for whatever task */
+ /* for now, we might just use specific value for whatever task */
+ hj_codes_from_lc_codes(l);
}
return lang;
} else {
@@ -198,10 +199,10 @@ void load_tex_patterns(int curlang, halfword head)
const char *clean_hyphenation(int id, const char *buff, char **cleaned)
{
int items = 0;
- unsigned char word[MAX_WORD_LEN + 1]; /* work buffer for bytes */
- unsigned uword[MAX_WORD_LEN + 1] = { 0 }; /* work buffer for unicode */
- int u = 0; /* unicode buffer value */
- int i = 0; /* index into buffer */
+ unsigned char word[MAX_WORD_LEN + 1]; /* work buffer for bytes */
+ unsigned uword[MAX_WORD_LEN + 1] = { 0 }; /* work buffer for unicode */
+ int u = 0; /* unicode buffer value */
+ int i = 0; /* index into buffer */
char *uindex = (char *)word;
const char *s = buff;
@@ -218,12 +219,12 @@ const char *clean_hyphenation(int id, const char *buff, char **cleaned)
/* now convert the input to unicode */
word[i] = '\0';
utf2uni_strcpy(uword, (const char *)word);
-
/* build the new word string */
i = 0;
while (uword[i]>0) {
u = uword[i++];
- if (u == '-') { /* skip */
+ if (u == '-') {
+ /* skip */
} else if (u == '=') {
STORE_CHAR(id,'-');
} else if (u == '{') {
@@ -253,7 +254,7 @@ const char *clean_hyphenation(int id, const char *buff, char **cleaned)
if (u == '}') {
items++;
}
- if (items != 3) { /* syntax error */
+ if (items != 3) {
*cleaned = NULL;
tex_error("exception syntax error", NULL);
return s;
@@ -322,51 +323,61 @@ void load_tex_hyphenation(int curlang, halfword head)
}
@ @c
-halfword insert_discretionary(halfword t, halfword pre, halfword post, halfword replace, int penalty)
+static halfword insert_discretionary(halfword t, halfword pre, halfword post, halfword replace, int penalty)
{
- halfword g, n;
+ halfword g;
int f;
- n = new_node(disc_node, syllable_disc);
- disc_penalty(n) = penalty;
- try_couple_nodes(n, vlink(t));
- couple_nodes(t, n);
- if (replace != null)
+ halfword d = new_node(disc_node, syllable_disc);
+ int attr = node_attr(t) ;
+ disc_penalty(d) = penalty;
+ if (t == replace) {
+ /* prev disc next-next */
+ try_couple_nodes(d, vlink(t));
+ try_couple_nodes(alink(t), d);
+ alink(t) = null;
+ vlink(t) = null;
+ replace = t ;
+ } else {
+ /* prev disc next */
+ try_couple_nodes(d, vlink(t));
+ couple_nodes(t, d);
+ }
+ if (replace != null) {
f = font(replace);
- else
- f = get_cur_font(); /* for compound words following explicit hyphens */
+ } else {
+ /* For compound words following explicit hyphens. */
+ f = get_cur_font();
+ }
for (g = pre; g != null; g = vlink(g)) {
font(g) = f;
- if (node_attr(t) != null) {
+ if (attr != null) {
delete_attribute_ref(node_attr(g));
- node_attr(g) = node_attr(t);
- attr_list_ref(node_attr(t)) += 1;
+ node_attr(g) = attr;
+ attr_list_ref(attr) += 1;
}
}
for (g = post; g != null; g = vlink(g)) {
font(g) = f;
- if (node_attr(t) != null) {
+ if (attr != null) {
delete_attribute_ref(node_attr(g));
- node_attr(g) = node_attr(t);
- attr_list_ref(node_attr(t)) += 1;
+ node_attr(g) = attr;
+ attr_list_ref(attr) += 1;
}
}
- for (g = replace; g != null; g = vlink(g)) {
- if (node_attr(t) != null) {
+ if (attr != null) {
+ for (g = replace; g != null; g = vlink(g)) {
delete_attribute_ref(node_attr(g));
- node_attr(g) = node_attr(t);
- attr_list_ref(node_attr(t)) += 1;
+ node_attr(g) = attr;
+ attr_list_ref(attr) += 1;
}
+ delete_attribute_ref(node_attr(d));
+ node_attr(d) = attr;
+ attr_list_ref(attr) += 1;
}
- if (node_attr(t) != null) {
- delete_attribute_ref(node_attr(vlink(t)));
- node_attr(vlink(t)) = node_attr(t);
- attr_list_ref(node_attr(t)) += 1;
- }
- t = vlink(t);
- set_disc_field(pre_break(t), pre);
- set_disc_field(post_break(t), post);
- set_disc_field(no_break(t), replace);
- return t;
+ set_disc_field(pre_break(d), pre);
+ set_disc_field(post_break(d), post);
+ set_disc_field(no_break(d), replace);
+ return d;
}
halfword insert_syllable_discretionary(halfword t, lang_variables * lan)
@@ -413,43 +424,38 @@ halfword insert_syllable_discretionary(halfword t, lang_variables * lan)
}
@ @c
-halfword compound_word_break(halfword t, int clang)
+static halfword insert_character(halfword t, int c)
+{
+ halfword p;
+ p = new_node(glyph_node, 0);
+ set_to_character(p);
+ character(p) = c;
+ if (t != null) {
+ couple_nodes(t, p);
+ }
+ return p;
+}
+
+static halfword compound_word_break(halfword t, int clang)
{
halfword disc = null;
halfword pre = null;
halfword pos = null;
halfword pre_exhyphen_char = get_pre_exhyphen_char(clang);
halfword post_exhyphen_char = get_post_exhyphen_char(clang);
- if (pre_exhyphen_char > 0)
+ if (pre_exhyphen_char > 0) {
pre = insert_character(null,pre_exhyphen_char);
+ } else {
+ pre = insert_character(null,ex_hyphen_char_par);
+ }
if (post_exhyphen_char > 0)
pos = insert_character(null,post_exhyphen_char);
- disc = insert_discretionary(t,pre,pos,null,ex_hyphen_penalty_par);
+ disc = insert_discretionary(t,pre,pos,t,ex_hyphen_penalty_par);
subtype(disc) = automatic_disc;
set_automatic_disc_penalty(disc);
return disc;
}
-halfword insert_complex_discretionary(halfword t, lang_variables * lan,
- halfword pre, halfword pos,
- halfword replace)
-{
- (void) lan;
- return insert_discretionary(t,pre,pos,replace,hyphen_penalty_par);
-}
-
-halfword insert_character(halfword t, int c)
-{
- halfword p;
- p = new_node(glyph_node, 0);
- set_to_character(p);
- character(p) = c;
- if (t != null) {
- couple_nodes(t, p);
- }
- return p;
-}
-
@ @c
void set_disc_field(halfword f, halfword t)
{
@@ -713,6 +719,20 @@ there was not the best idea ever.
*/
+/*
+ We only accept an explicit hyphen when there is a preceding glyph and we skip a sequence of
+ explicit hyphens as that normally indicates a -- or --- ligature in which case we can in a
+ worse case usage get bad node lists later on due to messed up ligature building as these
+ dashes are ligatures in base fonts. This is a side effect of the separating the hyphenation,
+ ligaturing and kerning steps. A test is cmr with ------.
+
+ A font handler can collapse successive hyphens but it's not nice to put the burden there. A
+ somewhat messy border case is ---- but in LuaTeX we don't treat -- and --- special. Also,
+ traditional TeX will break a line at -foo but this can be disabled by setting the automatic
+ mode to 1.
+
+*/
+
static halfword find_next_wordstart(halfword r, halfword first_language, halfword strict_bound)
{
register int l;
@@ -757,27 +777,31 @@ static halfword find_next_wordstart(halfword r, halfword first_language, halfwor
if (is_simple_character(r)) {
chr = character(r) ;
if (chr == ex_hyphen_char_par) {
- /*
- We only accept an explicit hyphen when there is a preceding glyph and
- we skip a sequence of explicit hyphens as that normally indicates a
- -- or --- ligature in which case we can in a worse case usage get bad
- node lists later on due to messed up ligature building as these dashes
- are ligatures in base fonts. This is a side effect of the separating the
- hyphenation, ligaturing and kerning steps. A test is cmr with ------.
- */
t = vlink(r) ;
- if ((start_ok == 0) && (t!=null) && (type(t) == glyph_node) && (character(t) != ex_hyphen_char_par)) {
- compound_word_break(r, char_lang(r));
- start_ok = 1 ;
+ if ((automatic_hyphen_mode_par == 0) && (t != null) && (type(t) == glyph_node) && (character(t) != ex_hyphen_char_par)) {
+ /* we have no word yet and the next character is a non hyphen */
+ r = compound_word_break(r, char_lang(r));
} else {
- start_ok = 0;
+ /* we jump over the sequence of hyphens */
+ while ((t != null) && (type(t) == glyph_node) && (character(t) == ex_hyphen_char_par)) {
+ r = t ;
+ t = vlink(r) ;
+ }
+ if (t == null) {
+ /* we reached the end of the list so we have no word start */
+ return null;
+ }
}
+ /* we need a restart */
+ start_ok = 0;
} else if (start_ok && (char_lang(r)>=first_language) && ((l = get_hj_code(char_lang(r),chr)) > 0)) {
if (char_uchyph(r) || l == chr || l <= 32) {
return r;
} else {
start_ok = 0;
}
+ } else {
+ /* go on */
}
}
break;
@@ -839,18 +863,23 @@ void hnj_hyphenation(halfword head, halfword tail)
halfword strict_bound = hyphenation_bounds_par;
halfword s, r = head, wordstart = null, save_tail1 = null, left = null, right = null;
- /* this first movement assures two things:
- \item{a)} that we won't waste lots of time on something that has been
- handled already (in that case, none of the glyphs match |simple_character|).
- \item{b)} that the first word can be hyphenated. if the movement was
- not explicit, then the indentation at the start of a paragraph
- list would make |find_next_wordstart()| look too far ahead.
- */
+ /*
+ This first movement assures two things:
+
+ \item{a)} that we won't waste lots of time on something that has been handled already
+ (in that case, none of the glyphs match |simple_character|).
+
+ \item{b)} that the first word can be hyphenated. if the movement was not explicit,
+ then the indentation at the start of a paragraph list would make |find_next_wordstart()|
+ look too far ahead.
+ */
while (r != null && (type(r) != glyph_node || !is_simple_character(r))) {
r = vlink(r);
}
- /* this will make |r| a glyph node with subtype character */
+ /*
+ This will make |r| a glyph node with subtype character.
+ */
r = find_next_wordstart(r,first_language,strict_bound);
if (r == null)
return;
@@ -860,15 +889,17 @@ void hnj_hyphenation(halfword head, halfword tail)
s = new_penalty(0,word_penalty);
couple_nodes(tail, s);
- while (r != null) { /* could be while(1), but let's be paranoid */
+ while (r != null) { /* could be while(1), but let's be paranoid */
int clang, lhmin, rhmin, hmin;
halfword hyf_font;
halfword end_word = r;
wordstart = r;
assert(is_simple_character(wordstart));
hyf_font = font(wordstart);
- if (hyphen_char(hyf_font) < 0) /* for backward compat */
+ if (hyphen_char(hyf_font) < 0) {
+ /* For backward compatibility: */
hyf_font = 0;
+ }
clang = char_lang(wordstart);
lhmin = char_lhmin(wordstart);
rhmin = char_rhmin(wordstart);
@@ -889,6 +920,7 @@ void hnj_hyphenation(halfword head, halfword tail)
) {
if (character(r) == ex_hyphen_char_par) {
explicit_hyphen = true;
+ break;
}
wordlen++;
if (lchar <= 32) {
@@ -911,12 +943,27 @@ void hnj_hyphenation(halfword head, halfword tail)
lchar = character(r) ;
}
hy = uni2string(hy, (unsigned) lchar);
- /* this should not be needed any more */
- /*if (vlink(r)!=null) alink(vlink(r))=r; */
end_word = r;
r = vlink(r);
}
- if ( valid_wordend(r,strict_bound)
+ if (explicit_hyphen == true) {
+ /* we are not at the start, so we only need to look ahead */
+ halfword t = vlink(r) ;
+ if ((automatic_hyphen_mode_par == 0 || automatic_hyphen_mode_par == 1) && (t != null) && ((type(t) == glyph_node) && (character(t) != ex_hyphen_char_par))) {
+ /* we have a word already but the next character may not be a hyphen too */
+ r = compound_word_break(r, char_lang(r));
+ } else {
+ /* we jump over the sequence of hyphens */
+ while ((t != null) && (type(t) == glyph_node) && (character(t) == ex_hyphen_char_par)) {
+ r = t ;
+ t = vlink(r) ;
+ }
+ if (t == null) {
+ /* we reached the end of the list and will quit the loop later */
+ r = null;
+ }
+ }
+ } else if ( valid_wordend(r,strict_bound)
&& clang >= first_language
&& wordlen >= lhmin + rhmin
&& (hmin <= 0 || wordlen >= hmin)
@@ -924,35 +971,10 @@ void hnj_hyphenation(halfword head, halfword tail)
&& (lang = tex_languages[clang]) != NULL
) {
*hy = 0;
- if ( lang->exceptions != 0
- && (replacement = hyphenation_exception(lang->exceptions, utf8word)) != NULL
- ) {
-#ifdef VERBOSE
- formatted_warning("hyphenation","replacing %s (c=%d) by %s", utf8word, clang, replacement);
-#endif
+ if (lang->exceptions != 0 && (replacement = hyphenation_exception(lang->exceptions, utf8word)) != NULL) {
+ /* handle the exception and go on to the next word */
do_exception(wordstart, r, replacement);
free(replacement);
- } else if (explicit_hyphen == true) {
- /*
- insert an explicit discretionary after each of the last in a
- set of explicit hyphens
- */
- halfword rr = r;
-#ifdef VERBOSE
- formatted_warning("hyphenation","explicit hyphen(s) found in %s (c=%d)", utf8word, clang);
-#endif
- while (rr != wordstart) {
- if (is_simple_character(rr)) {
- if (character(rr) == ex_hyphen_char_par) {
- compound_word_break(rr, clang);
- while (character(alink(rr)) == ex_hyphen_char_par)
- rr = alink(rr);
- if (rr == wordstart)
- break;
- }
- }
- rr = alink(rr);
- }
} else if (lang->patterns != NULL) {
left = wordstart;
for (i = lhmin; i > 1; i--) {
@@ -960,10 +982,7 @@ void hnj_hyphenation(halfword head, halfword tail)
while (!is_simple_character(left)) {
left = vlink(left);
}
- /*
- if (!left)
- break ;
- */
+ /* if (!left) break; */
/* what is left overruns right .. a bit messy */
}
right = r;
@@ -972,20 +991,10 @@ void hnj_hyphenation(halfword head, halfword tail)
while (!is_simple_character(right)) {
right = alink(right);
}
- /*
- if (!right)
- break ;
- */
+ /* if (!right) break; */
/* what is right overruns left .. a bit messy */
}
- /* maybe an extra check ... */
- /* |if (left && right) {| */
-#ifdef VERBOSE
- formatted_warning("hyphenation","hyphenate %s (c=%d,l=%d,r=%d) from %c to %c",
- utf8word, clang, lhmin, rhmin, character(left), character(right));
-#endif
- (void) hnj_hyphen_hyphenate(lang->patterns, wordstart, end_word, wordlen, left, right, &langdata);
- /* |}| */
+ (void) hnj_hyphen_hyphenate(lang->patterns, wordstart, end_word, wordlen, left, right, &langdata);
}
}
explicit_hyphen = false;
@@ -1026,7 +1035,7 @@ void new_hyphenation(halfword head, halfword tail)
}
}
-@ dumping and undumping languages
+@ Dumping and undumping languages.
@c
#define dump_string(a) \
@@ -1139,20 +1148,19 @@ void new_hyph_exceptions(void)
flush_list(def_ref);
}
-@ Similarly, when \TeX\ has scanned `\.{\\patterns}', it calls on a
-procedure named |new_patterns|.
+@ Similarly, when \TeX\ has scanned `\.{\\patterns}', it calls on a procedure named
+|new_patterns|.
@c
void new_patterns(void)
-{ /* initializes the hyphenation pattern data */
+{
(void) scan_toks(false, true);
load_tex_patterns(language_par, def_ref);
flush_list(def_ref);
}
-@ `\.{\\prehyphenchar}', sets the |pre_break| character, and
-`\.{\\posthyphenchar}' the |post_break| character. Their respective defaults are
-ascii hyphen ("-") and zero (nul).
+@ `\.{\\prehyphenchar}', sets the |pre_break| character, and `\.{\\posthyphenchar}' the
+|post_break| character. Their respective defaults are ascii hyphen ("-") and zero (nul).
@c
void new_pre_hyphen_char(void)
@@ -1169,9 +1177,8 @@ void new_post_hyphen_char(void)
set_post_hyphen_char(language_par, cur_val);
}
-@ `\.{\\preexhyphenchar}', sets the |pre_break| character, and
-`\.{\\postexhyphenchar}' the |post_break| character. Their defaults are both zero
-(nul).
+@ `\.{\\preexhyphenchar}', sets the |pre_break| character, and `\.{\\postexhyphenchar}' the
+|post_break| character. Their defaults are both zero (nul).
@c
void new_pre_exhyphen_char(void)
diff --git a/Build/source/texk/web2c/luatexdir/lua/lauxlib_bridge.h b/Build/source/texk/web2c/luatexdir/lua/lauxlib_bridge.h
index d71a6786845..802ed6f6394 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lauxlib_bridge.h
+++ b/Build/source/texk/web2c/luatexdir/lua/lauxlib_bridge.h
@@ -36,6 +36,5 @@ LUA_API int lua_compare (lua_State *L, int index1, int index2, int op);
#endif
#define luaL_newlibtable(L,l) lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)
-#define luaL_newlib(L,l) (luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
#endif
diff --git a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c
index 7944fdfd8a5..adb1ffd52e2 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c
@@ -54,7 +54,7 @@ static const char *const callbacknames[] = {
"pre_output_filter",
"buildpage_filter",
"hpack_filter", "vpack_filter",
- "char_exists",
+ "glyph_not_found",
"hyphenate",
"ligaturing",
"kerning",
@@ -75,6 +75,7 @@ static const char *const callbacknames[] = {
"call_edit",
"build_page_insert",
"glyph_stream_provider",
+ "finish_synctex_callback",
NULL
};
diff --git a/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc b/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc
index 7250ffd1863..cac1bd024b0 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc
+++ b/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc
@@ -21,7 +21,9 @@
#include "image/epdf.h"
-
+// Patches for the new poppler 0.59 from
+// https://www.mail-archive.com/arch-commits@archlinux.org/msg357548.html
+// with some modifications to comply the poppler API.
// define DEBUG
@@ -253,6 +255,12 @@ static int l_new_Attribute(lua_State * L)
lua_settable(L,-3)
+#define OBJECT_TYPE(name) \
+ lua_pushstring(L, #name); \
+ lua_pushinteger(L, (int)name); \
+ lua_settable(L,-3)
+
+
#define STRUCTELEMENT_TYPE_ENTRY(name) \
lua_pushstring(L, #name); \
lua_pushinteger(L, StructElement::name); \
@@ -306,6 +314,28 @@ static int l_Attribute_Type(lua_State * L) {
return 1;
}
+static int l_Object_Type(lua_State * L) {
+ lua_createtable(L,0,16);/*nr of ObjType values*/ ;
+ OBJECT_TYPE(objBool);
+ OBJECT_TYPE(objInt);
+ OBJECT_TYPE(objReal);
+ OBJECT_TYPE(objString);
+ OBJECT_TYPE(objName);
+ OBJECT_TYPE(objNull);
+ OBJECT_TYPE(objArray);
+ OBJECT_TYPE(objDict);
+ OBJECT_TYPE(objStream);
+ OBJECT_TYPE(objRef);
+ OBJECT_TYPE(objCmd);
+ OBJECT_TYPE(objError);
+ OBJECT_TYPE(objEOF);
+ OBJECT_TYPE(objNone);
+ OBJECT_TYPE(objInt64);
+ OBJECT_TYPE(objDead);
+ return 1;
+}
+
+
static int l_StructElement_Type(lua_State * L) {
lua_createtable (L, 0, 50);
STRUCTELEMENT_TYPE_ENTRY(Document);
@@ -398,14 +428,136 @@ static int l_new_Dict(lua_State * L)
static int l_new_Object(lua_State * L)
{
udstruct *uout;
+ int n = lua_gettop(L); // number of arguments
uout = new_Object_userdata(L);
- uout->d = new Object(); // automatic init to type "none"
- uout->atype = ALLOC_LEPDF;
- uout->pc = 0;
- uout->pd = NULL; // not connected to any PDFDoc
+ switch(n) {
+ case 0:
+ uout->d = new Object(); // automatic init to type "none"
+ uout->atype = ALLOC_LEPDF;
+ uout->pc = 0;
+ uout->pd = NULL; // not connected to any PDFDoc
+ break;
+ case 1:
+ if (lua_isboolean (L,1)) {
+ uout->d = new Object(lua_toboolean(L, 1)? gTrue : gFalse);
+ uout->atype = ALLOC_LEPDF;
+ uout->pc = 0;
+ uout->pd = NULL;
+ } else if (lua_isnumber (L,1)) {
+ double d = lua_tonumber(L,1);
+ // Missed :Object(long long int64gA)
+ if (d==((int)d)) {
+ uout->d = new Object((int)d);
+ } else {
+ uout->d = new Object(d);
+ }
+ uout->atype = ALLOC_LEPDF;
+ uout->pc = 0;
+ uout->pd = NULL;
+ } else if (lua_isstring (L,1)){
+ GooString *gs;
+ const char *s;
+ size_t len;
+ s = luaL_checklstring(L, 2, &len);
+ gs = new GooString(s, len);
+ uout->d = new Object(gs);
+ uout->atype = ALLOC_LEPDF;
+ uout->pc = 0;
+ uout->pd = NULL;
+ } else if (luaL_testudata(L,1,M_Array)){
+ udstruct *u;
+ Array *a;
+ u = (udstruct *) luaL_checkudata(L, 1, M_Array);
+ a = (Array *)u->d;
+ uout->d = new Object(a);
+ uout->atype = ALLOC_LEPDF;
+ uout->pc = 0;
+ uout->pd = NULL;
+ } else if (luaL_testudata(L,1,M_Dict)){
+ udstruct *u;
+ Dict *d;
+ u = (udstruct *) luaL_checkudata(L, 1, M_Dict);
+ d = (Dict *)u->d;
+ uout->d = new Object(d);
+ uout->atype = ALLOC_LEPDF;
+ uout->pc = 0;
+ uout->pd = NULL;
+ } else if (luaL_testudata(L,1,M_Stream)){
+ udstruct *u;
+ Stream *s;
+ u = (udstruct *) luaL_checkudata(L, 1, M_Stream);
+ s = (Stream *)u->d;
+ *((Object *) uout->d) = Object(s);
+ } else
+ luaL_error(L, "Invalid/unsupported value for Object constructor");
+ break;
+ case 2:
+ if (lua_isnumber (L,1) && lua_isnumber (L,2)) {
+ double numA = lua_tonumber(L,1);
+ double genA = lua_tonumber(L,2);
+ if ( ((numA)==(int)(numA)) && ((genA)==(int)(genA)) ){
+ uout->d = new Object((int)(numA), (int)(genA));
+ uout->atype = ALLOC_LEPDF;
+ uout->pc = 0;
+ uout->pd = NULL;
+ }
+ } else if (lua_isnumber (L,1) && (lua_isstring(L,2)|| lua_isnoneornil(L,2))) {
+ double d_typeA = lua_tonumber(L,1);
+ int typeA = (int)(d_typeA);
+ if (d_typeA==typeA){
+ switch((int)(typeA)) {
+ case objBool:
+ case objInt:
+ case objReal:
+ case objString:
+ case objName:
+ case objNull:
+ case objArray:
+ case objDict:
+ case objStream:
+ case objRef:
+ case objCmd:
+ case objError:
+ case objEOF:
+ case objNone:
+ case objInt64:
+ case objDead:
+ if (lua_isstring(L,2))
+ uout->d = new Object((ObjType)(typeA), luaL_checkstring(L, 2));
+ else
+ uout->d = new Object((ObjType)(typeA));
+ uout->atype = ALLOC_LEPDF;
+ uout->pc = 0;
+ uout->pd = NULL;
+
+ break;
+ default:
+ luaL_error(L, "Invalid values for Object constructor");
+ break;
+ }//switch((int)(d))
+ } else // (d_typeA)!=(typeA)
+ luaL_error(L, "Invalid/unsupported values for Object constructor");
+ } // if (lua_isnumber (L,1) && (lua_isstring(L,2)|| lua_isnoneornil(L,2)))
+ break;
+ default:
+ luaL_error(L, "Invalid specification for Object constructor");
+ }
+ lua_settop(L,1);
return 1;
}
+// static int l_new_Object(lua_State * L)
+// {
+// udstruct *uout;
+// uout = new_Object_userdata(L);
+// uout->d = new Object(); // automatic init to type "none"
+// uout->atype = ALLOC_LEPDF;
+// uout->pc = 0;
+// uout->pd = NULL; // not connected to any PDFDoc
+// return 1;
+// }
+
+
// PDFRectangle see Page.h
static int l_new_PDFRectangle(lua_State * L)
@@ -429,6 +581,7 @@ static const struct luaL_Reg epdflib_f[] = {
{"AttributeOwner_Type",l_AttributeOwner_Type},
{"Dict", l_new_Dict},
{"Object", l_new_Object},
+ {"Object_Type", l_Object_Type},
{"PDFRectangle", l_new_PDFRectangle},
{NULL, NULL} // sentinel
};
@@ -538,7 +691,7 @@ static int m_##in##_##function(lua_State * L) \
pdfdoc_changed_error(L); \
uout = new_Object_userdata(L); \
uout->d = new Object(); \
- ((in *) uin->d)->function((Object *) uout->d); \
+ *((Object *)uout->d) = ((in *) uin->d)->function(); \
uout->atype = ALLOC_LEPDF; \
uout->pc = uin->pc; \
uout->pd = uin->pd; \
@@ -665,30 +818,27 @@ static const struct luaL_Reg Annots_m[] = {
//**********************************************************************
// Array
-
-static int m_Array_incRef(lua_State * L)
-{
- int i;
- udstruct *uin;
- uin = (udstruct *) luaL_checkudata(L, 1, M_Array);
- if (uin->pd != NULL && uin->pd->pc != uin->pc)
- pdfdoc_changed_error(L);
- i = ((Array *) uin->d)->incRef();
- lua_pushinteger(L, i);
- return 1;
-}
-
-static int m_Array_decRef(lua_State * L)
-{
- int i;
- udstruct *uin;
- uin = (udstruct *) luaL_checkudata(L, 1, M_Array);
- if (uin->pd != NULL && uin->pd->pc != uin->pc)
- pdfdoc_changed_error(L);
- i = ((Array *) uin->d)->decRef();
- lua_pushinteger(L, i);
- return 1;
-}
+// Now private
+// static int m_Array_incRef(lua_State * L)
+// {
+// udstruct *uin;
+// uin = (udstruct *) luaL_checkudata(L, 1, M_Array);
+// if (uin->pd != NULL && uin->pd->pc != uin->pc)
+// pdfdoc_changed_error(L);
+// lua_pushinteger(L, 1);
+// return 1;
+// }
+// Now private
+// static int m_Array_decRef(lua_State * L)
+// {
+// int i;
+// udstruct *uin;
+// uin = (udstruct *) luaL_checkudata(L, 1, M_Array);
+// if (uin->pd != NULL && uin->pd->pc != uin->pc)
+// pdfdoc_changed_error(L);
+// lua_pushinteger(L, 1);
+// return 1;
+// }
m_poppler_get_INT(Array, getLength);
@@ -702,7 +852,7 @@ static int m_Array_add(lua_State * L)
if ((uin->pd != NULL && uin->pd->pc != uin->pc)
|| (uobj->pd != NULL && uobj->pd->pc != uobj->pc))
pdfdoc_changed_error(L);
- ((Array *) uin->d)->add(((Object *) uobj->d));
+ ((Array *) uin->d)->add(std::move(*((Object *) uobj->d)));
return 0;
}
@@ -718,7 +868,7 @@ static int m_Array_get(lua_State * L)
if (i > 0 && i <= len) {
uout = new_Object_userdata(L);
uout->d = new Object();
- ((Array *) uin->d)->get(i - 1, (Object *) uout->d);
+ *((Object *) uout->d) = ((Array *) uin->d)->get(i - 1);
uout->atype = ALLOC_LEPDF;
uout->pc = uin->pc;
uout->pd = uin->pd;
@@ -739,7 +889,7 @@ static int m_Array_getNF(lua_State * L)
if (i > 0 && i <= len) {
uout = new_Object_userdata(L);
uout->d = new Object();
- ((Array *) uin->d)->getNF(i - 1, (Object *) uout->d);
+ *((Object *) uout->d) = ((Array *) uin->d)->getNF(i - 1);
uout->atype = ALLOC_LEPDF;
uout->pc = uin->pc;
uout->pd = uin->pd;
@@ -773,8 +923,8 @@ static int m_Array_getString(lua_State * L)
m_poppler__tostring(Array);
static const struct luaL_Reg Array_m[] = {
- {"incRef", m_Array_incRef},
- {"decRef", m_Array_decRef},
+ // {"incRef", m_Array_incRef},// Now private
+ // {"decRef", m_Array_decRef},// Now private
{"getLength", m_Array_getLength},
{"add", m_Array_add},
{"get", m_Array_get},
@@ -950,30 +1100,26 @@ static const struct luaL_Reg Catalog_m[] = {
//**********************************************************************
// Dict
-
-static int m_Dict_incRef(lua_State * L)
-{
- int i;
- udstruct *uin;
- uin = (udstruct *) luaL_checkudata(L, 1, M_Dict);
- if (uin->pd != NULL && uin->pd->pc != uin->pc)
- pdfdoc_changed_error(L);
- i = ((Dict *) uin->d)->incRef();
- lua_pushinteger(L, i);
- return 1;
-}
-
-static int m_Dict_decRef(lua_State * L)
-{
- int i;
- udstruct *uin;
- uin = (udstruct *) luaL_checkudata(L, 1, M_Dict);
- if (uin->pd != NULL && uin->pd->pc != uin->pc)
- pdfdoc_changed_error(L);
- i = ((Dict *) uin->d)->decRef();
- lua_pushinteger(L, i);
- return 1;
-}
+// Now private
+// static int m_Dict_incRef(lua_State * L)
+// {
+// udstruct *uin;
+// uin = (udstruct *) luaL_checkudata(L, 1, M_Dict);
+// if (uin->pd != NULL && uin->pd->pc != uin->pc)
+// pdfdoc_changed_error(L);
+// lua_pushinteger(L, 1);
+// return 1;
+// }
+// Now private
+// static int m_Dict_decRef(lua_State * L)
+// {
+// udstruct *uin;
+// uin = (udstruct *) luaL_checkudata(L, 1, M_Dict);
+// if (uin->pd != NULL && uin->pd->pc != uin->pc)
+// pdfdoc_changed_error(L);
+// lua_pushinteger(L, 1);
+// return 1;
+// }
m_poppler_get_INT(Dict, getLength);
@@ -986,7 +1132,7 @@ static int m_Dict_add(lua_State * L)
pdfdoc_changed_error(L);
s = copyString(luaL_checkstring(L, 2));
uobj = (udstruct *) luaL_checkudata(L, 3, M_Object);
- ((Dict *) uin->d)->add(s, ((Object *) uobj->d));
+ ((Dict *) uin->d)->add(s, std::move(*((Object *) uobj->d)));
return 0;
}
@@ -999,7 +1145,7 @@ static int m_Dict_set(lua_State * L)
pdfdoc_changed_error(L);
s = luaL_checkstring(L, 2);
uobj = (udstruct *) luaL_checkudata(L, 3, M_Object);
- ((Dict *) uin->d)->set(s, ((Object *) uobj->d));
+ ((Dict *) uin->d)->set(s, std::move(*((Object *) uobj->d)));
return 0;
}
@@ -1027,7 +1173,7 @@ static int m_Dict_lookup(lua_State * L)
s = luaL_checkstring(L, 2);
uout = new_Object_userdata(L);
uout->d = new Object();
- ((Dict *) uin->d)->lookup(s, (Object *) uout->d);
+ *((Object *) uout->d) = ((Dict *) uin->d)->lookup(s);
uout->atype = ALLOC_LEPDF;
uout->pc = uin->pc;
uout->pd = uin->pd;
@@ -1044,7 +1190,7 @@ static int m_Dict_lookupNF(lua_State * L)
s = luaL_checkstring(L, 2);
uout = new_Object_userdata(L);
uout->d = new Object();
- ((Dict *) uin->d)->lookupNF(s, (Object *) uout->d);
+ *((Object *) uout->d) = ((Dict *) uin->d)->lookupNF(s);
uout->atype = ALLOC_LEPDF;
uout->pc = uin->pc;
uout->pd = uin->pd;
@@ -1096,7 +1242,7 @@ static int m_Dict_getVal(lua_State * L)
if (i > 0 && i <= len) {
uout = new_Object_userdata(L);
uout->d = new Object();
- ((Dict *) uin->d)->getVal(i - 1, (Object *) uout->d);
+ *((Object *) uout->d) = ((Dict *) uin->d)->getVal(i - 1);
uout->atype = ALLOC_LEPDF;
uout->pc = uin->pc;
uout->pd = uin->pd;
@@ -1117,7 +1263,7 @@ static int m_Dict_getValNF(lua_State * L)
if (i > 0 && i <= len) {
uout = new_Object_userdata(L);
uout->d = new Object();
- ((Dict *) uin->d)->getValNF(i - 1, (Object *) uout->d);
+ *((Object *) uout->d) = ((Dict *) uin->d)->getValNF(i - 1);
uout->atype = ALLOC_LEPDF;
uout->pc = uin->pc;
uout->pd = uin->pd;
@@ -1131,8 +1277,8 @@ m_poppler_check_string(Dict, hasKey);
m_poppler__tostring(Dict);
static const struct luaL_Reg Dict_m[] = {
- {"incRef", m_Dict_incRef},
- {"decRef", m_Dict_decRef},
+ // {"incRef", m_Dict_incRef},// Now private
+ // {"decRef", m_Dict_decRef},// Now private
{"getLength", m_Dict_getLength},
{"add", m_Dict_add},
{"set", m_Dict_set},
@@ -1381,9 +1527,9 @@ static int m_Object_initBool(lua_State * L)
pdfdoc_changed_error(L);
luaL_checktype(L, 2, LUA_TBOOLEAN);
if (lua_toboolean(L, 2) != 0)
- ((Object *) uin->d)->initBool(gTrue);
+ *((Object *) uin->d) = Object(gTrue);
else
- ((Object *) uin->d)->initBool(gFalse);
+ *((Object *) uin->d) = Object(gFalse);
return 0;
}
@@ -1395,7 +1541,7 @@ static int m_Object_initInt(lua_State * L)
if (uin->pd != NULL && uin->pd->pc != uin->pc)
pdfdoc_changed_error(L);
i = luaL_checkint(L, 2);
- ((Object *) uin->d)->initInt(i);
+ *((Object *) uin->d) = Object(i);
return 0;
}
@@ -1407,7 +1553,7 @@ static int m_Object_initReal(lua_State * L)
if (uin->pd != NULL && uin->pd->pc != uin->pc)
pdfdoc_changed_error(L);
d = luaL_checknumber(L, 2);
- ((Object *) uin->d)->initReal(d);
+ *((Object *) uin->d) = Object(d);
return 0;
}
@@ -1422,7 +1568,7 @@ static int m_Object_initString(lua_State * L)
pdfdoc_changed_error(L);
s = luaL_checklstring(L, 2, &len);
gs = new GooString(s, len);
- ((Object *) uin->d)->initString(gs);
+ *((Object *) uin->d) = Object(gs);
return 0;
}
@@ -1434,7 +1580,7 @@ static int m_Object_initName(lua_State * L)
if (uin->pd != NULL && uin->pd->pc != uin->pc)
pdfdoc_changed_error(L);
s = luaL_checkstring(L, 2);
- ((Object *) uin->d)->initName(s);
+ *((Object *) uin->d) = Object(objName, s);
return 0;
}
@@ -1444,13 +1590,14 @@ static int m_Object_initNull(lua_State * L)
uin = (udstruct *) luaL_checkudata(L, 1, M_Object);
if (uin->pd != NULL && uin->pd->pc != uin->pc)
pdfdoc_changed_error(L);
- ((Object *) uin->d)->initNull();
+ *((Object *) uin->d) = Object(objNull);
return 0;
}
static int m_Object_initArray(lua_State * L)
{
udstruct *uin, *uxref;
+ Array *a;
uin = (udstruct *) luaL_checkudata(L, 1, M_Object);
uxref = (udstruct *) luaL_checkudata(L, 2, M_XRef);
if (uin->pd != NULL && uxref->pd != NULL && uin->pd != uxref->pd)
@@ -1458,7 +1605,8 @@ static int m_Object_initArray(lua_State * L)
if ((uin->pd != NULL && uin->pd->pc != uin->pc)
|| (uxref->pd != NULL && uxref->pd->pc != uxref->pc))
pdfdoc_changed_error(L);
- ((Object *) uin->d)->initArray((XRef *) uxref->d);
+ a = new Array((XRef *) uxref->d);
+ *((Object *) uin->d) = Object(a);
return 0;
}
@@ -1469,6 +1617,7 @@ static int m_Object_initArray(lua_State * L)
static int m_Object_initDict(lua_State * L)
{
udstruct *uin, *uxref;
+ Dict *d;
uin = (udstruct *) luaL_checkudata(L, 1, M_Object);
uxref = (udstruct *) luaL_checkudata(L, 2, M_XRef);
if (uin->pd != NULL && uxref->pd != NULL && uin->pd != uxref->pd)
@@ -1476,7 +1625,8 @@ static int m_Object_initDict(lua_State * L)
if ((uin->pd != NULL && uin->pd->pc != uin->pc)
|| (uxref->pd != NULL && uxref->pd->pc != uxref->pc))
pdfdoc_changed_error(L);
- ((Object *) uin->d)->initDict((XRef *) uxref->d);
+ d = new Dict((XRef *) uxref->d);
+ *((Object *) uin->d) = Object(d);
return 0;
}
@@ -1490,7 +1640,7 @@ static int m_Object_initStream(lua_State * L)
if ((uin->pd != NULL && uin->pd->pc != uin->pc)
|| (ustream->pd != NULL && ustream->pd->pc != ustream->pc))
pdfdoc_changed_error(L);
- ((Object *) uin->d)->initStream((Stream *) ustream->d);
+ *((Object *) uin->d) = Object((Stream *) ustream->d);
return 0;
}
@@ -1503,7 +1653,7 @@ static int m_Object_initRef(lua_State * L)
pdfdoc_changed_error(L);
num = luaL_checkint(L, 2);
gen = luaL_checkint(L, 3);
- ((Object *) uin->d)->initRef(num, gen);
+ *((Object *) uin->d) = Object(num, gen);
return 0;
}
@@ -1515,7 +1665,7 @@ static int m_Object_initCmd(lua_State * L)
if (uin->pd != NULL && uin->pd->pc != uin->pc)
pdfdoc_changed_error(L);
s = luaL_checkstring(L, 2);
- ((Object *) uin->d)->initCmd(CHARP_CAST s);
+ *((Object *) uin->d) = Object(objCmd, CHARP_CAST s);
return 0;
}
@@ -1525,7 +1675,7 @@ static int m_Object_initError(lua_State * L)
uin = (udstruct *) luaL_checkudata(L, 1, M_Object);
if (uin->pd != NULL && uin->pd->pc != uin->pc)
pdfdoc_changed_error(L);
- ((Object *) uin->d)->initError();
+ *((Object *) uin->d) = Object(objError);
return 0;
}
@@ -1535,7 +1685,7 @@ static int m_Object_initEOF(lua_State * L)
uin = (udstruct *) luaL_checkudata(L, 1, M_Object);
if (uin->pd != NULL && uin->pd->pc != uin->pc)
pdfdoc_changed_error(L);
- ((Object *) uin->d)->initEOF();
+ *((Object *) uin->d) = Object(objEOF);
return 0;
}
@@ -1551,7 +1701,7 @@ static int m_Object_fetch(lua_State * L)
pdfdoc_changed_error(L);
uout = new_Object_userdata(L);
uout->d = new Object();
- ((Object *) uin->d)->fetch((XRef *) uxref->d, (Object *) uout->d);
+ *((Object *) uout->d) = ((Object *) uin->d)->fetch((XRef *) uxref->d);
uout->atype = ALLOC_LEPDF;
uout->pc = uin->pc;
uout->pd = uin->pd;
@@ -1816,7 +1966,7 @@ static int m_Object_arrayAdd(lua_State * L)
pdfdoc_changed_error(L);
if (!((Object *) uin->d)->isArray())
luaL_error(L, "Object is not an Array");
- ((Object *) uin->d)->arrayAdd((Object *) uobj->d);
+ ((Object *) uin->d)->arrayAdd(std::move(*((Object *) uobj->d)));
return 0;
}
@@ -1833,7 +1983,7 @@ static int m_Object_arrayGet(lua_State * L)
if (i > 0 && i <= len) {
uout = new_Object_userdata(L);
uout->d = new Object();
- ((Object *) uin->d)->arrayGet(i - 1, (Object *) uout->d);
+ *((Object *) uout->d) = ((Object *) uin->d)->arrayGet(i - 1);
uout->atype = ALLOC_LEPDF;
uout->pc = uin->pc;
uout->pd = uin->pd;
@@ -1857,7 +2007,7 @@ static int m_Object_arrayGetNF(lua_State * L)
if (i > 0 && i <= len) {
uout = new_Object_userdata(L);
uout->d = new Object();
- ((Object *) uin->d)->arrayGetNF(i - 1, (Object *) uout->d);
+ *((Object *) uout->d) = ((Object *) uin->d)->arrayGetNF(i - 1);
uout->atype = ALLOC_LEPDF;
uout->pc = uin->pc;
uout->pd = uin->pd;
@@ -1897,7 +2047,7 @@ static int m_Object_dictAdd(lua_State * L)
pdfdoc_changed_error(L);
if (!((Object *) uin->d)->isDict())
luaL_error(L, "Object is not a Dict");
- ((Object *) uin->d)->dictAdd(copyString(s), (Object *) uobj->d);
+ ((Object *) uin->d)->dictAdd(copyString(s), std::move(*((Object *) uobj->d)));
return 0;
}
@@ -1915,7 +2065,7 @@ static int m_Object_dictSet(lua_State * L)
pdfdoc_changed_error(L);
if (!((Object *) uin->d)->isDict())
luaL_error(L, "Object is not a Dict");
- ((Object *) uin->d)->dictSet(s, (Object *) uobj->d);
+ ((Object *) uin->d)->dictSet(s, std::move(*((Object *) uobj->d)));
return 0;
}
@@ -1930,7 +2080,7 @@ static int m_Object_dictLookup(lua_State * L)
if (((Object *) uin->d)->isDict()) {
uout = new_Object_userdata(L);
uout->d = new Object();
- ((Object *) uin->d)->dictLookup(s, (Object *) uout->d);
+ *((Object *) uout->d) = ((Object *) uin->d)->dictLookup(s);
uout->atype = ALLOC_LEPDF;
uout->pc = uin->pc;
uout->pd = uin->pd;
@@ -1950,7 +2100,7 @@ static int m_Object_dictLookupNF(lua_State * L)
if (((Object *) uin->d)->isDict()) {
uout = new_Object_userdata(L);
uout->d = new Object();
- ((Object *) uin->d)->dictLookupNF(s, (Object *) uout->d);
+ *((Object *) uout->d) = ((Object *) uin->d)->dictLookupNF(s);
uout->atype = ALLOC_LEPDF;
uout->pc = uin->pc;
uout->pd = uin->pd;
@@ -1991,7 +2141,7 @@ static int m_Object_dictGetVal(lua_State * L)
if (i > 0 && i <= len) {
uout = new_Object_userdata(L);
uout->d = new Object();
- ((Object *) uin->d)->dictGetVal(i - 1, (Object *) uout->d);
+ *((Object *) uout->d) = ((Object *) uin->d)->dictGetVal(i - 1);
uout->atype = ALLOC_LEPDF;
uout->pc = uin->pc;
uout->pd = uin->pd;
@@ -2015,7 +2165,7 @@ static int m_Object_dictGetValNF(lua_State * L)
if (i > 0 && i <= len) {
uout = new_Object_userdata(L);
uout->d = new Object();
- ((Object *) uin->d)->dictGetValNF(i - 1, (Object *) uout->d);
+ *((Object *) uout->d) = ((Object *) uin->d)->dictGetValNF(i - 1);
uout->atype = ALLOC_LEPDF;
uout->pc = uin->pc;
uout->pd = uin->pd;
@@ -2243,7 +2393,7 @@ m_poppler_get_poppler(Page, Stream, getMetadata);
m_poppler_get_poppler(Page, Dict, getPieceInfo);
m_poppler_get_poppler(Page, Dict, getSeparationInfo);
m_poppler_get_poppler(Page, Dict, getResourceDict);
-m_poppler_get_OBJECT(Page, getAnnots);
+m_poppler_get_OBJECT(Page, getAnnotsObject);
m_poppler_get_OBJECT(Page, getContents);
@@ -2270,7 +2420,7 @@ static const struct luaL_Reg Page_m[] = {
{"getPieceInfo", m_Page_getPieceInfo},
{"getSeparationInfo", m_Page_getSeparationInfo},
{"getResourceDict", m_Page_getResourceDict},
- {"getAnnots", m_Page_getAnnots},
+ {"getAnnotsObject", m_Page_getAnnotsObject},
{"getContents", m_Page_getContents},
{"__tostring", m_Page__tostring},
{NULL, NULL} // sentinel
@@ -2520,7 +2670,7 @@ static int m_PDFDoc_getDocInfo(lua_State * L)
if (((PdfDocument *) uin->d)->doc->getXRef()->isOk()) {
uout = new_Object_userdata(L);
uout->d = new Object();
- ((PdfDocument *) uin->d)->doc->getDocInfo((Object *) uout->d);
+ *((Object *) uout->d) = ((PdfDocument *) uin->d)->doc->getDocInfo();
uout->atype = ALLOC_LEPDF;
uout->pc = uin->pc;
uout->pd = uin->pd;
@@ -2538,7 +2688,7 @@ static int m_PDFDoc_getDocInfoNF(lua_State * L)
if (((PdfDocument *) uin->d)->doc->getXRef()->isOk()) {
uout = new_Object_userdata(L);
uout->d = new Object();
- ((PdfDocument *) uin->d)->doc->getDocInfoNF((Object *) uout->d);
+ *((Object *) uout->d) = ((PdfDocument *) uin->d)->doc->getDocInfoNF();
uout->atype = ALLOC_LEPDF;
uout->pc = uin->pc;
uout->pd = uin->pd;
@@ -2841,7 +2991,7 @@ static int m_Attribute_getValue(lua_State * L)
uout = new_Object_userdata(L);
uout->d = new Object();
origin = (Object *) (((Attribute *) uin->d)->getValue());
- origin->copy ( ((Object *)uout->d) );
+ *((Object *) uout->d) = origin->copy();
uout->atype = ALLOC_LEPDF;
uout->pc = uin->pc;
uout->pd = uin->pd;
@@ -3320,7 +3470,8 @@ static int m_StructTreeRoot_findParentElement(lua_State * L)
parent = root->findParentElement(i-1);
if (parent != NULL) {
uout = new_StructElement_userdata(L);
- uout->d = new StructElement( *parent );
+ // see https://isocpp.org/wiki/faq/const-correctness#aliasing-and-const
+ uout->d = (StructElement *) parent;
uout->atype = ALLOC_LEPDF;
uout->pc = uin->pc;
uout->pd = uin->pd;
@@ -3331,7 +3482,6 @@ static int m_StructTreeRoot_findParentElement(lua_State * L)
static const struct luaL_Reg StructTreeRoot_m[] = {
- {"findParentElement", m_StructTreeRoot_findParentElement},
{"getDoc",m_StructTreeRoot_getDoc},
{"getRoleMap",m_StructTreeRoot_getRoleMap},
{"getClassMap",m_StructTreeRoot_getClassMap},
@@ -3370,7 +3520,7 @@ static int m_XRef_fetch(lua_State * L)
gen = luaL_checkint(L, 3);
uout = new_Object_userdata(L);
uout->d = new Object();
- ((XRef *) uin->d)->fetch(num, gen, (Object *) uout->d);
+ *((Object *) uout->d) = ((XRef *) uin->d)->fetch(num, gen);
uout->atype = ALLOC_LEPDF;
uout->pc = uin->pc;
uout->pd = uin->pd;
diff --git a/Build/source/texk/web2c/luatexdir/lua/lfontlib.c b/Build/source/texk/web2c/luatexdir/lua/lfontlib.c
index 7e35d2360b7..0304be8bd11 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lfontlib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lfontlib.c
@@ -155,15 +155,15 @@ static int frozenfont(lua_State * L)
static int setfont(lua_State * L)
{
- int i = luaL_checkinteger(L, -2);
+ int t = lua_gettop(L);
+ int i = luaL_checkinteger(L,1);
if (i) {
- luaL_checktype(L, -1, LUA_TTABLE);
+ luaL_checktype(L, t, LUA_TTABLE);
if (is_valid_font(i)) {
- if (!(font_touched(i) || font_used(i))) {
+ if (! (font_touched(i) || font_used(i))) {
font_from_lua(L, i);
} else {
- luaL_error(L,
- "that font has been accessed already, changing it is forbidden");
+ luaL_error(L, "that font has been accessed already, changing it is forbidden");
}
} else {
luaL_error(L, "that integer id is not a valid font");
@@ -172,10 +172,56 @@ static int setfont(lua_State * L)
return 0;
}
+static int addcharacters(lua_State * L)
+{
+ int t = lua_gettop(L);
+ int i = luaL_checkinteger(L,1);
+ if (i) {
+ luaL_checktype(L, t, LUA_TTABLE);
+ if (is_valid_font(i)) {
+ characters_from_lua(L, i);
+ } else {
+ luaL_error(L, "that integer id is not a valid font");
+ }
+ }
+ return 0;
+}
+
+static int setexpansion(lua_State * L)
+{
+ int f = luaL_checkinteger(L,1);
+ if (f) {
+ if (is_valid_font(f)) {
+ int fstretch = luaL_checkinteger(L,2);
+ int fshrink = luaL_checkinteger(L,3);
+ int fstep = luaL_checkinteger(L,4);
+ set_expand_params(f, fstretch, fshrink, fstep);
+ } else {
+ luaL_error(L, "that integer id is not a valid font");
+ }
+ }
+ return 0;
+}
+
+/* font.define(id,table) */
+/* font.define(table) */
static int deffont(lua_State * L)
{
- int i = get_fontid();
+ int i = 0;
+ int t = lua_gettop(L);
+ if (t == 2) {
+ i = lua_tointeger(L,1);
+ if ((i <= 0) || ! is_valid_font(i)) {
+ lua_pop(L, 1); /* pop the broken table */
+ luaL_error(L, "font creation failed, invalid id passed");
+ }
+ } else if (t == 1) {
+ i = get_fontid();
+ } else {
+ luaL_error(L, "font creation failed, no table passed");
+ return 0;
+ }
luaL_checktype(L, -1, LUA_TTABLE);
if (font_from_lua(L, i)) {
lua_pushinteger(L, i);
@@ -183,21 +229,25 @@ static int deffont(lua_State * L)
} else {
lua_pop(L, 1); /* pop the broken table */
delete_font(i);
- luaL_error(L, "font creation failed");
+ luaL_error(L, "font creation failed, error in table");
}
return 0; /* not reached */
}
/* this returns the expected (!) next fontid. */
+/* first arg true will keep the id */
+
static int nextfontid(lua_State * L)
{
+ int b = ((lua_gettop(L) == 1) && lua_toboolean(L,1));
int i = get_fontid();
lua_pushinteger(L, i);
- delete_font(i);
+ if (b == 0) {
+ delete_font(i);
+ }
return 1;
}
-
static int getfont(lua_State * L)
{
int i = luaL_checkinteger(L, -1);
@@ -207,7 +257,6 @@ static int getfont(lua_State * L)
return 1;
}
-
static int getfontid(lua_State * L)
{
if (lua_type(L, 1) == LUA_TSTRING) {
@@ -228,7 +277,6 @@ static int getfontid(lua_State * L)
return 1;
}
-
static const struct luaL_Reg fontlib[] = {
{"read_tfm", font_read_tfm},
{"read_vf", font_read_vf},
@@ -237,6 +285,8 @@ static const struct luaL_Reg fontlib[] = {
{"each", tex_each_font},
{"getfont", getfont},
{"setfont", setfont},
+ {"addcharacters", addcharacters},
+ {"setexpansion", setexpansion},
{"define", deffont},
{"nextid", nextfontid},
{"id", getfontid},
diff --git a/Build/source/texk/web2c/luatexdir/lua/liolibext.c b/Build/source/texk/web2c/luatexdir/lua/liolibext.c
index 958cbb67b43..7bd6fa4519b 100644
--- a/Build/source/texk/web2c/luatexdir/lua/liolibext.c
+++ b/Build/source/texk/web2c/luatexdir/lua/liolibext.c
@@ -29,11 +29,9 @@
#endif
#include "lualib.h"
-
-
#ifdef LuajitTeX
/* luajit has its own way for io, which is a mix of */
-/* lua 5.1 and lua 5.2 . We use the stock luajit. */
+/* lua 5.1 and lua 5.2 . We use the stock luajit. */
#else
/*
** {======================================================
@@ -61,7 +59,6 @@
/* }====================================================== */
-
#if defined(LUA_USE_POSIX)
#define l_fseek(f,o,w) fseeko(f,o,w)
@@ -92,9 +89,6 @@
#endif/* #ifdef LuajitTeX */
-
-
-
static FILE *tofile (lua_State *L) {
#ifdef LuajitTeX
FILE **f = luaL_checkudata(L,1,LUA_FILEHANDLE);
@@ -110,6 +104,8 @@ static FILE *tofile (lua_State *L) {
#endif
}
+#define uchar(c) ((unsigned char)(c))
+
/*
HH: A few helpers to avoid reading numbers as strings. For now we put them in their
own namespace. We also have a few helpers that can make io functions tex friendly.
@@ -125,6 +121,19 @@ static int readcardinal1(lua_State *L) {
return 1;
}
+static int readcardinal1_s(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ if (p < 0 || p >= l) {
+ lua_pushnil(L);
+ } else {
+ int a = uchar(s[p]);
+ lua_pushinteger(L, a);
+ }
+ return 1;
+}
+
static int readcardinal2(lua_State *L) {
FILE *f = tofile(L);
int a = getc(f);
@@ -137,6 +146,20 @@ static int readcardinal2(lua_State *L) {
return 1;
}
+static int readcardinal2_s(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ if (p < 0 || p+1 >= l) {
+ lua_pushnil(L);
+ } else {
+ int a = uchar(s[p++]);
+ int b = uchar(s[p]);
+ lua_pushinteger(L, 0x100 * a + b);
+ }
+ return 1;
+}
+
static int readcardinal3(lua_State *L) {
FILE *f = tofile(L);
int a = getc(f);
@@ -150,6 +173,21 @@ static int readcardinal3(lua_State *L) {
return 1;
}
+static int readcardinal3_s(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ if (p < 0 || p+2 >= l) {
+ lua_pushnil(L);
+ } else {
+ int a = uchar(s[p++]);
+ int b = uchar(s[p++]);
+ int c = uchar(s[p]);
+ lua_pushinteger(L, 0x10000 * a + 0x100 * b + c);
+ }
+ return 1;
+}
+
static int readcardinal4(lua_State *L) {
FILE *f = tofile(L);
int a = getc(f);
@@ -164,6 +202,22 @@ static int readcardinal4(lua_State *L) {
return 1;
}
+static int readcardinal4_s(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ if (p < 0 || p+3 >= l) {
+ lua_pushnil(L);
+ } else {
+ int a = uchar(s[p++]);
+ int b = uchar(s[p++]);
+ int c = uchar(s[p++]);
+ int d = uchar(s[p]);
+ lua_pushinteger(L,0x1000000 * a + 0x10000 * b + 0x100 * c + d);
+ }
+ return 1;
+}
+
static int readinteger1(lua_State *L) {
FILE *f = tofile(L);
int a = getc(f);
@@ -176,6 +230,22 @@ static int readinteger1(lua_State *L) {
return 1;
}
+static int readinteger1_s(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ if (p < 0 || p >= l) {
+ lua_pushnil(L);
+ } else {
+ int a = uchar(s[p]);
+ if (a >= 0x80)
+ lua_pushinteger(L, a - 0x100);
+ else
+ lua_pushinteger(L, a);
+ }
+ return 1;
+}
+
static int readinteger2(lua_State *L) {
FILE *f = tofile(L);
int a = getc(f);
@@ -189,6 +259,23 @@ static int readinteger2(lua_State *L) {
return 1;
}
+static int readinteger2_s(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ if (p < 0 || p+1 >= l) {
+ lua_pushnil(L);
+ } else {
+ int a = uchar(s[p++]);
+ int b = 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);
int a = getc(f);
@@ -203,6 +290,24 @@ static int readinteger3(lua_State *L) {
return 1;
}
+static int readinteger3_s(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ if (p < 0 || p+2 >= l) {
+ lua_pushnil(L);
+ } else {
+ int a = uchar(s[p++]);
+ int b = uchar(s[p++]);
+ int c = 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);
int a = getc(f);
@@ -218,6 +323,25 @@ static int readinteger4(lua_State *L) {
return 1;
}
+static int readinteger4_s(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ if (p < 0 || p+3 >= l) {
+ lua_pushnil(L);
+ } else {
+ int a = uchar(s[p++]);
+ int b = uchar(s[p++]);
+ int c = uchar(s[p++]);
+ int d = 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 readfixed2(lua_State *L) {
FILE *f = tofile(L);
int a = getc(f);
@@ -225,9 +349,26 @@ static int readfixed2(lua_State *L) {
if (b == EOF)
lua_pushnil(L);
else if (a >= 0x80)
- lua_pushinteger(L, a + b/0xFFFF - 0x100);
+ lua_pushinteger(L, (a - 0x100) + b/0x100);
else
- lua_pushinteger(L, a + b/0xFFFF);
+ lua_pushinteger(L, (a ) + b/0x100);
+ return 1;
+}
+
+static int readfixed2_s(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ if (p < 0 || p+3 >= l) {
+ lua_pushnil(L);
+ } else {
+ int a = uchar(s[p++]);
+ int b = uchar(s[p]);
+ if (a >= 0x80)
+ lua_pushinteger(L, (a - 0x100) + b/0x100);
+ else
+ lua_pushinteger(L, (a ) + b/0x100);
+ }
return 1;
}
@@ -240,15 +381,34 @@ static int readfixed4(lua_State *L) {
if (d == EOF)
lua_pushnil(L);
else if (a >= 0x80)
- lua_pushnumber(L, (0x1000000 * a + 0x10000 * b + 0x100 * c + d - 0x100000000)/65536.0);
+ lua_pushnumber(L, (0x100 * a + b - 0x10000) + (0x100 * c + d)/0x10000);
else
- lua_pushnumber(L, (0x1000000 * a + 0x10000 * b + 0x100 * c + d)/65536.0);
+ lua_pushnumber(L, (0x100 * a + b ) + (0x100 * c + d)/0x10000);
/* from ff */
/* int n = 0x1000000 * a + 0x10000 * b + 0x100 * c + d; */
/* lua_pushnumber(L,(real) (n>>16) + ((n&0xffff)/65536.0)); */
return 1;
}
+static int readfixed4_s(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ if (p < 0 || p+3 >= l) {
+ lua_pushnil(L);
+ } else {
+ int a = uchar(s[p++]);
+ int b = uchar(s[p++]);
+ int c = uchar(s[p++]);
+ int d = uchar(s[p]);
+ if (a >= 0x80)
+ lua_pushnumber(L, (0x100 * a + b - 0x10000) + (0x100 * c + d)/0x10000);
+ else
+ lua_pushnumber(L, (0x100 * a + b ) + (0x100 * c + d)/0x10000);
+ }
+ return 1;
+}
+
static int read2dot14(lua_State *L) {
FILE *f = tofile(L);
int a = getc(f);
@@ -263,6 +423,21 @@ static int read2dot14(lua_State *L) {
return 1;
}
+static int read2dot14_s(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ if (p < 0 || p+1 >= l) {
+ lua_pushnil(L);
+ } else {
+ int a = uchar(s[p++]);
+ int b = uchar(s[p]);
+ int n = 0x100 * a + b;
+ lua_pushnumber(L,(real) ((n<<16)>>(16+14)) + ((n&0x3fff)/16384.0));
+ }
+ return 1;
+}
+
static int getposition(lua_State *L) {
FILE *f = tofile(L);
long p = ftell(f);
@@ -317,6 +492,28 @@ static int readbytetable(lua_State *L) {
return 1;
}
+static int readbytetable_s(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ int n = lua_tointeger(L,3);
+ if (p < 0 || p >= l) {
+ lua_pushnil(L);
+ } else {
+ int i ;
+ if (p + n >= l) {
+ n = l - p ;
+ }
+ lua_createtable(L, n, 0);
+ for (i=1;i<=n;i++) {
+ int a = uchar(s[p++]);
+ lua_pushinteger(L, a);
+ lua_rawseti(L,-2,i);
+ }
+ }
+ return 1;
+}
+
static int readbytes(lua_State *L) {
FILE *f = tofile(L);
int n = lua_tointeger(L,2);
@@ -332,6 +529,27 @@ static int readbytes(lua_State *L) {
return n;
}
+static int readbytes_s(lua_State *L) {
+ size_t l;
+ const char *s = luaL_checklstring(L, 1, &l);
+ size_t p = luaL_checkinteger(L, 2) - 1;
+ int n = lua_tointeger(L,3);
+ if (p < 0 || p >= l) {
+ return 0;
+ } else {
+ int i ;
+ if (p + n >= l) {
+ n = l - p ;
+ }
+ lua_createtable(L, n, 0);
+ for (i=1;i<=n;i++) {
+ int a = uchar(s[p++]);
+ lua_pushinteger(L, a);
+ }
+ return n;
+ }
+}
+
static int recordfilename(lua_State *L)
{
const char *fname = luaL_checkstring(L, 1);
@@ -374,11 +592,17 @@ static int checkpermission(lua_State *L)
lua_pushboolean(L,0);
lua_pushliteral(L, "specific command execution disabled");
break;
+ case 1:
+ /* doesn't happen */
+ lua_pushboolean(L,1);
+ lua_pushstring(L,filename);
+ break;
case 2:
lua_pushboolean(L,1);
lua_pushstring(L,safecmd);
break;
default:
+ /* -1 */
lua_pushboolean(L,0);
lua_pushliteral(L, "bad command line quoting");
break;
@@ -444,7 +668,35 @@ static const luaL_Reg fiolib[] = {
{NULL, NULL}
};
+static const luaL_Reg siolib[] = {
+ { "readcardinal1", readcardinal1_s },
+ { "readcardinal2", readcardinal2_s },
+ { "readcardinal3", readcardinal3_s },
+ { "readcardinal4", readcardinal4_s },
+ { "readinteger1", readinteger1_s },
+ { "readinteger2", readinteger2_s },
+ { "readinteger3", readinteger3_s },
+ { "readinteger4", readinteger4_s },
+ { "readfixed2", readfixed2_s },
+ { "readfixed4", readfixed4_s },
+ { "read2dot14", read2dot14_s },
+ { "readbytes", readbytes_s },
+ { "readbytetable", readbytetable_s },
+ /* done */
+ {NULL, NULL}
+};
+
+/*
+ The sio helpers are experimental and might be handy at some point. Speed-wise
+ there is no gain over file access because with ssd and caching we basically
+ operate in memory too. We keep them as complement to the file ones. I did
+ consider using an userdata object for the position etc but some simple tests
+ demonstrated that there is no real gain and the current ones permits to wrap
+ up whatever interface one likes.
+*/
+
int luaopen_fio(lua_State *L) {
luaL_register(L, "fio", fiolib);
+ luaL_register(L, "sio", siolib);
return 1;
}
diff --git a/Build/source/texk/web2c/luatexdir/lua/llualib.c b/Build/source/texk/web2c/luatexdir/lua/llualib.c
index c094c8ed1d1..461c211472d 100644
--- a/Build/source/texk/web2c/luatexdir/lua/llualib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/llualib.c
@@ -286,8 +286,7 @@ static int set_luaname(lua_State * L)
static int get_luaname(lua_State * L)
{
- int k;
- k = (int) luaL_checkinteger(L, 2);
+ int k = (int) luaL_checkinteger(L, 2);
if (k > 65535 || k < 0) {
/* error */
lua_pushnil(L);
@@ -306,6 +305,13 @@ static int lua_functions_get_table(lua_State * L) /* hh */
return 1;
}
+static int new_table(lua_State * L) /* hh */
+{
+ int i = (int) luaL_checkinteger(L, 1);
+ int h = (int) luaL_checkinteger(L, 2);
+ lua_createtable(L,i,h);
+ return 1;
+}
static const struct luaL_Reg lualib[] = {
/* *INDENT-OFF* */
@@ -313,6 +319,7 @@ static const struct luaL_Reg lualib[] = {
{"setluaname", set_luaname},
{"getbytecode", get_bytecode},
{"setbytecode", set_bytecode},
+ {"newtable", new_table},
{"get_functions_table",lua_functions_get_table},
/* *INDENT-ON* */
{NULL, NULL} /* sentinel */
diff --git a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c
index 49929fa2792..5ee46a7269d 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c
@@ -268,6 +268,19 @@ static int get_valid_node_subtype_id(lua_State * L, int n)
return i;
}
+/* enable fixer ... more fixers can be added in the future */
+
+static int lua_nodelib_fix_node_lists(lua_State * L)
+{
+ if (lua_type(L, -1) == LUA_TBOOLEAN) {
+ fix_node_lists = lua_toboolean(L,-1);
+ } else if (lua_type(L, -1) == LUA_TNUMBER) {
+ fix_node_lists = lua_tointeger(L,-1);
+ }
+ return 0;
+}
+
+
/* two simple helpers to speed up and simplify lua code (replaced by getnext and getprev) */
static int lua_nodelib_next(lua_State * L)
@@ -438,6 +451,8 @@ static int lua_nodelib_direct_getfont(lua_State * L)
lua_pushinteger(L, font(n));
} else if ((t == math_char_node) || (t == math_text_char_node)) {
lua_pushinteger(L, fam_fnt(math_fam(n), 0));
+ } else if (t == delim_node) {
+ lua_pushinteger(L, fam_fnt(small_fam(n), 0));
} else {
lua_pushnil(L);
}
@@ -473,6 +488,8 @@ static int lua_nodelib_direct_setfont(lua_State * L)
lua_pushinteger(L, font(*n));
} else if ((t == math_char_node) || (t == math_text_char_node)) {
lua_pushinteger(L, fam_fnt(math_fam(*n), 0));
+ } else if (t == delim_node) {
+ lua_pushinteger(L, fam_fnt(small_fam(*n), 0));
} else {
lua_pushnil(L);
}
@@ -492,6 +509,27 @@ static int lua_nodelib_direct_getchar(lua_State * L)
lua_pushinteger(L, character(n));
} else if ((t == math_char_node) || (t == math_text_char_node)) {
lua_pushinteger(L, math_character(n));
+ } else if (t == delim_node) {
+ /* used in wide fonts */
+ lua_pushinteger(L, small_char(n));
+ } else {
+ lua_pushnil(L);
+ }
+ } else {
+ lua_pushnil(L);
+ }
+ return 1;
+}
+
+static int lua_nodelib_direct_getfam(lua_State * L)
+{
+ halfword n = lua_tointeger(L, 1);
+ if (n) {
+ halfword t = type(n);
+ if ((t == math_char_node) || (t == math_text_char_node)) {
+ lua_pushinteger(L, math_fam(n));
+ } else if (t == delim_node) {
+ lua_pushinteger(L, small_fam(n));
} else {
lua_pushnil(L);
}
@@ -510,23 +548,47 @@ static int lua_nodelib_direct_setchar(lua_State * L)
character(n) = (halfword) lua_tointeger(L, 2);
} else if ((t == math_char_node) || (t == math_text_char_node)) {
math_character(n) = (halfword) lua_tointeger(L, 2);
+ } else if (t == delim_node) {
+ /* used in wide fonts */
+ small_char(n) = (halfword) lua_tointeger(L, 2);
}
}
return 0;
}
+static int lua_nodelib_direct_setfam(lua_State * L)
+{
+ halfword n = lua_tointeger(L, 1);
+ if ((n) && (lua_type(L, 2) == LUA_TNUMBER)) {
+ halfword t = type(n);
+ if ((t == math_char_node) || (t == math_text_char_node)) {
+ math_fam(n) = (halfword) lua_tointeger(L, 2);
+ } else if (t == delim_node) {
+ small_fam(n) = (halfword) lua_tointeger(L, 2);
+ }
+ }
+ return 0;
+}
/* node.getchar */
static int lua_nodelib_getchar(lua_State * L)
{
halfword *n = lua_touserdata(L, 1);
- if ( (n == NULL) || (! lua_getmetatable(L,1)) ) {
+ if ((n == NULL) || (! lua_getmetatable(L,1))) {
lua_pushnil(L);
- } else if (type(*n) == glyph_node) {
- lua_pushinteger(L, character(*n));
- } else if ((type(*n) == math_char_node) || (type(*n) == math_text_char_node)) {
- lua_pushinteger(L, math_character(*n));
+ } else {
+ halfword t = type(*n);
+ if (t == glyph_node) {
+ lua_pushinteger(L, character(*n));
+ } else if ((t == math_char_node) || (t == math_text_char_node)) {
+ lua_pushinteger(L, math_character(*n));
+ } else if (t == delim_node) {
+ /* used in wide fonts */
+ lua_pushinteger(L, small_char(*n));
+ } else {
+ lua_pushnil(L);
+ }
}
return 1;
}
@@ -673,7 +735,7 @@ static int lua_nodelib_direct_getnucleus(lua_State * L)
if (n) {
halfword t = type(n);
if (t == simple_noad || t == accent_noad || t == radical_noad) {
- lua_pushinteger(L, nucleus(n));
+ nodelib_pushdirect_or_nil(nucleus(n));
return 1;
}
}
@@ -703,7 +765,7 @@ static int lua_nodelib_direct_getsub(lua_State * L)
if (n) {
halfword t = type(n);
if (t == simple_noad || t == accent_noad || t == radical_noad) {
- lua_pushinteger(L, subscr(n));
+ nodelib_pushdirect_or_nil(subscr(n));
return 1;
}
}
@@ -733,7 +795,7 @@ static int lua_nodelib_direct_getsup(lua_State * L)
if (n) {
halfword t = type(n);
if (t == simple_noad || t == accent_noad || t == radical_noad) {
- lua_pushinteger(L, supscr(n));
+ nodelib_pushdirect_or_nil(supscr(n));
return 1;
}
}
@@ -785,7 +847,7 @@ static int lua_nodelib_direct_setkern(lua_State * L)
halfword t = type(n);
if (t == kern_node || t == margin_kern_node) {
if (lua_type(L, 2) == LUA_TNUMBER) {
- width(n) = (halfword) lua_tointeger(L, 2);
+ width(n) = (halfword) lua_roundnumber(L, 2);
} else {
width(n) = 0;
}
@@ -794,7 +856,7 @@ static int lua_nodelib_direct_setkern(lua_State * L)
}
} else if (t == math_node) {
if (lua_type(L, 2) == LUA_TNUMBER) {
- surround(n) = (halfword) lua_tointeger(L, 2);
+ surround(n) = (halfword) lua_roundnumber(L, 2);
} else {
surround(n) = 0;
}
@@ -867,10 +929,10 @@ static int lua_nodelib_direct_setoffsets(lua_State * L)
halfword n = lua_tointeger(L, 1);
if ((n) && (type(n) == glyph_node)) {
if ((lua_type(L, 2) == LUA_TNUMBER)) {
- x_displace(n) = (halfword) lua_tointeger(L, 2);
+ x_displace(n) = (halfword) lua_roundnumber(L, 2);
}
if ((lua_type(L, 3) == LUA_TNUMBER)) {
- y_displace(n) = (halfword) lua_tointeger(L, 3);
+ y_displace(n) = (halfword) lua_roundnumber(L, 3);
}
}
return 0;
@@ -1071,6 +1133,8 @@ static int lua_nodelib_direct_getlist(lua_State * L)
nodelib_pushdirect_or_nil_alink(list_ptr(n));
} else if ((t == sub_box_node) || (t == sub_mlist_node)) {
nodelib_pushdirect_or_nil_alink(math_list(n));
+ } else if (t == ins_node) {
+ nodelib_pushdirect_or_nil_alink(ins_ptr(n));
} else if (t == adjust_node) {
nodelib_pushdirect_or_nil_alink(adjust_ptr(n));
} else {
@@ -1097,6 +1161,12 @@ static int lua_nodelib_direct_setlist(lua_State * L)
} else {
math_list(n) = null;
}
+ } else if (t == ins_node) {
+ if (lua_type(L,2) == LUA_TNUMBER) {
+ ins_ptr(n) = (halfword) lua_tointeger(L, 2);
+ } else {
+ ins_ptr(n) = null;
+ }
} else if (t == adjust_node) {
if (lua_type(L,2) == LUA_TNUMBER) {
adjust_ptr(n) = (halfword) lua_tointeger(L, 2);
@@ -1120,6 +1190,10 @@ static int lua_nodelib_direct_setlist(lua_State * L)
fast_metatable_or_nil_alink(list_ptr(*n));
} else if ((type(*n) == sub_box_node) || (type(*n) == sub_mlist_node)) {
fast_metatable_or_nil_alink(math_list(*n));
+ } else if (type(*n) == ins_node) {
+ fast_metatable_or_nil_alink(ins_ptr(*n));
+ } else if (type(*n) == adjust_node) {
+ fast_metatable_or_nil_alink(adjust_ptr(*n));
} else {
lua_pushnil(L);
}
@@ -2999,7 +3073,7 @@ static int lua_nodelib_direct_setwidth(lua_State * L)
if (t == hlist_node || t == vlist_node || t == rule_node || t == glue_node || t == glue_spec_node || t == math_node ||
t == kern_node || t == margin_kern_node || t == ins_node || t == unset_node) {
if (lua_type(L, 2) == LUA_TNUMBER) {
- width(n) = lua_tointeger(L,2);
+ width(n) = lua_roundnumber(L,2);
} else {
width(n) = 0;
}
@@ -3035,7 +3109,7 @@ static int lua_nodelib_direct_setheight(lua_State * L)
halfword t = type(n);
if (t == hlist_node || t == vlist_node || t == rule_node || t == unset_node) {
if (lua_type(L, 2) == LUA_TNUMBER) {
- height(n) = lua_tointeger(L,2);
+ height(n) = lua_roundnumber(L,2);
} else {
height(n) = 0;
}
@@ -3071,7 +3145,7 @@ static int lua_nodelib_direct_setdepth(lua_State * L)
halfword t = type(n);
if (t == hlist_node || t == vlist_node || t == rule_node || t == unset_node) {
if (lua_type(L, 2) == LUA_TNUMBER) {
- depth(n) = lua_tointeger(L,2);
+ depth(n) = lua_roundnumber(L,2);
} else {
depth(n) = 0;
}
@@ -3104,7 +3178,7 @@ static int lua_nodelib_direct_setshift(lua_State * L)
halfword t = type(n);
if (t == hlist_node || t == vlist_node) {
if (lua_type(L, 2) == LUA_TNUMBER) {
- shift_amount(n) = lua_tointeger(L,2);
+ shift_amount(n) = lua_roundnumber(L,2);
} else {
shift_amount(n) = 0;
}
@@ -3129,6 +3203,11 @@ static int lua_nodelib_direct_get_glue(lua_State * L)
lua_pushinteger(L,stretch_order(n));
lua_pushinteger(L,shrink_order(n));
return 5;
+ } else if (t == hlist_node || t == vlist_node) {
+ lua_pushnumber(L, (double) glue_set(n)); /* float */
+ lua_pushinteger(L,glue_order(n));
+ lua_pushinteger(L,glue_sign(n));
+ return 3;
}
}
return 0;
@@ -3146,6 +3225,11 @@ static int lua_nodelib_direct_set_glue(lua_State * L)
shrink(n) = ((top > 3 && lua_type(L, 4) == LUA_TNUMBER)) ? lua_roundnumber(L,4) : 0;
stretch_order(n) = ((top > 4 && lua_type(L, 5) == LUA_TNUMBER)) ? lua_tointeger(L,5) : 0;
shrink_order(n) = ((top > 5 && lua_type(L, 6) == LUA_TNUMBER)) ? lua_tointeger(L,6) : 0;
+ } else if (t == hlist_node || t == vlist_node) {
+ glue_set(n) = ((top > 1 && lua_type(L, 2) == LUA_TNUMBER)) ? (glue_ratio) lua_tonumber(L,2) : 0;
+ glue_order(n) = ((top > 2 && lua_type(L, 3) == LUA_TNUMBER)) ? lua_tointeger(L,3) : 0;
+ glue_sign(n) = ((top > 3 && lua_type(L, 4) == LUA_TNUMBER)) ? lua_tointeger(L,4) : 0;
+ return 3;
}
}
return 0;
@@ -3159,9 +3243,12 @@ static int lua_nodelib_direct_is_zero_glue(lua_State * L)
if (t == glue_node || t == glue_spec_node || t == math_node || t == ins_node) {
lua_pushboolean(L,(width(n) == 0 && stretch(n) == 0 && shrink(n) == 0));
return 1;
+ } else if (t == hlist_node || t == vlist_node) {
+ lua_pushboolean(L,(glue_set(n) == 0 && glue_order(n) == 0 && glue_sign(n) == 0));
+ return 1;
}
}
- return luaL_error(L, "glue (spec) expected");
+ return 0;
}
/* node.getglue */
@@ -3173,16 +3260,21 @@ static int lua_nodelib_get_glue(lua_State * L)
halfword n = *check_isnode(L, 1);
if (n) {
halfword t = type(n);
- if (t == glue_node || t == glue_spec_node || t == math_node || t== ins_node) {
+ if (t == glue_node || t == glue_spec_node || t == math_node || t == ins_node) {
lua_pushinteger(L,width(n));
lua_pushinteger(L,stretch(n));
lua_pushinteger(L,shrink(n));
lua_pushinteger(L,stretch_order(n));
lua_pushinteger(L,shrink_order(n));
return 5;
+ } else if (t == hlist_node || t == vlist_node) {
+ lua_pushnumber(L, (double) glue_set(n)); /* float */
+ lua_pushinteger(L,glue_order(n));
+ lua_pushinteger(L,glue_sign(n));
+ return 3;
}
}
- return luaL_error(L, "glue (spec) expected");
+ return luaL_error(L, "glue (spec) or list expected");
}
static int lua_nodelib_set_glue(lua_State * L)
@@ -3197,20 +3289,31 @@ static int lua_nodelib_set_glue(lua_State * L)
shrink(n) = ((top > 3 && lua_type(L, 4) == LUA_TNUMBER)) ? lua_roundnumber(L,4) : 0;
stretch_order(n) = ((top > 4 && lua_type(L, 5) == LUA_TNUMBER)) ? lua_tointeger(L,5) : 0;
shrink_order(n) = ((top > 5 && lua_type(L, 6) == LUA_TNUMBER)) ? lua_tointeger(L,6) : 0;
+ } else if (t == hlist_node || t == vlist_node) {
+ glue_set(n) = ((top > 1 && lua_type(L, 2) == LUA_TNUMBER)) ? (glue_ratio) lua_tonumber(L,2) : 0;
+ glue_order(n) = ((top > 2 && lua_type(L, 3) == LUA_TNUMBER)) ? lua_tointeger(L,3) : 0;
+ glue_sign(n) = ((top > 3 && lua_type(L, 4) == LUA_TNUMBER)) ? lua_tointeger(L,4) : 0;
+ return 3;
}
- return 0;
+ return 0;
}
- return luaL_error(L, "glue (spec) expected");
+ return luaL_error(L, "glue (spec) or list expected");
}
static int lua_nodelib_is_zero_glue(lua_State * L)
{
halfword n = *check_isnode(L, 1);
- if ((n != null) && (type(n) == glue_node || type(n) == glue_spec_node || type(n) == math_node || type(n) == ins_node)) {
- lua_pushboolean(L,(width(n) == 0 && stretch(n) == 0 && shrink(n) == 0));
- return 1;
+ if (n != null) {
+ halfword t = type(n);
+ if (t == glue_node || t == glue_spec_node || t == math_node || t == ins_node) {
+ lua_pushboolean(L,(width(n) == 0 && stretch(n) == 0 && shrink(n) == 0));
+ return 1;
+ } else if (t == hlist_node || t == vlist_node) {
+ lua_pushboolean(L,(glue_set(n) == 0 && glue_order(n) == 0 && glue_sign(n) == 0));
+ return 1;
+ }
}
- return luaL_error(L, "glue (spec) expected");
+ return luaL_error(L, "glue (spec) or list expected");
}
/* iteration */
@@ -4051,6 +4154,8 @@ static int lua_nodelib_fast_getfield(lua_State * L)
fast_metatable_or_nil(subscr(n));
} else if (lua_key_eq(s, sup)) {
fast_metatable_or_nil(supscr(n));
+ } else if (lua_key_eq(s, options)) {
+ lua_pushinteger(L, noadoptions(n));
} else {
lua_pushnil(L);
}
@@ -4788,6 +4893,8 @@ static int lua_nodelib_direct_getfield(lua_State * L)
nodelib_pushdirect_or_nil(subscr(n));
} else if (lua_key_eq(s, sup)) {
nodelib_pushdirect_or_nil(supscr(n));
+ } else if (lua_key_eq(s, options)) {
+ lua_pushinteger(L, noadoptions(n));
} else {
lua_pushnil(L);
}
@@ -4835,7 +4942,7 @@ static int lua_nodelib_direct_getfield(lua_State * L)
} else if (t == math_node) {
if (lua_key_eq(s, surround)) {
lua_pushinteger(L, surround(n));
- /* glue */
+ /* glue */
} else if (lua_key_eq(s, width)) {
lua_pushinteger(L, width(n));
} else if (lua_key_eq(s, stretch)) {
@@ -5258,111 +5365,169 @@ static int font_tex_direct_kerning(lua_State * L)
}
/* node.protect_glyphs (returns also boolean because that signals callback) */
+/* node.unprotect_glyphs (returns also boolean because that signals callback) */
+
+#define protect_one_indeed(n) \
+ if (n != null) { \
+ int s = subtype(n); \
+ if (s <= 256) { \
+ subtype(n) = (quarterword) (s == 1 ? 256 : 256 + s); \
+ } \
+ }
+
+#define protect_all_indeed(n) \
+ h = n ; \
+ if (h != null) { \
+ while (h != null) { \
+ if (type(h) == glyph_node) { \
+ int s = subtype(h); \
+ if (s <= 256) { \
+ subtype(h) = (quarterword) (s == 1 ? 256 : 256 + s); \
+ } \
+ } \
+ h = vlink(h); \
+ } \
+ }
+
+#define protect_node_indeed(n) \
+ if (type(n) == glyph_node) { \
+ protect_one_indeed(n); \
+ } else if (type(n) == disc_node) { \
+ protect_all_indeed(vlink(no_break(n))); \
+ protect_all_indeed(vlink(pre_break(n))); \
+ protect_all_indeed(vlink(post_break(n))); \
+ }
+
+#define unprotect_one_indeed(n) \
+ if (n != null) { \
+ int s = subtype(n); \
+ if (s > 256) { \
+ subtype(n) = (quarterword) (s - 256); \
+ } \
+ }
+
+#define unprotect_all_indeed(n) \
+ h = n ; \
+ if (h != null) { \
+ while (h != null) { \
+ if (type(h) == glyph_node) { \
+ int s = subtype(h); \
+ if (s <= 256) { \
+ subtype(h) = (quarterword) (s - 256); \
+ } \
+ } \
+ h = vlink(h); \
+ } \
+ }
+
+#define unprotect_node_indeed(n) \
+ if (type(n) == glyph_node) { \
+ unprotect_one_indeed(n); \
+ } else if (type(n) == disc_node) { \
+ unprotect_all_indeed(vlink(no_break(n))); \
+ unprotect_all_indeed(vlink(pre_break(n))); \
+ unprotect_all_indeed(vlink(post_break(n))); \
+ }
+
+static int lua_nodelib_protect_glyph(lua_State * L)
+{
+ halfword n = *check_isnode(L, 1);
+ halfword h;
+ protect_node_indeed(n);
+ return 0;
+}
+
+static int lua_nodelib_unprotect_glyph(lua_State * L)
+{
+ halfword n = *check_isnode(L, 1);
+ halfword h;
+ unprotect_node_indeed(n);
+ return 0;
+}
static int lua_nodelib_protect_glyphs(lua_State * L)
{
- int t = 0;
halfword head = *check_isnode(L, 1);
+ halfword tail = null;
+ halfword h;
+ if (lua_gettop(L) > 1) {
+ tail = *check_isnode(L, 2);
+ }
while (head != null) {
- if (type(head) == glyph_node) {
- int s = subtype(head);
- if (s <= 256) {
- t = 1;
- subtype(head) = (quarterword) (s == 1 ? 256 : 256 + s);
- }
+ protect_node_indeed(head);
+ if (head == tail) {
+ break;
}
head = vlink(head);
}
- lua_pushboolean(L, t);
- lua_pushvalue(L, 1);
- return 2;
+ return 0;
}
-static int lua_nodelib_protect_glyph(lua_State * L)
+static int lua_nodelib_unprotect_glyphs(lua_State * L)
{
- halfword n = *check_isnode(L, 1);
- if (type(n) == glyph_node) {
- int s = subtype(n);
- if (s <= 256) {
- subtype(n) = (quarterword) (s == 1 ? 256 : 256 + s);
+ halfword head = *check_isnode(L, 1);
+ halfword tail = null;
+ halfword h;
+ if (lua_gettop(L) > 1) {
+ tail = *check_isnode(L, 2);
+ }
+ while (head != null) {
+ unprotect_node_indeed(head);
+ if (head == tail) {
+ break;
}
+ head = vlink(head);
}
return 0;
}
/* node.direct.protect_glyphs */
+/* node.direct.unprotect_glyphs */
-static int lua_nodelib_direct_protect_glyphs(lua_State * L)
+static int lua_nodelib_direct_protect_glyph(lua_State * L)
{
- int t = 0;
- halfword head = (halfword) lua_tointeger(L,1);
- while (head != null) {
- if (type(head) == glyph_node) {
- int s = subtype(head);
- if (s <= 256) {
- t = 1;
- subtype(head) = (quarterword) (s == 1 ? 256 : 256 + s);
- }
- }
- head = vlink(head);
- }
- lua_pushboolean(L, t);
- lua_pushvalue(L, 1);
- return 2;
+ halfword n = (halfword) lua_tointeger(L,1);
+ halfword h;
+ protect_node_indeed(n);
+ return 0;
}
-static int lua_nodelib_direct_protect_glyph(lua_State * L)
+static int lua_nodelib_direct_unprotect_glyph(lua_State * L)
{
halfword n = (halfword) lua_tointeger(L,1);
- if ((n != null) && (type(n) == glyph_node)) {
- int s = subtype(n);
- if (s <= 256) {
- subtype(n) = (quarterword) (s == 1 ? 256 : 256 + s);
- }
- }
+ halfword h;
+ unprotect_node_indeed(n);
return 0;
}
-/* node.unprotect_glyphs (returns also boolean because that signals callback) */
-
-static int lua_nodelib_unprotect_glyphs(lua_State * L)
+static int lua_nodelib_direct_protect_glyphs(lua_State * L)
{
- int t = 0;
- halfword head = *(check_isnode(L, 1));
+ halfword head = (halfword) lua_tointeger(L,1);
+ halfword tail = (halfword) lua_tointeger(L,2);
+ halfword h;
while (head != null) {
- if (type(head) == glyph_node) {
- int s = subtype(head);
- if (s > 256) {
- t = 1;
- subtype(head) = (quarterword) (s - 256);
- }
+ protect_node_indeed(head);
+ if (head == tail) {
+ break;
}
head = vlink(head);
}
- lua_pushboolean(L, t);
- lua_pushvalue(L, 1);
- return 2;
+ return 0;
}
-/* node.direct.unprotect_glyphs */
-
static int lua_nodelib_direct_unprotect_glyphs(lua_State * L)
{
- int t = 0;
halfword head = (halfword) lua_tointeger(L,1);
+ halfword tail = (halfword) lua_tointeger(L,2);
+ halfword h;
while (head != null) {
- if (type(head) == glyph_node) {
- int s = subtype(head);
- if (s > 256) {
- t = 1;
- subtype(head) = (quarterword) (s - 256);
- }
+ unprotect_node_indeed(head);
+ if (head == tail) {
+ break;
}
head = vlink(head);
}
- lua_pushboolean(L, t);
- lua_pushvalue(L, 1);
- return 2;
+ return 0;
}
/* node.first_glyph */
@@ -6100,6 +6265,8 @@ static int lua_nodelib_fast_setfield(lua_State * L)
subscr(n) = nodelib_getlist(L, 3);
} else if (lua_key_eq(s, sup)) {
supscr(n) = nodelib_getlist(L, 3);
+ } else if (lua_key_eq(s, options)) {
+ noadoptions(n) = (quarterword) lua_tointeger(L, 3);
} else {
return nodelib_cantset(L, n, s);
}
@@ -6690,6 +6857,55 @@ static int lua_nodelib_direct_is_glyph(lua_State * L)
return 2;
}
+/* uses_font */
+/* direct.uses_font */
+
+#define uses_font_disc(what,p,n) \
+p = vlink(what(n)); \
+while (p) { \
+ if ((type(p) == glyph_node) && (font(p) == f)) { \
+ lua_pushboolean(L,1); \
+ return 1; \
+ } \
+ p = vlink(p); \
+}
+
+
+static int lua_nodelib_direct_uses_font(lua_State * L)
+{
+ halfword n = lua_tointeger(L,1);
+ halfword f = lua_tointeger(L,2);
+ halfword p;
+ if (type(n) == glyph_node) {
+ lua_pushboolean(L,font(n) == f);
+ } else if (type(n) == disc_node) {
+ uses_font_disc(pre_break,p,n);
+ uses_font_disc(post_break,p,n);
+ uses_font_disc(no_break,p,n);
+ }
+ /* todo: other node types */
+ lua_pushboolean(L,0);
+ return 1;
+}
+
+static int lua_nodelib_uses_font(lua_State * L)
+{
+ halfword n = *check_isnode(L, 1);
+ halfword f = lua_tointeger(L,2);
+ halfword p;
+ if (type(n) == glyph_node) {
+ lua_pushboolean(L,font(n) == f);
+ } else if (type(n) == disc_node) {
+ uses_font_disc(pre_break,p,n);
+ uses_font_disc(post_break,p,n);
+ uses_font_disc(no_break,p,n);
+ }
+ /* todo: other node types */
+ lua_pushboolean(L,0);
+ return 1;
+}
+
+
/* direct.setfield */
static int lua_nodelib_direct_setfield(lua_State * L)
@@ -6905,6 +7121,8 @@ static int lua_nodelib_direct_setfield(lua_State * L)
subscr(n) = nodelib_popdirect(3);
} else if (lua_key_eq(s, sup)) {
supscr(n) = nodelib_popdirect(3);
+ } else if (lua_key_eq(s, options)) {
+ noadoptions(n) = (quarterword) lua_tointeger(L, 3);
} else {
return nodelib_cantset(L, n, s);
}
@@ -6939,7 +7157,7 @@ static int lua_nodelib_direct_setfield(lua_State * L)
height(n) = (halfword) lua_roundnumber(L, 3);
} else if ((lua_key_eq(s, list)) || (lua_key_eq(s, head))) {
ins_ptr(n) = nodelib_popdirect(3);
- /* glue */
+ /* glue */
} else if (lua_key_eq(s, width)) {
width(n) = (halfword) lua_roundnumber(L, 3);
} else if (lua_key_eq(s, stretch)) {
@@ -6958,7 +7176,7 @@ static int lua_nodelib_direct_setfield(lua_State * L)
subtype(n) = (quarterword) lua_tointeger(L, 3);
} else if (lua_key_eq(s, surround)) {
surround(n) = (halfword) lua_roundnumber(L, 3);
- /* glue */
+ /* glue */
} else if (lua_key_eq(s, width)) {
width(n) = (halfword) lua_roundnumber(L, 3);
} else if (lua_key_eq(s, stretch)) {
@@ -7481,20 +7699,20 @@ static int lua_nodelib_effective_glue(lua_State * L)
if ((glue == NULL) || (type(*glue) != glue_node)) {
lua_pushnil(L) ;
} else {
- int w = width(*glue) ;
+ double w = width(*glue) ;
parent = lua_touserdata(L, 2);
if ((parent != NULL) && ((type(*parent) == hlist_node) || (type(*parent) == vlist_node))) {
- if ((int)glue_sign(*parent) == 1) {
+ if ((int) glue_sign(*parent) == 1) {
if (stretch_order(*glue) == glue_order(*parent)) {
- w += stretch(*glue) * glue_set(*parent);
+ w += stretch(*glue) * (double) glue_set(*parent);
}
} else if (glue_sign(*parent) == 2) {
if (shrink_order(*glue) == glue_order(*parent)) {
- w -= shrink(*glue) * glue_set(*parent);
+ w -= shrink(*glue) * (double) glue_set(*parent);
}
}
}
- lua_pushinteger(L,w);
+ lua_pushinteger(L,round(w));
}
return 1;
}
@@ -7505,20 +7723,20 @@ static int lua_nodelib_direct_effective_glue(lua_State * L)
if ((glue == null) || (type(glue) != glue_node)) {
lua_pushnil(L) ;
} else {
- int w = width(glue) ;
+ double w = (double) width(glue) ;
halfword parent = lua_tointeger(L, 2);
if ((parent != null) && ((type(parent) == hlist_node) || (type(parent) == vlist_node))) {
if ((int)glue_sign(parent) == 1) {
if (stretch_order(glue) == glue_order(parent)) {
- w += stretch(glue) * glue_set(parent);
+ w += stretch(glue) * (double) glue_set(parent);
}
} else if (glue_sign(parent) == 2) {
if (shrink_order(glue) == glue_order(parent)) {
- w -= shrink(glue) * glue_set(parent);
+ w -= shrink(glue) * (double) glue_set(parent);
}
}
}
- lua_pushinteger(L,w);
+ lua_pushnumber(L,round(w));
}
return 1;
}
@@ -7563,6 +7781,46 @@ static int lua_nodelib_direct_check_discretionary(lua_State * L) {
return 0;
}
+static int lua_nodelib_direct_flatten_discretionaries(lua_State * L)
+{
+ halfword head = lua_tointeger(L, 1);
+ halfword current = head;
+ halfword next;
+ halfword d, n, h, t;
+ int c = 0;
+ while (current != null) {
+ next = vlink(current);
+ if (type(current) == disc_node) {
+ ++c;
+ d = current;
+ n = no_break(d);
+ h = vlink(n);
+ t = tlink(n);
+ if (h != null) {
+ try_couple_nodes(t,next);
+ if (current == head) {
+ head = h;
+ } else {
+ try_couple_nodes(alink(current),h);
+ }
+ vlink(n) = null ;
+ //tlink(n) = null;
+ } else {
+ if (current == head) {
+ head = next;
+ } else {
+ try_couple_nodes(alink(current),next);
+ }
+ }
+ flush_node(d);
+ }
+ current = next;
+ }
+ nodelib_pushdirect_or_nil(head);
+ lua_pushinteger(L,c);
+ return 2;
+}
+
static int lua_nodelib_check_discretionaries(lua_State * L) {
halfword c = *check_isnode(L, 1);
halfword p ;
@@ -7588,6 +7846,129 @@ static int lua_nodelib_check_discretionary(lua_State * L) {
return 0;
}
+static int lua_nodelib_flatten_discretionaries(lua_State * L)
+{
+ halfword head = *check_isnode(L, 1);
+ halfword current = head;
+ halfword next;
+ halfword d, n, h, t;
+ halfword *a;
+ int c = 0;
+ while (current != null) {
+ next = vlink(current);
+ if (type(current) == disc_node) {
+ ++c;
+ d = current;
+ n = no_break(d);
+ h = vlink(n);
+ t = tlink(n);
+ if (h != null) {
+ try_couple_nodes(t,next);
+ if (current == head) {
+ head = h;
+ } else {
+ try_couple_nodes(alink(current),h);
+ }
+ vlink(n) = null ;
+ //tlink(n) = null;
+ } else {
+ if (current == head) {
+ head = next;
+ } else {
+ try_couple_nodes(alink(current),next);
+ }
+ }
+ flush_node(d);
+ }
+ current = next;
+ }
+ fast_metatable_or_nil(head);
+ lua_pushinteger(L,c);
+ return 2;
+}
+
+/* synctex but not */
+
+static int lua_nodelib_direct_set_synctex_fields(lua_State * L)
+{
+ halfword n = lua_tointeger(L, 1);
+ halfword tag = lua_tointeger(L, 2);
+ halfword line = lua_tointeger(L, 3);
+ if (n != null) {
+ switch (type(n)) {
+ case glyph_node:
+ if (tag) synctex_tag_glyph(n) = tag;
+ if (line) synctex_line_glyph(n) = line;
+ break;
+ case glue_node:
+ if (tag) synctex_tag_glue(n) = tag;
+ if (line) synctex_line_glue(n) = line;
+ break;
+ case kern_node:
+ if (tag) synctex_tag_kern(n) = tag;
+ if (line) synctex_line_kern(n) = line;
+ break;
+ case hlist_node:
+ case vlist_node:
+ case unset_node:
+ if (tag) synctex_tag_box(n) = tag;
+ if (line) synctex_line_box(n) = line;
+ break;
+ case rule_node:
+ if (tag) synctex_tag_rule(n) = tag;
+ if (line) synctex_line_rule(n) = line;
+ break;
+ case math_node:
+ if (tag) synctex_tag_math(n) = tag;
+ if (line) synctex_line_math(n) = line;
+ break;
+ }
+ }
+ return 0;
+}
+
+static int lua_nodelib_direct_get_synctex_fields(lua_State * L)
+{
+ halfword n = lua_tointeger(L, 1);
+ if (n != null) {
+ switch (type(n)) {
+ case glyph_node:
+ lua_pushinteger(L,synctex_tag_glyph(n));
+ lua_pushinteger(L,synctex_line_glyph(n));
+ break;
+ case glue_node:
+ lua_pushinteger(L,synctex_tag_glue(n));
+ lua_pushinteger(L,synctex_line_glue(n));
+ break;
+ case kern_node:
+ lua_pushinteger(L,synctex_tag_kern(n));
+ lua_pushinteger(L,synctex_line_kern(n));
+ break;
+ case hlist_node:
+ case vlist_node:
+ case unset_node:
+ lua_pushinteger(L,synctex_tag_box(n));
+ lua_pushinteger(L,synctex_line_box(n));
+ break;
+ case rule_node:
+ lua_pushinteger(L,synctex_tag_rule(n));
+ lua_pushinteger(L,synctex_line_rule(n));
+ break;
+ case math_node:
+ lua_pushinteger(L,synctex_tag_math(n));
+ lua_pushinteger(L,synctex_line_math(n));
+ break;
+ default:
+ return 0;
+ break;
+ }
+ return 2;
+ }
+ return 0;
+}
+
+/* done */
+
static const struct luaL_Reg nodelib_p[] = {
{"__index", lua_nodelib_get_property_t},
{"__newindex", lua_nodelib_set_property_t},
@@ -7641,6 +8022,7 @@ static const struct luaL_Reg direct_nodelib_f[] = {
{"getshift", lua_nodelib_direct_getshift},
{"getfield", lua_nodelib_direct_getfield},
{"getfont", lua_nodelib_direct_getfont},
+ {"getfam", lua_nodelib_direct_getfam},
{"getid", lua_nodelib_direct_getid},
{"getnext", lua_nodelib_direct_getnext},
{"getprev", lua_nodelib_direct_getprev},
@@ -7659,6 +8041,7 @@ static const struct luaL_Reg direct_nodelib_f[] = {
{"has_field", lua_nodelib_direct_has_field},
{"is_char", lua_nodelib_direct_is_char},
{"is_glyph", lua_nodelib_direct_is_glyph},
+ {"uses_font", lua_nodelib_direct_uses_font},
{"hpack", lua_nodelib_direct_hpack},
/* {"id", lua_nodelib_id}, */ /* no node argument */
{"insert_after", lua_nodelib_direct_insert_after},
@@ -7681,6 +8064,7 @@ static const struct luaL_Reg direct_nodelib_f[] = {
{"setfield", lua_nodelib_direct_setfield},
{"setchar", lua_nodelib_direct_setchar},
{"setfont", lua_nodelib_direct_setfont},
+ {"setfam", lua_nodelib_direct_setfam},
{"setcomponents", lua_nodelib_direct_setcomponents},
{"setlang", lua_nodelib_direct_setlang},
{"setkern", lua_nodelib_direct_setkern},
@@ -7716,6 +8100,7 @@ static const struct luaL_Reg direct_nodelib_f[] = {
/* {"type", lua_nodelib_type}, */ /* no node argument */
/* {"types", lua_nodelib_types}, */ /* no node argument */
{"unprotect_glyphs", lua_nodelib_direct_unprotect_glyphs},
+ {"unprotect_glyph", lua_nodelib_direct_unprotect_glyph},
{"unset_attribute", lua_nodelib_direct_unset_attribute},
{"setglue",lua_nodelib_direct_set_glue},
{"getglue",lua_nodelib_direct_get_glue},
@@ -7732,6 +8117,10 @@ static const struct luaL_Reg direct_nodelib_f[] = {
{"effective_glue", lua_nodelib_direct_effective_glue},
{"check_discretionary", lua_nodelib_direct_check_discretionary},
{"check_discretionaries", lua_nodelib_direct_check_discretionaries},
+ {"flatten_discretionaries",lua_nodelib_direct_flatten_discretionaries},
+ /* done */
+ {"set_synctex_fields", lua_nodelib_direct_set_synctex_fields},
+ {"get_synctex_fields", lua_nodelib_direct_get_synctex_fields},
/* done */
{NULL, NULL} /* sentinel */
};
@@ -7775,6 +8164,7 @@ static const struct luaL_Reg nodelib_f[] = {
{"has_field", lua_nodelib_has_field},
{"is_char", lua_nodelib_is_char},
{"is_glyph", lua_nodelib_is_glyph},
+ {"uses_font", lua_nodelib_uses_font},
{"hpack", lua_nodelib_hpack},
{"id", lua_nodelib_id},
{"insert_after", lua_nodelib_insert_after},
@@ -7804,6 +8194,7 @@ static const struct luaL_Reg nodelib_f[] = {
{"type", lua_nodelib_type},
{"types", lua_nodelib_types},
{"unprotect_glyphs", lua_nodelib_unprotect_glyphs},
+ {"unprotect_glyph", lua_nodelib_unprotect_glyph},
{"unset_attribute", lua_nodelib_unset_attribute},
{"setglue",lua_nodelib_set_glue},
{"getglue",lua_nodelib_get_glue},
@@ -7823,7 +8214,12 @@ static const struct luaL_Reg nodelib_f[] = {
{"effective_glue", lua_nodelib_effective_glue},
{"check_discretionary", lua_nodelib_check_discretionary},
{"check_discretionaries", lua_nodelib_check_discretionaries},
+ {"flatten_discretionaries",lua_nodelib_flatten_discretionaries},
+ /* done */
+ /* {"set_synctex_fields", lua_nodelib_set_synctex_fields}, */
+ /* {"get_synctex_fields", lua_nodelib_get_synctex_fields}, */
/* done */
+ {"fix_node_lists", lua_nodelib_fix_node_lists},
{NULL, NULL} /* sentinel */
};
diff --git a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
index f20604ead8f..88f9eac7c24 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
@@ -949,6 +949,25 @@ static int getpdfcreationdate(lua_State * L)
return 1 ;
}
+static int getpdfmajorversion(lua_State * L)
+{
+ /* lua_pushinteger(L,static_pdf->major_version); */
+ lua_pushinteger(L,pdf_major_version);
+ return 1 ;
+}
+
+static int setpdfmajorversion(lua_State * L)
+{
+ if (lua_type(L, 1) == LUA_TNUMBER) {
+ int c = (int) lua_tointeger(L, 1);
+ if ((c >= 1) && (c <= 2)) {
+ static_pdf->major_version = c;
+ set_pdf_major_version(c);
+ }
+ }
+ return 0 ;
+}
+
static int getpdfminorversion(lua_State * L)
{
/* lua_pushinteger(L,static_pdf->minor_version); */
@@ -1199,6 +1218,8 @@ static const struct luaL_Reg pdflib[] = {
{ "xformname", getpdfxformname },
{ "getversion", getpdfversion },
{ "getcreationdate", getpdfcreationdate },
+ { "getmajorversion", getpdfmajorversion },
+ { "setmajorversion", setpdfmajorversion },
{ "getminorversion", getpdfminorversion },
{ "setminorversion", setpdfminorversion },
{ "newcolorstack", newpdfcolorstack },
diff --git a/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc b/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc
index 8bdbcf16535..eb881b63c3d 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc
+++ b/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc
@@ -944,7 +944,7 @@ LUALIB_API int luaopen_pdfscanner(lua_State * L)
luaL_openlib(L, 0, scannerlib_meta, 0);
lua_pushvalue(L, -1);
lua_setfield(L, -2, "__index");
- luaL_openlib(L, NULL, scannerlib_m, 0);
+ luaL_register(L, NULL, scannerlib_m);
luaL_register(L, "pdfscanner", scannerlib);
return 1;
}
diff --git a/Build/source/texk/web2c/luatexdir/lua/lstatslib.c b/Build/source/texk/web2c/luatexdir/lua/lstatslib.c
index 6ec2f0bd488..943cd0fb07a 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lstatslib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lstatslib.c
@@ -20,6 +20,7 @@
#include "ptexlib.h"
#include "lua/luatex-api.h"
+#include "luatex_svnversion.h"
typedef struct statistic {
const char *name;
@@ -260,6 +261,11 @@ static lua_Number kpse_used_state(void)
}
}
+static lua_Number get_development_id(void)
+{
+ return (lua_Number) luatex_svn_revision ;
+}
+
/* temp, for backward compat */
static int init_pool_ptr = 0;
@@ -293,6 +299,7 @@ static struct statistic stats[] = {
{"banner", 'S', (void *) &getbanner},
{"luatex_version", 'G', &get_luatexversion},
{"luatex_revision", 'S', (void *) &luatexrevision},
+ {"development_id", 'N', &get_development_id},
{"luatex_hashtype", 'S', (void *) &get_luatexhashtype},
{"luatex_hashchars", 'N', &get_luatexhashchars},
{"luatex_engine", 'S', (void *) &getenginename},
@@ -471,9 +478,15 @@ static int resetmessages(lua_State * L)
return 0;
}
+static int setexitcode(lua_State * L) {
+ defaultexitcode = luaL_checkinteger(L,1);
+ return 0;
+}
+
static const struct luaL_Reg statslib[] = {
{"list", statslist},
{"resetmessages", resetmessages},
+ {"setexitcode", setexitcode},
{NULL, NULL} /* sentinel */
};
diff --git a/Build/source/texk/web2c/luatexdir/lua/lstrlibext.c b/Build/source/texk/web2c/luatexdir/lua/lstrlibext.c
index 5d5c0d723ac..f7f8cbf10ea 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lstrlibext.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lstrlibext.c
@@ -359,6 +359,133 @@ static int str_bytetable (lua_State *L) {
return 1;
}
+/*
+ We provide a few helpers that we derived from the lua utf8 module
+ and slunicode. That way we're sort of covering a decent mix.
+
+*/
+
+#define MAXUNICODE 0x10FFFF
+
+/*
+ This is a combination of slunicode and utf8 converters but without mode
+ and a bit faster on the average than the utf8 one.
+*/
+
+static void utf8_enco (luaL_Buffer *b, unsigned c)
+{
+ if (c > MAXUNICODE) {
+ /* we silently ignore the bad character */
+ return;
+ }
+ if (0x80 > c) {
+ luaL_addchar(b, c);
+ return;
+ }
+ if (0x800 > c)
+ luaL_addchar(b, 0xC0|(c>>6));
+ else {
+ if (0x10000 > c)
+ luaL_addchar(b, 0xE0|(c>>12));
+ else {
+ luaL_addchar(b, 0xF0|(c>>18));
+ luaL_addchar(b, 0x80|(0x3F&(c>>12)));
+ }
+ luaL_addchar(b, 0x80|(0x3F&(c>>6)));
+ }
+ luaL_addchar(b, 0x80|(0x3F&c));
+}
+
+static int str_character (lua_State *L) {
+ int n = lua_gettop(L); /* number of arguments */
+ int i;
+ luaL_Buffer b;
+ luaL_buffinit(L,&b);
+ for (i = 1; i <= n; i++) {
+ utf8_enco (&b, (unsigned) lua_tointeger(L, i));
+ }
+ luaL_pushresult(&b);
+ return 1;
+}
+
+/*
+ The utf8 codepoint function takes two arguments, being positions in the
+ string, while slunicode byte takes two arguments representing the number of
+ utf characters. The variant below always returns all codepoints.
+
+*/
+
+static int str_utfvalue (lua_State *L) {
+ size_t ls;
+ int ind = 0;
+ int num = 0;
+ const char *s = lua_tolstring(L, 1, &ls);
+ while (ind<(int)ls) {
+ unsigned char i = (unsigned)*(s+ind);
+ if (i<0x80) {
+ lua_pushinteger(L, i);
+ num += 1;
+ ind += 1;
+ } else if (i>=0xF0) {
+ if ((ind+3)<(int)ls && ((unsigned)*(s+ind+1))>=0x80 && ((unsigned)*(s+ind+2))>=0x80 && ((unsigned)*(s+ind+3))>=0x80) {
+ unsigned char j = ((unsigned)*(s+ind+1))-128;
+ unsigned char k = ((unsigned)*(s+ind+2))-128;
+ unsigned char l = ((unsigned)*(s+ind+3))-128;
+ lua_pushinteger(L, (((((i-0xF0)*64) + j)*64) + k)*64 + l);
+ num += 1;
+ }
+ ind += 4;
+ } else if (i>=0xE0) {
+ if ((ind+2)<(int)ls && ((unsigned)*(s+ind+1))>=0x80 && ((unsigned)*(s+ind+2))>=0x80) {
+ unsigned char j = ((unsigned)*(s+ind+1))-128;
+ unsigned char k = ((unsigned)*(s+ind+2))-128;
+ lua_pushinteger(L, (((i-0xE0)*64) + j)*64 + k);
+ num += 1;
+ }
+ ind += 3;
+ } else if (i>=0xC0) {
+ if ((ind+1)<(int)ls && ((unsigned)*(s+ind+1))>=0x80) {
+ unsigned char j = ((unsigned)*(s+ind+1))-128;
+ lua_pushinteger(L, ((i-0xC0)*64) + j);
+ num += 1;
+ }
+ ind += 2;
+ } else {
+ ind += 1;
+ }
+ }
+ return num;
+}
+
+/* This is a simplified version of utf8.len but without range. */
+
+static int str_utflength (lua_State *L) {
+ size_t ls;
+ int ind = 0;
+ int num = 0;
+ const char *s = lua_tolstring(L, 1, &ls);
+ while (ind<(int)ls) {
+ unsigned char i = (unsigned)*(s+ind);
+ if (i<0x80) {
+ ind += 1;
+ } else if (i>=0xF0) {
+ ind += 4;
+ } else if (i>=0xE0) {
+ ind += 3;
+ } else if (i>=0xC0) {
+ ind += 2;
+ } else {
+ /* bad news, stupid recovery */
+ ind += 1;
+ }
+ num += 1;
+ }
+ lua_pushinteger(L, num);
+ return 1;
+}
+
+/* end of convenience inclusion */
+
static const luaL_Reg strlibext[] = {
{"utfvalues", str_utfvalues},
{"utfcharacters", str_utfcharacters},
@@ -368,6 +495,9 @@ static const luaL_Reg strlibext[] = {
{"bytepairs", str_bytepairs},
{"bytetable", str_bytetable},
{"explode", str_split},
+ {"utfcharacter", str_character},
+ {"utfvalue", str_utfvalue},
+ {"utflength", str_utflength},
#ifdef LuajitTeX
/* luajit has dump built in */
#else
diff --git a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
index b5a110657f4..65e55705e44 100644
--- a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c
@@ -789,7 +789,7 @@ static int get_item_index(lua_State * L, int i, int base)
static int gettex(lua_State * L);
-#define get_item_index_plus(L, where, base, what, value, is_assign, get_register, glue) { \
+#define get_item_index_plus(L, where, base, what, value, is_assign, get_register, texget) { \
size_t len; \
const char *str; \
int key, cs; \
@@ -804,7 +804,7 @@ static int gettex(lua_State * L);
if (key >= 0 && key <= 65535) { \
value = get_register(key); \
} else if (is_assign(eq_type(cs))) { \
- gettex(L); /* lazy */ \
+ texget = gettex(L); /* lazy */ \
} else { \
luaL_error(L, "incorrect %s name", what); \
} \
@@ -849,7 +849,11 @@ static int setdimen(lua_State * L)
static int getdimen(lua_State * L)
{
int value = 0;
- get_item_index_plus(L, lua_gettop(L), scaled_base, "dimen", value, is_dim_assign, get_tex_dimen_register, false);
+ int texget = 0;
+ get_item_index_plus(L, lua_gettop(L), scaled_base, "dimen", value, is_dim_assign, get_tex_dimen_register, texget);
+ if (texget > 0) {
+ return texget;
+ }
lua_pushinteger(L, value);
return 1;
}
@@ -877,7 +881,11 @@ static int setskip(lua_State * L)
static int getskip(lua_State * L)
{
int value = 0;
- get_item_index_plus(L, lua_gettop(L), skip_base, "skip", value, is_glue_assign, get_tex_skip_register, true);
+ int texget = 0;
+ get_item_index_plus(L, lua_gettop(L), skip_base, "skip", value, is_glue_assign, get_tex_skip_register, texget);
+ if (texget > 0) {
+ return texget;
+ }
if (value == null) {
lua_nodelib_push_fast(L, copy_node(zero_glue));
} else {
@@ -910,22 +918,47 @@ static int setglue(lua_State * L)
static int getglue(lua_State * L)
{
int value = 0;
+ int texget = 0;
int top = lua_gettop(L);
- get_item_index_plus(L, top, skip_base, "skip", value, is_glue_assign, get_tex_skip_register, true);
- if (value == null) {
- lua_pushinteger(L,0);
- lua_pushinteger(L,0);
- lua_pushinteger(L,0);
- lua_pushinteger(L,0);
- lua_pushinteger(L,0);
+ int dim = -1;
+ if (top > 1 && lua_type(L,top) == LUA_TBOOLEAN) {
+ dim = lua_toboolean(L,top);
+ top = top - 1;
} else {
- lua_pushinteger(L,width(value));
- lua_pushinteger(L,stretch(value));
- lua_pushinteger(L,shrink(value));
- lua_pushinteger(L,stretch_order(value));
- lua_pushinteger(L,shrink_order(value));
+ lua_pushboolean(L,1);
+ dim = 1 ;
+ /* no top adaption. somewhat messy, but the gettex fallback checks itself */
+ }
+ /* checks itself for the boolean */
+ get_item_index_plus(L, top, skip_base, "glue", value, is_glue_assign, get_tex_skip_register, texget);
+ if (texget > 0) {
+ return texget;
+ }
+ if (dim == 0) {
+ /* false */
+ if (value == null) {
+ lua_pushinteger(L,0);
+ } else {
+ lua_pushinteger(L,width(value));
+ }
+ return 1;
+ } else {
+ /* true and nil */
+ if (value == null) {
+ lua_pushinteger(L,0);
+ lua_pushinteger(L,0);
+ lua_pushinteger(L,0);
+ lua_pushinteger(L,0);
+ lua_pushinteger(L,0);
+ } else {
+ lua_pushinteger(L,width(value));
+ lua_pushinteger(L,stretch(value));
+ lua_pushinteger(L,shrink(value));
+ lua_pushinteger(L,stretch_order(value));
+ lua_pushinteger(L,shrink_order(value));
+ }
+ return 5;
}
- return 5;
}
static int ismuskip(lua_State * L)
@@ -947,7 +980,11 @@ static int setmuskip(lua_State * L)
static int getmuskip(lua_State * L)
{
int value = 0;
- get_item_index_plus(L, lua_gettop(L), mu_skip_base, "muskip", value, is_mu_glue_assign, get_tex_mu_skip_register, true);
+ int texget = 0;
+ get_item_index_plus(L, lua_gettop(L), mu_skip_base, "muskip", value, is_mu_glue_assign, get_tex_mu_skip_register, texget);
+ if (texget > 0) {
+ return texget;
+ }
lua_nodelib_push_fast(L, copy_node(value));
return 1;
}
@@ -976,16 +1013,45 @@ static int setmuglue(lua_State * L)
static int getmuglue(lua_State * L)
{
int value = 0;
- get_item_index_plus(L, lua_gettop(L), mu_skip_base, "muskip", value, is_mu_glue_assign, get_tex_mu_skip_register, true);
- if (value == null) {
- lua_pushnil(L);
- return 1;
+ int texget = 0;
+ int top = lua_gettop(L);
+ int dim = -1;
+ if (top > 1 && lua_type(L,top) == LUA_TBOOLEAN) {
+ dim = lua_toboolean(L,top);
+ top = top - 1;
} else {
- lua_pushinteger(L,width(value));
- lua_pushinteger(L,stretch(value));
- lua_pushinteger(L,shrink(value));
- lua_pushinteger(L,stretch_order(value));
- lua_pushinteger(L,shrink_order(value));
+ lua_pushboolean(L,1);
+ dim = 1 ;
+ /* no top adaption. somewhat messy, but the gettex fallback checks itself */
+ }
+ /* checks itself for the boolean */
+ get_item_index_plus(L, top, mu_skip_base, "muskip", value, is_mu_glue_assign, get_tex_mu_skip_register, texget);
+ if (texget > 0) {
+ return texget;
+ }
+ if (dim == 0) {
+ /* false */
+ if (value == null) {
+ lua_pushinteger(L,0);
+ } else {
+ lua_pushinteger(L,width(value));
+ }
+ return 1;
+ } else {
+ /* true and nil */
+ if (value == null) {
+ lua_pushinteger(L,0);
+ lua_pushinteger(L,0);
+ lua_pushinteger(L,0);
+ lua_pushinteger(L,0);
+ lua_pushinteger(L,0);
+ } else {
+ lua_pushinteger(L,width(value));
+ lua_pushinteger(L,stretch(value));
+ lua_pushinteger(L,shrink(value));
+ lua_pushinteger(L,stretch_order(value));
+ lua_pushinteger(L,shrink_order(value));
+ }
return 5;
}
}
@@ -1015,7 +1081,11 @@ static int setcount(lua_State * L)
static int getcount(lua_State * L)
{
int value = 0;
- get_item_index_plus(L, lua_gettop(L), count_base, "count", value, is_int_assign, get_tex_count_register, false);
+ int texget = 0;
+ get_item_index_plus(L, lua_gettop(L), count_base, "count", value, is_int_assign, get_tex_count_register, texget);
+ if (texget > 0) {
+ return texget;
+ }
lua_pushinteger(L, value);
return 1;
}
@@ -1047,7 +1117,11 @@ static int setattribute(lua_State * L)
static int getattribute(lua_State * L)
{
int value = 0;
- get_item_index_plus(L, lua_gettop(L), attribute_base, "attribute", value, is_attr_assign, get_tex_attribute_register, false);
+ int texget = 0;
+ get_item_index_plus(L, lua_gettop(L), attribute_base, "attribute", value, is_attr_assign, get_tex_attribute_register, texget);
+ if (texget > 0) {
+ return texget;
+ }
lua_pushinteger(L, value);
return 1;
}
@@ -2278,7 +2352,7 @@ static const struct luaL_Reg nest_m[] = {
static void init_nest_lib(lua_State * L)
{
luaL_newmetatable(L, NEST_METATABLE);
- luaL_register(L, NULL, nest_m);
+ luaL_openlib(L, NULL, nest_m, 0);
lua_pop(L, 1);
}
@@ -2656,7 +2730,7 @@ static int tex_enableprimitives(lua_State * L)
#define get_dimen_par(A,B) do { \
lua_key_rawgeti(A); \
if (lua_type(L, -1) == LUA_TNUMBER) { \
- A = (int) lua_tointeger(L, -1); \
+ A = (int) lua_roundnumber(L, -1); \
} else { \
A = (B); \
} \
@@ -2937,11 +3011,12 @@ static int tex_run_boot(lua_State * L)
/* Initialize synctex primitive */
synctexinitcommand();
/* tex is ready to go, now */
+ /*
unhide_lua_table(Luas, "tex", tex_table_id);
unhide_lua_table(Luas, "pdf", pdf_table_id);
unhide_lua_table(Luas, "token", token_table_id);
unhide_lua_table(Luas, "node", node_table_id);
-
+ */
lua_pushboolean(L, 1); /* true */
return 1;
}
@@ -3040,6 +3115,7 @@ static int tex_save_box_resource(lua_State * L)
int attributes = null;
int resources = null;
int type = 0;
+ int margin = pdf_xform_margin;
boolean immediate = false;
/* box attributes resources */
halfword boxnumber = lua_tointeger(L,1);
@@ -3057,6 +3133,9 @@ static int tex_save_box_resource(lua_State * L)
if (lua_type(L,5) == LUA_TNUMBER) {
type = lua_tointeger(L, 5);
}
+ if (lua_type(L,6) == LUA_TNUMBER) {
+ margin = lua_tointeger(L, 6);
+ }
/* more or less same as scanner variant */
boxdata = box(boxnumber);
if (boxdata == null)
@@ -3073,6 +3152,7 @@ static int tex_save_box_resource(lua_State * L)
set_obj_xform_height(static_pdf, index, height(boxdata));
set_obj_xform_depth(static_pdf, index, depth(boxdata));
set_obj_xform_type(static_pdf, index, type);
+ set_obj_xform_margin(static_pdf, index, margin);
box(boxnumber) = null;
last_saved_box_index = index;
lua_pushinteger(L, index);
@@ -3137,14 +3217,16 @@ static int tex_get_box_resource_dimensions(lua_State * L)
lua_pushnil(L);
lua_pushnil(L);
lua_pushnil(L);
+ lua_pushnil(L);
} else {
index = lua_tointeger(L,1);
check_obj_type(static_pdf, obj_type_xform, index);
lua_pushinteger(L, (int) obj_xform_width(static_pdf, index));
lua_pushinteger(L, (int) obj_xform_height(static_pdf, index));
lua_pushinteger(L, (int) obj_xform_depth(static_pdf, index));
+ lua_pushinteger(L, (int) obj_xform_margin(static_pdf, index));
}
- return 3;
+ return 4;
}
static int tex_build_page(lua_State * L)
@@ -3153,6 +3235,69 @@ static int tex_build_page(lua_State * L)
return 0;
}
+/* synctex */
+
+static int lua_set_synctex_mode(lua_State * L)
+{
+ halfword mode = lua_tointeger(L, 1);
+ synctex_set_mode(mode);
+ return 0;
+}
+static int lua_get_synctex_mode(lua_State * L)
+{
+ lua_pushinteger(L,synctex_get_mode());
+ return 1;
+}
+
+static int lua_set_synctex_tag(lua_State * L)
+{
+ halfword tag = lua_tointeger(L, 1);
+ synctex_set_tag(tag);
+ return 0;
+}
+
+static int lua_get_synctex_tag(lua_State * L)
+{
+ lua_pushinteger(L,synctex_get_tag());
+ return 1;
+}
+
+static int lua_force_synctex_tag(lua_State * L)
+{
+ halfword tag = lua_tointeger(L, 1);
+ synctex_force_tag(tag);
+ return 0;
+}
+
+static int lua_force_synctex_line(lua_State * L)
+{
+ halfword line = lua_tointeger(L, 1);
+ synctex_force_line(line);
+ return 0;
+}
+
+static int lua_set_synctex_line(lua_State * L)
+{
+ halfword line = lua_tointeger(L, 1);
+ synctex_set_line(line);
+ return 0;
+}
+
+static int lua_get_synctex_line(lua_State * L)
+{
+ lua_pushinteger(L,synctex_get_line());
+ return 1;
+}
+
+static int lua_set_synctex_no_files(lua_State * L)
+{
+ halfword flag = lua_tointeger(L, 1);
+ synctex_set_no_files(flag);
+ return 0;
+}
+
+/* till here */
+
void init_tex_table(lua_State * L)
{
lua_createtable(L, 0, 3);
@@ -3252,13 +3397,23 @@ static const struct luaL_Reg texlib[] = {
{ "getboxresourcedimensions", tex_get_box_resource_dimensions },
/* just for testing: it will probably stay but maybe with options */
{ "triggerbuildpage", tex_build_page },
+ /* not the best place but better than in node */
+ { "set_synctex_mode", lua_set_synctex_mode },
+ { "get_synctex_mode", lua_get_synctex_mode },
+ { "set_synctex_tag", lua_set_synctex_tag },
+ { "get_synctex_tag", lua_get_synctex_tag },
+ { "set_synctex_no_files", lua_set_synctex_no_files },
+ { "force_synctex_tag", lua_force_synctex_tag },
+ { "force_synctex_line", lua_force_synctex_line },
+ { "set_synctex_line", lua_set_synctex_line },
+ { "get_synctex_line", lua_get_synctex_line },
/* sentinel */
{ NULL, NULL }
};
int luaopen_tex(lua_State * L)
{
- luaL_register(L, "tex", texlib);
+ luaL_openlib(L, "tex", texlib, 0);
/* *INDENT-OFF* */
make_table(L, "attribute", "tex.attribute", "getattribute", "setattribute");
make_table(L, "skip", "tex.skip", "getskip", "setskip");
diff --git a/Build/source/texk/web2c/luatexdir/lua/luainit.w b/Build/source/texk/web2c/luatexdir/lua/luainit.w
index fa43976b0ac..763ac1a42a5 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luainit.w
+++ b/Build/source/texk/web2c/luatexdir/lua/luainit.w
@@ -446,7 +446,7 @@ static void parse_options(int ac, char **av)
"kpathsea : Karl Berry, Olaf Weber and others\n"
"lua : Roberto Ierusalimschy, Waldemar Celes and Luiz Henrique de Figueiredo\n"
"metapost : John Hobby, Taco Hoekwater and friends\n"
- "poppler : Derek Noonburg, Kristian H\\ogsberg (partial)\n"
+ "poppler : Derek Noonburg, Kristian Hogsberg (partial)\n"
"fontforge : George Williams (partial)\n"
"luajit : Mike Pall (used in LuajitTeX)\n");
/* *INDENT-ON* */
@@ -767,10 +767,12 @@ static void setup_lua_path(lua_State * L)
@ helper variables for the safe keeping of table ids
@c
+/*
int tex_table_id;
int pdf_table_id;
int token_table_id;
int node_table_id;
+*/
@ @c
int l_pack_type_index [PACK_TYPE_SIZE] ;
@@ -941,8 +943,8 @@ void lua_initialize(int ac, char **av)
/* If setlocale fails here, then the state */
/* could be compromised, and we exit. */
env_locale = setlocale (LC_ALL, "");
- if (!env_locale) {
- fprintf(stderr,"Unable to read environment locale:exit now.\n");
+ if (!env_locale && !lua_only) {
+ fprintf(stderr,"Unable to read environment locale: exit now.\n");
exit(1);
}
tmp = setlocale (LC_CTYPE, NULL);
@@ -962,7 +964,7 @@ void lua_initialize(int ac, char **av)
/* we can't ensure a 'sane' locale for lua. */
env_locale = setlocale (LC_ALL, old_locale);
if (!env_locale) {
- fprintf(stderr,"Unable to restore original locale:exit now.\n");
+ fprintf(stderr,"Unable to restore original locale %s: exit now.\n",old_locale);
exit(1);
}
xfree(old_locale);
@@ -1011,47 +1013,53 @@ void lua_initialize(int ac, char **av)
/* now run the file */
if (startup_filename != NULL) {
char *v1;
- /* hide the 'tex' and 'pdf' table */
- tex_table_id = hide_lua_table(Luas, "tex");
- token_table_id = hide_lua_table(Luas, "token");
- node_table_id = hide_lua_table(Luas, "node");
- pdf_table_id = hide_lua_table(Luas, "pdf");
-
+ int tex_table_id = hide_lua_table(Luas, "tex");
+ int token_table_id = hide_lua_table(Luas, "token");
+ int node_table_id = hide_lua_table(Luas, "node");
+ int pdf_table_id = hide_lua_table(Luas, "pdf");
+ if (lua_only) {
+ /* hide the 'tex' and 'pdf' table */
+ if (load_luatex_core_lua(Luas)) {
+ fprintf(stderr, "Error in execution of luatex-core.lua .\n");
+ }
+ if (luaL_loadfile(Luas, startup_filename)) {
+ fprintf(stdout, "%s\n", lua_tostring(Luas, -1));
+ exit(1);
+ }
+ init_tex_table(Luas); /* needed ? */
+ if (lua_pcall(Luas, 0, 0, 0)) {
+ fprintf(stdout, "%s\n", lua_tostring(Luas, -1));
+ lua_traceback(Luas);
+ /* lua_close(Luas); */
+ exit(1);
+ } else {
+ if (given_file)
+ free(given_file);
+ /* lua_close(Luas); */
+ exit(0);
+ }
+ }
+ /* a normal tex run */
+ init_tex_table(Luas);
+ unhide_lua_table(Luas, "tex", tex_table_id);
+ unhide_lua_table(Luas, "pdf", pdf_table_id);
+ unhide_lua_table(Luas, "token", token_table_id);
+ unhide_lua_table(Luas, "node", node_table_id);
if (luaL_loadfile(Luas, startup_filename)) {
fprintf(stdout, "%s\n", lua_tostring(Luas, -1));
exit(1);
}
- /* */
- init_tex_table(Luas);
- if (lua_only) {
- if (load_luatex_core_lua(Luas))
- fprintf(stderr, "Error in execution of luatex-core.lua .\n");
- }
if (lua_pcall(Luas, 0, 0, 0)) {
fprintf(stdout, "%s\n", lua_tostring(Luas, -1));
- lua_traceback(Luas);
+ lua_traceback(Luas);
exit(1);
}
- /* no filename? quit now! */
if (!input_name) {
get_lua_string("texconfig", "jobname", &input_name);
}
if (!dump_name) {
get_lua_string("texconfig", "formatname", &dump_name);
}
- if (lua_only) {
- if (given_file)
- free(given_file);
- /* this is not strictly needed but it pleases valgrind */
- lua_close(Luas);
- exit(0);
- }
- /* unhide the 'tex' and 'pdf' table */
- unhide_lua_table(Luas, "tex", tex_table_id);
- unhide_lua_table(Luas, "pdf", pdf_table_id);
- unhide_lua_table(Luas, "token", token_table_id);
- unhide_lua_table(Luas, "node", node_table_id);
-
/* |kpse_init| */
kpse_init = -1;
get_lua_boolean("texconfig", "kpse_init", &kpse_init);
diff --git a/Build/source/texk/web2c/luatexdir/lua/luanode.w b/Build/source/texk/web2c/luatexdir/lua/luanode.w
index af15748bacd..c09cac1ff01 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luanode.w
+++ b/Build/source/texk/web2c/luatexdir/lua/luanode.w
@@ -96,21 +96,18 @@ void lua_node_filter(int filterid, int extrainfo, halfword head_node, halfword *
start_node = vlink(head_node);
if (start_node != null) {
/* maybe just always slide (harmless and fast) */
- last_node = vlink(start_node);
if (fix_node_lists) {
- while (last_node != null) {
- alink(last_node) = start_node;
- start_node = last_node;
- last_node = vlink(start_node);
- }
+ /* slides and returns last node */
+ *tail_node = fix_node_list(start_node);
} else {
+ last_node = vlink(start_node);
while (last_node != null) {
start_node = last_node;
last_node = vlink(start_node);
}
+ /* we're at the end now */
+ *tail_node = start_node;
}
- /* we're at the end now */
- *tail_node = start_node;
} else {
/* we're already at the end */
*tail_node = head_node;
diff --git a/Build/source/texk/web2c/luatexdir/lua/luastuff.w b/Build/source/texk/web2c/luatexdir/lua/luastuff.w
index 6f57e8ee845..7274a683637 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luastuff.w
+++ b/Build/source/texk/web2c/luatexdir/lua/luastuff.w
@@ -619,34 +619,6 @@ void preset_environment(lua_State * L, const parm_struct * p, const char *s)
luajit compatibility layer for luatex lua5.2
*/
#ifdef LuajitTeX
-LUALIB_API void *luaL_testudata (lua_State *L, int ud, const char *tname) {
- void *p = lua_touserdata(L, ud);
- if (p != NULL) { /* value is a userdata? */
- if (lua_getmetatable(L, ud)) { /* does it have a metatable? */
- luaL_getmetatable(L, tname); /* get correct metatable */
- if (!lua_rawequal(L, -1, -2)) /* not the same? */
- p = NULL; /* value is a userdata with wrong metatable */
- lua_pop(L, 2); /* remove both metatables */
- return p;
- }
- }
- return NULL; /* value is not a userdata with a metatable */
-}
-
-@ @c
-/* It's not ok. See lua-users.org/wiki/CompatibilityWithLuaFive for another solution */
-LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
- /*luaL_checkversion(L);*/
- luaL_checkstack(L, nup, "too many upvalues");
- for (; l->name != NULL; l++) { /* fill the table with given functions */
- int i;
- for (i = 0; i < nup; i++) /* copy upvalues to the top */
- lua_pushvalue(L, -nup);
- lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */
- lua_setfield(L, -(nup + 2), l->name);
- }
- lua_pop(L, nup); /* remove upvalues */
-}
@ @c
LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) {
diff --git a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h
index b83745049c8..36b2f5979e1 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h
+++ b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h
@@ -130,6 +130,7 @@ extern int luaopen_font(lua_State * L);
extern int luaopen_vf(lua_State * L);
extern int font_to_lua(lua_State * L, int f);
extern int font_from_lua(lua_State * L, int f); /* return is boolean */
+extern int characters_from_lua(lua_State * L, int f); /* return is boolean */
extern int luaopen_token(lua_State * L);
extern void tokenlist_to_lua(lua_State * L, int p);
@@ -224,10 +225,13 @@ extern int loader_Call_luatex(lua_State * L, const char *name, const char *filen
extern void init_tex_table(lua_State * L);
+/*
extern int tex_table_id;
extern int pdf_table_id;
extern int token_table_id;
extern int node_table_id;
+*/
+
extern int main_initialize(void);
extern int do_run_callback(int special, const char *values, va_list vl);
@@ -503,7 +507,6 @@ make_lua_key(area);\
make_lua_key(art);\
make_lua_key(attr);\
make_lua_key(attributes);\
-make_lua_key(auto_expand);\
make_lua_key(bbox);\
make_lua_key(before_display);\
make_lua_key(best_ins_ptr);\
@@ -715,6 +718,7 @@ make_lua_key(pagesattributes);\
make_lua_key(parameters);\
make_lua_key(pardir);\
make_lua_key(parshape);\
+make_lua_key(pdf);\
make_lua_key(pdf_data);\
make_lua_key(pdf_destination);\
make_lua_key(pdf_literal);\
@@ -875,7 +879,6 @@ init_lua_key(area);\
init_lua_key(art);\
init_lua_key(attr);\
init_lua_key(attributes);\
-init_lua_key(auto_expand);\
init_lua_key(bbox);\
init_lua_key(before_display);\
init_lua_key(best_ins_ptr);\
@@ -1220,6 +1223,7 @@ init_lua_key_alias(pLTL,"+LTL");\
init_lua_key_alias(pRTT,"+RTT");\
init_lua_key_alias(pTLT,"+TLT");\
init_lua_key_alias(pTRT,"+TRT");\
+init_lua_key_alias(pdf,"pdf");\
init_lua_key_alias(pdf_data,"pdf.data");\
init_lua_key_alias(term_and_log,"term and log")
@@ -1294,7 +1298,6 @@ use_lua_key(area);
use_lua_key(art);
use_lua_key(attr);
use_lua_key(attributes);
-use_lua_key(auto_expand);
use_lua_key(bbox);
use_lua_key(before_display);
use_lua_key(best_ins_ptr);
@@ -1506,6 +1509,7 @@ use_lua_key(pagesattributes);
use_lua_key(parameters);
use_lua_key(pardir);
use_lua_key(parshape);
+use_lua_key(pdf);
use_lua_key(pdf_data);
use_lua_key(pdf_destination);
use_lua_key(pdf_literal);
diff --git a/Build/source/texk/web2c/luatexdir/lua/luatex-core.c b/Build/source/texk/web2c/luatexdir/lua/luatex-core.c
index 631f25c3b99..780c12f4c50 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luatex-core.c
+++ b/Build/source/texk/web2c/luatexdir/lua/luatex-core.c
@@ -24,7 +24,7 @@ int load_luatex_core_lua (lua_State * L)
0x54, 0x65, 0x58, 0x20, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x20,
0x54, 0x65, 0x61, 0x6d, 0x27, 0x2c, 0x0a, 0x2d, 0x2d, 0x20, 0x7d, 0x0a, 0x0a, 0x4c, 0x55, 0x41,
0x54, 0x45, 0x58, 0x43, 0x4f, 0x52, 0x45, 0x56, 0x45, 0x52, 0x53, 0x49, 0x4f, 0x4e, 0x20, 0x3d,
- 0x20, 0x31, 0x2e, 0x30, 0x30, 0x32, 0x0a, 0x0a, 0x2d, 0x2d, 0x20, 0x54, 0x68, 0x69, 0x73, 0x20,
+ 0x20, 0x31, 0x2e, 0x30, 0x30, 0x33, 0x0a, 0x0a, 0x2d, 0x2d, 0x20, 0x54, 0x68, 0x69, 0x73, 0x20,
0x66, 0x69, 0x6c, 0x65, 0x20, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x20, 0x73,
0x6f, 0x6d, 0x65, 0x20, 0x4c, 0x75, 0x61, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
0x73, 0x2e, 0x20, 0x54, 0x68, 0x65, 0x20, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x20,
@@ -45,214 +45,260 @@ int load_luatex_core_lua (lua_State * L)
0x65, 0x20, 0x3d, 0x20, 0x74, 0x79, 0x70, 0x65, 0x2c, 0x20, 0x6e, 0x65, 0x78, 0x74, 0x2c, 0x20,
0x67, 0x65, 0x74, 0x6d, 0x65, 0x74, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2c, 0x20, 0x72, 0x65,
0x71, 0x75, 0x69, 0x72, 0x65, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x69, 0x6e, 0x64,
- 0x2c, 0x20, 0x67, 0x73, 0x75, 0x62, 0x20, 0x3d, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e,
- 0x66, 0x69, 0x6e, 0x64, 0x2c, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x67, 0x73, 0x75,
- 0x62, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x69, 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x69,
- 0x6f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x69, 0x6f, 0x5f,
- 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x2e, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x0a, 0x6c, 0x6f, 0x63, 0x61,
- 0x6c, 0x20, 0x69, 0x6f, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x2e, 0x6c, 0x69, 0x6e, 0x65, 0x73,
- 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x61, 0x64,
- 0x6c, 0x69, 0x6e, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x66, 0x69,
- 0x6f, 0x2e, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
- 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73,
- 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x66, 0x69, 0x6f, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b,
- 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
- 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x66, 0x69, 0x6c, 0x65, 0x6e,
- 0x61, 0x6d, 0x65, 0x20, 0x20, 0x3d, 0x20, 0x66, 0x69, 0x6f, 0x2e, 0x72, 0x65, 0x63, 0x6f, 0x72,
- 0x64, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
- 0x20, 0x6d, 0x74, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x67, 0x65, 0x74, 0x6d, 0x65, 0x74, 0x61, 0x74, 0x61,
- 0x62, 0x6c, 0x65, 0x28, 0x69, 0x6f, 0x2e, 0x73, 0x74, 0x64, 0x65, 0x72, 0x72, 0x29, 0x0a, 0x6c,
- 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6d, 0x74, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x6d, 0x74, 0x2e, 0x6c, 0x69,
- 0x6e, 0x65, 0x73, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x73, 0x61, 0x66, 0x65, 0x72, 0x6f,
- 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20,
- 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x73, 0x61, 0x66, 0x65, 0x72, 0x5f, 0x6f, 0x70, 0x74,
- 0x69, 0x6f, 0x6e, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x65,
- 0x73, 0x63, 0x61, 0x70, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20,
- 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x5f, 0x65, 0x73, 0x63,
- 0x61, 0x70, 0x65, 0x20, 0x2d, 0x2d, 0x20, 0x30, 0x20, 0x28, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c,
- 0x65, 0x64, 0x29, 0x20, 0x31, 0x20, 0x28, 0x61, 0x6e, 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x29,
- 0x20, 0x32, 0x20, 0x28, 0x72, 0x65, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, 0x65, 0x64, 0x29, 0x0a,
- 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6b, 0x70, 0x73, 0x65, 0x75, 0x73, 0x65, 0x64, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x73, 0x74, 0x61, 0x74,
- 0x75, 0x73, 0x2e, 0x6b, 0x70, 0x73, 0x65, 0x5f, 0x75, 0x73, 0x65, 0x64, 0x20, 0x20, 0x20, 0x20,
- 0x2d, 0x2d, 0x20, 0x30, 0x20, 0x31, 0x0a, 0x0a, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x76, 0x65, 0x64,
- 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x20, 0x2d, 0x2d, 0x20,
- 0x63, 0x61, 0x6e, 0x20, 0x62, 0x65, 0x20, 0x70, 0x72, 0x6f, 0x74, 0x65, 0x63, 0x74, 0x65, 0x64,
- 0x0a, 0x2d, 0x2d, 0x20, 0x28, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x20, 0x66, 0x6f, 0x72,
- 0x20, 0x74, 0x6c, 0x31, 0x37, 0x20, 0x72, 0x65, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x29, 0x20, 0x69,
- 0x6f, 0x2e, 0x73, 0x61, 0x76, 0x65, 0x64, 0x5f, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x5f, 0x70, 0x6f,
- 0x70, 0x65, 0x6e, 0x20, 0x2d, 0x2d, 0x20, 0x63, 0x61, 0x6e, 0x20, 0x62, 0x65, 0x20, 0x70, 0x72,
- 0x6f, 0x74, 0x65, 0x63, 0x74, 0x65, 0x64, 0x0a, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x76, 0x65, 0x64,
- 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x20, 0x2d, 0x2d, 0x20,
- 0x61, 0x6c, 0x77, 0x61, 0x79, 0x73, 0x20, 0x72, 0x65, 0x61, 0x64, 0x6f, 0x6e, 0x6c, 0x79, 0x0a,
- 0x6d, 0x74, 0x2e, 0x73, 0x61, 0x76, 0x65, 0x64, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x6d, 0x74, 0x5f, 0x6c,
- 0x69, 0x6e, 0x65, 0x73, 0x20, 0x2d, 0x2d, 0x20, 0x61, 0x6c, 0x77, 0x61, 0x79, 0x73, 0x20, 0x72,
- 0x65, 0x61, 0x64, 0x6f, 0x6e, 0x6c, 0x79, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66,
- 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f, 0x69,
- 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x68, 0x6f, 0x77, 0x29,
- 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x68, 0x6f, 0x77, 0x20,
- 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x68, 0x6f, 0x77,
- 0x20, 0x3d, 0x20, 0x27, 0x72, 0x27, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20,
- 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x5f,
- 0x6f, 0x70, 0x65, 0x6e, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x68, 0x6f, 0x77, 0x29, 0x0a, 0x20,
+ 0x2c, 0x20, 0x67, 0x73, 0x75, 0x62, 0x2c, 0x20, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x20, 0x3d,
+ 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x66, 0x69, 0x6e, 0x64, 0x2c, 0x20, 0x73, 0x74,
+ 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x67, 0x73, 0x75, 0x62, 0x2c, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e,
+ 0x67, 0x2e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20,
+ 0x69, 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x0a, 0x6c, 0x6f,
+ 0x63, 0x61, 0x6c, 0x20, 0x69, 0x6f, 0x5f, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x2e, 0x70, 0x6f, 0x70,
+ 0x65, 0x6e, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x69, 0x6f, 0x5f, 0x6c, 0x69, 0x6e, 0x65,
+ 0x73, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x69,
+ 0x6f, 0x2e, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66,
+ 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x3d, 0x20, 0x66, 0x69, 0x6f, 0x2e, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e,
+ 0x65, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x63, 0x68, 0x65, 0x63,
+ 0x6b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x66, 0x69,
+ 0x6f, 0x2e, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f,
+ 0x6e, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x63, 0x6f,
+ 0x72, 0x64, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x20, 0x3d, 0x20, 0x66, 0x69,
+ 0x6f, 0x2e, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65,
+ 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6d, 0x74, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x67, 0x65,
+ 0x74, 0x6d, 0x65, 0x74, 0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x28, 0x69, 0x6f, 0x2e, 0x73, 0x74,
+ 0x64, 0x65, 0x72, 0x72, 0x29, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6d, 0x74, 0x5f, 0x6c,
+ 0x69, 0x6e, 0x65, 0x73, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x3d, 0x20, 0x6d, 0x74, 0x2e, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
+ 0x20, 0x73, 0x61, 0x66, 0x65, 0x72, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x73, 0x61,
+ 0x66, 0x65, 0x72, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
+ 0x20, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x73, 0x68,
+ 0x65, 0x6c, 0x6c, 0x5f, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x20, 0x2d, 0x2d, 0x20, 0x30, 0x20,
+ 0x28, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x29, 0x20, 0x31, 0x20, 0x28, 0x61, 0x6e,
+ 0x79, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x29, 0x20, 0x32, 0x20, 0x28, 0x72, 0x65, 0x73, 0x74, 0x72,
+ 0x69, 0x63, 0x74, 0x65, 0x64, 0x29, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6b, 0x70, 0x73,
+ 0x65, 0x75, 0x73, 0x65, 0x64, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x3d, 0x20, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x6b, 0x70, 0x73, 0x65, 0x5f, 0x75,
+ 0x73, 0x65, 0x64, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x30, 0x20, 0x31, 0x0a, 0x0a, 0x6c,
+ 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x6e, 0x6c, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x69, 0x6f,
+ 0x2e, 0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x6e, 0x6c, 0x0a, 0x0a, 0x69, 0x6f, 0x2e, 0x73, 0x61,
+ 0x76, 0x65, 0x64, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x20,
+ 0x2d, 0x2d, 0x20, 0x61, 0x6c, 0x77, 0x61, 0x79, 0x73, 0x20, 0x72, 0x65, 0x61, 0x64, 0x6f, 0x6e,
+ 0x6c, 0x79, 0x0a, 0x6d, 0x74, 0x2e, 0x73, 0x61, 0x76, 0x65, 0x64, 0x5f, 0x6c, 0x69, 0x6e, 0x65,
+ 0x73, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x6d,
+ 0x74, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x20, 0x2d, 0x2d, 0x20, 0x61, 0x6c, 0x77, 0x61, 0x79,
+ 0x73, 0x20, 0x72, 0x65, 0x61, 0x64, 0x6f, 0x6e, 0x6c, 0x79, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61,
+ 0x6c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65,
+ 0x78, 0x5f, 0x69, 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x68,
+ 0x6f, 0x77, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x68,
+ 0x6f, 0x77, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x68, 0x6f, 0x77, 0x20, 0x3d, 0x20, 0x27, 0x72, 0x27, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e,
+ 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x20, 0x3d, 0x20,
+ 0x69, 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x68, 0x6f, 0x77,
+ 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x66, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x74, 0x79, 0x70, 0x65, 0x28,
+ 0x68, 0x6f, 0x77, 0x29, 0x20, 0x3d, 0x3d, 0x20, 0x27, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x27,
+ 0x20, 0x61, 0x6e, 0x64, 0x20, 0x66, 0x69, 0x6e, 0x64, 0x28, 0x68, 0x6f, 0x77, 0x2c, 0x27, 0x77,
+ 0x27, 0x29, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x66, 0x69,
+ 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x27, 0x77, 0x27, 0x29,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65,
+ 0x63, 0x6f, 0x72, 0x64, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x28, 0x6e, 0x61, 0x6d,
+ 0x65, 0x2c, 0x27, 0x72, 0x27, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65,
+ 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72,
+ 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x6c, 0x6f, 0x63,
+ 0x61, 0x6c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74,
+ 0x65, 0x78, 0x5f, 0x69, 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6f,
+ 0x6e, 0x6c, 0x79, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x68, 0x6f, 0x77, 0x29, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x69, 0x66, 0x20, 0x68, 0x6f, 0x77, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x68, 0x6f, 0x77, 0x20, 0x3d, 0x20, 0x27, 0x72, 0x27, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x68, 0x6f, 0x77, 0x20, 0x3d, 0x20, 0x67, 0x73, 0x75, 0x62, 0x28, 0x68, 0x6f, 0x77, 0x2c,
+ 0x27, 0x5b, 0x5e, 0x72, 0x62, 0x5d, 0x27, 0x2c, 0x27, 0x27, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x68, 0x6f, 0x77, 0x20, 0x3d, 0x3d, 0x20, 0x27, 0x27,
+ 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x68, 0x6f, 0x77, 0x20, 0x3d, 0x20, 0x27, 0x72, 0x27, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x20, 0x3d, 0x20, 0x69, 0x6f,
+ 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x68, 0x6f, 0x77, 0x29, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x66, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64,
+ 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x27, 0x72,
+ 0x27, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72,
+ 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x6c, 0x6f, 0x63,
+ 0x61, 0x6c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74,
+ 0x65, 0x78, 0x5f, 0x69, 0x6f, 0x5f, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x28, 0x6e, 0x61, 0x6d, 0x65,
+ 0x2c, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20,
+ 0x6f, 0x6b, 0x61, 0x79, 0x2c, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x66, 0x69,
+ 0x6f, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f,
+ 0x6e, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6f,
+ 0x6b, 0x61, 0x79, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x74, 0x68,
+ 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72,
+ 0x6e, 0x20, 0x69, 0x6f, 0x5f, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x28, 0x66, 0x6f, 0x75, 0x6e, 0x64,
+ 0x2c, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x65, 0x6e,
+ 0x64, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f, 0x69, 0x6f, 0x5f, 0x6c, 0x69, 0x6e, 0x65,
+ 0x73, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x68, 0x6f, 0x77, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x69, 0x66, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x20, 0x3d, 0x20, 0x69,
+ 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x68, 0x6f, 0x77, 0x20,
+ 0x6f, 0x72, 0x20, 0x27, 0x72, 0x27, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x69, 0x66, 0x20, 0x66, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e,
+ 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66,
+ 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x28, 0x66, 0x29, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65,
+ 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x69, 0x6f, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x28, 0x29, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
+ 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78,
+ 0x5f, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x28, 0x66, 0x29, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x28, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65,
+ 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e,
+ 0x65, 0x28, 0x66, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x65, 0x6e, 0x64,
+ 0x0a, 0x0a, 0x69, 0x6f, 0x2e, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x6c, 0x75, 0x61,
+ 0x74, 0x65, 0x78, 0x5f, 0x69, 0x6f, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x0a, 0x6d, 0x74, 0x2e,
+ 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f, 0x69,
+ 0x6f, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x0a, 0x0a, 0x2d, 0x2d, 0x20, 0x57,
+ 0x65, 0x20, 0x61, 0x73, 0x73, 0x75, 0x6d, 0x65, 0x20, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d,
+ 0x65, 0x6e, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x65, 0x20, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64,
+ 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x68, 0x65, 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63,
+ 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x6b, 0x70, 0x73, 0x65, 0x2e, 0x20, 0x54,
+ 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x0a, 0x2d, 0x2d, 0x20, 0x63, 0x61,
+ 0x73, 0x65, 0x20, 0x69, 0x6e, 0x20, 0x43, 0x6f, 0x6e, 0x54, 0x65, 0x58, 0x74, 0x2e, 0x0a, 0x0a,
+ 0x69, 0x66, 0x20, 0x6b, 0x70, 0x73, 0x65, 0x75, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x3d, 0x20, 0x31,
+ 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x6f, 0x70,
+ 0x65, 0x6e, 0x20, 0x20, 0x3d, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f, 0x69, 0x6f, 0x5f,
+ 0x6f, 0x70, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x70, 0x6f, 0x70, 0x65,
+ 0x6e, 0x20, 0x3d, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f, 0x69, 0x6f, 0x5f, 0x70, 0x6f,
+ 0x70, 0x65, 0x6e, 0x0a, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x69, 0x66, 0x20, 0x73, 0x61, 0x66,
+ 0x65, 0x72, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x3d, 0x20, 0x31, 0x20, 0x74, 0x68,
+ 0x65, 0x6e, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75,
+ 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x64, 0x75,
+ 0x6d, 0x6d, 0x79, 0x28, 0x73, 0x74, 0x72, 0x2c, 0x66, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65,
+ 0x64, 0x20, 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f,
+ 0x6e, 0x28, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74,
+ 0x65, 0x64, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x6e, 0x6c,
+ 0x28, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x28, 0x22, 0x73, 0x61, 0x66, 0x65, 0x72, 0x20, 0x6f,
+ 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x73, 0x65, 0x74, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74,
+ 0x69, 0x6f, 0x6e, 0x20, 0x25, 0x71, 0x20, 0x69, 0x73, 0x20, 0x25, 0x73, 0x22, 0x2c, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x73, 0x74, 0x72, 0x2c, 0x66, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x22, 0x6c, 0x69,
+ 0x6d, 0x69, 0x74, 0x65, 0x64, 0x22, 0x20, 0x6f, 0x72, 0x20, 0x22, 0x64, 0x69, 0x73, 0x61, 0x62,
+ 0x6c, 0x65, 0x64, 0x22, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x20,
+ 0x3d, 0x20, 0x74, 0x72, 0x75, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x66, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x74, 0x79, 0x70, 0x65, 0x28, 0x68, 0x6f, 0x77,
- 0x29, 0x20, 0x3d, 0x3d, 0x20, 0x27, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x27, 0x20, 0x61, 0x6e,
- 0x64, 0x20, 0x66, 0x69, 0x6e, 0x64, 0x28, 0x68, 0x6f, 0x77, 0x2c, 0x27, 0x77, 0x27, 0x29, 0x20,
- 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x66, 0x69, 0x6c, 0x65, 0x6e,
- 0x61, 0x6d, 0x65, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x27, 0x77, 0x27, 0x29, 0x0a, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x72,
- 0x64, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x27,
- 0x72, 0x27, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a,
- 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
- 0x72, 0x6e, 0x20, 0x66, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20,
- 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f,
- 0x69, 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6f, 0x6e, 0x6c, 0x79,
- 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x68, 0x6f, 0x77, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69,
- 0x66, 0x20, 0x68, 0x6f, 0x77, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x68, 0x6f, 0x77, 0x20, 0x3d, 0x20, 0x27, 0x72, 0x27, 0x0a, 0x20, 0x20, 0x20,
- 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x68, 0x6f,
- 0x77, 0x20, 0x3d, 0x20, 0x67, 0x73, 0x75, 0x62, 0x28, 0x68, 0x6f, 0x77, 0x2c, 0x27, 0x5b, 0x5e,
- 0x72, 0x62, 0x5d, 0x27, 0x2c, 0x27, 0x27, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x69, 0x66, 0x20, 0x68, 0x6f, 0x77, 0x20, 0x3d, 0x3d, 0x20, 0x27, 0x27, 0x20, 0x74, 0x68,
- 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x68,
- 0x6f, 0x77, 0x20, 0x3d, 0x20, 0x27, 0x72, 0x27, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20,
- 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x5f, 0x6f, 0x70,
- 0x65, 0x6e, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x68, 0x6f, 0x77, 0x29, 0x0a, 0x20, 0x20, 0x20,
- 0x20, 0x69, 0x66, 0x20, 0x66, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x66, 0x69, 0x6c,
- 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x27, 0x72, 0x27, 0x29, 0x0a,
- 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
- 0x72, 0x6e, 0x20, 0x66, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20,
- 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f,
- 0x69, 0x6f, 0x5f, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x2e, 0x2e,
- 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6f, 0x6b, 0x61,
- 0x79, 0x2c, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x63,
- 0x68, 0x65, 0x63, 0x6b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x28, 0x6e,
- 0x61, 0x6d, 0x65, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6f, 0x6b, 0x61, 0x79,
- 0x20, 0x61, 0x6e, 0x64, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x69,
- 0x6f, 0x5f, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x28, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x2c, 0x2e, 0x2e,
- 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a,
- 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c,
- 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f, 0x69, 0x6f, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x28, 0x6e,
- 0x61, 0x6d, 0x65, 0x2c, 0x68, 0x6f, 0x77, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20,
- 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x20, 0x3d, 0x20, 0x69, 0x6f, 0x5f, 0x6f,
- 0x70, 0x65, 0x6e, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x2c, 0x68, 0x6f, 0x77, 0x20, 0x6f, 0x72, 0x20,
- 0x27, 0x72, 0x27, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20,
- 0x66, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
- 0x6f, 0x6e, 0x28, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x69, 0x6f, 0x5f,
- 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x28, 0x66, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65,
- 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
- 0x69, 0x6f, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x28, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65,
- 0x6e, 0x64, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75,
- 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f, 0x69, 0x6f,
- 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x28, 0x66, 0x29, 0x0a, 0x20, 0x20, 0x20,
- 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
- 0x28, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72,
- 0x6e, 0x20, 0x66, 0x69, 0x6f, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x28, 0x66,
- 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x69,
- 0x6f, 0x2e, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78,
- 0x5f, 0x69, 0x6f, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x0a, 0x6d, 0x74, 0x2e, 0x6c, 0x69, 0x6e,
- 0x65, 0x73, 0x20, 0x3d, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f, 0x69, 0x6f, 0x5f, 0x72,
- 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x65, 0x0a, 0x0a, 0x2d, 0x2d, 0x20, 0x57, 0x65, 0x20, 0x61,
- 0x73, 0x73, 0x75, 0x6d, 0x65, 0x20, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x6d, 0x65, 0x6e, 0x74,
- 0x20, 0x74, 0x6f, 0x20, 0x62, 0x65, 0x20, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x64, 0x20,
- 0x62, 0x79, 0x20, 0x74, 0x68, 0x65, 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x6d, 0x65,
- 0x6e, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x6b, 0x70, 0x73, 0x65, 0x2e, 0x20, 0x54, 0x68, 0x69, 0x73,
- 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x0a, 0x2d, 0x2d, 0x20, 0x63, 0x61, 0x73, 0x65, 0x20,
- 0x69, 0x6e, 0x20, 0x43, 0x6f, 0x6e, 0x54, 0x65, 0x58, 0x74, 0x2e, 0x0a, 0x0a, 0x69, 0x66, 0x20,
- 0x6b, 0x70, 0x73, 0x65, 0x75, 0x73, 0x65, 0x64, 0x20, 0x3d, 0x3d, 0x20, 0x31, 0x20, 0x74, 0x68,
- 0x65, 0x6e, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x20,
- 0x20, 0x3d, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f, 0x69, 0x6f, 0x5f, 0x6f, 0x70, 0x65,
- 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x3d,
- 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f, 0x69, 0x6f, 0x5f, 0x70, 0x6f, 0x70, 0x65, 0x6e,
- 0x0a, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x69, 0x66, 0x20, 0x73, 0x61, 0x66, 0x65, 0x72, 0x6f,
- 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x3d, 0x20, 0x31, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a,
- 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x73, 0x2e, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x20,
- 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x73, 0x2e, 0x73, 0x70, 0x61,
- 0x77, 0x6e, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f,
- 0x73, 0x2e, 0x65, 0x78, 0x65, 0x63, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a,
- 0x20, 0x20, 0x20, 0x20, 0x6f, 0x73, 0x2e, 0x73, 0x65, 0x74, 0x65, 0x6e, 0x76, 0x20, 0x20, 0x3d,
- 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x73, 0x2e, 0x74, 0x65, 0x6d, 0x70,
- 0x64, 0x69, 0x72, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69,
- 0x6f, 0x2e, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74,
+ 0x75, 0x72, 0x6e, 0x20, 0x66, 0x28, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x28,
+ 0x73, 0x74, 0x72, 0x2c, 0x66, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c,
+ 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x65, 0x64, 0x20, 0x3d, 0x20,
+ 0x66, 0x61, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x20,
+ 0x20, 0x20, 0x20, 0x6f, 0x73, 0x2e, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x20, 0x3d, 0x20,
+ 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x28, 0x22, 0x6f, 0x73,
+ 0x2e, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x22, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f,
+ 0x73, 0x2e, 0x73, 0x70, 0x61, 0x77, 0x6e, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x73, 0x74,
+ 0x61, 0x6c, 0x6c, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x28, 0x22, 0x6f, 0x73, 0x2e, 0x73, 0x70, 0x61,
+ 0x77, 0x6e, 0x22, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x73, 0x2e, 0x65, 0x78, 0x65, 0x63,
+ 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x64, 0x75, 0x6d,
+ 0x6d, 0x79, 0x28, 0x22, 0x6f, 0x73, 0x2e, 0x65, 0x78, 0x65, 0x63, 0x22, 0x29, 0x0a, 0x20, 0x20,
+ 0x20, 0x20, 0x6f, 0x73, 0x2e, 0x73, 0x65, 0x74, 0x65, 0x6e, 0x76, 0x20, 0x20, 0x3d, 0x20, 0x69,
+ 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x28, 0x22, 0x6f, 0x73, 0x2e,
+ 0x73, 0x65, 0x74, 0x65, 0x6e, 0x76, 0x22, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x73, 0x2e,
+ 0x74, 0x65, 0x6d, 0x70, 0x64, 0x69, 0x72, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c,
+ 0x6c, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x28, 0x22, 0x6f, 0x73, 0x2e, 0x74, 0x65, 0x6d, 0x70, 0x64,
+ 0x69, 0x72, 0x22, 0x29, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x70, 0x6f, 0x70,
+ 0x65, 0x6e, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x64, 0x75,
+ 0x6d, 0x6d, 0x79, 0x28, 0x22, 0x69, 0x6f, 0x2e, 0x70, 0x6f, 0x70, 0x65, 0x6e, 0x22, 0x29, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x20, 0x20, 0x20, 0x3d,
- 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x73, 0x2e, 0x72, 0x65, 0x6e,
- 0x61, 0x6d, 0x65, 0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f,
- 0x73, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a,
- 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x74, 0x6d, 0x70, 0x66, 0x69, 0x6c, 0x65, 0x20,
- 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x6f, 0x75, 0x74,
- 0x70, 0x75, 0x74, 0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20,
- 0x6c, 0x66, 0x73, 0x2e, 0x63, 0x68, 0x64, 0x69, 0x72, 0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c,
- 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x66, 0x73, 0x2e, 0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x20, 0x20,
- 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x66, 0x73, 0x2e, 0x74, 0x6f,
- 0x75, 0x63, 0x68, 0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c,
- 0x66, 0x73, 0x2e, 0x72, 0x6d, 0x64, 0x69, 0x72, 0x20, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a,
- 0x20, 0x20, 0x20, 0x20, 0x6c, 0x66, 0x73, 0x2e, 0x6d, 0x6b, 0x64, 0x69, 0x72, 0x20, 0x20, 0x3d,
- 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x73, 0x61, 0x76,
- 0x65, 0x64, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x20, 0x3d, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65,
- 0x78, 0x5f, 0x69, 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6f, 0x6e,
- 0x6c, 0x79, 0x0a, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x69, 0x66, 0x20, 0x73, 0x61, 0x66, 0x65,
- 0x72, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x3d, 0x20, 0x31, 0x20, 0x6f, 0x72, 0x20,
- 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x20, 0x7e, 0x3d, 0x20, 0x31,
- 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x66, 0x69, 0x20, 0x3d,
- 0x20, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x28, 0x27, 0x66, 0x66, 0x69, 0x27, 0x29, 0x0a,
- 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x6b, 0x2c, 0x20, 0x76, 0x20, 0x69, 0x6e, 0x20,
- 0x6e, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x66, 0x66, 0x69, 0x20, 0x64, 0x6f, 0x0a, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6b, 0x20, 0x7e, 0x3d, 0x20, 0x27, 0x67, 0x63,
- 0x27, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x66, 0x66, 0x69, 0x5b, 0x6b, 0x5d, 0x20, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20,
- 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x66, 0x69, 0x20, 0x3d, 0x20, 0x6e, 0x69,
- 0x6c, 0x0a, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x2d, 0x2d, 0x20, 0x6f, 0x73, 0x2e, 0x5b, 0x65,
- 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x7c, 0x6f, 0x73, 0x2e, 0x73, 0x70, 0x61, 0x77, 0x6e, 0x7c,
- 0x6f, 0x73, 0x2e, 0x65, 0x78, 0x65, 0x63, 0x5d, 0x20, 0x61, 0x6c, 0x72, 0x65, 0x61, 0x64, 0x79,
- 0x20, 0x61, 0x72, 0x65, 0x20, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65,
- 0x20, 0x61, 0x77, 0x61, 0x72, 0x65, 0x29, 0x0a, 0x0a, 0x0a, 0x69, 0x66, 0x20, 0x6d, 0x64, 0x35,
- 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
- 0x20, 0x73, 0x75, 0x6d, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x6d, 0x64, 0x35, 0x2e, 0x73, 0x75,
- 0x6d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x67, 0x73, 0x75, 0x62,
- 0x20, 0x20, 0x20, 0x3d, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x67, 0x73, 0x75, 0x62,
- 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x6f, 0x72, 0x6d, 0x61,
- 0x74, 0x20, 0x3d, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x66, 0x6f, 0x72, 0x6d, 0x61,
- 0x74, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x62, 0x79, 0x74, 0x65,
- 0x20, 0x20, 0x20, 0x3d, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x62, 0x79, 0x74, 0x65,
- 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6d,
- 0x64, 0x35, 0x2e, 0x73, 0x75, 0x6d, 0x68, 0x65, 0x78, 0x61, 0x28, 0x6b, 0x29, 0x0a, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, 0x67, 0x73,
- 0x75, 0x62, 0x28, 0x73, 0x75, 0x6d, 0x28, 0x6b, 0x29, 0x2c, 0x20, 0x22, 0x2e, 0x22, 0x2c, 0x20,
- 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x63, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66,
- 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x28, 0x22, 0x25, 0x30, 0x32, 0x78, 0x22, 0x2c, 0x62, 0x79, 0x74,
- 0x65, 0x28, 0x63, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e,
- 0x64, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x20, 0x20, 0x20,
- 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6d, 0x64, 0x35, 0x2e, 0x73, 0x75,
- 0x6d, 0x48, 0x45, 0x58, 0x41, 0x28, 0x6b, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, 0x67, 0x73, 0x75, 0x62, 0x28, 0x73, 0x75,
- 0x6d, 0x28, 0x6b, 0x29, 0x2c, 0x20, 0x22, 0x2e, 0x22, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74,
- 0x69, 0x6f, 0x6e, 0x28, 0x63, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74,
- 0x28, 0x22, 0x25, 0x30, 0x32, 0x58, 0x22, 0x2c, 0x62, 0x79, 0x74, 0x65, 0x28, 0x63, 0x29, 0x29,
- 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x29, 0x29, 0x0a, 0x20,
- 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x00
+ 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x28, 0x22, 0x69,
+ 0x6f, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x22, 0x2c, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x5f, 0x69,
+ 0x6f, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x5f, 0x72, 0x65, 0x61, 0x64, 0x6f, 0x6e, 0x6c, 0x79, 0x29,
+ 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x73, 0x2e, 0x72, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x20,
+ 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x28,
+ 0x22, 0x6f, 0x73, 0x2e, 0x72, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x29, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x6f, 0x73, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6e,
+ 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x28, 0x22, 0x6f, 0x73, 0x2e, 0x72,
+ 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x22, 0x29, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e,
+ 0x74, 0x6d, 0x70, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c,
+ 0x6c, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x28, 0x22, 0x69, 0x6f, 0x2e, 0x74, 0x6d, 0x70, 0x66, 0x69,
+ 0x6c, 0x65, 0x22, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x6f, 0x2e, 0x6f, 0x75, 0x74, 0x70,
+ 0x75, 0x74, 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x64, 0x75, 0x6d,
+ 0x6d, 0x79, 0x28, 0x22, 0x69, 0x6f, 0x2e, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x22, 0x29, 0x0a,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x66, 0x73, 0x2e, 0x63, 0x68, 0x64, 0x69, 0x72, 0x20, 0x20,
+ 0x3d, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x28, 0x22,
+ 0x6c, 0x66, 0x73, 0x2e, 0x63, 0x68, 0x64, 0x69, 0x72, 0x22, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x6c, 0x66, 0x73, 0x2e, 0x6c, 0x6f, 0x63, 0x6b, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x73,
+ 0x74, 0x61, 0x6c, 0x6c, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x28, 0x22, 0x6c, 0x66, 0x73, 0x2e, 0x6c,
+ 0x6f, 0x63, 0x6b, 0x22, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x66, 0x73, 0x2e, 0x74, 0x6f,
+ 0x75, 0x63, 0x68, 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x64, 0x75,
+ 0x6d, 0x6d, 0x79, 0x28, 0x22, 0x6c, 0x66, 0x73, 0x2e, 0x74, 0x6f, 0x75, 0x63, 0x68, 0x22, 0x29,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x66, 0x73, 0x2e, 0x72, 0x6d, 0x64, 0x69, 0x72, 0x20, 0x20,
+ 0x3d, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x28, 0x22,
+ 0x6c, 0x66, 0x73, 0x2e, 0x72, 0x6d, 0x64, 0x69, 0x72, 0x22, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20,
+ 0x6c, 0x66, 0x73, 0x2e, 0x6d, 0x6b, 0x64, 0x69, 0x72, 0x20, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x73,
+ 0x74, 0x61, 0x6c, 0x6c, 0x64, 0x75, 0x6d, 0x6d, 0x79, 0x28, 0x22, 0x6c, 0x66, 0x73, 0x2e, 0x6d,
+ 0x6b, 0x64, 0x69, 0x72, 0x22, 0x29, 0x0a, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x69, 0x66, 0x20,
+ 0x73, 0x61, 0x66, 0x65, 0x72, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x3d, 0x20, 0x31,
+ 0x20, 0x6f, 0x72, 0x20, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x65, 0x73, 0x63, 0x61, 0x70, 0x65, 0x20,
+ 0x7e, 0x3d, 0x20, 0x31, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66,
+ 0x66, 0x69, 0x20, 0x3d, 0x20, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x28, 0x27, 0x66, 0x66,
+ 0x69, 0x27, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x6b, 0x2c, 0x20, 0x76,
+ 0x20, 0x69, 0x6e, 0x20, 0x6e, 0x65, 0x78, 0x74, 0x2c, 0x20, 0x66, 0x66, 0x69, 0x20, 0x64, 0x6f,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6b, 0x20, 0x7e, 0x3d,
+ 0x20, 0x27, 0x67, 0x63, 0x27, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x66, 0x69, 0x5b, 0x6b, 0x5d, 0x20, 0x3d, 0x20,
+ 0x6e, 0x69, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x66, 0x69, 0x20,
+ 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x2d, 0x2d, 0x20, 0x6f,
+ 0x73, 0x2e, 0x5b, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x65, 0x7c, 0x6f, 0x73, 0x2e, 0x73, 0x70,
+ 0x61, 0x77, 0x6e, 0x7c, 0x6f, 0x73, 0x2e, 0x65, 0x78, 0x65, 0x63, 0x5d, 0x20, 0x61, 0x6c, 0x72,
+ 0x65, 0x61, 0x64, 0x79, 0x20, 0x61, 0x72, 0x65, 0x20, 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x65, 0x73,
+ 0x63, 0x61, 0x70, 0x65, 0x20, 0x61, 0x77, 0x61, 0x72, 0x65, 0x29, 0x0a, 0x0a, 0x0a, 0x69, 0x66,
+ 0x20, 0x6d, 0x64, 0x35, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c,
+ 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x73, 0x75, 0x6d, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x6d, 0x64,
+ 0x35, 0x2e, 0x73, 0x75, 0x6d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20,
+ 0x67, 0x73, 0x75, 0x62, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e,
+ 0x67, 0x73, 0x75, 0x62, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66,
+ 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x20, 0x3d, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x66,
+ 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20,
+ 0x62, 0x79, 0x74, 0x65, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e,
+ 0x62, 0x79, 0x74, 0x65, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x20, 0x6d, 0x64, 0x35, 0x2e, 0x73, 0x75, 0x6d, 0x68, 0x65, 0x78, 0x61, 0x28, 0x6b,
+ 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
+ 0x20, 0x28, 0x67, 0x73, 0x75, 0x62, 0x28, 0x73, 0x75, 0x6d, 0x28, 0x6b, 0x29, 0x2c, 0x20, 0x22,
+ 0x2e, 0x22, 0x2c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x63, 0x29, 0x0a,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75,
+ 0x72, 0x6e, 0x20, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x28, 0x22, 0x25, 0x30, 0x32, 0x78, 0x22,
+ 0x2c, 0x62, 0x79, 0x74, 0x65, 0x28, 0x63, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x65, 0x6e, 0x64, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a,
+ 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6d, 0x64,
+ 0x35, 0x2e, 0x73, 0x75, 0x6d, 0x48, 0x45, 0x58, 0x41, 0x28, 0x6b, 0x29, 0x0a, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, 0x67, 0x73, 0x75,
+ 0x62, 0x28, 0x73, 0x75, 0x6d, 0x28, 0x6b, 0x29, 0x2c, 0x20, 0x22, 0x2e, 0x22, 0x2c, 0x20, 0x66,
+ 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x63, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x66, 0x6f,
+ 0x72, 0x6d, 0x61, 0x74, 0x28, 0x22, 0x25, 0x30, 0x32, 0x58, 0x22, 0x2c, 0x62, 0x79, 0x74, 0x65,
+ 0x28, 0x63, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64,
+ 0x29, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x65, 0x6e, 0x64, 0x0a,
+ 0x0a, 0x00
};
return luaL_dostring(L, (const char*) luatex_core_lua);
} \ No newline at end of file
diff --git a/Build/source/texk/web2c/luatexdir/lua/luatex-core.lua b/Build/source/texk/web2c/luatexdir/lua/luatex-core.lua
index 15e0d8c830d..18bb7fcf0ed 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luatex-core.lua
+++ b/Build/source/texk/web2c/luatexdir/lua/luatex-core.lua
@@ -1,213 +1,229 @@
--- if not modules then modules = { } end modules ['luatex-core'] = {
--- version = 1.001,
--- comment = 'companion to luatex',
--- author = 'Hans Hagen & Luigi Scarso',
--- copyright = 'LuaTeX Development Team',
--- }
-
-LUATEXCOREVERSION = 1.002
-
--- This file overloads some Lua functions. The readline variants provide the same
--- functionality as LuaTeX <= 1.04 and doing it this way permits us to keep the
--- original io libraries clean. Performance is probably even a bit better now.
-
-local type, next, getmetatable, require = type, next, getmetatable, require
-local find, gsub = string.find, string.gsub
-
-local io_open = io.open
-local io_popen = io.popen
-local io_lines = io.lines
-
-local fio_readline = fio.readline
-local fio_checkpermission = fio.checkpermission
-local fio_recordfilename = fio.recordfilename
-
-local mt = getmetatable(io.stderr)
-local mt_lines = mt.lines
-local saferoption = status.safer_option
-local shellescape = status.shell_escape -- 0 (disabled) 1 (anything) 2 (restricted)
-local kpseused = status.kpse_used -- 0 1
-
-io.saved_open = io_open -- can be protected
--- (deleted for tl17 rebuild) io.saved_popen = io_popen -- can be protected
-io.saved_lines = io_lines -- always readonly
-mt.saved_lines = mt_lines -- always readonly
-
-local function luatex_io_open(name,how)
- if not how then
- how = 'r'
- end
- local f = io_open(name,how)
- if f then
- if type(how) == 'string' and find(how,'w') then
- fio_recordfilename(name,'w')
- else
- fio_recordfilename(name,'r')
- end
- end
- return f
-end
-
-local function luatex_io_open_readonly(name,how)
- if how then
- how = 'r'
- else
- how = gsub(how,'[^rb]','')
- if how == '' then
- how = 'r'
- end
- end
- local f = io_open(name,how)
- if f then
- fio_recordfilename(name,'r')
- end
- return f
-end
-
-local function luatex_io_popen(name,...)
- local okay, found = fio_checkpermission(name)
- if okay and found then
- return io_popen(found,...)
- end
-end
-
-local function luatex_io_lines(name,how)
- if name then
- local f = io_open(name,how or 'r')
- if f then
- return function()
- return fio_readline(f)
- end
- end
- else
- return io_lines()
- end
-end
-
-local function luatex_io_readline(f)
- return function()
- return fio_readline(f)
- end
-end
-
-io.lines = luatex_io_lines
-mt.lines = luatex_io_readline
-
--- We assume management to be provided by the replacement of kpse. This is the
--- case in ConTeXt.
-
-if kpseused == 1 then
-
- io.open = luatex_io_open
- io.popen = luatex_io_popen
-
-end
-
-if saferoption == 1 then
-
- os.execute = nil
- os.spawn = nil
- os.exec = nil
- os.setenv = nil
- os.tempdir = nil
-
- io.popen = nil
- io.open = nil
-
- os.rename = nil
- os.remove = nil
-
- io.tmpfile = nil
- io.output = nil
-
- lfs.chdir = nil
- lfs.lock = nil
- lfs.touch = nil
- lfs.rmdir = nil
- lfs.mkdir = nil
-
- io.saved_open = luatex_io_open_readonly
-
-end
-
-if saferoption == 1 or shellescape ~= 1 then
-
- ffi = require('ffi')
- for k, v in next, ffi do
- if k ~= 'gc' then
- ffi[k] = nil
- end
- end
- ffi = nil
-
-end
-
--- os.[execute|os.spawn|os.exec] already are shellescape aware)
-
-
-if md5 then
-
- local sum = md5.sum
- local gsub = string.gsub
- local format = string.format
- local byte = string.byte
-
- function md5.sumhexa(k)
- return (gsub(sum(k), ".", function(c)
- return format("%02x",byte(c))
- end))
- end
-
- function md5.sumHEXA(k)
- return (gsub(sum(k), ".", function(c)
- return format("%02X",byte(c))
- end))
- end
-
-end
-
-if utilities and utilities.merger and utilities.merger.compact then
-
- local byte, format, gmatch = string.byte, string.format, string.gmatch
- local concat = table.concat
-
- local data = gsub(io.loaddata('luatex-core.lua'),'if%s+utilities.*','')
- local t = { }
- local r = { }
- local n = 0
- local d = gsub(data,'\r\n','\n') -- be nice for unix
- local s = utilities.merger.compact(d) -- no comments and less spaces
-
- t[#t+1] = '/* generated from and by luatex-core.lua */'
- t[#t+1] = ''
- -- t[#t+1] = format('/*\n\n%s\n\n*/',d)
- -- t[#t+1] = ''
- t[#t+1] = '#include "lua.h"'
- t[#t+1] = '#include "lauxlib.h"'
- t[#t+1] = ''
- t[#t+1] = 'int load_luatex_core_lua (lua_State * L);'
- t[#t+1] = ''
- t[#t+1] = 'int load_luatex_core_lua (lua_State * L)'
- t[#t+1] = '{'
- t[#t+1] = ' static unsigned char luatex_core_lua[] = {'
- for c in gmatch(d,'.') do
- if n == 16 then
- n = 1
- t[#t+1] = ' ' .. concat(r,', ') .. ','
- else
- n = n + 1
- end
- r[n] = format('0x%02x',byte(c))
- end
- n = n + 1
- r[n] = '0x00'
- t[#t+1] = ' ' .. concat(r,', ',1,n)
- t[#t+1] = ' };'
- -- t[#t+1] = format('unsigned int luatex_core_lua_len = 0x%x;',#d+1)
- t[#t+1] = ' return luaL_dostring(L, (const char*) luatex_core_lua);'
- t[#t+1] = '}'
-
- io.savedata('luatex-core.c',concat(t,'\n'))
- io.savedata('luatex-core-stripped.lua',s)
-
-end
+-- if not modules then modules = { } end modules ['luatex-core'] = {
+-- version = 1.001,
+-- comment = 'companion to luatex',
+-- author = 'Hans Hagen & Luigi Scarso',
+-- copyright = 'LuaTeX Development Team',
+-- }
+
+LUATEXCOREVERSION = 1.003
+
+-- This file overloads some Lua functions. The readline variants provide the same
+-- functionality as LuaTeX <= 1.04 and doing it this way permits us to keep the
+-- original io libraries clean. Performance is probably even a bit better now.
+
+local type, next, getmetatable, require = type, next, getmetatable, require
+local find, gsub, format = string.find, string.gsub, string.format
+
+local io_open = io.open
+local io_popen = io.popen
+local io_lines = io.lines
+
+local fio_readline = fio.readline
+local fio_checkpermission = fio.checkpermission
+local fio_recordfilename = fio.recordfilename
+
+local mt = getmetatable(io.stderr)
+local mt_lines = mt.lines
+local saferoption = status.safer_option
+local shellescape = status.shell_escape -- 0 (disabled) 1 (anything) 2 (restricted)
+local kpseused = status.kpse_used -- 0 1
+
+local write_nl = texio.write_nl
+
+io.saved_lines = io_lines -- always readonly
+mt.saved_lines = mt_lines -- always readonly
+
+local function luatex_io_open(name,how)
+ if not how then
+ how = 'r'
+ end
+ local f = io_open(name,how)
+ if f then
+ if type(how) == 'string' and find(how,'w') then
+ fio_recordfilename(name,'w')
+ else
+ fio_recordfilename(name,'r')
+ end
+ end
+ return f
+end
+
+local function luatex_io_open_readonly(name,how)
+ if how then
+ how = 'r'
+ else
+ how = gsub(how,'[^rb]','')
+ if how == '' then
+ how = 'r'
+ end
+ end
+ local f = io_open(name,how)
+ if f then
+ fio_recordfilename(name,'r')
+ end
+ return f
+end
+
+local function luatex_io_popen(name,...)
+ local okay, found = fio_checkpermission(name)
+ if okay and found then
+ return io_popen(found,...)
+ end
+end
+
+local function luatex_io_lines(name,how)
+ if name then
+ local f = io_open(name,how or 'r')
+ if f then
+ return function()
+ return fio_readline(f)
+ end
+ end
+ else
+ return io_lines()
+ end
+end
+
+local function luatex_io_readline(f)
+ return function()
+ return fio_readline(f)
+ end
+end
+
+io.lines = luatex_io_lines
+mt.lines = luatex_io_readline
+
+-- We assume management to be provided by the replacement of kpse. This is the
+-- case in ConTeXt.
+
+if kpseused == 1 then
+
+ io.open = luatex_io_open
+ io.popen = luatex_io_popen
+
+end
+
+if saferoption == 1 then
+
+ local function installdummy(str,f)
+ local reported = false
+ return function(...)
+ if not reported then
+ write_nl(format("safer option set, function %q is %s",
+ str,f and "limited" or "disabled"))
+ reported = true
+ end
+ if f then
+ return f(...)
+ end
+ end
+ end
+
+ local function installlimit(str,f)
+ local reported = false
+ end
+
+ os.execute = installdummy("os.execute")
+ os.spawn = installdummy("os.spawn")
+ os.exec = installdummy("os.exec")
+ os.setenv = installdummy("os.setenv")
+ os.tempdir = installdummy("os.tempdir")
+
+ io.popen = installdummy("io.popen")
+ io.open = installdummy("io.open",luatex_io_open_readonly)
+
+ os.rename = installdummy("os.rename")
+ os.remove = installdummy("os.remove")
+
+ io.tmpfile = installdummy("io.tmpfile")
+ io.output = installdummy("io.output")
+
+ lfs.chdir = installdummy("lfs.chdir")
+ lfs.lock = installdummy("lfs.lock")
+ lfs.touch = installdummy("lfs.touch")
+ lfs.rmdir = installdummy("lfs.rmdir")
+ lfs.mkdir = installdummy("lfs.mkdir")
+
+end
+
+if saferoption == 1 or shellescape ~= 1 then
+
+ ffi = require('ffi')
+ for k, v in next, ffi do
+ if k ~= 'gc' then
+ ffi[k] = nil
+ end
+ end
+ ffi = nil
+
+end
+
+-- os.[execute|os.spawn|os.exec] already are shellescape aware)
+
+
+if md5 then
+
+ local sum = md5.sum
+ local gsub = string.gsub
+ local format = string.format
+ local byte = string.byte
+
+ function md5.sumhexa(k)
+ return (gsub(sum(k), ".", function(c)
+ return format("%02x",byte(c))
+ end))
+ end
+
+ function md5.sumHEXA(k)
+ return (gsub(sum(k), ".", function(c)
+ return format("%02X",byte(c))
+ end))
+ end
+
+end
+
+if utilities and utilities.merger and utilities.merger.compact then
+
+ local byte, format, gmatch = string.byte, string.format, string.gmatch
+ local concat = table.concat
+
+ local data = gsub(io.loaddata('luatex-core.lua'),'if%s+utilities.*','')
+ local t = { }
+ local r = { }
+ local n = 0
+ local d = gsub(data,'\r\n','\n') -- be nice for unix
+ local s = utilities.merger.compact(d) -- no comments and less spaces
+
+ t[#t+1] = '/* generated from and by luatex-core.lua */'
+ t[#t+1] = ''
+ -- t[#t+1] = format('/*\n\n%s\n\n*/',d)
+ -- t[#t+1] = ''
+ t[#t+1] = '#include "lua.h"'
+ t[#t+1] = '#include "lauxlib.h"'
+ t[#t+1] = ''
+ t[#t+1] = 'int load_luatex_core_lua (lua_State * L);'
+ t[#t+1] = ''
+ t[#t+1] = 'int load_luatex_core_lua (lua_State * L)'
+ t[#t+1] = '{'
+ t[#t+1] = ' static unsigned char luatex_core_lua[] = {'
+ for c in gmatch(d,'.') do
+ if n == 16 then
+ n = 1
+ t[#t+1] = ' ' .. concat(r,', ') .. ','
+ else
+ n = n + 1
+ end
+ r[n] = format('0x%02x',byte(c))
+ end
+ n = n + 1
+ r[n] = '0x00'
+ t[#t+1] = ' ' .. concat(r,', ',1,n)
+ t[#t+1] = ' };'
+ -- t[#t+1] = format('unsigned int luatex_core_lua_len = 0x%x;',#d+1)
+ t[#t+1] = ' return luaL_dostring(L, (const char*) luatex_core_lua);'
+ t[#t+1] = '}'
+
+ io.savedata('luatex-core.c',concat(t,'\n'))
+ io.savedata('luatex-core-stripped.lua',s)
+
+end
diff --git a/Build/source/texk/web2c/luatexdir/lua/luatoken.w b/Build/source/texk/web2c/luatexdir/lua/luatoken.w
index a567c7f7a2b..e9740ffc676 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luatoken.w
+++ b/Build/source/texk/web2c/luatexdir/lua/luatoken.w
@@ -96,6 +96,7 @@ command_item command_names[] = {
{"boundary", boundary_cmd, NULL},
{"radical", radical_cmd, NULL},
{"super_sub_script", super_sub_script_cmd, NULL},
+ {"no_super_sub_script", no_super_sub_script_cmd, NULL},
{"math_shift_cs", math_shift_cs_cmd, NULL},
{"end_cs_name", end_cs_name_cmd, NULL},
{"char_ghost", char_ghost_cmd, NULL},
diff --git a/Build/source/texk/web2c/luatexdir/luaffi/ctype.c b/Build/source/texk/web2c/luatexdir/luaffi/ctype.c
index c93fea03210..f477ea5bc31 100644
--- a/Build/source/texk/web2c/luatexdir/luaffi/ctype.c
+++ b/Build/source/texk/web2c/luatexdir/luaffi/ctype.c
@@ -245,6 +245,8 @@ void* to_cdata(lua_State* L, int idx, struct ctype* ct)
lua_pop(L, 1); /* mt */
cd = (struct cdata*) lua_touserdata(L, idx);
+
+ if (!cd) {lua_pushnil(L);return NULL;}
*ct = cd->type;
lua_getuservalue(L, idx);
diff --git a/Build/source/texk/web2c/luatexdir/luaffi/ffi.c b/Build/source/texk/web2c/luatexdir/luaffi/ffi.c
index abeeb5f1fe0..7771b512db5 100644
--- a/Build/source/texk/web2c/luatexdir/luaffi/ffi.c
+++ b/Build/source/texk/web2c/luatexdir/luaffi/ffi.c
@@ -387,7 +387,12 @@ static size_t unpack_vararg(lua_State* L, int i, char* to)
} else if (ct.type == INT64_TYPE) {
*(int64_t*) to = *(int64_t*) p;
return sizeof(int64_t);
- }
+
+ } else if (ct.type == FUNCTION_PTR_TYPE) {
+ *(cfunction *) to = *(cfunction *)p;
+ return sizeof(cfunction);
+ }
+
goto err;
case LUA_TNIL:
diff --git a/Build/source/texk/web2c/luatexdir/luaffi/ffi.h b/Build/source/texk/web2c/luatexdir/luaffi/ffi.h
index cfc25424175..8be6eccc192 100644
--- a/Build/source/texk/web2c/luatexdir/luaffi/ffi.h
+++ b/Build/source/texk/web2c/luatexdir/luaffi/ffi.h
@@ -370,9 +370,9 @@ __declspec(align(16))
#endif
struct cdata {
const struct ctype type
-#ifdef __GNUC__
- __attribute__ ((aligned(16)))
-#endif
+/*#ifdef __GNUC__*/
+/* __attribute__ ((aligned(16)))*/
+/*#endif*/
;
};
diff --git a/Build/source/texk/web2c/luatexdir/luapeg/lpeg.c b/Build/source/texk/web2c/luatexdir/luapeg/lpeg.c
index 30f54522de5..c2a2287dc7f 100644
--- a/Build/source/texk/web2c/luatexdir/luapeg/lpeg.c
+++ b/Build/source/texk/web2c/luatexdir/luapeg/lpeg.c
@@ -1,7 +1,7 @@
#include "lpeg.h"
/*
-** $Id: lpprint.c,v 1.9 2015/06/15 16:09:57 roberto Exp $
+** $Id: lpprint.c,v 1.10 2016/09/13 16:06:03 roberto Exp $
** Copyright 2007, Lua.org & PUC-Rio (see 'lpeg.html' for license)
*/
@@ -39,13 +39,13 @@ void printcharset (const byte *st) {
}
-static void printcapkind (int kind) {
+static const char *capkind (int kind) {
const char *const modes[] = {
"close", "position", "constant", "backref",
"argument", "simple", "table", "function",
"query", "string", "num", "substitution", "fold",
"runtime", "group"};
- printf("%s", modes[kind]);
+ return modes[kind];
}
@@ -75,13 +75,12 @@ void printinst (const Instruction *op, const Instruction *p) {
break;
}
case IFullCapture: {
- printcapkind(getkind(p));
- printf(" (size = %d) (idx = %d)", getoff(p), p->i.key);
+ printf("%s (size = %d) (idx = %d)",
+ capkind(getkind(p)), getoff(p), p->i.key);
break;
}
case IOpenCapture: {
- printcapkind(getkind(p));
- printf(" (idx = %d)", p->i.key);
+ printf("%s (idx = %d)", capkind(getkind(p)), p->i.key);
break;
}
case ISet: {
@@ -126,8 +125,8 @@ void printpatt (Instruction *p, int n) {
#if defined(LPEG_DEBUG)
static void printcap (Capture *cap) {
- printcapkind(cap->kind);
- printf(" (idx: %d - size: %d) -> %p\n", cap->idx, cap->siz, cap->s);
+ printf("%s (idx: %d - size: %d) -> %p\n",
+ capkind(cap->kind), cap->idx, cap->siz, cap->s);
}
@@ -179,7 +178,8 @@ void printtree (TTree *tree, int ident) {
break;
}
case TOpenCall: case TCall: {
- printf(" key: %d\n", tree->key);
+ assert(sib2(tree)->tag == TRule);
+ printf(" key: %d (rule: %d)\n", tree->key, sib2(tree)->cap);
break;
}
case TBehind: {
@@ -188,7 +188,7 @@ void printtree (TTree *tree, int ident) {
break;
}
case TCapture: {
- printf(" cap: %d key: %d n: %d\n", tree->cap, tree->key, tree->u.n);
+ printf(" kind: '%s' key: %d\n", capkind(tree->cap), tree->key);
printtree(sib1(tree), ident + 2);
break;
}
@@ -244,9 +244,8 @@ void printktable (lua_State *L, int idx) {
/* }====================================================== */
#endif
-
/*
-** $Id: lpvm.c,v 1.6 2015/09/28 17:01:25 roberto Exp $
+** $Id: lpvm.c,v 1.9 2016/06/03 20:11:18 roberto Exp $
** Copyright 2007, Lua.org & PUC-Rio (see 'lpeg.html' for license)
*/
@@ -292,14 +291,16 @@ typedef struct Stack {
/*
-** Double the size of the array of captures
+** Make the size of the array of captures 'cap' twice as large as needed
+** (which is 'captop'). ('n' is the number of new elements.)
*/
-static Capture *doublecap (lua_State *L, Capture *cap, int captop, int ptop) {
+static Capture *doublecap (lua_State *L, Capture *cap, int captop,
+ int n, int ptop) {
Capture *newc;
if (captop >= INT_MAX/((int)sizeof(Capture) * 2))
luaL_error(L, "too many captures");
newc = (Capture *)lua_newuserdata(L, captop * 2 * sizeof(Capture));
- memcpy(newc, cap, captop * sizeof(Capture));
+ memcpy(newc, cap, (captop - n) * sizeof(Capture));
lua_replace(L, caplistidx(ptop));
return newc;
}
@@ -360,8 +361,8 @@ static int resdyncaptures (lua_State *L, int fr, int curr, int limit) {
*/
static void adddyncaptures (const char *s, Capture *base, int n, int fd) {
int i;
- /* Cgroup capture is already there */
- assert(base[0].kind == Cgroup && base[0].siz == 0);
+ base[0].kind = Cgroup; /* create group capture */
+ base[0].siz = 0;
base[0].idx = 0; /* make it an anonymous group */
for (i = 1; i <= n; i++) { /* add runtime captures */
base[i].kind = Cruntime;
@@ -404,10 +405,11 @@ const char *match (lua_State *L, const char *o, const char *s, const char *e,
lua_pushlightuserdata(L, stackbase);
for (;;) {
#if defined(DEBUG)
+ printf("-------------------------------------\n");
+ printcaplist(capture, capture + captop);
printf("s: |%s| stck:%d, dyncaps:%d, caps:%d ",
- s, stack - getstackbase(L, ptop), ndyncap, captop);
+ s, (int)(stack - getstackbase(L, ptop)), ndyncap, captop);
printinst(op, p);
- printcaplist(capture, capture + captop);
#endif
assert(stackidx(ptop) + ndyncap == lua_gettop(L) && ndyncap <= captop);
switch ((Opcode)p->i.code) {
@@ -531,6 +533,9 @@ const char *match (lua_State *L, const char *o, const char *s, const char *e,
ndyncap -= removedyncap(L, capture, stack->caplevel, captop);
captop = stack->caplevel;
p = stack->p;
+#if defined(DEBUG)
+ printf("**FAIL**\n");
+#endif
continue;
}
case ICloseRunTime: {
@@ -540,16 +545,19 @@ const char *match (lua_State *L, const char *o, const char *s, const char *e,
cs.s = o; cs.L = L; cs.ocap = capture; cs.ptop = ptop;
n = runtimecap(&cs, capture + captop, s, &rem); /* call function */
captop -= n; /* remove nested captures */
+ ndyncap -= rem; /* update number of dynamic captures */
fr -= rem; /* 'rem' items were popped from Lua stack */
res = resdyncaptures(L, fr, s - o, e - o); /* get result */
if (res == -1) /* fail? */
goto fail;
s = o + res; /* else update current position */
n = lua_gettop(L) - fr + 1; /* number of new captures */
- ndyncap += n - rem; /* update number of dynamic captures */
+ ndyncap += n; /* update number of dynamic captures */
if (n > 0) { /* any new capture? */
+ if (fr + n >= SHRT_MAX)
+ luaL_error(L, "too many results in match-time capture");
if ((captop += n + 2) >= capsize) {
- capture = doublecap(L, capture, captop, ptop);
+ capture = doublecap(L, capture, captop, n + 2, ptop);
capsize = 2 * captop;
}
/* add new captures to 'capture' list */
@@ -586,7 +594,7 @@ const char *match (lua_State *L, const char *o, const char *s, const char *e,
capture[captop].idx = p->i.key;
capture[captop].kind = getkind(p);
if (++captop >= capsize) {
- capture = doublecap(L, capture, captop, ptop);
+ capture = doublecap(L, capture, captop, 0, ptop);
capsize = 2 * captop;
}
p++;
@@ -601,7 +609,7 @@ const char *match (lua_State *L, const char *o, const char *s, const char *e,
/*
-** $Id: lpcode.c,v 1.23 2015/06/12 18:36:47 roberto Exp $
+** $Id: lpcode.c,v 1.24 2016/09/15 17:46:13 roberto Exp $
** Copyright 2007, Lua.org & PUC-Rio (see 'lpeg.html' for license)
*/
@@ -728,6 +736,27 @@ int tocharset (TTree *tree, Charset *cs) {
/*
+** Visit a TCall node taking care to stop recursion. If node not yet
+** visited, return 'f(sib2(tree))', otherwise return 'def' (default
+** value)
+*/
+static int callrecursive (TTree *tree, int f (TTree *t), int def) {
+ int key = tree->key;
+ assert(tree->tag == TCall);
+ assert(sib2(tree)->tag == TRule);
+ if (key == 0) /* node already visited? */
+ return def; /* return default value */
+ else { /* first visit */
+ int result;
+ tree->key = 0; /* mark call as already visited */
+ result = f(sib2(tree)); /* go to called rule */
+ tree->key = key; /* restore tree */
+ return result;
+ }
+}
+
+
+/*
** Check whether a pattern tree has captures
*/
int hascaptures (TTree *tree) {
@@ -736,14 +765,17 @@ int hascaptures (TTree *tree) {
case TCapture: case TRunTime:
return 1;
case TCall:
- tree = sib2(tree); goto tailcall; /* return hascaptures(sib2(tree)); */
+ return callrecursive(tree, hascaptures, 0);
+ case TRule: /* do not follow siblings */
+ tree = sib1(tree); goto tailcall;
case TOpenCall: assert(0);
default: {
switch (numsiblings[tree->tag]) {
case 1: /* return hascaptures(sib1(tree)); */
tree = sib1(tree); goto tailcall;
case 2:
- if (hascaptures(sib1(tree))) return 1;
+ if (hascaptures(sib1(tree)))
+ return 1;
/* else return hascaptures(sib2(tree)); */
tree = sib2(tree); goto tailcall;
default: assert(numsiblings[tree->tag] == 0); return 0;
@@ -810,9 +842,9 @@ int checkaux (TTree *tree, int pred) {
/*
** number of characters to match a pattern (or -1 if variable)
-** ('count' avoids infinite loops for grammars)
*/
-int fixedlenx (TTree *tree, int count, int len) {
+int fixedlen (TTree *tree) {
+ int len = 0; /* to accumulate in tail calls */
tailcall:
switch (tree->tag) {
case TChar: case TSet: case TAny:
@@ -822,26 +854,29 @@ int fixedlenx (TTree *tree, int count, int len) {
case TRep: case TRunTime: case TOpenCall:
return -1;
case TCapture: case TRule: case TGrammar:
- /* return fixedlenx(sib1(tree), count); */
+ /* return fixedlen(sib1(tree)); */
tree = sib1(tree); goto tailcall;
- case TCall:
- if (count++ >= MAXRULES)
- return -1; /* may be a loop */
- /* else return fixedlenx(sib2(tree), count); */
- tree = sib2(tree); goto tailcall;
+ case TCall: {
+ int n1 = callrecursive(tree, fixedlen, -1);
+ if (n1 < 0)
+ return -1;
+ else
+ return len + n1;
+ }
case TSeq: {
- len = fixedlenx(sib1(tree), count, len);
- if (len < 0) return -1;
- /* else return fixedlenx(sib2(tree), count, len); */
- tree = sib2(tree); goto tailcall;
+ int n1 = fixedlen(sib1(tree));
+ if (n1 < 0)
+ return -1;
+ /* else return fixedlen(sib2(tree)) + len; */
+ len += n1; tree = sib2(tree); goto tailcall;
}
case TChoice: {
- int n1, n2;
- n1 = fixedlenx(sib1(tree), count, len);
- if (n1 < 0) return -1;
- n2 = fixedlenx(sib2(tree), count, len);
- if (n1 == n2) return n1;
- else return -1;
+ int n1 = fixedlen(sib1(tree));
+ int n2 = fixedlen(sib2(tree));
+ if (n1 != n2 || n1 < 0)
+ return -1;
+ else
+ return len + n1;
}
default: assert(0); return 0;
};
@@ -1312,9 +1347,10 @@ static void codeand (CompileState *compst, TTree *tree, int tt) {
/*
-** Captures: if pattern has fixed (and not too big) length, use
-** a single IFullCapture instruction after the match; otherwise,
-** enclose the pattern with OpenCapture - CloseCapture.
+** Captures: if pattern has fixed (and not too big) length, and it
+** has no nested captures, use a single IFullCapture instruction
+** after the match; otherwise, enclose the pattern with OpenCapture -
+** CloseCapture.
*/
static void codecapture (CompileState *compst, TTree *tree, int tt,
const Charset *fl) {
@@ -1586,8 +1622,6 @@ Instruction *compile (lua_State *L, Pattern *p) {
/* }====================================================== */
-
-
/*
** $Id: lpcap.c,v 1.6 2015/06/15 16:09:57 roberto Exp $
** Copyright 2007, Lua.org & PUC-Rio (see 'lpeg.html' for license)
@@ -2126,7 +2160,7 @@ int getcaptures (lua_State *L, const char *s, const char *r, int ptop) {
/*
-** $Id: lptree.c,v 1.21 2015/09/28 17:01:25 roberto Exp $
+** $Id: lptree.c,v 1.22 2016/09/13 18:10:22 roberto Exp $
** Copyright 2013, Lua.org & PUC-Rio (see 'lpeg.html' for license)
*/
@@ -2191,7 +2225,7 @@ static void fixonecall (lua_State *L, int postable, TTree *g, TTree *t) {
t->tag = TCall;
t->u.ps = n - (t - g); /* position relative to node */
assert(sib2(t)->tag == TRule);
- sib2(t)->key = t->key;
+ sib2(t)->key = t->key; /* fix rule's key */
}
@@ -3062,7 +3096,7 @@ static void buildgrammar (lua_State *L, TTree *grammar, int frule, int n) {
int rulesize;
TTree *rn = gettree(L, ridx, &rulesize);
nd->tag = TRule;
- nd->key = 0;
+ nd->key = 0; /* will be fixed when rule is used */
nd->cap = i; /* rule number */
nd->u.ps = rulesize + 1; /* point to next rule */
memcpy(sib1(nd), rn, rulesize * sizeof(TTree)); /* copy rule */
@@ -3096,6 +3130,11 @@ static int checkloops (TTree *tree) {
}
+/*
+** Give appropriate error message for 'verifyrule'. If a rule appears
+** twice in 'passed', there is path from it back to itself without
+** advancing the subject.
+*/
static int verifyerror (lua_State *L, int *passed, int npassed) {
int i, j;
for (i = npassed - 1; i >= 0; i--) { /* search for a repetition */
@@ -3117,6 +3156,8 @@ static int verifyerror (lua_State *L, int *passed, int npassed) {
** is only relevant if the first is nullable.
** Parameter 'nb' works as an accumulator, to allow tail calls in
** choices. ('nb' true makes function returns true.)
+** Parameter 'passed' is a list of already visited rules, 'npassed'
+** counts the elements in 'passed'.
** Assume ktable at the top of the stack.
*/
static int verifyrule (lua_State *L, TTree *tree, int *passed, int npassed,
@@ -3414,11 +3455,14 @@ int luaopen_lpeg (lua_State *L) {
lua_pushnumber(L, MAXBACK); /* initialize maximum backtracking */
lua_setfield(L, LUA_REGISTRYINDEX, MAXSTACKIDX);
luaL_setfuncs(L, metareg, 0);
+#if defined(LuajitTeX)
+ luaL_register(L,"lpeg",pattreg);
+#else
luaL_newlib(L, pattreg);
+#endif
lua_pushvalue(L, -1);
lua_setfield(L, -3, "__index");
return 1;
}
/* }====================================================== */
-
diff --git a/Build/source/texk/web2c/luatexdir/luapeg/lpeg.h b/Build/source/texk/web2c/luatexdir/luapeg/lpeg.h
index f722b887174..9bc79ff74c6 100644
--- a/Build/source/texk/web2c/luatexdir/luapeg/lpeg.h
+++ b/Build/source/texk/web2c/luatexdir/luapeg/lpeg.h
@@ -1,7 +1,7 @@
/*
-** $Id: lptypes.h,v 1.14 2015/09/28 17:17:41 roberto Exp $
+** $Id: lptypes.h,v 1.16 2017/01/13 13:33:17 roberto Exp $
** LPeg - PEG pattern matching for Lua
-** Copyright 2007-2015, Lua.org & PUC-Rio (see 'lpeg.html' for license)
+** Copyright 2007-2017, Lua.org & PUC-Rio (see 'lpeg.html' for license)
** written by Roberto Ierusalimschy
*/
@@ -13,7 +13,7 @@
#if !defined(lptypes_h)
#define lptypes_h
-
+#define LPEG_DEBUG
#if !defined(LPEG_DEBUG)
#define NDEBUG
#endif
@@ -29,7 +29,7 @@
#include "lua.h"
#include "lauxlib.h"
-#define VERSION "1.0.0"
+#define VERSION "1.0.1"
#define PATTERN_T "lpeg-pattern"
@@ -49,8 +49,9 @@
#define lua_rawlen lua_objlen
#define luaL_setfuncs(L,f,n) luaL_register(L,NULL,f)
+#if !defined(LuajitTeX)
#define luaL_newlib(L,f) luaL_register(L,"lpeg",f)
-
+#endif
#endif
@@ -158,20 +159,33 @@ typedef struct Charset {
#endif
/*
-** $Id: lpcap.h,v 1.2 2015/02/27 17:13:17 roberto Exp $
+** $Id: lpcap.h,v 1.3 2016/09/13 17:45:58 roberto Exp $
*/
#if !defined(lpcap_h)
#define lpcap_h
-/*#include "lptypes.h"*/
+/* #include "lptypes.h" */
/* kinds of captures */
typedef enum CapKind {
- Cclose, Cposition, Cconst, Cbackref, Carg, Csimple, Ctable, Cfunction,
- Cquery, Cstring, Cnum, Csubst, Cfold, Cruntime, Cgroup
+ Cclose, /* not used in trees */
+ Cposition,
+ Cconst, /* ktable[key] is Lua constant */
+ Cbackref, /* ktable[key] is "name" of group to get capture */
+ Carg, /* 'key' is arg's number */
+ Csimple, /* next node is pattern */
+ Ctable, /* next node is pattern */
+ Cfunction, /* ktable[key] is function; next node is pattern */
+ Cquery, /* ktable[key] is table; next node is pattern */
+ Cstring, /* ktable[key] is string; next node is pattern */
+ Cnum, /* numbered capture; 'key' is number of value to return */
+ Csubst, /* substitution capture; next node is pattern */
+ Cfold, /* ktable[key] is function; next node is pattern */
+ Cruntime, /* not used in trees (is uses another type for tree) */
+ Cgroup /* ktable[key] is group's "name" */
} CapKind;
@@ -201,52 +215,57 @@ int finddyncap (Capture *cap, Capture *last);
/*
-** $Id: lptree.h,v 1.2 2013/03/24 13:51:12 roberto Exp $
+** $Id: lptree.h,v 1.3 2016/09/13 18:07:51 roberto Exp $
*/
#if !defined(lptree_h)
#define lptree_h
-/*#include "lptypes.h" */
+/* #include "lptypes.h" */
/*
** types of trees
*/
typedef enum TTag {
- TChar = 0, TSet, TAny, /* standard PEG elements */
- TTrue, TFalse,
- TRep,
- TSeq, TChoice,
- TNot, TAnd,
- TCall,
- TOpenCall,
- TRule, /* sib1 is rule's pattern, sib2 is 'next' rule */
- TGrammar, /* sib1 is initial (and first) rule */
- TBehind, /* match behind */
- TCapture, /* regular capture */
- TRunTime /* run-time capture */
+ TChar = 0, /* 'n' = char */
+ TSet, /* the set is stored in next CHARSETSIZE bytes */
+ TAny,
+ TTrue,
+ TFalse,
+ TRep, /* 'sib1'* */
+ TSeq, /* 'sib1' 'sib2' */
+ TChoice, /* 'sib1' / 'sib2' */
+ TNot, /* !'sib1' */
+ TAnd, /* &'sib1' */
+ TCall, /* ktable[key] is rule's key; 'sib2' is rule being called */
+ TOpenCall, /* ktable[key] is rule's key */
+ TRule, /* ktable[key] is rule's key (but key == 0 for unused rules);
+ 'sib1' is rule's pattern;
+ 'sib2' is next rule; 'cap' is rule's sequential number */
+ TGrammar, /* 'sib1' is initial (and first) rule */
+ TBehind, /* 'sib1' is pattern, 'n' is how much to go back */
+ TCapture, /* captures: 'cap' is kind of capture (enum 'CapKind');
+ ktable[key] is Lua value associated with capture;
+ 'sib1' is capture body */
+ TRunTime /* run-time capture: 'key' is Lua function;
+ 'sib1' is capture body */
} TTag;
-/* number of siblings for each tree */
-extern const byte numsiblings[];
-
/*
** Tree trees
-** The first sibling of a tree (if there is one) is immediately after
-** the tree. A reference to a second sibling (ps) is its position
-** relative to the position of the tree itself. A key in ktable
-** uses the (unique) address of the original tree that created that
-** entry. NULL means no data.
+** The first child of a tree (if there is one) is immediately after
+** the tree. A reference to a second child (ps) is its position
+** relative to the position of the tree itself.
*/
typedef struct TTree {
byte tag;
byte cap; /* kind of capture (if it is a capture) */
unsigned short key; /* key in ktable for Lua data (0 if no key) */
union {
- int ps; /* occasional second sibling */
+ int ps; /* occasional second child */
int n; /* occasional counter */
} u;
} TTree;
@@ -263,10 +282,10 @@ typedef struct Pattern {
} Pattern;
-/* number of siblings for each tree */
+/* number of children for each tree */
extern const byte numsiblings[];
-/* access to siblings */
+/* access to children */
#define sib1(t) ((t) + 1)
#define sib2(t) ((t) + (t)->u.ps)
@@ -277,7 +296,6 @@ extern const byte numsiblings[];
#endif
-
/*
** $Id: lpvm.h,v 1.3 2014/02/21 13:06:41 roberto Exp $
*/
@@ -285,7 +303,7 @@ extern const byte numsiblings[];
#if !defined(lpvm_h)
#define lpvm_h
-/*#include "lpcap.h"*/
+/* #include "lpcap.h" */
/* Virtual Machine's instructions */
@@ -336,10 +354,8 @@ const char *match (lua_State *L, const char *o, const char *s, const char *e,
#endif
-
-
/*
-** $Id: lpcode.h,v 1.7 2015/06/12 18:24:45 roberto Exp $
+** $Id: lpcode.h,v 1.8 2016/09/15 17:46:13 roberto Exp $
*/
#if !defined(lpcode_h)
@@ -347,13 +363,13 @@ const char *match (lua_State *L, const char *o, const char *s, const char *e,
/*#include "lua.h"*/
-/*#include "lptypes.h"*/
-/*#include "lptree.h"*/
-/*#include "lpvm.h"*/
+/* #include "lptypes.h" */
+/* #include "lptree.h" */
+/* #include "lpvm.h" */
int tocharset (TTree *tree, Charset *cs);
int checkaux (TTree *tree, int pred);
-int fixedlenx (TTree *tree, int count, int len);
+int fixedlen (TTree *tree);
int hascaptures (TTree *tree);
int lp_gc (lua_State *L);
Instruction *compile (lua_State *L, Pattern *p);
@@ -375,13 +391,9 @@ int sizei (const Instruction *i);
*/
#define nullable(t) checkaux(t, PEnullable)
-#define fixedlen(t) fixedlenx(t, 0, 0)
-
#endif
-
-
/*
** $Id: lpprint.h,v 1.2 2015/06/12 18:18:08 roberto Exp $
*/
diff --git a/Build/source/texk/web2c/luatexdir/luatex.c b/Build/source/texk/web2c/luatexdir/luatex.c
index 9590dff1bdf..5dc5d64636a 100644
--- a/Build/source/texk/web2c/luatexdir/luatex.c
+++ b/Build/source/texk/web2c/luatexdir/luatex.c
@@ -12,6 +12,7 @@
/* We |#define DLLPROC| in order to build LuaTeX and LuajitTeX as DLL
for W32TeX. */
+
#if defined LuajitTeX
#define DLLPROC dllluajittexmain
#else
@@ -21,20 +22,20 @@
#include "ptexlib.h"
#include "luatex.h"
#include "lua/luatex-api.h"
-/*
-#include "luatex_svnversion.h"
-*/
-
#define TeX
-/* for tl17 update, change luatex_date_info but nothing else,
- as context depends on the numeric version number. */
-int luatex_version = 100; /* \.{\\luatexversion} */
-int luatex_revision = '4'; /* \.{\\luatexrevision} */
-int luatex_date_info = 2017060901; /* the compile date is now hardwired :YEAR MONTH DAY HOUR*/
-const char *luatex_version_string = "1.0.4";
-const char *engine_name = my_name; /* the name of this engine */
+/*
+ The version number can be queried with \.{\\luatexversion} and the revision with
+ with \.{\\luatexrevision}. Traditionally the revision can be any character and
+ pdf\TeX\ occasionally used no digits. Here we still use a character but we will
+ stick to "0" upto "9" so users can expect a number represented as string.
+*/
+
+int luatex_version = 106;
+int luatex_revision = '3';
+const char *luatex_version_string = "1.06.3";
+const char *engine_name = my_name;
#include <kpathsea/c-ctype.h>
#include <kpathsea/line.h>
@@ -583,6 +584,7 @@ main (int ac, string *av)
return EXIT_SUCCESS;
}
+
/*
This is supposed to ``open the terminal for input'', but what we
really do is copy command line arguments into TeX's or Metafont's
diff --git a/Build/source/texk/web2c/luatexdir/luatex_svnversion.h b/Build/source/texk/web2c/luatexdir/luatex_svnversion.h
index bef33fd6cda..3527b8d4049 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 -1
+#define luatex_svn_revision 6501
diff --git a/Build/source/texk/web2c/luatexdir/luatexcallbackids.h b/Build/source/texk/web2c/luatexdir/luatexcallbackids.h
index 927c4f1b2f1..32df36a4a1a 100644
--- a/Build/source/texk/web2c/luatexdir/luatexcallbackids.h
+++ b/Build/source/texk/web2c/luatexdir/luatexcallbackids.h
@@ -47,7 +47,7 @@ typedef enum {
pre_output_filter_callback,
buildpage_filter_callback,
hpack_filter_callback, vpack_filter_callback,
- char_exists_callback,
+ glyph_not_found_callback,
hyphenate_callback,
ligaturing_callback,
kerning_callback,
@@ -69,6 +69,7 @@ typedef enum {
call_edit_callback,
build_page_insert_callback,
glyph_stream_provider_callback,
+ finish_synctex_callback,
total_callbacks
} callback_callback_types;
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdffont.w b/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
index b3f1605154c..278efa9d6fa 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
@@ -41,7 +41,8 @@ scaled_whd output_one_char(PDF pdf, halfword p)
int ex_glyph = ex_glyph(p)/1000;
scaled_whd ci = get_charinfo_whd(f, c); /* the real width, height and depth of the character */
if (!(char_exists(f,c))) {
- char_warning(f,c);
+ lua_glyph_not_found_callback(f,c);
+ /* char_warning(f,c); */
return ci;
}
ci.wd = ext_xn_over_d(ci.wd, 1000000 + ex_glyph(p), 1000000);
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h
index f2086663c70..01b0e74cd1e 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h
@@ -81,7 +81,7 @@ extern int ten_pow[10];
extern void pdf_flush(PDF);
extern void pdf_room(PDF, int);
-extern void fix_pdf_minorversion(PDF);
+extern void fix_pdf_version(PDF);
/* output a byte to PDF buffer without checking of overflow */
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w
index 023f7fd65a3..26b7112ed09 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w
@@ -190,6 +190,7 @@ PDF init_pdf_struct(PDF pdf)
memset(pdf->obj_tab, 0, sizeof(obj_entry));
pdf->minor_version = -1;
+ pdf->major_version = -1;
pdf->decimal_digits = 4;
pdf->gamma = 65536;
pdf->image_gamma = 65536;
@@ -262,35 +263,43 @@ void fix_o_mode(void)
}
}
-@ This ensures that |pdfminorversion| is set only before any bytes have been
-written to the generated \.{PDF} file. Here also all variables for \.{PDF} output
-are initialized, the \.{PDF} file is opened by |ensure_pdf_open|, and the \.{PDF}
-header is written.
+@ This ensures that |pdfmajorversion| and |pdfminorversion| are set only before any
+bytes have been written to the generated \.{PDF} file. Here also all variables for
+\.{PDF} output are initialized, the \.{PDF} file is opened by |ensure_pdf_open|, and
+the \.{PDF} header is written.
@c
-void fix_pdf_minorversion(PDF pdf)
-{
- if (pdf->minor_version < 0) { /* unset */
+void fix_pdf_version(PDF pdf)
+{
+ if (pdf->major_version < 0) { /* unset */
+ if (pdf_major_version == 0) {
+ normal_warning("pdf backend","unset major version, using 1 instead");
+ pdf->major_version = 1;
+ } else if ((pdf_major_version < 0) || (pdf_major_version > 2)) {
+ formatted_warning("pdf backend","illegal major version %d, using 1 instead",pdf_major_version);
+ pdf->major_version = 1;
+ } else {
+ pdf->major_version = pdf_major_version;
+ }
+ } else if (pdf->major_version != pdf_major_version) {
+ normal_warning("pdf backend", "the major version cannot be changed after data is written to the PDF file");
+ }
+ if (pdf->minor_version < 0) { /* unset */
if ((pdf_minor_version < 0) || (pdf_minor_version > 9)) {
- const char *hlp[] = { "The pdfminorversion must be between 0 and 9.", "I changed this to 4.", NULL };
- char msg[256];
- (void) snprintf(msg, 255, "LuaTeX error (illegal pdfminorversion %d)", (int) pdf_minor_version);
- tex_error(msg, hlp);
+ formatted_warning("pdf backend","illegal minor version %d, using 4 instead",pdf_minor_version);
pdf->minor_version = 4;
} else {
pdf->minor_version = pdf_minor_version;
}
- } else {
- /* Check that variables for \.{PDF} output are unchanged */
- if (pdf->minor_version != pdf_minor_version)
- normal_error("pdf backend", "minorversion cannot be changed after data is written to the PDF file");
+ } else if (pdf->minor_version != pdf_minor_version) {
+ normal_warning("pdf backend", "minorversion cannot be changed after data is written to the PDF file");
}
}
static void fix_pdf_draftmode(PDF pdf)
{
if (pdf->draftmode != draft_mode_par)
- normal_error("pdf backend", "draftmode cannot be changed after data is written to the PDF file");
+ normal_warning("pdf backend", "draftmode cannot be changed after data is written to the PDF file");
if (pdf->draftmode != 0) {
pdf->compress_level = 0; /* re-fix it, might have been changed inbetween */
pdf->objcompresslevel = 0;
@@ -1027,11 +1036,11 @@ static void ensure_output_file_open(PDF pdf, const char *ext)
static void ensure_pdf_header_written(PDF pdf)
{
/* Initialize variables for \.{PDF} output */
- fix_pdf_minorversion(pdf);
+ fix_pdf_version(pdf);
init_pdf_outputparameters(pdf);
fix_pdf_draftmode(pdf);
/* Write \.{PDF} header */
- pdf_printf(pdf, "%%PDF-1.%d\n", pdf->minor_version);
+ pdf_printf(pdf, "%%PDF-%d.%d\n", pdf->major_version, pdf->minor_version);
/* The next blob will be removed 1.0. */
pdf_out(pdf, '%');
pdf_out(pdf, 'P' + 128);
@@ -1732,6 +1741,7 @@ void pdf_begin_page(PDF pdf)
pdf_dict_add_int(pdf, "FormType", 1);
}
xform_attributes = pdf_xform_attr; /* lookup once */
+ form_margin = obj_xform_margin(pdf, pdf_cur_form); /* now stored in object */
if (xform_attributes != null)
pdf_print_toks(pdf, xform_attributes);
if (obj_xform_attr(pdf, pdf_cur_form) != null) {
@@ -2062,19 +2072,21 @@ void pdf_end_page(PDF pdf)
pdf_end_dict(pdf);
}
/* Generate ProcSet */
- pdf_add_name(pdf, "ProcSet");
- pdf_begin_array(pdf);
- if ((procset & PROCSET_PDF) != 0)
- pdf_add_name(pdf, "PDF");
- if ((procset & PROCSET_TEXT) != 0)
- pdf_add_name(pdf, "Text");
- if ((procset & PROCSET_IMAGE_B) != 0)
- pdf_add_name(pdf, "ImageB");
- if ((procset & PROCSET_IMAGE_C) != 0)
- pdf_add_name(pdf, "ImageC");
- if ((procset & PROCSET_IMAGE_I) != 0)
- pdf_add_name(pdf, "ImageI");
- pdf_end_array(pdf);
+ if (pdf->major_version == 1) {
+ pdf_add_name(pdf, "ProcSet");
+ pdf_begin_array(pdf);
+ if ((procset & PROCSET_PDF) != 0)
+ pdf_add_name(pdf, "PDF");
+ if ((procset & PROCSET_TEXT) != 0)
+ pdf_add_name(pdf, "Text");
+ if ((procset & PROCSET_IMAGE_B) != 0)
+ pdf_add_name(pdf, "ImageB");
+ if ((procset & PROCSET_IMAGE_C) != 0)
+ pdf_add_name(pdf, "ImageC");
+ if ((procset & PROCSET_IMAGE_I) != 0)
+ pdf_add_name(pdf, "ImageI");
+ pdf_end_array(pdf);
+ }
pdf_end_dict(pdf);
pdf_end_obj(pdf);
}
@@ -2182,11 +2194,7 @@ static int pdf_print_info(PDF pdf, int luatexversion,
if ((pdf_suppress_optional_info & 128) == 0 && !producer_given) {
pdf_add_name(pdf, "Producer");
pdf_puts(pdf, " (LuaTeX-");
- pdf_print_int(pdf, luatexversion / 100);
- pdf_out(pdf, '.');
- pdf_print_int(pdf, luatexversion % 100);
- pdf_out(pdf, '.');
- pdf_print(pdf, luatexrevision);
+ pdf_puts(pdf, luatex_version_string);
pdf_out(pdf, ')');
}
if ((pdf_suppress_optional_info & 16) == 0 && !creator_given) {
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w b/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w
index 06755a54bdf..0703beed22c 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfglyph.w
@@ -197,8 +197,11 @@ void pdf_place_glyph(PDF pdf, internal_font_number f, int c, int ex)
boolean move;
pdfstructure *p = pdf->pstruct;
scaledpos pos = pdf->posstruct->pos;
- if (!char_exists(f, c))
- return;
+ /* already done:
+ if (!char_exists(f, c)) {
+ return;
+ }
+ */
if (font_writingmode(f) == vertical_writingmode) {
if (p->wmode != WMODE_V) {
p->wmode = WMODE_V;
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w b/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w
index 64a36dc67bf..35687bf7401 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfliteral.w
@@ -103,13 +103,14 @@ void pdf_literal(PDF pdf, str_number s, int literal_mode, boolean warn)
if (s >= STRING_OFFSET) {
/* needed for |out_save| */
j = 0;
- /* the next is obsolete, in fact, specials are obsolete in pdf mode */
+ /* unfortunately we always go through this when we have vf specials (and also via temp strings) */
if (literal_mode == scan_special) {
if (!(str_in_cstr(s, "PDF:", 0) || str_in_cstr(s, "pdf:", 0))) {
if (warn && ((!(str_in_cstr(s, "SRC:", 0) || str_in_cstr(s, "src:", 0))) || (str_length(s) == 0)))
tprint_nl("Non-PDF special ignored!");
return;
}
+ /*
j = j + (pool_pointer) strlen("PDF:");
if (str_in_cstr(s, "direct:", strlen("PDF:"))) {
j = j + (pool_pointer) strlen("direct:");
@@ -120,6 +121,26 @@ void pdf_literal(PDF pdf, str_number s, int literal_mode, boolean warn)
} else if (str_in_cstr(s, "raw:", strlen("PDF:"))) {
j = j + (pool_pointer) strlen("raw:");
literal_mode = direct_raw;
+ } else if (str_in_cstr(s, "origin:", strlen("PDF:"))) {
+ j = j + (pool_pointer) strlen("origin:");
+ literal_mode = set_origin;
+ } else {
+ literal_mode = set_origin;
+ }
+ */
+ j = j + (pool_pointer) 4; /* strlen("PDF:") */
+ if (str_in_cstr(s, "direct:", 4)) { /* strlen("PDF:") */
+ j = j + (pool_pointer) 7; /* strlen("direct:") */
+ literal_mode = direct_always;
+ } else if (str_in_cstr(s, "page:", 4)) { /* strlen("PDF:") */
+ j = j + (pool_pointer) 5; /* strlen("page:") */
+ literal_mode = direct_page;
+ } else if (str_in_cstr(s, "raw:", 4)) { /* strlen("PDF:") */
+ j = j + (pool_pointer) 4; /* strlen("raw:") */
+ literal_mode = direct_raw;
+ } else if (str_in_cstr(s, "origin:", 4)) { /* strlen("PDF:") */
+ j = j + (pool_pointer) 7; /* strlen("origin:") */
+ literal_mode = set_origin;
} else {
literal_mode = set_origin;
}
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftables.h b/Build/source/texk/web2c/luatexdir/pdf/pdftables.h
index 9a14d65da45..cfaab5df046 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdftables.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdftables.h
@@ -123,6 +123,7 @@ typedef enum {
c_pdf_image_resolution,
c_pdf_pk_resolution,
c_pdf_unique_resname,
+ c_pdf_major_version,
c_pdf_minor_version,
c_pdf_pagebox,
c_pdf_inclusion_errorlevel,
@@ -170,6 +171,7 @@ extern int pdf_retval;
# define pdf_image_resolution get_tex_extension_count_register(c_pdf_image_resolution)
# define pdf_pk_resolution get_tex_extension_count_register(c_pdf_pk_resolution)
# define pdf_unique_resname get_tex_extension_count_register(c_pdf_unique_resname)
+# define pdf_major_version get_tex_extension_count_register(c_pdf_major_version)
# define pdf_minor_version get_tex_extension_count_register(c_pdf_minor_version)
# define pdf_pagebox get_tex_extension_count_register(c_pdf_pagebox)
# define pdf_inclusion_errorlevel get_tex_extension_count_register(c_pdf_inclusion_errorlevel)
@@ -200,6 +202,7 @@ extern int pdf_retval;
# define pdf_pk_mode get_tex_extension_toks_register(t_pdf_pk_mode)
# define pdf_trailer_id get_tex_extension_toks_register(t_pdf_trailer_id)
+# define set_pdf_major_version(i) set_tex_extension_count_register(c_pdf_major_version,i)
# define set_pdf_minor_version(i) set_tex_extension_count_register(c_pdf_minor_version,i)
# define set_pdf_compress_level(i) set_tex_extension_count_register(c_pdf_compress_level,i)
# define set_pdf_obj_compress_level(i) set_tex_extension_count_register(c_pdf_obj_compress_level,i)
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h b/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h
index 34153600d97..c5f0393cc20 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h
@@ -293,6 +293,7 @@ typedef struct pdf_output_file_ {
int gen_tounicode;
int omit_cidset;
int inclusion_copy_font;
+ int major_version; /* fixed major part of the PDF version */
int minor_version; /* fixed minor part of the PDF version */
int compress_level; /* level for zlib object stream compression */
int objcompresslevel; /* fixed level for activating PDF object streams */
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.h b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.h
index 64525d837ea..2d6441ff496 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.h
@@ -22,7 +22,7 @@
#ifndef PDFXFORM_H
# define PDFXFORM_H
-# define pdfmem_xform_size 9 /* size of memory in |pdf->mem| which |obj_data_ptr| holds */
+# define pdfmem_xform_size 10 /* size of memory in |pdf->mem| which |obj_data_ptr| holds */
# define obj_xform_width(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 0]
# define obj_xform_height(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 1]
@@ -33,6 +33,7 @@
# define obj_xform_attr_str(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 6]
# define obj_xform_resources_str(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 7]
# define obj_xform_type(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 8]
+# define obj_xform_margin(pdf,A) pdf->mem[obj_data_ptr(pdf,A) + 9]
# define set_pdf_xform_objnum(A,B) pdf_xform_objnum(A)=B
# define set_obj_xform_width(pdf,A,B) obj_xform_width(pdf,A)=B
@@ -44,6 +45,7 @@
# define set_obj_xform_attr_str(pdf,A,B) obj_xform_attr_str(pdf,A)=B
# define set_obj_xform_resources_str(pdf,A,B) obj_xform_resources_str(pdf,A)=B
# define set_obj_xform_type(pdf,A,B) obj_xform_type(pdf,A)=B
+# define set_obj_xform_margin(pdf,A,B) obj_xform_margin(pdf,A)=B
extern int pdf_cur_form; /* the form being output */
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w
index 4c83b024939..731dc229080 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfxform.w
@@ -89,6 +89,12 @@ void scan_pdfxform(PDF pdf)
} else {
set_obj_xform_resources(pdf, k, null);
}
+ if (scan_keyword("margin")) {
+ scan_int();
+ set_obj_xform_margin(pdf, k, cur_val);
+ } else {
+ set_obj_xform_margin(pdf, k, pdf_xform_margin);
+ }
set_obj_xform_resources_str(pdf, k, null);
scan_int();
p = box(cur_val);
diff --git a/Build/source/texk/web2c/luatexdir/tex/commands.h b/Build/source/texk/web2c/luatexdir/tex/commands.h
index fc61ffd46c8..8eabaa4e7cc 100644
--- a/Build/source/texk/web2c/luatexdir/tex/commands.h
+++ b/Build/source/texk/web2c/luatexdir/tex/commands.h
@@ -142,6 +142,7 @@ typedef enum {
boundary_cmd, /* insert boundry node with value ( \.{\\*boundary} ) */
radical_cmd, /* square root and similar signs ( \.{\\radical} ) */
super_sub_script_cmd, /* explicit super- or subscript */
+ no_super_sub_script_cmd, /* explicit no super- or subscript */
math_shift_cs_cmd, /* start- and endmath */
end_cs_name_cmd, /* end control sequence ( \.{\\endcsname} ) */
char_ghost_cmd, /* \.{\\leftghost}, \.{\\rightghost} character for kerning */
@@ -259,7 +260,6 @@ typedef enum {
format_name_code, /* command code for \.{\\AlephVersion} */
luatex_banner_code, /* command code for \.{\\luatexbanner}: */
luatex_revision_code, /* command code for \.{\\luatexrevision} */
- luatex_date_code, /* command code for \.{\\luatexdate} */
etex_code, /* command code for \.{\\eTeXVersion} */
eTeX_revision_code, /* command code for \.{\\eTeXrevision} */
font_identifier_code, /* command code for \.{tex.fontidentifier} (virtual) */
diff --git a/Build/source/texk/web2c/luatexdir/tex/commands.w b/Build/source/texk/web2c/luatexdir/tex/commands.w
index 84235914c64..0a34b750116 100644
--- a/Build/source/texk/web2c/luatexdir/tex/commands.w
+++ b/Build/source/texk/web2c/luatexdir/tex/commands.w
@@ -1,4 +1,4 @@
-% commands.w
+f% commands.w
%
% Copyright 2009-2010 Taco Hoekwater <taco@@luatex.org>
%
@@ -52,6 +52,7 @@ void initialize_commands(void)
primitive_tex("thickmuskip", assign_mu_glue_cmd, glue_base + thick_mu_skip_code, glue_base + thin_mu_skip_code);
primitive_luatex("mathsurroundskip", assign_glue_cmd, glue_base + math_skip_code, glue_base);
primitive_luatex("mathsurroundmode", assign_int_cmd, int_base + math_skip_mode_code, int_base);
+ primitive_luatex("mathscriptboxmode", assign_int_cmd, int_base + math_script_box_mode_code, int_base);
primitive_tex("output", assign_toks_cmd, output_routine_loc, local_base);
primitive_tex("everypar", assign_toks_cmd, every_par_loc, local_base);
primitive_tex("everymath", assign_toks_cmd, every_math_loc, local_base);
@@ -74,9 +75,13 @@ void initialize_commands(void)
primitive_tex("displaywidowpenalty", assign_int_cmd, int_base + display_widow_penalty_code, int_base);
primitive_tex("brokenpenalty", assign_int_cmd, int_base + broken_penalty_code, int_base);
primitive_tex("binoppenalty", assign_int_cmd, int_base + bin_op_penalty_code, int_base);
+ primitive_luatex("prerelpenalty", assign_int_cmd, int_base + pre_rel_penalty_code, int_base);
+ primitive_luatex("prebinoppenalty", assign_int_cmd, int_base + pre_bin_op_penalty_code, int_base);
primitive_tex("relpenalty", assign_int_cmd, int_base + rel_penalty_code, int_base);
primitive_tex("predisplaypenalty", assign_int_cmd, int_base + pre_display_penalty_code, int_base);
primitive_tex("postdisplaypenalty", assign_int_cmd, int_base + post_display_penalty_code, int_base);
+ primitive_luatex("mathpenaltiesmode", assign_int_cmd, int_base + math_penalties_mode_code, int_base);
+ primitive_luatex("mathdelimitersmode", assign_int_cmd, int_base + math_delimiters_mode_code, int_base);
primitive_tex("interlinepenalty", assign_int_cmd, int_base + inter_line_penalty_code, int_base);
primitive_tex("doublehyphendemerits", assign_int_cmd, int_base + double_hyphen_demerits_code, int_base);
primitive_tex("finalhyphendemerits", assign_int_cmd, int_base + final_hyphen_demerits_code, int_base);
@@ -160,6 +165,8 @@ void initialize_commands(void)
primitive_luatex("hyphenpenaltymode", assign_int_cmd, int_base + hyphen_penalty_mode_code, int_base);
primitive_luatex("automatichyphenpenalty", assign_int_cmd, int_base + automatic_hyphen_penalty_code, int_base);
primitive_luatex("explicithyphenpenalty", assign_int_cmd, int_base + explicit_hyphen_penalty_code, int_base);
+ primitive_luatex("automatichyphenmode", assign_int_cmd, int_base + automatic_hyphen_mode_code, int_base);
+ primitive_luatex("breakafterdirmode", assign_int_cmd, int_base + break_after_dir_mode_code, int_base);
/* Many of \TeX's primitives need no |equiv|, since they are identifiable
by their |eq_type| alone. These primitives are loaded into the hash table
@@ -317,7 +324,6 @@ void initialize_commands(void)
primitive_tex("fontname", convert_cmd, font_name_code, 0);
primitive_luatex("fontid", convert_cmd, font_id_code, 0);
primitive_luatex("luatexrevision", convert_cmd, luatex_revision_code, 0);
- primitive_luatex("luatexdatestamp", convert_cmd, luatex_date_code, 0);
primitive_luatex("luatexbanner", convert_cmd, luatex_banner_code, 0);
primitive_luatex("leftmarginkern", convert_cmd, left_margin_kern_code, 0);
primitive_luatex("rightmarginkern", convert_cmd, right_margin_kern_code, 0);
@@ -445,8 +451,10 @@ void initialize_commands(void)
primitive_tex("unhcopy", un_hbox_cmd, copy_code, 0);
primitive_tex("unvbox", un_vbox_cmd, box_code, 0);
primitive_tex("unvcopy", un_vbox_cmd, copy_code, 0);
- primitive_tex("-", discretionary_cmd, explicit_disc, 0);
+ primitive_tex("-", discretionary_cmd, explicit_disc, 0); /* good old tex */
primitive_tex("discretionary", discretionary_cmd, discretionary_disc, 0);
+ primitive_luatex("explicitdiscretionary", discretionary_cmd, explicit_disc, 0);
+ primitive_luatex("automaticdiscretionary", discretionary_cmd, automatic_disc, 0);
primitive_luatex("localleftbox", assign_local_box_cmd, 0, 0);
primitive_luatex("localrightbox", assign_local_box_cmd, 1, 0);
@@ -479,6 +487,8 @@ void initialize_commands(void)
primitive_luatex("crampedscriptscriptstyle", math_style_cmd, cramped_script_script_style, 0);
primitive_luatex("Usuperscript", super_sub_script_cmd, sup_mark_cmd, sup_mark_cmd);
primitive_luatex("Usubscript", super_sub_script_cmd, sub_mark_cmd, sup_mark_cmd);
+ primitive_luatex("Unosuperscript", no_super_sub_script_cmd, sup_mark_cmd, sup_mark_cmd);
+ primitive_luatex("Unosubscript", no_super_sub_script_cmd, sub_mark_cmd, sup_mark_cmd);
primitive_tex("above", above_cmd, above_code, 0);
primitive_tex("over", above_cmd, over_code, 0);
primitive_tex("atop", above_cmd, atop_code, 0);
@@ -752,6 +762,7 @@ void initialize_etex_commands(void)
primitive_etex("savinghyphcodes", assign_int_cmd, int_base + saving_hyph_codes_code, int_base);
primitive_luatex("suppressfontnotfounderror", assign_int_cmd, int_base + suppress_fontnotfound_error_code, int_base);
primitive_luatex("suppresslongerror", assign_int_cmd, int_base + suppress_long_error_code, int_base);
+ primitive_luatex("suppressprimitiveerror", assign_int_cmd, int_base + suppress_primitive_error_code, int_base);
primitive_luatex("suppressmathparerror", assign_int_cmd, int_base + suppress_mathpar_error_code, int_base);
primitive_luatex("suppressifcsnameerror", assign_int_cmd, int_base + suppress_ifcsname_error_code, int_base);
primitive_luatex("suppressoutererror", assign_int_cmd, int_base + suppress_outer_error_code, int_base);
diff --git a/Build/source/texk/web2c/luatexdir/tex/conditional.w b/Build/source/texk/web2c/luatexdir/tex/conditional.w
index 268786add75..318775141a8 100644
--- a/Build/source/texk/web2c/luatexdir/tex/conditional.w
+++ b/Build/source/texk/web2c/luatexdir/tex/conditional.w
@@ -152,6 +152,7 @@ static boolean test_for_cs(void)
halfword q; /*for traversing token lists in \.{\\ifx} tests */
halfword n = get_avail();
halfword p = n; /*head of the list of characters */
+is_in_csname += 1;
while (1) {
get_x_token();
if (cur_cs != 0)
@@ -165,6 +166,7 @@ static boolean test_for_cs(void)
get_x_token();
} while (cur_cmd != end_cs_name_cmd);
flush_list(n);
+is_in_csname -= 1;
return b;
} else {
complain_missing_csname();
@@ -205,6 +207,7 @@ static boolean test_for_cs(void)
b = (eq_type(cur_cs) != undefined_cs_cmd);
flush_list(n);
last_cs_name = cur_cs;
+is_in_csname -= 1;
return b;
}
diff --git a/Build/source/texk/web2c/luatexdir/tex/dumpdata.w b/Build/source/texk/web2c/luatexdir/tex/dumpdata.w
index aa0d1655d6d..9d06f1c8ed4 100644
--- a/Build/source/texk/web2c/luatexdir/tex/dumpdata.w
+++ b/Build/source/texk/web2c/luatexdir/tex/dumpdata.w
@@ -23,7 +23,7 @@
/* we start with 907: the sum of the values of the bytes of "don knuth" */
-#define FORMAT_ID (907+28)
+#define FORMAT_ID (907+37)
#if ((FORMAT_ID>=0) && (FORMAT_ID<=256))
#error Wrong value for FORMAT_ID.
#endif
diff --git a/Build/source/texk/web2c/luatexdir/tex/equivalents.h b/Build/source/texk/web2c/luatexdir/tex/equivalents.h
index d7ca036e25a..f478b4a41b2 100644
--- a/Build/source/texk/web2c/luatexdir/tex/equivalents.h
+++ b/Build/source/texk/web2c/luatexdir/tex/equivalents.h
@@ -291,8 +291,18 @@ the |number_regs| \.{\\dimen} registers.
# define hyphen_penalty_mode_code 100
# define automatic_hyphen_penalty_code 101
# define explicit_hyphen_penalty_code 102
+# define automatic_hyphen_mode_code 103
+# define break_after_dir_mode_code 104
-# define math_option_code (explicit_hyphen_penalty_code+1)
+# define pre_bin_op_penalty_code 105
+# define pre_rel_penalty_code 106
+# define math_penalties_mode_code 107
+# define math_delimiters_mode_code 108
+# define math_script_box_mode_code 109
+
+# define suppress_primitive_error_code 110
+
+# define math_option_code (suppress_primitive_error_code+1)
# define mathoption_int_base_code (math_option_code+1) /* one reserve */
# define mathoption_int_last_code (mathoption_int_base_code+8)
@@ -648,6 +658,11 @@ extern halfword last_cs_name;
#define delimiter_factor_par int_par(delimiter_factor_code)
#define bin_op_penalty_par int_par(bin_op_penalty_code)
#define rel_penalty_par int_par(rel_penalty_code)
+#define pre_bin_op_penalty_par int_par(pre_bin_op_penalty_code)
+#define pre_rel_penalty_par int_par(pre_rel_penalty_code)
+#define math_penalties_mode_par int_par(math_penalties_mode_code)
+#define math_delimiters_mode_par int_par(math_delimiters_mode_code)
+#define math_script_box_mode_par int_par(math_script_box_mode_code)
#define null_delimiter_space_par dimen_par(null_delimiter_space_code)
#define disable_lig_par int_par(disable_lig_code)
#define disable_kern_par int_par(disable_kern_code)
@@ -740,6 +755,7 @@ extern halfword last_cs_name;
#define suppress_mathpar_error_par int_par(suppress_mathpar_error_code)
#define suppress_fontnotfound_error_par int_par(suppress_fontnotfound_error_code)
#define suppress_ifcsname_error_par int_par(suppress_ifcsname_error_code)
+#define suppress_primitive_error_par int_par(suppress_primitive_error_code)
#define error_context_lines_par int_par(error_context_lines_code)
#define math_old_par mathoption_int_par(c_mathoption_old_code)
@@ -773,6 +789,8 @@ extern halfword last_cs_name;
#define hyphen_penalty_mode_par int_par(hyphen_penalty_mode_code)
#define automatic_hyphen_penalty_par int_par(automatic_hyphen_penalty_code)
#define explicit_hyphen_penalty_par int_par(explicit_hyphen_penalty_code)
+#define automatic_hyphen_mode_par int_par(automatic_hyphen_mode_code)
+#define break_after_dir_mode_par int_par(break_after_dir_mode_code)
#define cur_lang_par int_par(cur_lang_code)
#define cur_font_par equiv(cur_font_loc)
diff --git a/Build/source/texk/web2c/luatexdir/tex/errors.h b/Build/source/texk/web2c/luatexdir/tex/errors.h
index 3eae1c8a927..39fdf6b46e2 100644
--- a/Build/source/texk/web2c/luatexdir/tex/errors.h
+++ b/Build/source/texk/web2c/luatexdir/tex/errors.h
@@ -37,6 +37,8 @@ typedef enum {
extern int interaction; /* current level of interaction */
extern int interactionoption; /* set from command line */
+extern int defaultexitcode; /* the exit code can be overloaded */
+
extern void initialize_errors(void);
extern char *last_error;
diff --git a/Build/source/texk/web2c/luatexdir/tex/errors.w b/Build/source/texk/web2c/luatexdir/tex/errors.w
index cec9a144f1c..93dbe141b91 100644
--- a/Build/source/texk/web2c/luatexdir/tex/errors.w
+++ b/Build/source/texk/web2c/luatexdir/tex/errors.w
@@ -215,6 +215,8 @@ boolean use_err_help; /* should the |err_help| list be shown? */
exits the program. It is used when there is no recovery from a particular error.
@c
+int defaultexitcode = 0; /* the exit code can be overloaded */
+
__attribute__ ((noreturn))
void do_final_end(void)
{
@@ -224,7 +226,7 @@ void do_final_end(void)
if ((history != spotless) && (history != warning_issued))
uexit(1);
else
- uexit(0);
+ uexit(defaultexitcode);
}
__attribute__ ((noreturn))
diff --git a/Build/source/texk/web2c/luatexdir/tex/expand.w b/Build/source/texk/web2c/luatexdir/tex/expand.w
index 731345eb66e..c912863b2a1 100644
--- a/Build/source/texk/web2c/luatexdir/tex/expand.w
+++ b/Build/source/texk/web2c/luatexdir/tex/expand.w
@@ -209,7 +209,7 @@ void expand(void)
iloc = p;
istart = p;
}
- } else {
+ } else if (suppress_primitive_error_par == 0) {
print_err("Missing primitive name");
help2
("The control sequence marked <to be read again> does not",
diff --git a/Build/source/texk/web2c/luatexdir/tex/linebreak.w b/Build/source/texk/web2c/luatexdir/tex/linebreak.w
index 48705ad8cad..345a1a42456 100644
--- a/Build/source/texk/web2c/luatexdir/tex/linebreak.w
+++ b/Build/source/texk/web2c/luatexdir/tex/linebreak.w
@@ -755,6 +755,14 @@ Replacement texts and discretionary texts are supposed to contain
only character nodes, kern nodes, and box or rule nodes.
@c
+#define bad_node_in_disc_error(p) { \
+ if (type(p) == whatsit_node) { \
+ formatted_error("linebreak","invalid node with type %s and subtype %i found in discretionary",node_data[type(p)].name,subtype(p)); \
+ } else { \
+ formatted_error("linebreak","invalid node with type %s found in discretionary",node_data[type(p)].name); \
+ } \
+}
+
static void add_to_widths(halfword s, int line_break_dir, int adjust_spacing, scaled * widths)
{
while (s != null) {
@@ -783,7 +791,8 @@ static void add_to_widths(halfword s, int line_break_dir, int adjust_spacing, sc
case disc_node: /* TH temp */
break;
default:
- confusion("invalid node found in discretionary"); /* todo: report type */
+ bad_node_in_disc_error(s);
+ break;
}
}
s = vlink(s);
@@ -825,7 +834,7 @@ static void sub_from_widths(halfword s, int line_break_dir, int adjust_spacing,
case disc_node: /* TH temp */
break;
default:
- confusion("invalid node found in discretionary"); /* todo: report type */
+ bad_node_in_disc_error(s);
break;
}
}
@@ -1857,20 +1866,16 @@ void ext_do_line_break(int paragraph_dir,
to see whether or not a breakpoint is legal at |cur_p|,
as explained above.
- The |precedes_break| test also considers dir nodes and prohibits
- a break after an opening dir_node (positive dir). In |\textdir TRT x|
- the space after |TRT| is preserved and therefore the dir node
- is bound to the |x|. Being more clever makes no sense: users
- should code their input properly.
+ We only break after certain nodes (see texnodes.h), a font related
+ kern and a dir node when |\breakafterdirmode=1|.
*/
if (auto_breaking) {
halfword prev_p = alink(cur_p);
if (prev_p != temp_head && (
is_char_node(prev_p)
|| precedes_break(prev_p)
- || ( (type(prev_p) == kern_node) && (
- subtype(prev_p) == font_kern || subtype(prev_p) == accent_kern)
- )
+ || precedes_kern(prev_p)
+ || precedes_dir(prev_p)
)) {
ext_try_break(0, unhyphenated_node, line_break_dir, adjust_spacing,
par_shape_ptr, adj_demerits,
diff --git a/Build/source/texk/web2c/luatexdir/tex/mainbody.h b/Build/source/texk/web2c/luatexdir/tex/mainbody.h
index 158893631d7..4a5cb93a164 100644
--- a/Build/source/texk/web2c/luatexdir/tex/mainbody.h
+++ b/Build/source/texk/web2c/luatexdir/tex/mainbody.h
@@ -23,7 +23,6 @@
extern int luatex_version;
extern int luatex_revision;
-extern int luatex_date_info;
extern const char *luatex_version_string;
extern const char *engine_name;
@@ -218,7 +217,6 @@ is conditionally compiled in the C code.
extern int get_luatexversion(void);
extern str_number get_luatexrevision(void);
-extern int get_luatex_date_info(void);
extern int ready_already;
diff --git a/Build/source/texk/web2c/luatexdir/tex/mainbody.w b/Build/source/texk/web2c/luatexdir/tex/mainbody.w
index faa6e1992da..4d38b9d4a47 100644
--- a/Build/source/texk/web2c/luatexdir/tex/mainbody.w
+++ b/Build/source/texk/web2c/luatexdir/tex/mainbody.w
@@ -230,12 +230,6 @@ str_number get_luatexrevision(void)
return luatex_revision;
}
-int get_luatex_date_info(void)
-{
- return luatex_date_info; /* todo, silly value */
-}
-
-
@ This is it: the part of \TeX\ that executes all those procedures we have
written.
@@ -524,7 +518,18 @@ void close_files_and_terminate(void)
/* rubish, these pdf arguments, passed, needs to be fixed, e.g. with a dummy in dvi */
wrapup_backend();
/* Close {\sl Sync\TeX} file and write status */
- synctexterminate(log_opened_global); /* Let the {\sl Sync\TeX} controller close its files. */
+ synctexterminate(log_opened_global);
+ /*
+ The following is needed because synctex removes files and we want to keep them which
+ means renaming a temp file .. we can't bypass the terminate because it might do mem
+ cleanup.
+ */
+ if (synctex_get_mode() > 0) {
+ callback_id = callback_defined(finish_synctex_callback);
+ if (callback_id > 0) {
+ run_callback(callback_id, "->");
+ }
+ }
free_text_codes();
free_math_codes();
if (log_opened_global) {
diff --git a/Build/source/texk/web2c/luatexdir/tex/maincontrol.w b/Build/source/texk/web2c/luatexdir/tex/maincontrol.w
index 0baba872e8e..7b4cf9065ca 100644
--- a/Build/source/texk/web2c/luatexdir/tex/maincontrol.w
+++ b/Build/source/texk/web2c/luatexdir/tex/maincontrol.w
@@ -705,6 +705,7 @@ static void init_main_control (void) {
non_math(sup_mark_cmd, insert_dollar_sign);
non_math(sub_mark_cmd, insert_dollar_sign);
non_math(super_sub_script_cmd, insert_dollar_sign);
+ non_math(no_super_sub_script_cmd, insert_dollar_sign);
non_math(math_comp_cmd, insert_dollar_sign);
non_math(delim_num_cmd, insert_dollar_sign);
non_math(left_right_cmd, insert_dollar_sign);
@@ -825,6 +826,7 @@ static void init_main_control (void) {
jump_table[mmode + sub_mark_cmd] = sub_sup;
jump_table[mmode + sup_mark_cmd] = sub_sup;
jump_table[mmode + super_sub_script_cmd] = sub_sup;
+ jump_table[mmode + no_super_sub_script_cmd] = no_sub_sup;
jump_table[mmode + left_right_cmd] = math_left_right;
jump_table[mmode + math_shift_cmd] = run_math_shift;
jump_table[mmode + math_shift_cs_cmd] = run_math_shift;
@@ -1759,18 +1761,42 @@ void append_discretionary(void)
if (cur_chr == explicit_disc) {
/* \- */
c = get_pre_hyphen_char(cur_lang_par);
- if (c != 0) {
+ if (c > 0) {
vlink(pre_break(tail)) = new_char(equiv(cur_font_loc), c);
alink(vlink(pre_break(tail))) = pre_break(tail);
tlink(pre_break(tail)) = vlink(pre_break(tail));
}
c = get_post_hyphen_char(cur_lang_par);
- if (c != 0) {
+ if (c > 0) {
vlink(post_break(tail)) = new_char(equiv(cur_font_loc), c);
alink(vlink(post_break(tail))) = post_break(tail);
tlink(post_break(tail)) = vlink(post_break(tail));
}
set_explicit_disc_penalty(tail);
+ } else if (cur_chr == automatic_disc) {
+ /* - as done in hyphenator */
+ c = get_pre_exhyphen_char(cur_lang_par);
+ if (c <= 0) {
+ c = ex_hyphen_char_par;
+ }
+ if (c > 0) {
+ vlink(pre_break(tail)) = new_char(equiv(cur_font_loc), c);
+ alink(vlink(pre_break(tail))) = pre_break(tail);
+ tlink(pre_break(tail)) = vlink(pre_break(tail));
+ }
+ c = get_post_exhyphen_char(cur_lang_par);
+ if (c > 0) {
+ vlink(post_break(tail)) = new_char(equiv(cur_font_loc), c);
+ alink(vlink(post_break(tail))) = post_break(tail);
+ tlink(post_break(tail)) = vlink(post_break(tail));
+ }
+ c = ex_hyphen_char_par;
+ if (c > 0) {
+ vlink(no_break(tail)) = new_char(equiv(cur_font_loc), c);
+ alink(vlink(no_break(tail))) = no_break(tail);
+ tlink(no_break(tail)) = vlink(no_break(tail));
+ }
+ set_automatic_disc_penalty(tail);
} else {
/* \discretionary */
if (scan_keyword("penalty")) {
@@ -3601,6 +3627,9 @@ void initialize(void)
hang_after_par = 1;
max_dead_cycles_par = 25;
math_pre_display_gap_factor_par = 2000;
+ pre_bin_op_penalty_par = inf_penalty;
+ math_script_box_mode_par = 1;
+ pre_rel_penalty_par = inf_penalty;
escape_char_par = '\\';
end_line_char_par = carriage_return;
set_del_code('.', 0, 0, 0, 0, level_one); /* this null delimiter is used in error recovery */
@@ -3632,7 +3661,9 @@ void initialize(void)
set_eq_level(end_write, level_one);
set_eq_type(end_write, outer_call_cmd);
set_equiv(end_write, null);
-
+ /* bah */
+ set_pdf_major_version(1);
+ set_pdf_minor_version(0);
}
synctexoffset = int_base + synctex_code;
diff --git a/Build/source/texk/web2c/luatexdir/tex/mlist.w b/Build/source/texk/web2c/luatexdir/tex/mlist.w
index 7a002c2843d..291ce8c4868 100644
--- a/Build/source/texk/web2c/luatexdir/tex/mlist.w
+++ b/Build/source/texk/web2c/luatexdir/tex/mlist.w
@@ -1348,29 +1348,30 @@ static void endless_loop_error(internal_font_number g, int y)
tex_error(s, hlp);
}
-static pointer do_delimiter(pointer q, pointer d, int s, scaled v, boolean flat, int cur_style, boolean shift, boolean *stack, scaled *delta)
+static pointer do_delimiter(pointer q, pointer d, int s, scaled v, boolean flat, int cur_style, boolean shift, boolean *stack, scaled *delta, int *same)
{
- pointer b; /* the box that will be constructed */
- internal_font_number f, g; /* best-so-far and tentative font codes */
- int c, i, x, y; /* best-so-far and tentative character codes */
- scaled u; /* height-plus-depth of a tentative character */
- scaled w; /* largest height-plus-depth so far */
- int z; /* runs through font family members */
- boolean large_attempt; /* are we trying the ``large'' variant? */
- pointer att; /* to save the current attribute list */
- boolean do_parts;
+ pointer b; /* the box that will be constructed */
+ internal_font_number f, g; /* best-so-far and tentative font codes */
+ int c, i, x, y; /* best-so-far and tentative character codes */
+ scaled u; /* height-plus-depth of a tentative character */
+ scaled w = 0; /* largest height-plus-depth so far */
+ int z; /* runs through font family members */
+ boolean large_attempt = false; /* are we trying the ``large'' variant? */
+ pointer att = null; /* to save the current attribute list */
+ int emas = 0 ;
+ boolean do_parts = false;
extinfo *ext;
- att = null;
f = null_font;
c = 0;
- w = 0;
- do_parts = false;
- large_attempt = false;
if (d == null)
goto FOUND;
z = small_fam(d);
x = small_char(d);
i = 0;
+ if (same != NULL) {
+ emas = *same ;
+ same = 0;
+ }
while (true) {
/*
The search process is complicated slightly by the facts that some of the
@@ -1448,6 +1449,9 @@ static pointer do_delimiter(pointer q, pointer d, int s, scaled v, boolean flat,
if (stack != NULL)
*stack = true ;
} else {
+ if (same != NULL && x == c) {
+ *same = emas;
+ }
b = char_box(f, c, att);
if (!do_new_math(f)) {
/* italic gets added to width */
@@ -1475,10 +1479,12 @@ static pointer do_delimiter(pointer q, pointer d, int s, scaled v, boolean flat,
*stack = false ;
}
if (!flat) {
- /* vertical variant */
- shift_amount(b) = half(height(b) - depth(b));
- if (shift) {
- shift_amount(b) -= math_axis_size(s);
+ if (emas == 0 || ! delimitermodenoshift) {
+ /* vertical variant */
+ shift_amount(b) = half(height(b) - depth(b));
+ if (shift) {
+ shift_amount(b) -= math_axis_size(s);
+ }
}
}
delete_attribute_ref(att);
@@ -1605,7 +1611,7 @@ static void math_kern(pointer p, scaled m)
f = f + unity;
}
width(p) = mu_mult(width(p));
- subtype(p) = italic_kern;
+ subtype(p) = italic_kern; /* this is weird, it's not a italic but explicit_kern */
}
}
@@ -1666,21 +1672,21 @@ static pointer clean_box(pointer p, int s, int cur_style)
pointer r; /* temporary pointer */
pointer mlist = null; /* beginning of mlist to be translated */
switch (type(p)) {
- case math_char_node:
- mlist = new_noad();
- r = math_clone(p);
- nucleus(mlist) = r;
- break;
- case sub_box_node:
- q = math_list(p);
- goto FOUND;
- break;
- case sub_mlist_node:
- mlist = math_list(p);
- break;
- default:
- q = new_null_box();
- goto FOUND;
+ case math_char_node:
+ mlist = new_noad();
+ r = math_clone(p);
+ nucleus(mlist) = r;
+ break;
+ case sub_box_node:
+ q = math_list(p);
+ goto FOUND;
+ break;
+ case sub_mlist_node:
+ mlist = math_list(p);
+ break;
+ default:
+ q = new_null_box();
+ goto FOUND;
}
mlist_to_hlist(mlist, false, s);
q = vlink(temp_head); /* recursive call */
@@ -1857,7 +1863,7 @@ static void make_hextension(pointer q, int cur_style)
pointer e, p;
halfword w;
boolean stack = false;
- e = do_delimiter(q, left_delimiter(q), cur_size, radicalwidth(q), true, cur_style, true, &stack, NULL);
+ e = do_delimiter(q, left_delimiter(q), cur_size, radicalwidth(q), true, cur_style, true, &stack, NULL, NULL);
w = width(e);
if (!stack&& (radicalwidth(q) != 0) && (radicalwidth(q) != width(e))) {
if (radicalmiddle(q)) {
@@ -1887,7 +1893,7 @@ static void make_radical(pointer q, int cur_style)
if (theta == undefined_math_parameter) {
/* a real radical */
theta = fraction_rule(cur_style);
- y = do_delimiter(q, left_delimiter(q), cur_size, height(x) + depth(x) + clr + theta, false, cur_style, true, NULL, NULL);
+ y = do_delimiter(q, left_delimiter(q), cur_size, height(x) + depth(x) + clr + theta, false, cur_style, true, NULL, NULL, NULL);
/*
If |y| is a composite then set |theta| to the height of its top
character, else set it to the height of |y|.
@@ -1907,7 +1913,7 @@ static void make_radical(pointer q, int cur_style)
}
} else {
/* not really a radical but we use its node, historical sharing (like in mathml) */
- y = do_delimiter(q, left_delimiter(q), cur_size, height(x) + depth(x) + clr + theta, false, cur_style, true, NULL, NULL);
+ y = do_delimiter(q, left_delimiter(q), cur_size, height(x) + depth(x) + clr + theta, false, cur_style, true, NULL, NULL, NULL);
}
left_delimiter(q) = null;
delta = (depth(y) + height(y) - theta) - (height(x) + depth(x) + clr);
@@ -2034,7 +2040,7 @@ static void make_over_delimiter(pointer q, int cur_style)
boolean stack;
x = clean_box(nucleus(q), sub_style(cur_style), cur_style);
check_widths(q,x);
- y = do_delimiter(q, left_delimiter(q), cur_size, wd, true, cur_style, true, &stack, NULL);
+ y = do_delimiter(q, left_delimiter(q), cur_size, wd, true, cur_style, true, &stack, NULL, NULL);
left_delimiter(q) = null;
check_radical(q,stack,y,x);
fixup_widths(q, x, y);
@@ -2061,7 +2067,7 @@ static void make_under_delimiter(pointer q, int cur_style)
boolean stack;
y = clean_box(nucleus(q), sup_style(cur_style), cur_style);
check_widths(q,y);
- x = do_delimiter(q, left_delimiter(q), cur_size, wd, true, cur_style, true, &stack, NULL);
+ x = do_delimiter(q, left_delimiter(q), cur_size, wd, true, cur_style, true, &stack, NULL, NULL);
left_delimiter(q) = null;
check_radical(q,stack,x,y);
fixup_widths(q, x, y);
@@ -2088,7 +2094,7 @@ static void make_delimiter_over(pointer q, int cur_style)
boolean stack;
y = clean_box(nucleus(q), cur_style, cur_style);
check_widths(q,y);
- x = do_delimiter(q, left_delimiter(q), cur_size + (cur_size == script_script_size ? 0 : 1), wd, true, cur_style, true, &stack, NULL);
+ x = do_delimiter(q, left_delimiter(q), cur_size + (cur_size == script_script_size ? 0 : 1), wd, true, cur_style, true, &stack, NULL, NULL);
left_delimiter(q) = null;
check_radical(q,stack,x,y);
fixup_widths(q, x, y);
@@ -2115,7 +2121,7 @@ static void make_delimiter_under(pointer q, int cur_style)
boolean stack;
x = clean_box(nucleus(q), cur_style, cur_style);
check_widths(q,x);
- y = do_delimiter(q, left_delimiter(q), cur_size + (cur_size == script_script_size ? 0 : 1), wd, true, cur_style, true, &stack, NULL);
+ y = do_delimiter(q, left_delimiter(q), cur_size + (cur_size == script_script_size ? 0 : 1), wd, true, cur_style, true, &stack, NULL, NULL);
left_delimiter(q) = null;
check_radical(q,stack,y,x);
fixup_widths(q, x, y);
@@ -2182,11 +2188,24 @@ static boolean compute_accent_skew(pointer q, int flags, scaled *s)
* use the positioning of the nucleus of that noad, recursing until
* the inner most |accent_noad|. This way multiple stacked accents are
* aligned to the inner most one.
+
+ the vlink test was added in version 1.06, so that we only consider a lone
+ noad:
+
+ $
+ \Umathaccent bottom 0 0 "023DF { \Umathaccent fixed 0 0 "00302 { m } r } \quad
+ \Umathaccent bottom 0 0 "023DF { l \Umathaccent fixed 0 0 "00302 { m } r } \quad
+ \Umathaccent bottom 0 0 "023DF { l \Umathaccent fixed 0 0 "00302 { m } } \quad
+ \Umathaccent bottom 0 0 "023DF { \Umathaccent fixed 0 0 "00302 { m } } \quad
+ \Umathaccent bottom 0 0 "023DF { l r }
+ $
+
*/
p = math_list(nucleus(q));
- if (type(p) == accent_noad) {
+ if (type(p) == accent_noad && vlink(p) == null) {
s_is_absolute = compute_accent_skew(p, flags, s);
}
+ } else {
}
return s_is_absolute;
@@ -2423,7 +2442,7 @@ static void make_fraction(pointer q, int cur_style)
if (middle_delimiter(q) != null) {
delta = 0;
- m = do_delimiter(q, middle_delimiter(q), cur_size, delta, false, cur_style, true, NULL, NULL);
+ m = do_delimiter(q, middle_delimiter(q), cur_size, delta, false, cur_style, true, NULL, NULL, NULL);
middle_delimiter(q) = null;
} else {
m = null ;
@@ -2592,9 +2611,9 @@ static void make_fraction(pointer q, int cur_style)
} else {
delta = fraction_del_size_old(cur_style);
}
- l = do_delimiter(q, left_delimiter(q), cur_size, delta, false, cur_style, true, NULL, NULL);
+ l = do_delimiter(q, left_delimiter(q), cur_size, delta, false, cur_style, true, NULL, NULL, NULL);
left_delimiter(q) = null;
- r = do_delimiter(q, right_delimiter(q), cur_size, delta, false, cur_style, true, NULL, NULL);
+ r = do_delimiter(q, right_delimiter(q), cur_size, delta, false, cur_style, true, NULL, NULL, NULL);
right_delimiter(q) = null;
couple_nodes(l,v);
couple_nodes(v,r);
@@ -2619,7 +2638,7 @@ the limits have been set above and below the operator. In that case,
@c
static void make_scripts(pointer q, pointer p, scaled it, int cur_style, scaled supshift, scaled subshift);
-static pointer check_nucleus_complexity(halfword q, scaled * delta, int cur_style);
+static pointer check_nucleus_complexity(halfword q, scaled * delta, int cur_style, int *same);
static scaled make_op(pointer q, int cur_style)
{
@@ -2644,7 +2663,7 @@ static scaled make_op(pointer q, int cur_style)
reset_attributes(y, node_attr(q));
small_fam(y) = math_fam(nucleus(q));
small_char(y) = math_character(nucleus(q));
- x = do_delimiter(q, y, text_size, ok_size, false, cur_style, true, NULL, &delta);
+ x = do_delimiter(q, y, text_size, ok_size, false, cur_style, true, NULL, &delta, NULL);
if (delta != 0) {
if (do_new_math(cur_f)) {
/* we never added italic correction */
@@ -2705,7 +2724,7 @@ static scaled make_op(pointer q, int cur_style)
delta = half(delta) ;
}
*/
- p = check_nucleus_complexity(q, &dummy, cur_style);
+ p = check_nucleus_complexity(q, &dummy, cur_style, NULL);
if ((subscr(q) == null) && (supscr(q) == null)) {
assign_new_hlist(q, p);
} else {
@@ -2752,7 +2771,7 @@ static scaled make_op(pointer q, int cur_style)
delta = 0;
} else {
/* similar code then the caller (before CHECK_DIMENSIONS) */
- p = check_nucleus_complexity(q, &delta, cur_style);
+ p = check_nucleus_complexity(q, &delta, cur_style, NULL);
if ((subscr(q) == null) && (supscr(q) == null)) {
assign_new_hlist(q, p);
} else {
@@ -2923,6 +2942,7 @@ static void make_ord(pointer q)
/* add italic correction */
if (do_new_math(cur_f) && (char_italic(cur_f,math_character(nucleus(q))) != 0)) {
p = new_kern(char_italic(cur_f,math_character(nucleus(q))));
+ subtype(p) = italic_kern;
reset_attributes(p, node_attr(q));
couple_nodes(p,vlink(q));
couple_nodes(q,p);
@@ -3082,7 +3102,8 @@ static scaled find_math_kern(internal_font_number l_f, int l_c,
{
scaled corr_height_top = 0, corr_height_bot = 0;
scaled krn_l = 0, krn_r = 0, krn = 0;
- if ((!do_new_math(l_f)) || (!do_new_math(r_f)) || (!char_exists(l_f, l_c)) || (!char_exists(r_f, r_c)))
+// if ((!do_new_math(l_f)) || (!do_new_math(r_f)) || (!char_exists(l_f, l_c)) || (!char_exists(r_f, r_c)))
+ if ((!(do_new_math(l_f) || do_new_math(r_f))) || (!char_exists(l_f, l_c)) || (!char_exists(r_f, r_c)))
return MATH_KERN_NOT_FOUND;
if (cmd == sup_mark_cmd) {
@@ -3203,39 +3224,91 @@ kerns assuming that is italic correction. The heuristics are unreliable for
the new fonts so eventualy there will be an option to ignore such corrections.
@ @c
-#define analyze_script(init,su_n,su_f,su_c) do { \
- su_n = init; \
- if (su_n != null) { \
- if (type(su_n) == sub_mlist_node && math_list(su_n)) { \
- su_n = math_list(su_n); \
- if (su_n != null) { \
- while (su_n) { \
- if ((type(su_n) == kern_node) || (type(su_n) == glue_node)) {\
- su_n = vlink(su_n); \
- } else if (type(su_n) == simple_noad) { \
- su_n = nucleus(su_n); \
- if (type(su_n) != math_char_node) { \
- su_n = null; \
- } \
- break; \
- } else { \
- su_n = null; \
- break; \
- } \
- } \
- } \
- } \
- if ((su_n != null) && (type(su_n) == math_char_node)) { \
- fetch(su_n); \
- if (char_exists(cur_f, cur_c)) { \
- su_f = cur_f; \
- su_c = cur_c; \
- } else { \
- su_n = null; \
- } \
- } \
- } \
- } while (0)
+#define analyze_script(init,su_n,su_f,su_c) do { \
+ su_n = init; \
+ if (su_n != null) { \
+ if (math_script_box_mode_par > 0 && type(su_n) == sub_mlist_node) { \
+ su_n = math_list(su_n); \
+ while (su_n != null) { \
+ if ((type(su_n) == kern_node) || (type(su_n) == glue_node)) { \
+ su_n = vlink(su_n); \
+ } else if (type(su_n) == simple_noad) { \
+ su_n = nucleus(su_n); \
+ if (type(su_n) == math_char_node) { \
+ fetch(su_n); \
+ if (char_exists(cur_f, cur_c)) { \
+ su_f = cur_f; \
+ su_c = cur_c; \
+ } else { \
+ su_n = null; \
+ } \
+ } else { \
+ su_n = null; \
+ } \
+ break; \
+ } else { \
+ su_n = null; \
+ break; \
+ } \
+ } \
+ } else if (type(su_n) == sub_box_node) { \
+ su_n = math_list(su_n); \
+ if (su_n != null) { \
+ if (type(su_n) == hlist_node) { \
+ su_n = list_ptr(su_n); \
+ } \
+ if (su_n != null) { \
+ if (math_script_box_mode_par == 2) { \
+ while (su_n != null) { \
+ if ((type(su_n) == kern_node) || (type(su_n) == glue_node)) { \
+ su_n = vlink(su_n); \
+ } else if (type(su_n) == glyph_node) { \
+ if (char_exists(font(su_n), character(su_n))) { \
+ su_f = font(su_n); \
+ su_c = character(su_n); \
+ } else { \
+ su_n = null; \
+ } \
+ break ; \
+ } else { \
+ su_n = null; \
+ break; \
+ } \
+ } \
+ } else if (math_script_box_mode_par == 3) { \
+ int boundary = -1; \
+ while (su_n != null) { \
+ if ((type(su_n) == boundary_node) && (subtype(su_n) == user_boundary)) { \
+ boundary = boundary_value(su_n); \
+ su_n = vlink(su_n); \
+ } else if ((type(su_n) == kern_node) || (type(su_n) == glue_node)) { \
+ su_n = vlink(su_n); \
+ } else if ((boundary > -1) && (type(su_n) == glyph_node)) { \
+ if (char_exists(font(su_n), character(su_n))) { \
+ su_f = font(su_n); \
+ su_c = character(su_n); \
+ } else { \
+ su_n = null; \
+ } \
+ break ; \
+ } else { \
+ su_n = null; \
+ break; \
+ } \
+ } \
+ } \
+ } \
+ } else { \
+ su_n = null; \
+ } \
+ } else { \
+ su_n = null; \
+ } \
+ } \
+ } while (0) \
+
+#define x_su_style(n,cur_style,su_style) \
+ (noadoptionnosubscript(n) ? cur_style : su_style(cur_style))
static void make_scripts(pointer q, pointer p, scaled it, int cur_style, scaled supshift, scaled subshift)
{
@@ -3265,6 +3338,7 @@ static void make_scripts(pointer q, pointer p, scaled it, int cur_style, scaled
if ((subscr(q) == null) && (delta1 != 0)) {
/* todo: selective */
x = new_kern(delta1); /* italic correction */
+ subtype(x) = italic_kern;
reset_attributes(x, node_attr(nucleus(q)));
couple_nodes(p,x);
delta1 = 0;
@@ -3296,7 +3370,8 @@ static void make_scripts(pointer q, pointer p, scaled it, int cur_style, scaled
when there is a subscript without a superscript, the top of the subscript
should not exceed the baseline plus four-fifths of the x-height.
*/
- x = clean_box(subscr(q), sub_style(cur_style), cur_style);
+ /* x = clean_box(subscr(q), sub_style(cur_style), cur_style); */
+ x = clean_box(subscr(q), (noadoptionnosubscript(q) ? cur_style : sub_style(cur_style)), cur_style);
width(x) = width(x) + space_after_script(cur_style);
switch (math_scripts_mode_par) {
case 1:
@@ -3346,7 +3421,8 @@ static void make_scripts(pointer q, pointer p, scaled it, int cur_style, scaled
the bottom of a superscript should never descend below the baseline plus
one-fourth of the x-height.
*/
- x = clean_box(supscr(q), sup_style(cur_style), cur_style);
+ /* x = clean_box(supscr(q), sup_style(cur_style), cur_style); */
+ x = clean_box(supscr(q), (noadoptionnosupscript(q) ? cur_style : sup_style(cur_style)), cur_style);
width(x) = width(x) + space_after_script(cur_style);
switch (math_scripts_mode_par) {
case 1:
@@ -3401,7 +3477,8 @@ static void make_scripts(pointer q, pointer p, scaled it, int cur_style, scaled
both subscript and superscript move up so that the bottom of the superscript
is at least as high as the baseline plus four-fifths of the x-height
*/
- y = clean_box(subscr(q), sub_style(cur_style), cur_style);
+ /* y = clean_box(subscr(q) sub_style(cur_style), cur_style); */
+ y = clean_box(subscr(q), (noadoptionnosubscript(q) ? cur_style : sub_style(cur_style)), cur_style);
width(y) = width(y) + space_after_script(cur_style);
switch (math_scripts_mode_par) {
case 1:
@@ -3508,23 +3585,17 @@ static small_number make_left_right(pointer q, int style, scaled max_d, scaled m
{
scaled delta;
pointer tmp, lst;
- scaled hd_asked = 0;
scaled ic = 0;
boolean stack = false;
boolean axis = false;
- /*
- scaled hd_done = 0;
- boolean fitting = true;
- boolean fence = false;
- int chr = 0;
- int cls = 0;
- */
+ int same = subtype(q);
+
setup_cur_size(style);
if ((delimiterheight(q)!=0) || (delimiterdepth(q)!=0)) {
- hd_asked = delimiterheight(q) + delimiterdepth(q);
- tmp = do_delimiter(q, delimiter(q), cur_size, hd_asked, false, style, false, &stack, &ic);
+ delta = delimiterheight(q) + delimiterdepth(q);
+ tmp = do_delimiter(q, delimiter(q), cur_size, delta, false, style, false, &stack, &ic, &same);
delimiteritalic(q) = ic;
/* beware, a stacked delimiter has a shift but no corrected height/depth (yet) */
@@ -3533,19 +3604,6 @@ static small_number make_left_right(pointer q, int style, scaled max_d, scaled m
shift_amount(tmp) = delimiterdepth(q);
}
- /*
- hd_done = height(tmp) + depth(tmp);
- fitting = stack || ((hd_done-hd_asked) == 0);
-
- if (type(delimiter(q)) == delim_node && (small_char(delimiter(q)) != 0)) {
- chr = small_char(delimiter(q));
- cls = get_math_code(chr).class_value ;
- fence = (cls == 4) || (cls == 5) ;
- }
-
- printf("delimiter stack %i fence %i fitting %i\n",stack,fence,fitting);
- */
-
if (delimiterexact(q)) {
delimiterheight(q) = height(tmp) - shift_amount(tmp);
delimiterdepth(q) = depth(tmp) + shift_amount(tmp);
@@ -3566,19 +3624,18 @@ static small_number make_left_right(pointer q, int style, scaled max_d, scaled m
} else {
axis = ! delimiternoaxis(q);
delta = get_delimiter_height(max_d,max_h,axis);
- tmp = do_delimiter(q, delimiter(q), cur_size, delta, false, style, axis, &stack, &ic);
+ tmp = do_delimiter(q, delimiter(q), cur_size, delta, false, style, axis, &stack, &ic, &same);
delimiteritalic(q) = ic;
}
delimiter(q) = null;
assign_new_hlist(q, tmp);
+ delimitersamesize(q) = same; /* new */
if (delimiterclass(q) >= ord_noad_type) {
if (delimiterclass(q) <= inner_noad_type) {
return delimiterclass(q);
} else {
return ord_noad_type;
}
- } else if (subtype(q) == no_noad_side) {
- return open_noad_type;
} else if (subtype(q) == left_noad_side) {
return open_noad_type;
} else {
@@ -3797,58 +3854,67 @@ static pointer math_spacing_glue(int l_type, int r_type, int mstyle, scaled mmu)
}
@ @c
-static pointer check_nucleus_complexity(halfword q, scaled * delta, int cur_style)
+static pointer check_nucleus_complexity(halfword q, scaled * delta, int cur_style, int *same)
{
pointer p = null;
+ pointer t = null;
+ if (same != NULL) {
+ *same = 0;
+ }
switch (type(nucleus(q))) {
- case math_char_node:
- case math_text_char_node:
- fetch(nucleus(q));
- if (char_exists(cur_f, cur_c)) {
- /* we could look at neighbours */
- if (do_new_math(cur_f)) {
- *delta = 0 ; /* cf spec only the last one */
- } else {
- *delta = char_italic(cur_f, cur_c);
- }
- p = new_glyph(cur_f, cur_c);
- reset_attributes(p, node_attr(nucleus(q)));
- if (do_new_math(cur_f)) {
- if (! math_no_char_italic_par) {
- /* keep italic, but bad with two successive letters */
- } else if (get_char_cat_code(cur_c) == 11) {
+ case math_char_node:
+ case math_text_char_node:
+ fetch(nucleus(q));
+ if (char_exists(cur_f, cur_c)) {
+ /* we could look at neighbours */
+ if (do_new_math(cur_f)) {
+ *delta = 0 ; /* cf spec only the last one */
+ } else {
+ *delta = char_italic(cur_f, cur_c);
+ }
+ p = new_glyph(cur_f, cur_c);
+ reset_attributes(p, node_attr(nucleus(q)));
+ if (do_new_math(cur_f)) {
+ if (! math_no_char_italic_par) {
+ /* keep italic, but bad with two successive letters */
+ } else if (get_char_cat_code(cur_c) == 11) {
+ /* no italic correction in mid-word of text font */
+ *delta = 0;
+ }
+ } else {
/* no italic correction in mid-word of text font */
- *delta = 0;
+ if (((type(nucleus(q))) == math_text_char_node) && (space(cur_f) != 0)) {
+ *delta = 0;
+ }
}
- } else {
- /* no italic correction in mid-word of text font */
- if (((type(nucleus(q))) == math_text_char_node) && (space(cur_f) != 0)) {
+ /* so we only add italic correction when we have no scripts */
+ if ((subscr(q) == null) && (supscr(q) == null) && (*delta != 0)) {
+ pointer x = new_kern(*delta);
+ subtype(x) = italic_kern;
+ reset_attributes(x, node_attr(nucleus(q)));
+ couple_nodes(p,x);
*delta = 0;
+ } else /* needs checking but looks ok */
+ if (do_new_math(cur_f)) {
+ *delta = char_italic(cur_f, cur_c); /* must be more selective */
}
}
- /* so we only add italic correction when we have no scripts */
- if ((subscr(q) == null) && (supscr(q) == null) && (*delta != 0)) {
- pointer x = new_kern(*delta);
- reset_attributes(x, node_attr(nucleus(q)));
- couple_nodes(p,x);
- *delta = 0;
- }
- if (do_new_math(cur_f)) {
- *delta = char_italic(cur_f, cur_c); /* must be more selective */
- }
- }
- break;
- case sub_box_node:
- p = math_list(nucleus(q));
- break;
- case sub_mlist_node:
- mlist_to_hlist(math_list(nucleus(q)), false, cur_style); /* recursive call */
- setup_cur_size(cur_style);
- p = hpack(vlink(temp_head), 0, additional, -1);
- reset_attributes(p, node_attr(nucleus(q)));
- break;
- default:
- confusion("mlist2"); /* this can't happen mlist2 */
+ break;
+ case sub_box_node:
+ p = math_list(nucleus(q));
+ break;
+ case sub_mlist_node:
+ t = math_list(nucleus(q));
+ mlist_to_hlist(t, false, cur_style); /* recursive call */
+if (same != NULL && type(t) == fence_noad && delimitersamesize(t)) {
+ *same = delimitersamesize(t) ;
+}
+ setup_cur_size(cur_style);
+ p = hpack(vlink(temp_head), 0, additional, -1);
+ reset_attributes(p, node_attr(nucleus(q)));
+ break;
+ default:
+ confusion("mlist2"); /* this can't happen mlist2 */
}
return p;
}
@@ -3867,9 +3933,12 @@ void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
int t; /* the effective |type| of noad |q| during the second pass */
int t_subtype; /* the effective |subtype| of noad |q| during the second pass */
pointer p = null;
+ pointer pp = null;
pointer z = null;
halfword nxt ;
+ int same = 0;
int pen; /* a penalty to be inserted */
+ int prepen; /* a penalty to be inserted */
scaled max_hl = 0; /* maximum height of the list translated so far */
scaled max_d = 0; /* maximum depth of the list translated so far */
scaled delta; /* italic correction offset for subscript and superscript */
@@ -3877,6 +3946,10 @@ void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
r_subtype = op_noad_type_normal;
setup_cur_size(cur_style);
cur_mu = x_over_n(get_math_quad_size(cur_size), 18);
+ if (math_penalties_mode_par) {
+ /* we could do this via the callback but it's nice to have it as primitive too */
+ penalties = 1;
+ }
while (q != null) {
/*
we use the fact that no character nodes appear in an mlist, hence
@@ -3891,179 +3964,180 @@ void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
delta = 0;
nxt = vlink(q);
switch (type(q)) {
- case simple_noad:
- switch (subtype(q)) {
- case bin_noad_type:
- switch (r_type) {
- case simple_noad:
- switch (r_subtype) {
- case bin_noad_type:
- case op_noad_type_normal:
- case op_noad_type_limits:
- case op_noad_type_no_limits:
- case rel_noad_type:
- case open_noad_type:
- case punct_noad_type:
- subtype(q) = ord_noad_type;
- goto RESWITCH;
+ case simple_noad:
+ switch (subtype(q)) {
+ case bin_noad_type:
+ switch (r_type) {
+ case simple_noad:
+ switch (r_subtype) {
+ case bin_noad_type:
+ case op_noad_type_normal:
+ case op_noad_type_limits:
+ case op_noad_type_no_limits:
+ case rel_noad_type:
+ case open_noad_type:
+ case punct_noad_type:
+ subtype(q) = ord_noad_type;
+ goto RESWITCH;
+ break;
+ }
+ break;
+ case fence_noad:
+ if (r_subtype == left_noad_side) {
+ subtype(q) = ord_noad_type; /* so these can best be the same size */
+ goto RESWITCH;
+ }
break;
}
break;
- case fence_noad:
- if (r_subtype == left_noad_side) {
- subtype(q) = ord_noad_type; /* so these can best be the same size */
- goto RESWITCH;
+ case over_noad_type:
+ make_over(q, cur_style, cur_size, math_rules_fam_par);
+ break;
+ case under_noad_type:
+ make_under(q, cur_style, cur_size, math_rules_fam_par);
+ break;
+ case vcenter_noad_type:
+ make_vcenter(q);
+ break;
+ case rel_noad_type:
+ case close_noad_type:
+ case punct_noad_type:
+ if (r_type == simple_noad && r_subtype == bin_noad_type) {
+ type(r) = simple_noad; /* assumes the same size .. can't this go */
+ subtype(r) = ord_noad_type;
}
break;
+ case op_noad_type_normal:
+ case op_noad_type_limits:
+ case op_noad_type_no_limits:
+ delta = make_op(q, cur_style);
+ if ((subtype(q) == op_noad_type_limits) || (subtype(q) == op_noad_type_no_limits))
+ goto CHECK_DIMENSIONS;
+ break;
+ case ord_noad_type:
+ make_ord(q);
+ break;
+ case open_noad_type:
+ case inner_noad_type:
+ break;
}
break;
- case over_noad_type:
- make_over(q, cur_style, cur_size, math_rules_fam_par);
- break;
- case under_noad_type:
- make_under(q, cur_style, cur_size, math_rules_fam_par);
- break;
- case vcenter_noad_type:
- make_vcenter(q);
- break;
- case rel_noad_type:
- case close_noad_type:
- case punct_noad_type:
- if (r_type == simple_noad && r_subtype == bin_noad_type) {
- type(r) = simple_noad; /* assumes the same size .. can't this go */
- subtype(r) = ord_noad_type;
+ case fence_noad:
+ if (subtype(q) != left_noad_side) {
+ if (r_type == simple_noad && r_subtype == bin_noad_type) {
+ type(r) = simple_noad; /* assumes the same size */
+ subtype(r) = ord_noad_type;
+ }
}
+ goto DONE_WITH_NOAD;
break;
- case op_noad_type_normal:
- case op_noad_type_limits:
- case op_noad_type_no_limits:
- delta = make_op(q, cur_style);
- if ((subtype(q) == op_noad_type_limits) || (subtype(q) == op_noad_type_no_limits))
- goto CHECK_DIMENSIONS;
+ case fraction_noad:
+ make_fraction(q, cur_style);
+ goto CHECK_DIMENSIONS;
break;
- case ord_noad_type:
- make_ord(q);
+ case radical_noad:
+ if (subtype(q) == 7)
+ make_hextension(q, cur_style);
+ else if (subtype(q) == 6)
+ make_delimiter_over(q, cur_style);
+ else if (subtype(q) == 5)
+ make_delimiter_under(q, cur_style);
+ else if (subtype(q) == 4)
+ make_over_delimiter(q, cur_style);
+ else if (subtype(q) == 3)
+ make_under_delimiter(q, cur_style);
+ else
+ make_radical(q, cur_style);
break;
- case open_noad_type:
- case inner_noad_type:
+ case accent_noad:
+ make_math_accent(q, cur_style);
break;
- }
- break;
- case fence_noad:
- if (subtype(q) != left_noad_side)
- if (r_type == simple_noad && r_subtype == bin_noad_type) {
- type(r) = simple_noad; /* assumes the same size */
- subtype(r) = ord_noad_type;
- }
- goto DONE_WITH_NOAD;
- break;
- case fraction_noad:
- make_fraction(q, cur_style);
- goto CHECK_DIMENSIONS;
- break;
- case radical_noad:
- if (subtype(q) == 7)
- make_hextension(q, cur_style);
- else if (subtype(q) == 6)
- make_delimiter_over(q, cur_style);
- else if (subtype(q) == 5)
- make_delimiter_under(q, cur_style);
- else if (subtype(q) == 4)
- make_over_delimiter(q, cur_style);
- else if (subtype(q) == 3)
- make_under_delimiter(q, cur_style);
- else
- make_radical(q, cur_style);
- break;
- case accent_noad:
- make_math_accent(q, cur_style);
- break;
- case style_node:
- cur_style = subtype(q);
- setup_cur_size(cur_style);
- cur_mu = x_over_n(get_math_quad_style(cur_style), 18);
- goto DONE_WITH_NODE;
- break;
- case choice_node:
- switch (cur_style / 2) {
- case 0: /* |display_style=0| */
- choose_mlist(display_mlist);
+ case style_node:
+ cur_style = subtype(q);
+ setup_cur_size(cur_style);
+ cur_mu = x_over_n(get_math_quad_style(cur_style), 18);
+ goto DONE_WITH_NODE;
break;
- case 1: /* |text_style=2| */
- choose_mlist(text_mlist);
+ case choice_node:
+ switch (cur_style / 2) {
+ case 0: /* |display_style=0| */
+ choose_mlist(display_mlist);
+ break;
+ case 1: /* |text_style=2| */
+ choose_mlist(text_mlist);
+ break;
+ case 2: /* |script_style=4| */
+ choose_mlist(script_mlist);
+ break;
+ case 3: /* |script_script_style=6| */
+ choose_mlist(script_script_mlist);
+ break;
+ }
+ flush_node_list(display_mlist(q));
+ flush_node_list(text_mlist(q));
+ flush_node_list(script_mlist(q));
+ flush_node_list(script_script_mlist(q));
+ type(q) = style_node;
+ subtype(q) = (quarterword) cur_style;
+ if (p != null) {
+ z = vlink(q);
+ couple_nodes(q,p);
+ while (vlink(p) != null)
+ p = vlink(p);
+ try_couple_nodes(p,z);
+ }
+ goto DONE_WITH_NODE;
break;
- case 2: /* |script_style=4| */
- choose_mlist(script_mlist);
+ case ins_node:
+ case mark_node:
+ case adjust_node:
+ case boundary_node:
+ case whatsit_node:
+ case penalty_node:
+ case disc_node:
+ goto DONE_WITH_NODE;
break;
- case 3: /* |script_script_style=6| */
- choose_mlist(script_script_mlist);
+ case rule_node:
+ if (height(q) > max_hl)
+ max_hl = height(q);
+ if (depth(q) > max_d)
+ max_d = depth(q);
+ goto DONE_WITH_NODE;
break;
- }
- flush_node_list(display_mlist(q));
- flush_node_list(text_mlist(q));
- flush_node_list(script_mlist(q));
- flush_node_list(script_script_mlist(q));
- type(q) = style_node;
- subtype(q) = (quarterword) cur_style;
- if (p != null) {
- z = vlink(q);
- couple_nodes(q,p);
- while (vlink(p) != null)
- p = vlink(p);
- try_couple_nodes(p,z);
- }
- goto DONE_WITH_NODE;
- break;
- case ins_node:
- case mark_node:
- case adjust_node:
- case boundary_node:
- case whatsit_node:
- case penalty_node:
- case disc_node:
- goto DONE_WITH_NODE;
- break;
- case rule_node:
- if (height(q) > max_hl)
- max_hl = height(q);
- if (depth(q) > max_d)
- max_d = depth(q);
- goto DONE_WITH_NODE;
- break;
- case glue_node:
- /*
- conditional math glue (`\.{\\nonscript}') results in a |glue_node|
- pointing to |zero_glue|, with |subtype(q)=cond_math_glue|; in such a case
- the node following will be eliminated if it is a glue or kern node and if the
- current size is different from |text_size|
+ case glue_node:
+ /*
+ conditional math glue (`\.{\\nonscript}') results in a |glue_node|
+ pointing to |zero_glue|, with |subtype(q)=cond_math_glue|; in such a case
+ the node following will be eliminated if it is a glue or kern node and if the
+ current size is different from |text_size|
- unconditional math glue (`\.{\\muskip}') is converted to normal glue by
- multiplying the dimensions by |cur_mu|
+ unconditional math glue (`\.{\\muskip}') is converted to normal glue by
+ multiplying the dimensions by |cur_mu|
- */
- if (subtype(q) == mu_glue) {
- math_glue_to_glue(q, cur_mu);
- } else if ((cur_size != text_size) && (subtype(q) == cond_math_glue)) {
- p = vlink(q);
- if (p != null)
- if ((type(p) == glue_node) || (type(p) == kern_node)) {
- if (vlink(p) != null) {
- couple_nodes(q,vlink(p));
- vlink(p) = null;
- } else {
- vlink(q) = null;
+ */
+ if (subtype(q) == mu_glue) {
+ math_glue_to_glue(q, cur_mu);
+ } else if ((cur_size != text_size) && (subtype(q) == cond_math_glue)) {
+ p = vlink(q);
+ if (p != null)
+ if ((type(p) == glue_node) || (type(p) == kern_node)) {
+ if (vlink(p) != null) {
+ couple_nodes(q,vlink(p));
+ vlink(p) = null;
+ } else {
+ vlink(q) = null;
+ }
+ flush_node_list(p);
}
- flush_node_list(p);
- }
- }
- goto DONE_WITH_NODE;
- break;
- case kern_node:
- math_kern(q, cur_mu);
- goto DONE_WITH_NODE;
- break;
- default:
- confusion("mlist1");
+ }
+ goto DONE_WITH_NODE;
+ break;
+ case kern_node:
+ math_kern(q, cur_mu);
+ goto DONE_WITH_NODE;
+ break;
+ default:
+ confusion("mlist1");
}
/*
When we get to the following part of the program, we have ``fallen through''
@@ -4077,7 +4151,11 @@ void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
when both are present.
*/
- p = check_nucleus_complexity(q, &delta, cur_style);
+same = 0 ;
+ p = check_nucleus_complexity(q, &delta, cur_style, &same);
+if (same) {
+ noadextra4(q) = same ;
+}
if ((subscr(q) == null) && (supscr(q) == null)) {
/*
Adding italic correction here is kind of fuzzy because some
@@ -4094,9 +4172,13 @@ void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
case open_noad_type:
case close_noad_type:
case punct_noad_type:
- case inner_noad_type:
delta = 0;
break;
+ case inner_noad_type:
+ if (! delimitermodeitalics) {
+ delta = 0;
+ }
+ break;
case op_noad_type_normal:
case op_noad_type_limits:
case op_noad_type_no_limits:
@@ -4110,6 +4192,7 @@ void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
}
if (delta != 0) {
pointer d = new_kern(delta);
+ subtype(d) = italic_kern;
reset_attributes(d, node_attr(q));
couple_nodes(p,d);
}
@@ -4178,15 +4261,18 @@ void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
t = simple_noad;
t_subtype = ord_noad_type;
pen = inf_penalty;
+ prepen = inf_penalty;
switch (type(q)) {
case simple_noad:
t_subtype = subtype(q);
switch (t_subtype) {
case bin_noad_type:
pen = bin_op_penalty_par;
+ prepen = pre_bin_op_penalty_par;
break;
case rel_noad_type:
pen = rel_penalty_par;
+ prepen = pre_rel_penalty_par;
break;
case vcenter_noad_type:
case over_noad_type:
@@ -4233,12 +4319,24 @@ void mlist_to_hlist(pointer mlist, boolean penalties, int cur_style)
/* Append inter-element spacing based on |r_type| and |t| */
if (r_type > 0) {
/* not the first noad */
+ pp = p;
+if (delimitermodeordinal && t_subtype == inner_noad_type && noadextra4(q) == 1) {
+ z = math_spacing_glue(r_subtype, ord_noad_type, cur_style, cur_mu);
+} else {
z = math_spacing_glue(r_subtype, t_subtype, cur_style, cur_mu);
+}
if (z != null) {
reset_attributes(z, node_attr(p));
couple_nodes(p,z);
p = z;
}
+ if (penalties && prepen < inf_penalty && type(pp) != penalty_node) {
+ /* no checking of prev node type */
+ z = new_penalty(prepen,noad_penalty);
+ reset_attributes(z, node_attr(p));
+ couple_nodes(p,z);
+ p = z;
+ }
}
/*
Append any |new_hlist| entries for |q|, and any appropriate penalties
diff --git a/Build/source/texk/web2c/luatexdir/tex/printing.w b/Build/source/texk/web2c/luatexdir/tex/printing.w
index 006392810b9..72444156480 100644
--- a/Build/source/texk/web2c/luatexdir/tex/printing.w
+++ b/Build/source/texk/web2c/luatexdir/tex/printing.w
@@ -838,25 +838,66 @@ int font_in_short_display; /* an internal font number */
sort of ``complicated'' are indicated only by printing `\.{[]}'.
@c
+
+/*
+So, 0, 1 as well as any large value will behave the same as before. The reason
+for this extension is that a \name not always makes sense.
+
+0 \foo xyz
+1 \foo (bar)
+2 <bar> xyz
+3 <bar @@ ..> xyz
+4 <id>
+5 <id: bar>
+6 <id: bar @@ ..> xyz
+
+*/
+
void print_font_identifier(internal_font_number f)
{
str_number fonttext;
fonttext = font_id_text(f);
- if (fonttext > 0) {
- print_esc(fonttext);
+ if (tracing_fonts_par >= 2 && tracing_fonts_par <= 6) {
+ /* < > is less likely to clash with text parenthesis */
+ tprint("<");
+ if (tracing_fonts_par >= 2 && tracing_fonts_par <= 3) {
+ print_font_name(f);
+ if (tracing_fonts_par >= 3 || font_size(f) != font_dsize(f)) {
+ tprint(" @@ ");
+ print_scaled(font_size(f));
+ tprint("pt");
+ }
+ } else if (tracing_fonts_par >= 4 && tracing_fonts_par <= 6) {
+ print_int(f);
+ if (tracing_fonts_par >= 5) {
+ tprint(": ");
+ print_font_name(f);
+ if (tracing_fonts_par >= 6 || font_size(f) != font_dsize(f)) {
+ tprint(" @@ ");
+ print_scaled(font_size(f));
+ tprint("pt");
+ }
+ }
+ }
+ print_char('>');
} else {
- tprint_esc("FONT");
- print_int(f);
- }
- if (tracing_fonts_par > 0) {
- tprint(" (");
- print_font_name(f);
- if (font_size(f) != font_dsize(f)) {
- tprint("@@");
- print_scaled(font_size(f));
- tprint("pt");
+ /* old method, inherited from pdftex */
+ if (fonttext > 0) {
+ print_esc(fonttext);
+ } else {
+ tprint_esc("FONT");
+ print_int(f);
+ }
+ if (tracing_fonts_par > 0) {
+ tprint(" (");
+ print_font_name(f);
+ if (font_size(f) != font_dsize(f)) {
+ tprint("@@");
+ print_scaled(font_size(f));
+ tprint("pt");
+ }
+ print_char(')');
}
- print_char(')');
}
}
diff --git a/Build/source/texk/web2c/luatexdir/tex/texfileio.w b/Build/source/texk/web2c/luatexdir/tex/texfileio.w
index 2281de12c4c..a10e9ba63d0 100644
--- a/Build/source/texk/web2c/luatexdir/tex/texfileio.w
+++ b/Build/source/texk/web2c/luatexdir/tex/texfileio.w
@@ -150,9 +150,6 @@ char *luatex_find_file(const char *s, int callback_index)
case find_enc_file_callback:
ftemp = kpse_find_file(s, kpse_enc_format, 0);
break;
- case find_sfd_file_callback:
- ftemp = kpse_find_file(s, kpse_sfd_format, 0);
- break;
case find_map_file_callback:
ftemp = kpse_find_file(s, kpse_fontmap_format, 0);
break;
@@ -967,13 +964,13 @@ void start_input(void)
update_terminal();
istate = new_line;
/* Prepare new file {\sl Sync\TeX} information */
- synctexstartinput(); /* Give control to the {\sl Sync\TeX} controller */
-
+ if (! synctex_get_no_files()) {
+ synctexstartinput(); /* Give control to the {\sl Sync\TeX} controller */
+ }
/* Read the first line of the new file */
/* Here we have to remember to tell the |lua_input_ln| routine not to
start with a |get|. If the file is empty, it is considered to
contain a single blank line. */
-
line = 1;
if (lua_input_ln(cur_file, 0, false)) {
;
diff --git a/Build/source/texk/web2c/luatexdir/tex/texmath.h b/Build/source/texk/web2c/luatexdir/tex/texmath.h
index e5ad6798257..24bb34dc977 100644
--- a/Build/source/texk/web2c/luatexdir/tex/texmath.h
+++ b/Build/source/texk/web2c/luatexdir/tex/texmath.h
@@ -70,6 +70,7 @@ extern void math_ac(void);
extern pointer new_style(small_number);
extern void append_choices(void);
extern void sub_sup(void);
+extern void no_sub_sup(void);
extern void math_fraction(void);
extern void math_left_right(void);
extern void after_math(void);
diff --git a/Build/source/texk/web2c/luatexdir/tex/texmath.w b/Build/source/texk/web2c/luatexdir/tex/texmath.w
index eeeb75bd792..6d4b87a3864 100644
--- a/Build/source/texk/web2c/luatexdir/tex/texmath.w
+++ b/Build/source/texk/web2c/luatexdir/tex/texmath.w
@@ -1353,6 +1353,17 @@ is sufficiently large, the |cur_chr| is treated as an active character and
nothing is appended.
@c
+#define math_class_to_type(target,source) \
+ switch (source) { \
+ case 0: target = ord_noad_type; break; \
+ case 1: target = op_noad_type_normal; break; \
+ case 2: target = bin_noad_type; break; \
+ case 3: target = rel_noad_type; break; \
+ case 4: target = open_noad_type; break; \
+ case 5: target = close_noad_type; break; \
+ case 6: target = punct_noad_type; break; \
+ }
+
void set_math_char(mathcodeval mval)
{
pointer p; /* the new noad */
@@ -1375,17 +1386,7 @@ void set_math_char(mathcodeval mval)
math_fam(nucleus(p)) = cur_fam_par;
subtype(p) = ord_noad_type;
} else {
- switch (mval.class_value) {
- /* *INDENT-OFF* */
- case 0: subtype(p) = ord_noad_type; break;
- case 1: subtype(p) = op_noad_type_normal; break;
- case 2: subtype(p) = bin_noad_type; break;
- case 3: subtype(p) = rel_noad_type; break;
- case 4: subtype(p) = open_noad_type; break;
- case 5: subtype(p) = close_noad_type; break;
- case 6: subtype(p) = punct_noad_type; break;
- /* *INDENT-ON* */
- }
+ math_class_to_type(subtype(p),mval.class_value);
}
vlink(tail) = p;
tail = p;
@@ -1727,7 +1728,7 @@ void build_choices(void)
action procedure called |sub_sup|.
@c
-void sub_sup(void)
+static void do_sub_sup(int no)
{
pointer q;
if (tail == head || (!scripts_allowed(tail))) {
@@ -1745,6 +1746,9 @@ void sub_sup(void)
nucleus(tail) = q;
tex_error("Double superscript", hlp);
}
+ if (no) {
+ noadoptions(tail) = noadoptions(tail) | noad_option_no_super_script ;
+ }
q = new_node(math_char_node, 0);
supscr(tail) = q;
(void) scan_math(supscr(tail), sup_style(m_style));
@@ -1758,12 +1762,26 @@ void sub_sup(void)
nucleus(tail) = q;
tex_error("Double subscript", hlp);
}
+ if (no) {
+ noadoptions(tail) = noadoptions(tail) | noad_option_no_sub_script ;
+ }
q = new_node(math_char_node, 0);
subscr(tail) = q;
(void) scan_math(subscr(tail), sub_style(m_style));
}
}
+void sub_sup(void)
+{
+ do_sub_sup(0);
+}
+
+void no_sub_sup(void)
+{
+ do_sub_sup(1);
+}
+
+
@ An operation like `\.{\\over}' causes the current mlist to go into a
state of suspended animation: |incompleat_noad| points to a |fraction_noad|
that contains the mlist-so-far as its numerator, while the denominator
@@ -1991,7 +2009,7 @@ void math_left_right(void)
options = options | noad_option_exact ;
} else if (scan_keyword("class")) {
scan_int();
- type = cur_val ;
+ math_class_to_type(type,cur_val);
} else {
break;
}
@@ -2029,9 +2047,9 @@ void math_left_right(void)
delimiteroptions(p) = options;
delimiterclass(p) = type;
delimiteritalic(p) = 0;
+ delimitersamesize(p) = 0;
scan_delimiter(delimiter(p), no_mathcode);
-
if (t == no_noad_side) {
tail_append(new_noad());
subtype(tail) = inner_noad_type;
@@ -2133,36 +2151,41 @@ At this time we are in vertical mode (or internal vertical mode).
@c
#define inject_display_skip_before(g) \
- switch (display_skip_mode_par) { \
- case 0 : /* normal tex */ \
- tail_append(new_param_glue(g)); \
- break;\
- case 1 : /* always */ \
- tail_append(new_param_glue(g)); \
- break; \
- case 2 : /* non-zero */ \
- if (g != 0 && ! glue_is_zero(glue_par(g))) \
+ if (g > 0) { \
+ switch (display_skip_mode_par) { \
+ case 0 : /* normal tex | always */ \
+ case 1 : /* always */ \
+ tail_append(new_param_glue(g)); \
+ break; \
+ case 2 : /* non-zero */ \
+ if (! glue_is_zero(glue_par(g))) \
+ tail_append(new_param_glue(g)); \
+ break; \
+ case 3: /* ignore */ \
+ break; \
+ default: /* > 3 reserved for future use */ \
tail_append(new_param_glue(g)); \
- break; \
- case 3: /* ignore */ \
- break; \
+ break; \
+ } \
}
#define inject_display_skip_after(g) \
- switch (display_skip_mode_par) { \
- case 0 : /* normal tex */ \
- if (g != 0 && glue_is_positive(glue_par(g))) \
+ if (g > 0) { \
+ switch (display_skip_mode_par) { \
+ case 0 : /* normal tex | always */ \
+ case 1 : /* always */ \
tail_append(new_param_glue(g)); \
- break; \
- case 1 : /* always */ \
- tail_append(new_param_glue(g)); \
- break; \
- case 2 : /* non-zero */ \
- if (g != 0 && ! glue_is_zero(glue_par(g))) \
+ break; \
+ case 2 : /* non-zero */ \
+ if (! glue_is_zero(glue_par(g))) \
+ tail_append(new_param_glue(g)); \
+ break; \
+ case 3: /* ignore */ \
+ break; \
+ default: /* > 3 reserved for future use */ \
tail_append(new_param_glue(g)); \
- break; \
- case 3: /* ignore */ \
- break; \
+ break; \
+ } \
}
static void finish_displayed_math(boolean l, pointer eqno_box, pointer p)
diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.h b/Build/source/texk/web2c/luatexdir/tex/texnodes.h
index b838dd0a2f9..2bdd432e570 100644
--- a/Build/source/texk/web2c/luatexdir/tex/texnodes.h
+++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.h
@@ -23,19 +23,6 @@
#ifndef __NODES_H__
# define __NODES_H__
-/* these are in texlang.c */
-
-# define set_vlink(a,b) vlink(a)=b
-# define get_vlink(a) vlink(a)
-# define get_character(a) character(a)
-
-extern halfword insert_discretionary(halfword t, halfword pre, halfword post, halfword replace, int penalty);
-extern halfword insert_syllable_discretionary(halfword t, lang_variables * lan);
-extern halfword insert_word_discretionary(halfword t, lang_variables * lan);
-extern halfword insert_complex_discretionary(halfword t, lang_variables * lan, halfword pre, halfword post, halfword replace);
-extern halfword insert_character(halfword t, int n);
-extern void set_disc_field(halfword f, halfword t);
-
# define varmemcast(a) (memory_word *)(a)
extern memory_word *volatile varmem;
@@ -297,15 +284,17 @@ typedef enum {
# define adjust_pre subtype
# define adjust_ptr(a) vlink(a+2)
-# define glyph_node_size 6
-# define character(a) vinfo((a)+2)
-# define font(a) vlink((a)+2)
-# define lang_data(a) vinfo((a)+3)
-# define lig_ptr(a) vlink((a)+3)
-# define x_displace(a) vinfo((a)+4)
-# define y_displace(a) vlink((a)+4)
-# define ex_glyph(a) vinfo((a)+5) /* expansion factor (hz) */
-# define x_advance(a) vlink((a)+5)
+# define glyph_node_size 7
+# define character(a) vinfo((a)+2)
+# define font(a) vlink((a)+2)
+# define lang_data(a) vinfo((a)+3)
+# define lig_ptr(a) vlink((a)+3)
+# define x_displace(a) vinfo((a)+4)
+# define y_displace(a) vlink((a)+4)
+# define ex_glyph(a) vinfo((a)+5) /* expansion factor (hz) */
+# define x_advance(a) vlink((a)+5) /* obsolete, can become user field */
+# define synctex_tag_glyph(a) vinfo((a)+6)
+# define synctex_line_glyph(a) vlink((a)+6)
# define is_char_node(a) (a!=null && type(a)==glyph_node)
@@ -432,6 +421,8 @@ typedef enum {
*/
# define precedes_break(a) (type(a)<=last_preceding_break_node)
+# define precedes_kern(a) ((type(a) == kern_node) && (subtype(a) == font_kern || subtype(a) == accent_kern))
+# define precedes_dir(a) ((type(a) == dir_node) && (break_after_dir_mode_par == 1))
# define non_discardable(a) (type(a)<=last_non_discardable_node)
# define known_node_type(i) ( i >= 0 && i <= MAX_NODE_TYPE)
@@ -492,9 +483,9 @@ typedef enum {
# define noadheight(a) vlink((a)+5)
# define noaddepth(a) vinfo((a)+5)
# define noadextra1(a) vlink((a)+6) /* we need to match delimiter (saves copy) */
-# define noadextra2(a) vinfo((a)+6)
+# define noadoptions(a) vinfo((a)+6)
# define noadextra3(a) vlink((a)+7) /* see (!) below */
-# define noadextra4(a) vinfo((a)+7)
+# define noadextra4(a) vinfo((a)+7) /* used to store samesize */
/* accent noads */
@@ -506,28 +497,31 @@ typedef enum {
/* left and right noads */
-# define fence_noad_size 8 /* needs to match noad size */
-# define delimiteritalic(a) vlink((a)+4)
-/* define delimiterwidth(a) vinfo((a)+4) */
-# define delimiterheight(a) vlink((a)+5)
-# define delimiterdepth(a) vinfo((a)+5)
-# define delimiter(a) vlink((a)+6) /* |delimiter| field in left and right noads */
-# define delimiteroptions(a) vinfo((a)+6)
-# define delimiterclass(a) vlink((a)+7) /* (!) we could probably pack some more in 6 */
-# define delimiterextra1(a) vinfo((a)+7) /* not used */
+# define fence_noad_size 8 /* needs to match noad size */
+# define delimiteritalic(a) vlink((a)+4)
+/* define delimiterwidth(a) vinfo((a)+4) */
+# define delimiterheight(a) vlink((a)+5)
+# define delimiterdepth(a) vinfo((a)+5)
+# define delimiter(a) vlink((a)+6) /* |delimiter| field in left and right noads */
+# define delimiteroptions(a) vinfo((a)+6)
+# define delimiterclass(a) vlink((a)+7) /* (!) we could probably pack some more in 6 */
+# define delimitersamesize(a) vinfo((a)+7) /* set by engine */
/* when dimensions then axis else noaxis */
typedef enum {
- noad_option_set = 0x08,
- noad_option_unused_1 = 0x00 + 0x08,
- noad_option_unused_2 = 0x01 + 0x08,
- noad_option_axis = 0x02 + 0x08,
- noad_option_no_axis = 0x04 + 0x08,
- noad_option_exact = 0x10 + 0x08,
- noad_option_left = 0x11 + 0x08,
- noad_option_middle = 0x12 + 0x08,
- noad_option_right = 0x14 + 0x08,
+ noad_option_set = 0x08,
+ noad_option_unused_1 = 0x00 + 0x08,
+ noad_option_unused_2 = 0x01 + 0x08,
+ noad_option_axis = 0x02 + 0x08,
+ noad_option_no_axis = 0x04 + 0x08,
+ noad_option_exact = 0x10 + 0x08,
+ noad_option_left = 0x11 + 0x08,
+ noad_option_middle = 0x12 + 0x08,
+ noad_option_right = 0x14 + 0x08,
+ noad_option_no_sub_script = 0x21 + 0x08,
+ noad_option_no_super_script = 0x22 + 0x08,
+ noad_option_no_script = 0x23 + 0x08,
} delimiter_options ;
# define delimiteroptionset(a) ((delimiteroptions(a) & noad_option_set ) == noad_option_set )
@@ -535,6 +529,23 @@ typedef enum {
# define delimiternoaxis(a) ((delimiteroptions(a) & noad_option_no_axis) == noad_option_no_axis)
# define delimiterexact(a) ((delimiteroptions(a) & noad_option_exact ) == noad_option_exact )
+# define noadoptionnosubscript(a) ( (type(a) == simple_noad) && ( \
+ ((delimiteroptions(a) & noad_option_no_sub_script ) == noad_option_no_sub_script) || \
+ ((delimiteroptions(a) & noad_option_no_script ) == noad_option_no_script ) ))
+# define noadoptionnosupscript(a) ( (type(a) == simple_noad) && ( \
+ ((delimiteroptions(a) & noad_option_no_super_script) == noad_option_no_super_script) || \
+ ((delimiteroptions(a) & noad_option_no_script ) == noad_option_no_script ) ))
+
+typedef enum {
+ noad_delimiter_mode_noshift = 0x01,
+ noad_delimiter_mode_italics = 0x02,
+ noad_delimiter_mode_ordinal = 0x04,
+} delimiter_modes ;
+
+# define delimitermodenoshift ((math_delimiters_mode_par & noad_delimiter_mode_noshift) == noad_delimiter_mode_noshift)
+# define delimitermodeitalics ((math_delimiters_mode_par & noad_delimiter_mode_italics) == noad_delimiter_mode_italics)
+# define delimitermodeordinal ((math_delimiters_mode_par & noad_delimiter_mode_ordinal) == noad_delimiter_mode_ordinal)
+
/* subtype of fence noads */
# define left_noad_side 1
@@ -928,7 +939,7 @@ extern halfword do_copy_node_list(halfword, halfword);
extern halfword copy_node_list(halfword);
extern halfword copy_node(const halfword);
extern void check_node(halfword);
-extern void fix_node_list(halfword);
+extern halfword fix_node_list(halfword);
extern int fix_node_lists;
extern char *sprint_node_mem_usage(void);
extern halfword raw_glyph_node(void);
@@ -1013,5 +1024,16 @@ extern int lua_properties_use_metatable ;
extern halfword make_local_par_node(int mode);
+extern void synctex_set_mode(int mode);
+extern int synctex_get_mode(void);
+extern void synctex_set_tag(int tag);
+extern void synctex_set_line(int line);
+extern void synctex_force_tag(int tag);
+extern void synctex_force_line(int tag);
+extern int synctex_get_tag(void);
+extern void synctex_set_no_files(int flag);
+extern int synctex_get_no_files(void);
+extern int synctex_get_line(void);
+
#endif
diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.w b/Build/source/texk/web2c/luatexdir/tex/texnodes.w
index 7967006ec35..d0008b08fc8 100644
--- a/Build/source/texk/web2c/luatexdir/tex/texnodes.w
+++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.w
@@ -656,11 +656,14 @@ static int test_count = 1;
#define check_action_ref(a) { dorangetest(p,a,var_mem_max); }
#define check_attribute_ref(a) { dorangetest(p,a,var_mem_max); }
-#define check_token_ref(a) { \
+
+/* hm, we can just pass p then */
+
+#define check_token_ref(p) { \
if (type(p) == whatsit_node) { \
- formatted_error("nodes","fuzzy token cleanup in whatsit node with id %i and subtype %i",type(p),subtype(p)); \
+ formatted_error("nodes","fuzzy token cleanup in whatsit node with type %s and subtype %i",node_data[type(p)].name,subtype(p)); \
} else { \
- formatted_error("nodes","fuzzy token cleanup in node with id %i",type(p)); \
+ formatted_error("nodes","fuzzy token cleanup in node with type %s",node_data[type(p)].name); \
} \
}
@@ -828,6 +831,67 @@ static int copy_error(halfword p)
}
@ @c
+static halfword synctex_anyway_mode = 0; /* 2 also glyphs */
+static halfword synctex_line_field = 0;
+static halfword synctex_no_files = 0;
+
+void synctex_set_mode(int m)
+{
+ synctex_anyway_mode = m;
+};
+
+int synctex_get_mode(void)
+{
+ return synctex_anyway_mode;
+};
+
+void synctex_set_no_files(int f)
+{
+ synctex_no_files = f;
+};
+
+int synctex_get_no_files(void)
+{
+ return (int) synctex_no_files ;
+};
+
+void synctex_set_tag(int t)
+{
+ cur_input.synctex_tag_field = t;
+};
+
+int synctex_get_tag(void)
+{
+ return (int) cur_input.synctex_tag_field;
+};
+
+
+int synctex_get_line(void)
+{
+ return (int) synctex_line_field;
+};
+
+static int forced_tag = 0;
+static int forced_line = 0;
+
+void synctex_force_tag(int t)
+{
+ forced_tag = t;
+};
+
+void synctex_force_line(int t)
+{
+ forced_line = t;
+};
+
+void synctex_set_line(int l)
+{
+ synctex_line_field = l;
+};
+
+@ @c
+/* if_stack is called a lot so maybe optimize */
+
halfword new_node(int i, int j)
{
int s = get_node_size(i, j);
@@ -892,13 +956,54 @@ halfword new_node(int i, int j)
default:
break;
}
- if (synctex_par) {
- /* handle synctex extension */
+ if (synctex_anyway_mode) {
switch (i) {
- case math_node:
- synctex_tag_math(n) = cur_input.synctex_tag_field;
- synctex_line_math(n) = line;
+ /* 1 = all but glyphs */
+ /* 2 = also glyphs */
+ /* 3 = glyphs and glue */
+ /* 4 = only glyphs */
+ case glyph_node:
+ if (synctex_anyway_mode > 1) {
+ synctex_tag_glyph(n) = forced_tag ? forced_tag : cur_input.synctex_tag_field;
+ synctex_line_glyph(n) = forced_line ? forced_line : synctex_line_field ? synctex_line_field : line;
+ }
+ break;
+ case glue_node:
+ if (synctex_anyway_mode < 4) {
+ synctex_tag_glue(n) = forced_tag ? forced_tag : cur_input.synctex_tag_field;
+ synctex_line_glue(n) = forced_line ? forced_line : synctex_line_field ? synctex_line_field : line;
+ }
+ break;
+ case kern_node:
+ if (synctex_anyway_mode < 3) {
+ synctex_tag_kern(n) = forced_tag ? forced_tag : cur_input.synctex_tag_field;
+ synctex_line_kern(n) = forced_line ? forced_line : synctex_line_field ? synctex_line_field : line;
+ }
+ break;
+ case hlist_node:
+ case vlist_node:
+ case unset_node: /* useless */
+ if (synctex_anyway_mode < 3) {
+ synctex_tag_box(n) = forced_tag ? forced_tag : cur_input.synctex_tag_field;
+ synctex_line_box(n) = forced_line ? forced_line : synctex_line_field ? synctex_line_field : line;
+ }
+ break;
+ case rule_node:
+ if (synctex_anyway_mode < 3) {
+ synctex_tag_rule(n) = forced_tag ? forced_tag : cur_input.synctex_tag_field;
+ synctex_line_rule(n) = forced_line ? forced_line : synctex_line_field ? synctex_line_field : line;
+ }
break;
+ case math_node: /* noads probably make more sense */
+ if (synctex_anyway_mode < 3) {
+ synctex_tag_math(n) = forced_tag ? forced_tag : cur_input.synctex_tag_field;
+ synctex_line_math(n) = forced_line ? forced_line : synctex_line_field ? synctex_line_field : line;
+ }
+ break;
+ }
+ } else if (synctex_par) {
+ /* handle synctex extension */
+ switch (i) {
case glue_node:
synctex_tag_glue(n) = cur_input.synctex_tag_field;
synctex_line_glue(n) = line;
@@ -919,6 +1024,10 @@ halfword new_node(int i, int j)
synctex_tag_rule(n) = cur_input.synctex_tag_field;
synctex_line_rule(n) = line;
break;
+ case math_node:
+ synctex_tag_math(n) = cur_input.synctex_tag_field;
+ synctex_line_math(n) = line;
+ break;
}
}
/* take care of attributes */
@@ -935,6 +1044,10 @@ halfword raw_glyph_node(void)
{
register halfword n = get_node(glyph_node_size);
(void) memset((void *) (varmem + n + 1), 0, (sizeof(memory_word) * (glyph_node_size - 1)));
+ if (synctex_anyway_mode > 1) {
+ synctex_tag_glyph(n) = forced_tag ? forced_tag : cur_input.synctex_tag_field;
+ synctex_line_glyph(n) = forced_line ? forced_line : synctex_line_field ? synctex_line_field : line;
+ }
type(n) = glyph_node;
subtype(n) = 0;
return n;
@@ -944,6 +1057,10 @@ halfword new_glyph_node(void)
{
register halfword n = get_node(glyph_node_size);
(void) memset((void *) (varmem + n + 1), 0, (sizeof(memory_word) * (glyph_node_size - 1)));
+ if (synctex_anyway_mode > 1) {
+ synctex_tag_glyph(n) = forced_tag ? forced_tag : cur_input.synctex_tag_field;
+ synctex_line_glyph(n) = forced_line ? forced_line : synctex_line_field ? synctex_line_field : line;
+ }
type(n) = glyph_node;
subtype(n) = 0;
build_attribute_list(n);
@@ -1102,7 +1219,16 @@ halfword copy_node(const halfword p)
}
*/
- if (synctex_par) {
+ if (synctex_anyway_mode) {
+ /*
+ if (t == glyph_node) {
+ if (synctex_anyway_mode > 1) {
+ synctex_tag_glyph(r) = forced_tag ? forced_tag : cur_input.synctex_tag_field;
+ synctex_line_glyph(r) = forced_line ? forced_line : synctex_line_field ? synctex_line_field : line;
+ }
+ }
+ */
+ } else if (synctex_par) {
/* handle synctex extension */
switch (t) {
case math_node:
@@ -1520,7 +1646,7 @@ static void check_node_wrapup_core(halfword p)
switch (subtype(p)) {
/* frontend code */
case special_node:
- check_token_ref(write_tokens(p));
+ check_token_ref(p);
break;
case user_defined_node:
switch (user_node_type(p)) {
@@ -1528,7 +1654,7 @@ static void check_node_wrapup_core(halfword p)
check_attribute_ref(user_node_value(p));
break;
case 't':
- check_token_ref(user_node_value(p));
+ check_token_ref(p);
break;
case 'n':
dorangetest(p, user_node_value(p), var_mem_max);
@@ -1558,39 +1684,39 @@ void check_node_wrapup_pdf(halfword p)
switch (subtype(p)) {
case pdf_literal_node:
if (pdf_literal_type(p) == normal)
- check_token_ref(pdf_literal_data(p));
+ check_token_ref(p);
break;
case pdf_colorstack_node:
if (pdf_colorstack_cmd(p) <= colorstack_data)
- check_token_ref(pdf_colorstack_data(p));
+ check_token_ref(p);
break;
case pdf_setmatrix_node:
- check_token_ref(pdf_setmatrix_data(p));
+ check_token_ref(p);
break;
case late_lua_node:
if (late_lua_name(p) > 0)
- check_token_ref(late_lua_name(p));
+ check_token_ref(p);
if (late_lua_type(p) == normal)
- check_token_ref(late_lua_data(p));
+ check_token_ref(p);
break;
case pdf_annot_node:
- check_token_ref(pdf_annot_data(p));
+ check_token_ref(p);
break;
case pdf_start_link_node:
if (pdf_link_attr(p) != null)
- check_token_ref(pdf_link_attr(p));
+ check_token_ref(p);
check_action_ref(pdf_link_action(p));
break;
case pdf_dest_node:
if (pdf_dest_named_id(p) > 0)
- check_token_ref(pdf_dest_id(p));
+ check_token_ref(p);
break;
case pdf_thread_node:
case pdf_start_thread_node:
if (pdf_thread_named_id(p) > 0)
- check_token_ref(pdf_thread_id(p));
+ check_token_ref(p);
if (pdf_thread_attr(p) != null)
- check_token_ref(pdf_thread_attr(p));
+ check_token_ref(p);
break;
case pdf_save_node:
case pdf_restore_node:
@@ -1718,18 +1844,19 @@ void check_node(halfword p)
}
@ @c
-void fix_node_list(halfword head)
+halfword fix_node_list(halfword head)
{
- halfword p, q;
+ halfword next, tail;
if (head == null)
- return;
- p = head;
- q = vlink(p);
- while (q != null) {
- alink(q) = p;
- p = q;
- q = vlink(p);
+ return null;
+ tail = head;
+ next = vlink(head);
+ while (next != null) {
+ alink(next) = tail;
+ tail = next;
+ next = vlink(tail);
}
+ return tail;
}
@ @c
diff --git a/Build/source/texk/web2c/luatexdir/tex/textoken.w b/Build/source/texk/web2c/luatexdir/tex/textoken.w
index f0b6a0c6e75..bf14a96148e 100644
--- a/Build/source/texk/web2c/luatexdir/tex/textoken.w
+++ b/Build/source/texk/web2c/luatexdir/tex/textoken.w
@@ -2311,6 +2311,7 @@ static int do_variable_pdf(halfword c)
else if (scan_keyword("imageresolution")) { do_variable_backend_int(c_pdf_image_resolution); }
else if (scan_keyword("pkresolution")) { do_variable_backend_int(c_pdf_pk_resolution); }
else if (scan_keyword("uniqueresname")) { do_variable_backend_int(c_pdf_unique_resname); }
+ else if (scan_keyword("majorversion")) { do_variable_backend_int(c_pdf_major_version); }
else if (scan_keyword("minorversion")) { do_variable_backend_int(c_pdf_minor_version); }
else if (scan_keyword("pagebox")) { do_variable_backend_int(c_pdf_pagebox); }
else if (scan_keyword("inclusionerrorlevel")) { do_variable_backend_int(c_pdf_inclusion_errorlevel); }
@@ -2775,11 +2776,6 @@ void conv_toks(void)
print(get_luatexrevision());
pop_selector;
break;
- case luatex_date_code:
- push_selector;
- print_int(get_luatex_date_info());
- pop_selector;
- break;
case etex_code:
push_selector;
tprint(eTeX_version_string);
@@ -3008,9 +3004,6 @@ str_number the_convert_string(halfword c, int i)
case luatex_revision_code:
print(get_luatexrevision());
break;
- case luatex_date_code:
- print_int(get_luatex_date_info());
- break;
case etex_code:
tprint(eTeX_version_string);
break;
diff --git a/Build/source/texk/web2c/luatexdir/utils/utils.w b/Build/source/texk/web2c/luatexdir/utils/utils.w
index e947fb77df5..420f5cfe4e4 100644
--- a/Build/source/texk/web2c/luatexdir/utils/utils.w
+++ b/Build/source/texk/web2c/luatexdir/utils/utils.w
@@ -36,6 +36,7 @@
#include "md5.h"
#include "lua/luatex-api.h" /* for luatex_banner */
+#include "luatex_svnversion.h"
#include "png.h"
#include "mplib.h"
@@ -250,24 +251,39 @@ char *stripzeros(char *a)
@ @c
void initversionstring(char **versions)
{
+#ifdef LuajitTeX
+#define LUA_VER_STRING LUAJIT_VERSION
+#else
+#define LUA_VER_STRING "lua version " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "." LUA_VERSION_RELEASE
+#endif
+#define STR(tok) STR2(tok)
+#define STR2(tok) #tok
const_string fmt =
"Compiled with libpng %s; using %s\n"
- "Compiled with zlib %s; using %s\n"
+ "Compiled with %s\n" /* Lua or LuaJIT */
+ "Compiled with mplib version %s\n"
"Compiled with poppler version %s\n"
- "Compiled with mplib version %s\n";
+ "Compiled with zlib %s; using %s\n"
+ "\nDevelopment id: %s\n";
size_t len = strlen(fmt)
+ strlen(PNG_LIBPNG_VER_STRING) + strlen(png_libpng_ver)
- + strlen(ZLIB_VERSION) + strlen(zlib_version)
- + strlen(POPPLER_VERSION)
+ + strlen(LUA_VER_STRING)
+ strlen(mp_metapost_version())
+ + strlen(POPPLER_VERSION)
+ + strlen(ZLIB_VERSION) + strlen(zlib_version)
+ + strlen(STR(luatex_svn_revision))
+ 1;
/* len will be more than enough, because of the placeholder chars in fmt
that get replaced by the arguments. */
*versions = xmalloc(len);
sprintf(*versions, fmt,
- PNG_LIBPNG_VER_STRING, png_libpng_ver,
- ZLIB_VERSION, zlib_version, POPPLER_VERSION, mp_metapost_version());
+ PNG_LIBPNG_VER_STRING, png_libpng_ver, LUA_VER_STRING,
+ mp_metapost_version(),POPPLER_VERSION,
+ ZLIB_VERSION, zlib_version,STR(luatex_svn_revision));
+#undef STR2
+#undef STR
+#undef LUA_VER_STRING
}
@ @c
@@ -358,9 +374,9 @@ int do_zround(double r)
}
-@ MSVC doesn't have |rint|.
+@ Old MSVC doesn't have |rint|.
@c
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && _MSC_VER <= 1600
# include <math.h>
double rint(double x)