diff options
Diffstat (limited to 'Build/source')
154 files changed, 8038 insertions, 8013 deletions
diff --git a/Build/source/libs/lua53/ChangeLog b/Build/source/libs/lua53/ChangeLog index 8ef10ff28bb..d5c4b88bcd1 100644 --- a/Build/source/libs/lua53/ChangeLog +++ b/Build/source/libs/lua53/ChangeLog @@ -1,3 +1,14 @@ +2018-07-21 Luigi Scarso <luigi.scarso@gmail.com> + + * Adapted for Lua 5.3.5 + + +2018-06-18 Luigi Scarso <luigi.scarso@gmail.com> + + * dropped poppler, new pplib from + http://eurydyka.kaliope.org.pl/~pawel/libpp/html/ppapi.html + + 2017-10-24 Luigi Scarso <luigi.scarso@gmail.com> * Adapted for Lua 5.3.4 diff --git a/Build/source/libs/lua53/Makefile.am b/Build/source/libs/lua53/Makefile.am index a7994ea5a39..f736ce9a328 100644 --- a/Build/source/libs/lua53/Makefile.am +++ b/Build/source/libs/lua53/Makefile.am @@ -65,6 +65,7 @@ nodist_libtexlua53_la_SOURCES = \ @LUA53_TREE@/src/lvm.c \ @LUA53_TREE@/src/lzio.c + lua53includedir = ${includedir}/texlua53 lua53include_HEADERS = \ diff --git a/Build/source/libs/lua53/TLpatches/ChangeLog b/Build/source/libs/lua53/TLpatches/ChangeLog index 882ddcdde9e..dd2bcb2f07b 100644 --- a/Build/source/libs/lua53/TLpatches/ChangeLog +++ b/Build/source/libs/lua53/TLpatches/ChangeLog @@ -1,3 +1,7 @@ +2018-07-21 Luigi Scarso <luigi.scarso@gmail.com> + Adapted for lua 5.3.5 + + 2017-10-24 Luigi Scarso <luigi.scarso@gmail.com> Adapted for lua 5.3.4 diff --git a/Build/source/libs/lua53/TLpatches/patch-01-utf-8 b/Build/source/libs/lua53/TLpatches/patch-01-utf-8 index f2ac4013430..0f7cb898128 100644 --- a/Build/source/libs/lua53/TLpatches/patch-01-utf-8 +++ b/Build/source/libs/lua53/TLpatches/patch-01-utf-8 @@ -1,7 +1,16 @@ -diff -ur lua-5.3.4.orig/src/lctype.h lua-5.3.4/src/lctype.h ---- lctype.h.orig 2017-10-24 15:14:50.724139638 +0200 -+++ lctype.h 2017-10-24 15:15:51.704137138 +0200 -@@ -53,9 +53,11 @@ +diff -u lctype.h.orig lctype.h +--- lctype.h.orig 2018-07-21 09:57:36.061692228 +0200 ++++ lctype.h 2018-07-21 10:03:29.625677730 +0200 +@@ -7,6 +7,8 @@ + #ifndef lctype_h + #define lctype_h + ++#include <ctype.h> ++ + #include "lua.h" + + +@@ -53,9 +55,11 @@ /* ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' diff --git a/Build/source/libs/lua53/TLpatches/patch-02-FreeBSD b/Build/source/libs/lua53/TLpatches/patch-02-FreeBSD index fc59f4842a3..ad85a5988d8 100644 --- a/Build/source/libs/lua53/TLpatches/patch-02-FreeBSD +++ b/Build/source/libs/lua53/TLpatches/patch-02-FreeBSD @@ -1,6 +1,6 @@ -diff -ur liolib.c.orig liolib.c ---- liolib.c.orig 2017-10-24 15:16:06.036136550 +0200 -+++ liolib.c 2017-10-24 15:16:49.968134748 +0200 +diff -u liolib.c.orig liolib.c +--- liolib.c.orig 2017-04-19 19:29:57.000000000 +0200 ++++ liolib.c 2018-07-21 10:04:50.965674394 +0200 @@ -16,6 +16,9 @@ #include <stdio.h> #include <stdlib.h> diff --git a/Build/source/libs/lua53/TLpatches/patch-03-export b/Build/source/libs/lua53/TLpatches/patch-03-export index dda2b87b24c..9bc2a4627fc 100644 --- a/Build/source/libs/lua53/TLpatches/patch-03-export +++ b/Build/source/libs/lua53/TLpatches/patch-03-export @@ -1,6 +1,6 @@ -diff -ur lopcodes.h.orig lopcodes.h ---- lopcodes.h.orig 2017-10-24 15:22:51.012119943 +0200 -+++ lopcodes.h 2017-10-24 15:18:37.924130321 +0200 +diff -u lopcodes.h.orig lopcodes.h +--- lopcodes.h.orig 2018-07-21 09:59:37.349687255 +0200 ++++ lopcodes.h 2018-07-21 10:07:04.413668921 +0200 @@ -278,7 +278,7 @@ OpArgK /* argument is a constant or register/constant */ }; @@ -20,9 +20,10 @@ diff -ur lopcodes.h.orig lopcodes.h /* number of list items to accumulate before a SETLIST instruction */ -diff -ur lundump.h.orig lundump.h ---- lundump.h.orig 2017-10-24 15:19:03.860129258 +0200 -+++ lundump.h 2017-10-24 15:19:47.088127485 +0200 + +diff -u lundump.h.orig lundump.h +--- lundump.h.orig 2018-07-21 10:00:01.545686262 +0200 ++++ lundump.h 2018-07-21 10:08:12.341666136 +0200 @@ -26,7 +26,7 @@ LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name); @@ -32,4 +33,3 @@ diff -ur lundump.h.orig lundump.h void* data, int strip); #endif - diff --git a/Build/source/libs/lua53/lua53-src/README b/Build/source/libs/lua53/lua53-src/README index 0b31908a06c..ed424defe02 100644 --- a/Build/source/libs/lua53/lua53-src/README +++ b/Build/source/libs/lua53/lua53-src/README @@ -1,5 +1,5 @@ -This is Lua 5.3.4, released on 12 Jan 2017. +This is Lua 5.3.5, released on 26 Jun 2018. For installation instructions, license details, and further information about Lua, see doc/readme.html. diff --git a/Build/source/libs/lua53/lua53-src/doc/contents.html b/Build/source/libs/lua53/lua53-src/doc/contents.html index 445556f9641..c4eb2677906 100644 --- a/Build/source/libs/lua53/lua53-src/doc/contents.html +++ b/Build/source/libs/lua53/lua53-src/doc/contents.html @@ -32,7 +32,7 @@ For a complete introduction to Lua programming, see the book <P> <SMALL> -Copyright © 2015–2017 Lua.org, PUC-Rio. +Copyright © 2015–2018 Lua.org, PUC-Rio. Freely available under the terms of the <A HREF="http://www.lua.org/license.html">Lua license</A>. </SMALL> @@ -609,10 +609,10 @@ Freely available under the terms of the <P CLASS="footer"> Last update: -Thu Dec 22 18:29:39 BRST 2016 +Mon Jun 18 22:56:06 -03 2018 </P> <!-- -Last change: revised for Lua 5.3.4 +Last change: revised for Lua 5.3.5 --> </BODY> diff --git a/Build/source/libs/lua53/lua53-src/doc/lua.css b/Build/source/libs/lua53/lua53-src/doc/lua.css index 5bedf7eb898..cbd0799d152 100644 --- a/Build/source/libs/lua53/lua53-src/doc/lua.css +++ b/Build/source/libs/lua53/lua53-src/doc/lua.css @@ -10,7 +10,7 @@ body { line-height: 1.25 ; margin: 16px auto ; padding: 32px ; - border: solid #a0a0a0 1px ; + border: solid #ccc 1px ; border-radius: 20px ; max-width: 70em ; width: 90% ; @@ -111,36 +111,29 @@ pre.session { border-radius: 8px ; } -td.gutter { - width: 4% ; -} - -table.columns { +table { border: none ; border-spacing: 0 ; border-collapse: collapse ; } -table.columns td { - vertical-align: top ; +td { padding: 0 ; - padding-bottom: 1em ; - text-align: justify ; - line-height: 1.25 ; + margin: 0 ; } -p.logos a:link:hover, p.logos a:visited:hover { - background-color: inherit ; +td.gutter { + width: 4% ; } -table.book { - border: none ; - border-spacing: 0 ; - border-collapse: collapse ; +table.columns td { + vertical-align: top ; + padding-bottom: 1em ; + text-align: justify ; + line-height: 1.25 ; } table.book td { - padding: 0 ; vertical-align: top ; } @@ -159,6 +152,10 @@ table.book span { margin-top: 0.25em ; } +p.logos a:link:hover, p.logos a:visited:hover { + background-color: inherit ; +} + img { background-color: white ; } diff --git a/Build/source/libs/lua53/lua53-src/doc/manual.html b/Build/source/libs/lua53/lua53-src/doc/manual.html index 3126b5d6afb..89a642a45d9 100644 --- a/Build/source/libs/lua53/lua53-src/doc/manual.html +++ b/Build/source/libs/lua53/lua53-src/doc/manual.html @@ -19,7 +19,7 @@ by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes <P> <SMALL> -Copyright © 2015–2017 Lua.org, PUC-Rio. +Copyright © 2015–2018 Lua.org, PUC-Rio. Freely available under the terms of the <a href="http://www.lua.org/license.html">Lua license</a>. </SMALL> @@ -35,7 +35,7 @@ Freely available under the terms of the <!-- ====================================================================== --> <p> -<!-- $Id: manual.of,v 1.167 2017/01/09 15:18:11 roberto Exp $ --> +<!-- $Id: manual.of,v 1.167.1.2 2018/06/26 15:49:07 roberto Exp $ --> @@ -203,8 +203,8 @@ even those that do not support threads natively. <p> The type <em>table</em> implements associative arrays, -that is, arrays that can be indexed not only with numbers, -but with any Lua value except <b>nil</b> and NaN. +that is, arrays that can have as indices not only numbers, +but any Lua value except <b>nil</b> and NaN. (<em>Not a Number</em> is a special value used to represent undefined or unrepresentable numerical results, such as <code>0/0</code>.) Tables can be <em>heterogeneous</em>; @@ -400,6 +400,8 @@ with the event name prefixed by two underscores; the corresponding values are called <em>metamethods</em>. In the previous example, the key is "<code>__add</code>" and the metamethod is the function that performs the addition. +Unless stated otherwise, +metamethods should be function values. <p> @@ -597,7 +599,7 @@ it is also slower than a real <code>__le</code> metamethod.) </li> <li><b><code>__index</code>: </b> -The indexing access <code>table[key]</code>. +The indexing access operation <code>table[key]</code>. This event happens when <code>table</code> is not a table or when <code>key</code> is not present in <code>table</code>. The metamethod is looked up in <code>table</code>. @@ -1276,13 +1278,8 @@ Square brackets are used to index a table: <pre> var ::= prefixexp ‘<b>[</b>’ exp ‘<b>]</b>’ </pre><p> -The meaning of accesses to table fields can be changed via metatables. -An access to an indexed variable <code>t[i]</code> is equivalent to -a call <code>gettable_event(t,i)</code>. -(See <a href="#2.4">§2.4</a> for a complete description of the -<code>gettable_event</code> function. -This function is not defined or callable in Lua. -We use it here only for explanatory purposes.) +The meaning of accesses to table fields can be changed via metatables +(see <a href="#2.4">§2.4</a>). <p> @@ -1477,22 +1474,17 @@ cyclically permutes the values of <code>x</code>, <code>y</code>, and <code>z</c <p> -The meaning of assignments to global variables -and table fields can be changed via metatables. -An assignment to an indexed variable <code>t[i] = val</code> is equivalent to -<code>settable_event(t,i,val)</code>. -(See <a href="#2.4">§2.4</a> for a complete description of the -<code>settable_event</code> function. -This function is not defined or callable in Lua. -We use it here only for explanatory purposes.) - - -<p> An assignment to a global name <code>x = val</code> is equivalent to the assignment <code>_ENV.x = val</code> (see <a href="#2.2">§2.2</a>). +<p> +The meaning of assignments to table fields and +global variables (which are actually table fields, too) +can be changed via metatables (see <a href="#2.4">§2.4</a>). + + @@ -1831,17 +1823,17 @@ Here are some examples: g(f(), x) -- f() is adjusted to 1 result g(x, f()) -- g gets x plus all results from f() a,b,c = f(), x -- f() is adjusted to 1 result (c gets nil) - a,b = ... -- a gets the first vararg parameter, b gets + a,b = ... -- a gets the first vararg argument, b gets -- the second (both a and b can get nil if there - -- is no corresponding vararg parameter) + -- is no corresponding vararg argument) a,b,c = x, f() -- f() is adjusted to 2 results a,b,c = f() -- f() is adjusted to 3 results return f() -- returns all results from f() - return ... -- returns all received vararg parameters + return ... -- returns all received vararg arguments return x,y,f() -- returns x, y, and all results from f() {f()} -- creates a list with all results from f() - {...} -- creates a list with all vararg parameters + {...} -- creates a list with all vararg arguments {f(), nil} -- f() is adjusted to 1 result </pre> @@ -2039,9 +2031,12 @@ two objects are considered equal only if they are the same object. Every time you create a new object (a table, userdata, or thread), this new object is different from any previously existing object. -Closures with the same reference are always equal. +A closure is always equal to itself. Closures with any detectable difference (different behavior, different definition) are always different. +Closures created at different times but with no detectable differences +may be classified as equal or not +(depending on internal caching details). <p> @@ -2303,7 +2298,7 @@ If the value of prefixexp has type <em>function</em>, then this function is called with the given arguments. Otherwise, the prefixexp "call" metamethod is called, -having as first parameter the value of prefixexp, +having as first argument the value of prefixexp, followed by the original call arguments (see <a href="#2.4">§2.4</a>). @@ -2881,7 +2876,7 @@ it can do whatever it wants on that Lua state, as it should be already protected. However, when C code operates on other Lua states -(e.g., a Lua parameter to the function, +(e.g., a Lua argument to the function, a Lua state stored in the registry, or the result of <a href="#lua_newthread"><code>lua_newthread</code></a>), it should use them only in API calls that cannot raise errors. @@ -3370,7 +3365,7 @@ it is left unchanged. Destroys all objects in the given Lua state (calling the corresponding garbage-collection metamethods, if any) and frees all dynamic memory used by this state. -On several platforms, you may not need to call this function, +In several platforms, you may not need to call this function, because all resources are naturally released when the host program ends. On the other hand, long-running programs that create multiple states, such as daemons or web servers, @@ -5584,7 +5579,7 @@ given as argument to a hook (see <a href="#lua_Hook"><code>lua_Hook</code></a>). <p> -To get information about a function you push it onto the stack +To get information about a function, you push it onto the stack and start the <code>what</code> string with the character '<code>></code>'. (In that case, <code>lua_getinfo</code> pops the function from the top of the stack.) @@ -6462,7 +6457,7 @@ file-related functions in the standard library <p> Pushes onto the stack the field <code>e</code> from the metatable -of the object at index <code>obj</code> and returns the type of pushed value. +of the object at index <code>obj</code> and returns the type of the pushed value. If the object does not have a metatable, or if the metatable does not have this field, pushes nothing and returns <code>LUA_TNIL</code>. @@ -6749,7 +6744,7 @@ In words, if the argument <code>arg</code> is nil or absent, the macro results in the default <code>dflt</code>. Otherwise, it results in the result of calling <code>func</code> with the state <code>L</code> and the argument index <code>arg</code> as -parameters. +arguments. Note that it evaluates the expression <code>dflt</code> only if needed. @@ -8680,7 +8675,7 @@ the lowercase letters plus the '<code>-</code>' character. <p> You can put a closing square bracket in a set by positioning it as the first character in the set. -You can put an hyphen in a set +You can put a hyphen in a set by positioning it as the first or the last character in the set. (You can also use an escape for both cases.) @@ -9082,8 +9077,8 @@ Returns the destination table <code>a2</code>. <p> -Returns a new table with all parameters stored into keys 1, 2, etc. -and with a field "<code>n</code>" with the total number of parameters. +Returns a new table with all arguments stored into keys 1, 2, etc. +and with a field "<code>n</code>" with the total number of arguments. Note that the resulting table may not be a sequence. @@ -9215,7 +9210,7 @@ Returns the arc sine of <code>x</code> (in radians). <p> Returns the arc tangent of <code>y/x</code> (in radians), -but uses the signs of both parameters to find the +but uses the signs of both arguments to find the quadrant of the result. (It also handles correctly the case of <code>x</code> being zero.) @@ -9516,7 +9511,7 @@ all I/O functions return <b>nil</b> on failure (plus an error message as a second result and a system-dependent error code as a third result) and some value different from <b>nil</b> on success. -On non-POSIX systems, +In non-POSIX systems, the computation of the error message and error code in case of errors may be not thread safe, @@ -9553,7 +9548,7 @@ When called with a file name, it opens the named file (in text mode), and sets its handle as the default input file. When called with a file handle, it simply sets this file handle as the default input file. -When called without parameters, +When called without arguments, it returns the current default input file. @@ -9580,7 +9575,7 @@ it returns no values (to finish the loop) and automatically closes the file. The call <code>io.lines()</code> (with no file name) is equivalent to <code>io.input():lines("*l")</code>; that is, it iterates over the lines of the default input file. -In this case it does not close the file when the loop ends. +In this case, the iterator does not close the file when the loop ends. <p> @@ -9963,7 +9958,7 @@ the host system and on the current locale. <p> -On non-POSIX systems, +In non-POSIX systems, this function may be not thread safe because of its reliance on C function <code>gmtime</code> and C function <code>localtime</code>. @@ -10163,7 +10158,7 @@ and explicitly removed when no longer needed. <p> -On POSIX systems, +In POSIX systems, this function also creates a file with that name, to avoid security risks. (Someone else might create the file with wrong permissions @@ -10301,8 +10296,8 @@ The first parameter or local variable has index 1, and so on, following the order that they are declared in the code, counting only the variables that are active in the current scope of the function. -Negative indices refer to vararg parameters; --1 is the first vararg parameter. +Negative indices refer to vararg arguments; +-1 is the first vararg argument. The function returns <b>nil</b> if there is no variable with the given index, and raises an error when called with a level out of range. (You can call <a href="#pdf-debug.getinfo"><code>debug.getinfo</code></a> to check whether the level is valid.) @@ -10400,7 +10395,7 @@ When called without arguments, <p> -When the hook is called, its first parameter is a string +When the hook is called, its first argument is a string describing the event that has triggered its call: <code>"call"</code> (or <code>"tail call"</code>), <code>"return"</code>, @@ -10551,7 +10546,8 @@ The options are: <ul> <li><b><code>-e <em>stat</em></code>: </b> executes string <em>stat</em>;</li> -<li><b><code>-l <em>mod</em></code>: </b> "requires" <em>mod</em>;</li> +<li><b><code>-l <em>mod</em></code>: </b> "requires" <em>mod</em> and assigns the + result to global @<em>mod</em>;</li> <li><b><code>-i</code>: </b> enters interactive mode after running <em>script</em>;</li> <li><b><code>-v</code>: </b> prints version information;</li> <li><b><code>-E</code>: </b> ignores environment variables;</li> @@ -10629,7 +10625,7 @@ For instance, the call </pre><p> will print "<code>-e</code>". If there is a script, -the script is called with parameters +the script is called with arguments <code>arg[1]</code>, ···, <code>arg[#arg]</code>. (Like all chunks in Lua, the script is compiled as a vararg function.) @@ -10815,7 +10811,7 @@ The following functions were deprecated in the mathematical library: <code>frexp</code>, and <code>ldexp</code>. You can replace <code>math.pow(x,y)</code> with <code>x^y</code>; you can replace <code>math.atan2</code> with <code>math.atan</code>, -which now accepts one or two parameters; +which now accepts one or two arguments; you can replace <code>math.ldexp(x,exp)</code> with <code>x * 2.0^exp</code>. For the other operations, you can either use an external library or @@ -10850,7 +10846,7 @@ of the first result.) <ul> <li> -Continuation functions now receive as parameters what they needed +Continuation functions now receive as arguments what they needed to get through <code>lua_getctx</code>, so <code>lua_getctx</code> has been removed. Adapt your code accordingly. @@ -10973,12 +10969,13 @@ and LiteralString, see <a href="#3.1">§3.1</a>.) + <P CLASS="footer"> Last update: -Mon Jan 9 13:30:53 BRST 2017 +Tue Jun 26 13:16:37 -03 2018 </P> <!-- -Last change: revised for Lua 5.3.4 +Last change: revised for Lua 5.3.5 --> </body></html> diff --git a/Build/source/libs/lua53/lua53-src/doc/readme.html b/Build/source/libs/lua53/lua53-src/doc/readme.html index 96a9386e2af..b118f7b02d1 100644 --- a/Build/source/libs/lua53/lua53-src/doc/readme.html +++ b/Build/source/libs/lua53/lua53-src/doc/readme.html @@ -107,7 +107,7 @@ Here are the details. <OL> <LI> Open a terminal window and move to -the top-level directory, which is named <TT>lua-5.3.x</TT>. +the top-level directory, which is named <TT>lua-5.3.5</TT>. The <TT>Makefile</TT> there controls both the build process and the installation process. <P> <LI> @@ -355,10 +355,10 @@ THE SOFTWARE. <P CLASS="footer"> Last update: -Thu Dec 22 18:22:57 BRST 2016 +Mon Jun 18 22:57:33 -03 2018 </P> <!-- -Last change: revised for Lua 5.3.4 +Last change: revised for Lua 5.3.5 --> </BODY> diff --git a/Build/source/libs/lua53/lua53-src/src/Makefile b/Build/source/libs/lua53/lua53-src/src/Makefile index d71c75c8732..64c78f775ba 100644 --- a/Build/source/libs/lua53/lua53-src/src/Makefile +++ b/Build/source/libs/lua53/lua53-src/src/Makefile @@ -102,7 +102,7 @@ c89: freebsd: - $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -lreadline" + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX -DLUA_USE_READLINE -I/usr/include/edit" SYSLIBS="-Wl,-E -ledit" CC="cc" generic: $(ALL) @@ -110,7 +110,7 @@ linux: $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl -lreadline" macosx: - $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX" SYSLIBS="-lreadline" CC=cc + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX" SYSLIBS="-lreadline" mingw: $(MAKE) "LUA_A=lua53.dll" "LUA_T=lua.exe" \ diff --git a/Build/source/libs/lua53/lua53-src/src/lapi.c b/Build/source/libs/lua53/lua53-src/src/lapi.c index c9455a5d8cd..02b7fab7ead 100644 --- a/Build/source/libs/lua53/lua53-src/src/lapi.c +++ b/Build/source/libs/lua53/lua53-src/src/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 2.259 2016/02/29 14:27:14 roberto Exp $ +** $Id: lapi.c,v 2.259.1.2 2017/12/06 18:35:12 roberto Exp $ ** Lua API ** See Copyright Notice in lua.h */ @@ -533,6 +533,7 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { lua_lock(L); if (n == 0) { setfvalue(L->top, fn); + api_incr_top(L); } else { CClosure *cl; @@ -546,9 +547,9 @@ LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) { /* does not need barrier because closure is white */ } setclCvalue(L, L->top, cl); + api_incr_top(L); + luaC_checkGC(L); } - api_incr_top(L); - luaC_checkGC(L); lua_unlock(L); } diff --git a/Build/source/libs/lua53/lua53-src/src/lapi.h b/Build/source/libs/lua53/lua53-src/src/lapi.h index 6d36dee3fb7..8e16ad53d99 100644 --- a/Build/source/libs/lua53/lua53-src/src/lapi.h +++ b/Build/source/libs/lua53/lua53-src/src/lapi.h @@ -1,5 +1,5 @@ /* -** $Id: lapi.h,v 2.9 2015/03/06 19:49:50 roberto Exp $ +** $Id: lapi.h,v 2.9.1.1 2017/04/19 17:20:42 roberto Exp $ ** Auxiliary functions from Lua API ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lauxlib.c b/Build/source/libs/lua53/lua53-src/src/lauxlib.c index f7a383663e1..8bdada50a7e 100644 --- a/Build/source/libs/lua53/lua53-src/src/lauxlib.c +++ b/Build/source/libs/lua53/lua53-src/src/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.289 2016/12/20 18:37:00 roberto Exp $ +** $Id: lauxlib.c,v 1.289.1.1 2017/04/19 17:20:42 roberto Exp $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lauxlib.h b/Build/source/libs/lua53/lua53-src/src/lauxlib.h index 9a2e66aa067..9857d3a835a 100644 --- a/Build/source/libs/lua53/lua53-src/src/lauxlib.h +++ b/Build/source/libs/lua53/lua53-src/src/lauxlib.h @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.h,v 1.131 2016/12/06 14:54:31 roberto Exp $ +** $Id: lauxlib.h,v 1.131.1.1 2017/04/19 17:20:42 roberto Exp $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lbaselib.c b/Build/source/libs/lua53/lua53-src/src/lbaselib.c index 08523e6e754..6460e4f8d42 100644 --- a/Build/source/libs/lua53/lua53-src/src/lbaselib.c +++ b/Build/source/libs/lua53/lua53-src/src/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.314 2016/09/05 19:06:34 roberto Exp $ +** $Id: lbaselib.c,v 1.314.1.1 2017/04/19 17:39:34 roberto Exp $ ** Basic library ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lbitlib.c b/Build/source/libs/lua53/lua53-src/src/lbitlib.c index 1cb1d5b9323..4786c0d4830 100644 --- a/Build/source/libs/lua53/lua53-src/src/lbitlib.c +++ b/Build/source/libs/lua53/lua53-src/src/lbitlib.c @@ -1,5 +1,5 @@ /* -** $Id: lbitlib.c,v 1.30 2015/11/11 19:08:09 roberto Exp $ +** $Id: lbitlib.c,v 1.30.1.1 2017/04/19 17:20:42 roberto Exp $ ** Standard library for bitwise operations ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lcode.c b/Build/source/libs/lua53/lua53-src/src/lcode.c index 0bb414262e3..12619f54a02 100644 --- a/Build/source/libs/lua53/lua53-src/src/lcode.c +++ b/Build/source/libs/lua53/lua53-src/src/lcode.c @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 2.112 2016/12/22 13:08:50 roberto Exp $ +** $Id: lcode.c,v 2.112.1.1 2017/04/19 17:20:42 roberto Exp $ ** Code generator for Lua ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lcode.h b/Build/source/libs/lua53/lua53-src/src/lcode.h index cd306d573ae..882dc9c156e 100644 --- a/Build/source/libs/lua53/lua53-src/src/lcode.h +++ b/Build/source/libs/lua53/lua53-src/src/lcode.h @@ -1,5 +1,5 @@ /* -** $Id: lcode.h,v 1.64 2016/01/05 16:22:37 roberto Exp $ +** $Id: lcode.h,v 1.64.1.1 2017/04/19 17:20:42 roberto Exp $ ** Code generator for Lua ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lcorolib.c b/Build/source/libs/lua53/lua53-src/src/lcorolib.c index 2303429e7bb..0b17af9e343 100644 --- a/Build/source/libs/lua53/lua53-src/src/lcorolib.c +++ b/Build/source/libs/lua53/lua53-src/src/lcorolib.c @@ -1,5 +1,5 @@ /* -** $Id: lcorolib.c,v 1.10 2016/04/11 19:19:55 roberto Exp $ +** $Id: lcorolib.c,v 1.10.1.1 2017/04/19 17:20:42 roberto Exp $ ** Coroutine Library ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lctype.c b/Build/source/libs/lua53/lua53-src/src/lctype.c index ae9367e691b..f8ad7a2edf6 100644 --- a/Build/source/libs/lua53/lua53-src/src/lctype.c +++ b/Build/source/libs/lua53/lua53-src/src/lctype.c @@ -1,5 +1,5 @@ /* -** $Id: lctype.c,v 1.12 2014/11/02 19:19:04 roberto Exp $ +** $Id: lctype.c,v 1.12.1.1 2017/04/19 17:20:42 roberto Exp $ ** 'ctype' functions for Lua ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lctype.h b/Build/source/libs/lua53/lua53-src/src/lctype.h index b961175bc42..a963eb9015f 100644 --- a/Build/source/libs/lua53/lua53-src/src/lctype.h +++ b/Build/source/libs/lua53/lua53-src/src/lctype.h @@ -1,5 +1,5 @@ /* -** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $ +** $Id: lctype.h,v 1.12.1.1 2013/04/12 18:48:47 roberto Exp $ ** 'ctype' functions for Lua ** See Copyright Notice in lua.h */ @@ -76,6 +76,7 @@ LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; #else /* }{ */ + /* ** use standard C ctypes */ diff --git a/Build/source/libs/lua53/lua53-src/src/lctype.h.orig b/Build/source/libs/lua53/lua53-src/src/lctype.h.orig index 99c7d122376..b09b21a337c 100644 --- a/Build/source/libs/lua53/lua53-src/src/lctype.h.orig +++ b/Build/source/libs/lua53/lua53-src/src/lctype.h.orig @@ -1,5 +1,5 @@ /* -** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $ +** $Id: lctype.h,v 1.12.1.1 2013/04/12 18:48:47 roberto Exp $ ** 'ctype' functions for Lua ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/ldblib.c b/Build/source/libs/lua53/lua53-src/src/ldblib.c index 786f6cd95d7..9d29afb0a89 100644 --- a/Build/source/libs/lua53/lua53-src/src/ldblib.c +++ b/Build/source/libs/lua53/lua53-src/src/ldblib.c @@ -1,5 +1,5 @@ /* -** $Id: ldblib.c,v 1.151 2015/11/23 11:29:43 roberto Exp $ +** $Id: ldblib.c,v 1.151.1.1 2017/04/19 17:20:42 roberto Exp $ ** Interface from Lua to its debug API ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/ldebug.c b/Build/source/libs/lua53/lua53-src/src/ldebug.c index 239affb76c5..e1389296e9e 100644 --- a/Build/source/libs/lua53/lua53-src/src/ldebug.c +++ b/Build/source/libs/lua53/lua53-src/src/ldebug.c @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 2.121 2016/10/19 12:32:10 roberto Exp $ +** $Id: ldebug.c,v 2.121.1.2 2017/07/10 17:21:50 roberto Exp $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -653,6 +653,7 @@ l_noret luaG_runerror (lua_State *L, const char *fmt, ...) { CallInfo *ci = L->ci; const char *msg; va_list argp; + luaC_checkGC(L); /* error message uses memory */ va_start(argp, fmt); msg = luaO_pushvfstring(L, fmt, argp); /* format message */ va_end(argp); diff --git a/Build/source/libs/lua53/lua53-src/src/ldebug.h b/Build/source/libs/lua53/lua53-src/src/ldebug.h index 0e31546b1b4..8cea0ee0a72 100644 --- a/Build/source/libs/lua53/lua53-src/src/ldebug.h +++ b/Build/source/libs/lua53/lua53-src/src/ldebug.h @@ -1,5 +1,5 @@ /* -** $Id: ldebug.h,v 2.14 2015/05/22 17:45:56 roberto Exp $ +** $Id: ldebug.h,v 2.14.1.1 2017/04/19 17:20:42 roberto Exp $ ** Auxiliary functions from Debug Interface module ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/ldo.c b/Build/source/libs/lua53/lua53-src/src/ldo.c index 90b695fb04c..316e45c8fec 100644 --- a/Build/source/libs/lua53/lua53-src/src/ldo.c +++ b/Build/source/libs/lua53/lua53-src/src/ldo.c @@ -1,5 +1,5 @@ /* -** $Id: ldo.c,v 2.157 2016/12/13 15:52:21 roberto Exp $ +** $Id: ldo.c,v 2.157.1.1 2017/04/19 17:20:42 roberto Exp $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/ldo.h b/Build/source/libs/lua53/lua53-src/src/ldo.h index 4f5d51c3c70..3b2983a3864 100644 --- a/Build/source/libs/lua53/lua53-src/src/ldo.h +++ b/Build/source/libs/lua53/lua53-src/src/ldo.h @@ -1,5 +1,5 @@ /* -** $Id: ldo.h,v 2.29 2015/12/21 13:02:14 roberto Exp $ +** $Id: ldo.h,v 2.29.1.1 2017/04/19 17:20:42 roberto Exp $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/ldump.c b/Build/source/libs/lua53/lua53-src/src/ldump.c index 016e300822f..f025acac3c2 100644 --- a/Build/source/libs/lua53/lua53-src/src/ldump.c +++ b/Build/source/libs/lua53/lua53-src/src/ldump.c @@ -1,5 +1,5 @@ /* -** $Id: ldump.c,v 2.37 2015/10/08 15:53:49 roberto Exp $ +** $Id: ldump.c,v 2.37.1.1 2017/04/19 17:20:42 roberto Exp $ ** save precompiled Lua chunks ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lfunc.c b/Build/source/libs/lua53/lua53-src/src/lfunc.c index 67967dab3fc..ccafbb8ab3c 100644 --- a/Build/source/libs/lua53/lua53-src/src/lfunc.c +++ b/Build/source/libs/lua53/lua53-src/src/lfunc.c @@ -1,5 +1,5 @@ /* -** $Id: lfunc.c,v 2.45 2014/11/02 19:19:04 roberto Exp $ +** $Id: lfunc.c,v 2.45.1.1 2017/04/19 17:39:34 roberto Exp $ ** Auxiliary functions to manipulate prototypes and closures ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lfunc.h b/Build/source/libs/lua53/lua53-src/src/lfunc.h index 2eeb0d5a489..c916e9878ad 100644 --- a/Build/source/libs/lua53/lua53-src/src/lfunc.h +++ b/Build/source/libs/lua53/lua53-src/src/lfunc.h @@ -1,5 +1,5 @@ /* -** $Id: lfunc.h,v 2.15 2015/01/13 15:49:11 roberto Exp $ +** $Id: lfunc.h,v 2.15.1.1 2017/04/19 17:39:34 roberto Exp $ ** Auxiliary functions to manipulate prototypes and closures ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lgc.c b/Build/source/libs/lua53/lua53-src/src/lgc.c index ba2c19e14e9..db4df82922e 100644 --- a/Build/source/libs/lua53/lua53-src/src/lgc.c +++ b/Build/source/libs/lua53/lua53-src/src/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.215 2016/12/22 13:08:50 roberto Exp $ +** $Id: lgc.c,v 2.215.1.2 2017/08/31 16:15:27 roberto Exp $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -643,8 +643,9 @@ static void clearkeys (global_State *g, GCObject *l, GCObject *f) { for (n = gnode(h, 0); n < limit; n++) { if (!ttisnil(gval(n)) && (iscleared(g, gkey(n)))) { setnilvalue(gval(n)); /* remove value ... */ - removeentry(n); /* and remove entry from table */ } + if (ttisnil(gval(n))) /* is entry empty? */ + removeentry(n); /* remove entry from table */ } } } diff --git a/Build/source/libs/lua53/lua53-src/src/lgc.h b/Build/source/libs/lua53/lua53-src/src/lgc.h index aed3e18a5f0..425cd7cef34 100644 --- a/Build/source/libs/lua53/lua53-src/src/lgc.h +++ b/Build/source/libs/lua53/lua53-src/src/lgc.h @@ -1,5 +1,5 @@ /* -** $Id: lgc.h,v 2.91 2015/12/21 13:02:14 roberto Exp $ +** $Id: lgc.h,v 2.91.1.1 2017/04/19 17:39:34 roberto Exp $ ** Garbage Collector ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/linit.c b/Build/source/libs/lua53/lua53-src/src/linit.c index afcaf98b24b..480da52c7e5 100644 --- a/Build/source/libs/lua53/lua53-src/src/linit.c +++ b/Build/source/libs/lua53/lua53-src/src/linit.c @@ -1,5 +1,5 @@ /* -** $Id: linit.c,v 1.39 2016/12/04 20:17:24 roberto Exp $ +** $Id: linit.c,v 1.39.1.1 2017/04/19 17:20:42 roberto Exp $ ** Initialization of libraries for lua.c and other clients ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/liolib.c b/Build/source/libs/lua53/lua53-src/src/liolib.c index d47be5a27df..76f372acbe8 100644 --- a/Build/source/libs/lua53/lua53-src/src/liolib.c +++ b/Build/source/libs/lua53/lua53-src/src/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 2.151 2016/12/20 18:37:00 roberto Exp $ +** $Id: liolib.c,v 2.151.1.1 2017/04/19 17:29:57 roberto Exp $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -209,11 +209,16 @@ static int aux_close (lua_State *L) { } +static int f_close (lua_State *L) { + tofile(L); /* make sure argument is an open stream */ + return aux_close(L); +} + + static int io_close (lua_State *L) { if (lua_isnone(L, 1)) /* no argument? */ lua_getfield(L, LUA_REGISTRYINDEX, IO_OUTPUT); /* use standard output */ - tofile(L); /* make sure argument is an open stream */ - return aux_close(L); + return f_close(L); } @@ -715,7 +720,7 @@ static const luaL_Reg iolib[] = { ** methods for file handles */ static const luaL_Reg flib[] = { - {"close", io_close}, + {"close", f_close}, {"flush", f_flush}, {"lines", f_lines}, {"read", f_read}, diff --git a/Build/source/libs/lua53/lua53-src/src/liolib.c.orig b/Build/source/libs/lua53/lua53-src/src/liolib.c.orig index 156840358d0..8a9e75cd089 100644 --- a/Build/source/libs/lua53/lua53-src/src/liolib.c.orig +++ b/Build/source/libs/lua53/lua53-src/src/liolib.c.orig @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 2.151 2016/12/20 18:37:00 roberto Exp $ +** $Id: liolib.c,v 2.151.1.1 2017/04/19 17:29:57 roberto Exp $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -206,11 +206,16 @@ static int aux_close (lua_State *L) { } +static int f_close (lua_State *L) { + tofile(L); /* make sure argument is an open stream */ + return aux_close(L); +} + + static int io_close (lua_State *L) { if (lua_isnone(L, 1)) /* no argument? */ lua_getfield(L, LUA_REGISTRYINDEX, IO_OUTPUT); /* use standard output */ - tofile(L); /* make sure argument is an open stream */ - return aux_close(L); + return f_close(L); } @@ -712,7 +717,7 @@ static const luaL_Reg iolib[] = { ** methods for file handles */ static const luaL_Reg flib[] = { - {"close", io_close}, + {"close", f_close}, {"flush", f_flush}, {"lines", f_lines}, {"read", f_read}, diff --git a/Build/source/libs/lua53/lua53-src/src/llex.c b/Build/source/libs/lua53/lua53-src/src/llex.c index 70328273f7a..66fd411ba9d 100644 --- a/Build/source/libs/lua53/lua53-src/src/llex.c +++ b/Build/source/libs/lua53/lua53-src/src/llex.c @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 2.96 2016/05/02 14:02:12 roberto Exp $ +** $Id: llex.c,v 2.96.1.1 2017/04/19 17:20:42 roberto Exp $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/llex.h b/Build/source/libs/lua53/lua53-src/src/llex.h index 2363d87e40e..2ed0af66a48 100644 --- a/Build/source/libs/lua53/lua53-src/src/llex.h +++ b/Build/source/libs/lua53/lua53-src/src/llex.h @@ -1,5 +1,5 @@ /* -** $Id: llex.h,v 1.79 2016/05/02 14:02:12 roberto Exp $ +** $Id: llex.h,v 1.79.1.1 2017/04/19 17:20:42 roberto Exp $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/llimits.h b/Build/source/libs/lua53/lua53-src/src/llimits.h index f21377fef98..d1036f6bc8d 100644 --- a/Build/source/libs/lua53/lua53-src/src/llimits.h +++ b/Build/source/libs/lua53/lua53-src/src/llimits.h @@ -1,5 +1,5 @@ /* -** $Id: llimits.h,v 1.141 2015/11/19 19:16:22 roberto Exp $ +** $Id: llimits.h,v 1.141.1.1 2017/04/19 17:20:42 roberto Exp $ ** Limits, basic types, and some other 'installation-dependent' definitions ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lmathlib.c b/Build/source/libs/lua53/lua53-src/src/lmathlib.c index b7f8baee076..7ef7e593fd3 100644 --- a/Build/source/libs/lua53/lua53-src/src/lmathlib.c +++ b/Build/source/libs/lua53/lua53-src/src/lmathlib.c @@ -1,5 +1,5 @@ /* -** $Id: lmathlib.c,v 1.119 2016/12/22 13:08:50 roberto Exp $ +** $Id: lmathlib.c,v 1.119.1.1 2017/04/19 17:20:42 roberto Exp $ ** Standard mathematical library ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lmem.c b/Build/source/libs/lua53/lua53-src/src/lmem.c index 0a0476cc773..0241cc3bac0 100644 --- a/Build/source/libs/lua53/lua53-src/src/lmem.c +++ b/Build/source/libs/lua53/lua53-src/src/lmem.c @@ -1,5 +1,5 @@ /* -** $Id: lmem.c,v 1.91 2015/03/06 19:45:54 roberto Exp $ +** $Id: lmem.c,v 1.91.1.1 2017/04/19 17:20:42 roberto Exp $ ** Interface to Memory Manager ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lmem.h b/Build/source/libs/lua53/lua53-src/src/lmem.h index 30f484895e7..357b1e43e7f 100644 --- a/Build/source/libs/lua53/lua53-src/src/lmem.h +++ b/Build/source/libs/lua53/lua53-src/src/lmem.h @@ -1,5 +1,5 @@ /* -** $Id: lmem.h,v 1.43 2014/12/19 17:26:14 roberto Exp $ +** $Id: lmem.h,v 1.43.1.1 2017/04/19 17:20:42 roberto Exp $ ** Interface to Memory Manager ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/loadlib.c b/Build/source/libs/lua53/lua53-src/src/loadlib.c index 4791e748b16..45f44d3225a 100644 --- a/Build/source/libs/lua53/lua53-src/src/loadlib.c +++ b/Build/source/libs/lua53/lua53-src/src/loadlib.c @@ -1,5 +1,5 @@ /* -** $Id: loadlib.c,v 1.130 2017/01/12 17:14:26 roberto Exp $ +** $Id: loadlib.c,v 1.130.1.1 2017/04/19 17:20:42 roberto Exp $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h ** diff --git a/Build/source/libs/lua53/lua53-src/src/lobject.c b/Build/source/libs/lua53/lua53-src/src/lobject.c index 2da76899a27..2218c8cdd77 100644 --- a/Build/source/libs/lua53/lua53-src/src/lobject.c +++ b/Build/source/libs/lua53/lua53-src/src/lobject.c @@ -1,5 +1,5 @@ /* -** $Id: lobject.c,v 2.113 2016/12/22 13:08:50 roberto Exp $ +** $Id: lobject.c,v 2.113.1.1 2017/04/19 17:29:57 roberto Exp $ ** Some generic functions over Lua objects ** See Copyright Notice in lua.h */ @@ -435,7 +435,8 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { } case 'p': { /* a pointer */ char buff[4*sizeof(void *) + 8]; /* should be enough space for a '%p' */ - int l = l_sprintf(buff, sizeof(buff), "%p", va_arg(argp, void *)); + void *p = va_arg(argp, void *); + int l = lua_pointer2str(buff, sizeof(buff), p); pushstr(L, buff, l); break; } diff --git a/Build/source/libs/lua53/lua53-src/src/lobject.h b/Build/source/libs/lua53/lua53-src/src/lobject.h index 3c042289492..24088614027 100644 --- a/Build/source/libs/lua53/lua53-src/src/lobject.h +++ b/Build/source/libs/lua53/lua53-src/src/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 2.117 2016/08/01 19:51:24 roberto Exp $ +** $Id: lobject.h,v 2.117.1.1 2017/04/19 17:39:34 roberto Exp $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lopcodes.c b/Build/source/libs/lua53/lua53-src/src/lopcodes.c index a1cbef85737..5ca3eb261a4 100644 --- a/Build/source/libs/lua53/lua53-src/src/lopcodes.c +++ b/Build/source/libs/lua53/lua53-src/src/lopcodes.c @@ -1,5 +1,5 @@ /* -** $Id: lopcodes.c,v 1.55 2015/01/05 13:48:33 roberto Exp $ +** $Id: lopcodes.c,v 1.55.1.1 2017/04/19 17:20:42 roberto Exp $ ** Opcodes for Lua virtual machine ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lopcodes.h b/Build/source/libs/lua53/lua53-src/src/lopcodes.h index f9b438e15d9..df6c2264b7b 100644 --- a/Build/source/libs/lua53/lua53-src/src/lopcodes.h +++ b/Build/source/libs/lua53/lua53-src/src/lopcodes.h @@ -1,5 +1,5 @@ /* -** $Id: lopcodes.h,v 1.149 2016/07/19 17:12:21 roberto Exp $ +** $Id: lopcodes.h,v 1.149.1.1 2017/04/19 17:20:42 roberto Exp $ ** Opcodes for Lua virtual machine ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lopcodes.h.orig b/Build/source/libs/lua53/lua53-src/src/lopcodes.h.orig index bbc4b61968a..6feaa1cd07a 100644 --- a/Build/source/libs/lua53/lua53-src/src/lopcodes.h.orig +++ b/Build/source/libs/lua53/lua53-src/src/lopcodes.h.orig @@ -1,5 +1,5 @@ /* -** $Id: lopcodes.h,v 1.149 2016/07/19 17:12:21 roberto Exp $ +** $Id: lopcodes.h,v 1.149.1.1 2017/04/19 17:20:42 roberto Exp $ ** Opcodes for Lua virtual machine ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/loslib.c b/Build/source/libs/lua53/lua53-src/src/loslib.c index 5a94eb9068d..de590c6b717 100644 --- a/Build/source/libs/lua53/lua53-src/src/loslib.c +++ b/Build/source/libs/lua53/lua53-src/src/loslib.c @@ -1,5 +1,5 @@ /* -** $Id: loslib.c,v 1.65 2016/07/18 17:58:58 roberto Exp $ +** $Id: loslib.c,v 1.65.1.1 2017/04/19 17:29:57 roberto Exp $ ** Standard Operating System library ** See Copyright Notice in lua.h */ @@ -293,7 +293,8 @@ static int os_date (lua_State *L) { else stm = l_localtime(&t, &tmr); if (stm == NULL) /* invalid date? */ - luaL_error(L, "time result cannot be represented in this installation"); + return luaL_error(L, + "time result cannot be represented in this installation"); if (strcmp(s, "*t") == 0) { lua_createtable(L, 0, 9); /* 9 = number of fields */ setallfields(L, stm); @@ -340,7 +341,8 @@ static int os_time (lua_State *L) { setallfields(L, &ts); /* update fields with normalized values */ } if (t != (time_t)(l_timet)t || t == (time_t)(-1)) - luaL_error(L, "time result cannot be represented in this installation"); + return luaL_error(L, + "time result cannot be represented in this installation"); l_pushtime(L, t); return 1; } diff --git a/Build/source/libs/lua53/lua53-src/src/lparser.c b/Build/source/libs/lua53/lua53-src/src/lparser.c index cd4512d4d41..cc54de43c63 100644 --- a/Build/source/libs/lua53/lua53-src/src/lparser.c +++ b/Build/source/libs/lua53/lua53-src/src/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 2.155 2016/08/01 19:51:24 roberto Exp $ +** $Id: lparser.c,v 2.155.1.2 2017/04/29 18:11:40 roberto Exp $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -1392,7 +1392,7 @@ static void test_then_block (LexState *ls, int *escapelist) { luaK_goiffalse(ls->fs, &v); /* will jump to label if condition is true */ enterblock(fs, &bl, 0); /* must enter block before 'goto' */ gotostat(ls, v.t); /* handle goto/break */ - skipnoopstat(ls); /* skip other no-op statements */ + while (testnext(ls, ';')) {} /* skip colons */ if (block_follow(ls, 0)) { /* 'goto' is the entire block? */ leaveblock(fs); return; /* and that is it */ diff --git a/Build/source/libs/lua53/lua53-src/src/lparser.h b/Build/source/libs/lua53/lua53-src/src/lparser.h index 02e9b03aebc..f45b23cba56 100644 --- a/Build/source/libs/lua53/lua53-src/src/lparser.h +++ b/Build/source/libs/lua53/lua53-src/src/lparser.h @@ -1,5 +1,5 @@ /* -** $Id: lparser.h,v 1.76 2015/12/30 18:16:13 roberto Exp $ +** $Id: lparser.h,v 1.76.1.1 2017/04/19 17:20:42 roberto Exp $ ** Lua Parser ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lprefix.h b/Build/source/libs/lua53/lua53-src/src/lprefix.h index 02daa837f55..9a749a3f30c 100644 --- a/Build/source/libs/lua53/lua53-src/src/lprefix.h +++ b/Build/source/libs/lua53/lua53-src/src/lprefix.h @@ -1,5 +1,5 @@ /* -** $Id: lprefix.h,v 1.2 2014/12/29 16:54:13 roberto Exp $ +** $Id: lprefix.h,v 1.2.1.1 2017/04/19 17:20:42 roberto Exp $ ** Definitions for Lua code that must come before any other header file ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lstate.c b/Build/source/libs/lua53/lua53-src/src/lstate.c index 9194ac3419e..c1a76643c33 100644 --- a/Build/source/libs/lua53/lua53-src/src/lstate.c +++ b/Build/source/libs/lua53/lua53-src/src/lstate.c @@ -1,5 +1,5 @@ /* -** $Id: lstate.c,v 2.133 2015/11/13 12:16:51 roberto Exp $ +** $Id: lstate.c,v 2.133.1.1 2017/04/19 17:39:34 roberto Exp $ ** Global State ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lstate.h b/Build/source/libs/lua53/lua53-src/src/lstate.h index a469466c447..56b37410000 100644 --- a/Build/source/libs/lua53/lua53-src/src/lstate.h +++ b/Build/source/libs/lua53/lua53-src/src/lstate.h @@ -1,5 +1,5 @@ /* -** $Id: lstate.h,v 2.133 2016/12/22 13:08:50 roberto Exp $ +** $Id: lstate.h,v 2.133.1.1 2017/04/19 17:39:34 roberto Exp $ ** Global State ** See Copyright Notice in lua.h */ @@ -26,6 +26,24 @@ ** 'tobefnz': all objects ready to be finalized; ** 'fixedgc': all objects that are not to be collected (currently ** only small strings, such as reserved words). +** +** Moreover, there is another set of lists that control gray objects. +** These lists are linked by fields 'gclist'. (All objects that +** can become gray have such a field. The field is not the same +** in all objects, but it always has this name.) Any gray object +** must belong to one of these lists, and all objects in these lists +** must be gray: +** +** 'gray': regular gray objects, still waiting to be visited. +** 'grayagain': objects that must be revisited at the atomic phase. +** That includes +** - black objects got in a write barrier; +** - all kinds of weak tables during propagation phase; +** - all threads. +** 'weak': tables with weak values to be cleared; +** 'ephemeron': ephemeron tables with white->white entries; +** 'allweak': tables with weak keys and/or weak values to be cleared. +** The last three lists are used only during the atomic phase. */ diff --git a/Build/source/libs/lua53/lua53-src/src/lstring.c b/Build/source/libs/lua53/lua53-src/src/lstring.c index 9351766fd63..6257f211d9e 100644 --- a/Build/source/libs/lua53/lua53-src/src/lstring.c +++ b/Build/source/libs/lua53/lua53-src/src/lstring.c @@ -1,5 +1,5 @@ /* -** $Id: lstring.c,v 2.56 2015/11/23 11:32:51 roberto Exp $ +** $Id: lstring.c,v 2.56.1.1 2017/04/19 17:20:42 roberto Exp $ ** String table (keeps all strings handled by Lua) ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lstring.h b/Build/source/libs/lua53/lua53-src/src/lstring.h index 27efd207726..d612abd3332 100644 --- a/Build/source/libs/lua53/lua53-src/src/lstring.h +++ b/Build/source/libs/lua53/lua53-src/src/lstring.h @@ -1,5 +1,5 @@ /* -** $Id: lstring.h,v 1.61 2015/11/03 15:36:01 roberto Exp $ +** $Id: lstring.h,v 1.61.1.1 2017/04/19 17:20:42 roberto Exp $ ** String table (keep all strings handled by Lua) ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lstrlib.c b/Build/source/libs/lua53/lua53-src/src/lstrlib.c index c7aa755fabd..b4bed7e93d1 100644 --- a/Build/source/libs/lua53/lua53-src/src/lstrlib.c +++ b/Build/source/libs/lua53/lua53-src/src/lstrlib.c @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.254 2016/12/22 13:08:50 roberto Exp $ +** $Id: lstrlib.c,v 1.254.1.1 2017/04/19 17:29:57 roberto Exp $ ** Standard library for string operations and pattern-matching ** See Copyright Notice in lua.h */ @@ -879,7 +879,7 @@ static int lua_number2strx (lua_State *L, char *buff, int sz, buff[i] = toupper(uchar(buff[i])); } else if (fmt[SIZELENMOD] != 'a') - luaL_error(L, "modifiers for format '%%a'/'%%A' not implemented"); + return luaL_error(L, "modifiers for format '%%a'/'%%A' not implemented"); return n; } @@ -1199,8 +1199,8 @@ static int getnum (const char **fmt, int df) { static int getnumlimit (Header *h, const char **fmt, int df) { int sz = getnum(fmt, df); if (sz > MAXINTSIZE || sz <= 0) - luaL_error(h->L, "integral size (%d) out of limits [1,%d]", - sz, MAXINTSIZE); + return luaL_error(h->L, "integral size (%d) out of limits [1,%d]", + sz, MAXINTSIZE); return sz; } diff --git a/Build/source/libs/lua53/lua53-src/src/ltable.c b/Build/source/libs/lua53/lua53-src/src/ltable.c index d080189f28d..ea4fe7fcb31 100644 --- a/Build/source/libs/lua53/lua53-src/src/ltable.c +++ b/Build/source/libs/lua53/lua53-src/src/ltable.c @@ -1,5 +1,5 @@ /* -** $Id: ltable.c,v 2.118 2016/11/07 12:38:35 roberto Exp $ +** $Id: ltable.c,v 2.118.1.4 2018/06/08 16:22:51 roberto Exp $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -223,7 +223,9 @@ static unsigned int computesizes (unsigned int nums[], unsigned int *pna) { unsigned int na = 0; /* number of elements to go to array part */ unsigned int optimal = 0; /* optimal size for array part */ /* loop while keys can fill more than half of total size */ - for (i = 0, twotoi = 1; *pna > twotoi / 2; i++, twotoi *= 2) { + for (i = 0, twotoi = 1; + twotoi > 0 && *pna > twotoi / 2; + i++, twotoi *= 2) { if (nums[i] > 0) { a += nums[i]; if (a > twotoi/2) { /* more than half elements present? */ @@ -330,17 +332,34 @@ static void setnodevector (lua_State *L, Table *t, unsigned int size) { } +typedef struct { + Table *t; + unsigned int nhsize; +} AuxsetnodeT; + + +static void auxsetnode (lua_State *L, void *ud) { + AuxsetnodeT *asn = cast(AuxsetnodeT *, ud); + setnodevector(L, asn->t, asn->nhsize); +} + + void luaH_resize (lua_State *L, Table *t, unsigned int nasize, unsigned int nhsize) { unsigned int i; int j; + AuxsetnodeT asn; unsigned int oldasize = t->sizearray; int oldhsize = allocsizenode(t); Node *nold = t->node; /* save old hash ... */ if (nasize > oldasize) /* array part must grow? */ setarrayvector(L, t, nasize); /* create new hash part with appropriate size */ - setnodevector(L, t, nhsize); + asn.t = t; asn.nhsize = nhsize; + if (luaD_rawrunprotected(L, auxsetnode, &asn) != LUA_OK) { /* mem. error? */ + setarrayvector(L, t, oldasize); /* array back to its original size */ + luaD_throw(L, LUA_ERRMEM); /* rethrow memory error */ + } if (nasize < oldasize) { /* array part must shrink? */ t->sizearray = nasize; /* re-insert elements from vanishing slice */ @@ -610,13 +629,13 @@ void luaH_setint (lua_State *L, Table *t, lua_Integer key, TValue *value) { } -static int unbound_search (Table *t, unsigned int j) { - unsigned int i = j; /* i is zero or a present index */ +static lua_Unsigned unbound_search (Table *t, lua_Unsigned j) { + lua_Unsigned i = j; /* i is zero or a present index */ j++; /* find 'i' and 'j' such that i is present and j is not */ while (!ttisnil(luaH_getint(t, j))) { i = j; - if (j > cast(unsigned int, MAX_INT)/2) { /* overflow? */ + if (j > l_castS2U(LUA_MAXINTEGER) / 2) { /* overflow? */ /* table was built with bad purposes: resort to linear search */ i = 1; while (!ttisnil(luaH_getint(t, i))) i++; @@ -626,7 +645,7 @@ static int unbound_search (Table *t, unsigned int j) { } /* now do a binary search between them */ while (j - i > 1) { - unsigned int m = (i+j)/2; + lua_Unsigned m = (i+j)/2; if (ttisnil(luaH_getint(t, m))) j = m; else i = m; } @@ -638,7 +657,7 @@ static int unbound_search (Table *t, unsigned int j) { ** Try to find a boundary in table 't'. A 'boundary' is an integer index ** such that t[i] is non-nil and t[i+1] is nil (and 0 if t[1] is nil). */ -int luaH_getn (Table *t) { +lua_Unsigned luaH_getn (Table *t) { unsigned int j = t->sizearray; if (j > 0 && ttisnil(&t->array[j - 1])) { /* there is a boundary in the array part: (binary) search for it */ diff --git a/Build/source/libs/lua53/lua53-src/src/ltable.h b/Build/source/libs/lua53/lua53-src/src/ltable.h index 6da9024fe1f..92db0ac7bf1 100644 --- a/Build/source/libs/lua53/lua53-src/src/ltable.h +++ b/Build/source/libs/lua53/lua53-src/src/ltable.h @@ -1,5 +1,5 @@ /* -** $Id: ltable.h,v 2.23 2016/12/22 13:08:50 roberto Exp $ +** $Id: ltable.h,v 2.23.1.2 2018/05/24 19:39:05 roberto Exp $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -54,7 +54,7 @@ LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); LUAI_FUNC void luaH_free (lua_State *L, Table *t); LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); -LUAI_FUNC int luaH_getn (Table *t); +LUAI_FUNC lua_Unsigned luaH_getn (Table *t); #if defined(LUA_DEBUG) diff --git a/Build/source/libs/lua53/lua53-src/src/ltablib.c b/Build/source/libs/lua53/lua53-src/src/ltablib.c index 98b2f871379..c5349578ec7 100644 --- a/Build/source/libs/lua53/lua53-src/src/ltablib.c +++ b/Build/source/libs/lua53/lua53-src/src/ltablib.c @@ -1,5 +1,5 @@ /* -** $Id: ltablib.c,v 1.93 2016/02/25 19:41:54 roberto Exp $ +** $Id: ltablib.c,v 1.93.1.1 2017/04/19 17:20:42 roberto Exp $ ** Library for Table Manipulation ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/ltm.c b/Build/source/libs/lua53/lua53-src/src/ltm.c index 14e52578884..0e7c713214c 100644 --- a/Build/source/libs/lua53/lua53-src/src/ltm.c +++ b/Build/source/libs/lua53/lua53-src/src/ltm.c @@ -1,5 +1,5 @@ /* -** $Id: ltm.c,v 2.38 2016/12/22 13:08:50 roberto Exp $ +** $Id: ltm.c,v 2.38.1.1 2017/04/19 17:39:34 roberto Exp $ ** Tag methods ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/ltm.h b/Build/source/libs/lua53/lua53-src/src/ltm.h index 63db7269bbf..8170688daeb 100644 --- a/Build/source/libs/lua53/lua53-src/src/ltm.h +++ b/Build/source/libs/lua53/lua53-src/src/ltm.h @@ -1,5 +1,5 @@ /* -** $Id: ltm.h,v 2.22 2016/02/26 19:20:15 roberto Exp $ +** $Id: ltm.h,v 2.22.1.1 2017/04/19 17:20:42 roberto Exp $ ** Tag methods ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lua.c b/Build/source/libs/lua53/lua53-src/src/lua.c index 3f082da6be6..ca5b298523b 100644 --- a/Build/source/libs/lua53/lua53-src/src/lua.c +++ b/Build/source/libs/lua53/lua53-src/src/lua.c @@ -1,5 +1,5 @@ /* -** $Id: lua.c,v 1.230 2017/01/12 17:14:26 roberto Exp $ +** $Id: lua.c,v 1.230.1.1 2017/04/19 17:29:57 roberto Exp $ ** Lua stand-alone interpreter ** See Copyright Notice in lua.h */ @@ -138,7 +138,7 @@ static void print_usage (const char *badoption) { "Available options are:\n" " -e stat execute string 'stat'\n" " -i enter interactive mode after executing 'script'\n" - " -l name require library 'name'\n" + " -l name require library 'name' into global 'name'\n" " -v show version information\n" " -E ignore environment variables\n" " -- stop handling options\n" diff --git a/Build/source/libs/lua53/lua53-src/src/lua.h b/Build/source/libs/lua53/lua53-src/src/lua.h index 26c0e2d698c..c236e360957 100644 --- a/Build/source/libs/lua53/lua53-src/src/lua.h +++ b/Build/source/libs/lua53/lua53-src/src/lua.h @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.332 2016/12/22 15:51:20 roberto Exp $ +** $Id: lua.h,v 1.332.1.2 2018/06/13 16:58:17 roberto Exp $ ** Lua - A Scripting Language ** Lua.org, PUC-Rio, Brazil (http://www.lua.org) ** See Copyright Notice at the end of this file @@ -19,11 +19,11 @@ #define LUA_VERSION_MAJOR "5" #define LUA_VERSION_MINOR "3" #define LUA_VERSION_NUM 503 -#define LUA_VERSION_RELEASE "4" +#define LUA_VERSION_RELEASE "5" #define LUA_VERSION "Lua " LUA_VERSION_MAJOR "." LUA_VERSION_MINOR #define LUA_RELEASE LUA_VERSION "." LUA_VERSION_RELEASE -#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2017 Lua.org, PUC-Rio" +#define LUA_COPYRIGHT LUA_RELEASE " Copyright (C) 1994-2018 Lua.org, PUC-Rio" #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo, W. Celes" @@ -460,7 +460,7 @@ struct lua_Debug { /****************************************************************************** -* Copyright (C) 1994-2017 Lua.org, PUC-Rio. +* Copyright (C) 1994-2018 Lua.org, PUC-Rio. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the diff --git a/Build/source/libs/lua53/lua53-src/src/luac.c b/Build/source/libs/lua53/lua53-src/src/luac.c index c0c91d017ae..549ad395004 100644 --- a/Build/source/libs/lua53/lua53-src/src/luac.c +++ b/Build/source/libs/lua53/lua53-src/src/luac.c @@ -1,5 +1,5 @@ /* -** $Id: luac.c,v 1.75 2015/03/12 01:58:27 lhf Exp $ +** $Id: luac.c,v 1.76 2018/06/19 01:32:02 lhf Exp $ ** Lua compiler (saves bytecodes to files; also lists bytecodes) ** See Copyright Notice in lua.h */ @@ -206,7 +206,7 @@ int main(int argc, char* argv[]) } /* -** $Id: luac.c,v 1.75 2015/03/12 01:58:27 lhf Exp $ +** $Id: luac.c,v 1.76 2018/06/19 01:32:02 lhf Exp $ ** print bytecodes ** See Copyright Notice in lua.h */ @@ -348,6 +348,7 @@ static void PrintCode(const Proto* f) case OP_ADD: case OP_SUB: case OP_MUL: + case OP_MOD: case OP_POW: case OP_DIV: case OP_IDIV: diff --git a/Build/source/libs/lua53/lua53-src/src/luaconf.h b/Build/source/libs/lua53/lua53-src/src/luaconf.h index dbd399e3ca7..9eeeea69e20 100644 --- a/Build/source/libs/lua53/lua53-src/src/luaconf.h +++ b/Build/source/libs/lua53/lua53-src/src/luaconf.h @@ -1,5 +1,5 @@ /* -** $Id: luaconf.h,v 1.259 2016/12/22 13:08:50 roberto Exp $ +** $Id: luaconf.h,v 1.259.1.1 2017/04/19 17:29:57 roberto Exp $ ** Configuration file for Lua ** See Copyright Notice in lua.h */ @@ -604,8 +604,6 @@ */ #if !defined(LUA_USE_C89) #define l_sprintf(s,sz,f,i) snprintf(s,sz,f,i) -/* Should we use this line ? */ -/*#define l_sprintf(s,sz,f,i) ((void)(sz), sprintf(s,f,i))*/ #else #define l_sprintf(s,sz,f,i) ((void)(sz), sprintf(s,f,i)) #endif @@ -623,6 +621,13 @@ /* +@@ lua_pointer2str converts a pointer to a readable string in a +** non-specified way. +*/ +#define lua_pointer2str(buff,sz,p) l_sprintf(buff,sz,"%p",p) + + +/* @@ lua_number2strx converts a float to an hexadecimal numeric string. ** In C99, 'sprintf' (with format specifiers '%a'/'%A') does that. ** Otherwise, you can leave 'lua_number2strx' undefined and Lua will diff --git a/Build/source/libs/lua53/lua53-src/src/lualib.h b/Build/source/libs/lua53/lua53-src/src/lualib.h index 6c0bc4cb084..f5304aa0dd0 100644 --- a/Build/source/libs/lua53/lua53-src/src/lualib.h +++ b/Build/source/libs/lua53/lua53-src/src/lualib.h @@ -1,5 +1,5 @@ /* -** $Id: lualib.h,v 1.45 2017/01/12 17:14:26 roberto Exp $ +** $Id: lualib.h,v 1.45.1.1 2017/04/19 17:20:42 roberto Exp $ ** Lua standard libraries ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lundump.c b/Build/source/libs/lua53/lua53-src/src/lundump.c index 4080af9c0d9..7a67d75aaa0 100644 --- a/Build/source/libs/lua53/lua53-src/src/lundump.c +++ b/Build/source/libs/lua53/lua53-src/src/lundump.c @@ -1,5 +1,5 @@ /* -** $Id: lundump.c,v 2.44 2015/11/02 16:09:30 roberto Exp $ +** $Id: lundump.c,v 2.44.1.1 2017/04/19 17:20:42 roberto Exp $ ** load precompiled Lua chunks ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lundump.h b/Build/source/libs/lua53/lua53-src/src/lundump.h index fe4a97463f8..f3e2e9061d6 100644 --- a/Build/source/libs/lua53/lua53-src/src/lundump.h +++ b/Build/source/libs/lua53/lua53-src/src/lundump.h @@ -1,5 +1,5 @@ /* -** $Id: lundump.h,v 1.45 2015/09/08 15:41:05 roberto Exp $ +** $Id: lundump.h,v 1.45.1.1 2017/04/19 17:20:42 roberto Exp $ ** load precompiled Lua chunks ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lundump.h.orig b/Build/source/libs/lua53/lua53-src/src/lundump.h.orig index aa5cc82f1b5..ce492d689cd 100644 --- a/Build/source/libs/lua53/lua53-src/src/lundump.h.orig +++ b/Build/source/libs/lua53/lua53-src/src/lundump.h.orig @@ -1,5 +1,5 @@ /* -** $Id: lundump.h,v 1.45 2015/09/08 15:41:05 roberto Exp $ +** $Id: lundump.h,v 1.45.1.1 2017/04/19 17:20:42 roberto Exp $ ** load precompiled Lua chunks ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lutf8lib.c b/Build/source/libs/lua53/lua53-src/src/lutf8lib.c index de9e3dcdd64..10bd238a71d 100644 --- a/Build/source/libs/lua53/lua53-src/src/lutf8lib.c +++ b/Build/source/libs/lua53/lua53-src/src/lutf8lib.c @@ -1,5 +1,5 @@ /* -** $Id: lutf8lib.c,v 1.16 2016/12/22 13:08:50 roberto Exp $ +** $Id: lutf8lib.c,v 1.16.1.1 2017/04/19 17:29:57 roberto Exp $ ** Standard library for UTF-8 manipulation ** See Copyright Notice in lua.h */ @@ -171,7 +171,7 @@ static int byteoffset (lua_State *L) { } else { if (iscont(s + posi)) - luaL_error(L, "initial position is a continuation byte"); + return luaL_error(L, "initial position is a continuation byte"); if (n < 0) { while (n < 0 && posi > 0) { /* move back */ do { /* find beginning of previous character */ diff --git a/Build/source/libs/lua53/lua53-src/src/lvm.c b/Build/source/libs/lua53/lua53-src/src/lvm.c index 84ade6b2fa6..cc43d8714db 100644 --- a/Build/source/libs/lua53/lua53-src/src/lvm.c +++ b/Build/source/libs/lua53/lua53-src/src/lvm.c @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 2.268 2016/02/05 19:59:14 roberto Exp $ +** $Id: lvm.c,v 2.268.1.1 2017/04/19 17:39:34 roberto Exp $ ** Lua virtual machine ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lvm.h b/Build/source/libs/lua53/lua53-src/src/lvm.h index 422f8719491..a8f954f04ce 100644 --- a/Build/source/libs/lua53/lua53-src/src/lvm.h +++ b/Build/source/libs/lua53/lua53-src/src/lvm.h @@ -1,5 +1,5 @@ /* -** $Id: lvm.h,v 2.41 2016/12/22 13:08:50 roberto Exp $ +** $Id: lvm.h,v 2.41.1.1 2017/04/19 17:20:42 roberto Exp $ ** Lua virtual machine ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lzio.c b/Build/source/libs/lua53/lua53-src/src/lzio.c index c9e1f491f34..6f79094410f 100644 --- a/Build/source/libs/lua53/lua53-src/src/lzio.c +++ b/Build/source/libs/lua53/lua53-src/src/lzio.c @@ -1,5 +1,5 @@ /* -** $Id: lzio.c,v 1.37 2015/09/08 15:41:05 roberto Exp $ +** $Id: lzio.c,v 1.37.1.1 2017/04/19 17:20:42 roberto Exp $ ** Buffered streams ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/lua53/lua53-src/src/lzio.h b/Build/source/libs/lua53/lua53-src/src/lzio.h index e7b6f34b1e3..d8978708157 100644 --- a/Build/source/libs/lua53/lua53-src/src/lzio.h +++ b/Build/source/libs/lua53/lua53-src/src/lzio.h @@ -1,5 +1,5 @@ /* -** $Id: lzio.h,v 1.31 2015/09/08 15:41:05 roberto Exp $ +** $Id: lzio.h,v 1.31.1.1 2017/04/19 17:20:42 roberto Exp $ ** Buffered streams ** See Copyright Notice in lua.h */ diff --git a/Build/source/libs/luajit/native/Makefile.am b/Build/source/libs/luajit/native/Makefile.am index f89c2fa7629..c9ed9d7a114 100644 --- a/Build/source/libs/luajit/native/Makefile.am +++ b/Build/source/libs/luajit/native/Makefile.am @@ -28,6 +28,7 @@ buildvm_arch.h: minilua$(EXEEXT) $(LUAJIT_TREE)/dynasm/dynasm.lua `cat ../dynasm_flags` \ -o $@ $(srcdir)/$(LUAJIT_TREE)/src/vm_$(DASM_ARCH).dasc +minilua_CPPFLAGS = $(AM_CPPFLAGS) $(LUAJIT_DEFINES) `cat ../native_flags` nodist_minilua_SOURCES = \ @LUAJIT_TREE@/src/host/minilua.c minilua_LDADD = $(MATH_LIB) diff --git a/Build/source/libs/zziplib/zziplib-src/zzip/lib.h b/Build/source/libs/zziplib/zziplib-src/zzip/lib.h index 4a02f5473e4..b09a1302829 100644 --- a/Build/source/libs/zziplib/zziplib-src/zzip/lib.h +++ b/Build/source/libs/zziplib/zziplib-src/zzip/lib.h @@ -16,6 +16,7 @@ #include <zzip/zzip.h> #include <zzip/plugin.h> #include <zzip/stdint.h> +#include <zzip/zzip32.h> #ifdef __cplusplus extern "C" { diff --git a/Build/source/texk/web2c/Makefile.am b/Build/source/texk/web2c/Makefile.am index 38740776acf..ec388fc2bff 100644 --- a/Build/source/texk/web2c/Makefile.am +++ b/Build/source/texk/web2c/Makefile.am @@ -237,6 +237,7 @@ include $(srcdir)/luatexdir/am/libunilib.am include $(srcdir)/luatexdir/am/luafontforge.am include $(srcdir)/luatexdir/am/libluatex.am include $(srcdir)/luatexdir/am/luaffi.am +include $(srcdir)/luatexdir/am/luapplib.am include $(srcdir)/luatexdir/am/luatex.am ## XeTeX diff --git a/Build/source/texk/web2c/ac/web2c.ac b/Build/source/texk/web2c/ac/web2c.ac index 8cf40e03c93..27bd6bb2c8d 100644 --- a/Build/source/texk/web2c/ac/web2c.ac +++ b/Build/source/texk/web2c/ac/web2c.ac @@ -35,9 +35,9 @@ m4_define([kpse_tex_progs], [dnl [[euptex], [yes], [yes], [e-upTeX], [ptexenc]], [[aleph], [yes], [], [Aleph], []], [[pdftex], [yes], [yes], [pdfTeX], [xpdf libpng]], -[[luatex], [yes], [], [LuaTeX], [poppler mpfr libpng zziplib lua52]], -[[luatex53], [yes], [], [LuaTeX53], [poppler mpfr libpng zziplib lua53]], -[[luajittex], [yes], [], [LuaJITTeX], [poppler mpfr libpng zziplib luajit]], +[[luatex], [yes], [], [LuaTeX], [libpng zziplib lua52]], +[[luatex53], [yes], [], [LuaTeX53], [libpng zziplib lua53]], +[[luajittex], [yes], [], [LuaJITTeX], [libpng zziplib luajit]], [[mp], [yes], [], [MetaPost], [mpfr cairo libpng]], [[pmp], [yes], [], [pMetaPost], [mpfr cairo libpng ptexenc]], [[upmp], [yes], [], [upMetaPost], [mpfr cairo libpng ptexenc]], diff --git a/Build/source/texk/web2c/configure.ac b/Build/source/texk/web2c/configure.ac index 6c083929715..5448f620321 100644 --- a/Build/source/texk/web2c/configure.ac +++ b/Build/source/texk/web2c/configure.ac @@ -46,13 +46,10 @@ KPSE_LT_HACK KPSE_WEB2C_PREPARE m4_include([ac/web2c.ac]) -# LuaTeX and XeTeX now require C++11 because poppler does :(. +# XeTeX now requires C++11 because poppler does :(. # XeTeX also requires C+11 because of ICU. -if test "x$enable_xetex" = xyes \ - || test "x$enable_luatex" = xyes \ - || test "x$enable_luajittex" = xyes \ - || test "x$enable_luatex53" = xyes; then - AC_MSG_NOTICE([checking for C++11, since LuaTeX and/or XeTeX enabled]) +if test "x$enable_xetex" = xyes; then + AC_MSG_NOTICE([checking for C++11, since XeTeX enabled]) AX_CXX_COMPILE_STDCXX([11]) fi diff --git a/Build/source/texk/web2c/luatexdir/ChangeLog b/Build/source/texk/web2c/luatexdir/ChangeLog index 94cbfc3e6d5..62d4ab0491f 100644 --- a/Build/source/texk/web2c/luatexdir/ChangeLog +++ b/Build/source/texk/web2c/luatexdir/ChangeLog @@ -1,3 +1,7 @@ +2018-08-27 Luigi Scarso <luigi.scarso@gmail.com> + * dropped dependency from gmp and mpfr + + 2017-11-02 Luigi Scarso <luigi.scarso@gmail.com> LuaFilesystem 1.7.0 diff --git a/Build/source/texk/web2c/luatexdir/NEWS b/Build/source/texk/web2c/luatexdir/NEWS index 91a4ec7fec1..5c044e77e18 100644 --- a/Build/source/texk/web2c/luatexdir/NEWS +++ b/Build/source/texk/web2c/luatexdir/NEWS @@ -1,4 +1,39 @@ ============================================================== +LuaTeX 1.08 2018-08-28 +============================================================== + + +(1) This release is a prelude to 1.10, the next stable iteration of LuaTeX +after version 1.00. + +(2) Lua 5.3 is now considered to be default and we might use 5.4 in version +1.10. There are no real functional changed expected. You still need to rename +the binary for 5.3! + +(3) Binary mode is no longer available in MPlib but it is still available in +stand alone MetaPost. This simplifies compilation and reduces dependencies. + +(4) The dependency on Poppler for pdf image inclusion has been removed. We +now use a small dedicated library written by Pawel Jakowski. We no longer +need c++ compilers. We're in the process of making it behave well on all +platforms. It has been tested on intel platforms. + +(5) We know that there can be some (alignment) issues with the arm platform +but these are looked into. Therefore, later this year we will release 1.09. +Version 1.10 is planned for TeXlive. We hope that ffi works ok on intel and +arm platforms at that point. + +(6) There have been some extensions to the Lua libraries and some callbacks +have been added. Also, a few new primitives have been introduced. The +documentation mentions the stable extensions. + +(7) There are the usual bug fixes and cleanups but there have been no real +fundamental changes in the API. + + + + +============================================================== LuaTeX 1.07 2018-01-17 ============================================================== diff --git a/Build/source/texk/web2c/luatexdir/am/libluatex.am b/Build/source/texk/web2c/luatexdir/am/libluatex.am index 3e90186acc3..e3678b64b9e 100644 --- a/Build/source/texk/web2c/luatexdir/am/libluatex.am +++ b/Build/source/texk/web2c/luatexdir/am/libluatex.am @@ -26,9 +26,10 @@ liblua53tex_a_DEPENDENCIES = libff.a liblua53misc.a libluajittex_a_DEPENDENCIES = libff.a libluajitmisc.a libluatex_a_preflags = $(AM_CPPFLAGS) $(ZLIB_INCLUDES) $(LIBPNG_INCLUDES) -libluatex_a_preflags += $(POPPLER_INCLUDES) -I$(srcdir)/libmd5 +libluatex_a_preflags += -I$(srcdir)/libmd5 libluatex_a_preflags += -DpdfTeX -I$(srcdir)/luatexdir libluatex_a_preflags += -I$(srcdir)/luatexdir/unilib +libluatex_a_preflags += -I$(srcdir)/luatexdir/luapplib/util libluatex_a_preflags += -I$(srcdir)/luatexdir/luafontloader/fontforge/inc libluatex_a_preflags += -DLUA_FF_LIB=1 -I$(srcdir)/luatexdir/luafontloader/fontforge/fontforge libluatex_a_preflags += -DSYNCTEX_ENGINE_H='<synctex-luatex.h>' -I$(srcdir)/synctexdir @@ -43,29 +44,31 @@ liblua53tex_a_CXXFLAGS = $(WARNING_CXXFLAGS) libluajittex_a_CXXFLAGS = $(WARNING_CXXFLAGS) dist_libluatex_a_SOURCES = \ - luatexdir/lua/lstrlibext.c + luatexdir/lua/lstrlibext.c \ + luatexdir/lua/helpers.c \ + luatexdir/lua/texluac.c nodist_libluatex_a_SOURCES = \ - helpers.c luastuff.c texluac.c \ $(dist_libluatex_sources) \ $(nodist_libluatex_sources) dist_liblua53tex_a_SOURCES = \ - luatexdir/lua/lstrlibext.c + luatexdir/lua/lstrlibext.c \ + luatexdir/lua/helpers.c \ + luatexdir/lua/texluac.c nodist_liblua53tex_a_SOURCES = \ - helpers.c luastuff.c texluac.c \ $(dist_libluatex_sources) \ $(nodist_libluatex_sources) dist_libluajittex_a_SOURCES = \ luatexdir/lua/lauxlib_bridge.h \ - luatexdir/lua/lstrlibext.c + luatexdir/lua/lstrlibext.c \ + luatexdir/lua/texluajitc.c nodist_libluajittex_a_SOURCES = \ - luastuff.c texluajitc.c \ $(dist_libluatex_sources) \ $(nodist_libluatex_sources) ## mplib "stub" backends are in mplibstuff.c -$(libluatex_a_OBJECTS): libff.a libmplibcore.a libluamisc.a $(POPPLER_DEPEND) -$(liblua53tex_a_OBJECTS): libff.a libmplibcore.a liblua53misc.a $(POPPLER_DEPEND) -$(libluajittex_a_OBJECTS): libff.a libmplibcore.a libluajitmisc.a $(POPPLER_DEPEND) +$(libluatex_a_OBJECTS): libff.a libmplibcore.a libluamisc.a +$(liblua53tex_a_OBJECTS): libff.a libmplibcore.a liblua53misc.a +$(libluajittex_a_OBJECTS): libff.a libmplibcore.a libluajitmisc.a ## from luatexdir @@ -91,76 +94,77 @@ dist_libluatex_sources += \ ## luatex_dvi_ctangle = $(ctangle_silent)CWEBINPUTS=$(srcdir)/luatexdir/dvi $(ctangle) -dvigen.c: ctangle$(EXEEXT) luatexdir/dvi/dvigen.w - $(luatex_dvi_ctangle) dvigen.w +#dvigen.c: ctangle$(EXEEXT) luatexdir/dvi/dvigen.w +# $(luatex_dvi_ctangle) dvigen.w -libluatex_web += luatexdir/dvi/dvigen.w +#libluatex_web += luatexdir/dvi/dvigen.w -nodist_libluatex_sources += dvigen.c +#nodist_libluatex_sources += dvigen.c dist_libluatex_sources += \ - luatexdir/dvi/dvigen.h + luatexdir/dvi/dvigen.h \ + luatexdir/dvi/dvigen.c ## from luatexdir/font ## luatex_font_ctangle = $(ctangle_silent)CWEBINPUTS=$(srcdir)/luatexdir/font $(ctangle) -dofont.c: ctangle$(EXEEXT) luatexdir/font/dofont.w - $(luatex_font_ctangle) dofont.w -luafont.c: ctangle$(EXEEXT) luatexdir/font/luafont.w - $(luatex_font_ctangle) luafont.w -mapfile.c: ctangle$(EXEEXT) luatexdir/font/mapfile.w - $(luatex_font_ctangle) mapfile.w -pkin.c: ctangle$(EXEEXT) luatexdir/font/pkin.w - $(luatex_font_ctangle) pkin.w -sfnt.c: ctangle$(EXEEXT) luatexdir/font/sfnt.w - $(luatex_font_ctangle) sfnt.w -texfont.c: ctangle$(EXEEXT) luatexdir/font/texfont.w - $(luatex_font_ctangle) texfont.w -tfmofm.c: ctangle$(EXEEXT) luatexdir/font/tfmofm.w - $(luatex_font_ctangle) tfmofm.w -tounicode.c: ctangle$(EXEEXT) luatexdir/font/tounicode.w - $(luatex_font_ctangle) tounicode.w -tt_glyf.c: ctangle$(EXEEXT) luatexdir/font/tt_glyf.w - $(luatex_font_ctangle) tt_glyf.w -tt_table.c: ctangle$(EXEEXT) luatexdir/font/tt_table.w - $(luatex_font_ctangle) tt_table.w -vfovf.c: ctangle$(EXEEXT) luatexdir/font/vfovf.w - $(luatex_font_ctangle) vfovf.w -vfpacket.c: ctangle$(EXEEXT) luatexdir/font/vfpacket.w - $(luatex_font_ctangle) vfpacket.w -writecff.c: ctangle$(EXEEXT) luatexdir/font/writecff.w - $(luatex_font_ctangle) writecff.w -writeenc.c: ctangle$(EXEEXT) luatexdir/font/writeenc.w - $(luatex_font_ctangle) writeenc.w -writefont.c: ctangle$(EXEEXT) luatexdir/font/writefont.w - $(luatex_font_ctangle) writefont.w -writet1.c: ctangle$(EXEEXT) luatexdir/font/writet1.w - $(luatex_font_ctangle) writet1.w -writet3.c: ctangle$(EXEEXT) luatexdir/font/writet3.w - $(luatex_font_ctangle) writet3.w -writettf.c: ctangle$(EXEEXT) luatexdir/font/writettf.w - $(luatex_font_ctangle) writettf.w -writetype0.c: ctangle$(EXEEXT) luatexdir/font/writetype0.w - $(luatex_font_ctangle) writetype0.w -writetype2.c: ctangle$(EXEEXT) luatexdir/font/writetype2.w - $(luatex_font_ctangle) writetype2.w - -libluatex_web += luatexdir/font/dofont.w luatexdir/font/luafont.w luatexdir/font/mapfile.w -libluatex_web += luatexdir/font/pkin.w luatexdir/font/sfnt.w -libluatex_web += luatexdir/font/texfont.w luatexdir/font/tfmofm.w -libluatex_web += luatexdir/font/tounicode.w luatexdir/font/tt_glyf.w -libluatex_web += luatexdir/font/tt_table.w luatexdir/font/vfovf.w -libluatex_web += luatexdir/font/vfpacket.w luatexdir/font/writecff.w -libluatex_web += luatexdir/font/writeenc.w luatexdir/font/writefont.w -libluatex_web += luatexdir/font/writet1.w luatexdir/font/writet3.w -libluatex_web += luatexdir/font/writettf.w luatexdir/font/writetype0.w -libluatex_web += luatexdir/font/writetype2.w - -nodist_libluatex_sources += dofont.c luafont.c mapfile.c pkin.c sfnt.c -nodist_libluatex_sources += texfont.c tfmofm.c tounicode.c tt_glyf.c tt_table.c vfovf.c vfpacket.c -nodist_libluatex_sources += writecff.c writeenc.c writefont.c writet1.c writet3.c writettf.c -nodist_libluatex_sources += writetype0.c writetype2.c +# dofont.c: ctangle$(EXEEXT) luatexdir/font/dofont.w +# $(luatex_font_ctangle) dofont.w +# luafont.c: ctangle$(EXEEXT) luatexdir/font/luafont.w +# $(luatex_font_ctangle) luafont.w +# mapfile.c: ctangle$(EXEEXT) luatexdir/font/mapfile.w +# $(luatex_font_ctangle) mapfile.w +# pkin.c: ctangle$(EXEEXT) luatexdir/font/pkin.w +# $(luatex_font_ctangle) pkin.w +# sfnt.c: ctangle$(EXEEXT) luatexdir/font/sfnt.w +# $(luatex_font_ctangle) sfnt.w +# texfont.c: ctangle$(EXEEXT) luatexdir/font/texfont.w +# $(luatex_font_ctangle) texfont.w +# tfmofm.c: ctangle$(EXEEXT) luatexdir/font/tfmofm.w +# $(luatex_font_ctangle) tfmofm.w +# tounicode.c: ctangle$(EXEEXT) luatexdir/font/tounicode.w +# $(luatex_font_ctangle) tounicode.w +# tt_glyf.c: ctangle$(EXEEXT) luatexdir/font/tt_glyf.w +# $(luatex_font_ctangle) tt_glyf.w +# tt_table.c: ctangle$(EXEEXT) luatexdir/font/tt_table.w +# $(luatex_font_ctangle) tt_table.w +# vfovf.c: ctangle$(EXEEXT) luatexdir/font/vfovf.w +# $(luatex_font_ctangle) vfovf.w +# vfpacket.c: ctangle$(EXEEXT) luatexdir/font/vfpacket.w +# $(luatex_font_ctangle) vfpacket.w +# writecff.c: ctangle$(EXEEXT) luatexdir/font/writecff.w +# $(luatex_font_ctangle) writecff.w +# writeenc.c: ctangle$(EXEEXT) luatexdir/font/writeenc.w +# $(luatex_font_ctangle) writeenc.w +# writefont.c: ctangle$(EXEEXT) luatexdir/font/writefont.w +# $(luatex_font_ctangle) writefont.w +# writet1.c: ctangle$(EXEEXT) luatexdir/font/writet1.w +# $(luatex_font_ctangle) writet1.w +# writet3.c: ctangle$(EXEEXT) luatexdir/font/writet3.w +# $(luatex_font_ctangle) writet3.w +# writettf.c: ctangle$(EXEEXT) luatexdir/font/writettf.w +# $(luatex_font_ctangle) writettf.w +# writetype0.c: ctangle$(EXEEXT) luatexdir/font/writetype0.w +# $(luatex_font_ctangle) writetype0.w +# writetype2.c: ctangle$(EXEEXT) luatexdir/font/writetype2.w +# $(luatex_font_ctangle) writetype2.w + +# libluatex_web += luatexdir/font/dofont.w luatexdir/font/luafont.w luatexdir/font/mapfile.w +# libluatex_web += luatexdir/font/pkin.w luatexdir/font/sfnt.w +# libluatex_web += luatexdir/font/texfont.w luatexdir/font/tfmofm.w +# libluatex_web += luatexdir/font/tounicode.w luatexdir/font/tt_glyf.w +# libluatex_web += luatexdir/font/tt_table.w luatexdir/font/vfovf.w +# libluatex_web += luatexdir/font/vfpacket.w luatexdir/font/writecff.w +# libluatex_web += luatexdir/font/writeenc.w luatexdir/font/writefont.w +# libluatex_web += luatexdir/font/writet1.w luatexdir/font/writet3.w +# libluatex_web += luatexdir/font/writettf.w luatexdir/font/writetype0.w +# libluatex_web += luatexdir/font/writetype2.w + +# nodist_libluatex_sources += dofont.c luafont.c mapfile.c pkin.c sfnt.c +# nodist_libluatex_sources += texfont.c tfmofm.c tounicode.c tt_glyf.c tt_table.c vfovf.c vfpacket.c +# nodist_libluatex_sources += writecff.c writeenc.c writefont.c writet1.c writet3.c writettf.c +# nodist_libluatex_sources += writetype0.c writetype2.c dist_libluatex_sources += \ luatexdir/font/luatexfont.h \ @@ -170,33 +174,54 @@ dist_libluatex_sources += \ luatexdir/font/tt_glyf.h \ luatexdir/font/tt_table.h \ luatexdir/font/writecff.h \ - luatexdir/font/writettf.h + luatexdir/font/writettf.h \ + luatexdir/font/dofont.c \ + luatexdir/font/luafont.c \ + luatexdir/font/mapfile.c \ + luatexdir/font/pkin.c \ + luatexdir/font/sfnt.c \ + luatexdir/font/texfont.c \ + luatexdir/font/tfmofm.c \ + luatexdir/font/tounicode.c \ + luatexdir/font/tt_glyf.c \ + luatexdir/font/tt_table.c \ + luatexdir/font/vfovf.c \ + luatexdir/font/vfpacket.c \ + luatexdir/font/writecff.c \ + luatexdir/font/writeenc.c \ + luatexdir/font/writefont.c \ + luatexdir/font/writet1.c \ + luatexdir/font/writet3.c \ + luatexdir/font/writettf.c \ + luatexdir/font/writetype0.c \ + luatexdir/font/writetype2.c + ## from luatexdir/image ## luatex_image_ctangle = $(ctangle_silent)CWEBINPUTS=$(srcdir)/luatexdir/image $(ctangle) -writeimg.c: ctangle$(EXEEXT) luatexdir/image/writeimg.w - $(luatex_image_ctangle) writeimg.w -writejbig2.c: ctangle$(EXEEXT) luatexdir/image/writejbig2.w - $(luatex_image_ctangle) writejbig2.w -writejpg.c: ctangle$(EXEEXT) luatexdir/image/writejpg.w - $(luatex_image_ctangle) writejpg.w -writejp2.c: ctangle$(EXEEXT) luatexdir/image/writejp2.w - $(luatex_image_ctangle) writejp2.w -writepng.c: ctangle$(EXEEXT) luatexdir/image/writepng.w - $(luatex_image_ctangle) writepng.w -pdftoepdf.cc: ctangle$(EXEEXT) luatexdir/image/pdftoepdf.w - $(luatex_image_ctangle) pdftoepdf.w - $@ - -libluatex_web += luatexdir/image/writeimg.w -libluatex_web += luatexdir/image/writejbig2.w -libluatex_web += luatexdir/image/writejpg.w -libluatex_web += luatexdir/image/writejp2.w -libluatex_web += luatexdir/image/writepng.w -libluatex_web += luatexdir/image/pdftoepdf.w - -nodist_libluatex_sources += writeimg.c writejbig2.c writejpg.c writejp2.c writepng.c pdftoepdf.cc +#writeimg.c: ctangle$(EXEEXT) luatexdir/image/writeimg.w +# $(luatex_image_ctangle) writeimg.w +#writejbig2.c: ctangle$(EXEEXT) luatexdir/image/writejbig2.w +# $(luatex_image_ctangle) writejbig2.w +#writejpg.c: ctangle$(EXEEXT) luatexdir/image/writejpg.w +# $(luatex_image_ctangle) writejpg.w +#writejp2.c: ctangle$(EXEEXT) luatexdir/image/writejp2.w +# $(luatex_image_ctangle) writejp2.w +#writepng.c: ctangle$(EXEEXT) luatexdir/image/writepng.w +# $(luatex_image_ctangle) writepng.w +#pdftoepdf.cc: ctangle$(EXEEXT) luatexdir/image/pdftoepdf.w +# $(luatex_image_ctangle) pdftoepdf.w - $@ + +#libluatex_web += luatexdir/image/writeimg.w +#libluatex_web += luatexdir/image/writejbig2.w +#libluatex_web += luatexdir/image/writejpg.w +#libluatex_web += luatexdir/image/writejp2.w +#libluatex_web += luatexdir/image/writepng.w +#libluatex_web += luatexdir/image/pdftoepdf.w + +#nodist_libluatex_sources += writeimg.c writejbig2.c writejpg.c writejp2.c writepng.c dist_libluatex_sources += \ luatexdir/image/epdf.h \ @@ -206,72 +231,61 @@ dist_libluatex_sources += \ luatexdir/image/writejbig2.h \ luatexdir/image/writejpg.h \ luatexdir/image/writejp2.h \ - luatexdir/image/writepng.h + luatexdir/image/writepng.h \ + luatexdir/image/pdftoepdf.c \ + luatexdir/image/writeimg.c \ + luatexdir/image/writejbig2.c \ + luatexdir/image/writejp2.c \ + luatexdir/image/writejpg.c \ + luatexdir/image/writepng.c ## from luatexdir/lang ## luatex_lang_ctangle = $(ctangle_silent)CWEBINPUTS=$(srcdir)/luatexdir/lang $(ctangle) -hnjalloc.c: ctangle$(EXEEXT) luatexdir/lang/hnjalloc.w - $(luatex_lang_ctangle) hnjalloc.w -hyphen.c: ctangle$(EXEEXT) luatexdir/lang/hyphen.w - $(luatex_lang_ctangle) hyphen.w -texlang.c: ctangle$(EXEEXT) luatexdir/lang/texlang.w - $(luatex_lang_ctangle) texlang.w - -libluatex_web += luatexdir/lang/texlang.w luatexdir/lang/hyphen.w luatexdir/lang/hnjalloc.w - -nodist_libluatex_sources += texlang.c hyphen.c hnjalloc.c - dist_libluatex_sources += \ luatexdir/lang/hnjalloc.h \ luatexdir/lang/hyphen.h \ - luatexdir/lang/texlang.h + luatexdir/lang/texlang.h \ + luatexdir/lang/hnjalloc.c \ + luatexdir/lang/hyphen.c \ + luatexdir/lang/texlang.c ## from luatexdir/lua ## luatex_lua_ctangle = $(ctangle_silent)CWEBINPUTS=$(srcdir)/luatexdir/lua $(ctangle) -helpers.c: ctangle$(EXEEXT) luatexdir/lua/helpers.w - $(luatex_lua_ctangle) helpers.w -luainit.c: ctangle$(EXEEXT) luatexdir/lua/luainit.w - $(luatex_lua_ctangle) luainit.w +#helpers.c: ctangle$(EXEEXT) luatexdir/lua/helpers.w +# $(luatex_lua_ctangle) helpers.w +#luainit.c: ctangle$(EXEEXT) luatexdir/lua/luainit.w +# $(luatex_lua_ctangle) luainit.w #luajitstuff.c: ctangle$(EXEEXT) luatexdir/lua/luajitstuff.w # $(luatex_lua_ctangle) luajitstuff.w -luanode.c: ctangle$(EXEEXT) luatexdir/lua/luanode.w - $(luatex_lua_ctangle) luanode.w -luastuff.c: ctangle$(EXEEXT) luatexdir/lua/luastuff.w - $(luatex_lua_ctangle) luastuff.w -luatoken.c: ctangle$(EXEEXT) luatexdir/lua/luatoken.w - $(luatex_lua_ctangle) luatoken.w -mplibstuff.c: ctangle$(EXEEXT) luatexdir/lua/mplibstuff.w - $(luatex_lua_ctangle) mplibstuff.w -texluac.c: ctangle$(EXEEXT) luatexdir/lua/texluac.w - $(luatex_lua_ctangle) texluac.w -texluajitc.c: ctangle$(EXEEXT) luatexdir/lua/texluajitc.w - $(luatex_lua_ctangle) texluajitc.w - -libluatex_web += luatexdir/lua/helpers.w -#libluatex_web += luatexdir/lua/luainit.w luatexdir/lua/luajitstuff.w -libluatex_web += luatexdir/lua/luainit.w -libluatex_web += luatexdir/lua/luanode.w luatexdir/lua/luastuff.w luatexdir/lua/luatoken.w -libluatex_web += luatexdir/lua/mplibstuff.w -libluatex_web += luatexdir/lua/texluac.w luatexdir/lua/texluajitc.w +#luanode.c: ctangle$(EXEEXT) luatexdir/lua/luanode.w +# $(luatex_lua_ctangle) luanode.w +#luastuff.c: ctangle$(EXEEXT) luatexdir/lua/luastuff.w +# $(luatex_lua_ctangle) luastuff.w +#luatoken.c: ctangle$(EXEEXT) luatexdir/lua/luatoken.w +# $(luatex_lua_ctangle) luatoken.w +#mplibstuff.c: ctangle$(EXEEXT) luatexdir/lua/mplibstuff.w +# $(luatex_lua_ctangle) mplibstuff.w +#texluac.c: ctangle$(EXEEXT) luatexdir/lua/texluac.w +# $(luatex_lua_ctangle) texluac.w +#texluajitc.c: ctangle$(EXEEXT) luatexdir/lua/texluajitc.w +# $(luatex_lua_ctangle) texluajitc.w -nodist_libluatex_sources += luainit.c luanode.c luatoken.c -nodist_libluatex_sources += mplibstuff.c +#libluatex_web += luatexdir/lua/luainit.w luatexdir/lua/luajitstuff.w dist_libluatex_sources += \ luatexdir/lua/lcallbacklib.c \ luatexdir/lua/lfontlib.c \ luatexdir/lua/limglib.c \ - luatexdir/lua/lpdfscannerlib.cc \ - luatexdir/lua/lepdflib.cc \ + luatexdir/lua/lpdfelib.c \ + luatexdir/lua/lpdfscannerlib.c \ luatexdir/lua/lkpselib.c \ luatexdir/lua/llanglib.c \ luatexdir/lua/llualib.c \ - luatexdir/lua/llfslibext.c \ luatexdir/lua/lnodelib.c \ luatexdir/lua/liolibext.c \ luatexdir/lua/loslibext.c \ @@ -281,71 +295,79 @@ dist_libluatex_sources += \ luatexdir/lua/ltexlib.c \ luatexdir/lua/lnewtokenlib.c \ luatexdir/lua/luatex-api.h \ - luatexdir/lua/luatex-core.c + luatexdir/lua/luatex-core.c \ + luatexdir/lua/helpers.c \ + luatexdir/lua/luainit.c \ + luatexdir/lua/luanode.c \ + luatexdir/lua/luastuff.c \ + luatexdir/lua/luatoken.c \ + luatexdir/lua/mplibstuff.c + + ## from luatexdir/pdf ## luatex_pdf_ctangle = $(ctangle_silent)CWEBINPUTS=$(srcdir)/luatexdir/pdf $(ctangle) -pdfpagetree.c: ctangle$(EXEEXT) luatexdir/pdf/pdfpagetree.w - $(luatex_pdf_ctangle) pdfpagetree.w -pdfaction.c: ctangle$(EXEEXT) luatexdir/pdf/pdfaction.w - $(luatex_pdf_ctangle) pdfaction.w -pdfannot.c: ctangle$(EXEEXT) luatexdir/pdf/pdfannot.w - $(luatex_pdf_ctangle) pdfannot.w -pdfcolorstack.c: ctangle$(EXEEXT) luatexdir/pdf/pdfcolorstack.w - $(luatex_pdf_ctangle) pdfcolorstack.w -pdfdest.c: ctangle$(EXEEXT) luatexdir/pdf/pdfdest.w - $(luatex_pdf_ctangle) pdfdest.w -pdffont.c: ctangle$(EXEEXT) luatexdir/pdf/pdffont.w - $(luatex_pdf_ctangle) pdffont.w -pdfgen.c: ctangle$(EXEEXT) luatexdir/pdf/pdfgen.w - $(luatex_pdf_ctangle) pdfgen.w -pdfglyph.c: ctangle$(EXEEXT) luatexdir/pdf/pdfglyph.w - $(luatex_pdf_ctangle) pdfglyph.w -pdfimage.c: ctangle$(EXEEXT) luatexdir/pdf/pdfimage.w - $(luatex_pdf_ctangle) pdfimage.w -pdflink.c: ctangle$(EXEEXT) luatexdir/pdf/pdflink.w - $(luatex_pdf_ctangle) pdflink.w -pdflistout.c: ctangle$(EXEEXT) luatexdir/pdf/pdflistout.w - $(luatex_pdf_ctangle) pdflistout.w -pdfliteral.c: ctangle$(EXEEXT) luatexdir/pdf/pdfliteral.w - $(luatex_pdf_ctangle) pdfliteral.w -pdfobj.c: ctangle$(EXEEXT) luatexdir/pdf/pdfobj.w - $(luatex_pdf_ctangle) pdfobj.w -pdfoutline.c: ctangle$(EXEEXT) luatexdir/pdf/pdfoutline.w - $(luatex_pdf_ctangle) pdfoutline.w -pdfpage.c: ctangle$(EXEEXT) luatexdir/pdf/pdfpage.w - $(luatex_pdf_ctangle) pdfpage.w -pdfrule.c: ctangle$(EXEEXT) luatexdir/pdf/pdfrule.w - $(luatex_pdf_ctangle) pdfrule.w -pdfsaverestore.c: ctangle$(EXEEXT) luatexdir/pdf/pdfsaverestore.w - $(luatex_pdf_ctangle) pdfsaverestore.w -pdfsetmatrix.c: ctangle$(EXEEXT) luatexdir/pdf/pdfsetmatrix.w - $(luatex_pdf_ctangle) pdfsetmatrix.w -pdfshipout.c: ctangle$(EXEEXT) luatexdir/pdf/pdfshipout.w - $(luatex_pdf_ctangle) pdfshipout.w -pdftables.c: ctangle$(EXEEXT) luatexdir/pdf/pdftables.w - $(luatex_pdf_ctangle) pdftables.w -pdfthread.c: ctangle$(EXEEXT) luatexdir/pdf/pdfthread.w - $(luatex_pdf_ctangle) pdfthread.w -pdfxform.c: ctangle$(EXEEXT) luatexdir/pdf/pdfxform.w - $(luatex_pdf_ctangle) pdfxform.w - -libluatex_web += luatexdir/pdf/pdfpagetree.w luatexdir/pdf/pdfaction.w luatexdir/pdf/pdfannot.w -libluatex_web += luatexdir/pdf/pdfcolorstack.w luatexdir/pdf/pdfdest.w -libluatex_web += luatexdir/pdf/pdffont.w luatexdir/pdf/pdfgen.w luatexdir/pdf/pdfglyph.w -libluatex_web += luatexdir/pdf/pdfimage.w luatexdir/pdf/pdflink.w luatexdir/pdf/pdflistout.w -libluatex_web += luatexdir/pdf/pdfliteral.w luatexdir/pdf/pdfobj.w -libluatex_web += luatexdir/pdf/pdfoutline.w luatexdir/pdf/pdfpage.w luatexdir/pdf/pdfrule.w -libluatex_web += luatexdir/pdf/pdfsaverestore.w luatexdir/pdf/pdfsetmatrix.w -libluatex_web += luatexdir/pdf/pdfshipout.w luatexdir/pdf/pdftables.w -libluatex_web += luatexdir/pdf/pdfthread.w luatexdir/pdf/pdfxform.w - -nodist_libluatex_sources += pdfpagetree.c pdfaction.c pdfannot.c pdfcolorstack.c pdfdest.c pdffont.c -nodist_libluatex_sources += pdfgen.c pdfglyph.c pdfimage.c pdflink.c pdflistout.c pdfliteral.c -nodist_libluatex_sources += pdfobj.c pdfoutline.c pdfpage.c pdfrule.c pdfsaverestore.c -nodist_libluatex_sources += pdfsetmatrix.c pdfshipout.c pdftables.c pdfthread.c pdfxform.c +# pdfpagetree.c: ctangle$(EXEEXT) luatexdir/pdf/pdfpagetree.w +# $(luatex_pdf_ctangle) pdfpagetree.w +# pdfaction.c: ctangle$(EXEEXT) luatexdir/pdf/pdfaction.w +# $(luatex_pdf_ctangle) pdfaction.w +# pdfannot.c: ctangle$(EXEEXT) luatexdir/pdf/pdfannot.w +# $(luatex_pdf_ctangle) pdfannot.w +# pdfcolorstack.c: ctangle$(EXEEXT) luatexdir/pdf/pdfcolorstack.w +# $(luatex_pdf_ctangle) pdfcolorstack.w +# pdfdest.c: ctangle$(EXEEXT) luatexdir/pdf/pdfdest.w +# $(luatex_pdf_ctangle) pdfdest.w +# pdffont.c: ctangle$(EXEEXT) luatexdir/pdf/pdffont.w +# $(luatex_pdf_ctangle) pdffont.w +# pdfgen.c: ctangle$(EXEEXT) luatexdir/pdf/pdfgen.w +# $(luatex_pdf_ctangle) pdfgen.w +# pdfglyph.c: ctangle$(EXEEXT) luatexdir/pdf/pdfglyph.w +# $(luatex_pdf_ctangle) pdfglyph.w +# pdfimage.c: ctangle$(EXEEXT) luatexdir/pdf/pdfimage.w +# $(luatex_pdf_ctangle) pdfimage.w +# pdflink.c: ctangle$(EXEEXT) luatexdir/pdf/pdflink.w +# $(luatex_pdf_ctangle) pdflink.w +# pdflistout.c: ctangle$(EXEEXT) luatexdir/pdf/pdflistout.w +# $(luatex_pdf_ctangle) pdflistout.w +# pdfliteral.c: ctangle$(EXEEXT) luatexdir/pdf/pdfliteral.w +# $(luatex_pdf_ctangle) pdfliteral.w +# pdfobj.c: ctangle$(EXEEXT) luatexdir/pdf/pdfobj.w +# $(luatex_pdf_ctangle) pdfobj.w +# pdfoutline.c: ctangle$(EXEEXT) luatexdir/pdf/pdfoutline.w +# $(luatex_pdf_ctangle) pdfoutline.w +# pdfpage.c: ctangle$(EXEEXT) luatexdir/pdf/pdfpage.w +# $(luatex_pdf_ctangle) pdfpage.w +# pdfrule.c: ctangle$(EXEEXT) luatexdir/pdf/pdfrule.w +# $(luatex_pdf_ctangle) pdfrule.w +# pdfsaverestore.c: ctangle$(EXEEXT) luatexdir/pdf/pdfsaverestore.w +# $(luatex_pdf_ctangle) pdfsaverestore.w +# pdfsetmatrix.c: ctangle$(EXEEXT) luatexdir/pdf/pdfsetmatrix.w +# $(luatex_pdf_ctangle) pdfsetmatrix.w +# pdfshipout.c: ctangle$(EXEEXT) luatexdir/pdf/pdfshipout.w +# $(luatex_pdf_ctangle) pdfshipout.w +# pdftables.c: ctangle$(EXEEXT) luatexdir/pdf/pdftables.w +# $(luatex_pdf_ctangle) pdftables.w +# pdfthread.c: ctangle$(EXEEXT) luatexdir/pdf/pdfthread.w +# $(luatex_pdf_ctangle) pdfthread.w +# pdfxform.c: ctangle$(EXEEXT) luatexdir/pdf/pdfxform.w +# $(luatex_pdf_ctangle) pdfxform.w + +#libluatex_web += luatexdir/pdf/pdfpagetree.w luatexdir/pdf/pdfaction.w luatexdir/pdf/pdfannot.w +#libluatex_web += luatexdir/pdf/pdfcolorstack.w luatexdir/pdf/pdfdest.w +#libluatex_web += luatexdir/pdf/pdffont.w luatexdir/pdf/pdfgen.w luatexdir/pdf/pdfglyph.w +#libluatex_web += luatexdir/pdf/pdfimage.w luatexdir/pdf/pdflink.w luatexdir/pdf/pdflistout.w +#libluatex_web += luatexdir/pdf/pdfliteral.w luatexdir/pdf/pdfobj.w +#libluatex_web += luatexdir/pdf/pdfoutline.w luatexdir/pdf/pdfpage.w luatexdir/pdf/pdfrule.w +#libluatex_web += luatexdir/pdf/pdfsaverestore.w luatexdir/pdf/pdfsetmatrix.w +#libluatex_web += luatexdir/pdf/pdfshipout.w luatexdir/pdf/pdftables.w +#libluatex_web += luatexdir/pdf/pdfthread.w luatexdir/pdf/pdfxform.w + +#nodist_libluatex_sources += pdfpagetree.c pdfaction.c pdfannot.c pdfcolorstack.c pdfdest.c pdffont.c +#nodist_libluatex_sources += pdfgen.c pdfglyph.c pdfimage.c pdflink.c pdflistout.c pdfliteral.c +#nodist_libluatex_sources += pdfobj.c pdfoutline.c pdfpage.c pdfrule.c pdfsaverestore.c +#nodist_libluatex_sources += pdfsetmatrix.c pdfshipout.c pdftables.c pdfthread.c pdfxform.c dist_libluatex_sources += \ luatexdir/pdf/pdfpagetree.h \ @@ -370,7 +392,29 @@ dist_libluatex_sources += \ luatexdir/pdf/pdftables.h \ luatexdir/pdf/pdfthread.h \ luatexdir/pdf/pdftypes.h \ - luatexdir/pdf/pdfxform.h + luatexdir/pdf/pdfxform.h \ + luatexdir/pdf/pdfaction.c \ + luatexdir/pdf/pdfannot.c \ + luatexdir/pdf/pdfcolorstack.c \ + luatexdir/pdf/pdfdest.c \ + luatexdir/pdf/pdffont.c \ + luatexdir/pdf/pdfgen.c \ + luatexdir/pdf/pdfglyph.c \ + luatexdir/pdf/pdfimage.c \ + luatexdir/pdf/pdflink.c \ + luatexdir/pdf/pdflistout.c \ + luatexdir/pdf/pdfliteral.c \ + luatexdir/pdf/pdfobj.c \ + luatexdir/pdf/pdfoutline.c \ + luatexdir/pdf/pdfpage.c \ + luatexdir/pdf/pdfpagetree.c \ + luatexdir/pdf/pdfrule.c \ + luatexdir/pdf/pdfsaverestore.c \ + luatexdir/pdf/pdfsetmatrix.c \ + luatexdir/pdf/pdfshipout.c \ + luatexdir/pdf/pdftables.c \ + luatexdir/pdf/pdfthread.c \ + luatexdir/pdf/pdfxform.c ################################################################################ ################################################################################ @@ -415,93 +459,79 @@ dist_libluatex_sources += \ ## luatex_tex_ctangle = $(ctangle_silent)CWEBINPUTS=$(srcdir)/luatexdir/tex $(ctangle) -align.c: ctangle$(EXEEXT) luatexdir/tex/align.w - $(luatex_tex_ctangle) align.w -arithmetic.c: ctangle$(EXEEXT) luatexdir/tex/arithmetic.w - $(luatex_tex_ctangle) arithmetic.w -buildpage.c: ctangle$(EXEEXT) luatexdir/tex/buildpage.w - $(luatex_tex_ctangle) buildpage.w -commands.c: ctangle$(EXEEXT) luatexdir/tex/commands.w - $(luatex_tex_ctangle) commands.w -conditional.c: ctangle$(EXEEXT) luatexdir/tex/conditional.w - $(luatex_tex_ctangle) conditional.w -directions.c: ctangle$(EXEEXT) luatexdir/tex/directions.w - $(luatex_tex_ctangle) directions.w -dumpdata.c: ctangle$(EXEEXT) luatexdir/tex/dumpdata.w - $(luatex_tex_ctangle) dumpdata.w -equivalents.c: ctangle$(EXEEXT) luatexdir/tex/equivalents.w - $(luatex_tex_ctangle) equivalents.w -errors.c: ctangle$(EXEEXT) luatexdir/tex/errors.w - $(luatex_tex_ctangle) errors.w -expand.c: ctangle$(EXEEXT) luatexdir/tex/expand.w - $(luatex_tex_ctangle) expand.w -extensions.c: ctangle$(EXEEXT) luatexdir/tex/extensions.w - $(luatex_tex_ctangle) extensions.w -filename.c: ctangle$(EXEEXT) luatexdir/tex/filename.w - $(luatex_tex_ctangle) filename.w -inputstack.c: ctangle$(EXEEXT) luatexdir/tex/inputstack.w - $(luatex_tex_ctangle) inputstack.w -linebreak.c: ctangle$(EXEEXT) luatexdir/tex/linebreak.w - $(luatex_tex_ctangle) linebreak.w -mainbody.c: ctangle$(EXEEXT) luatexdir/tex/mainbody.w - $(luatex_tex_ctangle) mainbody.w -maincontrol.c: ctangle$(EXEEXT) luatexdir/tex/maincontrol.w - $(luatex_tex_ctangle) maincontrol.w -mathcodes.c: ctangle$(EXEEXT) luatexdir/tex/mathcodes.w - $(luatex_tex_ctangle) mathcodes.w -memoryword.c: ctangle$(EXEEXT) luatexdir/tex/memoryword.w - $(luatex_tex_ctangle) memoryword.w -mlist.c: ctangle$(EXEEXT) luatexdir/tex/mlist.w - $(luatex_tex_ctangle) mlist.w -nesting.c: ctangle$(EXEEXT) luatexdir/tex/nesting.w - $(luatex_tex_ctangle) nesting.w -packaging.c: ctangle$(EXEEXT) luatexdir/tex/packaging.w - $(luatex_tex_ctangle) packaging.w -postlinebreak.c: ctangle$(EXEEXT) luatexdir/tex/postlinebreak.w - $(luatex_tex_ctangle) postlinebreak.w -primitive.c: ctangle$(EXEEXT) luatexdir/tex/primitive.w - $(luatex_tex_ctangle) primitive.w -printing.c: ctangle$(EXEEXT) luatexdir/tex/printing.w - $(luatex_tex_ctangle) printing.w -scanning.c: ctangle$(EXEEXT) luatexdir/tex/scanning.w - $(luatex_tex_ctangle) scanning.w -stringpool.c: ctangle$(EXEEXT) luatexdir/tex/stringpool.w - $(luatex_tex_ctangle) stringpool.w -texdeffont.c: ctangle$(EXEEXT) luatexdir/tex/texdeffont.w - $(luatex_tex_ctangle) texdeffont.w -texfileio.c: ctangle$(EXEEXT) luatexdir/tex/texfileio.w - $(luatex_tex_ctangle) texfileio.w -texmath.c: ctangle$(EXEEXT) luatexdir/tex/texmath.w - $(luatex_tex_ctangle) texmath.w -texnodes.c: ctangle$(EXEEXT) luatexdir/tex/texnodes.w - $(luatex_tex_ctangle) texnodes.w -textcodes.c: ctangle$(EXEEXT) luatexdir/tex/textcodes.w - $(luatex_tex_ctangle) textcodes.w -textoken.c: ctangle$(EXEEXT) luatexdir/tex/textoken.w - $(luatex_tex_ctangle) textoken.w - -libluatex_web += luatexdir/tex/align.w luatexdir/tex/arithmetic.w luatexdir/tex/buildpage.w -libluatex_web += luatexdir/tex/commands.w luatexdir/tex/conditional.w luatexdir/tex/directions.w -libluatex_web += luatexdir/tex/dumpdata.w luatexdir/tex/equivalents.w luatexdir/tex/errors.w -libluatex_web += luatexdir/tex/expand.w luatexdir/tex/extensions.w luatexdir/tex/filename.w -libluatex_web += luatexdir/tex/inputstack.w luatexdir/tex/linebreak.w luatexdir/tex/mainbody.w -libluatex_web += luatexdir/tex/maincontrol.w luatexdir/tex/mathcodes.w luatexdir/tex/memoryword.w -libluatex_web += luatexdir/tex/mlist.w luatexdir/tex/nesting.w luatexdir/tex/packaging.w -libluatex_web += luatexdir/tex/postlinebreak.w luatexdir/tex/primitive.w luatexdir/tex/printing.w -libluatex_web += luatexdir/tex/scanning.w luatexdir/tex/stringpool.w luatexdir/tex/texdeffont.w -libluatex_web += luatexdir/tex/texfileio.w luatexdir/tex/texmath.w luatexdir/tex/texnodes.w -libluatex_web += luatexdir/tex/textcodes.w luatexdir/tex/textoken.w - -nodist_libluatex_sources += align.c arithmetic.c buildpage.c commands.c conditional.c directions.c -nodist_libluatex_sources += dumpdata.c equivalents.c errors.c expand.c extensions.c filename.c -nodist_libluatex_sources += inputstack.c linebreak.c mainbody.c maincontrol.c mathcodes.c -nodist_libluatex_sources += memoryword.c mlist.c nesting.c packaging.c postlinebreak.c -nodist_libluatex_sources += primitive.c printing.c scanning.c stringpool.c texdeffont.c -nodist_libluatex_sources += texfileio.c texmath.c texnodes.c textcodes.c textoken.c +# align.c: ctangle$(EXEEXT) luatexdir/tex/align.w +# $(luatex_tex_ctangle) align.w +#arithmetic.c: ctangle$(EXEEXT) luatexdir/tex/arithmetic.w +# $(luatex_tex_ctangle) arithmetic.w +# buildpage.c: ctangle$(EXEEXT) luatexdir/tex/buildpage.w +# $(luatex_tex_ctangle) buildpage.w +#commands.c: ctangle$(EXEEXT) luatexdir/tex/commands.w +# $(luatex_tex_ctangle) commands.w +#conditional.c: ctangle$(EXEEXT) luatexdir/tex/conditional.w +# $(luatex_tex_ctangle) conditional.w +#directions.c: ctangle$(EXEEXT) luatexdir/tex/directions.w +# $(luatex_tex_ctangle) directions.w +#dumpdata.c: ctangle$(EXEEXT) luatexdir/tex/dumpdata.w +# $(luatex_tex_ctangle) dumpdata.w +#equivalents.c: ctangle$(EXEEXT) luatexdir/tex/equivalents.w +# $(luatex_tex_ctangle) equivalents.w +#errors.c: ctangle$(EXEEXT) luatexdir/tex/errors.w +# $(luatex_tex_ctangle) errors.w +# expand.c: ctangle$(EXEEXT) luatexdir/tex/expand.w +# $(luatex_tex_ctangle) expand.w +# extensions.c: ctangle$(EXEEXT) luatexdir/tex/extensions.w +# $(luatex_tex_ctangle) extensions.w +#filename.c: ctangle$(EXEEXT) luatexdir/tex/filename.w +# $(luatex_tex_ctangle) filename.w +#inputstack.c: ctangle$(EXEEXT) luatexdir/tex/inputstack.w +# $(luatex_tex_ctangle) inputstack.w +# linebreak.c: ctangle$(EXEEXT) luatexdir/tex/linebreak.w +# $(luatex_tex_ctangle) linebreak.w +#mainbody.c: ctangle$(EXEEXT) luatexdir/tex/mainbody.w +# $(luatex_tex_ctangle) mainbody.w +#maincontrol.c: ctangle$(EXEEXT) luatexdir/tex/maincontrol.w +# $(luatex_tex_ctangle) maincontrol.w +#mathcodes.c: ctangle$(EXEEXT) luatexdir/tex/mathcodes.w +# $(luatex_tex_ctangle) mathcodes.w +#memoryword.c: ctangle$(EXEEXT) luatexdir/tex/memoryword.w +# $(luatex_tex_ctangle) memoryword.w +# mlist.c: ctangle$(EXEEXT) luatexdir/tex/mlist.w +# $(luatex_tex_ctangle) mlist.w +#nesting.c: ctangle$(EXEEXT) luatexdir/tex/nesting.w +# $(luatex_tex_ctangle) nesting.w +# packaging.c: ctangle$(EXEEXT) luatexdir/tex/packaging.w +# $(luatex_tex_ctangle) packaging.w +#postlinebreak.c: ctangle$(EXEEXT) luatexdir/tex/postlinebreak.w +# $(luatex_tex_ctangle) postlinebreak.w +#primitive.c: ctangle$(EXEEXT) luatexdir/tex/primitive.w +# $(luatex_tex_ctangle) primitive.w +#printing.c: ctangle$(EXEEXT) luatexdir/tex/printing.w +# $(luatex_tex_ctangle) printing.w +# scanning.c: ctangle$(EXEEXT) luatexdir/tex/scanning.w +# $(luatex_tex_ctangle) scanning.w +#stringpool.c: ctangle$(EXEEXT) luatexdir/tex/stringpool.w +# $(luatex_tex_ctangle) stringpool.w +#texdeffont.c: ctangle$(EXEEXT) luatexdir/tex/texdeffont.w +# $(luatex_tex_ctangle) texdeffont.w +# texfileio.c: ctangle$(EXEEXT) luatexdir/tex/texfileio.w +# $(luatex_tex_ctangle) texfileio.w +# texmath.c: ctangle$(EXEEXT) luatexdir/tex/texmath.w +# $(luatex_tex_ctangle) texmath.w +# texnodes.c: ctangle$(EXEEXT) luatexdir/tex/texnodes.w +# $(luatex_tex_ctangle) texnodes.w +#textcodes.c: ctangle$(EXEEXT) luatexdir/tex/textcodes.w +# $(luatex_tex_ctangle) textcodes.w +# textoken.c: ctangle$(EXEEXT) luatexdir/tex/textoken.w +# $(luatex_tex_ctangle) textoken.w + + + dist_libluatex_sources += \ luatexdir/tex/align.h \ luatexdir/tex/arithmetic.h \ + luatexdir/tex/backend.h \ + luatexdir/tex/backend.c \ luatexdir/tex/buildpage.h \ luatexdir/tex/commands.h \ luatexdir/tex/conditional.h \ @@ -530,25 +560,58 @@ dist_libluatex_sources += \ luatexdir/tex/texfileio.h \ luatexdir/tex/texmath.h \ luatexdir/tex/texnodes.h \ + luatexdir/tex/textcodes.h \ luatexdir/tex/textoken.h \ - luatexdir/tex/textcodes.h + luatexdir/tex/align.c \ + luatexdir/tex/arithmetic.c \ + luatexdir/tex/buildpage.c \ + luatexdir/tex/commands.c \ + luatexdir/tex/conditional.c \ + luatexdir/tex/directions.c \ + luatexdir/tex/dumpdata.c \ + luatexdir/tex/equivalents.c \ + luatexdir/tex/errors.c \ + luatexdir/tex/expand.c \ + luatexdir/tex/extensions.c \ + luatexdir/tex/filename.c \ + luatexdir/tex/inputstack.c \ + luatexdir/tex/linebreak.c \ + luatexdir/tex/mainbody.c \ + luatexdir/tex/maincontrol.c \ + luatexdir/tex/mathcodes.c \ + luatexdir/tex/memoryword.c \ + luatexdir/tex/mlist.c \ + luatexdir/tex/nesting.c \ + luatexdir/tex/packaging.c \ + luatexdir/tex/postlinebreak.c \ + luatexdir/tex/primitive.c \ + luatexdir/tex/printing.c \ + luatexdir/tex/scanning.c \ + luatexdir/tex/stringpool.c \ + luatexdir/tex/texdeffont.c \ + luatexdir/tex/texfileio.c \ + luatexdir/tex/texmath.c \ + luatexdir/tex/texnodes.c \ + luatexdir/tex/textcodes.c \ + luatexdir/tex/textoken.c + ## from luatexdir/utils ## luatex_utils_ctangle = $(ctangle_silent)CWEBINPUTS=$(srcdir)/luatexdir/utils $(ctangle) -avlstuff.c: ctangle$(EXEEXT) luatexdir/utils/avlstuff.w - $(luatex_utils_ctangle) avlstuff.w -managed-sa.c: ctangle$(EXEEXT) luatexdir/utils/managed-sa.w - $(luatex_utils_ctangle) managed-sa.w -utils.c: ctangle$(EXEEXT) luatexdir/utils/utils.w - $(luatex_utils_ctangle) utils.w -unistring.c: ctangle$(EXEEXT) luatexdir/utils/unistring.w - $(luatex_utils_ctangle) unistring.w +#avlstuff.c: ctangle$(EXEEXT) luatexdir/utils/avlstuff.w +# $(luatex_utils_ctangle) avlstuff.w +#managed-sa.c: ctangle$(EXEEXT) luatexdir/utils/managed-sa.w +# $(luatex_utils_ctangle) managed-sa.w +#utils.c: ctangle$(EXEEXT) luatexdir/utils/utils.w +# $(luatex_utils_ctangle) utils.w +#unistring.c: ctangle$(EXEEXT) luatexdir/utils/unistring.w +# $(luatex_utils_ctangle) unistring.w -libluatex_web += luatexdir/utils/avlstuff.w luatexdir/utils/managed-sa.w luatexdir/utils/utils.w luatexdir/utils/unistring.w +#libluatex_web += luatexdir/utils/avlstuff.w luatexdir/utils/managed-sa.w luatexdir/utils/utils.w luatexdir/utils/unistring.w -nodist_libluatex_sources += avlstuff.c managed-sa.c utils.c unistring.c +#nodist_libluatex_sources += avlstuff.c managed-sa.c utils.c unistring.c dist_libluatex_sources += \ luatexdir/utils/avl.c \ @@ -556,7 +619,11 @@ dist_libluatex_sources += \ luatexdir/utils/avlstuff.h \ luatexdir/utils/managed-sa.h \ luatexdir/utils/utils.h \ - luatexdir/utils/unistring.h + luatexdir/utils/unistring.h \ + luatexdir/utils/avlstuff.c \ + luatexdir/utils/managed-sa.c \ + luatexdir/utils/unistring.c \ + luatexdir/utils/utils.c ## from ../synctexdir ## diff --git a/Build/source/texk/web2c/luatexdir/am/luamisc.am b/Build/source/texk/web2c/luatexdir/am/luamisc.am index 7e874ae09af..014b6eb3f0c 100644 --- a/Build/source/texk/web2c/luatexdir/am/luamisc.am +++ b/Build/source/texk/web2c/luatexdir/am/luamisc.am @@ -8,9 +8,9 @@ ## and slnunicode) EXTRA_LIBRARIES += libluamisc.a liblua53misc.a libluajitmisc.a -libluamisc_a_DEPENDENCIES = $(ZZIPLIB_DEPEND) libluasocket.a libluaffi.a -liblua53misc_a_DEPENDENCIES = $(ZZIPLIB_DEPEND) liblua53socket.a liblua53ffi.a -libluajitmisc_a_DEPENDENCIES = $(ZZIPLIB_DEPEND) libluajitsocket.a +libluamisc_a_DEPENDENCIES = $(ZZIPLIB_DEPEND) libluasocket.a libluaffi.a libluapplib.a +liblua53misc_a_DEPENDENCIES = $(ZZIPLIB_DEPEND) liblua53socket.a liblua53ffi.a liblua53pplib.a +libluajitmisc_a_DEPENDENCIES = $(ZZIPLIB_DEPEND) libluajitsocket.a libluajitpplib.a $(libluamisc_a_OBJECTS): $(libluamisc_a_DEPENDENCIES) $(liblua53misc_a_OBJECTS): $(liblua53misc_a_DEPENDENCIES) diff --git a/Build/source/texk/web2c/luatexdir/am/luatex.am b/Build/source/texk/web2c/luatexdir/am/luatex.am index 4482ffe6079..2fb4d64f68a 100644 --- a/Build/source/texk/web2c/luatexdir/am/luatex.am +++ b/Build/source/texk/web2c/luatexdir/am/luatex.am @@ -42,11 +42,11 @@ endif LUAJITTEX EXTRA_PROGRAMS += luatex luatex53 luajittex # Force Automake to use CXXLD for linking -nodist_EXTRA_luatex_SOURCES = dummy.cxx -nodist_EXTRA_luatex53_SOURCES = dummy.cxx -nodist_EXTRA_luajittex_SOURCES = dummy.cxx +#nodist_EXTRA_luatex_SOURCES = dummy.cxx +#nodist_EXTRA_luatex53_SOURCES = dummy.cxx +#nodist_EXTRA_luajittex_SOURCES = dummy.cxx -luatex_preflags = $(AM_CPPFLAGS) $(ZLIB_INCLUDES) $(LIBPNG_INCLUDES) $(POPPLER_INCLUDES) +luatex_preflags = $(AM_CPPFLAGS) $(ZLIB_INCLUDES) $(LIBPNG_INCLUDES) luatex_postflags = -I$(srcdir)/libmd5 -DpdfTeX -I$(srcdir)/luatexdir -I$(srcdir)/mplibdir luatex_postflags += -Dextra_version_info=`date +-%Y%m%d%H` luatex_postflags += -I$(srcdir)/synctexdir -DSYNCTEX_ENGINE_H='<synctex-luatex.h>' @@ -64,14 +64,15 @@ luatex_LDFLAGS = -export-dynamic luatex53_LDFLAGS = -export-dynamic luajittex_LDFLAGS = -export-dynamic $(LUAJIT_LDEXTRA) -luatex_postldadd = libmplibcore.a $(MPFR_LIBS) $(GMP_LIBS) -luatex_postldadd += $(ZZIPLIB_LIBS) $(LIBPNG_LIBS) $(ZLIB_LIBS) $(POPPLER_LIBS) +#luatex_postldadd = libmplibcore.a $(MPFR_LIBS) $(GMP_LIBS) +luatex_postldadd = libmplibcore.a +luatex_postldadd += $(ZZIPLIB_LIBS) $(LIBPNG_LIBS) $(ZLIB_LIBS) luatex_postldadd += $(LDADD) libmputil.a libunilib.a libmd5.a $(lua_socketlibs) -luatex_LDADD = libluatex.a libff.a libluamisc.a libluasocket.a libluaffi.a $(LUA_LIBS) $(luatex_postldadd) -luatex53_LDADD = liblua53tex.a libff.a liblua53misc.a liblua53socket.a liblua53ffi.a $(LUA_LUA53_LIBS) $(luatex_postldadd) -luajittex_LDADD = libluajittex.a libff.a libluajitmisc.a libluajitsocket.a $(LUAJIT_LIBS) $(luatex_postldadd) +luatex_LDADD = libluatex.a libff.a libluamisc.a libluasocket.a libluaffi.a libluapplib.a $(LUA_LIBS) $(luatex_postldadd) +luatex53_LDADD = liblua53tex.a libff.a liblua53misc.a liblua53socket.a liblua53ffi.a liblua53pplib.a $(LUA_LUA53_LIBS) $(luatex_postldadd) +luajittex_LDADD = libluajittex.a libff.a libluajitmisc.a libluajitsocket.a libluajitpplib.a $(LUAJIT_LIBS) $(luatex_postldadd) luatex_depend = $(proglib) $(KPATHSEA_DEPEND) $(LIBPNG_DEPEND) libmputil.a libmd5.a luatex_DEPENDENCIES = $(luatex_depend) libluatex.a diff --git a/Build/source/texk/web2c/luatexdir/dvi/dvigen.h b/Build/source/texk/web2c/luatexdir/dvi/dvigen.h index 49552f1d9c2..cfbbc6245b6 100644 --- a/Build/source/texk/web2c/luatexdir/dvi/dvigen.h +++ b/Build/source/texk/web2c/luatexdir/dvi/dvigen.h @@ -21,166 +21,34 @@ #ifndef DVIGEN_H # define DVIGEN_H -extern int total_pages; -extern scaled max_v; -extern scaled max_h; -extern int max_push; -extern int last_bop; -extern int dead_cycles; -extern boolean doing_leaders; -extern int oval, ocmd; -extern int lq, lr; -extern int cur_s; - -typedef int dvi_index; /* an index into the output buffer */ +/* todo: move initialization from mainbody to ensure_open */ extern int dvi_buf_size; extern eight_bits *dvi_buf; /* 0 is unused */ -extern dvi_index half_buf; -extern dvi_index dvi_limit; -extern dvi_index dvi_ptr; -extern int dvi_offset; -extern int dvi_gone; - -/* -To put a byte in the buffer without paying the cost of invoking a procedure -each time, we use the macro |dvi_out|. -*/ - -# define dvi_out(A) do { \ - dvi_buf[dvi_ptr++]=(eight_bits)(A); \ - if (dvi_ptr==dvi_limit) dvi_swap(); \ - } while (0) - -extern void dvi_swap(void); -extern void dvi_four(int x); -extern void dvi_push(void); -extern void dvi_pop(int l); -extern void out_cmd(void); -extern void dvi_font_def(internal_font_number f); - -# define dvi_set(A,B) do { \ - oval=A; ocmd=set1; out_cmd(); dvi.h += (B); \ - } while (0) - -# define dvi_put(A) do { \ - oval=A; ocmd=put1; out_cmd(); \ - } while (0) - -# define location(A) varmem[(A)+1].cint - -extern halfword down_ptr, right_ptr; /* heads of the down and right stacks */ - -/* -The |vinfo| fields in the entries of the down stack or the right stack -have six possible settings: |y_here| or |z_here| mean that the \.{DVI} -command refers to |y| or |z|, respectively (or to |w| or |x|, in the -case of horizontal motion); |yz_OK| means that the \.{DVI} command is -\\{down} (or \\{right}) but can be changed to either |y| or |z| (or -to either |w| or |x|); |y_OK| means that it is \\{down} and can be changed -to |y| but not |z|; |z_OK| is similar; and |d_fixed| means it must stay -\\{down}. - -The four settings |yz_OK|, |y_OK|, |z_OK|, |d_fixed| would not need to -be distinguished from each other if we were simply solving the -digit-subscripting problem mentioned above. But in \TeX's case there is -a complication because of the nested structure of |push| and |pop| -commands. Suppose we add parentheses to the digit-subscripting problem, -redefining hits so that $\delta_y\ldots \delta_y$ is a hit if all $y$'s between -the $\delta$'s are enclosed in properly nested parentheses, and if the -parenthesis level of the right-hand $\delta_y$ is deeper than or equal to -that of the left-hand one. Thus, `(' and `)' correspond to `|push|' -and `|pop|'. Now if we want to assign a subscript to the final 1 in the -sequence -$$2_y\,7_d\,1_d\,(\,8_z\,2_y\,8_z\,)\,1$$ -we cannot change the previous $1_d$ to $1_y$, since that would invalidate -the $2_y\ldots2_y$ hit. But we can change it to $1_z$, scoring a hit -since the intervening $8_z$'s are enclosed in parentheses. -*/ - -typedef enum { - y_here = 1, /* |vinfo| when the movement entry points to a |y| command */ - z_here = 2, /* |vinfo| when the movement entry points to a |z| command */ - yz_OK = 3, /* |vinfo| corresponding to an unconstrained \\{down} command */ - y_OK = 4, /* |vinfo| corresponding to a \\{down} that can't become a |z| */ - z_OK = 5, /* |vinfo| corresponding to a \\{down} that can't become a |y| */ - d_fixed = 6, /* |vinfo| corresponding to a \\{down} that can't change */ -} movement_codes; - -/* As we search through the stack, we are in one of three states, - |y_seen|, |z_seen|, or |none_seen|, depending on whether we have - encountered |y_here| or |z_here| nodes. These states are encoded as - multiples of 6, so that they can be added to the |info| fields for quick - decision-making. */ - -# define none_seen 0 /* no |y_here| or |z_here| nodes have been encountered yet */ -# define y_seen 6 /* we have seen |y_here| but not |z_here| */ -# define z_seen 12 /* we have seen |z_here| but not |y_here| */ - -extern void movement(scaled w, eight_bits o); -extern void prune_movements(int l); - -/* -The actual distances by which we want to move might be computed as the -sum of several separate movements. For example, there might be several -glue nodes in succession, or we might want to move right by the width of -some box plus some amount of glue. More importantly, the baselineskip -distances are computed in terms of glue together with the depth and -height of adjacent boxes, and we want the \.{DVI} file to lump these -three quantities together into a single motion. - -Therefore, \TeX\ maintains two pairs of global variables: |dvi.h| and |dvi.v| -are the |h| and |v| coordinates corresponding to the commands actually -output to the \.{DVI} file, while |cur.h| and |cur.v| are the coordinates -corresponding to the current state of the output routines. Coordinate -changes will accumulate in |cur.h| and |cur.v| without being reflected -in the output, until such a change becomes necessary or desirable; we -can call the |movement| procedure whenever we want to make |dvi.h=pos.h| -or |dvi.v=pos.v|. - -The current font reflected in the \.{DVI} output is called |dvi_f|; -there is no need for a `\\{cur\_f}' variable. - -The depth of nesting of |hlist_out| and |vlist_out| is called |cur_s|; -this is essentially the depth of |push| commands in the \.{DVI} output. -*/ - -# define synch_h(p) do { \ - if (p.h != dvi.h) { \ - movement(p.h - dvi.h, right1); \ - dvi.h = p.h; \ - } \ - } while (0) - -# define synch_v(p) do { \ - if (p.v != dvi.v) { \ - movement(dvi.v - p.v, down1); \ - dvi.v = p.v; \ - } \ - } while (0) - -# define synch_dvi_with_pos(p) do {synch_h(p); synch_v(p); } while (0) - -# define billion 1000000000.0 - -# define vet_glue(A) do { glue_temp=A; \ - if (glue_temp>billion) \ - glue_temp=billion; \ - else if (glue_temp<-billion) \ - glue_temp=-billion; \ - } while (0) - -extern scaledpos dvi; -extern void dvi_special(PDF pdf, halfword p); +/*tex Housekeeping. */ -extern void ensure_dvi_header_written(PDF pdf); -extern void finish_dvi_file(PDF pdf, int version, int revision); +extern void dvi_open_file(PDF pdf); +extern void dvi_write_header(PDF pdf); +extern void dvi_finish_file(PDF pdf, int fatal_error); +extern void dvi_begin_page(PDF pdf); +extern void dvi_end_page(PDF pdf); + +/*tex Specific injections. */ extern void dvi_place_glyph(PDF pdf, internal_font_number f, int c, int ex); extern void dvi_place_rule(PDF pdf, halfword q, scaledpos size); +extern void dvi_special(PDF pdf, halfword p); -extern void dvi_begin_page(PDF pdf); -extern void dvi_end_page(PDF pdf); +/*tex List handling (and nesting). */ + +extern void dvi_push_list(PDF pdf, scaledpos *saved_pos, int *saved_loc); +extern void dvi_pop_list(PDF pdf, scaledpos *saved_pos, int *saved_loc); +extern void dvi_set_reference_point(PDF pdf, posstructure *refpoint); + +/*tex Status information used in |lstatslib|. Not that useful. */ + +extern int dvi_get_status_ptr(PDF pdf); +extern int dvi_get_status_gone(PDF pdf); #endif diff --git a/Build/source/texk/web2c/luatexdir/font/luatexfont.h b/Build/source/texk/web2c/luatexdir/font/luatexfont.h index 459d2092b54..7016b88729c 100644 --- a/Build/source/texk/web2c/luatexdir/font/luatexfont.h +++ b/Build/source/texk/web2c/luatexdir/font/luatexfont.h @@ -1,4 +1,4 @@ -/* luatexfont.h --- General font definitions +/* Copyright 2008-2013 Taco Hoekwater <taco@luatex.org> @@ -15,45 +15,36 @@ License for more details. You should have received a copy of the GNU General Public License along - with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */ + with LuaTeX; if not, see <http://www.gnu.org/licenses/>. +*/ #ifndef LUATEXFONT_H -# define LUATEXFONT_H - -# include "ptexlib.h" -# ifndef pdfTeX -# define pdfTeX -# include "sfnt.h" /* which wants that pdfTeX is defined */ -# undef pdfTeX -# else -# include "sfnt.h" -# endif - -/**********************************************************************/ - -# define ASCENT_CODE 0 -# define CAPHEIGHT_CODE 1 -# define DESCENT_CODE 2 -# define ITALIC_ANGLE_CODE 3 -# define STEMV_CODE 4 -# define XHEIGHT_CODE 5 -# define FONTBBOX1_CODE 6 -# define FONTBBOX2_CODE 7 -# define FONTBBOX3_CODE 8 -# define FONTBBOX4_CODE 9 -# define FONTNAME_CODE 10 -# define GEN_KEY_NUM (XHEIGHT_CODE + 1) -# define MAX_KEY_CODE (FONTBBOX1_CODE + 1) -# define INT_KEYS_NUM (FONTBBOX4_CODE + 1) -# define FONT_KEYS_NUM (FONTNAME_CODE + 1) - -# define FD_FLAGS_NOT_SET_IN_MAPLINE -1 -# define FD_FLAGS_DEFAULT_EMBED 4 /* a symbol font */ -# define FD_FLAGS_DEFAULT_NON_EMBED 0x22 - /* a nonsymbolic serif font */ - -/**********************************************************************/ + +#define LUATEXFONT_H + +#include "ptexlib.h" +#include "sfnt.h" + +#define ASCENT_CODE 0 +#define CAPHEIGHT_CODE 1 +#define DESCENT_CODE 2 +#define ITALIC_ANGLE_CODE 3 +#define STEMV_CODE 4 +#define XHEIGHT_CODE 5 +#define FONTBBOX1_CODE 6 +#define FONTBBOX2_CODE 7 +#define FONTBBOX3_CODE 8 +#define FONTBBOX4_CODE 9 +#define FONTNAME_CODE 10 +#define GEN_KEY_NUM (XHEIGHT_CODE + 1) +#define MAX_KEY_CODE (FONTBBOX1_CODE + 1) +#define INT_KEYS_NUM (FONTBBOX4_CODE + 1) +#define FONT_KEYS_NUM (FONTNAME_CODE + 1) + +#define FD_FLAGS_NOT_SET_IN_MAPLINE -1 +#define FD_FLAGS_DEFAULT_EMBED 4 /* a symbol font */ +#define FD_FLAGS_DEFAULT_NON_EMBED 0x22 /* a nonsymbolic serif font */ typedef struct { const char *pdfname; @@ -63,60 +54,59 @@ typedef struct { extern const key_entry font_key[FONT_KEYS_NUM]; -# include "mapfile.h" +#include "mapfile.h" typedef struct { - int val; /* value */ - boolean set; /* true if parameter has been set */ + int val; /* value */ + boolean set; /* true if parameter has been set */ } intparm; typedef struct { - int fe_objnum; /* object number */ - char *name; /* encoding file name */ - char **glyph_names; /* array of glyph names */ - struct avl_table *tx_tree; /* tree of encoding positions marked as used by TeX */ + int fe_objnum; /* object number */ + char *name; /* encoding file name */ + char **glyph_names; /* array of glyph names */ + struct avl_table *tx_tree; /* tree of encoding positions marked as used by TeX */ } fe_entry; typedef struct fd_entry_ { - int fd_objnum; /* object number of the font descriptor object */ - char *fontname; /* /FontName (without subset tag) */ - char *subset_tag; /* 6-character subset tag */ + int fd_objnum; /* object number of the font descriptor object */ + char *fontname; /* /FontName (without subset tag) */ + char *subset_tag; /* 6-character subset tag */ boolean ff_found; - int ff_objnum; /* object number of the font program stream */ - boolean all_glyphs; /* embed all glyphs? */ + int ff_objnum; /* object number of the font program stream */ + boolean all_glyphs; /* embed all glyphs? */ boolean write_ttf_glyph_names; intparm font_dim[FONT_KEYS_NUM]; - fe_entry *fe; /* pointer to encoding structure */ - char **builtin_glyph_names; /* builtin encoding as read from the Type1 font file */ - fm_entry *fm; /* pointer to font map structure */ - struct avl_table *tx_tree; /* tree of non-reencoded TeX characters marked as used */ - struct avl_table *gl_tree; /* tree of all marked glyphs */ - internal_font_number tex_font; /* needed for variable */ + fe_entry *fe; /* pointer to encoding structure */ + char **builtin_glyph_names; /* builtin encoding as read from the Type1 font file */ + fm_entry *fm; /* pointer to font map structure */ + struct avl_table *tx_tree; /* tree of non-reencoded TeX characters marked as used */ + struct avl_table *gl_tree; /* tree of all marked glyphs */ + internal_font_number tex_font; /* needed for variable */ } fd_entry; typedef struct fo_entry_ { - int fo_objnum; /* object number of the font dictionary */ - internal_font_number tex_font; /* needed only for \pdffontattr{} */ - fm_entry *fm; /* pointer to font map structure for this font dictionary */ - fd_entry *fd; /* pointer to /FontDescriptor object structure */ - fe_entry *fe; /* pointer to encoding structure */ - int cw_objnum; /* object number of the font program object */ - int first_char; /* first character used in this font */ - int last_char; /* last character used in this font */ - struct avl_table *tx_tree; /* tree of non-reencoded TeX characters marked as used */ - int tounicode_objnum; /* object number of ToUnicode */ + int fo_objnum; /* object number of the font dictionary */ + internal_font_number tex_font; /* needed only for \pdffontattr{} */ + fm_entry *fm; /* pointer to font map structure for this font dictionary */ + fd_entry *fd; /* pointer to /FontDescriptor object structure */ + fe_entry *fe; /* pointer to encoding structure */ + int cw_objnum; /* object number of the font program object */ + int first_char; /* first character used in this font */ + int last_char; /* last character used in this font */ + struct avl_table *tx_tree; /* tree of non-reencoded TeX characters marked as used */ + int tounicode_objnum; /* object number of ToUnicode */ } fo_entry; typedef struct { - char *name; /* glyph name */ - long code; /* -1 = undefined; -2 = multiple codes, stored - as string in unicode_seq; otherwise unicode value */ - char *unicode_seq; /* multiple unicode sequence */ + char *name; /* glyph name */ + long code; /* -1 = undefined; -2 = multiple codes, stored as string in unicode_seq; otherwise unicode value */ + char *unicode_seq; /* multiple unicode sequence */ } glyph_unicode_entry; -typedef struct glw_entry_ { /* subset glyphs for inclusion in CID-based fonts */ - unsigned int id; /* glyph CID */ - signed int wd; /* glyph width in 1/1000 em parts */ +typedef struct glw_entry_ { /* subset glyphs for inclusion in CID-based fonts */ + unsigned int id; /* glyph CID */ + signed int wd; /* glyph width in 1/1000 em parts */ } glw_entry; typedef struct { @@ -124,19 +114,18 @@ typedef struct { halfword *raster; } chardesc; -/**********************************************************************/ - -# include "texfont.h" +#include "texfont.h" /* tounicode.c */ + int write_cid_tounicode(PDF, fo_entry *, internal_font_number); void glyph_unicode_free(void); void def_tounicode(str_number, str_number); int write_tounicode(PDF, char **, char *); /* vfpacket.c */ -void replace_packet_fonts(internal_font_number f, int *old_fontid, - int *new_fontid, int count); + +void replace_packet_fonts(internal_font_number f, int *old_fontid, int *new_fontid, int count); int *packet_local_fonts(internal_font_number f, int *num); int packet_cur_s; /* current |do_vf_packet()| recursion level */ @@ -144,12 +133,15 @@ int packet_stack_ptr; /* pointer into |packet_stack| */ vf_struct *new_vfstruct(void); /* writecff.c */ + void writetype1w(PDF pdf, fd_entry * fd); /* writetype0.c */ + void writetype0(PDF pdf, fd_entry * fd); /* writefont.c */ + void do_pdf_font(PDF, internal_font_number); fd_entry *lookup_fd_entry(char *); fd_entry *new_fd_entry(internal_font_number); @@ -157,6 +149,7 @@ void write_fontstuff(PDF); void register_fd_entry(fd_entry * fd); /* writet1.c */ + boolean t1_subset(char *, char *, unsigned char *); char **load_enc_file(char *); void writet1(PDF, fd_entry *); @@ -164,36 +157,40 @@ void t1_free(void); extern int t1_length1, t1_length2, t1_length3; /* writetype2.c */ + boolean writetype2(PDF, fd_entry *); extern unsigned long cidtogid_obj; -pdf_obj *pdf_new_stream(void); -void pdf_add_stream(pdf_obj * stream, unsigned char *buf, long len); -void pdf_release_obj(pdf_obj * stream); unsigned long ttc_read_offset(sfnt * sfont, int ttc_idx, fd_entry *fd); /* writeenc.c */ + fe_entry *get_fe_entry(char *); void enc_free(void); void write_fontencodings(PDF pdf); /* writettf.c */ + void writettf(PDF, fd_entry *); void writeotf(PDF, fd_entry *); void ttf_free(void); extern int ttf_length; /* pkin.c */ + int readchar(boolean, chardesc *); /* macnames.c */ + extern char notdef[]; /* vfovf.c */ + internal_font_number letter_space_font(internal_font_number f, int e, boolean nolig); void pdf_check_vf(internal_font_number f); internal_font_number copy_font_info(internal_font_number f); /* writet3.c */ + extern FILE *t3_file; void writet3(PDF, internal_font_number); @@ -201,12 +198,11 @@ extern unsigned char *t3_buffer; extern int t3_size; extern int t3_curbyte; -# define t3_read_file() readbinfile(t3_file, &t3_buffer, &t3_size) -# define t3_close() xfclose(t3_file, cur_file_name) -# define t3_getchar() t3_buffer[t3_curbyte++] -# define t3_eof() (t3_curbyte>t3_size) - -# define t3_prefix(s) (!strncmp(t3_line_array, s, strlen(s))) -# define t3_putchar(c) pdfout(c) +#define t3_read_file() readbinfile(t3_file, &t3_buffer, &t3_size) +#define t3_close() xfclose(t3_file, cur_file_name) +#define t3_getchar() t3_buffer[t3_curbyte++] +#define t3_eof() (t3_curbyte>t3_size) +#define t3_prefix(s) (!strncmp(t3_line_array, s, strlen(s))) +#define t3_putchar(c) pdfout(c) -#endif /* LUATEXFONT_H */ +#endif diff --git a/Build/source/texk/web2c/luatexdir/font/mapfile.h b/Build/source/texk/web2c/luatexdir/font/mapfile.h index ad752af744f..e3e0e613add 100644 --- a/Build/source/texk/web2c/luatexdir/font/mapfile.h +++ b/Build/source/texk/web2c/luatexdir/font/mapfile.h @@ -98,13 +98,6 @@ typedef struct { /**********************************************************************/ -# define FONT_SLANT_MIN -2000 -# define FONT_SLANT_MAX 2000 -# define FONT_EXTEND_MIN -5000 -# define FONT_EXTEND_MAX 5000 - -/**********************************************************************/ - fm_entry *getfontmap(char *tfm_name); void fm_free(void); ff_entry *check_ff_exist(char *, boolean); diff --git a/Build/source/texk/web2c/luatexdir/font/sfnt.h b/Build/source/texk/web2c/luatexdir/font/sfnt.h index dce4248e981..602a0805f67 100644 --- a/Build/source/texk/web2c/luatexdir/font/sfnt.h +++ b/Build/source/texk/web2c/luatexdir/font/sfnt.h @@ -28,11 +28,12 @@ # endif /* HAVE_CONFIG_H_ */ /* Data Types as described in Apple's TTRefMan */ -typedef unsigned char BYTE; + +/*typedef unsigned char BYTE;*/ /* defined in pdfgen.h */ typedef signed char ICHAR; typedef unsigned short USHORT; typedef signed short SHORT; -typedef unsigned long ULONG; +/*typedef unsigned long ULONG;*//* defined in pdfgen.h */ typedef signed long LONG; typedef unsigned long Fixed; /* 16.16-bit signed fixed-point number */ typedef short FWord; @@ -70,40 +71,16 @@ struct sfnt_table_directory { typedef struct { int type; struct sfnt_table_directory *directory; -# ifdef XETEX - FT_Face ft_face; - long loc; -# elif defined(pdfTeX) BYTE *buffer; long buflen; long loc; -# else - FILE *stream; -# endif } sfnt; /* Convert sfnt "fixed" type to double */ + # define fixed(a) ((double)((a)%0x10000L)/(double)(0x10000L) + \ (a)/0x10000L - (((a)/0x10000L > 0x7fffL) ? 0x10000L : 0)) -# ifdef XETEX -UNSIGNED_BYTE ft_unsigned_byte(sfnt * f); -SIGNED_BYTE ft_signed_byte(sfnt * f); -UNSIGNED_PAIR ft_unsigned_pair(sfnt * f); -SIGNED_PAIR ft_signed_pair(sfnt * f); -UNSIGNED_QUAD ft_unsigned_quad(sfnt * f); -unsigned long ft_read(unsigned char *buf, unsigned long len, sfnt * f); - -# define sfnt_get_byte(s) ((BYTE) ft_unsigned_byte(s)) -# define sfnt_get_char(s) ((ICHAR) ft_signed_byte (s)) -# define sfnt_get_ushort(s) ((USHORT) ft_unsigned_pair(s)) -# define sfnt_get_short(s) ((SHORT) ft_signed_pair (s)) -# define sfnt_get_ulong(s) ((ULONG) ft_unsigned_quad(s)) -# define sfnt_get_long(s) ((LONG) ft_signed_quad (s)) - -# define sfnt_seek_set(s,o) (s)->loc = (o) -# define sfnt_read(b,l,s) ft_read((b), (l), (s)) -# elif defined(pdfTeX) BYTE get_unsigned_byte(sfnt * f); ICHAR get_signed_byte(sfnt * f); USHORT get_unsigned_pair(sfnt * f); @@ -111,45 +88,28 @@ SHORT get_signed_pair(sfnt * f); ULONG get_unsigned_quad(sfnt * f); int do_sfnt_read(unsigned char *dest, int len, sfnt * f); -# define sfnt_get_byte(s) ((BYTE) get_unsigned_byte(s)) -# define sfnt_get_char(s) ((ICHAR) get_signed_byte (s)) -# define sfnt_get_ushort(s) ((USHORT) get_unsigned_pair(s)) -# define sfnt_get_short(s) ((SHORT) get_signed_pair (s)) -# define sfnt_get_ulong(s) ((ULONG) get_unsigned_quad(s)) -# define sfnt_get_long(s) ((LONG) get_signed_quad (s)) - -# define sfnt_seek_set(s,o) (s)->loc = (o) -# define sfnt_read(b,l,s) do_sfnt_read((b), (l), (s)) -# else -/* get_***_*** from numbers.h */ -# define sfnt_get_byte(s) ((BYTE) get_unsigned_byte((s)->stream)) -# define sfnt_get_char(s) ((ICHAR) get_signed_byte ((s)->stream)) -# define sfnt_get_ushort(s) ((USHORT) get_unsigned_pair((s)->stream)) -# define sfnt_get_short(s) ((SHORT) get_signed_pair ((s)->stream)) -# define sfnt_get_ulong(s) ((ULONG) get_unsigned_quad((s)->stream)) -# define sfnt_get_long(s) ((LONG) get_signed_quad ((s)->stream)) - -# define sfnt_seek_set(s,o) seek_absolute((s)->stream, (o)) -# define sfnt_read(b,l,s) fread((b), 1, (l), (s)->stream) -# endif +#define sfnt_get_byte(s) ((BYTE) get_unsigned_byte(s)) +#define sfnt_get_char(s) ((ICHAR) get_signed_byte (s)) +#define sfnt_get_ushort(s) ((USHORT) get_unsigned_pair(s)) +#define sfnt_get_short(s) ((SHORT) get_signed_pair (s)) +#define sfnt_get_ulong(s) ((ULONG) get_unsigned_quad(s)) +#define sfnt_get_long(s) ((LONG) get_signed_quad (s)) + +#define sfnt_seek_set(s,o) (s)->loc = (o) +#define sfnt_read(b,l,s) do_sfnt_read((b), (l), (s)) extern int put_big_endian(void *s, LONG q, int n); -# define sfnt_put_ushort(s,v) put_big_endian((s), v, 2); -# define sfnt_put_short(s,v) put_big_endian((s), v, 2); -# define sfnt_put_ulong(s,v) put_big_endian((s), v, 4); -# define sfnt_put_long(s,v) put_big_endian((s), v, 4); +#define sfnt_put_ushort(s,v) put_big_endian((s), v, 2); +#define sfnt_put_short(s,v) put_big_endian((s), v, 2); +#define sfnt_put_ulong(s,v) put_big_endian((s), v, 4); +#define sfnt_put_long(s,v) put_big_endian((s), v, 4); -# ifdef XETEX -extern sfnt *sfnt_open(FT_Face face, int accept_types); -# elif defined(pdfTeX) extern sfnt *sfnt_open(unsigned char *buffer, int buflen); -# else -extern sfnt *sfnt_open(FILE * fp); -# endif extern void sfnt_close(sfnt * sfont); /* table directory */ + extern int sfnt_read_table_directory(sfnt * sfont, ULONG offset); extern ULONG sfnt_find_table_len(sfnt * sfont, const char *tag); extern ULONG sfnt_find_table_pos(sfnt * sfont, const char *tag); @@ -159,18 +119,10 @@ extern void sfnt_set_table(sfnt * sfont, const char *tag, void *data, ULONG length); extern int sfnt_require_table(sfnt * sfont, const char *tag, int must_exist); -# ifdef pdfTeX -typedef struct { - ULONG length; - BYTE *data; -} pdf_obj; - -# define ASSERT(a) assert(a) -# define RELEASE(a) free(a) -# define NEW(a,b) xmalloc((unsigned)((unsigned)(a)*sizeof(b))) -# define RENEW(a,b,c) xrealloc(a, (unsigned)((unsigned)(b)*sizeof(c))) - -# endif +#define ASSERT(a) assert(a) +#define RELEASE(a) free(a) +#define NEW(a,b) xmalloc((unsigned)((unsigned)(a)*sizeof(b))) +#define RENEW(a,b,c) xrealloc(a, (unsigned)((unsigned)(b)*sizeof(c))) extern pdf_obj *sfnt_create_FontFile_stream(sfnt * sfont); diff --git a/Build/source/texk/web2c/luatexdir/font/texfont.h b/Build/source/texk/web2c/luatexdir/font/texfont.h index 75beafe66f1..2622b7a14ed 100644 --- a/Build/source/texk/web2c/luatexdir/font/texfont.h +++ b/Build/source/texk/web2c/luatexdir/font/texfont.h @@ -32,6 +32,17 @@ # define pointer halfword +# define FONT_SLANT_MIN -2000 +# define FONT_SLANT_MAX 2000 +# define FONT_EXTEND_MIN -5000 +# define FONT_EXTEND_MAX 5000 +# define FONT_SQUEEZE_MIN -5000 +# define FONT_SQUEEZE_MAX 5000 +# define FONT_MODE_MIN 0 +# define FONT_MODE_MAX 3 /* pdf values */ +# define FONT_WIDTH_MIN 0 +# define FONT_WIDTH_MAX 5000 + /* these are dumped en block, so they need endianness tests */ typedef struct liginfo { @@ -141,6 +152,9 @@ typedef struct texfont { boolean _font_oldmath; /* default to false when MathConstants seen */ int _font_slant; /* a slant in ppt */ int _font_extend; /* an extension in ppt, or 1000 */ + int _font_squeeze; /* an extension in ppt, or 1000 */ + int _font_width; + int _font_mode; int font_max_shrink; int font_max_stretch; int _font_step; /* amount of one step of expansion */ @@ -329,6 +343,15 @@ boolean cmp_font_area(int, str_number); # define font_extend(a) font_tables[a]->_font_extend # define set_font_extend(a,b) font_extend(a) = b +# define font_squeeze(a) font_tables[a]->_font_squeeze +# define set_font_squeeze(a,b) font_squeeze(a) = b + +# define font_width(a) font_tables[a]->_font_width +# define set_font_width(a,b) font_width(a) = b + +# define font_mode(a) font_tables[a]->_font_mode +# define set_font_mode(a,b) font_mode(a) = b + # define font_shrink(a) font_tables[a]->_font_shrink # define set_font_shrink(a,b) font_shrink(a) = b @@ -625,7 +648,7 @@ typedef enum { packet_char_code, packet_scale_code, packet_lua_code, packet_pdf_code, - packet_pdf_mode, + packet_pdf_mode } packet_command_codes; extern scaled store_scaled_f(scaled sq, int fw); diff --git a/Build/source/texk/web2c/luatexdir/image/epdf.h b/Build/source/texk/web2c/luatexdir/image/epdf.h index 57bb2e39ae9..9c32c06b795 100644 --- a/Build/source/texk/web2c/luatexdir/image/epdf.h +++ b/Build/source/texk/web2c/luatexdir/image/epdf.h @@ -18,15 +18,19 @@ with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */ -// this is the common header file for C++ sources pdftoepdf.cc and lepdflib.cc +/* this is the common header file for C++ sources pdftoepdf.c and lepdflib.c */ #ifndef EPDF_H # define EPDF_H -extern "C" { + +/*extern "C" {*/ + #ifdef HAVE_CONFIG_H #include <w2c/config.h> #endif -} + +/*}*/ + # include <stdlib.h> # include <math.h> # include <stddef.h> @@ -35,41 +39,22 @@ extern "C" { # include <kpathsea/c-ctype.h> # include <sys/stat.h> # include <dirent.h> -# include <poppler-config.h> -# include <goo/GooString.h> -# include <goo/gmem.h> -# include <goo/gfile.h> -# include <Object.h> -# include <Stream.h> -# include <Gfx.h> -# include <Annot.h> -# include <Array.h> -# include <Dict.h> -# include <XRef.h> -# include <Catalog.h> -# include <StructTreeRoot.h> -# include <Link.h> -# include <Page.h> -# include <GfxFont.h> -# include <PDFDoc.h> -# include <GlobalParams.h> -# include <Error.h> -# include <FileSpec.h> - -extern "C" { + +/*extern "C" { */ # include <kpathsea/c-auto.h> - extern char *xstrdup(const char *); +extern char *xstrdup(const char *); - typedef enum { FE_FAIL, FE_RETURN_NULL } file_error_mode; +typedef enum { FE_FAIL, FE_RETURN_NULL } file_error_mode; /* the following code is extremly ugly but needed for including web2c/config.h */ - typedef const char *const_string; /* including kpathsea/types.h doesn't work on some systems */ +typedef const char *const_string; /* including kpathsea/types.h doesn't work on some systems */ # define KPATHSEA_CONFIG_H /* avoid including other kpathsea header files */ - /* from web2c/config.h */ + +/* from web2c/config.h */ # ifdef CONFIG_H /* CONFIG_H has been defined by some xpdf */ # undef CONFIG_H /* header file */ @@ -84,117 +69,105 @@ extern "C" { # include "lua.h" # include "lauxlib.h" - /* pdfgen.w */ - extern int ten_pow[10]; - __attribute__ ((format(printf, 2, 3))) - extern void pdf_printf(PDF, const char *fmt, ...); - extern void pdf_begin_obj(PDF, int, int); - extern void pdf_end_obj(PDF); - extern void pdf_begin_dict(PDF); - extern void pdf_end_dict(PDF); - extern void pdf_begin_array(PDF); - extern void pdf_end_array(PDF); - extern void pdf_add_null(PDF); - extern void pdf_add_bool(PDF, int i); - extern void pdf_add_int(PDF, int i); - extern void pdf_add_ref(PDF, int num); - extern void pdf_add_name(PDF, const char *name); - extern void pdf_dict_add_streaminfo(PDF); - extern void pdf_begin_stream(PDF); - extern void pdf_end_stream(PDF); - extern void pdf_room(PDF, int); - extern void pdf_out_block(PDF pdf, const char *s, size_t n); - - extern void pdf_dict_add_int(PDF, const char *key, int i); - extern void pdf_dict_add_ref(PDF, const char *key, int num); - extern void pdf_dict_add_name(PDF, const char *key, const char *val); - extern void pdf_dict_add_streaminfo(PDF); - -# define pdf_out(pdf, A) do { pdf_room(pdf, 1); *(pdf->buf->p++) = A; } while (0) -# define pdf_quick_out(pdf,A) *(pdf->buf->p++)=(unsigned char)(A) +# include "luapplib/pplib.h" + +/* pdfgen.w */ + +extern int ten_pow[10]; +__attribute__ ((format(printf, 2, 3))) +extern void pdf_printf(PDF, const char *fmt, ...); +extern void pdf_begin_obj(PDF, int, int); +extern void pdf_end_obj(PDF); +extern void pdf_begin_dict(PDF); +extern void pdf_end_dict(PDF); +extern void pdf_begin_array(PDF); +extern void pdf_end_array(PDF); +extern void pdf_add_null(PDF); +extern void pdf_add_bool(PDF, int i); +extern void pdf_add_int(PDF, int i); +extern void pdf_add_real(PDF, double d); +extern void pdf_add_ref(PDF, int num); +extern void pdf_add_name(PDF, const char *name); +extern void pdf_dict_add_streaminfo(PDF); +extern void pdf_begin_stream(PDF); +extern void pdf_end_stream(PDF); +extern void pdf_room(PDF, int); +extern void pdf_out_block(PDF pdf, const char *s, size_t n); + +extern void pdf_dict_add_int(PDF, const char *key, int i); +extern void pdf_dict_add_ref(PDF, const char *key, int num); +extern void pdf_dict_add_name(PDF, const char *key, const char *val); +extern void pdf_dict_add_streaminfo(PDF); + +/* Conflict with pdfgen.h */ +/*# define pdf_out(pdf, A) do { pdf_room(pdf, 1); *(pdf->buf->p++) = A; } while (0)*/ +/*# define pdf_quick_out(pdf,A) *(pdf->buf->p++)=(unsigned char)(A) */ + # define pdf_puts(pdf, s) pdf_out_block((pdf), (s), strlen(s)) - /* pdfpage.w */ - extern void print_pdffloat(PDF pdf, pdffloat f); +/* pdfpage.w */ - /* pdftables.w */ - extern int pdf_create_obj(PDF pdf, int t, int i); +extern void print_pdffloat(PDF pdf, pdffloat f); - /* pdftoepdf.cc */ - extern void read_pdf_info(image_dict *); - extern void flush_pdf_info(image_dict *); - extern void write_epdf(PDF, image_dict *, int suppress_optional_info); - extern void unrefPdfDocument(char *); - extern void unrefMemStreamPdfDocument(char *); - extern void epdf_free(void); - extern void copyReal(PDF pdf, double d); +/* pdftables.w */ - /* writeimg.w */ - extern void pdf_dict_add_img_filename(PDF pdf, image_dict * idict); +extern int pdf_create_obj(PDF pdf, int t, int i); - /* utils.w */ - extern char *convertStringToPDFString(char *in, int len); +/* pdftoepdf.c */ - /* lepdflib.w */ - int luaopen_epdf(lua_State * L); +extern void read_pdf_info(image_dict *); +extern void flush_pdf_info(image_dict *); -# include "luatex-common.h" +extern void write_epdf(PDF, image_dict *, int suppress_optional_info); +extern int write_epdf_object(PDF, image_dict *, int n); -}; +extern void unrefPdfDocument(char *); +extern void unrefMemStreamPdfDocument(char *); -/**********************************************************************/ - -// PdfObject encapsulates the xpdf Object type, -// and properly frees its resources on destruction. -// Use obj-> to access members of the Object, -// and &obj to get a pointer to the object. -// It is no longer necessary to call Object::free explicitely. - -# if 0 -// PdfObject is replaced by xpdf's Object type, with manual obj.free() - -// *INDENT-OFF* -class PdfObject { - public: - PdfObject() { // nothing - } - ~PdfObject() { - iObject.free(); - } - Object *operator->() { - return &iObject; - } - Object *operator&() { - return &iObject; - } - private: // no copying or assigning - PdfObject(const PdfObject &); - void operator=(const PdfObject &); - public: - Object iObject; -}; -// *INDENT-ON* -# endif +extern void epdf_free(void); + +/* writeimg.w */ -/**********************************************************************/ +extern void pdf_dict_add_img_filename(PDF pdf, image_dict * idict); + +/* utils.w */ + +/*extern char *convertStringToPDFString(const char *in, int len);*/ + +/* lepdflib.w */ + +int luaopen_epdf(lua_State * L); + +# include "luatex-common.h" + +/*}*/ + +typedef struct InObj InObj; struct InObj { - Ref ref; // ref in original PDF - int num; // new object number in output PDF - InObj *next; // next entry in list of indirect objects -}; + ppref *ref; /* ref in original PDF */ + int num; /* new object number in output PDF */ + InObj *next; /* next entry in list of indirect objects */ +} ; + + +typedef struct avl_table avl_table; struct PdfDocument { - char *file_path; // full file name including path - char *checksum; // for reopening - PDFDoc *doc; - InObj *inObjList; // temporary linked list - avl_table *ObjMapTree; // permanent over luatex run - unsigned int occurences; // number of references to the PdfDocument; it can be deleted when occurences == 0 - unsigned int pc; // counter to track PDFDoc generation or deletion + char *file_path; /* full file name including path */ + char *checksum; /* for reopening */ + ppdoc *pdfe; + InObj *inObjList; /* temporary linked list */ + avl_table *ObjMapTree; /* permanent over luatex run */ + int is_mem; + char *memstream; + unsigned int occurences; /* number of references to the PdfDocument; it can be deleted when occurences == 0 */ + unsigned int pc; /* counter to track PDFDoc generation or deletion */ }; -PdfDocument *refPdfDocument(const char *file_path, file_error_mode fe); +typedef struct PdfDocument PdfDocument; + +PdfDocument *refPdfDocument(const char *file_path, file_error_mode fe, const char *userpassword, const char *ownerpassword); PdfDocument *refMemStreamPdfDocument(char *docstream, unsigned long long streamsize, const char *file_id); diff --git a/Build/source/texk/web2c/luatexdir/image/image.h b/Build/source/texk/web2c/luatexdir/image/image.h index 7c79723f1df..985f53d06eb 100644 --- a/Build/source/texk/web2c/luatexdir/image/image.h +++ b/Build/source/texk/web2c/luatexdir/image/image.h @@ -39,6 +39,7 @@ extern scaled one_hundred_bp; /* from pdfgen.w */ typedef struct { char *stream; + size_t size; } pdf_stream_struct; typedef struct { @@ -116,6 +117,8 @@ typedef struct { char *filepath; /* full file path after kpathsea */ char *attr; /* additional image dict entries */ FILE *file; + char *userpassword; + char *ownerpassword; imgtype_e image_type; int procset; /* /ProcSet flags */ int color_depth; /* color depth */ @@ -125,6 +128,7 @@ typedef struct { int flags; int luaref ; boolean keepopen; + boolean nolength; int errorlevel; int pdfmajorversion; int pdfminorversion; @@ -159,6 +163,8 @@ typedef struct { # define img_pagename(N) ((N)->pagename) # define img_filename(N) ((N)->filename) # define img_visiblefilename(N) ((N)->visiblefilename) +# define img_userpassword(N) ((N)->userpassword) +# define img_ownerpassword(N) ((N)->ownerpassword) # define img_filepath(N) ((N)->filepath) # define img_attr(N) ((N)->attr) # define img_file(N) ((N)->file) @@ -171,12 +177,14 @@ typedef struct { # define img_flags(N) ((N)->flags) # define img_luaref(N) ((N)->luaref) # define img_keepopen(N) ((N)->keepopen) +# define img_nolength(N) ((N)->nolength) # 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) # define img_pdfstream_stream(N) ((N)->img_struct.pdfstream->stream) +# define img_pdfstream_size(N) ((N)->img_struct.pdfstream->size) # define img_png_ptr(N) ((N)->img_struct.png) # define img_png_png_ptr(N) ((N)->img_struct.png->png_ptr) diff --git a/Build/source/texk/web2c/luatexdir/image/pdftoepdf.h b/Build/source/texk/web2c/luatexdir/image/pdftoepdf.h index 0a8ef942c0e..cc8f0e15041 100644 --- a/Build/source/texk/web2c/luatexdir/image/pdftoepdf.h +++ b/Build/source/texk/web2c/luatexdir/image/pdftoepdf.h @@ -30,12 +30,7 @@ void flush_pdf_info(image_dict *); void unrefPdfDocument(char *); void unrefMemStreamPdfDocument(char *); void write_epdf(PDF, image_dict *, int suppress_optional_info); -void epdf_check_mem(void); -void copyReal(PDF pdf, double d); - -int poppler_version_major(void); -int poppler_version_minor(void); -int poppler_version_micro(void); +int write_epdf_object(PDF, image_dict *, int n); /* epdf.c --- this should go in an own header file */ diff --git a/Build/source/texk/web2c/luatexdir/image/writeimg.h b/Build/source/texk/web2c/luatexdir/image/writeimg.h index 46c42d2657e..dc86648e217 100644 --- a/Build/source/texk/web2c/luatexdir/image/writeimg.h +++ b/Build/source/texk/web2c/luatexdir/image/writeimg.h @@ -38,6 +38,7 @@ void scan_pdfrefximage(PDF pdf); scaled_whd tex_scale(scaled_whd nat, scaled_whd tex); scaled_whd scale_img(image_dict *, scaled_whd, int); void write_img(PDF, image_dict *); +int write_img_object(PDF, image_dict *, int n); void pdf_write_image(PDF pdf, int n); void check_pdfstream_dict(image_dict *); void write_pdfstream(PDF, image_dict *); diff --git a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c index f3ff58a752f..32cf6630223 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lcallbacklib.c @@ -22,6 +22,9 @@ int callback_count = 0; int saved_callback_count = 0; +int direct_callback_count = 0; +int late_callback_count = 0; +int function_callback_count = 0; int callback_set[total_callbacks] = { 0 }; @@ -74,7 +77,12 @@ static const char *const callbacknames[] = { "call_edit", "build_page_insert", "glyph_stream_provider", - "finish_synctex_callback", + "font_descriptor_objnum_provider", + "finish_synctex", + "wrapup_run", + "new_graf", + "page_objnum_provider", + "make_extensible", NULL }; @@ -207,7 +215,6 @@ int run_saved_callback(int r, const char *name, const char *values, ...) lua_rawget(Luas, -2); if (lua_isfunction(Luas, -1)) { saved_callback_count++; - callback_count++; ret = do_run_callback(2, values, args); } va_end(args); diff --git a/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc b/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc index 32bcdab0177..ea8ed96b051 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc +++ b/Build/source/texk/web2c/luatexdir/lua/lepdflib.cc @@ -17,3627 +17,3 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */ - - -#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 - -//********************************************************************** -// TODO: add more poppler functions (many are still missing) - -//********************************************************************** -// objects allocated by poppler may not be deleted in the lepdflib - -typedef enum { ALLOC_POPPLER, ALLOC_LEPDF } alloctype; - -typedef struct { - void *d; - alloctype atype; // was it allocated by poppler or the lepdflib.cc? - PdfDocument *pd; // reference to PdfDocument, or NULL - unsigned long pc; // counter to detect PDFDoc change -} udstruct; - -static const char *ErrorCodeNames[] = { "None", "OpenFile", "BadCatalog", - "Damaged", "Encrypted", "HighlightFile", "BadPrinter", "Printing", - "Permission", "BadPageNum", "FileIO", NULL -}; - -//********************************************************************** - -#define M_Annot "epdf.Annot" /* ls-hh: epdf.* gives better protection in registry */ -#define M_Annots "epdf.Annots" -#define M_Array "epdf.Array" -#define M_Catalog "epdf.Catalog" -#define M_Dict "epdf.Dict" -#define M_EmbFile "epdf.EmbFile" -#define M_FileSpec "epdf.FileSpec" -#define M_GooString "epdf.GooString" -#define M_LinkDest "epdf.LinkDest" -#define M_Link "epdf.Link" -#define M_Links "epdf.Links" -#define M_Object "epdf.Object" -#define M_Page "epdf.Page" -#define M_PDFDoc "epdf.PDFDoc" -#define M_PDFRectangle "epdf.PDFRectangle" -#define M_Ref "epdf.Ref" -#define M_Stream "epdf.Stream" -#define M_StructElement "epdf.StructElement" -#define M_Attribute "epdf.Attribute" -#define M_TextSpan "epdf.TextSpan" -#define M_StructTreeRoot "epdf.StructTreeRoot" -#define M_XRefEntry "epdf.XRefEntry" -#define M_XRef "epdf.XRef" - -//********************************************************************** - -#define new_poppler_userdata(type) \ -static udstruct *new_##type##_userdata(lua_State * L) \ -{ \ - udstruct *a; \ - a = (udstruct *) lua_newuserdata(L, sizeof(udstruct)); /* udstruct ... */ \ - a->atype = ALLOC_POPPLER; \ - luaL_getmetatable(L, M_##type); /* m udstruct ... */ \ - lua_setmetatable(L, -2); /* udstruct ... */ \ - return a; \ -} - -new_poppler_userdata(PDFDoc); - -new_poppler_userdata(Annot); -new_poppler_userdata(Array); -new_poppler_userdata(Catalog); -new_poppler_userdata(Dict); -new_poppler_userdata(EmbFile); -new_poppler_userdata(FileSpec); -new_poppler_userdata(LinkDest); -new_poppler_userdata(Links); -new_poppler_userdata(Object); -new_poppler_userdata(Page); -new_poppler_userdata(PDFRectangle); -new_poppler_userdata(Ref); -new_poppler_userdata(Stream); -new_poppler_userdata(StructElement); -new_poppler_userdata(Attribute); -new_poppler_userdata(TextSpan); -new_poppler_userdata(StructTreeRoot); -new_poppler_userdata(XRef); - -//********************************************************************** - -static void pdfdoc_changed_error(lua_State * L) -{ - luaL_error(L, "PDFDoc changed or gone"); -} - -static void pdfdoc_differs_error(lua_State * L) -{ - luaL_error(L, "PDFDoc differs between arguments"); -} - -//********************************************************************** - -static int l_open_PDFDoc(lua_State * L) -{ - const char *file_path; - udstruct *uout; - PdfDocument *d; - file_path = luaL_checkstring(L, 1); // path - d = refPdfDocument(file_path, FE_RETURN_NULL); - if (d == NULL) - lua_pushnil(L); - else { - if (!(globalParams)) // globalParams could be already created - globalParams = new GlobalParams(); - uout = new_PDFDoc_userdata(L); - uout->d = d; - uout->atype = ALLOC_LEPDF; - uout->pc = d->pc; - uout->pd = d; - } - return 1; // doc path -} - -static int l_open_MemStreamPDFDoc(lua_State * L) -{ - const char *docstream = NULL; - char *docstream_usr = NULL ; - const char *file_id; - unsigned long long stream_size; - udstruct *uout; - PdfDocument *d; - switch (lua_type(L, 1)) { - case LUA_TSTRING: - docstream = luaL_checkstring(L, 1); // stream as Lua string - break; - case LUA_TLIGHTUSERDATA: - docstream = (const char *) lua_touserdata(L, 1); // stream as sequence of bytes - break; - default: - luaL_error(L, "bad argument: string or lightuserdata expected"); - } - if (docstream==NULL) - luaL_error(L, "bad document"); - stream_size = (unsigned long long) luaL_checkint(L, 2);// size of the stream - file_id = luaL_checkstring(L, 3); // a symbolic name for this stream, mandatory - if (file_id == NULL) - luaL_error(L, "PDFDoc has an invalid id"); - if (strlen(file_id) >STREAM_FILE_ID_LEN ) // a limit to the length of the string - luaL_error(L, "PDFDoc has a too long id"); - docstream_usr = (char *)gmalloc((unsigned) (stream_size + 1)); - if (!docstream_usr) - luaL_error(L, "no room for PDFDoc"); - memcpy(docstream_usr, docstream, (stream_size + 1)); - docstream_usr[stream_size]='\0'; - d = refMemStreamPdfDocument(docstream_usr, stream_size, file_id); - if (d == NULL) { - lua_pushnil(L); - lua_pushnil(L); - lua_pushnil(L); - } - else if (d->file_path == NULL ) { - lua_pushnil(L); - lua_pushnil(L); - lua_pushnil(L); - } - else { - if (!(globalParams)) // globalParams could be already created - globalParams = new GlobalParams(); - uout = new_PDFDoc_userdata(L); - uout->d = d; - uout->atype = ALLOC_LEPDF; - uout->pc = d->pc; - uout->pd = d; - lua_pushstring(L,d->file_path); - lua_pushstring(L,STREAM_URI); - } - return 3; // stream, stream_id, stream_uri -} - - - - -static int l_new_Array(lua_State * L) -{ - udstruct *uxref, *uout; - uxref = (udstruct *) luaL_checkudata(L, 1, M_XRef); - if (uxref->pd != NULL && uxref->pd->pc != uxref->pc) - pdfdoc_changed_error(L); - uout = new_Array_userdata(L); - uout->d = new Array((XRef *) uxref->d); // automatic init to length 0 - uout->atype = ALLOC_LEPDF; - uout->pc = uxref->pc; - uout->pd = uxref->pd; - return 1; -} - -static int l_new_Attribute(lua_State * L) -{ - Attribute::Type t; - const char *n; - int nlen; - udstruct *uobj, *uout; - - if (lua_type(L,1)==LUA_TNUMBER) { - uobj = (udstruct *) luaL_checkudata(L, 2, M_Object); - if (uobj->pd != NULL && uobj->pd->pc != uobj->pc) - pdfdoc_changed_error(L); - t = (Attribute::Type) luaL_checkint(L, 1); - uout = new_Attribute_userdata(L); - uout->d = new Attribute(t, (Object *)uobj->d); - uout->atype = ALLOC_LEPDF; - uout->pc = uobj->pc; - uout->pd = uobj->pd; - - } else if (lua_type(L,1)==LUA_TSTRING) { - n = luaL_checkstring(L,1); - nlen = luaL_checkint(L,2); - uobj = (udstruct *) luaL_checkudata(L, 3, M_Object); - if (uobj->pd != NULL && uobj->pd->pc != uobj->pc) - pdfdoc_changed_error(L); - uout = new_Attribute_userdata(L); - uout->d = new Attribute(n, nlen, (Object *)uobj->d); - uout->atype = ALLOC_LEPDF; - uout->pc = uobj->pc; - uout->pd = uobj->pd; - } else - lua_pushnil(L); - return 1; -} - -#define ATTRIBUTE_TYPE_ENTRY(name) \ - lua_pushstring(L, #name); \ - lua_pushinteger(L, Attribute::name); \ - 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); \ - lua_settable(L,-3) - - -static int l_Attribute_Type(lua_State * L) { - lua_createtable (L, 0, 42); - ATTRIBUTE_TYPE_ENTRY(BBox); - ATTRIBUTE_TYPE_ENTRY(BackgroundColor); - ATTRIBUTE_TYPE_ENTRY(BorderColor); - ATTRIBUTE_TYPE_ENTRY(BorderThickness); - ATTRIBUTE_TYPE_ENTRY(Color); - ATTRIBUTE_TYPE_ENTRY(ColumnGap); - ATTRIBUTE_TYPE_ENTRY(ColumnWidths); - ATTRIBUTE_TYPE_ENTRY(Desc); - ATTRIBUTE_TYPE_ENTRY(Role); - ATTRIBUTE_TYPE_ENTRY(TextDecorationColor); - ATTRIBUTE_TYPE_ENTRY(TextDecorationThickness); - ATTRIBUTE_TYPE_ENTRY(BaselineShift); - ATTRIBUTE_TYPE_ENTRY(BlockAlign); - ATTRIBUTE_TYPE_ENTRY(BorderStyle); - ATTRIBUTE_TYPE_ENTRY(ColSpan); - ATTRIBUTE_TYPE_ENTRY(ColumnCount); - ATTRIBUTE_TYPE_ENTRY(EndIndent); - ATTRIBUTE_TYPE_ENTRY(GlyphOrientationVertical); - ATTRIBUTE_TYPE_ENTRY(Headers); - ATTRIBUTE_TYPE_ENTRY(Height); - ATTRIBUTE_TYPE_ENTRY(InlineAlign); - ATTRIBUTE_TYPE_ENTRY(LineHeight); - ATTRIBUTE_TYPE_ENTRY(ListNumbering); - ATTRIBUTE_TYPE_ENTRY(Padding); - ATTRIBUTE_TYPE_ENTRY(Placement); - ATTRIBUTE_TYPE_ENTRY(RowSpan); - ATTRIBUTE_TYPE_ENTRY(RubyAlign); - ATTRIBUTE_TYPE_ENTRY(RubyPosition); - ATTRIBUTE_TYPE_ENTRY(Scope); - ATTRIBUTE_TYPE_ENTRY(SpaceAfter); - ATTRIBUTE_TYPE_ENTRY(SpaceBefore); - ATTRIBUTE_TYPE_ENTRY(StartIndent); - ATTRIBUTE_TYPE_ENTRY(Summary); - ATTRIBUTE_TYPE_ENTRY(TBorderStyle); - ATTRIBUTE_TYPE_ENTRY(TPadding); - ATTRIBUTE_TYPE_ENTRY(TextAlign); - ATTRIBUTE_TYPE_ENTRY(TextDecorationType); - ATTRIBUTE_TYPE_ENTRY(TextIndent); - ATTRIBUTE_TYPE_ENTRY(Width); - ATTRIBUTE_TYPE_ENTRY(WritingMode); - ATTRIBUTE_TYPE_ENTRY(Unknown); - ATTRIBUTE_TYPE_ENTRY(checked); - 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); - STRUCTELEMENT_TYPE_ENTRY(Part); - STRUCTELEMENT_TYPE_ENTRY(Art); - STRUCTELEMENT_TYPE_ENTRY(Sect); - STRUCTELEMENT_TYPE_ENTRY(Div); - STRUCTELEMENT_TYPE_ENTRY(BlockQuote); - STRUCTELEMENT_TYPE_ENTRY(Caption); - STRUCTELEMENT_TYPE_ENTRY(NonStruct); - STRUCTELEMENT_TYPE_ENTRY(Index); - STRUCTELEMENT_TYPE_ENTRY(Private); - STRUCTELEMENT_TYPE_ENTRY(Span); - STRUCTELEMENT_TYPE_ENTRY(Quote); - STRUCTELEMENT_TYPE_ENTRY(Note); - STRUCTELEMENT_TYPE_ENTRY(Reference); - STRUCTELEMENT_TYPE_ENTRY(BibEntry); - STRUCTELEMENT_TYPE_ENTRY(Code); - STRUCTELEMENT_TYPE_ENTRY(Link); - STRUCTELEMENT_TYPE_ENTRY(Annot); - STRUCTELEMENT_TYPE_ENTRY(Ruby); - STRUCTELEMENT_TYPE_ENTRY(RB); - STRUCTELEMENT_TYPE_ENTRY(RT); - STRUCTELEMENT_TYPE_ENTRY(RP); - STRUCTELEMENT_TYPE_ENTRY(Warichu); - STRUCTELEMENT_TYPE_ENTRY(WT); - STRUCTELEMENT_TYPE_ENTRY(WP); - STRUCTELEMENT_TYPE_ENTRY(P); - STRUCTELEMENT_TYPE_ENTRY(H); - STRUCTELEMENT_TYPE_ENTRY(H1); - STRUCTELEMENT_TYPE_ENTRY(H2); - STRUCTELEMENT_TYPE_ENTRY(H3); - STRUCTELEMENT_TYPE_ENTRY(H4); - STRUCTELEMENT_TYPE_ENTRY(H5); - STRUCTELEMENT_TYPE_ENTRY(H6); - STRUCTELEMENT_TYPE_ENTRY(L); - STRUCTELEMENT_TYPE_ENTRY(LI); - STRUCTELEMENT_TYPE_ENTRY(Lbl); - STRUCTELEMENT_TYPE_ENTRY(LBody); - STRUCTELEMENT_TYPE_ENTRY(Table); - STRUCTELEMENT_TYPE_ENTRY(TR); - STRUCTELEMENT_TYPE_ENTRY(TH); - STRUCTELEMENT_TYPE_ENTRY(TD); - STRUCTELEMENT_TYPE_ENTRY(THead); - STRUCTELEMENT_TYPE_ENTRY(TFoot); - STRUCTELEMENT_TYPE_ENTRY(TBody); - STRUCTELEMENT_TYPE_ENTRY(Figure); - STRUCTELEMENT_TYPE_ENTRY(Formula); - STRUCTELEMENT_TYPE_ENTRY(Form); - STRUCTELEMENT_TYPE_ENTRY(TOC); - STRUCTELEMENT_TYPE_ENTRY(TOCI); - lua_pushstring(L, "Unknown"); - lua_pushinteger(L, 0); - lua_settable(L,-3); - return 1; -} - -static int l_AttributeOwner_Type(lua_State * L) { - lua_createtable (L, 0, 12); - lua_pushstring(L, "XML-1.00"); lua_pushinteger(L, Attribute::XML_1_00); lua_settable(L,-3); - lua_pushstring(L, "HTML-3.20"); lua_pushinteger(L, Attribute::HTML_3_20); lua_settable(L,-3); - lua_pushstring(L, "HTML-4.01"); lua_pushinteger(L, Attribute::HTML_4_01); lua_settable(L,-3); - lua_pushstring(L, "OEB-1.00"); lua_pushinteger(L, Attribute::OEB_1_00); lua_settable(L,-3); - lua_pushstring(L, "RTF-1.05"); lua_pushinteger(L, Attribute::RTF_1_05); lua_settable(L,-3); - lua_pushstring(L, "CSS-1.00"); lua_pushinteger(L, Attribute::CSS_1_00); lua_settable(L,-3); - lua_pushstring(L, "CSS-2.00"); lua_pushinteger(L, Attribute::CSS_2_00); lua_settable(L,-3); - lua_pushstring(L, "Layout"); lua_pushinteger(L, Attribute::Layout); lua_settable(L,-3); - lua_pushstring(L, "PrintField"); lua_pushinteger(L, Attribute::PrintField); lua_settable(L,-3); - lua_pushstring(L, "Table"); lua_pushinteger(L, Attribute::Table); lua_settable(L,-3); - lua_pushstring(L, "List"); lua_pushinteger(L, Attribute::List); lua_settable(L,-3); - lua_pushstring(L, "UserProperties"); lua_pushinteger(L, Attribute::UserProperties);lua_settable(L,-3); - return 1; -} - - -static int l_new_Dict(lua_State * L) -{ - udstruct *uxref, *uout; - uxref = (udstruct *) luaL_checkudata(L, 1, M_XRef); - if (uxref->pd != NULL && uxref->pd->pc != uxref->pc) - pdfdoc_changed_error(L); - uout = new_Dict_userdata(L); - uout->d = new Dict((XRef *) uxref->d); // automatic init to length 0 - uout->atype = ALLOC_LEPDF; - uout->pc = uxref->pc; - uout->pd = uxref->pd; - return 1; -} - -static int l_new_Object(lua_State * L) -{ - udstruct *uout; - int n = lua_gettop(L); // number of arguments - uout = new_Object_userdata(L); - 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) -{ - udstruct *uout; - uout = new_PDFRectangle_userdata(L); - uout->d = new PDFRectangle(); // automatic init to [0, 0, 0, 0] - uout->atype = ALLOC_LEPDF; - uout->pc = 0; - uout->pd = NULL; - return 1; -} - -static const struct luaL_Reg epdflib_f[] = { - {"open", l_open_PDFDoc}, - {"openMemStream", l_open_MemStreamPDFDoc}, - {"Array", l_new_Array}, - {"Attribute", l_new_Attribute}, - {"StructElement_Type", l_StructElement_Type}, - {"Attribute_Type", l_Attribute_Type}, - {"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 -}; - -//********************************************************************** - -#define m_poppler_get_poppler(in, out, function) \ -static int m_##in##_##function(lua_State * L) \ -{ \ - out *o; \ - udstruct *uin, *uout; \ - uin = (udstruct *) luaL_checkudata(L, 1, M_##in); \ - if (uin->pd != NULL && uin->pd->pc != uin->pc) \ - pdfdoc_changed_error(L); \ - o = ((in *) uin->d)->function(); \ - if (o != NULL) { \ - uout = new_##out##_userdata(L); \ - uout->d = o; \ - uout->pc = uin->pc; \ - uout->pd = uin->pd; \ - } else \ - lua_pushnil(L); \ - return 1; \ -} - -#define m_poppler_get_BOOL(in, function) \ -static int m_##in##_##function(lua_State * L) \ -{ \ - udstruct *uin; \ - uin = (udstruct *) luaL_checkudata(L, 1, M_##in); \ - if (uin->pd != NULL && uin->pd->pc != uin->pc) \ - pdfdoc_changed_error(L); \ - if (((in *) uin->d)->function()) \ - lua_pushboolean(L, 1); \ - else \ - lua_pushboolean(L, 0); \ - return 1; \ -} - -#define m_poppler_get_INT(in, function) \ -static int m_##in##_##function(lua_State * L) \ -{ \ - int i; \ - udstruct *uin; \ - uin = (udstruct *) luaL_checkudata(L, 1, M_##in); \ - if (uin->pd != NULL && uin->pd->pc != uin->pc) \ - pdfdoc_changed_error(L); \ - i = (int) ((in *) uin->d)->function(); \ - lua_pushinteger(L, i); \ - return 1; \ -} - - -#define m_poppler_get_GUINT(in, function) \ -static int m_##in##_##function(lua_State * L) \ -{ \ - unsigned int i; \ - udstruct *uin; \ - uin = (udstruct *) luaL_checkudata(L, 1, M_##in); \ - if (uin->pd != NULL && uin->pd->pc != uin->pc) \ - pdfdoc_changed_error(L); \ - i = (unsigned int) ((in *) uin->d)->function(); \ - lua_pushinteger(L, i); \ - return 1; \ -} - -#define m_poppler_get_UINT(in, function) \ -m_poppler_get_GUINT(in, function) - - - -#define m_poppler_get_DOUBLE(in, function) \ -static int m_##in##_##function(lua_State * L) \ -{ \ - double d; \ - udstruct *uin; \ - uin = (udstruct *) luaL_checkudata(L, 1, M_##in); \ - if (uin->pd != NULL && uin->pd->pc != uin->pc) \ - pdfdoc_changed_error(L); \ - d = (double) ((in *) uin->d)->function(); \ - lua_pushnumber(L, d); /* float */ \ - return 1; \ -} - -#define m_poppler_get_GOOSTRING(in, function) \ -static int m_##in##_##function(lua_State * L) \ -{ \ - GooString *gs; \ - udstruct *uin; \ - uin = (udstruct *) luaL_checkudata(L, 1, M_##in); \ - if (uin->pd != NULL && uin->pd->pc != uin->pc) \ - pdfdoc_changed_error(L); \ - gs = (GooString *)((in *) uin->d)->function(); \ - if (gs != NULL) \ - lua_pushlstring(L, gs->getCString(), gs->getLength()); \ - else \ - lua_pushnil(L); \ - return 1; \ -} - -#define m_poppler_get_OBJECT(in, function) \ -static int m_##in##_##function(lua_State * L) \ -{ \ - udstruct *uin, *uout; \ - uin = (udstruct *) luaL_checkudata(L, 1, M_##in); \ - if (uin->pd != NULL && uin->pd->pc != uin->pc) \ - pdfdoc_changed_error(L); \ - uout = new_Object_userdata(L); \ - uout->d = new Object(); \ - *((Object *)uout->d) = ((in *) uin->d)->function(); \ - uout->atype = ALLOC_LEPDF; \ - uout->pc = uin->pc; \ - uout->pd = uin->pd; \ - return 1; \ -} - -#define m_poppler_do(in, function) \ -static int m_##in##_##function(lua_State * L) \ -{ \ - udstruct *uin; \ - uin = (udstruct *) luaL_checkudata(L, 1, M_##in); \ - if (uin->pd != NULL && uin->pd->pc != uin->pc) \ - pdfdoc_changed_error(L); \ - ((in *) uin->d)->function(); \ - return 0; \ -} - -#define m_poppler__tostring(type) \ -static int m_##type##__tostring(lua_State * L) \ -{ \ - udstruct *uin; \ - uin = (udstruct *) luaL_checkudata(L, 1, M_##type); \ - if (uin->pd != NULL && uin->pd->pc != uin->pc) \ - pdfdoc_changed_error(L); \ - lua_pushfstring(L, "%s: %p", #type, (type *) uin->d); \ - return 1; \ -} - -#define m_poppler_check_string(in, function) \ -static int m_##in##_##function(lua_State * L) \ -{ \ - const char *s; \ - udstruct *uin; \ - uin = (udstruct *) luaL_checkudata(L, 1, M_##in); \ - if (uin->pd != NULL && uin->pd->pc != uin->pc) \ - pdfdoc_changed_error(L); \ - s = luaL_checkstring(L, 2); \ - if (((in *) uin->d)->function(s)) \ - lua_pushboolean(L, 1); \ - else \ - lua_pushboolean(L, 0); \ - return 1; \ -} - -//********************************************************************** -// Annot - -m_poppler_get_BOOL(Annot, isOk); - -static int m_Annot_match(lua_State * L) -{ - udstruct *uin, *uref; - uin = (udstruct *) luaL_checkudata(L, 1, M_Annot); - uref = (udstruct *) luaL_checkudata(L, 2, M_Ref); - if (uin->pd != NULL && uref->pd != NULL && uin->pd != uref->pd) - pdfdoc_differs_error(L); - if ((uin->pd != NULL && uin->pd->pc != uin->pc) - || (uref->pd != NULL && uref->pd->pc != uref->pc)) - pdfdoc_changed_error(L); - lua_pushboolean(L, ((Annot *) uin->d)->match((Ref *) uref->d)); - return 1; -} - -m_poppler__tostring(Annot); - -static int m_Annot__gc(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Annot); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); -#ifdef DEBUG - printf("\n===== Annot GC ===== uin=<%p>\n", uin); -#endif - if (uin->atype == ALLOC_LEPDF) -#if 1 /* def HAVE_ANNOTDECREFCNT */ - ((Annot *) uin->d)->decRefCnt(); -#else - delete(Annot *) uin->d; -#endif - return 0; -} - -static const struct luaL_Reg Annot_m[] = { - {"isOk", m_Annot_isOk}, - {"match", m_Annot_match}, - {"__tostring", m_Annot__tostring}, - {"__gc", m_Annot__gc}, - {NULL, NULL} // sentinel -}; - -//********************************************************************** -// Annots - -m_poppler_get_INT(Annots, getNumAnnots); - -static int m_Annots_getAnnot(lua_State * L) -{ - int i, annots; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Annots); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - annots = ((Annots *) uin->d)->getNumAnnots(); - if (i > 0 && i <= annots) { - uout = new_Annot_userdata(L); - uout->d = ((Annots *) uin->d)->getAnnot(i); - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -m_poppler__tostring(Annots); - -static const struct luaL_Reg Annots_m[] = { - {"getNumAnnots", m_Annots_getNumAnnots}, - {"getAnnot", m_Annots_getAnnot}, - {"__tostring", m_Annots__tostring}, - {NULL, NULL} // sentinel -}; - -//********************************************************************** -// Array -// 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); - -static int m_Array_add(lua_State * L) -{ - udstruct *uin, *uobj; - uin = (udstruct *) luaL_checkudata(L, 1, M_Array); - uobj = (udstruct *) luaL_checkudata(L, 2, M_Object); - if (uin->pd != NULL && uobj->pd != NULL && uin->pd != uobj->pd) - pdfdoc_differs_error(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(std::move(*((Object *) uobj->d))); - return 0; -} - -static int m_Array_get(lua_State * L) -{ - int i, len; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Array); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - len = ((Array *) uin->d)->getLength(); - if (i > 0 && i <= len) { - uout = new_Object_userdata(L); - uout->d = new Object(); - *((Object *) uout->d) = ((Array *) uin->d)->get(i - 1); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -static int m_Array_getNF(lua_State * L) -{ - int i, len; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Array); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - len = ((Array *) uin->d)->getLength(); - if (i > 0 && i <= len) { - uout = new_Object_userdata(L); - uout->d = new Object(); - *((Object *) uout->d) = ((Array *) uin->d)->getNF(i - 1); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -static int m_Array_getString(lua_State * L) -{ - GooString *gs; - int i, len; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Array); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - len = ((Array *) uin->d)->getLength(); - if (i > 0 && i <= len) { - gs = new GooString(); - if (((Array *) uin->d)->getString(i - 1, gs)) - lua_pushlstring(L, gs->getCString(), gs->getLength()); - else - lua_pushnil(L); - delete gs; - } else - lua_pushnil(L); - return 1; -} - -m_poppler__tostring(Array); - -static const struct luaL_Reg Array_m[] = { - // {"incRef", m_Array_incRef},// Now private - // {"decRef", m_Array_decRef},// Now private - {"getLength", m_Array_getLength}, - {"add", m_Array_add}, - {"get", m_Array_get}, - {"getNF", m_Array_getNF}, - {"getString", m_Array_getString}, - {"__tostring", m_Array__tostring}, - {NULL, NULL} // sentinel -}; - -//********************************************************************** -// Catalog - -m_poppler_get_BOOL(Catalog, isOk); -m_poppler_get_INT(Catalog, getNumPages); - -static int m_Catalog_getPage(lua_State * L) -{ - int i, pages; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Catalog); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - pages = ((Catalog *) uin->d)->getNumPages(); - if (i > 0 && i <= pages) { - uout = new_Page_userdata(L); - uout->d = ((Catalog *) uin->d)->getPage(i); - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -static int m_Catalog_getPageRef(lua_State * L) -{ - int i, pages; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Catalog); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - pages = ((Catalog *) uin->d)->getNumPages(); - if (i > 0 && i <= pages) { - uout = new_Ref_userdata(L); - uout->d = (Ref *) gmalloc(sizeof(Ref)); - ((Ref *) uout->d)->num = ((Catalog *) uin->d)->getPageRef(i)->num; - ((Ref *) uout->d)->gen = ((Catalog *) uin->d)->getPageRef(i)->gen; - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -m_poppler_get_GOOSTRING(Catalog, getBaseURI); -m_poppler_get_GOOSTRING(Catalog, readMetadata); -m_poppler_get_poppler(Catalog, StructTreeRoot, getStructTreeRoot); - -static int m_Catalog_findPage(lua_State * L) -{ - int num, gen, i; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Catalog); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - num = luaL_checkint(L, 2); - gen = luaL_checkint(L, 3); - i = ((Catalog *) uin->d)->findPage(num, gen); - if (i > 0) - lua_pushinteger(L, i); - else - lua_pushnil(L); - return 1; -} - -static int m_Catalog_findDest(lua_State * L) -{ - GooString *name; - LinkDest *dest; - const char *s; - size_t len; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Catalog); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - s = luaL_checklstring(L, 2, &len); - name = new GooString(s, len); - dest = ((Catalog *) uin->d)->findDest(name); - if (dest != NULL) { - uout = new_LinkDest_userdata(L); - uout->d = dest; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - delete name; - return 1; -} - -m_poppler_get_poppler(Catalog, Object, getDests); -m_poppler_get_INT(Catalog, numEmbeddedFiles); - -static int m_Catalog_embeddedFile(lua_State * L) -{ - int i, len; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Catalog); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - len = ((Catalog *) uin->d)->numEmbeddedFiles(); - if (i > 0 && i <= len) { - uout = new_FileSpec_userdata(L); - uout->d = ((Catalog *) uin->d)->embeddedFile(i - 1); - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -m_poppler_get_INT(Catalog, numJS); - -static int m_Catalog_getJS(lua_State * L) -{ - GooString *gs; - int i, len; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Catalog); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - len = ((Catalog *) uin->d)->numJS(); - if (i > 0 && i <= len) { - gs = ((Catalog *) uin->d)->getJS(i - 1); - if (gs != NULL) - lua_pushlstring(L, gs->getCString(), gs->getLength()); - else - lua_pushnil(L); - delete gs; - } else - lua_pushnil(L); - return 1; -} - -m_poppler_get_poppler(Catalog, Object, getOutline); -m_poppler_get_poppler(Catalog, Object, getAcroForm); - -m_poppler__tostring(Catalog); - -static const struct luaL_Reg Catalog_m[] = { - {"isOk", m_Catalog_isOk}, - {"getNumPages", m_Catalog_getNumPages}, - {"getPage", m_Catalog_getPage}, - {"getPageRef", m_Catalog_getPageRef}, - {"getBaseURI", m_Catalog_getBaseURI}, - {"readMetadata", m_Catalog_readMetadata}, - {"getStructTreeRoot", m_Catalog_getStructTreeRoot}, - {"findPage", m_Catalog_findPage}, - {"findDest", m_Catalog_findDest}, - {"getDests", m_Catalog_getDests}, - {"numEmbeddedFiles", m_Catalog_numEmbeddedFiles}, - {"embeddedFile", m_Catalog_embeddedFile}, - {"numJS", m_Catalog_numJS}, - {"getJS", m_Catalog_getJS}, - {"getOutline", m_Catalog_getOutline}, - {"getAcroForm", m_Catalog_getAcroForm}, - {"__tostring", m_Catalog__tostring}, - {NULL, NULL} // sentinel -}; - -//********************************************************************** -// Dict -// 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); - -static int m_Dict_add(lua_State * L) -{ - char *s; - udstruct *uin, *uobj; - uin = (udstruct *) luaL_checkudata(L, 1, M_Dict); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - s = copyString(luaL_checkstring(L, 2)); - uobj = (udstruct *) luaL_checkudata(L, 3, M_Object); - ((Dict *) uin->d)->add(s, std::move(*((Object *) uobj->d))); - return 0; -} - -static int m_Dict_set(lua_State * L) -{ - const char *s; - udstruct *uin, *uobj; - uin = (udstruct *) luaL_checkudata(L, 1, M_Dict); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - s = luaL_checkstring(L, 2); - uobj = (udstruct *) luaL_checkudata(L, 3, M_Object); - ((Dict *) uin->d)->set(s, std::move(*((Object *) uobj->d))); - return 0; -} - -static int m_Dict_remove(lua_State * L) -{ - const char *s; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Dict); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - s = luaL_checkstring(L, 2); - ((Dict *) uin->d)->remove(s); - return 0; -} - -m_poppler_check_string(Dict, is); - -static int m_Dict_lookup(lua_State * L) -{ - const char *s; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Dict); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - s = luaL_checkstring(L, 2); - uout = new_Object_userdata(L); - uout->d = new Object(); - *((Object *) uout->d) = ((Dict *) uin->d)->lookup(s); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - return 1; -} - -static int m_Dict_lookupNF(lua_State * L) -{ - const char *s; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Dict); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - s = luaL_checkstring(L, 2); - uout = new_Object_userdata(L); - uout->d = new Object(); - *((Object *) uout->d) = ((Dict *) uin->d)->lookupNF(s); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - return 1; -} - -static int m_Dict_lookupInt(lua_State * L) -{ - const char *s1, *s2; - 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); - s1 = luaL_checkstring(L, 2); - s2 = luaL_checkstring(L, 3); - if (((Dict *) uin->d)->lookupInt(s1, s2, &i)) - lua_pushinteger(L, i); - else - lua_pushnil(L); - return 1; -} - -static int m_Dict_getKey(lua_State * L) -{ - int i, len; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Dict); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - len = ((Dict *) uin->d)->getLength(); - if (i > 0 && i <= len) - lua_pushstring(L, ((Dict *) uin->d)->getKey(i - 1)); - else - lua_pushnil(L); - return 1; -} - -static int m_Dict_getVal(lua_State * L) -{ - int i, len; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Dict); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - len = ((Dict *) uin->d)->getLength(); - if (i > 0 && i <= len) { - uout = new_Object_userdata(L); - uout->d = new Object(); - *((Object *) uout->d) = ((Dict *) uin->d)->getVal(i - 1); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -static int m_Dict_getValNF(lua_State * L) -{ - int i, len; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Dict); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - len = ((Dict *) uin->d)->getLength(); - if (i > 0 && i <= len) { - uout = new_Object_userdata(L); - uout->d = new Object(); - *((Object *) uout->d) = ((Dict *) uin->d)->getValNF(i - 1); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -m_poppler_check_string(Dict, hasKey); - -m_poppler__tostring(Dict); - -static const struct luaL_Reg Dict_m[] = { - // {"incRef", m_Dict_incRef},// Now private - // {"decRef", m_Dict_decRef},// Now private - {"getLength", m_Dict_getLength}, - {"add", m_Dict_add}, - {"set", m_Dict_set}, - {"remove", m_Dict_remove}, - {"is", m_Dict_is}, - {"lookup", m_Dict_lookup}, - {"lookupNF", m_Dict_lookupNF}, - {"lookupInt", m_Dict_lookupInt}, - {"getKey", m_Dict_getKey}, - {"getVal", m_Dict_getVal}, - {"getValNF", m_Dict_getValNF}, - {"hasKey", m_Dict_hasKey}, - {"__tostring", m_Dict__tostring}, - {NULL, NULL} // sentinel -}; - -//********************************************************************** -// EmbFile - -m_poppler_get_INT(EmbFile, size); -m_poppler_get_GOOSTRING(EmbFile, modDate); -m_poppler_get_GOOSTRING(EmbFile, createDate); -m_poppler_get_GOOSTRING(EmbFile, checksum); -m_poppler_get_GOOSTRING(EmbFile, mimeType); - -m_poppler_get_BOOL(EmbFile, isOk); - -static int m_EmbFile_save(lua_State * L) -{ - const char *s; - size_t len; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_EmbFile); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - s = luaL_checklstring(L, 2, &len); - if (((EmbFile *) uin->d)->save(s)) - lua_pushboolean(L, 1); - else - lua_pushboolean(L, 0); - return 1; -} - -m_poppler__tostring(EmbFile); - -static const struct luaL_Reg EmbFile_m[] = { - {"size", m_EmbFile_size}, - {"modDate", m_EmbFile_modDate}, - {"createDate", m_EmbFile_createDate}, - {"checksum", m_EmbFile_checksum}, - {"mimeType", m_EmbFile_mimeType}, - {"isOk", m_EmbFile_isOk}, - {"save", m_EmbFile_save}, - {"__tostring", m_EmbFile__tostring}, - {NULL, NULL} // sentinel -}; - -//********************************************************************** -// FileSpec - -m_poppler_get_BOOL(FileSpec, isOk); -m_poppler_get_GOOSTRING(FileSpec, getFileName); -m_poppler_get_GOOSTRING(FileSpec, getFileNameForPlatform); -m_poppler_get_GOOSTRING(FileSpec, getDescription); - -static int m_FileSpec_getEmbeddedFile(lua_State * L) -{ - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_FileSpec); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - uout = new_EmbFile_userdata(L); - uout->d = ((FileSpec *) uin->d)->getEmbeddedFile(); - uout->pc = uin->pc; - uout->pd = uin->pd; - return 1; -} - -m_poppler__tostring(FileSpec); - -static const struct luaL_Reg FileSpec_m[] = { - {"isOk", m_FileSpec_isOk}, - {"getFileName", m_FileSpec_getFileName}, - {"getFileNameForPlatform", m_FileSpec_getFileNameForPlatform}, - {"getDescription", m_FileSpec_getDescription}, - {"getEmbeddedFile", m_FileSpec_getEmbeddedFile}, - {"__tostring", m_FileSpec__tostring}, - {NULL, NULL} // sentinel -}; - -//********************************************************************** -// GooString - -static int m_GooString__tostring(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_GooString); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - lua_pushlstring(L, ((GooString *) uin->d)->getCString(), - ((GooString *) uin->d)->getLength()); - return 1; -} - -static const struct luaL_Reg GooString_m[] = { - {"__tostring", m_GooString__tostring}, - {NULL, NULL} // sentinel -}; - -//********************************************************************** -// LinkDest - -static const char *LinkDestKindNames[] = - { "XYZ", "Fit", "FitH", "FitV", "FitR", "FitB", "FitBH", "FitBV", NULL }; - -m_poppler_get_BOOL(LinkDest, isOk); - -static int m_LinkDest_getKind(lua_State * L) -{ - int i; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_LinkDest); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = (int) ((LinkDest *) uin->d)->getKind(); - lua_pushinteger(L, i); - return 1; -} - -static int m_LinkDest_getKindName(lua_State * L) -{ - int i; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_LinkDest); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = (int) ((LinkDest *) uin->d)->getKind(); - lua_pushstring(L, LinkDestKindNames[i]); - return 1; -} - -m_poppler_get_BOOL(LinkDest, isPageRef); -m_poppler_get_INT(LinkDest, getPageNum); - -static int m_LinkDest_getPageRef(lua_State * L) -{ - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_LinkDest); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - uout = new_Ref_userdata(L); - uout->d = (Ref *) gmalloc(sizeof(Ref)); - ((Ref *) uout->d)->num = ((LinkDest *) uin->d)->getPageRef().num; - ((Ref *) uout->d)->gen = ((LinkDest *) uin->d)->getPageRef().gen; - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - return 1; -} - -m_poppler_get_DOUBLE(LinkDest, getLeft); -m_poppler_get_DOUBLE(LinkDest, getBottom); -m_poppler_get_DOUBLE(LinkDest, getRight); -m_poppler_get_DOUBLE(LinkDest, getTop); -m_poppler_get_DOUBLE(LinkDest, getZoom); -m_poppler_get_BOOL(LinkDest, getChangeLeft); -m_poppler_get_BOOL(LinkDest, getChangeTop); -m_poppler_get_BOOL(LinkDest, getChangeZoom); - -m_poppler__tostring(LinkDest); - -static const struct luaL_Reg LinkDest_m[] = { - {"isOk", m_LinkDest_isOk}, - {"getKind", m_LinkDest_getKind}, - {"getKindName", m_LinkDest_getKindName}, // not poppler - {"isPageRef", m_LinkDest_isPageRef}, - {"getPageNum", m_LinkDest_getPageNum}, - {"getPageRef", m_LinkDest_getPageRef}, - {"getLeft", m_LinkDest_getLeft}, - {"getBottom", m_LinkDest_getBottom}, - {"getRight", m_LinkDest_getRight}, - {"getTop", m_LinkDest_getTop}, - {"getZoom", m_LinkDest_getZoom}, - {"getChangeLeft", m_LinkDest_getChangeLeft}, - {"getChangeTop", m_LinkDest_getChangeTop}, - {"getChangeZoom", m_LinkDest_getChangeZoom}, - {"__tostring", m_LinkDest__tostring}, - {NULL, NULL} // sentinel -}; - -//********************************************************************** -// Links - -m_poppler_get_INT(Links, getNumLinks); - -m_poppler__tostring(Links); - -static const struct luaL_Reg Links_m[] = { - {"getNumLinks", m_Links_getNumLinks}, - //{"getLink", m_Links_getLink}, - {"__tostring", m_Links__tostring}, - {NULL, NULL} // sentinel -}; - -//********************************************************************** -// Object - -#ifdef HAVE_OBJECT_INITCMD_CONST_CHARP -#define CHARP_CAST -#else -// must cast arg of Object::initCmd, Object::isStream, and Object::streamIs -// from 'const char *' to 'char *', although they are not modified. -#define CHARP_CAST (char *) -#endif - -// Special type checking. -#define m_Object_isType_(function, cast) \ -static int m_Object_##function(lua_State * L) \ -{ \ - udstruct *uin; \ - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); \ - if (uin->pd != NULL && uin->pd->pc != uin->pc) \ - pdfdoc_changed_error(L); \ - if (lua_gettop(L) >= 2) { \ - if (lua_isstring(L, 2) \ - && ((Object *) uin->d)->function(cast lua_tostring(L, 2))) \ - lua_pushboolean(L, 1); \ - else \ - lua_pushboolean(L, 0); \ - } else { \ - if (((Object *) uin->d)->function()) \ - lua_pushboolean(L, 1); \ - else \ - lua_pushboolean(L, 0); \ - } \ - return 1; \ -} -#define m_Object_isType(function) m_Object_isType_(function, ) -#define m_Object_isType_nonconst(function) m_Object_isType_(function, CHARP_CAST) - -static int m_Object_initBool(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - luaL_checktype(L, 2, LUA_TBOOLEAN); - if (lua_toboolean(L, 2) != 0) - *((Object *) uin->d) = Object(gTrue); - else - *((Object *) uin->d) = Object(gFalse); - return 0; -} - -static int m_Object_initInt(lua_State * L) -{ - int i; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - *((Object *) uin->d) = Object(i); - return 0; -} - -static int m_Object_initReal(lua_State * L) -{ - double d; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - d = luaL_checknumber(L, 2); - *((Object *) uin->d) = Object(d); - return 0; -} - -static int m_Object_initString(lua_State * L) -{ - GooString *gs; - const char *s; - size_t len; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - s = luaL_checklstring(L, 2, &len); - gs = new GooString(s, len); - *((Object *) uin->d) = Object(gs); - return 0; -} - -static int m_Object_initName(lua_State * L) -{ - const char *s; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - s = luaL_checkstring(L, 2); - *((Object *) uin->d) = Object(objName, s); - return 0; -} - -static int m_Object_initNull(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - *((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) - pdfdoc_differs_error(L); - if ((uin->pd != NULL && uin->pd->pc != uin->pc) - || (uxref->pd != NULL && uxref->pd->pc != uxref->pc)) - pdfdoc_changed_error(L); - a = new Array((XRef *) uxref->d); - *((Object *) uin->d) = Object(a); - return 0; -} - -// TODO: decide betweeen -// Object *initDict(XRef *xref); -// Object *initDict(Dict *dictA); - -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) - pdfdoc_differs_error(L); - if ((uin->pd != NULL && uin->pd->pc != uin->pc) - || (uxref->pd != NULL && uxref->pd->pc != uxref->pc)) - pdfdoc_changed_error(L); - d = new Dict((XRef *) uxref->d); - *((Object *) uin->d) = Object(d); - return 0; -} - -static int m_Object_initStream(lua_State * L) -{ - udstruct *uin, *ustream; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - ustream = (udstruct *) luaL_checkudata(L, 2, M_Stream); - if (uin->pd != NULL && ustream->pd != NULL && uin->pd != ustream->pd) - pdfdoc_differs_error(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) = Object((Stream *) ustream->d); - return 0; -} - -static int m_Object_initRef(lua_State * L) -{ - int num, gen; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - num = luaL_checkint(L, 2); - gen = luaL_checkint(L, 3); - *((Object *) uin->d) = Object(num, gen); - return 0; -} - -static int m_Object_initCmd(lua_State * L) -{ - const char *s; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - s = luaL_checkstring(L, 2); - *((Object *) uin->d) = Object(objCmd, s); - return 0; -} - -static int m_Object_initError(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - *((Object *) uin->d) = Object(objError); - return 0; -} - -static int m_Object_initEOF(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - *((Object *) uin->d) = Object(objEOF); - return 0; -} - -static int m_Object_fetch(lua_State * L) -{ - udstruct *uin, *uxref, *uout; - 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) - pdfdoc_differs_error(L); - if ((uin->pd != NULL && uin->pd->pc != uin->pc) - || (uxref->pd != NULL && uxref->pd->pc != uxref->pc)) - pdfdoc_changed_error(L); - uout = new_Object_userdata(L); - uout->d = new Object(); - *((Object *) uout->d) = ((Object *) uin->d)->fetch((XRef *) uxref->d); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - return 1; -} - -static int m_Object_getType(lua_State * L) -{ - ObjType t; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - t = ((Object *) uin->d)->getType(); - lua_pushinteger(L, (int) t); - return 1; -} - -static int m_Object_getTypeName(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - lua_pushstring(L, ((Object *) uin->d)->getTypeName()); - return 1; -} - -m_poppler_get_BOOL(Object, isBool); -m_poppler_get_BOOL(Object, isInt); -m_poppler_get_BOOL(Object, isReal); -m_poppler_get_BOOL(Object, isNum); -m_poppler_get_BOOL(Object, isString); -m_Object_isType(isName); -m_poppler_get_BOOL(Object, isNull); -m_poppler_get_BOOL(Object, isArray); -m_Object_isType(isDict); -m_Object_isType_nonconst(isStream); -m_poppler_get_BOOL(Object, isRef); -m_Object_isType(isCmd); -m_poppler_get_BOOL(Object, isError); -m_poppler_get_BOOL(Object, isEOF); -m_poppler_get_BOOL(Object, isNone); - -static int m_Object_getBool(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isBool()) { - if (((Object *) uin->d)->getBool()) - lua_pushboolean(L, 1); - else - lua_pushboolean(L, 0); - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_getInt(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isInt()) - lua_pushinteger(L, ((Object *) uin->d)->getInt()); - else - lua_pushnil(L); - return 1; -} - -static int m_Object_getReal(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isReal()) - lua_pushnumber(L, ((Object *) uin->d)->getReal()); /* float */ - else - lua_pushnil(L); - return 1; -} - -static int m_Object_getNum(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isInt()) - lua_pushinteger(L, ((Object *) uin->d)->getInt()); - else if (((Object *) uin->d)->isReal()) - lua_pushinteger(L, ((Object *) uin->d)->getReal()); - else if (((Object *) uin->d)->isNum()) /* redundant */ - lua_pushnumber(L, ((Object *) uin->d)->getNum()); /* integer or float */ - else - lua_pushnil(L); - return 1; -} - -static int m_Object_getString(lua_State * L) -{ - GooString *gs; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isString()) { - gs = (GooString *)((Object *) uin->d)->getString(); - lua_pushlstring(L, gs->getCString(), gs->getLength()); - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_getName(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isName()) - lua_pushstring(L, ((Object *) uin->d)->getName()); - else - lua_pushnil(L); - return 1; -} - -static int m_Object_getArray(lua_State * L) -{ - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isArray()) { - uout = new_Array_userdata(L); - uout->d = ((Object *) uin->d)->getArray(); - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_getDict(lua_State * L) -{ - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isDict()) { - uout = new_Dict_userdata(L); - uout->d = ((Object *) uin->d)->getDict(); - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_getStream(lua_State * L) -{ - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isStream()) { - uout = new_Stream_userdata(L); - uout->d = ((Object *) uin->d)->getStream(); - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_getRef(lua_State * L) -{ - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isRef()) { - uout = new_Ref_userdata(L); - uout->d = (Ref *) gmalloc(sizeof(Ref)); - ((Ref *) uout->d)->num = ((Object *) uin->d)->getRef().num; - ((Ref *) uout->d)->gen = ((Object *) uin->d)->getRef().gen; - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_getRefNum(lua_State * L) -{ - int i; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isRef()) { - i = ((Object *) uin->d)->getRef().num; - lua_pushinteger(L, i); - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_getRefGen(lua_State * L) -{ - int i; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isRef()) { - i = ((Object *) uin->d)->getRef().gen; - lua_pushinteger(L, i); - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_getCmd(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isCmd()) - lua_pushstring(L, ((Object *) uin->d)->getCmd()); - else - lua_pushnil(L); - return 1; -} - -static int m_Object_arrayGetLength(lua_State * L) -{ - int len; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isArray()) { - len = ((Object *) uin->d)->arrayGetLength(); - lua_pushinteger(L, len); - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_arrayAdd(lua_State * L) -{ - udstruct *uin, *uobj; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - uobj = (udstruct *) luaL_checkudata(L, 2, M_Object); - if (uin->pd != NULL && uobj->pd != NULL && uin->pd != uobj->pd) - pdfdoc_differs_error(L); - if ((uin->pd != NULL && uin->pd->pc != uin->pc) - || (uobj->pd != NULL && uobj->pd->pc != uobj->pd->pc)) - pdfdoc_changed_error(L); - if (!((Object *) uin->d)->isArray()) - luaL_error(L, "Object is not an Array"); - ((Object *) uin->d)->arrayAdd(std::move(*((Object *) uobj->d))); - return 0; -} - -static int m_Object_arrayGet(lua_State * L) -{ - int i, len; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - if (((Object *) uin->d)->isArray()) { - len = ((Object *) uin->d)->arrayGetLength(); - if (i > 0 && i <= len) { - uout = new_Object_userdata(L); - uout->d = new Object(); - *((Object *) uout->d) = ((Object *) uin->d)->arrayGet(i - 1); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_arrayGetNF(lua_State * L) -{ - int i, len; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - if (((Object *) uin->d)->isArray()) { - len = ((Object *) uin->d)->arrayGetLength(); - if (i > 0 && i <= len) { - uout = new_Object_userdata(L); - uout->d = new Object(); - *((Object *) uout->d) = ((Object *) uin->d)->arrayGetNF(i - 1); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_dictGetLength(lua_State * L) -{ - int len; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isDict()) { - len = ((Object *) uin->d)->dictGetLength(); - lua_pushinteger(L, len); - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_dictAdd(lua_State * L) -{ - const char *s; - udstruct *uin, *uobj; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - s = luaL_checkstring(L, 2); - uobj = (udstruct *) luaL_checkudata(L, 3, M_Object); - if (uin->pd != NULL && uobj->pd != NULL && uin->pd != uobj->pd) - pdfdoc_differs_error(L); - if ((uin->pd != NULL && uin->pd->pc != uin->pc) - || (uobj->pd != NULL && uobj->pd->pc != uobj->pd->pc)) - pdfdoc_changed_error(L); - if (!((Object *) uin->d)->isDict()) - luaL_error(L, "Object is not a Dict"); - ((Object *) uin->d)->dictAdd(copyString(s), std::move(*((Object *) uobj->d))); - return 0; -} - -static int m_Object_dictSet(lua_State * L) -{ - const char *s; - udstruct *uin, *uobj; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - s = luaL_checkstring(L, 2); - uobj = (udstruct *) luaL_checkudata(L, 3, M_Object); - if (uin->pd != NULL && uobj->pd != NULL && uin->pd != uobj->pd) - pdfdoc_differs_error(L); - if ((uin->pd != NULL && uin->pd->pc != uin->pc) - || (uobj->pd != NULL && uobj->pd->pc != uobj->pd->pc)) - pdfdoc_changed_error(L); - if (!((Object *) uin->d)->isDict()) - luaL_error(L, "Object is not a Dict"); - ((Object *) uin->d)->dictSet(s, std::move(*((Object *) uobj->d))); - return 0; -} - -static int m_Object_dictLookup(lua_State * L) -{ - const char *s; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - s = luaL_checkstring(L, 2); - if (((Object *) uin->d)->isDict()) { - uout = new_Object_userdata(L); - uout->d = new Object(); - *((Object *) uout->d) = ((Object *) uin->d)->dictLookup(s); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_dictLookupNF(lua_State * L) -{ - const char *s; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - s = luaL_checkstring(L, 2); - if (((Object *) uin->d)->isDict()) { - uout = new_Object_userdata(L); - uout->d = new Object(); - *((Object *) uout->d) = ((Object *) uin->d)->dictLookupNF(s); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_dictGetKey(lua_State * L) -{ - int i, len; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - if (((Object *) uin->d)->isDict()) { - len = ((Object *) uin->d)->dictGetLength(); - if (i > 0 && i <= len) - lua_pushstring(L, ((Object *) uin->d)->dictGetKey(i - 1)); - else - lua_pushnil(L); - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_dictGetVal(lua_State * L) -{ - int i, len; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - if (((Object *) uin->d)->isDict()) { - len = ((Object *) uin->d)->dictGetLength(); - if (i > 0 && i <= len) { - uout = new_Object_userdata(L); - uout->d = new Object(); - *((Object *) uout->d) = ((Object *) uin->d)->dictGetVal(i - 1); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_dictGetValNF(lua_State * L) -{ - int i, len; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - if (((Object *) uin->d)->isDict()) { - len = ((Object *) uin->d)->dictGetLength(); - if (i > 0 && i <= len) { - uout = new_Object_userdata(L); - uout->d = new Object(); - *((Object *) uout->d) = ((Object *) uin->d)->dictGetValNF(i - 1); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_streamIs(lua_State * L) -{ - const char *s; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - s = luaL_checkstring(L, 2); - if (((Object *) uin->d)->isStream()) { - if (((Object *) uin->d)->streamIs(CHARP_CAST s)) - lua_pushboolean(L, 1); - else - lua_pushboolean(L, 0); - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_streamReset(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isStream()) - ((Object *) uin->d)->streamReset(); - return 0; -} - -static int m_Object_streamGetChar(lua_State * L) -{ - int i; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isStream()) { - i = ((Object *) uin->d)->streamGetChar(); - lua_pushinteger(L, i); - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_streamLookChar(lua_State * L) -{ - int i; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isStream()) { - i = ((Object *) uin->d)->streamLookChar(); - lua_pushinteger(L, i); - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_streamGetPos(lua_State * L) -{ - int i; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isStream()) { - i = (int) ((Object *) uin->d)->streamGetPos(); - lua_pushinteger(L, i); - } else - lua_pushnil(L); - return 1; -} - -static int m_Object_streamSetPos(lua_State * L) -{ - int i; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - if (((Object *) uin->d)->isStream()) - ((Object *) uin->d)->streamSetPos(i); - return 0; -} - -static int m_Object_streamGetDict(lua_State * L) -{ - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((Object *) uin->d)->isStream()) { - uout = new_Dict_userdata(L); - uout->d = ((Object *) uin->d)->streamGetDict(); - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -static int m_Object__gc(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); -#ifdef DEBUG - printf("\n===== Object GC ===== uin=<%p>\n", uin); -#endif - if (uin->atype == ALLOC_LEPDF) { - // free() seems to collide with the lua gc - //((Object *) uin->d)->free(); - delete(Object *) uin->d; - } - return 0; -} - -m_poppler__tostring(Object); - -static const struct luaL_Reg Object_m[] = { - {"initBool", m_Object_initBool}, - {"initInt", m_Object_initInt}, - {"initReal", m_Object_initReal}, - {"initString", m_Object_initString}, - {"initName", m_Object_initName}, - {"initNull", m_Object_initNull}, - {"initArray", m_Object_initArray}, - {"initDict", m_Object_initDict}, - {"initStream", m_Object_initStream}, - {"initRef", m_Object_initRef}, - {"initCmd", m_Object_initCmd}, - {"initError", m_Object_initError}, - {"initEOF", m_Object_initEOF}, - // {"copy", m_Object_copy}, - {"fetch", m_Object_fetch}, - {"getType", m_Object_getType}, - {"getTypeName", m_Object_getTypeName}, - {"isBool", m_Object_isBool}, - {"isInt", m_Object_isInt}, - {"isReal", m_Object_isReal}, - {"isNum", m_Object_isNum}, - {"isString", m_Object_isString}, - {"isName", m_Object_isName}, - {"isNull", m_Object_isNull}, - {"isArray", m_Object_isArray}, - {"isDict", m_Object_isDict}, - {"isStream", m_Object_isStream}, - {"isRef", m_Object_isRef}, - {"isCmd", m_Object_isCmd}, - {"isError", m_Object_isError}, - {"isEOF", m_Object_isEOF}, - {"isNone", m_Object_isNone}, - {"getBool", m_Object_getBool}, - {"getInt", m_Object_getInt}, - {"getReal", m_Object_getReal}, - {"getNum", m_Object_getNum}, - {"getString", m_Object_getString}, - {"getName", m_Object_getName}, - {"getArray", m_Object_getArray}, - {"getDict", m_Object_getDict}, - {"getStream", m_Object_getStream}, - {"getRef", m_Object_getRef}, - {"getRefNum", m_Object_getRefNum}, - {"getRefGen", m_Object_getRefGen}, - {"getCmd", m_Object_getCmd}, - {"arrayGetLength", m_Object_arrayGetLength}, - {"arrayAdd", m_Object_arrayAdd}, - {"arrayGet", m_Object_arrayGet}, - {"arrayGetNF", m_Object_arrayGetNF}, - {"dictGetLength", m_Object_dictGetLength}, - {"dictAdd", m_Object_dictAdd}, - {"dictSet", m_Object_dictSet}, - {"dictLookup", m_Object_dictLookup}, - {"dictLookupNF", m_Object_dictLookupNF}, - {"dictGetKey", m_Object_dictGetKey}, - {"dictGetVal", m_Object_dictGetVal}, - {"dictGetValNF", m_Object_dictGetValNF}, - {"streamIs", m_Object_streamIs}, - {"streamReset", m_Object_streamReset}, - // {"streamClose", m_Object_streamClose}, - {"streamGetChar", m_Object_streamGetChar}, - {"streamLookChar", m_Object_streamLookChar}, - // {"streamGetLine", m_Object_streamGetLine}, - {"streamGetPos", m_Object_streamGetPos}, - {"streamSetPos", m_Object_streamSetPos}, - {"streamGetDict", m_Object_streamGetDict}, - {"__tostring", m_Object__tostring}, - {"__gc", m_Object__gc}, // finalizer - {NULL, NULL} // sentinel -}; - -//********************************************************************** -// Page - -m_poppler_get_BOOL(Page, isOk); -m_poppler_get_INT(Page, getNum); -m_poppler_get_poppler(Page, PDFRectangle, getMediaBox); -m_poppler_get_poppler(Page, PDFRectangle, getCropBox); -m_poppler_get_BOOL(Page, isCropped); -m_poppler_get_DOUBLE(Page, getMediaWidth); -m_poppler_get_DOUBLE(Page, getMediaHeight); -m_poppler_get_DOUBLE(Page, getCropWidth); -m_poppler_get_DOUBLE(Page, getCropHeight); -m_poppler_get_poppler(Page, PDFRectangle, getBleedBox); -m_poppler_get_poppler(Page, PDFRectangle, getTrimBox); -m_poppler_get_poppler(Page, PDFRectangle, getArtBox); -m_poppler_get_INT(Page, getRotate); -m_poppler_get_GOOSTRING(Page, getLastModified); -m_poppler_get_poppler(Page, Dict, getBoxColorInfo); -m_poppler_get_poppler(Page, Dict, getGroup); -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, getAnnotsObject); - -m_poppler_get_OBJECT(Page, getContents); - -m_poppler__tostring(Page); - -static const struct luaL_Reg Page_m[] = { - {"isOk", m_Page_isOk}, - {"getNum", m_Page_getNum}, - {"getMediaBox", m_Page_getMediaBox}, - {"getCropBox", m_Page_getCropBox}, - {"isCropped", m_Page_isCropped}, - {"getMediaWidth", m_Page_getMediaWidth}, - {"getMediaHeight", m_Page_getMediaHeight}, - {"getCropWidth", m_Page_getCropWidth}, - {"getCropHeight", m_Page_getCropHeight}, - {"getBleedBox", m_Page_getBleedBox}, - {"getTrimBox", m_Page_getTrimBox}, - {"getArtBox", m_Page_getArtBox}, - {"getRotate", m_Page_getRotate}, - {"getLastModified", m_Page_getLastModified}, - {"getBoxColorInfo", m_Page_getBoxColorInfo}, - {"getGroup", m_Page_getGroup}, - {"getMetadata", m_Page_getMetadata}, - {"getPieceInfo", m_Page_getPieceInfo}, - {"getSeparationInfo", m_Page_getSeparationInfo}, - {"getResourceDict", m_Page_getResourceDict}, - {"getAnnotsObject", m_Page_getAnnotsObject}, - {"getContents", m_Page_getContents}, - {"__tostring", m_Page__tostring}, - {NULL, NULL} // sentinel -}; - -//********************************************************************** -// PDFDoc - -#define m_PDFDoc_BOOL(function) \ -static int m_PDFDoc_##function(lua_State * L) \ -{ \ - udstruct *uin; \ - uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); \ - if (uin->pd != NULL && uin->pd->pc != uin->pc) \ - pdfdoc_changed_error(L); \ - if (((PdfDocument *) uin->d)->doc->function()) \ - lua_pushboolean(L, 1); \ - else \ - lua_pushboolean(L, 0); \ - return 1; \ -} - -#define m_PDFDoc_INT(function) \ -static int m_PDFDoc_##function(lua_State * L) \ -{ \ - int i; \ - udstruct *uin; \ - uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); \ - if (uin->pd != NULL && uin->pd->pc != uin->pc) \ - pdfdoc_changed_error(L); \ - i = ((PdfDocument *) uin->d)->doc->function(); \ - lua_pushinteger(L, i); \ - return 1; \ -} - -m_PDFDoc_BOOL(isOk); -m_PDFDoc_INT(getErrorCode); - -static int m_PDFDoc_getFileName(lua_State * L) -{ - GooString *gs; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - gs = ((PdfDocument *) uin->d)->doc->getFileName(); - if (gs != NULL) - lua_pushlstring(L, gs->getCString(), gs->getLength()); - else - lua_pushnil(L); - return 1; -} - -static int m_PDFDoc_getErrorCodeName(lua_State * L) -{ - int i; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = ((PdfDocument *) uin->d)->doc->getErrorCode(); - lua_pushstring(L, ErrorCodeNames[i]); - return 1; -} - -static int m_PDFDoc_getXRef(lua_State * L) -{ - XRef *xref; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - xref = ((PdfDocument *) uin->d)->doc->getXRef(); - if (xref->isOk()) { - uout = new_XRef_userdata(L); - uout->d = xref; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -static int m_PDFDoc_getCatalog(lua_State * L) -{ - Catalog *cat; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - cat = ((PdfDocument *) uin->d)->doc->getCatalog(); - if (cat->isOk()) { - uout = new_Catalog_userdata(L); - uout->d = cat; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -#define m_PDFDoc_PAGEDIMEN(function) \ -static int m_PDFDoc_##function(lua_State * L) \ -{ \ - int i, pages; \ - double d; \ - udstruct *uin; \ - uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); \ - if (uin->pd != NULL && uin->pd->pc != uin->pc) \ - pdfdoc_changed_error(L); \ - i = luaL_checkint(L, 2); \ - pages = ((PdfDocument *) uin->d)->doc->getNumPages(); \ - if (i > 0 && i <= pages) { \ - d = (double) ((PdfDocument *) uin->d)->doc->function(i); \ - lua_pushnumber(L, d); /* float */ \ - } else \ - lua_pushnil(L); \ - return 1; \ -} - -m_PDFDoc_PAGEDIMEN(getPageMediaWidth); -m_PDFDoc_PAGEDIMEN(getPageMediaHeight); -m_PDFDoc_PAGEDIMEN(getPageCropWidth); -m_PDFDoc_PAGEDIMEN(getPageCropHeight); -m_PDFDoc_INT(getNumPages); - -static int m_PDFDoc_readMetadata(lua_State * L) -{ - GooString *gs; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((PdfDocument *) uin->d)->doc->getCatalog()->isOk()) { - gs = ((PdfDocument *) uin->d)->doc->readMetadata(); - if (gs != NULL) - lua_pushlstring(L, gs->getCString(), gs->getLength()); - else - lua_pushnil(L); - } else - lua_pushnil(L); - return 1; -} - -static int m_PDFDoc_getStructTreeRoot(lua_State * L) -{ - StructTreeRoot *obj; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((PdfDocument *) uin->d)->doc->getCatalog()->isOk()) { - obj = ((PdfDocument *) uin->d)->doc->getStructTreeRoot(); - uout = new_StructTreeRoot_userdata(L); - uout->d = obj; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -static int m_PDFDoc_findPage(lua_State * L) -{ - int num, gen, i; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - num = luaL_checkint(L, 2); - gen = luaL_checkint(L, 3); - if (((PdfDocument *) uin->d)->doc->getCatalog()->isOk()) { - i = ((PdfDocument *) uin->d)->doc->findPage(num, gen); - if (i > 0) - lua_pushinteger(L, i); - else - lua_pushnil(L); - } else - lua_pushnil(L); - return 1; -} - -static int m_PDFDoc_getLinks(lua_State * L) -{ - int i, pages; - Links *links; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = luaL_checkint(L, 2); - pages = ((PdfDocument *) uin->d)->doc->getNumPages(); - if (i > 0 && i <= pages) { - links = ((PdfDocument *) uin->d)->doc->getLinks(i); - if (links != NULL) { - uout = new_Links_userdata(L); - uout->d = links; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - } else - lua_pushnil(L); - return 1; -} - -static int m_PDFDoc_findDest(lua_State * L) -{ - GooString *name; - LinkDest *dest; - const char *s; - size_t len; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - s = luaL_checklstring(L, 2, &len); - name = new GooString(s, len); - if (((PdfDocument *) uin->d)->doc->getCatalog()->isOk()) { - dest = ((PdfDocument *) uin->d)->doc->findDest(name); - if (dest != NULL) { - uout = new_LinkDest_userdata(L); - uout->d = dest; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - } else - lua_pushnil(L); - delete name; - return 1; -} - -m_PDFDoc_BOOL(isEncrypted); -m_PDFDoc_BOOL(okToPrint); -m_PDFDoc_BOOL(okToChange); -m_PDFDoc_BOOL(okToCopy); -m_PDFDoc_BOOL(okToAddNotes); -m_PDFDoc_BOOL(isLinearized); - -static int m_PDFDoc_getDocInfo(lua_State * L) -{ - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((PdfDocument *) uin->d)->doc->getXRef()->isOk()) { - uout = new_Object_userdata(L); - uout->d = new Object(); - *((Object *) uout->d) = ((PdfDocument *) uin->d)->doc->getDocInfo(); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -static int m_PDFDoc_getDocInfoNF(lua_State * L) -{ - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - if (((PdfDocument *) uin->d)->doc->getXRef()->isOk()) { - uout = new_Object_userdata(L); - uout->d = new Object(); - *((Object *) uout->d) = ((PdfDocument *) uin->d)->doc->getDocInfoNF(); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -m_PDFDoc_INT(getPDFMajorVersion); -m_PDFDoc_INT(getPDFMinorVersion); - -m_poppler__tostring(PDFDoc); - -static int m_PDFDoc__gc(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); -#ifdef DEBUG - printf("\n===== PDFDoc GC ===== file_path=<%s>\n", - ((PdfDocument *) uin->d)->file_path); -#endif - assert(uin->atype == ALLOC_LEPDF); - unrefPdfDocument(((PdfDocument *) uin->d)->file_path); - return 0; -} - -static const struct luaL_Reg PDFDoc_m[] = { - {"isOk", m_PDFDoc_isOk}, - {"getErrorCode", m_PDFDoc_getErrorCode}, - {"getErrorCodeName", m_PDFDoc_getErrorCodeName}, // not poppler - {"getFileName", m_PDFDoc_getFileName}, - {"getXRef", m_PDFDoc_getXRef}, - {"getCatalog", m_PDFDoc_getCatalog}, - // {"getBaseStream", m_PDFDoc_getBaseStream}, - {"getPageMediaWidth", m_PDFDoc_getPageMediaWidth}, - {"getPageMediaHeight", m_PDFDoc_getPageMediaHeight}, - {"getPageCropWidth", m_PDFDoc_getPageCropWidth}, - {"getPageCropHeight", m_PDFDoc_getPageCropHeight}, - {"getNumPages", m_PDFDoc_getNumPages}, - {"readMetadata", m_PDFDoc_readMetadata}, - {"getStructTreeRoot", m_PDFDoc_getStructTreeRoot}, - {"findPage", m_PDFDoc_findPage}, - {"getLinks", m_PDFDoc_getLinks}, - {"findDest", m_PDFDoc_findDest}, - {"isEncrypted", m_PDFDoc_isEncrypted}, - {"okToPrint", m_PDFDoc_okToPrint}, - {"okToChange", m_PDFDoc_okToChange}, - {"okToCopy", m_PDFDoc_okToCopy}, - {"okToAddNotes", m_PDFDoc_okToAddNotes}, - {"isLinearized", m_PDFDoc_isLinearized}, - {"getDocInfo", m_PDFDoc_getDocInfo}, - {"getDocInfoNF", m_PDFDoc_getDocInfoNF}, - {"getPDFMajorVersion", m_PDFDoc_getPDFMajorVersion}, - {"getPDFMinorVersion", m_PDFDoc_getPDFMinorVersion}, - {"__tostring", m_PDFDoc__tostring}, - {"__gc", m_PDFDoc__gc}, // finalizer - {NULL, NULL} // sentinel -}; - -//********************************************************************** -// PDFRectangle - -m_poppler_get_BOOL(PDFRectangle, isValid); - -m_poppler__tostring(PDFRectangle); - -static int m_PDFRectangle__index(lua_State * L) -{ - const char *s; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_PDFRectangle); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - s = luaL_checkstring(L, 2); - if (strlen(s) == 2) { - if (s[0] == 'x') { - if (s[1] == '1') - lua_pushnumber(L, ((PDFRectangle *) uin->d)->x1); /* float */ - else if (s[1] == '2') - lua_pushnumber(L, ((PDFRectangle *) uin->d)->x2); /* float */ - else - lua_pushnil(L); - } else if (s[0] == 'y') { - if (s[1] == '1') - lua_pushnumber(L, ((PDFRectangle *) uin->d)->y1); /* float */ - else if (s[1] == '2') - lua_pushnumber(L, ((PDFRectangle *) uin->d)->y2); /* float */ - else - lua_pushnil(L); - } else - lua_pushnil(L); - } else - lua_pushnil(L); - return 1; -} - -static int m_PDFRectangle__newindex(lua_State * L) -{ - double d; - const char *s; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_PDFRectangle); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - s = luaL_checkstring(L, 2); - d = luaL_checknumber(L, 3); - if (strlen(s) == 2) { - if (s[0] == 'x') { - if (s[1] == '1') - ((PDFRectangle *) uin->d)->x1 = d; - else if (s[1] == '2') - ((PDFRectangle *) uin->d)->x2 = d; - else - luaL_error(L, "wrong PDFRectangle coordinate (%s)", s); - } else if (s[0] == 'y') { - if (s[1] == '1') - ((PDFRectangle *) uin->d)->y1 = d; - else if (s[1] == '2') - ((PDFRectangle *) uin->d)->y2 = d; - } else - luaL_error(L, "wrong PDFRectangle coordinate (%s)", s); - } else - luaL_error(L, "wrong PDFRectangle coordinate (%s)", s); - return 0; -} - -static int m_PDFRectangle__gc(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_PDFRectangle); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); -#ifdef DEBUG - printf("\n===== PDFRectangle GC ===== uin=<%p>\n", uin); -#endif - if (uin->atype == ALLOC_LEPDF) - delete(PDFRectangle *) uin->d; - return 0; -} - -static const struct luaL_Reg PDFRectangle_m[] = { - {"isValid", m_PDFRectangle_isValid}, - {"__index", m_PDFRectangle__index}, - {"__newindex", m_PDFRectangle__newindex}, - {"__tostring", m_PDFRectangle__tostring}, - {"__gc", m_PDFRectangle__gc}, - {NULL, NULL} // sentinel -}; - -//********************************************************************** -// Ref - -static int m_Ref__index(lua_State * L) -{ - const char *s; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Ref); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - s = luaL_checkstring(L, 2); - if (strcmp(s, "num") == 0) - lua_pushinteger(L, ((Ref *) uin->d)->num); - else if (strcmp(s, "gen") == 0) - lua_pushinteger(L, ((Ref *) uin->d)->gen); - else - lua_pushnil(L); - return 1; -} - -m_poppler__tostring(Ref); - -static int m_Ref__gc(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Ref); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); -#ifdef DEBUG - printf("\n===== Ref GC ===== uin=<%p>\n", uin); -#endif - if (uin->atype == ALLOC_LEPDF && ((Ref *) uin->d) != NULL) - gfree(((Ref *) uin->d)); - return 0; -} - -static const struct luaL_Reg Ref_m[] = { - {"__index", m_Ref__index}, - {"__tostring", m_Ref__tostring}, - {"__gc", m_Ref__gc}, // finalizer - {NULL, NULL} // sentinel -}; - -//********************************************************************** -// Stream - -static const char *StreamKindNames[] = - { "File", "ASCIIHex", "ASCII85", "LZW", "RunLength", "CCITTFax", "DCT", - "Flate", "JBIG2", "JPX", "Weird", NULL -}; - -m_poppler_get_INT(Stream, getKind); - -static int m_Stream_getKindName(lua_State * L) -{ - StreamKind t; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Stream); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - t = ((Stream *) uin->d)->getKind(); - lua_pushstring(L, StreamKindNames[t]); - return 1; -} - -m_poppler_do(Stream, reset); -m_poppler_do(Stream, close); -m_poppler_get_INT(Stream, getChar); -m_poppler_get_INT(Stream, lookChar); -m_poppler_get_INT(Stream, getRawChar); -m_poppler_get_INT(Stream, getUnfilteredChar); -m_poppler_do(Stream, unfilteredReset); -m_poppler_get_INT(Stream, getPos); -m_poppler_get_BOOL(Stream, isBinary); -m_poppler_get_poppler(Stream, Stream, getUndecodedStream); -m_poppler_get_poppler(Stream, Dict, getDict); - -m_poppler__tostring(Stream); - -static const struct luaL_Reg Stream_m[] = { - {"getKind", m_Stream_getKind}, - {"getKindName", m_Stream_getKindName}, // not poppler - {"reset", m_Stream_reset}, - {"close", m_Stream_close}, - {"getUndecodedStream", m_Stream_getUndecodedStream}, - {"getChar", m_Stream_getChar}, - {"lookChar", m_Stream_lookChar}, - {"getRawChar", m_Stream_getRawChar}, - {"getUnfilteredChar", m_Stream_getUnfilteredChar}, - {"unfilteredReset", m_Stream_unfilteredReset}, - // {"getLine", m_Stream_getLine}, - {"getPos", m_Stream_getPos}, - {"isBinary", m_Stream_isBinary}, - {"getUndecodedStream", m_Stream_getUndecodedStream}, - {"getDict", m_Stream_getDict}, - {"__tostring", m_Stream__tostring}, - {NULL, NULL} // sentinel -}; - -//********************************************************************** -// TextSpan - -m_poppler_get_GOOSTRING(TextSpan, getText); -m_poppler__tostring(TextSpan); - -static const struct luaL_Reg TextSpan_m[] = { - {"getText", m_TextSpan_getText}, - {"__tostring", m_TextSpan__tostring}, - {NULL, NULL} // sentinel -}; - - - - -//********************************************************************** -// Attribute -m_poppler_get_BOOL(Attribute,isOk); -m_poppler_get_INT(Attribute,getType); -m_poppler_get_INT(Attribute,getOwner); -m_poppler_get_GOOSTRING(Attribute,getName); - -static int m_Attribute_getTypeName(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Attribute); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - lua_pushstring(L, ((Attribute *) uin->d)->getTypeName()); - return 1; -} - -static int m_Attribute_getOwnerName(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Attribute); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - lua_pushstring(L, ((Attribute *) uin->d)->getOwnerName()); - return 1; -} - -static int m_Attribute_getValue(lua_State * L) -{ - udstruct *uin, *uout; - Object *origin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Attribute); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - uout = new_Object_userdata(L); - uout->d = new Object(); - origin = (Object *) (((Attribute *) uin->d)->getValue()); - *((Object *) uout->d) = origin->copy(); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - return 1; -} - - -static int m_Attribute_getDefaultValue(lua_State * L) -{ - Attribute::Type t; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_Attribute); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - t = (Attribute::Type) luaL_checkint(L, 2); - uout = new_Object_userdata(L); - uout->d = ((Attribute *)uin->d)->getDefaultValue(t) ; - //uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - return 1; -} - - -m_poppler_get_GUINT(Attribute,getRevision); - -static int m_Attribute_setRevision(lua_State * L) -{ - Guint i; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Attribute); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = (Guint) luaL_checkint(L, 2); - ((Attribute *) uin->d)->setRevision(i); - return 0; -} - -m_poppler_get_BOOL(Attribute, isHidden); - -static int m_Attribute_setHidden(lua_State * L) -{ - GBool i; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Attribute); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = (GBool) lua_toboolean(L, 2); - ((Attribute *) uin->d)->setHidden(i); - return 0; -} - -static int m_Attribute_getFormattedValue(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Attribute); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - lua_pushstring(L, ((Attribute *) uin->d)->getFormattedValue()); - return 1; -} - - -static int m_Attribute_setFormattedValue(lua_State * L) -{ - const char *c; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Attribute); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - c = luaL_checkstring(L, 2); - ((Attribute *) uin->d)->setFormattedValue(c); - return 0; -} - -static int m_Attribute__gc(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_Attribute); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); -#ifdef DEBUG - printf("\n===== Attribute GC ===== uin=<%p>\n", uin); -#endif - if (uin->atype == ALLOC_LEPDF) { - delete(Attribute *) uin->d; - } - return 0; -} - - -m_poppler__tostring(Attribute); - - -static const struct luaL_Reg Attribute_m[] = { - {"isOk",m_Attribute_isOk}, - {"getType",m_Attribute_getType}, - {"getOwner",m_Attribute_getOwner}, - {"getTypeName",m_Attribute_getTypeName}, - {"getOwnerName",m_Attribute_getOwnerName}, - {"getValue",m_Attribute_getValue}, - {"getDefaultValue",m_Attribute_getDefaultValue}, - {"getName",m_Attribute_getName}, - {"getRevision",m_Attribute_getRevision}, - {"setRevision",m_Attribute_setRevision}, - {"istHidden",m_Attribute_isHidden}, - {"setHidden",m_Attribute_setHidden}, - {"getFormattedValue",m_Attribute_getFormattedValue}, - {"setFormattedValue",m_Attribute_setFormattedValue}, - {"__gc", m_Attribute__gc}, - {"__tostring", m_Attribute__tostring}, - {NULL, NULL} // sentinel -}; - - - - -//********************************************************************** -// StructElement - - -m_poppler_get_INT(StructElement,getType); -m_poppler_get_BOOL(StructElement,isOk); -m_poppler_get_BOOL(StructElement,isBlock); -m_poppler_get_BOOL(StructElement,isInline); -m_poppler_get_BOOL(StructElement,isGrouping); -m_poppler_get_BOOL(StructElement,isContent); -m_poppler_get_BOOL(StructElement,isObjectRef); -m_poppler_get_BOOL(StructElement,hasPageRef); -m_poppler_get_INT(StructElement,getMCID); -m_poppler_get_INT(StructElement, getNumChildren); - -m_poppler_get_GUINT(StructElement,getRevision); -m_poppler_get_UINT(StructElement,getNumAttributes); - -m_poppler_get_GOOSTRING(StructElement, getID); -m_poppler_get_GOOSTRING(StructElement, getLanguage); -m_poppler_get_GOOSTRING(StructElement, getTitle); -m_poppler_get_GOOSTRING(StructElement, getExpandedAbbr); -m_poppler_get_GOOSTRING(StructElement, getAltText); -m_poppler_get_GOOSTRING(StructElement, getActualText); - -m_poppler_get_poppler(StructElement, StructTreeRoot, getStructTreeRoot); -m_poppler__tostring(StructElement); - - -static int m_StructElement_getObjectRef(lua_State * L) -{ - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - uout = new_Ref_userdata(L); - uout->d = (Ref *) gmalloc(sizeof(Ref)); - ((Ref *) uout->d)->num = ((StructElement *) uin->d)->getObjectRef().num; - ((Ref *) uout->d)->gen = ((StructElement *) uin->d)->getObjectRef().gen; - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - return 1; -} - - -static int m_StructElement_getParentRef(lua_State * L) -{ - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - uout = new_Ref_userdata(L); - uout->d = (Ref *) gmalloc(sizeof(Ref)); - ((Ref *) uout->d)->num = ((StructElement *) uin->d)->getParentRef().num; - ((Ref *) uout->d)->gen = ((StructElement *) uin->d)->getParentRef().gen; - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - return 1; -} - -// Not exactly as the header: -// Ref = StructElement:getPageRef() -// Ref is false if the C++ functione return false -static int m_StructElement_getPageRef(lua_State * L) -{ - GBool b; - Ref *r; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - r = (Ref *) gmalloc(sizeof(Ref)); - b = ((StructElement *) uin->d)->getPageRef( *r ); - if (b) { - uout = new_Ref_userdata(L); - uout->d = r ; - //uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushboolean(L,0); - return 1; -} - - - -static int m_StructElement_getTypeName(lua_State * L) -{ - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - lua_pushstring(L, ((StructElement *) uin->d)->getTypeName()); - return 1; -} - - -static int m_StructElement_setRevision(lua_State * L) -{ - Guint i; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = (Guint) luaL_checkint(L, 2); - ((StructElement *) uin->d)->setRevision(i); - return 0; -} - -static int m_StructElement_getText(lua_State * L) -{ - GBool i; - GooString *gs; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = (GBool) lua_toboolean(L, 2); - gs = ((StructElement *) uin->d)->getText(i); - if (gs != NULL) - lua_pushlstring(L, gs->getCString(), gs->getLength()); - else - lua_pushnil(L); - return 1; -} - - -static int m_StructElement_getChild(lua_State * L) -{ - StructElement *c; - int i; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = (int) luaL_checkint(L, 2); - c = ((StructElement *) uin->d)->getChild(i-1); - if (c != NULL) { - uout = new_StructElement_userdata(L); - uout->d = c ; - //uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - } - else - lua_pushnil(L); - return 1; -} - - -static int m_StructElement_appendChild(lua_State * L) -{ - udstruct *uin, *uin1; - uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - uin1 = (udstruct *) luaL_checkudata(L, 2, M_StructElement); - if (uin1->pd != NULL && uin1->pd->pc != uin1->pc) - pdfdoc_changed_error(L); - ((StructElement *) uin->d)->appendChild( (StructElement *)uin1->d ); - return 0; -} - - -static int m_StructElement_getAttribute(lua_State * L) -{ - Attribute *a; - int i; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = (int) luaL_checkint(L, 2); - a = ((StructElement *) uin->d)->getAttribute(i-1); - if (a != NULL) { - uout = new_Attribute_userdata(L); - uout->d = a ; - uout->pc = uin->pc; - uout->pd = uin->pd; - } - else - lua_pushnil(L); - return 1; -} - - - -static int m_StructElement_appendAttribute(lua_State * L) -{ - - udstruct *uin, *uin1; - uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - uin1 = (udstruct *) luaL_checkudata(L, 2, M_Attribute); - if (uin1->pd != NULL && uin1->pd->pc != uin1->pc) - pdfdoc_changed_error(L); - ((StructElement *) uin->d)->appendAttribute( (Attribute *)uin1->d ); - return 0; -} - - -static int m_StructElement_findAttribute(lua_State * L) -{ - Attribute::Type t; - Attribute::Owner o; - GBool g; - udstruct *uin, *uout; - const Attribute *a; - uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - t = (Attribute::Type) luaL_checkint(L,1); - o = (Attribute::Owner) luaL_checkint(L,2); - g = (GBool) lua_toboolean(L, 3); - a = ((StructElement *) uin->d)->findAttribute(t,g,o); - - if (a!=NULL){ - uout = new_Attribute_userdata(L); - uout->d = new Attribute(a->getType(),a->getValue()); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -// This returns a lua table -static int m_StructElement_getTextSpans(lua_State * L) -{ - int i ; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - - if ((((StructElement *) uin->d)->getTextSpans()).size()>0) { - lua_createtable (L, - (int) (((StructElement *) uin->d)->getTextSpans()).size(), - 0); - for(i=0;i<(int) (((StructElement *) uin->d)->getTextSpans()).size(); i++){ - uout = new_TextSpan_userdata(L); - uout->d = new TextSpan( (((StructElement *) uin->d)->getTextSpans())[i] ); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - lua_rawseti(L,-2,i+1); - } - } else - lua_pushnil(L); - return 1; -} - - - -static const struct luaL_Reg StructElement_m[] = { - {"getTypeName", m_StructElement_getTypeName}, - {"getType",m_StructElement_getType}, - {"isOk",m_StructElement_isOk}, - {"isBlock",m_StructElement_isBlock}, - {"isInline",m_StructElement_isInline}, - {"isGrouping",m_StructElement_isGrouping}, - {"isContent",m_StructElement_isContent}, - {"isObjectRef",m_StructElement_isObjectRef}, - {"getMCID",m_StructElement_getMCID}, - {"getObjectRef",m_StructElement_getObjectRef}, - {"getParentRef",m_StructElement_getParentRef}, - {"hasPageRef",m_StructElement_hasPageRef}, - {"getPageRef",m_StructElement_getPageRef}, - {"getStructTreeRoot",m_StructElement_getStructTreeRoot}, - {"getID",m_StructElement_getID}, - {"getLanguage",m_StructElement_getLanguage}, - {"getRevision",m_StructElement_getRevision}, - {"setRevision",m_StructElement_setRevision}, - {"getTitle",m_StructElement_getTitle}, - {"getExpandedAbbr",m_StructElement_getExpandedAbbr}, - {"getNumChildren",m_StructElement_getNumChildren}, - {"getChild",m_StructElement_getChild}, - {"appendChild",m_StructElement_appendChild}, - {"getNumAttributes",m_StructElement_getNumAttributes}, - {"getAttribute",m_StructElement_getAttribute}, - {"appendAttribute",m_StructElement_appendAttribute}, - {"findAttribute",m_StructElement_findAttribute}, - {"getAltText",m_StructElement_getAltText}, - {"getActualText",m_StructElement_getActualText}, - {"getText",m_StructElement_getText}, - {"getTextSpans",m_StructElement_getTextSpans}, - {"__tostring", m_StructElement__tostring}, - {NULL, NULL} // sentinel -}; - - -//********************************************************************** -// StructTreeRoot - -m_poppler_get_INT(StructTreeRoot, getNumChildren); -m_poppler_get_poppler(StructTreeRoot, PDFDoc, getDoc); -m_poppler_get_poppler(StructTreeRoot, Dict, getRoleMap); -m_poppler_get_poppler(StructTreeRoot, Dict, getClassMap); -m_poppler__tostring(StructTreeRoot); - -static int m_StructTreeRoot_getChild(lua_State * L) -{ - unsigned int i; - udstruct *uin, *uout; - StructElement *child ; - StructTreeRoot *root ; - - uin = (udstruct *) luaL_checkudata(L, 1, M_StructTreeRoot); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = (unsigned) luaL_checkint(L, 2); - root = (StructTreeRoot *) uin->d; - if (i-1 < root->getNumChildren() ){ - child = root->getChild(i-1); - uout = new_StructElement_userdata(L); - uout->d = child; - //uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - } else - lua_pushnil(L); - return 1; -} - -static int m_StructTreeRoot_appendChild(lua_State * L) -{ - udstruct *uin, *uin_child; - StructElement *child ; - StructTreeRoot *root ; - uin = (udstruct *) luaL_checkudata(L, 1, M_StructTreeRoot); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - uin_child = (udstruct *) luaL_checkudata(L, 2, M_StructElement); - if (uin_child->pd != NULL && uin_child->pd->pc != uin_child->pc) - pdfdoc_changed_error(L); - root = (StructTreeRoot *) uin->d; - child = (StructElement *) uin_child->d; - root->appendChild(child); - return 0; -} - - -static int m_StructTreeRoot_findParentElement(lua_State * L) -{ - unsigned int i; - udstruct *uin, *uout; - const StructElement *parent ; - StructTreeRoot *root ; - - uin = (udstruct *) luaL_checkudata(L, 1, M_StructTreeRoot); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - i = (unsigned) luaL_checkint(L, 2); - root = (StructTreeRoot *) uin->d; - parent = root->findParentElement(i-1); - if (parent != NULL) { - uout = new_StructElement_userdata(L); - // 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; - } else - lua_pushnil(L); - return 1; -} - - -static const struct luaL_Reg StructTreeRoot_m[] = { - {"getDoc",m_StructTreeRoot_getDoc}, - {"getRoleMap",m_StructTreeRoot_getRoleMap}, - {"getClassMap",m_StructTreeRoot_getClassMap}, - {"getNumChildren",m_StructTreeRoot_getNumChildren}, - {"getChild",m_StructTreeRoot_getChild}, - {"appendChild",m_StructTreeRoot_appendChild}, - {"findParentElement",m_StructTreeRoot_findParentElement}, - {"__tostring", m_StructTreeRoot__tostring}, - {NULL, NULL} // sentinel -}; - -//********************************************************************** -// XRef - -m_poppler_get_BOOL(XRef, isOk); -m_poppler_get_INT(XRef, getErrorCode); -m_poppler_get_BOOL(XRef, isEncrypted); -m_poppler_get_BOOL(XRef, okToPrint); -m_poppler_get_BOOL(XRef, okToPrintHighRes); -m_poppler_get_BOOL(XRef, okToChange); -m_poppler_get_BOOL(XRef, okToCopy); -m_poppler_get_BOOL(XRef, okToAddNotes); -m_poppler_get_BOOL(XRef, okToFillForm); -m_poppler_get_BOOL(XRef, okToAccessibility); -m_poppler_get_BOOL(XRef, okToAssemble); -m_poppler_get_OBJECT(XRef, getCatalog); - -static int m_XRef_fetch(lua_State * L) -{ - int num, gen; - udstruct *uin, *uout; - uin = (udstruct *) luaL_checkudata(L, 1, M_XRef); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - num = luaL_checkint(L, 2); - gen = luaL_checkint(L, 3); - uout = new_Object_userdata(L); - uout->d = new Object(); - *((Object *) uout->d) = ((XRef *) uin->d)->fetch(num, gen); - uout->atype = ALLOC_LEPDF; - uout->pc = uin->pc; - uout->pd = uin->pd; - return 1; -} - -m_poppler_get_OBJECT(XRef, getDocInfo); -m_poppler_get_OBJECT(XRef, getDocInfoNF); -m_poppler_get_INT(XRef, getNumObjects); -m_poppler_get_INT(XRef, getRootNum); -m_poppler_get_INT(XRef, getRootGen); -// getStreamEnd - -static int m_XRef_getNumEntry(lua_State * L) -{ - int i, offset; - udstruct *uin; - uin = (udstruct *) luaL_checkudata(L, 1, M_XRef); - if (uin->pd != NULL && uin->pd->pc != uin->pc) - pdfdoc_changed_error(L); - offset = luaL_checkint(L, 2); - i = ((XRef *) uin->d)->getNumEntry(offset); - if (i >= 0) - lua_pushinteger(L, i); - else - lua_pushnil(L); - return 1; -} - -m_poppler_get_poppler(XRef, Object, getTrailerDict); - -m_poppler__tostring(XRef); - -static const struct luaL_Reg XRef_m[] = { - {"isOk", m_XRef_isOk}, - {"getErrorCode", m_XRef_getErrorCode}, - {"isEncrypted", m_XRef_isEncrypted}, - {"okToPrint", m_XRef_okToPrint}, - {"okToPrintHighRes", m_XRef_okToPrintHighRes}, - {"okToChange", m_XRef_okToChange}, - {"okToCopy", m_XRef_okToCopy}, - {"okToAddNotes", m_XRef_okToAddNotes}, - {"okToFillForm", m_XRef_okToFillForm}, - {"okToAccessibility", m_XRef_okToAccessibility}, - {"okToAssemble", m_XRef_okToAssemble}, - {"getCatalog", m_XRef_getCatalog}, - {"fetch", m_XRef_fetch}, - {"getDocInfo", m_XRef_getDocInfo}, - {"getDocInfoNF", m_XRef_getDocInfoNF}, - {"getNumObjects", m_XRef_getNumObjects}, - {"getRootNum", m_XRef_getRootNum}, - {"getRootGen", m_XRef_getRootGen}, - // {"getStreamEnd", m_XRef_getStreamEnd}, - {"getNumEntry", m_XRef_getNumEntry}, - {"getTrailerDict", m_XRef_getTrailerDict}, - {"__tostring", m_XRef__tostring}, - {NULL, NULL} // sentinel -}; - -//********************************************************************** -// XRefEntry - -m_poppler__tostring(XRefEntry); - -static const struct luaL_Reg XRefEntry_m[] = { - {"__tostring", m_XRefEntry__tostring}, - {NULL, NULL} // sentinel -}; - -//********************************************************************** - -#ifdef LuajitTeX -#define setfuncs_meta(type) \ - luaL_newmetatable(L, M_##type); \ - lua_pushvalue(L, -1); \ - lua_setfield(L, -2, "__index"); \ - lua_pushstring(L, "no user access"); \ - lua_setfield(L, -2, "__metatable"); \ - luaL_openlib(L, NULL, type##_m, 0) -#else -#define setfuncs_meta(type) \ - luaL_newmetatable(L, M_##type); \ - lua_pushvalue(L, -1); \ - lua_setfield(L, -2, "__index"); \ - lua_pushstring(L, "no user access"); \ - lua_setfield(L, -2, "__metatable"); \ - luaL_setfuncs(L, type##_m, 0) -#endif - -int luaopen_epdf(lua_State * L) -{ - setfuncs_meta(Annot); - setfuncs_meta(Annots); - setfuncs_meta(Array); - setfuncs_meta(Catalog); - setfuncs_meta(Dict); - setfuncs_meta(EmbFile); - setfuncs_meta(FileSpec); - setfuncs_meta(GooString); - setfuncs_meta(LinkDest); - setfuncs_meta(Links); - setfuncs_meta(Object); - setfuncs_meta(Page); - setfuncs_meta(PDFDoc); - setfuncs_meta(PDFRectangle); - setfuncs_meta(Ref); - setfuncs_meta(Stream); - setfuncs_meta(Attribute); - setfuncs_meta(StructElement); - setfuncs_meta(StructTreeRoot); - setfuncs_meta(TextSpan); - setfuncs_meta(XRef); - setfuncs_meta(XRefEntry); - luaL_openlib(L, "epdf", epdflib_f, 0); - return 1; -} diff --git a/Build/source/texk/web2c/luatexdir/lua/lfontlib.c b/Build/source/texk/web2c/luatexdir/lua/lfontlib.c index a709e42c45c..2592ffba683 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lfontlib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lfontlib.c @@ -324,7 +324,9 @@ static int l_vf_char(lua_State * L) } mat_p = &(vsp->packet_stack[vsp->packet_stack_level]); w = char_width(lf, k); - mat_p->pos.h += round_xn_over_d(w, 1000 + ex_glyph, 1000); + if (ex_glyph != 0) + w = round_xn_over_d(w, 1000 + ex_glyph, 1000); + mat_p->pos.h += w; synch_pos_with_cur(static_pdf->posstruct, vsp->refpos, mat_p->pos); return 0; } @@ -416,11 +418,14 @@ static int l_vf_right(lua_State * L) { scaled i; vf_struct *vsp = static_pdf->vfstruct; + int ex_glyph = vsp->ex_glyph/1000; packet_stack_record *mat_p; if (!vsp->vflua) normal_error("vf", "vf.right() outside virtual font"); mat_p = &(vsp->packet_stack[vsp->packet_stack_level]); i = (scaled) luaL_checkinteger(L, 1); + if (ex_glyph != 0 && i != 0) /* new, experiment */ + i = round_xn_over_d(i, 1000 + ex_glyph, 1000); i = store_scaled_f(i, vsp->fs_f); mat_p->pos.h += i; synch_pos_with_cur(static_pdf->posstruct, vsp->refpos, mat_p->pos); @@ -431,11 +436,14 @@ static int l_vf_rule(lua_State * L) { scaledpos size; vf_struct *vsp = static_pdf->vfstruct; + int ex_glyph = vsp->ex_glyph/1000; packet_stack_record *mat_p; if (!vsp->vflua) normal_error("vf", "vf.rule() outside virtual font"); size.h = (scaled) luaL_checkinteger(L, 1); size.v = (scaled) luaL_checkinteger(L, 2); + if (ex_glyph != 0 && size.h > 0) /* new, experiment */ + size.h = round_xn_over_d(size.h, 1000 + ex_glyph, 1000); size.h = store_scaled_f(size.h, vsp->fs_f); size.v = store_scaled_f(size.v, vsp->fs_f); if (size.h > 0 && size.v > 0) @@ -460,6 +468,16 @@ static int l_vf_special(lua_State * L) return 0; } +static int l_vf_pdf(lua_State * L) +{ + vf_struct *vsp = static_pdf->vfstruct; + if (!vsp->vflua) + normal_error("vf", "vf.special() outside virtual font"); + luapdfprint(L); + pdf_out(static_pdf, '\n'); + return 0; +} + static const struct luaL_Reg vflib[] = { {"char", l_vf_char}, {"down", l_vf_down}, @@ -476,6 +494,7 @@ static const struct luaL_Reg vflib[] = { /* {"scale", l_vf_scale}, */ /* {"slot", l_vf_slot}, */ {"special", l_vf_special}, + {"pdf", l_vf_pdf}, {NULL, NULL} /* sentinel */ }; diff --git a/Build/source/texk/web2c/luatexdir/lua/limglib.c b/Build/source/texk/web2c/luatexdir/lua/limglib.c index f9d863eef13..ce2b4b7b538 100644 --- a/Build/source/texk/web2c/luatexdir/lua/limglib.c +++ b/Build/source/texk/web2c/luatexdir/lua/limglib.c @@ -24,7 +24,7 @@ #include "lua.h" #include "lauxlib.h" -#define img_types_max 7 +#define img_types_max 8 const char *img_types[] = { "none", @@ -243,6 +243,26 @@ static void write_image_or_node(lua_State * L, wrtype_e writetype) img_state(ad) = DICT_REFERED; } +static int write_image_object(lua_State * L, wrtype_e writetype) +{ + image *a, **aa; + image_dict *ad; + int num; + if (lua_gettop(L) != 2) + luaL_error(L, "%s expects two argument", wrtype_s[writetype]); + aa = (image **) luaL_checkudata(L, 1, TYPE_IMG); + a = *aa; + ad = img_dict(a); + + read_img(ad); + + /* setup_image(static_pdf, a, writetype); */ + num = (int) lua_tointeger(L, 2); + num = write_img_object(static_pdf, ad, num); + lua_pushinteger(L,num); + return 1; +} + static int l_write_image(lua_State * L) { write_image_or_node(L, WR_WRITE); @@ -260,6 +280,17 @@ static int l_immediatewrite_image(lua_State * L) return 1; } +static int l_immediatewrite_image_object(lua_State * L) +{ + check_o_mode(static_pdf, "img.immediatewriteobject", 1 << OMODE_PDF, true); + if (global_shipping_mode != NOT_SHIPPING) { + luaL_error(L, "img.immediatewriteobject can not be used with \\latelua"); + } else { + write_image_object(L, WR_IMMEDIATEWRITE); + } + return 1; +} + static int l_image_node(lua_State * L) { write_image_or_node(L, WR_NODE); @@ -273,7 +304,7 @@ static int l_image_keys(lua_State * L) static int l_image_types(lua_State * L) { - return lua_show_valid_list(L, img_types, img_types_max); + return lua_show_valid_list(L, img_types, 0, img_types_max); } static int l_image_boxes(lua_State * L) @@ -287,10 +318,13 @@ static const struct luaL_Reg imglib_f[] = { { "scan", l_scan_image }, { "write", l_write_image }, { "immediatewrite", l_immediatewrite_image }, + { "immediatewriteobject", l_immediatewrite_image_object }, { "node", l_image_node }, - { "keys", l_image_keys }, + { "fields", l_image_keys }, { "types", l_image_types }, { "boxes", l_image_boxes }, + /* for a while: */ + { "keys", l_image_keys }, { NULL, NULL } }; @@ -348,14 +382,10 @@ static int m_img_get(lua_State * L) } else { lua_pushstring(L, img_filename(d)); } - } else if (lua_key_eq(s,visiblefilename)) { - if (img_visiblefilename(d) == NULL || strlen(img_visiblefilename(d)) == 0) { - lua_pushnil(L); - } else { - lua_pushstring(L, img_visiblefilename(d)); - } } else if (lua_key_eq(s,keepopen)) { lua_pushboolean(L, img_keepopen(d)); + } else if (lua_key_eq(s,nolength)) { + lua_pushboolean(L, img_nolength(d)); } else if (lua_key_eq(s,filepath)) { if (img_filepath(d) == NULL || strlen(img_filepath(d)) == 0) { lua_pushnil(L); @@ -461,10 +491,28 @@ static int m_img_get(lua_State * L) if (img_type(d) != IMG_TYPE_PDFSTREAM || img_pdfstream_ptr(d) == NULL || img_pdfstream_stream(d) == NULL - || strlen(img_pdfstream_stream(d)) == 0) { + || img_pdfstream_size(d) == 0) { + lua_pushnil(L); + } else { + lua_pushlstring(L, img_pdfstream_stream(d), img_pdfstream_size(d)); + } + } else if (lua_key_eq(s,visiblefilename)) { + if (img_visiblefilename(d) == NULL || strlen(img_visiblefilename(d)) == 0) { + lua_pushnil(L); + } else { + lua_pushstring(L, img_visiblefilename(d)); + } + } else if (lua_key_eq(s,userpassword)) { + if (img_userpassword(d) == NULL || strlen(img_userpassword(d)) == 0) { + lua_pushnil(L); + } else { + lua_pushstring(L, img_userpassword(d)); + } + } else if (lua_key_eq(s,ownerpassword)) { + if (img_ownerpassword(d) == NULL || strlen(img_ownerpassword(d)) == 0) { lua_pushnil(L); } else { - lua_pushstring(L, img_pdfstream_stream(d)); + lua_pushstring(L, img_ownerpassword(d)); } } else if (lua_key_eq(s,ref_count)) { lua_pushinteger(L, img_luaref(d)); @@ -520,7 +568,7 @@ static void lua_to_image(lua_State * L, image * a, image_dict * d) if (img_state(d) >= DICT_FILESCANNED) { luaL_error(L, "image.filename is now read-only"); } else if (img_type(d) == IMG_TYPE_PDFSTREAM) { - luaL_error(L, "image.filename can't be used with image.stream"); + /* just ignore */ } else if (t == LUA_TSTRING) { xfree(img_filename(d)); img_filename(d) = xstrdup(lua_tostring(L, -1)); @@ -531,13 +579,35 @@ static void lua_to_image(lua_State * L, image * a, image_dict * d) if (img_state(d) >= DICT_FILESCANNED) { luaL_error(L, "image.visiblefilename is now read-only"); } else if (img_type(d) == IMG_TYPE_PDFSTREAM) { - luaL_error(L, "image.visiblefilename can't be used with image.stream"); + img_visiblefilename(d) = NULL; } else if (t == LUA_TSTRING) { xfree(img_visiblefilename(d)); img_visiblefilename(d) = xstrdup(lua_tostring(L, -1)); } else { luaL_error(L, "image.visiblefilename needs string value"); } + } else if (lua_key_eq(s,userpassword)) { + if (img_state(d) >= DICT_FILESCANNED) { + luaL_error(L, "image.userpassword is now read-only"); + } else if (img_type(d) == IMG_TYPE_PDFSTREAM) { + img_userpassword(d) = NULL; + } else if (t == LUA_TSTRING) { + xfree(img_userpassword(d)); + img_userpassword(d) = xstrdup(lua_tostring(L, -1)); + } else { + luaL_error(L, "image.userpassword needs string value"); + } + } else if (lua_key_eq(s,ownerpassword)) { + if (img_state(d) >= DICT_FILESCANNED) { + luaL_error(L, "image.ownerpassword is now read-only"); + } else if (img_type(d) == IMG_TYPE_PDFSTREAM) { + img_ownerpassword(d) = NULL; + } else if (t == LUA_TSTRING) { + xfree(img_ownerpassword(d)); + img_ownerpassword(d) = xstrdup(lua_tostring(L, -1)); + } else { + luaL_error(L, "image.ownerpassword needs string value"); + } } else if (lua_key_eq(s,attr)) { if (img_state(d) >= DICT_FILESCANNED) { luaL_error(L, "image.attr is now read-only"); @@ -607,6 +677,8 @@ static void lua_to_image(lua_State * L, image * a, image_dict * d) } else { img_keepopen(d) = lua_toboolean(L, -1); } + } else if (lua_key_eq(s,nolength)) { + img_nolength(d) = lua_toboolean(L, -1); } else if (lua_key_eq(s,bbox)) { if (img_state(d) >= DICT_FILESCANNED) { luaL_error(L, "image.bbox is now read-only"); @@ -636,11 +708,15 @@ static void lua_to_image(lua_State * L, image * a, image_dict * d) } else if (img_state(d) >= DICT_FILESCANNED) { luaL_error(L, "image.stream is now read-only"); } else { + size_t size = 0; + const char *stream = lua_tolstring(L, -1, &size); if (img_pdfstream_ptr(d) == NULL) { new_img_pdfstream_struct(d); } xfree(img_pdfstream_stream(d)); - img_pdfstream_stream(d) = xstrdup(lua_tostring(L, -1)); + img_pdfstream_size(d) = size; + img_pdfstream_stream(d) = xmalloc(size); + memcpy(img_pdfstream_stream(d),stream,size); img_type(d) = IMG_TYPE_PDFSTREAM; } } else { diff --git a/Build/source/texk/web2c/luatexdir/lua/liolibext.c b/Build/source/texk/web2c/luatexdir/lua/liolibext.c index 29ad8447ad0..71b9b41d12c 100644 --- a/Build/source/texk/web2c/luatexdir/lua/liolibext.c +++ b/Build/source/texk/web2c/luatexdir/lua/liolibext.c @@ -125,7 +125,7 @@ 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) { + if (p >= l) { lua_pushnil(L); } else { int a = uchar(s[p]); @@ -150,7 +150,7 @@ 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) { + if (p+1 >= l) { lua_pushnil(L); } else { int a = uchar(s[p++]); @@ -177,7 +177,7 @@ 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) { + if (p+2 >= l) { lua_pushnil(L); } else { int a = uchar(s[p++]); @@ -206,7 +206,7 @@ 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) { + if (p+3 >= l) { lua_pushnil(L); } else { int a = uchar(s[p++]); @@ -218,6 +218,139 @@ static int readcardinal4_s(lua_State *L) { return 1; } +static int readcardinaltable(lua_State *L) { + FILE *f = tofile(L); + int n = lua_tointeger(L,2); + int b = lua_tointeger(L,3); + int i; + lua_createtable(L,n,0); + switch (b) { + case 1: + for (i=1;i<=n;i++) { + int a = getc(f); + if (a == EOF) { + break; + } else { + lua_pushinteger(L, a); + lua_rawseti(L, -2, i); + } + } + break; + case 2: + for (i=1;i<=n;i++) { + int a = getc(f); + int b = getc(f); + if (b == EOF) { + break; + } else { + /* (a<<8) | b */ + lua_pushinteger(L, 0x100 * a + b); + lua_rawseti(L, -2, i); + } + } + break; + case 3: + for (i=1;i<=n;i++) { + int a = getc(f); + int b = getc(f); + int c = getc(f); + if (c == EOF) { + break; + } else { + /* (a<<16) | (b<<8) | c */ + lua_pushinteger(L, 0x10000 * a + 0x100 * b + c); + lua_rawseti(L, -2, i); + } + } + break; + case 4: + for (i=1;i<=n;i++) { + int a = getc(f); + int b = getc(f); + int c = getc(f); + int d = getc(f); + if (d == EOF) { + break; + } else { + /* (a<<24) | (b<<16) | (c<<8) | d */ + lua_pushinteger(L,0x1000000 * a + 0x10000 * b + 0x100 * c + d); + lua_rawseti(L, -2, i); + } + } + break; + default: + break; + } + return 1; +} + +static int readcardinaltable_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); + int b = lua_tointeger(L,4); + int i; + lua_createtable(L,n,0); + /*if (p >= 0) {*/ + switch (b) { + case 1: + for (i=1;i<=n;i++) { + if (p >= l) { + break; + } else { + int a = uchar(s[p++]); + lua_pushinteger(L, a); + lua_rawseti(L, -2, i); + } + } + break; + case 2: + for (i=1;i<=n;i++) { + if (p+1 >= l) { + break; + } else { + int a = uchar(s[p++]); + int b = uchar(s[p++]); + lua_pushinteger(L, 0x100 * a + b); + lua_rawseti(L, -2, i); + } + } + break; + case 3: + for (i=1;i<=n;i++) { + if (p+2 >= l) { + break; + } else { + int a = uchar(s[p++]); + int b = uchar(s[p++]); + int c = uchar(s[p++]); + lua_pushinteger(L, 0x10000 * a + 0x100 * b + c); + lua_rawseti(L, -2, i); + } + } + break; + case 4: + for (i=1;i<=n;i++) { + if (p+3 >= l) { + break; + } 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); + lua_rawseti(L, -2, i); + } + } + break; + default: + break; + } + /*}*/ + return 1; +} + static int readinteger1(lua_State *L) { FILE *f = tofile(L); int a = getc(f); @@ -234,7 +367,7 @@ 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) { + if (p >= l) { lua_pushnil(L); } else { int a = uchar(s[p]); @@ -263,7 +396,7 @@ 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) { + if (p+1 >= l) { lua_pushnil(L); } else { int a = uchar(s[p++]); @@ -294,7 +427,7 @@ 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) { + if (p+2 >= l) { lua_pushnil(L); } else { int a = uchar(s[p++]); @@ -327,7 +460,7 @@ 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) { + if (p+3 >= l) { lua_pushnil(L); } else { int a = uchar(s[p++]); @@ -342,6 +475,160 @@ static int readinteger4_s(lua_State *L) { return 1; } +static int readintegertable(lua_State *L) { + FILE *f = tofile(L); + int n = lua_tointeger(L,2); + int b = lua_tointeger(L,3); + int i; + lua_createtable(L,n,0); + switch (b) { + case 1: + for (i=1;i<=n;i++) { + int a = getc(f); + if (a == EOF) { + break; + } else if (a >= 0x80) { + lua_pushinteger(L, a - 0x100); + } else { + lua_pushinteger(L, a); + } + lua_rawseti(L, -2, i); + } + break; + case 2: + for (i=1;i<=n;i++) { + int a = getc(f); + int b = getc(f); + if (b == EOF) { + break; + } else if (a >= 0x80) { + lua_pushinteger(L, 0x100 * a + b - 0x10000); + } else { + lua_pushinteger(L, 0x100 * a + b); + } + lua_rawseti(L, -2, i); + } + break; + case 3: + for (i=1;i<=n;i++) { + int a = getc(f); + int b = getc(f); + int c = getc(f); + if (c == EOF) { + break; + } else if (a >= 0x80) { + lua_pushinteger(L, 0x10000 * a + 0x100 * b + c - 0x1000000); + } else { + lua_pushinteger(L, 0x10000 * a + 0x100 * b + c); + } + lua_rawseti(L, -2, i); + } + break; + case 4: + for (i=1;i<=n;i++) { + int a = getc(f); + int b = getc(f); + int c = getc(f); + int d = getc(f); + if (d == EOF) { + break; + } else if (a >= 0x80) { + lua_pushinteger(L, 0x1000000 * a + 0x10000 * b + 0x100 * c + d - 0x100000000); + } else { + lua_pushinteger(L, 0x1000000 * a + 0x10000 * b + 0x100 * c + d); + } + lua_rawseti(L, -2, i); + } + break; + default: + break; + } + return 1; +} + +static int readintegertable_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); + int b = lua_tointeger(L,4); + int i; + lua_createtable(L,n,0); + /*if (p >= 0) {*/ + switch (b) { + case 1: + for (i=1;i<=n;i++) { + if (p >= l) { + break; + } else { + int a = uchar(s[p++]); + if (a >= 0x80) { + lua_pushinteger(L, a - 0x100); + } else { + lua_pushinteger(L, a); + } + lua_rawseti(L, -2, i); + } + } + break; + case 2: + for (i=1;i<=n;i++) { + if (p+1 >= l) { + break; + } 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); + } + lua_rawseti(L, -2, i); + } + } + break; + case 3: + for (i=1;i<=n;i++) { + if (p+2 >= l) { + break; + } 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); + } + lua_rawseti(L, -2, i); + } + } + break; + case 4: + for (i=1;i<=n;i++) { + if (p+3 >= l) { + break; + } 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); + } + lua_rawseti(L, -2, i); + } + } + break; + default: + break; + } + /*}*/ + return 1; +} + static int readfixed2(lua_State *L) { FILE *f = tofile(L); int a = getc(f); @@ -359,7 +646,7 @@ 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) { + if (p+3 >= l) { lua_pushnil(L); } else { int a = uchar(s[p++]); @@ -394,7 +681,7 @@ 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) { + if (p+3 >= l) { lua_pushnil(L); } else { int a = uchar(s[p++]); @@ -427,7 +714,7 @@ 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) { + if (p+1 >= l) { lua_pushnil(L); } else { int a = uchar(s[p++]); @@ -497,7 +784,7 @@ static int readbytetable_s(lua_State *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) { + if (p >= l) { lua_pushnil(L); } else { int i ; @@ -534,7 +821,7 @@ static int readbytes_s(lua_State *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) { + if (p >= l) { return 0; } else { int i ; @@ -644,44 +931,48 @@ static int readline(lua_State *L) static const luaL_Reg fiolib[] = { /* helpers */ - { "readcardinal1", readcardinal1 }, - { "readcardinal2", readcardinal2 }, - { "readcardinal3", readcardinal3 }, - { "readcardinal4", readcardinal4 }, - { "readinteger1", readinteger1 }, - { "readinteger2", readinteger2 }, - { "readinteger3", readinteger3 }, - { "readinteger4", readinteger4 }, - { "readfixed2", readfixed2 }, - { "readfixed4", readfixed4 }, - { "read2dot14", read2dot14 }, - { "setposition", setposition }, - { "getposition", getposition }, - { "skipposition", skipposition }, - { "readbytes", readbytes }, - { "readbytetable", readbytetable }, - { "readline", readline }, + { "readcardinal1", readcardinal1 }, + { "readcardinal2", readcardinal2 }, + { "readcardinal3", readcardinal3 }, + { "readcardinal4", readcardinal4 }, + { "readcardinaltable", readcardinaltable }, + { "readinteger1", readinteger1 }, + { "readinteger2", readinteger2 }, + { "readinteger3", readinteger3 }, + { "readinteger4", readinteger4 }, + { "readintegertable", readintegertable }, + { "readfixed2", readfixed2 }, + { "readfixed4", readfixed4 }, + { "read2dot14", read2dot14 }, + { "setposition", setposition }, + { "getposition", getposition }, + { "skipposition", skipposition }, + { "readbytes", readbytes }, + { "readbytetable", readbytetable }, + { "readline", readline }, /* extras */ - { "recordfilename", recordfilename }, - { "checkpermission", checkpermission }, + { "recordfilename", recordfilename }, + { "checkpermission", checkpermission }, /* done */ {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 }, + { "readcardinal1", readcardinal1_s }, + { "readcardinal2", readcardinal2_s }, + { "readcardinal3", readcardinal3_s }, + { "readcardinal4", readcardinal4_s }, + { "readcardinaltable", readcardinaltable_s }, + { "readinteger1", readinteger1_s }, + { "readinteger2", readinteger2_s }, + { "readinteger3", readinteger3_s }, + { "readinteger4", readinteger4_s }, + { "readintegertable", readintegertable_s }, + { "readfixed2", readfixed2_s }, + { "readfixed4", readfixed4_s }, + { "read2dot14", read2dot14_s }, + { "readbytes", readbytes_s }, + { "readbytetable", readbytetable_s }, /* done */ {NULL, NULL} }; diff --git a/Build/source/texk/web2c/luatexdir/lua/llanglib.c b/Build/source/texk/web2c/luatexdir/lua/llanglib.c index 382d4094403..5855f33fc68 100644 --- a/Build/source/texk/web2c/luatexdir/lua/llanglib.c +++ b/Build/source/texk/web2c/luatexdir/lua/llanglib.c @@ -20,7 +20,6 @@ #include "ptexlib.h" #include "lua/luatex-api.h" - #define LANG_METATABLE "luatex.lang" #define check_islang(L,b) (struct tex_language **)luaL_checkudata(L,b,LANG_METATABLE) @@ -84,7 +83,6 @@ static int lang_clear_patterns(lua_State * L) return 0; } - static int lang_hyphenation(lua_State * L) { struct tex_language **lang_ptr; @@ -137,7 +135,6 @@ static int lang_post_hyphen_char(lua_State * L) } } - static int lang_pre_exhyphen_char(lua_State * L) { struct tex_language **lang_ptr; @@ -262,7 +259,6 @@ static int do_lang_hyphenate(lua_State * L) } static const struct luaL_Reg langlib_d[] = { - /* *INDENT-OFF* */ {"clear_patterns", lang_clear_patterns}, {"clear_hyphenation", lang_clear_hyphenation}, {"patterns", lang_patterns}, @@ -275,13 +271,11 @@ static const struct luaL_Reg langlib_d[] = { {"sethjcode", lang_sethjcode}, {"gethjcode", lang_gethjcode}, {"id", lang_id}, - /* *INDENT-ON* */ - {NULL, NULL} /* sentinel */ + /*tex sentinel */ + {NULL, NULL} }; - static const struct luaL_Reg langlib[] = { - /* *INDENT-OFF* */ {"clear_patterns", lang_clear_patterns}, {"clear_hyphenation", lang_clear_hyphenation}, {"patterns", lang_patterns}, @@ -297,17 +291,19 @@ static const struct luaL_Reg langlib[] = { {"clean", do_lang_clean}, {"hyphenate", do_lang_hyphenate}, {"new", lang_new}, - /* *INDENT-ON* */ - {NULL, NULL} /* sentinel */ + /*tex sentinel */ + {NULL, NULL} }; - int luaopen_lang(lua_State * L) { luaL_newmetatable(L, LANG_METATABLE); - lua_pushvalue(L, -1); /* push metatable */ - lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ - luaL_openlib(L, NULL, langlib_d, 0); /* dict methods */ + /*tex push metatable */ + lua_pushvalue(L, -1); + /*tex metatable.__index = metatable */ + lua_setfield(L, -2, "__index"); + /*tex set dict methods */ + luaL_openlib(L, NULL, langlib_d, 0); luaL_openlib(L, "lang", langlib, 0); return 1; } diff --git a/Build/source/texk/web2c/luatexdir/lua/llualib.c b/Build/source/texk/web2c/luatexdir/lua/llualib.c index a73e3abf2e6..ac9b03ffe60 100644 --- a/Build/source/texk/web2c/luatexdir/lua/llualib.c +++ b/Build/source/texk/web2c/luatexdir/lua/llualib.c @@ -20,14 +20,13 @@ #include "ptexlib.h" #include "lua/luatex-api.h" - -#define LOAD_BUF_SIZE 256 +#define LOAD_BUF_SIZE 64*1024 #define UINT_MAX32 0xFFFFFFFF typedef struct { unsigned char *buf; int size; - int done; + /* int done; */ int alloc; } bytecode; @@ -95,7 +94,7 @@ void undump_luac_registers(void) lua_bytecode_registers = xmalloc((unsigned) (i * sizeof(bytecode))); luabytecode_bytes = (unsigned) (i * sizeof(bytecode)); for (i = 0; i <= (unsigned) luabytecode_max; i++) { - lua_bytecode_registers[i].done = 0; + /* lua_bytecode_registers[i].done = 0; */ lua_bytecode_registers[i].size = 0; lua_bytecode_registers[i].buf = NULL; } @@ -170,14 +169,18 @@ static int writer(lua_State * L, const void *b, size_t size, void *B) static const char *reader(lua_State * L, void *ud, size_t * size) { bytecode *buf = (bytecode *) ud; - (void) L; /* for -Wunused */ + (void) L; /* for -Wunused */ + /* if (buf->done == buf->size) { *size = 0; buf->done = 0; return NULL; } + */ *size = (size_t) buf->size; + /* buf->done = buf->size; + */ return (const char *) buf->buf; } @@ -196,7 +199,7 @@ static int get_bytecode(lua_State * L) #else "bytecode", NULL)) { #endif - return luaL_error(L, "bad bytecode register"); + return luaL_error(L, "bad bytecode register"); } else { lua_pushvalue(L, -1); bytecode_register_shadow_set(L, k); @@ -208,6 +211,41 @@ static int get_bytecode(lua_State * L) return 1; } +void luabytecodecall(int slot) +{ + int i; + int stacktop = lua_gettop(Luas); + lua_active++; + if (slot < 0 || slot > luabytecode_max) { + luaL_error(Luas, "bytecode register out of range"); + } else if (bytecode_register_shadow_get(Luas, slot) || lua_bytecode_registers[slot].buf == NULL) { + luaL_error(Luas, "undefined bytecode register"); + } else if (lua_load(Luas, reader, (void *) (lua_bytecode_registers + slot), +#ifdef LuajitTeX + "bytecode")) +#else + "bytecode", NULL)) +#endif + { + luaL_error(Luas, "bytecode register doesn't load well"); + } else { + int base = lua_gettop(Luas); /* function index */ + lua_pushinteger(Luas, slot); + lua_pushcfunction(Luas, lua_traceback); /* push traceback function */ + lua_insert(Luas, base); /* put it under chunk */ +++function_callback_count; /* this will be a dedicated counter */ + i = lua_pcall(Luas, 1, 0, base); + lua_remove(Luas, base); /* remove traceback function */ + if (i != 0) { + lua_gc(Luas, LUA_GCCOLLECT, 0); + Luas = luatex_error(Luas, (i == LUA_ERRRUN ? 0 : 1)); + } + } + + lua_settop(Luas,stacktop); + lua_active--; +} + static int set_bytecode(lua_State * L) { int k, ltype; @@ -244,7 +282,7 @@ static int set_bytecode(lua_State * L) for (i = (unsigned) (luabytecode_max + 1); i <= (unsigned) k; i++) { lua_bytecode_registers[i].buf = NULL; lua_bytecode_registers[i].size = 0; - lua_bytecode_registers[i].done = 0; + /* lua_bytecode_registers[i].done = 0; */ } luabytecode_max = k; } @@ -252,7 +290,7 @@ static int set_bytecode(lua_State * L) xfree(lua_bytecode_registers[k].buf); luabytecode_bytes -= (unsigned) lua_bytecode_registers[k].size; lua_bytecode_registers[k].size = 0; - lua_bytecode_registers[k].done = 0; + /* lua_bytecode_registers[k].done = 0; */ lua_pushnil(L); bytecode_register_shadow_set(L, k); } @@ -268,7 +306,7 @@ static int set_bytecode(lua_State * L) lua_dump(L, writer, (void *) (lua_bytecode_registers + k),strip); #endif #if LUA_VERSION_NUM == 502 - lua_dump(L, writer, (void *) (lua_bytecode_registers + k)); + lua_dump(L, writer, (void *) (lua_bytecode_registers + k)); #endif #endif } @@ -329,6 +367,18 @@ static int new_table(lua_State * L) /* hh */ return 1; } +static int get_stack_top(lua_State * L) /* hh */ +{ + lua_pushinteger(L, lua_gettop(L)); + return 1; +} + +static int get_call_level(lua_State * L) /* hh */ +{ + lua_pushinteger(L, lua_active); + return 1; +} + static const struct luaL_Reg lualib[] = { /* *INDENT-OFF* */ {"getluaname", get_luaname}, @@ -337,6 +387,8 @@ static const struct luaL_Reg lualib[] = { {"setbytecode", set_bytecode}, {"newtable", new_table}, {"get_functions_table",lua_functions_get_table}, + {"getstacktop",get_stack_top}, + {"getcalllevel", get_call_level}, /* *INDENT-ON* */ {NULL, NULL} /* sentinel */ }; diff --git a/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c b/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c index 085129d54c0..3e879b54ade 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lnewtokenlib.c @@ -33,10 +33,12 @@ #include "ptexlib.h" #include "lua/luatex-api.h" +/* typedef struct lua_token { int token; int origin; } lua_token; +*/ typedef struct saved_tex_scanner { int token; @@ -145,33 +147,51 @@ static void push_token(lua_State * L, int tok) lua_setmetatable(L, -2); } -/* static int run_get_cs_offset(lua_State * L) */ -/* { */ -/* lua_pushinteger(L, cs_token_flag); */ -/* return 1; */ -/* } */ - -/* static int run_get_command_id(lua_State * L) */ -/* { */ -/* int cs = -1; */ -/* if (lua_type(L, -1) == LUA_TSTRING) { */ -/* cs = get_command_id(lua_tostring(L, -1)); */ -/* } */ -/* lua_pushinteger(L, cs); */ -/* return 1; */ -/* } */ - -/* static int run_get_csname_id(lua_State * L) */ -/* { */ -/* const char *s; */ -/* size_t k, cs = 0; */ -/* if (lua_type(L, -1) == LUA_TSTRING) { */ -/* s = lua_tolstring(L, -1, &k); */ -/* cs = (size_t) string_lookup(s, k); */ -/* } */ -/* lua_pushinteger(L, (lua_Number) cs); */ -/* return 1; */ -/* } */ +static int run_get_biggest_char(lua_State * L) +{ + lua_pushinteger(L, biggest_char); + return 1; +} + +/* not that useful: + +static int run_get_cs_offset(lua_State * L) +{ + lua_pushinteger(L, cs_token_flag); + return 1; +} + +*/ + +static int run_get_command_id(lua_State * L) +{ + int id = -1; + if (lua_type(L, -1) == LUA_TSTRING) { + id = get_command_id(lua_tostring(L, -1)); + } + if (id >= 0) { + lua_pushinteger(L, id); + } else { + lua_pushnil(L); + } + return 1; +} + +/* not that useful: + +static int run_get_csname_id(lua_State * L) +{ + const char *s; + size_t k, cs = 0; + if (lua_type(L, -1) == LUA_TSTRING) { + s = lua_tolstring(L, -1, &k); + cs = (size_t) string_lookup(s, k); + } + lua_pushinteger(L, (lua_Number) cs); + return 1; +} + +*/ static int run_get_next(lua_State * L) { @@ -296,6 +316,22 @@ static int run_scan_keyword(lua_State * L) return 1; } +static int run_scan_keyword_cs(lua_State * L) +{ + saved_tex_scanner texstate; + const char *s = luaL_checkstring(L, -1); + int v = 0; + if (s) { + save_tex_scanner(texstate); + if (scan_keyword_case_sensitive(s)) { + v = 1; + } + unsave_tex_scanner(texstate); + } + lua_pushboolean(L,v); + return 1; +} + static int run_scan_csname(lua_State * L) { unsigned char *s; @@ -328,6 +364,138 @@ static int run_scan_int(lua_State * L) return 1; } +/* + char * str ; +*/ + +# define declare_buffer \ + unsigned char word[5 + 1]; \ + char *uindex = (char *)word; \ + luaL_Buffer b ; \ + luaL_buffinit(L,&b) ; + +/* + str = (char *) uni2str(cur_chr); + luaL_addstring(&b,(char *) str); + xfree(str); +*/ + +# define add_to_buffer(chr) \ + if (chr <= 255) { \ + luaL_addchar(&b,(unsigned) (char) chr); \ + } else { \ + uindex = uni2string((char *)word,(unsigned) chr); \ + *uindex = '\0'; \ + luaL_addstring(&b,(char *) word); \ + } + +# define push_buffer \ + luaL_pushresult(&b); + +static int run_scan_float_indeed(lua_State * L, boolean exponent) +{ + saved_tex_scanner texstate; + int ok; + boolean negative = false; + double d; + declare_buffer; + save_tex_scanner(texstate); + /* we collapse as in scan_dimen */ + while(1) { + do { + get_x_token(); + } while (cur_cmd == spacer_cmd); + if (cur_tok == minus_token) { + negative = !negative; + } else if (cur_tok != plus_token) { + break; + } + } + if (negative) { + add_to_buffer('-'); + } + /* we accept [.,]digits */ + if (cur_tok == point_token || cur_tok == comma_token) { + add_to_buffer('.'); + while (1) { + get_x_token(); + if ((cur_tok >= zero_token) && (cur_tok <= nine_token)) { + add_to_buffer(cur_chr); + } else if (exponent) { + goto EXPONENT; + } else { + back_input(); + goto DONE; + } + } + } else { + back_input(); + while (1) { + get_x_token(); + if ((cur_tok >= zero_token) && (cur_tok <= nine_token)) { + add_to_buffer(cur_chr); + } else { + if (cur_tok == point_token || cur_tok == comma_token) { + add_to_buffer('.'); + while (1) { + get_x_token(); + if ((cur_tok >= zero_token) && (cur_tok <= nine_token)) { + add_to_buffer(cur_chr); + } else { + back_input(); + break; + } + } + } else if (exponent) { + goto EXPONENT; + } else { + back_input(); + goto DONE; + } + } + } + } +EXPONENT: + if ((cur_chr == 'E') || (cur_chr == 'e')) { + add_to_buffer(cur_chr); + get_x_token(); + if ((cur_tok == minus_token) || (cur_tok == plus_token)) { + add_to_buffer(cur_chr); + } else if ((cur_tok >= zero_token) && (cur_tok <= nine_token)) { + add_to_buffer(cur_chr); + } + while (1) { + get_x_token(); + if ((cur_tok >= zero_token) && (cur_tok <= nine_token)) { + add_to_buffer(cur_chr); + } else { + break; + } + } + } + back_input(); +DONE: + push_buffer; + d = lua_tonumberx(L,1,&ok); + if (ok) { + lua_pushnumber(L,d); + } else { + lua_pushnil(L); + } + unsave_tex_scanner(texstate); + return 1; +} + +static int run_scan_float(lua_State * L) +{ + return run_scan_float_indeed(L,true); +} + +static int run_scan_real(lua_State * L) +{ + return run_scan_float_indeed(L,false); +} + static int run_scan_dimen(lua_State * L) { saved_tex_scanner texstate; @@ -339,7 +507,7 @@ static int run_scan_dimen(lua_State * L) if (t>1) mu = lua_toboolean(L,2); /* mu units required ?*/ save_tex_scanner(texstate); - scan_dimen( mu,inf, false); /* arg3 = shortcut */ + scan_dimen(mu,inf, false); /* arg3 = shortcut */ v = cur_val; o = cur_order; unsave_tex_scanner(texstate); @@ -415,25 +583,67 @@ static int run_scan_string(lua_State * L) /* HH */ } else if (cur_cmd == call_cmd) { t = token_link(cur_chr); tokenlist_to_luastring(L,t); + } else if (cur_cmd == 11 || cur_cmd == 12 ) { + declare_buffer; + while (1) { + add_to_buffer(cur_chr); + get_x_token(); + if (cur_cmd != 11 && cur_cmd != 12 ) { + break ; + } + } + back_input(); + push_buffer; } else { - if (cur_cmd == 11 || cur_cmd == 12 ) { - char * str ; - luaL_Buffer b ; - luaL_buffinit(L,&b) ; - while (1) { - str = (char *) uni2str(cur_chr); - luaL_addstring(&b,(char *) str); - get_x_token(); - if (cur_cmd != 11 && cur_cmd != 12 ) { - break ; - } + back_input(); + lua_pushnil(L); + } + unsave_tex_scanner(texstate); + return 1; +} + +static int run_scan_argument(lua_State * L) /* HH */ +{ /* can be simplified, no need for intermediate list */ + saved_tex_scanner texstate; + halfword t, saved_defref; + save_tex_scanner(texstate); + do { + get_token(); + } while ((cur_cmd == spacer_cmd) || (cur_cmd == relax_cmd)); + if (cur_cmd == left_brace_cmd) { + back_input(); + saved_defref = def_ref; + (void) scan_toks(false, true); + t = def_ref; + def_ref = saved_defref; + tokenlist_to_luastring(L,t); + } else if (cur_cmd == call_cmd) { + halfword saved_cur_tok = cur_tok; + cur_tok = right_brace_token + '}'; + back_input(); + cur_tok = saved_cur_tok; + back_input(); + cur_tok = left_brace_token + '{'; + back_input(); + saved_defref = def_ref; + (void) scan_toks(false, true); + t = def_ref; + def_ref = saved_defref; + tokenlist_to_luastring(L,t); + } else if (cur_cmd == 11 || cur_cmd == 12 ) { + declare_buffer; + while (1) { + add_to_buffer(cur_chr); + get_x_token(); + if (cur_cmd != 11 && cur_cmd != 12 ) { + break ; } - back_input(); - luaL_pushresult(&b); - } else { - back_input(); - lua_pushnil(L); } + back_input(); + push_buffer; + } else { + back_input(); + lua_pushnil(L); } unsave_tex_scanner(texstate); return 1; @@ -447,20 +657,16 @@ static int run_scan_word(lua_State * L) /* HH */ get_x_token(); } while ((cur_cmd == spacer_cmd) || (cur_cmd == relax_cmd)); if (cur_cmd == 11 || cur_cmd == 12 ) { - char *str ; - luaL_Buffer b ; - luaL_buffinit(L,&b) ; + declare_buffer; while (1) { - str = (char *) uni2str(cur_chr); - luaL_addstring(&b,str); - xfree(str); + add_to_buffer(cur_chr); get_x_token(); if (cur_cmd != 11 && cur_cmd != 12 ) { break ; } } back_input(); - luaL_pushresult(&b); + push_buffer; } else { back_input(); lua_pushnil(L); @@ -503,12 +709,12 @@ static int lua_tokenlib_is_token(lua_State * L) /* HH */ return 1; } -/* static int run_expand(lua_State * L) */ -/* { */ -/* (void) L; */ -/* expand(); */ -/* return 0; */ -/* } */ +static int run_expand(lua_State * L) +{ + (void) L; + expand(); + return 0; +} static int run_lookup(lua_State * L) { @@ -529,6 +735,21 @@ static int run_lookup(lua_State * L) return 1; } +static int lua_tokenlib_is_defined(lua_State * L) +{ + const char *s; + size_t l; + if (lua_type(L, -1) == LUA_TSTRING) { + s = lua_tolstring(L, -1, &l); + if (l > 0) { + lua_pushboolean(L,string_lookup(s, l) != undefined_control_sequence); + return 1; + } + } + lua_pushnil(L); + return 1; +} + static int run_build(lua_State * L) { if (lua_type(L, 1) == LUA_TNUMBER) { @@ -550,6 +771,15 @@ static int run_build(lua_State * L) } } +static int run_new(lua_State * L) +{ + int cs = 0; + int chr = (int) lua_tointeger(L, 1); + int cmd = (int) lua_tointeger(L, 2); + make_new_token(L, cmd, chr, cs); + return 1; +} + /* token instance functions */ static int lua_tokenlib_free(lua_State * L) @@ -602,7 +832,6 @@ inline static int lua_tokenlib_get_index(lua_State * L) e -= toks_base; break; default: - e = -1; break; } if ((e >= 0) && (e <= 65535)) { @@ -630,7 +859,7 @@ inline static int lua_tokenlib_get_cmdname(lua_State * L) lua_token *n = check_istoken(L, 1); halfword t = token_info(n->token); int cmd = (t >= cs_token_flag ? eq_type(t - cs_token_flag) : token_cmd(t)); - lua_pushstring(L, command_names[cmd].cmd_name); /* can be sped up */ + lua_push_string_by_index(L, command_names[cmd].lua); return 1; } @@ -750,7 +979,7 @@ static int lua_tokenlib_equal(lua_State * L) n = check_istoken(L, 1); m = check_istoken(L, 2); if (token_info(n->token) == token_info(m->token)) { - lua_pushboolean(L,1); + lua_pushboolean(L,1); return 1; } lua_pushboolean(L,0); @@ -789,6 +1018,19 @@ static int run_scan_token(lua_State * L) return 1; } +static int run_scan_list(lua_State * L) +{ + saved_tex_scanner texstate; + save_tex_scanner(texstate); + /*tex + This is s tricky call as we are in \LUA\ and therefore + mess with the main loop. + */ + lua_nodelib_push_fast(L, local_scan_box()); + unsave_tex_scanner(texstate); + return 1; +} + /* experiment */ /* [catcodetable] csname content : \def\csname{content} */ @@ -844,6 +1086,56 @@ static int get_macro(lua_State * L) return 0; } +static int set_lua(lua_State *L) +{ + const char *name = null; + const char *s = null; + size_t lname = 0; + int cs; + int n = lua_gettop(L); + int a = 0; /* global state */ + int p = 0; /* protected state */ + int f = 0; /* function index */ + int nncs = no_new_control_sequence; + if (n < 2) { + return 0 ; + } + name = lua_tolstring(L, 1, &lname); + if (name == null) { + return 0 ; + } + f = lua_tointeger(L, 2); + if (n > 2) { + s = lua_tostring(L, 3); + if (s) { + if (lua_key_eq(s, global)) { + a = 4; + } else if (lua_key_eq(s, protected)) { + p = 1; + } + } + if (n > 3) { + s = lua_tostring(L, 4); + if (s) { + if (lua_key_eq(s, global)) { + a = 4; + } else if (lua_key_eq(s, protected)) { + p = 1; + } + } + } + } + no_new_control_sequence = false ; + cs = string_lookup(name, lname); + no_new_control_sequence = nncs; + if (p) { + define(cs, lua_call_cmd, f); + } else { + define(cs, lua_expandable_call_cmd, f); + } + return 0; +} + static int set_macro(lua_State * L) { const char *name = null; @@ -963,27 +1255,75 @@ static int set_macro(lua_State * L) return 0; } +static int set_char(lua_State * L) +{ + const char *name = null; + const char *s = null; + size_t lname = 0; + int cs, value; + int n = lua_gettop(L); + int a = 0 ; /* global state */ + int nncs = no_new_control_sequence; + if (n < 2) + return 0; + name = lua_tolstring(L, 1, &lname); + if (name == null) + return 0; + value = lua_tointeger(L, 2); + if (value < 0) + return 0; + if (n > 2) + s = lua_tostring(L, 3); + if (s && (lua_key_eq(s, global))) { + a = 4; + } + no_new_control_sequence = false ; + cs = string_lookup(name, lname); + no_new_control_sequence = nncs; + define(cs, char_given_cmd, value); + return 0; +} + +static int get_command_names(lua_State * L) +{ + int i; + lua_createtable(L,data_cmd+1,0); + for (i = 0; command_names[i].lua != 0; i++) { + lua_rawgeti(L, LUA_REGISTRYINDEX, command_names[i].lua); + lua_rawseti(L, -2, i); + } + return 1; +} + static const struct luaL_Reg tokenlib[] = { { "type", lua_tokenlib_type }, { "create", run_build }, + { "new", run_new }, { "is_token", lua_tokenlib_is_token }, + { "is_defined", lua_tokenlib_is_defined }, + { "commands", get_command_names }, + { "command_id", run_get_command_id }, + { "biggest_char", run_get_biggest_char }, /* scanners */ { "get_next", run_get_next }, - { "put_next", run_put_next }, { "scan_keyword", run_scan_keyword }, + { "scan_keyword_cs", run_scan_keyword_cs }, { "scan_int", run_scan_int }, + { "scan_float", run_scan_float }, + { "scan_real", run_scan_real }, { "scan_dimen", run_scan_dimen }, { "scan_glue", run_scan_glue }, { "scan_toks", run_scan_toks }, { "scan_code", run_scan_code }, { "scan_string", run_scan_string }, + { "scan_argument", run_scan_argument }, { "scan_word", run_scan_word }, { "scan_csname", run_scan_csname }, { "scan_token", run_scan_token }, /* expands next token if needed */ - /* push into input stream */ - /* - { "write",luatwrite }, - */ + { "scan_list", run_scan_list }, + /* writers */ + { "put_next", run_put_next }, + { "expand", run_expand }, /* getters */ { "get_command", lua_tokenlib_get_command }, { "get_index", lua_tokenlib_get_index }, @@ -995,15 +1335,12 @@ static const struct luaL_Reg tokenlib[] = { { "get_active", lua_tokenlib_get_active }, { "get_expandable", lua_tokenlib_get_expandable }, { "get_protected", lua_tokenlib_get_protected }, - /* maybe more setters */ - { "set_macro", set_macro }, { "get_macro", get_macro }, { "get_meaning", get_meaning }, - /* probably never */ - /* {"expand", run_expand}, */ /* does not work yet! */ - /* {"csname_id", run_get_csname_id}, */ /* yes or no */ - /* {"command_id", run_get_command_id}, */ /* yes or no */ - /* {"cs_offset", run_get_cs_offset}, */ /* not that useful */ + /* setters */ + { "set_macro", set_macro }, + { "set_char", set_char }, + { "set_lua", set_lua }, {NULL, NULL} }; diff --git a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c index 7b4c614ea4a..d8732df7605 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lnodelib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lnodelib.c @@ -209,6 +209,80 @@ halfword *check_isnode(lua_State * L, int i) return NULL; } +static int nodelib_setdir_text(lua_State * L, int i, halfword n) +{ + if (lua_type(L, i) == LUA_TSTRING) { + const char *s = lua_tostring(L, i); + if (s==lua_key_plus(TLT)) { + dir_dir(n) = 0 ; + subtype(n) = normal_dir; + } else if (s==lua_key_minus(TLT)) { + dir_dir(n) = 0 ; + subtype(n) = cancel_dir; + } else if (s==lua_key_plus(TRT)) { + dir_dir(n) = 1 ; + subtype(n) = normal_dir; + } else if (s==lua_key_minus(TRT)) { + dir_dir(n) = 1 ; + subtype(n) = cancel_dir; + } else if (s==lua_key_plus(LTL)) { + dir_dir(n) = 2 ; + subtype(n) = normal_dir; + } else if (s==lua_key_minus(LTL)) { + dir_dir(n) = 2 ; + subtype(n) = cancel_dir; + } else if (s==lua_key_plus(RTT)) { + dir_dir(n) = 3 ; + subtype(n) = normal_dir; + } else if (s==lua_key_minus(RTT)) { + dir_dir(n) = 3 ; + subtype(n) = cancel_dir; + } else { + luaL_error(L, "Bad direction specifier %s", s); + } + } else { + luaL_error(L, "Direction specifiers have to be strings"); + } + return 0; +} + +static int nodelib_getdir_par(lua_State * L, int n) +{ + if (lua_type(L, n) == LUA_TSTRING) { + const char *s = lua_tostring(L, n); + if (s==lua_key(TLT)) + return 0 ; + else if (s==lua_key(TRT)) + return 1 ; + else if (s==lua_key(LTL)) + return 2 ; + else if (s==lua_key(RTT)) + return 3 ; + else + luaL_error(L, "Bad direction specifier %s", s); + } else { + luaL_error(L, "Direction specifiers have to be strings"); + } + return 0; +} + +static int nodelib_getdirection(lua_State * L, int n) +{ + if (lua_type(L, n) == LUA_TNUMBER) { + int i = lua_tointeger(L, n); + check_dir_value(i); + return i; + } else { + luaL_error(L, "Direction specifiers have to be numbers"); + } + return 0; +} + +int nodelib_getdir(lua_State * L, int n) /* the api public one */ +{ + return nodelib_getdir_par(L,n); +} + /* This routine finds the numerical value of a string (or number) at @@ -216,13 +290,32 @@ halfword *check_isnode(lua_State * L, int i) */ +/* s = lua_tostring(L, 2); */ +/* if (lua_key_eq(s, id)) { */ + static int get_node_type_id_from_name(lua_State * L, int n, node_info * data) { - int j; - const char *s = lua_tostring(L, n); - for (j = 0; data[j].id != -1; j++) { - if (strcmp(s, data[j].name) == 0) { - return j; + if (data != NULL) { + int j; + const char *s = lua_tostring(L, n); + for (j = 0; data[j].id != -1; j++) { + if (s == data[j].name) { + return j; + } + } + } + return -1; +} + +static int get_node_subtype_id_from_name(lua_State * L, int n, subtype_info * data) +{ + if (data != NULL) { + int j; + const char *s = lua_tostring(L, n); + for (j = 0; data[j].id != -1; j++) { + if (s == data[j].name) { + return j; + } } } return -1; @@ -234,7 +327,7 @@ static int get_valid_node_type_id(lua_State * L, int n) int t = lua_type(L, n); if (t == LUA_TSTRING) { i = get_node_type_id_from_name(L,n,node_data); - if (i<0) { + if (i < 0) { luaL_error(L, "invalid node type id: %s", lua_tostring(L, n)); } } else if (t == LUA_TNUMBER) { @@ -347,6 +440,31 @@ void lua_nodelib_push_fast(lua_State * L, halfword n) return; } +/* getting and setting fields (helpers) */ + +int nodelib_getlist(lua_State * L, int n) +{ + if (lua_isuserdata(L, n)) { + halfword m = *check_isnode(L, n); + return m; + } else { + return null; + } +} + +static str_number nodelib_getstring(lua_State * L, int a) +{ + size_t k; + const char *s = lua_tolstring(L, a, &k); + return maketexlstring(s, k); +} + +static int nodelib_cantset(lua_State * L, int n, const char *s) +{ + luaL_error(L,"You cannot set field %s in a node of type %s",s,node_data[type(n)].name); + return 0; +} + /* converts type strings to type ids */ static int lua_nodelib_id(lua_State * L) @@ -439,6 +557,44 @@ static int lua_nodelib_direct_setsubtype(lua_State * L) return 1; } +/* node.direct.getexpansion */ +/* node.direct.setexpansion */ + +static int lua_nodelib_direct_getexpansion(lua_State * L) +{ + halfword n = lua_tointeger(L, 1); + if (n != null) { + halfword t = type(n); + if (t == glyph_node) { + lua_pushinteger(L, ex_glyph(n)); + return 1; + } else if (t == kern_node) { + lua_pushinteger(L, ex_kern(n)); + return 1; + } + } + lua_pushnil(L); + return 1; +} + +static int lua_nodelib_direct_setexpansion(lua_State * L) +{ + halfword n = lua_tointeger(L, 1); + if (n) { + halfword t = type(n); + halfword e = 0; + if (lua_type(L, 2) == LUA_TNUMBER) { + e = (halfword) lua_tointeger(L, 2); + } + if (t == glyph_node) { + ex_glyph(n) = e; + } else if ( t == kern_node) { + ex_kern(n) = e; + } + } + return 0; +} + /* node.direct.getfont */ /* node.direct.setfont */ @@ -530,6 +686,10 @@ static int lua_nodelib_direct_getfam(lua_State * L) lua_pushinteger(L, math_fam(n)); } else if (t == delim_node) { lua_pushinteger(L, small_fam(n)); + } else if (t == fraction_noad) { + lua_pushinteger(L, fraction_fam(n)); + } else if (t == simple_noad) { + lua_pushinteger(L, noad_fam(n)); } else { lua_pushnil(L); } @@ -565,6 +725,10 @@ static int lua_nodelib_direct_setfam(lua_State * L) math_fam(n) = (halfword) lua_tointeger(L, 2); } else if (t == delim_node) { small_fam(n) = (halfword) lua_tointeger(L, 2); + } else if (t == fraction_noad) { + fraction_fam(n) = (halfword) lua_tointeger(L, 2); + } else if (t == simple_noad) { + noad_fam(n) = (halfword) lua_tointeger(L, 2); } } return 0; @@ -572,7 +736,7 @@ static int lua_nodelib_direct_setfam(lua_State * L) /* node.getchar */ - static int lua_nodelib_getchar(lua_State * L) +static int lua_nodelib_getchar(lua_State * L) { halfword *n = lua_touserdata(L, 1); if ((n == NULL) || (! lua_getmetatable(L,1))) { @@ -665,7 +829,8 @@ static int lua_nodelib_direct_setattributelist(lua_State * L) { halfword n = lua_tointeger(L, 1); if ((n) && nodetype_has_attributes(type(n))) { - if (lua_type(L, 2) == LUA_TNUMBER) { + int t = lua_type(L, 2); + if (t == LUA_TNUMBER) { halfword a =lua_tointeger(L, 2); if (type(a) == attribute_list_node) { reassign_attribute(n,a); @@ -674,6 +839,12 @@ static int lua_nodelib_direct_setattributelist(lua_State * L) } else { reassign_attribute(n,null); } + } else if (t == LUA_TBOOLEAN) { + if (lua_toboolean(L,2)) { + reassign_attribute(n,current_attribute_list()); + } else { + reassign_attribute(n,null); + } } else { reassign_attribute(n,null); } @@ -681,7 +852,6 @@ static int lua_nodelib_direct_setattributelist(lua_State * L) } return 0; } - /* node.direct.getpenalty */ /* node.direct.setpenalty */ @@ -827,7 +997,15 @@ static int lua_nodelib_direct_getkern(lua_State * L) halfword n = lua_tointeger(L, 1); if (n) { halfword t = type(n); - if (t == kern_node || t == margin_kern_node) { + if (t == kern_node) { + if (lua_toboolean(L,2)) { + lua_pushnumber(L, (1+ex_kern(n)/1000) * width(n)); + lua_pushinteger(L, ex_kern(n)); + return 2; + } else { + lua_pushinteger(L, width(n)); + } + } else if (t == margin_kern_node) { lua_pushinteger(L, width(n)); } else if (t == math_node) { lua_pushinteger(L, surround(n)); @@ -874,7 +1052,7 @@ static int lua_nodelib_direct_getdir(lua_State * L) if (n) { halfword t = type(n); if (t == dir_node) { - lua_push_dir_text(L, dir_dir(n)); + lua_push_dir_text(L, dir_dir(n), subtype(n)); } else if (t == hlist_node || t == vlist_node) { lua_push_dir_par(L, box_dir(n)); } else if (t == rule_node) { @@ -890,19 +1068,68 @@ static int lua_nodelib_direct_getdir(lua_State * L) return 1; } +static int lua_nodelib_direct_getdirection(lua_State * L) +{ + halfword n = lua_tointeger(L, 1); + if (n) { + halfword t = type(n); + if (t == dir_node) { + lua_push_direction(L, dir_dir(n)); + lua_pushboolean(L, subtype(n)); + return 2; + } else if (t == hlist_node || t == vlist_node) { + lua_push_direction(L, box_dir(n)); + } else if (t == rule_node) { + lua_push_direction(L, rule_dir(n)); + } else if (t == local_par_node) { + lua_push_direction(L, local_par_dir(n)); + } else { + lua_pushnil(L); + } + } else { + lua_pushnil(L); + } + return 1; +} + static int lua_nodelib_direct_setdir(lua_State * L) { halfword n = lua_tointeger(L, 1); if (n) { halfword t = type(n); if (t == dir_node) { - dir_dir(n) = nodelib_getdir(L, 2, 0); + nodelib_setdir_text(L, 2, n); + } else if (t == hlist_node || type(n) == vlist_node) { + box_dir(n) = nodelib_getdir_par(L, 2); + } else if (t == rule_node) { + rule_dir(n) = nodelib_getdir_par(L, 2); + } else if (t == local_par_node) { + local_par_dir(n) = nodelib_getdir_par(L, 2); + } + } + return 0; +} + +static int lua_nodelib_direct_setdirection(lua_State * L) +{ + halfword n = lua_tointeger(L, 1); + if (n) { + halfword t = type(n); + if (t == dir_node) { + dir_dir(n) = nodelib_getdirection(L, 2); + if ((lua_type(L, 3) == LUA_TBOOLEAN)) { + if (lua_toboolean(L, 3)) { + subtype(n) = cancel_dir; + } else { + subtype(n) = normal_dir; + } + } } else if (t == hlist_node || type(n) == vlist_node) { - box_dir(n) = nodelib_getdir(L, 2, 1); + box_dir(n) = nodelib_getdirection(L, 2); } else if (t == rule_node) { - rule_dir(n) = nodelib_getdir(L, 2, 1); + rule_dir(n) = nodelib_getdirection(L, 2); } else if (t == local_par_node) { - local_par_dir(n) = nodelib_getdir(L, 3, 1); + local_par_dir(n) = nodelib_getdirection(L, 2); } } return 0; @@ -1017,15 +1244,24 @@ static int lua_nodelib_direct_setdisc(lua_State * L) /* node.direct.getwhd */ /* node.direct.setwhd */ -#define push_list_whd(n) \ - lua_pushinteger(L, width(n)); \ +#define push_list_whd(n) do { \ + lua_pushinteger(L, width(n)); \ lua_pushinteger(L, height(n)); \ - lua_pushinteger(L, depth(n)); \ + lua_pushinteger(L, depth(n)); \ +} while (0) + +#define push_char_whd(n) do { \ + lua_pushinteger(L, char_width(font(n),character(n))); \ + lua_pushinteger(L, char_height(font(n),character(n))); \ + lua_pushinteger(L, char_depth(font(n),character(n))); \ +} while (0) -#define push_char_whd(n) \ - lua_pushinteger(L, char_width(font(n),character(n))); \ +#define push_char_ehd(n) do { \ + lua_pushnumber(L, (1+ex_glyph(n)/1000) * char_width(font(n),character(n))); \ lua_pushinteger(L, char_height(font(n),character(n))); \ - lua_pushinteger(L, char_depth(font(n),character(n))); \ + lua_pushinteger(L, char_depth(font(n),character(n))); \ + lua_pushinteger(L, ex_glyph(n)); \ +} while (0) static int lua_nodelib_direct_getwhd(lua_State * L) { @@ -1036,8 +1272,13 @@ static int lua_nodelib_direct_getwhd(lua_State * L) push_list_whd(n); return 3; } else if (t == glyph_node) { - push_char_whd(n); - return 3; + if (lua_toboolean(L,2)) { + push_char_ehd(n); + return 4; + } else { + push_char_whd(n); + return 3; + } } else if (t == glue_node) { halfword l = leader_ptr(n); if (l != null) { @@ -1104,8 +1345,13 @@ static int lua_nodelib_direct_setwhd(lua_State * L) push_list_whd(*n); return 3; } else if (t == glyph_node) { - push_char_whd(*n); - return 3; + if (lua_toboolean(L,2)) { + push_char_ehd(*n); + return 4; + } else { + push_char_whd(*n); + return 3; + } } else if (t == glue_node) { halfword l = leader_ptr(*n); if (l != null) { @@ -1214,7 +1460,7 @@ static int lua_nodelib_direct_getleader(lua_State * L) return 1; } - static int lua_nodelib_direct_setleader(lua_State * L) +static int lua_nodelib_direct_setleader(lua_State * L) { halfword n = lua_tointeger(L, 1); if ((n) && (type(n) == glue_node)) { @@ -1227,7 +1473,7 @@ static int lua_nodelib_direct_getleader(lua_State * L) return 0; } - /* node.getleader */ +/* node.getleader */ static int lua_nodelib_getleader(lua_State * L) { @@ -1243,6 +1489,241 @@ static int lua_nodelib_direct_getleader(lua_State * L) return 1; } +/* node.direct.getdata */ +/* node.direct.setdata */ + +#define get_user_node_direct_value(L, n) do { \ + switch (user_node_type(n)) { \ + case 'a': \ + nodelib_pushdirect(user_node_value(n)); \ + break; \ + case 'd': \ + lua_pushinteger(L, user_node_value(n)); \ + break; \ + case 'l': \ + if (user_node_value(n) != 0) { \ + lua_rawgeti(L, LUA_REGISTRYINDEX, user_node_value(n)); \ + } else { \ + lua_pushnil(L); \ + } \ + break; \ + case 'n': \ + nodelib_pushdirect(user_node_value(n)); \ + break; \ + case 's': \ + nodelib_pushstring(L, user_node_value(n)); \ + break; \ + case 't': \ + tokenlist_to_lua(L, user_node_value(n)); \ + break; \ + default: \ + lua_pushinteger(L, user_node_value(n)); \ + break; \ + } \ +} while (0) + +#define set_user_node_direct_value(L,n,i) do { \ + switch (user_node_type(n)) { \ + case 'a': \ + user_node_value(n) = nodelib_getlist(L, i); \ + break; \ + case 'd': \ + user_node_value(n) = (halfword) lua_roundnumber(L, i); \ + break; \ + case 'l': \ + lua_pushvalue(L, i); \ + if (user_node_value(n) != 0) { \ + luaL_unref(L, LUA_REGISTRYINDEX,user_node_value(n)); \ + } \ + user_node_value(n) = luaL_ref(L, LUA_REGISTRYINDEX); \ + break; \ + case 'n': \ + user_node_value(n) = nodelib_getlist(L, i); \ + break; \ + case 's': \ + user_node_value(n) = nodelib_getstring(L, i); \ + break; \ + case 't': \ + user_node_value(n) = nodelib_gettoks(L, i); \ + break; \ + default: \ + user_node_value(n) = (halfword) lua_roundnumber(L, i); \ + break; \ + } \ +} while (0) + +#define get_pdf_literal_direct_value(L,n) do { \ + if (pdf_literal_type(n) == lua_refid_literal) { \ + lua_rawgeti(L, LUA_REGISTRYINDEX, pdf_literal_data(n)); \ + } else if (pdf_literal_type(n) == lua_refid_literal) { \ + tokenlist_to_luastring(L, pdf_literal_data(n)); \ + } \ +} while (0) + +#define set_pdf_literal_direct_normal(L,n,i) do { \ + if (ini_version) { \ + pdf_literal_data(n) = nodelib_gettoks(L, i); \ + pdf_literal_type(n) = normal; \ + } else { \ + lua_pushvalue(L, i); \ + pdf_literal_data(n) = luaL_ref(L, LUA_REGISTRYINDEX); \ + pdf_literal_type(n) = lua_refid_literal; \ + } \ +} while (0) + +#define set_pdf_literal_direct_token(L,n,i) do { \ + pdf_literal_data(n) = nodelib_gettoks(L, i); \ +} while (0) + +#define cleanup_late_lua(n) do { \ + if (late_lua_data(n) != 0) { \ + if (late_lua_type(n) == normal) { \ + delete_token_ref(late_lua_data(n)); \ + } else if (late_lua_type(n) == lua_refid_literal) { \ + luaL_unref(L, LUA_REGISTRYINDEX,late_lua_data(n)); \ + } \ + } \ +} while (0) + +#define cleanup_late_lua_name(n) do { \ + if (late_lua_name(n) != 0) { \ + delete_token_ref(late_lua_name(n)); \ + } \ +} while (0) + +#define set_late_lua_direct_normal(L,n,i) do { \ + cleanup_late_lua(n) ; \ + if (ini_version) { \ + late_lua_data(n) = nodelib_gettoks(L, i); \ + late_lua_type(n) = normal; \ + } else if (lua_type(L, i) == LUA_TNUMBER) { \ + late_lua_data(n) = lua_tointeger(L,i); \ + late_lua_type(n) = lua_refid_call; \ + } else { \ + lua_pushvalue(L, i); \ + late_lua_data(n) = luaL_ref(L, LUA_REGISTRYINDEX); \ + late_lua_type(n) = lua_refid_literal; \ + } \ +} while (0) + +#define set_late_lua_direct_token(L,n,i) do { \ + cleanup_late_lua(n) ; \ + late_lua_data(n) = nodelib_gettoks(L, i); \ + late_lua_type(n) = normal; \ +} while (0) + +#define get_late_lua_direct_value(L,n) do { \ + if (late_lua_type(n) == lua_refid_literal) { \ + lua_rawgeti(L, LUA_REGISTRYINDEX, late_lua_data(n)); \ + } else if (late_lua_type(n) == lua_refid_call) { \ + lua_pushinteger(L, late_lua_data(n)); \ + } else if (late_lua_type(n) == normal) { \ + tokenlist_to_luastring(L, late_lua_data(n)); \ + } \ +} while (0) + +#define set_special_direct_value(L,n,i) do { \ + write_tokens(n) = nodelib_gettoks(L, i); \ +} while (0) + +#define get_special_direct_value(L,n) do { \ + tokenlist_to_luastring(L, write_tokens(n)); \ +} while (0) + +#define set_write_direct_value(L,n,i) do { \ + write_tokens(n) = nodelib_gettoks(L, i); \ +} while (0) + +#define get_write_direct_value(L,n) do { \ + tokenlist_to_lua(L, write_tokens(n)); \ +} while (0) + +#define set_pdf_setmatrix_direct_value(L,n,i) do { \ + pdf_setmatrix_data(n) = nodelib_gettoks(L, i); \ +} while (0) + +#define get_pdf_setmatrix_direct_value(L,n) do { \ + tokenlist_to_luastring(L, pdf_setmatrix_data(n)); \ +} while (0) + +/*tex + + These getter and setter get |data| as well as |value| fields. One can + make them equivalent to |getvalue| and |setvalue| if needed. + +*/ + +static int lua_nodelib_direct_getdata(lua_State * L) +{ + halfword n = lua_tointeger(L, 1); + if (n == null) { + lua_pushnil(L); + } else { + halfword t = type(n) ; + if (t == glyph_node) { + lua_pushinteger(L,glyph_node_data(n)); + } else if (t == boundary_node) { + lua_pushinteger(L,boundary_value(n)); + } else if (t == whatsit_node) { + halfword s = subtype(n); + if (s == user_defined_node) { + get_user_node_direct_value(L, n); + } else if (s == pdf_literal_node) { + get_pdf_literal_direct_value(L, n); + /*tex A bonus. */ + lua_pushinteger(L,pdf_literal_mode(n)); + return 2; + } else if (s == late_lua_node) { + get_late_lua_direct_value(L, n); + } else if (s == pdf_setmatrix_node) { + get_pdf_setmatrix_direct_value(L, n); + } else if (s == special_node) { + get_special_direct_value(L, n); + } else if (s == write_node) { + get_write_direct_value(L, n); + } else { + lua_pushnil(L); + } + } else { + lua_pushnil(L); + } + } + return 1; +} + +static int lua_nodelib_direct_setdata(lua_State * L) /* data and value */ +{ + halfword n = lua_tointeger(L, 1); + if (n != null) { + halfword t = type(n) ; + if (t == glyph_node) { + glyph_node_data(n) = lua_tointeger(L,2); + } else if (t == boundary_node) { + boundary_value(n) = lua_tointeger(L,2); + } else if (t == whatsit_node) { + halfword s = subtype(n); + if (s == user_defined_node) { + set_user_node_direct_value(L, n, 2); + } else if (s == pdf_literal_node) { + set_pdf_literal_direct_normal(L, n, 2); + if (lua_type(L,2) == LUA_TNUMBER) { + /*tex A bonus. */ + pdf_literal_mode(n) = lua_tointeger(L,2); + } + } else if (s == late_lua_node) { + set_late_lua_direct_normal(L, n, 2); + } else if (s == pdf_setmatrix_node) { + set_pdf_setmatrix_direct_value(L, n, 2); + } else if (s == special_node) { + set_special_direct_value(L, n, 2); + } else if (s == write_node) { + set_write_direct_value(L,n,2); + } + } + } + return 0; +} + /* node.direct.getnext */ /* node.direct.setnext */ @@ -1488,11 +1969,13 @@ static int lua_nodelib_type(lua_State * L) if (lua_type(L,1) == LUA_TNUMBER) { int i = lua_tointeger(L, 1); if (known_node_type(i)) { - lua_pushstring(L, node_data[i].name); + /* lua_pushstring(L, node_data[i].name); */ + lua_push_string_by_index(L, node_data[i].lua); return 1; } } else if (maybe_isnode(L, 1) != NULL) { - lua_pushstring(L,"node"); + /* lua_pushstring(L,"node"); */ + lua_push_string_by_name(L,node); return 1; } lua_pushnil(L); @@ -1501,10 +1984,9 @@ static int lua_nodelib_type(lua_State * L) /* node.new (allocate a new node) */ -static int lua_nodelib_new(lua_State * L) +static halfword lua_nodelib_new_node(lua_State * L) { int i, j; - halfword n = null; int t = lua_type(L, 1); if (t == LUA_TNUMBER) { i = lua_tointeger(L,1); @@ -1536,33 +2018,26 @@ static int lua_nodelib_new(lua_State * L) } } else if (t == LUA_TNUMBER) { j = (int) lua_tointeger(L, 2); + } else if (t == LUA_TSTRING) { + j = get_node_subtype_id_from_name(L,2,node_data[i].subtypes); } else { j = 0; } - n = new_node(i, j); + return new_node(i, j); +} + +static int lua_nodelib_new(lua_State * L) +{ + halfword n = lua_nodelib_new_node(L); lua_nodelib_push_fast(L, n); return 1; } -/* node.direct.new (still with checking) */ +/* node.direct.new */ static int lua_nodelib_direct_new(lua_State * L) { - int j; - halfword n ; - int i = get_valid_node_type_id(L, 1); - if (i == whatsit_node) { - j = -1; - if (lua_gettop(L) > 1) - j = get_valid_node_subtype_id(L, 2); - if (j < 0) - luaL_error(L, "Creating a whatsit requires the subtype number as a second argument"); - } else { - j = 0; - if (lua_gettop(L) > 1) - j = (int) lua_tointeger(L, 2); - } - n = new_node(i, j); + halfword n = lua_nodelib_new_node(L); lua_pushinteger(L,n); return 1; } @@ -1704,9 +2179,6 @@ static int lua_nodelib_remove(lua_State * L) alink(vlink(current)) = t; current = vlink(current); } -#if DEBUG - show_node_links(head, "after"); -#endif /* can be: lua_nodelib_push_fast(L, head); */ lua_pushinteger(L, head); lua_nodelib_push(L); @@ -1843,8 +2315,9 @@ static int lua_nodelib_direct_insert_before(lua_State * L) current = tail_of_list(head); if (head != current) { halfword t = alink(current); - if (t == null || vlink(t) != current) + if (t == null || vlink(t) != current) { set_t_to_prev(head, current); + } couple_nodes(t, n); } couple_nodes(n, current); /* nice but incompatible: couple_nodes(tail_of_list(n),current) */ @@ -2091,8 +2564,10 @@ static int lua_nodelib_hpack(lua_State * L) luaL_error(L, "wrong mode in hpack"); } if (lua_gettop(L) > 3) { - if (lua_type(L, 4) == LUA_TSTRING) { - d = nodelib_getdir(L, 4, 1); + if (lua_type(L, 4) == LUA_TNUMBER) { + d = nodelib_getdirection(L, 4); + } else if (lua_type(L, 4) == LUA_TSTRING) { + d = nodelib_getdir_par(L, 4); } else { lua_pushstring(L, "incorrect 4th argument"); } @@ -2138,8 +2613,10 @@ static int lua_nodelib_direct_hpack(lua_State * L) lua_pushstring(L, "incorrect 3rd argument"); } if (lua_gettop(L) > 3) { - if (lua_type(L, 4) == LUA_TSTRING) { - d = nodelib_getdir(L, 4, 1); + if (lua_type(L, 4) == LUA_TNUMBER) { + d = nodelib_getdirection(L, 4); + } else if (lua_type(L, 4) == LUA_TSTRING) { + d = nodelib_getdir_par(L, 4); } else { lua_pushstring(L, "incorrect 4th argument"); } @@ -2177,8 +2654,10 @@ static int lua_nodelib_vpack(lua_State * L) } if (lua_gettop(L) > 3) { - if (lua_type(L, 4) == LUA_TSTRING) { - d = nodelib_getdir(L, 4, 1); + if (lua_type(L, 4) == LUA_TNUMBER) { + d = nodelib_getdirection(L, 4); + } else if (lua_type(L, 4) == LUA_TSTRING) { + d = nodelib_getdir_par(L, 4); } else { lua_pushstring(L, "incorrect 4th argument"); } @@ -2222,8 +2701,10 @@ static int lua_nodelib_direct_vpack(lua_State * L) } if (lua_gettop(L) > 3) { - if (lua_type(L, 4) == LUA_TSTRING) { - d = nodelib_getdir(L, 4, 1); + if (lua_type(L, 4) == LUA_TNUMBER) { + d = nodelib_getdirection(L, 4); + } else if (lua_type(L, 4) == LUA_TSTRING) { + d = nodelib_getdir_par(L, 4); } else { lua_pushstring(L, "incorrect 4th argument"); } @@ -2269,13 +2750,17 @@ static int lua_nodelib_dimensions(lua_State * L) n = *(check_isnode(L, i)); if (lua_gettop(L) > i && !lua_isnil(L, (i + 1))) { if (lua_type(L, (i + 1)) == LUA_TSTRING) { - d = nodelib_getdir(L, (i + 1), 1); + d = nodelib_getdir_par(L, (i + 1)); } else { p = *(check_isnode(L, (i + 1))); } } - if (lua_gettop(L) > (i + 1) && lua_type(L, (i + 2)) == LUA_TSTRING) { - d = nodelib_getdir(L, (i + 2), 1); + if (lua_gettop(L) > (i + 1)) { + if (lua_type(L, (i + 2)) == LUA_TNUMBER) { + d = nodelib_getdirection(L, (i + 2)); + } else if (lua_type(L, (i + 2)) == LUA_TSTRING) { + d = nodelib_getdir_par(L, (i + 2)); + } } siz = natural_sizes(n, p, g_mult, g_sign, g_order, d); lua_pushinteger(L, siz.wd); @@ -2322,7 +2807,8 @@ static int lua_nodelib_direct_dimensions(lua_State * L) int g_order = normal; int i = 1; int d = -1; - halfword n = null, p = null; + halfword n = null; + halfword p = null; if (top > 3) { i += 3; g_mult = (glue_ratio) lua_tonumber(L, 1); /* integer or float */ @@ -2332,13 +2818,18 @@ static int lua_nodelib_direct_dimensions(lua_State * L) n = (halfword) lua_tointeger(L,i); if (lua_gettop(L) > i && !lua_isnil(L, (i + 1))) { if (lua_type(L, (i + 1)) == LUA_TSTRING) { - d = nodelib_getdir(L, (i + 1), 1); + d = nodelib_getdir_par(L, (i + 1)); } else { p = (halfword) lua_tointeger(L,i+1); } } - if (lua_gettop(L) > (i + 1) && lua_type(L, (i + 2)) == LUA_TSTRING) - d = nodelib_getdir(L, (i + 2), 1); + if (lua_gettop(L) > (i + 1)) { + if (lua_type(L, (i + 2)) == LUA_TNUMBER) { + d = nodelib_getdirection(L, (i + 2)); + } else if (lua_type(L, (i + 2)) == LUA_TSTRING) { + d = nodelib_getdir_par(L, (i + 2)); + } + } siz = natural_sizes(n, p, g_mult, g_sign, g_order, d); lua_pushinteger(L, siz.wd); lua_pushinteger(L, siz.ht); @@ -2383,7 +2874,7 @@ static int lua_nodelib_mlist_to_hlist(lua_State * L) luaL_checkany(L, 3); m = lua_toboolean(L, 3); mlist_to_hlist(n, m, w); - alink(vlink(temp_head)) = null; /*hh-ls */ + alink(vlink(temp_head)) = null; lua_nodelib_push_fast(L, vlink(temp_head)); return 1; } @@ -2407,8 +2898,8 @@ static int lua_nodelib_mfont(lua_State * L) identifiers. It has to do some more work, because not all identifiers are valid for all types of nodes. - If really needed we can optimize this one using a big if .. - .. else like with the getter and setter. + We can make this faster if needed but when this needs to + be called often something is wrong with the code. */ @@ -2438,16 +2929,19 @@ static int get_node_field_id(lua_State * L, int n, int node) } } else { int j; - const char **fields = node_data[t].fields; + field_info *fields ; if (t == whatsit_node) { fields = whatsit_node_data[subtype(node)].fields; + } else { + fields = node_data[t].fields; } if (lua_key_eq(s, list)) { s = lua_key(head); } if (fields != NULL) { - for (j = 0; fields[j] != NULL; j++) { - if (strcmp(s, fields[j]) == 0) { + for (j = 0; fields[j].lua != 0; j++) { + // if (strcmp(s, fields[j]) == 0) { + if (fields[j].name == s) { return j + 3; } } @@ -2549,7 +3043,7 @@ static int lua_nodelib_fields(lua_State * L) { int i = -1; int offset = 2; - const char **fields; + field_info *fields; int t = get_valid_node_type_id(L, 1); if (t == whatsit_node) { t = get_valid_node_subtype_id(L, 2); @@ -2573,26 +3067,63 @@ static int lua_nodelib_fields(lua_State * L) lua_rawseti(L, -2, -1); } if (fields != NULL) { - for (i = 0; fields[i] != NULL; i++) { - lua_pushstring(L, fields[i]); /* todo */ + for (i = 0; fields[i].lua != 0; i++) { + // lua_pushstring(L, fields[i]); /* todo */ + lua_rawgeti(L, LUA_REGISTRYINDEX, fields[i].lua); lua_rawseti(L, -2, (i + offset)); } } return 1; } +static int lua_nodelib_values(lua_State * L) +{ + int i = -1; + subtype_info *values = NULL; + const char *s ; + int t = lua_type(L,1); + if (t == LUA_TSTRING) { + /* + delimiter options (bit set) + delimiter modes (bit set) + */ + s = lua_tostring(L,1); + if (lua_key_eq(s,dir)) values = node_values_dir; + else if (lua_key_eq(s,direction)) values = node_values_dir; + else if (lua_key_eq(s,glue)) values = node_values_fill; + /* backend */ + else if (lua_key_eq(s,pdf_literal)) values = node_values_pdf_literal; + else if (lua_key_eq(s,pdf_action)) values = node_values_pdf_action; + else if (lua_key_eq(s,pdf_window)) values = node_values_pdf_window; + else if (lua_key_eq(s,color_stack)) values = node_values_color_stack; + /* extras */ + else if (lua_key_eq(s,pagestate)) values = other_values_page_states; + } + if (values != NULL) { + lua_checkstack(L, 2); + lua_newtable(L); + for (i = 0; values[i].id >= 0 ; i++) { + lua_rawgeti(L, LUA_REGISTRYINDEX, values[i].lua); + lua_rawseti(L, -2, values[i].id); + } + } else { + lua_pushnil(L); + } + return 1; +} + static int lua_nodelib_subtypes(lua_State * L) { int i = -1; - int l = 0; - const char **subtypes = NULL; + subtype_info *subtypes = NULL; const char *s ; int t = lua_type(L,1); if (t == LUA_TSTRING) { /* official accessors */ s = lua_tostring(L,1); if (lua_key_eq(s,glyph)) subtypes = node_subtypes_glyph; - else if (lua_key_eq(s,glue)) { subtypes = node_subtypes_glue; l = 1; } + else if (lua_key_eq(s,glue)) subtypes = node_subtypes_glue; + else if (lua_key_eq(s,dir)) subtypes = node_subtypes_dir; else if (lua_key_eq(s,boundary)) subtypes = node_subtypes_boundary; else if (lua_key_eq(s,penalty)) subtypes = node_subtypes_penalty; else if (lua_key_eq(s,kern)) subtypes = node_subtypes_kern; @@ -2602,8 +3133,8 @@ static int lua_nodelib_subtypes(lua_State * L) || lua_key_eq(s,vlist)) subtypes = node_subtypes_list; /* too many but ok as reserved */ else if (lua_key_eq(s,adjust)) subtypes = node_subtypes_adjust; else if (lua_key_eq(s,disc)) subtypes = node_subtypes_disc; - else if (lua_key_eq(s,fill)) subtypes = node_subtypes_fill; - else if (lua_key_eq(s,leader)) { subtypes = node_subtypes_leader; l = 2; } + else if (lua_key_eq(s,fill)) subtypes = node_values_fill; + else if (lua_key_eq(s,leader)) subtypes = node_subtypes_leader; else if (lua_key_eq(s,marginkern)) subtypes = node_subtypes_marginkern; else if (lua_key_eq(s,math)) subtypes = node_subtypes_math; else if (lua_key_eq(s,noad)) subtypes = node_subtypes_noad; @@ -2611,13 +3142,14 @@ static int lua_nodelib_subtypes(lua_State * L) else if (lua_key_eq(s,accent)) subtypes = node_subtypes_accent; else if (lua_key_eq(s,fence)) subtypes = node_subtypes_fence; /* backend */ - else if (lua_key_eq(s,pdf_destination)) subtypes = node_subtypes_pdf_destination; - else if (lua_key_eq(s,pdf_literal)) subtypes = node_subtypes_pdf_literal; + else if (lua_key_eq(s,pdf_destination)) subtypes = node_values_pdf_destination; + else if (lua_key_eq(s,pdf_literal)) subtypes = node_values_pdf_literal; } else if (t == LUA_TNUMBER) { /* maybe */ t = lua_tointeger(L,1); if (t == glyph_node) subtypes = node_subtypes_glyph; - else if (t == glue_node) { subtypes = node_subtypes_glue; l = 1; } + else if (t == glue_node) subtypes = node_subtypes_glue; + else if (t == dir_node) subtypes = node_subtypes_dir; else if (t == boundary_node) subtypes = node_subtypes_boundary; else if (t == penalty_node) subtypes = node_subtypes_penalty; else if (t == kern_node) subtypes = node_subtypes_kern; @@ -2626,7 +3158,7 @@ static int lua_nodelib_subtypes(lua_State * L) || (t == vlist_node)) subtypes = node_subtypes_list; else if (t == adjust_node) subtypes = node_subtypes_adjust; else if (t == disc_node) subtypes = node_subtypes_disc; - else if (t == glue_spec_node) subtypes = node_subtypes_fill; + else if (t == glue_spec_node) subtypes = node_values_fill; else if (t == margin_kern_node) subtypes = node_subtypes_marginkern; else if (t == math_node) subtypes = node_subtypes_math; else if (t == simple_noad) subtypes = node_subtypes_noad; @@ -2634,29 +3166,15 @@ static int lua_nodelib_subtypes(lua_State * L) else if (t == accent_noad) subtypes = node_subtypes_accent; else if (t == fence_noad) subtypes = node_subtypes_fence; /* backend */ - else if (t == pdf_dest_node) subtypes = node_subtypes_pdf_destination; - else if (t == pdf_literal_node) subtypes = node_subtypes_pdf_literal; + else if (t == pdf_dest_node) subtypes = node_values_pdf_destination; + else if (t == pdf_literal_node) subtypes = node_values_pdf_literal; } if (subtypes != NULL) { lua_checkstack(L, 2); lua_newtable(L); - if (l < 2) { - for (i = 0; subtypes[i] != NULL; i++) { - lua_pushstring(L, subtypes[i]); /* todo */ - lua_rawseti(L, -2, i); - } - } - if (l > 0) { - /* add math states */ - for (i = 0; node_subtypes_mathglue[i] != NULL; i++) { - lua_pushstring(L, node_subtypes_mathglue[i]); /* todo */ - lua_rawseti(L, -2, 98 + i); - } - /* add leaders */ - for (i = 0; node_subtypes_leader[i] != NULL; i++) { - lua_pushstring(L, node_subtypes_leader[i]); /* todo */ - lua_rawseti(L, -2, 100 + i); - } + for (i = 0; subtypes[i].id >= 0 ; i++) { + lua_rawgeti(L, LUA_REGISTRYINDEX, subtypes[i].lua); + lua_rawseti(L, -2, subtypes[i].id); } } else { lua_pushnil(L); @@ -2823,7 +3341,10 @@ static int lua_nodelib_get_attribute(lua_State * L) if (p != null) { p = vlink(p); if (p != null) { - int i = lua_tointeger(L, 2); + int i = 0; + if (lua_gettop(L) > 1) { + i = lua_tointeger(L, 2); + } while (p != null) { if (attribute_id(p) == i) { int ret = attribute_value(p); @@ -2895,7 +3416,10 @@ static int lua_nodelib_direct_get_attribute(lua_State * L) if (p != null) { p = vlink(p); if (p != null) { - int i = lua_tointeger(L, 2); + int i = 0; + if (lua_gettop(L) > 1) { + i = lua_tointeger(L, 2); + } while (p != null) { if (attribute_id(p) == i) { int ret = attribute_value(p); @@ -3049,10 +3573,24 @@ static int lua_nodelib_direct_getwidth(lua_State * L) if (t == hlist_node || t == vlist_node || t == rule_node) { lua_pushinteger(L,width(n)); } else if (t == glyph_node) { - lua_pushinteger(L, char_width(font(n),character(n))); + if (lua_toboolean(L,2)) { + lua_pushnumber(L, (1+ex_glyph(n)/1000) * char_width(font(n),character(n))); + lua_pushinteger(L, ex_glyph(n)); + return 2; + } else { + lua_pushinteger(L, char_width(font(n),character(n))); + } } else if (t == glue_node || t == glue_spec_node || t == math_node || t == ins_node) { lua_pushinteger(L,width(n)); - } else if (t == kern_node || t == margin_kern_node) { + } else if (t == kern_node) { + if (lua_toboolean(L,2)) { + lua_pushnumber(L, (1+ex_kern(n)/1000) * width(n)); + lua_pushinteger(L, ex_kern(n)); + return 2; + } else { + lua_pushinteger(L, width(n)); + } + } else if (t == margin_kern_node) { lua_pushinteger(L,width(n)); } else if (t == unset_node) { lua_pushinteger(L,width(n)); @@ -3071,7 +3609,8 @@ static int lua_nodelib_direct_setwidth(lua_State * L) if (n) { halfword t = type(n); 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) { + t == kern_node || t == margin_kern_node || t == ins_node || t == unset_node || + t == fraction_noad || t == radical_noad ) { if (lua_type(L, 2) == LUA_TNUMBER) { width(n) = lua_roundnumber(L,2); } else { @@ -3093,6 +3632,8 @@ static int lua_nodelib_direct_getheight(lua_State * L) lua_pushinteger(L, char_height(font(n),character(n))); } else if (t == unset_node || t == ins_node) { lua_pushinteger(L,height(n)); + } else if (t == fence_noad) { + lua_pushinteger(L,delimiterheight(n)); } else { lua_pushnil(L); } @@ -3107,12 +3648,14 @@ static int lua_nodelib_direct_setheight(lua_State * L) halfword n = lua_tointeger(L, 1); if (n) { halfword t = type(n); + halfword h = 0; + if (lua_type(L, 2) == LUA_TNUMBER) { + h = lua_roundnumber(L,2); + } if (t == hlist_node || t == vlist_node || t == rule_node || t == unset_node) { - if (lua_type(L, 2) == LUA_TNUMBER) { - height(n) = lua_roundnumber(L,2); - } else { - height(n) = 0; - } + height(n) = h; + } else if (t == fence_noad) { + delimiterheight(n) = h; } } return 0; @@ -3129,6 +3672,8 @@ static int lua_nodelib_direct_getdepth(lua_State * L) lua_pushinteger(L, char_depth(font(n),character(n))); } else if (t == unset_node || t == ins_node) { lua_pushinteger(L,depth(n)); + } else if (t == fence_noad) { + lua_pushinteger(L,delimiterdepth(n)); } else { lua_pushnil(L); } @@ -3143,12 +3688,14 @@ static int lua_nodelib_direct_setdepth(lua_State * L) halfword n = lua_tointeger(L, 1); if (n) { halfword t = type(n); + halfword d = 0; + if (lua_type(L, 2) == LUA_TNUMBER) { + d = lua_roundnumber(L,2); + } if (t == hlist_node || t == vlist_node || t == rule_node || t == unset_node) { - if (lua_type(L, 2) == LUA_TNUMBER) { - depth(n) = lua_roundnumber(L,2); - } else { - depth(n) = 0; - } + depth(n) = d; + } else if (t == fence_noad) { + delimiterdepth(n) = d; } } return 0; @@ -3324,9 +3871,51 @@ static int nodelib_aux_nil(lua_State * L) return 1; } -/* node.direct.traverse_id */ /* node.direct.traverse */ +/* node.direct.traverse_id */ /* node.direct.traverse_char */ +/* node.direct.traverse_glyph */ +/* node.direct.traverse_list */ + +static int nodelib_direct_aux_next(lua_State * L) +{ + halfword t; + if (lua_isnil(L, 2)) { + t = lua_tointeger(L,1) ; + lua_settop(L,1); + } else { + t = lua_tointeger(L,2) ; + t = vlink(t); + lua_settop(L,2); + } + if (t == null) { + lua_pushnil(L); + return 1; + } else { + lua_pushinteger(L,t); + lua_pushinteger(L,type(t)); + lua_pushinteger(L,subtype(t)); + return 3; + } +} + +static int lua_nodelib_direct_traverse(lua_State * L) +{ + halfword n; + if (lua_isnil(L, 1)) { + lua_pushcclosure(L, nodelib_aux_nil, 0); + return 1; + } + n = (halfword) lua_tointeger(L, 1); + if (n == null) { + lua_pushcclosure(L, nodelib_aux_nil, 0); + return 1; + } + lua_pushcclosure(L, nodelib_direct_aux_next, 0); + lua_pushinteger(L,n); + lua_pushnil(L); + return 3; +} static int nodelib_direct_aux_next_filtered(lua_State * L) { @@ -3340,18 +3929,17 @@ static int nodelib_direct_aux_next_filtered(lua_State * L) t = vlink(t); lua_settop(L,2); } - while (1) { - if (t == null) { - break; - } else if (type(t) == i) { - lua_pushinteger(L,t); - return 1; - } else { - t = vlink(t); - } + while (t != null && type(t) != i) { + t = vlink(t); + } + if (t == null) { + lua_pushnil(L); + return 1; + } else { + lua_pushinteger(L,t); + lua_pushinteger(L,subtype(t)); + return 2; } - lua_pushnil(L); - return 1; } static int lua_nodelib_direct_traverse_filtered(lua_State * L) @@ -3371,7 +3959,7 @@ static int lua_nodelib_direct_traverse_filtered(lua_State * L) return 3; } -static int nodelib_direct_aux_next(lua_State * L) +static int nodelib_direct_aux_next_char(lua_State * L) { halfword t; /* traverser */ if (lua_isnil(L, 2)) { /* first call */ @@ -3382,15 +3970,21 @@ static int nodelib_direct_aux_next(lua_State * L) t = vlink(t); lua_settop(L,2); } + while (! ((t == null) || (type(t) == glyph_node && subtype(t) < 256))) { + t = vlink(t); + } if (t == null) { lua_pushnil(L); + return 1; } else { lua_pushinteger(L,t); + lua_pushinteger(L,character(t)); + lua_pushinteger(L,font(t)); + return 3; } - return 1; } -static int lua_nodelib_direct_traverse(lua_State * L) +static int lua_nodelib_direct_traverse_char(lua_State * L) { halfword n; if (lua_isnil(L, 1)) { @@ -3402,13 +3996,13 @@ static int lua_nodelib_direct_traverse(lua_State * L) lua_pushcclosure(L, nodelib_aux_nil, 0); return 1; } - lua_pushcclosure(L, nodelib_direct_aux_next, 0); + lua_pushcclosure(L, nodelib_direct_aux_next_char, 0); lua_pushinteger(L,n); lua_pushnil(L); return 3; } -static int nodelib_direct_aux_next_char(lua_State * L) +static int nodelib_direct_aux_next_glyph(lua_State * L) { halfword t; /* traverser */ if (lua_isnil(L, 2)) { /* first call */ @@ -3419,21 +4013,21 @@ static int nodelib_direct_aux_next_char(lua_State * L) t = vlink(t); lua_settop(L,2); } - while (1) { - if (t == null) { - break; - } else if ((type(t) == glyph_node) && (subtype(t) < 256)){ - lua_pushinteger(L,t); - return 1; - } else { - t = vlink(t); - } + while (t != null && type(t) != glyph_node) { + t = vlink(t); + } + if (t == null) { + lua_pushnil(L); + return 1; + } else { + lua_pushinteger(L,t); + lua_pushinteger(L,character(t)); + lua_pushinteger(L,font(t)); + return 3; } - lua_pushnil(L); - return 1; } -static int lua_nodelib_direct_traverse_char(lua_State * L) +static int lua_nodelib_direct_traverse_glyph(lua_State * L) { halfword n; if (lua_isnil(L, 1)) { @@ -3445,15 +4039,98 @@ static int lua_nodelib_direct_traverse_char(lua_State * L) lua_pushcclosure(L, nodelib_aux_nil, 0); return 1; } - lua_pushcclosure(L, nodelib_direct_aux_next_char, 0); + lua_pushcclosure(L, nodelib_direct_aux_next_glyph, 0); lua_pushinteger(L,n); lua_pushnil(L); return 3; } -/* node.traverse_id */ +static int nodelib_direct_aux_next_list(lua_State * L) +{ + halfword t; /* traverser */ + if (lua_isnil(L, 2)) { /* first call */ + t = lua_tointeger(L,1) ; + lua_settop(L,1); + } else { + t = lua_tointeger(L,2) ; + t = vlink(t); + lua_settop(L,2); + } + while (t != null && type(t) != hlist_node && type(t) != vlist_node) { + t = vlink(t); + } + if (t == null) { + lua_pushnil(L); + return 1; + } else { + lua_pushinteger(L,t); + lua_pushinteger(L,type(t)); + lua_pushinteger(L,subtype(t)); + nodelib_pushdirect_or_nil(list_ptr(t)); + return 4; + } +} + +static int lua_nodelib_direct_traverse_list(lua_State * L) +{ + halfword n; + if (lua_isnil(L, 1)) { + lua_pushcclosure(L, nodelib_aux_nil, 0); + return 1; + } + n = (halfword) lua_tointeger(L, 1); + if (n == null) { + lua_pushcclosure(L, nodelib_aux_nil, 0); + return 1; + } + lua_pushcclosure(L, nodelib_direct_aux_next_list, 1); + lua_pushinteger(L, n); + lua_pushnil(L); + return 3; +} + /* node.traverse */ +/* node.traverse_id */ /* node.traverse_char */ +/* node.traverse_glyph */ +/* node.traverse_list */ + +static int nodelib_aux_next(lua_State * L) +{ + halfword t; + halfword *a; + if (lua_isnil(L, 2)) { + t = *check_isnode(L, 1); + lua_settop(L,1); + } else { + t = *check_isnode(L, 2); + t = vlink(t); + lua_settop(L,2); + } + if (t == null) { + lua_pushnil(L); + return 1; + } else { + fast_metatable_top(t); + lua_pushinteger(L,type(t)); + lua_pushinteger(L,subtype(t)); + return 3; + } +} + +static int lua_nodelib_traverse(lua_State * L) +{ + halfword n; + if (lua_isnil(L, 1)) { + lua_pushcclosure(L, nodelib_aux_nil, 0); + return 1; + } + n = *check_isnode(L, 1); + lua_pushcclosure(L, nodelib_aux_next, 0); + lua_nodelib_push_fast(L, n); + lua_pushnil(L); + return 3; +} static int nodelib_aux_next_filtered(lua_State * L) { @@ -3473,10 +4150,12 @@ static int nodelib_aux_next_filtered(lua_State * L) } if (t == null) { lua_pushnil(L); + return 1; } else { fast_metatable_top(t); + lua_pushinteger(L,subtype(t)); + return 2; } - return 1; } static int lua_nodelib_traverse_filtered(lua_State * L) @@ -3494,10 +4173,10 @@ static int lua_nodelib_traverse_filtered(lua_State * L) return 3; } -static int nodelib_aux_next(lua_State * L) +static int nodelib_aux_next_char(lua_State * L) { halfword t; /* traverser */ - halfword *a; /* a or *a */ + halfword *a; if (lua_isnil(L, 2)) { /* first call */ t = *check_isnode(L, 1); lua_settop(L,1); @@ -3506,15 +4185,21 @@ static int nodelib_aux_next(lua_State * L) t = vlink(t); lua_settop(L,2); } + while (! ((t == null) || (type(t) == glyph_node && subtype(t) < 256))) { + t = vlink(t); + } if (t == null) { lua_pushnil(L); + return 1; } else { fast_metatable_top(t); + lua_pushinteger(L,character(t)); + lua_pushinteger(L,font(t)); + return 3; } - return 1; } -static int lua_nodelib_traverse(lua_State * L) +static int lua_nodelib_traverse_char(lua_State * L) { halfword n; if (lua_isnil(L, 1)) { @@ -3522,13 +4207,13 @@ static int lua_nodelib_traverse(lua_State * L) return 1; } n = *check_isnode(L, 1); - lua_pushcclosure(L, nodelib_aux_next, 0); + lua_pushcclosure(L, nodelib_aux_next_char, 0); lua_nodelib_push_fast(L, n); lua_pushnil(L); return 3; } -static int nodelib_aux_next_char(lua_State * L) +static int nodelib_aux_next_glyph(lua_State * L) { halfword t; /* traverser */ halfword *a; @@ -3540,20 +4225,21 @@ static int nodelib_aux_next_char(lua_State * L) t = vlink(t); lua_settop(L,2); } - while (1) { - if (t == null) { - break; - } else if ((type(t) == glyph_node) && (subtype(t) < 256)){ - fast_metatable_top(t); - return 1; - } else { - t = vlink(t); - } + while (t != null && type(t) != glyph_node) { + t = vlink(t); + } + if (t == null) { + lua_pushnil(L); + return 1; + } else { + fast_metatable_top(t); + lua_pushinteger(L,character(t)); + lua_pushinteger(L,font(t)); + return 3; } - return 1; } -static int lua_nodelib_traverse_char(lua_State * L) +static int lua_nodelib_traverse_glyph(lua_State * L) { halfword n; if (lua_isnil(L, 1)) { @@ -3561,7 +4247,48 @@ static int lua_nodelib_traverse_char(lua_State * L) return 1; } n = *check_isnode(L, 1); - lua_pushcclosure(L, nodelib_aux_next_char, 0); + lua_pushcclosure(L, nodelib_aux_next_glyph, 0); + lua_nodelib_push_fast(L, n); + lua_pushnil(L); + return 3; +} + +static int nodelib_aux_next_list(lua_State * L) +{ + halfword t; /* traverser */ + halfword *a; + if (lua_isnil(L, 2)) { /* first call */ + t = *check_isnode(L, 1); + lua_settop(L,1); + } else { + t = *check_isnode(L, 2); + t = vlink(t); + lua_settop(L,2); + } + while (t != null && type(t) != hlist_node && type(t) != vlist_node) { + t = vlink(t); + } + if (t == null) { + lua_pushnil(L); + return 1; + } else { + fast_metatable_top(t); + lua_pushinteger(L,type(t)); + lua_pushinteger(L,subtype(t)); + fast_metatable_or_nil(list_ptr(t)); + return 4; + } +} + +static int lua_nodelib_traverse_list(lua_State * L) +{ + halfword n; + if (lua_isnil(L, 1)) { + lua_pushcclosure(L, nodelib_aux_nil, 0); + return 1; + } + n = *check_isnode(L, 1); + lua_pushcclosure(L, nodelib_aux_next_list, 1); lua_nodelib_push_fast(L, n); lua_pushnil(L); return 3; @@ -3638,46 +4365,6 @@ static int lua_nodelib_count(lua_State * L) return do_lua_nodelib_count(L, m, i, n); } -/* getting and setting fields (helpers) */ - -int nodelib_getlist(lua_State * L, int n) -{ - if (lua_isuserdata(L, n)) { - halfword m = *check_isnode(L, n); - return m; - } else { - return null; - } -} - -int nodelib_getdir(lua_State * L, int n, int absolute_only) -{ - if (lua_type(L, n) == LUA_TSTRING) { - const char *s = lua_tostring(L, n); - RETURN_DIR_VALUES(TLT); - RETURN_DIR_VALUES(TRT); - RETURN_DIR_VALUES(LTL); - RETURN_DIR_VALUES(RTT); - luaL_error(L, "Bad direction specifier %s", s); - } else { - luaL_error(L, "Direction specifiers have to be strings"); - } - return 0; -} - -static str_number nodelib_getstring(lua_State * L, int a) -{ - size_t k; - const char *s = lua_tolstring(L, a, &k); - return maketexlstring(s, k); -} - -static int nodelib_cantset(lua_State * L, int n, const char *s) -{ - luaL_error(L,"You cannot set field %s in a node of type %s",s,node_data[type(n)].name); - return 0; -} - /* node.direct.getfield */ static void lua_nodelib_getfield_whatsit(lua_State * L, int n, const char *s) @@ -3690,54 +4377,48 @@ static void lua_nodelib_getfield_whatsit(lua_State * L, int n, const char *s) lua_pushinteger(L, user_node_type(n)); } else if (lua_key_eq(s, value)) { switch (user_node_type(n)) { - case 'a': - nodelib_pushlist(L, user_node_value(n)); - break; - case 'd': - lua_pushinteger(L, user_node_value(n)); - break; - case 'l': - if (user_node_value(n) != 0) { - lua_rawgeti(L, LUA_REGISTRYINDEX, user_node_value(n)); - } else { - lua_pushnil(L); - } - break; - case 'n': - nodelib_pushlist(L, user_node_value(n)); - break; - case 's': - nodelib_pushstring(L, user_node_value(n)); - break; - case 't': - tokenlist_to_lua(L, user_node_value(n)); - break; - default: - lua_pushinteger(L, user_node_value(n)); - break; + case 'a': + nodelib_pushlist(L, user_node_value(n)); + break; + case 'd': + lua_pushinteger(L, user_node_value(n)); + break; + case 'l': + if (user_node_value(n) != 0) { + lua_rawgeti(L, LUA_REGISTRYINDEX, user_node_value(n)); + } else { + lua_pushnil(L); + } + break; + case 'n': + nodelib_pushlist(L, user_node_value(n)); + break; + case 's': + nodelib_pushstring(L, user_node_value(n)); + break; + case 't': + tokenlist_to_lua(L, user_node_value(n)); + break; + default: + lua_pushinteger(L, user_node_value(n)); + break; } } else { lua_pushnil(L); } } else if (t == pdf_literal_node) { + /*tex The |string| key is obsolete. */ if (lua_key_eq(s, mode)) { lua_pushinteger(L, pdf_literal_mode(n)); - } else if (lua_key_eq(s, data)) { - if (pdf_literal_type(n) == lua_refid_literal) { - lua_rawgeti(L, LUA_REGISTRYINDEX, pdf_literal_data(n)); - } else { - tokenlist_to_luastring(L, pdf_literal_data(n)); - } + } else if (lua_key_eq(s, data) || lua_key_eq(s, token) || lua_key_eq(s, string)) { + get_pdf_literal_direct_value(L, n); } else { lua_pushnil(L); } } else if (t == late_lua_node) { - if (lua_key_eq(s, string) || lua_key_eq(s, data)) { - if (late_lua_type(n) == lua_refid_literal) { - lua_rawgeti(L, LUA_REGISTRYINDEX, late_lua_data(n)); - } else { - tokenlist_to_luastring(L, late_lua_data(n)); - } + /*tex The |string| key is obsolete. */ + if (lua_key_eq(s, data) || lua_key_eq(s, token) || lua_key_eq(s, string)) { + get_late_lua_direct_value(L,n); } else if (lua_key_eq(s, name)) { tokenlist_to_luastring(L, late_lua_name(n)); } else { @@ -3782,7 +4463,7 @@ static void lua_nodelib_getfield_whatsit(lua_State * L, int n, const char *s) } } else if (t == pdf_setmatrix_node) { if (lua_key_eq(s, data)) { - tokenlist_to_luastring(L, pdf_setmatrix_data(n)); + get_pdf_setmatrix_direct_value(L,n); } else { lua_pushnil(L); } @@ -3806,13 +4487,13 @@ static void lua_nodelib_getfield_whatsit(lua_State * L, int n, const char *s) if (lua_key_eq(s, stream)) { lua_pushinteger(L, write_stream(n)); } else if (lua_key_eq(s, data)) { - tokenlist_to_lua(L, write_tokens(n)); + get_write_direct_value(L,n); } else { lua_pushnil(L); } } else if (t == special_node) { if (lua_key_eq(s, data)) { - tokenlist_to_luastring(L, write_tokens(n)); + get_special_direct_value(L,n); } else { lua_pushnil(L); } @@ -3978,8 +4659,8 @@ static int lua_nodelib_fast_getfield(lua_State * L) lua_pushinteger(L, x_displace(n)); } else if (lua_key_eq(s, yoffset)) { lua_pushinteger(L, y_displace(n)); - } else if (lua_key_eq(s, xadvance)) { - lua_pushinteger(L, x_advance(n)); + } else if (lua_key_eq(s, data)) { + lua_pushinteger(L, glyph_node_data(n)); } else if (lua_key_eq(s, width)) { lua_pushinteger(L, char_width(font(n),character(n))); } else if (lua_key_eq(s, height)) { @@ -4013,6 +4694,8 @@ static int lua_nodelib_fast_getfield(lua_State * L) lua_pushinteger(L, height(n)); } else if (lua_key_eq(s, depth)) { lua_pushinteger(L, depth(n)); + } else if (lua_key_eq(s, direction)) { + lua_pushinteger(L, box_dir(n)); } else if (lua_key_eq(s, dir)) { lua_push_dir_par(L, box_dir(n)); } else if (lua_key_eq(s, shift)) { @@ -4086,6 +4769,12 @@ static int lua_nodelib_fast_getfield(lua_State * L) lua_pushinteger(L, height(n)); } else if (lua_key_eq(s, depth)) { lua_pushinteger(L, depth(n)); + } else if (lua_key_eq(s, left)) { + lua_pushinteger(L,rule_left(n)); + } else if (lua_key_eq(s, right)) { + lua_pushinteger(L,rule_right(n)); + } else if (lua_key_eq(s, direction)) { + lua_pushinteger(L, rule_dir(n)); } else if (lua_key_eq(s, dir)) { lua_push_dir_par(L, rule_dir(n)); } else if (lua_key_eq(s, index)) { @@ -4096,8 +4785,10 @@ static int lua_nodelib_fast_getfield(lua_State * L) lua_pushnil(L); } } else if (t == dir_node) { - if (lua_key_eq(s, dir)) { - lua_push_dir_text(L, dir_dir(n)); + if (lua_key_eq(s, direction)) { + lua_pushinteger(L, dir_dir(n)); + } else if (lua_key_eq(s, dir)) { + lua_push_dir_text(L, dir_dir(n),subtype(n)); } else if (lua_key_eq(s, level)) { lua_pushinteger(L, dir_level(n)); } else if (lua_key_eq(s, subtype)) { /* can be used for anything */ @@ -4110,6 +4801,8 @@ static int lua_nodelib_fast_getfield(lua_State * L) lua_pushinteger(L, local_pen_inter(n)); } else if (lua_key_eq(s, pen_broken)) { lua_pushinteger(L, local_pen_broken(n)); + } else if (lua_key_eq(s, direction)) { + lua_pushinteger(L, local_par_dir(n)); } else if (lua_key_eq(s, dir)) { lua_push_dir_par(L, local_par_dir(n)); } else if (lua_key_eq(s, box_left)) { @@ -4241,6 +4934,8 @@ static int lua_nodelib_fast_getfield(lua_State * L) fast_metatable_or_nil(right_delimiter(n)); } else if (lua_key_eq(s, middle)) { fast_metatable_or_nil(middle_delimiter(n)); + } else if (lua_key_eq(s, fam)) { + lua_pushinteger(L, fraction_fam(n)); } else if (lua_key_eq(s, options)) { lua_pushinteger(L, fractionoptions(n)); } else { @@ -4409,6 +5104,8 @@ static int lua_nodelib_fast_getfield(lua_State * L) lua_pushinteger(L, height(n)); } else if (lua_key_eq(s, depth)) { lua_pushinteger(L, depth(n)); + } else if (lua_key_eq(s, direction)) { + lua_pushinteger(L, box_dir(n)); } else if (lua_key_eq(s, dir)) { lua_push_dir_par(L, box_dir(n)); } else if (lua_key_eq(s, shrink)) { @@ -4477,55 +5174,23 @@ static void lua_nodelib_direct_getfield_whatsit(lua_State * L, int n, const char } else if (lua_key_eq(s, type)) { lua_pushinteger(L, user_node_type(n)); } else if (lua_key_eq(s, value)) { - switch (user_node_type(n)) { - case 'a': - nodelib_pushdirect(user_node_value(n)); - break; - case 'd': - lua_pushinteger(L, user_node_value(n)); - break; - case 'l': - if (user_node_value(n) != 0) { - lua_rawgeti(L, LUA_REGISTRYINDEX, user_node_value(n)); - } else { - lua_pushnil(L); - } - break; - case 'n': - nodelib_pushdirect(user_node_value(n)); - break; - case 's': - nodelib_pushstring(L, user_node_value(n)); - break; - case 't': - tokenlist_to_lua(L, user_node_value(n)); - break; - default: - lua_pushinteger(L, user_node_value(n)); - break; - } + get_user_node_direct_value(L, n); } else { lua_pushnil(L); } } else if (t == pdf_literal_node) { + /*tex The |string| key is obsolete. */ if (lua_key_eq(s, mode)) { lua_pushinteger(L, pdf_literal_mode(n)); - } else if (lua_key_eq(s, data)) { - if (pdf_literal_type(n) == lua_refid_literal) { - lua_rawgeti(L, LUA_REGISTRYINDEX, pdf_literal_data(n)); - } else { - tokenlist_to_luastring(L, pdf_literal_data(n)); - } + } else if (lua_key_eq(s, data) || lua_key_eq(s, token) || lua_key_eq(s, string)) { + get_pdf_literal_direct_value(L, n); } else { lua_pushnil(L); } } else if (t == late_lua_node) { - if (lua_key_eq(s, string) || lua_key_eq(s, data)) { - if (late_lua_type(n) == lua_refid_literal) { - lua_rawgeti(L, LUA_REGISTRYINDEX, late_lua_data(n)); - } else { - tokenlist_to_luastring(L, late_lua_data(n)); - } + /*tex The |string| key is obsolete. */ + if (lua_key_eq(s, data) || lua_key_eq(s, token) || lua_key_eq(s, string)) { + get_late_lua_direct_value(L,n); } else if (lua_key_eq(s, name)) { tokenlist_to_luastring(L, late_lua_name(n)); } else { @@ -4570,7 +5235,7 @@ static void lua_nodelib_direct_getfield_whatsit(lua_State * L, int n, const char } } else if (t == pdf_setmatrix_node) { if (lua_key_eq(s, data)) { - tokenlist_to_luastring(L, pdf_setmatrix_data(n)); + get_pdf_setmatrix_direct_value(L,n); } else { lua_pushnil(L); } @@ -4594,13 +5259,13 @@ static void lua_nodelib_direct_getfield_whatsit(lua_State * L, int n, const char if (lua_key_eq(s, stream)) { lua_pushinteger(L, write_stream(n)); } else if (lua_key_eq(s, data)) { - tokenlist_to_lua(L, write_tokens(n)); + get_write_direct_value(L,n); } else { lua_pushnil(L); } } else if (t == special_node) { if (lua_key_eq(s, data)) { - tokenlist_to_luastring(L, write_tokens(n)); + get_special_direct_value(L,n); } else { lua_pushnil(L); } @@ -4751,8 +5416,8 @@ static int lua_nodelib_direct_getfield(lua_State * L) lua_pushinteger(L, x_displace(n)); } else if (lua_key_eq(s, yoffset)) { lua_pushinteger(L, y_displace(n)); - } else if (lua_key_eq(s, xadvance)) { - lua_pushinteger(L, x_advance(n)); + } else if (lua_key_eq(s, data)) { + lua_pushinteger(L, glyph_node_data(n)); } else if (lua_key_eq(s, width)) { lua_pushinteger(L, char_width(font(n),character(n))); } else if (lua_key_eq(s, height)) { @@ -4784,6 +5449,8 @@ static int lua_nodelib_direct_getfield(lua_State * L) lua_pushinteger(L, height(n)); } else if (lua_key_eq(s, depth)) { lua_pushinteger(L, depth(n)); + } else if (lua_key_eq(s, direction)) { + lua_pushinteger(L, box_dir(n)); } else if (lua_key_eq(s, dir)) { lua_push_dir_par(L, box_dir(n)); } else if (lua_key_eq(s, shift)) { @@ -4847,6 +5514,12 @@ static int lua_nodelib_direct_getfield(lua_State * L) lua_pushinteger(L, height(n)); } else if (lua_key_eq(s, depth)) { lua_pushinteger(L, depth(n)); + } else if (lua_key_eq(s, left)) { + lua_pushinteger(L,rule_left(n)); + } else if (lua_key_eq(s, right)) { + lua_pushinteger(L,rule_right(n)); + } else if (lua_key_eq(s, direction)) { + lua_pushinteger(L, rule_dir(n)); } else if (lua_key_eq(s, dir)) { lua_push_dir_par(L, rule_dir(n)); } else if (lua_key_eq(s, index)) { @@ -4857,8 +5530,10 @@ static int lua_nodelib_direct_getfield(lua_State * L) lua_pushnil(L); } } else if (t == dir_node) { - if (lua_key_eq(s, dir)) { - lua_push_dir_text(L, dir_dir(n)); + if (lua_key_eq(s, direction)) { + lua_pushinteger(L, dir_dir(n)); + } else if (lua_key_eq(s, dir)) { + lua_push_dir_text(L, dir_dir(n), subtype(n)); } else if (lua_key_eq(s, level)) { lua_pushinteger(L, dir_level(n)); } else if (lua_key_eq(s, subtype)) { /* can be used for anything */ @@ -4871,6 +5546,8 @@ static int lua_nodelib_direct_getfield(lua_State * L) lua_pushinteger(L, local_pen_inter(n)); } else if (lua_key_eq(s, pen_broken)) { lua_pushinteger(L, local_pen_broken(n)); + } else if (lua_key_eq(s, direction)) { + lua_pushinteger(L, local_par_dir(n)); } else if (lua_key_eq(s, dir)) { lua_push_dir_par(L, local_par_dir(n)); } else if (lua_key_eq(s, box_left)) { @@ -4969,6 +5646,8 @@ static int lua_nodelib_direct_getfield(lua_State * L) nodelib_pushdirect_or_nil(right_delimiter(n)); } else if (lua_key_eq(s, middle)) { nodelib_pushdirect_or_nil(middle_delimiter(n)); + } else if (lua_key_eq(s, fam)) { + lua_pushinteger(L, fraction_fam(n)); } else if (lua_key_eq(s, options)) { lua_pushinteger(L, fractionoptions(n)); } else { @@ -5111,6 +5790,8 @@ static int lua_nodelib_direct_getfield(lua_State * L) lua_pushinteger(L, height(n)); } else if (lua_key_eq(s, depth)) { lua_pushinteger(L, depth(n)); + } else if (lua_key_eq(s, direction)) { + lua_pushinteger(L, box_dir(n)); } else if (lua_key_eq(s, dir)) { lua_push_dir_par(L, box_dir(n)); } else if (lua_key_eq(s, shrink)) { @@ -5213,7 +5894,7 @@ static int lua_nodelib_equal(lua_State * L) static int font_tex_ligaturing(lua_State * L) { /* on the stack are two nodes and a direction */ - /* hh-ls: we need to deal with prev nodes when a range starts with a ligature */ + /* we need to deal with prev nodes when a range starts with a ligature */ halfword tmp_head; halfword h; halfword t = null; @@ -5254,7 +5935,7 @@ static int font_tex_ligaturing(lua_State * L) static int font_tex_direct_ligaturing(lua_State * L) { /* on the stack are two nodes and a direction */ - /* hh-ls: we need to deal with prev nodes when a range starts with a ligature */ + /* we need to deal with prev nodes when a range starts with a ligature */ halfword tmp_head; halfword h; halfword t = null; @@ -5805,57 +6486,29 @@ static int lua_nodelib_direct_tonode(lua_State * L) /* node.setfield */ -#define cleanup_late_lua(n) do { \ - if (late_lua_data(n) != 0) { \ - if (late_lua_type(n) == normal) { \ - delete_token_ref(late_lua_data(n)); \ - } else if (late_lua_type(n) == lua_refid_literal) { \ - luaL_unref(L, LUA_REGISTRYINDEX,late_lua_data(n)); \ - } \ - } \ -} while (0) - -#define cleanup_late_lua_name(n) do { \ - if (late_lua_name(n) != 0) { \ - delete_token_ref(late_lua_name(n)); \ - } \ -} while (0) - static int lua_nodelib_setfield_whatsit(lua_State * L, int n, const char *s) { int t = subtype(n); if (t == pdf_literal_node) { + /*tex The |string| key is obsolete. */ if (lua_key_eq(s, mode)) { pdf_literal_mode(n) = (quarterword) lua_tointeger(L, 3); - } else if (lua_key_eq(s, data)) { - if (ini_version) { - pdf_literal_data(n) = nodelib_gettoks(L, 3); - } else { - lua_pushvalue(L, 3); - pdf_literal_data(n) = luaL_ref(L, LUA_REGISTRYINDEX); - pdf_literal_type(n) = lua_refid_literal; - } + } else if (lua_key_eq(s, data) || lua_key_eq(s, string)) { + set_pdf_literal_direct_normal(L, n, 3); + } else if (lua_key_eq(s, token)) { + set_pdf_literal_direct_token(L, n, 3); } else { return nodelib_cantset(L, n, s); } } else if (t == late_lua_node) { - if (lua_key_eq(s, string)) { - cleanup_late_lua(n) ; /* ls-hh */ - if (ini_version) { - late_lua_data(n) = nodelib_gettoks(L, 3); - late_lua_type(n) = normal; - } else { - lua_pushvalue(L, 3); - late_lua_data(n) = luaL_ref(L, LUA_REGISTRYINDEX); - late_lua_type(n) = lua_refid_literal; - } - } else if (lua_key_eq(s, data)) { - cleanup_late_lua(n) ; /* ls-hh */ - late_lua_data(n) = nodelib_gettoks(L, 3); - late_lua_type(n) = normal; + /*tex The |string| key is obsolete. */ + if (lua_key_eq(s, data) || lua_key_eq(s, string)) { + set_late_lua_direct_normal(L, n, 3); + } else if (lua_key_eq(s, token)) { + set_late_lua_direct_token(L, n, 3); } else if (lua_key_eq(s, name)) { - cleanup_late_lua_name(n) ; /* ls-hh */ + cleanup_late_lua_name(n) ; late_lua_name(n) = nodelib_gettoks(L, 3); } else { return nodelib_cantset(L, n, s); @@ -5868,31 +6521,31 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, const char *s) user_node_type(n) = (halfword) lua_tointeger(L, 3); } else if (lua_key_eq(s, value)) { switch (user_node_type(n)) { - case 'a': - user_node_value(n) = nodelib_getlist(L, 3); - break; - case 'd': - user_node_value(n) = (halfword) lua_roundnumber(L, 3); - break; - case 'l': - lua_pushvalue(L, 3); - if (user_node_value(n) != 0) { - luaL_unref(L, LUA_REGISTRYINDEX,user_node_value(n)); - } - user_node_value(n) = luaL_ref(L, LUA_REGISTRYINDEX); - break; - case 'n': - user_node_value(n) = nodelib_getlist(L, 3); - break; - case 's': - user_node_value(n) = nodelib_getstring(L, 3); - break; - case 't': - user_node_value(n) = nodelib_gettoks(L, 3); - break; - default: - user_node_value(n) = (halfword) lua_roundnumber(L, 3); - break; + case 'a': + user_node_value(n) = nodelib_getlist(L, 3); + break; + case 'd': + user_node_value(n) = (halfword) lua_roundnumber(L, 3); + break; + case 'l': + lua_pushvalue(L, 3); + if (user_node_value(n) != 0) { + luaL_unref(L, LUA_REGISTRYINDEX,user_node_value(n)); + } + user_node_value(n) = luaL_ref(L, LUA_REGISTRYINDEX); + break; + case 'n': + user_node_value(n) = nodelib_getlist(L, 3); + break; + case 's': + user_node_value(n) = nodelib_getstring(L, 3); + break; + case 't': + user_node_value(n) = nodelib_gettoks(L, 3); + break; + default: + user_node_value(n) = (halfword) lua_roundnumber(L, 3); + break; } } else { return nodelib_cantset(L, n, s); @@ -5937,7 +6590,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, const char *s) } } else if (t == pdf_setmatrix_node) { if (lua_key_eq(s, data)) { - pdf_setmatrix_data(n) = nodelib_gettoks(L, 3); + set_pdf_setmatrix_direct_value(L,n,3); } else { return nodelib_cantset(L, n, s); } @@ -5967,7 +6620,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, const char *s) if (lua_key_eq(s, stream)) { write_stream(n) = (halfword) lua_tointeger(L, 3); } else if (lua_key_eq(s, data)) { - write_tokens(n) = nodelib_gettoks(L, 3); + set_write_direct_value(L,n,3); } else { return nodelib_cantset(L, n, s); } @@ -6023,7 +6676,7 @@ static int lua_nodelib_setfield_whatsit(lua_State * L, int n, const char *s) } } else if (t == special_node) { if (lua_key_eq(s, data)) { - write_tokens(n) = nodelib_gettoks(L, 3); + set_special_direct_value(L,n,3); } else { return nodelib_cantset(L, n, s); } @@ -6107,8 +6760,8 @@ static int lua_nodelib_fast_setfield(lua_State * L) x_displace(n) = (halfword) lua_roundnumber(L, 3); } else if (lua_key_eq(s, yoffset)) { y_displace(n) = (halfword) lua_roundnumber(L, 3); - } else if (lua_key_eq(s, xadvance)) { - x_advance(n) = (halfword) lua_roundnumber(L, 3); + } else if (lua_key_eq(s, data)) { + glyph_node_data(n) = (halfword) lua_tointeger(L, 3);; } else if (lua_key_eq(s, width)) { /* not yet */ } else if (lua_key_eq(s, height)) { @@ -6141,8 +6794,10 @@ static int lua_nodelib_fast_setfield(lua_State * L) height(n) = (halfword) lua_roundnumber(L, 3); } else if (lua_key_eq(s, depth)) { depth(n) = (halfword) lua_roundnumber(L, 3); + } else if (lua_key_eq(s, direction)) { + box_dir(n) = nodelib_getdirection(L, 3); } else if (lua_key_eq(s, dir)) { - box_dir(n) = nodelib_getdir(L, 3, 1); + box_dir(n) = nodelib_getdir_par(L, 3); } else if (lua_key_eq(s, shift)) { shift_amount(n) = (halfword) lua_roundnumber(L, 3); } else if (lua_key_eq(s, glue_order)) { @@ -6213,8 +6868,14 @@ static int lua_nodelib_fast_setfield(lua_State * L) height(n) = (halfword) lua_roundnumber(L, 3); } else if (lua_key_eq(s, depth)) { depth(n) = (halfword) lua_roundnumber(L, 3); + } else if (lua_key_eq(s, left)) { + rule_left(n) = (halfword) lua_roundnumber(L, 3); + } else if (lua_key_eq(s, right)) { + rule_right(n) = (halfword) lua_roundnumber(L, 3); + } else if (lua_key_eq(s, direction)) { + rule_dir(n) = nodelib_getdirection(L, 3); } else if (lua_key_eq(s, dir)) { - rule_dir(n) = nodelib_getdir(L, 3, 1); + rule_dir(n) = nodelib_getdir_par(L, 3); } else if (lua_key_eq(s, index)) { rule_index(n) = (halfword) lua_tointeger(L, 3); } else if (lua_key_eq(s, transform)) { @@ -6223,12 +6884,12 @@ static int lua_nodelib_fast_setfield(lua_State * L) return nodelib_cantset(L, n, s); } } else if (t == dir_node) { - if (lua_key_eq(s, dir)) { - dir_dir(n) = nodelib_getdir(L, 3, 0); + if (lua_key_eq(s, direction)) { + dir_dir(n) = nodelib_getdirection(L, 3); + } else if (lua_key_eq(s, dir)) { + nodelib_setdir_text(L, 3, n); } else if (lua_key_eq(s, level)) { dir_level(n) = (halfword) lua_tointeger(L, 3); - } else if (lua_key_eq(s, subtype)) { /* can be used for anything */ - subtype(n) = (quarterword) lua_tointeger(L, 3); } else { return nodelib_cantset(L, n, s); } @@ -6237,8 +6898,10 @@ static int lua_nodelib_fast_setfield(lua_State * L) local_pen_inter(n) = (halfword) lua_tointeger(L, 3); } else if (lua_key_eq(s, pen_broken)) { local_pen_broken(n) = (halfword) lua_tointeger(L, 3); + } else if (lua_key_eq(s, direction)) { + local_par_dir(n) = nodelib_getdirection(L, 3); } else if (lua_key_eq(s, dir)) { - local_par_dir(n) = nodelib_getdir(L, 3, 1); + local_par_dir(n) = nodelib_getdir_par(L, 3); } else if (lua_key_eq(s, box_left)) { local_box_left(n) = nodelib_getlist(L, 3); } else if (lua_key_eq(s, box_left_width)) { @@ -6349,6 +7012,8 @@ static int lua_nodelib_fast_setfield(lua_State * L) right_delimiter(n) = nodelib_getlist(L, 3); } else if (lua_key_eq(s, middle)) { middle_delimiter(n) = nodelib_getlist(L, 3); + } else if (lua_key_eq(s, fam)) { + fraction_fam(n) = (halfword) lua_tointeger(L, 3); } else if (lua_key_eq(s, options)) { fractionoptions(n) = (halfword) lua_tointeger(L, 3); } else { @@ -6517,8 +7182,10 @@ static int lua_nodelib_fast_setfield(lua_State * L) height(n) = (halfword) lua_roundnumber(L, 3); } else if (lua_key_eq(s, depth)) { depth(n) = (halfword) lua_roundnumber(L, 3); + } else if (lua_key_eq(s, direction)) { + box_dir(n) = nodelib_getdirection(L, 3); } else if (lua_key_eq(s, dir)) { - box_dir(n) = nodelib_getdir(L, 3, 1); + box_dir(n) = nodelib_getdir_par(L, 3); } else if (lua_key_eq(s, shrink)) { glue_shrink(n) = (halfword) lua_roundnumber(L, 3); } else if (lua_key_eq(s, glue_order)) { @@ -6592,36 +7259,24 @@ static int lua_nodelib_direct_setfield_whatsit(lua_State * L, int n, const char { int t = subtype(n); if (t == pdf_literal_node) { + /*tex The |string| key is obsolete. */ if (lua_key_eq(s, mode)) { pdf_literal_mode(n) = (quarterword) lua_tointeger(L, 3); - } else if (lua_key_eq(s, data)) { - if (ini_version) { - pdf_literal_data(n) = nodelib_gettoks(L, 3); - } else { - lua_pushvalue(L, 3); - pdf_literal_data(n) = luaL_ref(L, LUA_REGISTRYINDEX); - pdf_literal_type(n) = lua_refid_literal; - } + } else if (lua_key_eq(s, data) || lua_key_eq(s, string)) { + set_pdf_literal_direct_normal(L, n, 3); + } else if (lua_key_eq(s, token)) { + set_pdf_literal_direct_token(L, n, 3); } else { return nodelib_cantset(L, n, s); } } else if (t == late_lua_node) { - if (lua_key_eq(s, string)) { - cleanup_late_lua(n) ; /* ls-hh */ - if (ini_version) { - late_lua_data(n) = nodelib_gettoks(L, 3); - late_lua_type(n) = normal; - } else { - lua_pushvalue(L, 3); - late_lua_data(n) = luaL_ref(L, LUA_REGISTRYINDEX); - late_lua_type(n) = lua_refid_literal; - } - } else if (lua_key_eq(s, data)) { - cleanup_late_lua(n) ; /* ls-hh */ - late_lua_data(n) = nodelib_gettoks(L, 3); - late_lua_type(n) = normal; + /*tex The |string| key is obsolete. */ + if (lua_key_eq(s, data) || lua_key_eq(s, string)) { + set_late_lua_direct_normal(L, n, 3); + } else if (lua_key_eq(s, token)) { + set_late_lua_direct_token(L, n, 3); } else if (lua_key_eq(s, name)) { - cleanup_late_lua_name(n) ; /* ls-hh */ + cleanup_late_lua_name(n) ; late_lua_name(n) = nodelib_gettoks(L, 3); } else { return nodelib_cantset(L, n, s); @@ -6632,33 +7287,7 @@ static int lua_nodelib_direct_setfield_whatsit(lua_State * L, int n, const char } else if (lua_key_eq(s, type)) { user_node_type(n) = (halfword) lua_tointeger(L, 3); } else if (lua_key_eq(s, value)) { - switch (user_node_type(n)) { - case 'a': - user_node_value(n) = nodelib_getlist(L, 3); - break; - case 'd': - user_node_value(n) = (halfword) lua_roundnumber(L, 3); - break; - case 'l': - lua_pushvalue(L, 3); - if (user_node_value(n) != 0) { - luaL_unref(L, LUA_REGISTRYINDEX,user_node_value(n)); - } - user_node_value(n) = luaL_ref(L, LUA_REGISTRYINDEX); - break; - case 'n': - user_node_value(n) = nodelib_getlist(L, 3); - break; - case 's': - user_node_value(n) = nodelib_getstring(L, 3); - break; - case 't': - user_node_value(n) = nodelib_gettoks(L, 3); - break; - default: - user_node_value(n) = (halfword) lua_roundnumber(L, 3); - break; - } + set_user_node_direct_value(L, n, 3); } else { return nodelib_cantset(L, n, s); } @@ -6702,7 +7331,7 @@ static int lua_nodelib_direct_setfield_whatsit(lua_State * L, int n, const char } } else if (t == pdf_setmatrix_node) { if (lua_key_eq(s, data)) { - pdf_setmatrix_data(n) = nodelib_gettoks(L, 3); + set_pdf_setmatrix_direct_value(L, n, 3); } else { return nodelib_cantset(L, n, s); } @@ -6730,9 +7359,9 @@ static int lua_nodelib_direct_setfield_whatsit(lua_State * L, int n, const char } } else if (t == write_node) { if (lua_key_eq(s, stream)) { - write_stream(n) = (halfword) lua_tointeger(L, 3); + set_write_direct_value(L,n,3); } else if (lua_key_eq(s, data)) { - write_tokens(n) = nodelib_gettoks(L, 3); + set_write_direct_value(L,n,3); } else { return nodelib_cantset(L, n, s); } @@ -6788,7 +7417,7 @@ static int lua_nodelib_direct_setfield_whatsit(lua_State * L, int n, const char } } else if (t == special_node) { if (lua_key_eq(s, data)) { - write_tokens(n) = nodelib_gettoks(L, 3); + set_special_direct_value(L, n, 3); } else { return nodelib_cantset(L, n, s); } @@ -6963,8 +7592,8 @@ static int lua_nodelib_direct_setfield(lua_State * L) x_displace(n) = (halfword) lua_roundnumber(L, 3); } else if (lua_key_eq(s, yoffset)) { y_displace(n) = (halfword) lua_roundnumber(L, 3); - } else if (lua_key_eq(s, xadvance)) { - x_advance(n) = (halfword) lua_roundnumber(L, 3); + } else if (lua_key_eq(s, data)) { + glyph_node_data(n) = (halfword) lua_tointeger(L, 3); } else if (lua_key_eq(s, expansion_factor)) { ex_glyph(n) = (halfword) lua_roundnumber(L, 3); } else if (lua_key_eq(s, components)) { @@ -6997,8 +7626,10 @@ static int lua_nodelib_direct_setfield(lua_State * L) height(n) = (halfword) lua_roundnumber(L, 3); } else if (lua_key_eq(s, depth)) { depth(n) = (halfword) lua_roundnumber(L, 3); + } else if (lua_key_eq(s, direction)) { + box_dir(n) = nodelib_getdirection(L, 3); } else if (lua_key_eq(s, dir)) { - box_dir(n) = nodelib_getdir(L, 3, 1); + box_dir(n) = nodelib_getdir_par(L, 3); } else if (lua_key_eq(s, shift)) { shift_amount(n) = (halfword) lua_roundnumber(L, 3); } else if (lua_key_eq(s, glue_order)) { @@ -7069,8 +7700,14 @@ static int lua_nodelib_direct_setfield(lua_State * L) height(n) = (halfword) lua_roundnumber(L, 3); } else if (lua_key_eq(s, depth)) { depth(n) = (halfword) lua_roundnumber(L, 3); + } else if (lua_key_eq(s, left)) { + rule_left(n) = (halfword) lua_roundnumber(L, 3); + } else if (lua_key_eq(s, right)) { + rule_right(n) = (halfword) lua_roundnumber(L, 3); + } else if (lua_key_eq(s, direction)) { + rule_dir(n) = nodelib_getdirection(L, 3); } else if (lua_key_eq(s, dir)) { - rule_dir(n) = nodelib_getdir(L, 3, 1); + rule_dir(n) = nodelib_getdir_par(L, 3); } else if (lua_key_eq(s, index)) { rule_index(n) = (halfword) lua_tointeger(L, 3); } else if (lua_key_eq(s, transform)) { @@ -7079,12 +7716,12 @@ static int lua_nodelib_direct_setfield(lua_State * L) return nodelib_cantset(L, n, s); } } else if (t == dir_node) { - if (lua_key_eq(s, dir)) { - dir_dir(n) = nodelib_getdir(L, 3, 0); + if (lua_key_eq(s, direction)) { + dir_dir(n) = nodelib_getdirection(L, 3); + } else if (lua_key_eq(s, dir)) { + nodelib_setdir_text(L, 3, n); } else if (lua_key_eq(s, level)) { dir_level(n) = (halfword) lua_tointeger(L, 3); - } else if (lua_key_eq(s, subtype)) { /* can be used for anything */ - subtype(n) = (quarterword) lua_tointeger(L, 3); } else { return nodelib_cantset(L, n, s); } @@ -7099,8 +7736,10 @@ static int lua_nodelib_direct_setfield(lua_State * L) local_pen_inter(n) = (halfword) lua_tointeger(L, 3); } else if (lua_key_eq(s, pen_broken)) { local_pen_broken(n) = (halfword) lua_tointeger(L, 3); + } else if (lua_key_eq(s, direction)) { + local_par_dir(n) = nodelib_getdirection(L, 3); } else if (lua_key_eq(s, dir)) { - local_par_dir(n) = nodelib_getdir(L, 3, 1); + local_par_dir(n) = nodelib_getdir_par(L, 3); } else if (lua_key_eq(s, box_left)) { local_box_left(n) = nodelib_getlist(L, 3); } else if (lua_key_eq(s, box_left_width)) { @@ -7205,6 +7844,8 @@ static int lua_nodelib_direct_setfield(lua_State * L) right_delimiter(n) = nodelib_popdirect(3); } else if (lua_key_eq(s, middle)) { middle_delimiter(n) = nodelib_popdirect(3); + } else if (lua_key_eq(s, fam)) { + fraction_fam(n) = (halfword) lua_tointeger(L, 3); } else if (lua_key_eq(s, options)) { fractionoptions(n) = (halfword) lua_tointeger(L, 3); } else { @@ -7373,8 +8014,10 @@ static int lua_nodelib_direct_setfield(lua_State * L) height(n) = (halfword) lua_roundnumber(L, 3); } else if (lua_key_eq(s, depth)) { depth(n) = (halfword) lua_roundnumber(L, 3); + } else if (lua_key_eq(s, direction)) { + box_dir(n) = nodelib_getdirection(L, 3); } else if (lua_key_eq(s, dir)) { - box_dir(n) = nodelib_getdir(L, 3, 1); + box_dir(n) = nodelib_getdir_par(L, 3); } else if (lua_key_eq(s, shrink)) { glue_shrink(n) = (halfword) lua_roundnumber(L, 3); } else if (lua_key_eq(s, glue_order)) { @@ -7516,6 +8159,8 @@ static int lua_nodelib_direct_setbox(lua_State * L) /* node.is_node(n) */ +/* + static int lua_nodelib_is_node(lua_State * L) { if (maybe_isnode(L,1) == NULL) @@ -7525,6 +8170,18 @@ static int lua_nodelib_is_node(lua_State * L) return 1; } +*/ + +static int lua_nodelib_is_node(lua_State * L) +{ + halfword *p = maybe_isnode(L, 1); + if (p == NULL) + lua_pushboolean(L,0); + else + lua_pushinteger(L, *((halfword *)p)); + return 1; +} + /* node.direct.is_direct(n) (handy for mixed usage testing) */ static int lua_nodelib_direct_is_direct(lua_State * L) @@ -7571,7 +8228,7 @@ static int lua_nodelib_direct_is_node(lua_State * L) mechanism. And, one can always sweep the table empty. */ -static int lua_nodelib_properties_set_mode(lua_State * L) /* hh */ +static int lua_nodelib_properties_set_mode(lua_State * L) { /* <boolean> */ if (lua_isboolean(L,1)) { lua_properties_enabled = lua_toboolean(L,1); @@ -7584,7 +8241,7 @@ static int lua_nodelib_properties_set_mode(lua_State * L) /* hh */ /* We used to have variants in assigned defaults but they made no sense. */ -static int lua_nodelib_properties_flush_table(lua_State * L) /* hh */ +static int lua_nodelib_properties_flush_table(lua_State * L) { /* <node|direct> <number> */ lua_get_metatablelua(node_properties); lua_pushnil(L); /* initializes lua_next */ @@ -7599,7 +8256,7 @@ static int lua_nodelib_properties_flush_table(lua_State * L) /* hh */ /* maybe we should allocate a proper index 0..var_mem_max but not now */ -static int lua_nodelib_get_property(lua_State * L) /* hh */ +static int lua_nodelib_get_property(lua_State * L) { /* <node> */ halfword n = *((halfword *) lua_touserdata(L, 1)); if (n == null) { @@ -7611,7 +8268,7 @@ static int lua_nodelib_get_property(lua_State * L) /* hh */ return 1; } -static int lua_nodelib_direct_get_property(lua_State * L) /* hh */ +static int lua_nodelib_direct_get_property(lua_State * L) { /* <direct> */ halfword n = lua_tointeger(L, 1); if (n == null) { @@ -7623,7 +8280,7 @@ static int lua_nodelib_direct_get_property(lua_State * L) /* hh */ return 1; } -static int lua_nodelib_set_property(lua_State * L) /* hh */ +static int lua_nodelib_set_property(lua_State * L) { /* <node> <value> */ halfword n = *((halfword *) lua_touserdata(L, 1)); @@ -7638,7 +8295,7 @@ static int lua_nodelib_set_property(lua_State * L) /* hh */ return 0; } -static int lua_nodelib_direct_set_property(lua_State * L) /* hh */ +static int lua_nodelib_direct_set_property(lua_State * L) { /* <direct> <value> */ halfword n = lua_tointeger(L, 1); @@ -7653,13 +8310,13 @@ static int lua_nodelib_direct_set_property(lua_State * L) /* hh */ return 0; } -static int lua_nodelib_direct_properties_get_table(lua_State * L) /* hh */ +static int lua_nodelib_direct_properties_get_table(lua_State * L) { /* <node|direct> */ lua_get_metatablelua(node_properties); return 1; } -static int lua_nodelib_properties_get_table(lua_State * L) /* hh */ +static int lua_nodelib_properties_get_table(lua_State * L) { /* <node|direct> */ lua_get_metatablelua(node_properties_indirect); return 1; @@ -7667,7 +8324,7 @@ static int lua_nodelib_properties_get_table(lua_State * L) /* hh */ /* bonus */ -static int lua_nodelib_get_property_t(lua_State * L) /* hh */ +static int lua_nodelib_get_property_t(lua_State * L) { /* <table> <node> */ halfword n = *((halfword *) lua_touserdata(L, 2)); if (n == null) { @@ -7678,7 +8335,7 @@ static int lua_nodelib_get_property_t(lua_State * L) /* hh */ return 1; } -static int lua_nodelib_set_property_t(lua_State * L) /* hh */ +static int lua_nodelib_set_property_t(lua_State * L) { /* <table> <node> <value> */ halfword n = *((halfword *) lua_touserdata(L, 2)); @@ -7804,7 +8461,7 @@ static int lua_nodelib_direct_flatten_discretionaries(lua_State * L) try_couple_nodes(alink(current),h); } vlink(n) = null ; - //tlink(n) = null; + /*tlink(n) = null; */ } else { if (current == head) { head = next; @@ -7870,7 +8527,7 @@ static int lua_nodelib_flatten_discretionaries(lua_State * L) try_couple_nodes(alink(current),h); } vlink(n) = null ; - //tlink(n) = null; + /*tlink(n) = null; */ } else { if (current == head) { head = next; @@ -7967,6 +8624,115 @@ static int lua_nodelib_direct_get_synctex_fields(lua_State * L) return 0; } +/* helper, assumes one node, returns node and delta .. to be tested */ + +static int lua_nodelib_prepend_prevdepth(lua_State * L) +{ + halfword *a; + halfword p; + halfword prevdepth; + boolean mirrored; + halfword n = *check_isnode(L, 1); + if (!(type(n) == hlist_node || type(n) == vlist_node)) { + lua_pushnil(L); + return 1; + } + prevdepth = lua_tointeger(L,2); + mirrored = (type(n) == hlist_node) && is_mirrored(box_dir(n)) ; + if (prevdepth > ignore_depth) { + halfword d; + if (mirrored) { + d = width(baseline_skip_par) - prevdepth - depth(n); + } else { + d = width(baseline_skip_par) - prevdepth - height(n); + } + if (d < line_skip_limit_par) { + p = new_param_glue(line_skip_code); + } else { + p = new_skip_param(baseline_skip_code); + width(p) = d; + } + couple_nodes(p,n); + fast_metatable_or_nil(p); /* glue */ + } else { + fast_metatable_or_nil(n); /* node */ + } + if (mirrored) { + prevdepth = height(n); + } else { + prevdepth = depth(n); + } + lua_pushinteger(L,prevdepth); /* new prevdepth */ + return 2; +} + +static int lua_nodelib_direct_prepend_prevdepth(lua_State * L) +{ + halfword p; + halfword prevdepth; + boolean mirrored; + halfword n = lua_tointeger(L, 1); + if (type(n) == hlist_node || type(n) == vlist_node) { + lua_pushnil(L); + return 1; + } + prevdepth = lua_tointeger(L,2); + mirrored = (type(n) == hlist_node) && is_mirrored(box_dir(n)) ; + if (prevdepth > ignore_depth) { + halfword d; + if (mirrored) { + d = width(baseline_skip_par) - prevdepth - depth(n); + } else { + d = width(baseline_skip_par) - prevdepth - height(n); + } + if (d < line_skip_limit_par) { + p = new_param_glue(line_skip_code); + } else { + p = new_skip_param(baseline_skip_code); + width(p) = d; + } + couple_nodes(p,n); + lua_pushinteger(L,p); /* glue */ + } else { + lua_pushinteger(L,n); /* node */ + } + if (mirrored) { + prevdepth = height(n); + } else { + prevdepth = depth(n); + } + lua_pushinteger(L,prevdepth); /* new prevdepth */ + return 2; +} + +static int lua_nodelib_make_extensible(lua_State * L) +{ + int top = lua_gettop(L); + if (top >= 3) { + halfword fnt = lua_tointeger(L,1); + halfword chr = lua_tointeger(L,2); + halfword size = lua_tointeger(L,3); + halfword overlap = 65536 ; + halfword attlist = null; + halfword b = null; + int horizontal = 0; + if (top >= 4) { + overlap = lua_tointeger(L,4); + } + if (top >= 5) { + horizontal = lua_toboolean(L,5); + } + if (top >= 6) { + attlist = *check_isnode(L, 6); + } + b = make_extensible(fnt,chr,size,overlap,horizontal,attlist); + nodelib_pushlist(L,b); + } else { + lua_pushnil(L); + } + return 1; +} + /* done */ static const struct luaL_Reg nodelib_p[] = { @@ -8022,6 +8788,7 @@ static const struct luaL_Reg direct_nodelib_f[] = { {"getshift", lua_nodelib_direct_getshift}, {"getfield", lua_nodelib_direct_getfield}, {"getfont", lua_nodelib_direct_getfont}, + {"getexpansion", lua_nodelib_direct_getexpansion}, {"getfam", lua_nodelib_direct_getfam}, {"getid", lua_nodelib_direct_getid}, {"getnext", lua_nodelib_direct_getnext}, @@ -8029,11 +8796,13 @@ static const struct luaL_Reg direct_nodelib_f[] = { {"getboth", lua_nodelib_direct_getboth}, {"getlist", lua_nodelib_direct_getlist}, {"getleader", lua_nodelib_direct_getleader}, + {"getdata", lua_nodelib_direct_getdata}, {"getsubtype", lua_nodelib_direct_getsubtype}, {"getattributelist", lua_nodelib_direct_getattributelist}, {"getnucleus", lua_nodelib_direct_getnucleus}, {"getsub", lua_nodelib_direct_getsub}, {"getsup", lua_nodelib_direct_getsup}, + {"getdirection", lua_nodelib_direct_getdirection}, {"has_glyph", lua_nodelib_direct_has_glyph}, {"has_attribute", lua_nodelib_direct_has_attribute}, {"get_attribute", lua_nodelib_direct_get_attribute}, @@ -8064,12 +8833,14 @@ static const struct luaL_Reg direct_nodelib_f[] = { {"setfield", lua_nodelib_direct_setfield}, {"setchar", lua_nodelib_direct_setchar}, {"setfont", lua_nodelib_direct_setfont}, + {"setexpansion", lua_nodelib_direct_setexpansion}, {"setfam", lua_nodelib_direct_setfam}, {"setcomponents", lua_nodelib_direct_setcomponents}, {"setlang", lua_nodelib_direct_setlang}, {"setkern", lua_nodelib_direct_setkern}, {"setpenalty", lua_nodelib_direct_setpenalty}, {"setdir", lua_nodelib_direct_setdir}, + {"setdirection", lua_nodelib_direct_setdirection}, {"setoffsets", lua_nodelib_direct_setoffsets}, {"setdisc", lua_nodelib_direct_setdisc}, {"setwhd", lua_nodelib_direct_setwhd}, @@ -8084,6 +8855,7 @@ static const struct luaL_Reg direct_nodelib_f[] = { {"setsplit", lua_nodelib_direct_setsplit}, {"setlist", lua_nodelib_direct_setlist}, {"setleader", lua_nodelib_direct_setleader}, + {"setdata", lua_nodelib_direct_setdata}, {"setsubtype", lua_nodelib_direct_setsubtype}, {"setattributelist", lua_nodelib_direct_setattributelist}, {"setnucleus", lua_nodelib_direct_setnucleus}, @@ -8097,6 +8869,8 @@ static const struct luaL_Reg direct_nodelib_f[] = { {"traverse", lua_nodelib_direct_traverse}, {"traverse_id", lua_nodelib_direct_traverse_filtered}, {"traverse_char", lua_nodelib_direct_traverse_char}, + {"traverse_glyph", lua_nodelib_direct_traverse_glyph}, + {"traverse_list", lua_nodelib_direct_traverse_list}, /* {"type", lua_nodelib_type}, */ /* no node argument */ /* {"types", lua_nodelib_types}, */ /* no node argument */ {"unprotect_glyphs", lua_nodelib_direct_unprotect_glyphs}, @@ -8110,14 +8884,15 @@ static const struct luaL_Reg direct_nodelib_f[] = { /* {"whatsits", lua_nodelib_whatsits}, */ /* no node argument */ {"write", lua_nodelib_direct_append}, {"set_properties_mode",lua_nodelib_properties_set_mode}, - {"flush_properties_table",lua_nodelib_properties_flush_table}, /* hh experiment */ - {"get_properties_table",lua_nodelib_direct_properties_get_table}, /* hh experiment */ + {"flush_properties_table",lua_nodelib_properties_flush_table}, + {"get_properties_table",lua_nodelib_direct_properties_get_table}, {"getproperty", lua_nodelib_direct_get_property}, {"setproperty", lua_nodelib_direct_set_property}, {"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}, + {"prepend_prevdepth",lua_nodelib_direct_prepend_prevdepth}, /* done */ {"set_synctex_fields", lua_nodelib_direct_set_synctex_fields}, {"get_synctex_fields", lua_nodelib_direct_get_synctex_fields}, @@ -8139,6 +8914,7 @@ static const struct luaL_Reg nodelib_f[] = { {"family_font", lua_nodelib_mfont}, {"fields", lua_nodelib_fields}, {"subtypes", lua_nodelib_subtypes}, + {"values", lua_nodelib_values}, {"first_glyph", lua_nodelib_first_glyph}, {"flush_list", lua_nodelib_flush_list}, {"flush_node", lua_nodelib_flush_node}, @@ -8191,33 +8967,34 @@ static const struct luaL_Reg nodelib_f[] = { {"traverse", lua_nodelib_traverse}, {"traverse_id", lua_nodelib_traverse_filtered}, {"traverse_char", lua_nodelib_traverse_char}, + {"traverse_glyph", lua_nodelib_traverse_glyph}, + {"traverse_list", lua_nodelib_traverse_list}, {"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}, - {"is_zero_glue",lua_nodelib_is_zero_glue}, + {"setglue", lua_nodelib_set_glue}, + {"getglue", lua_nodelib_get_glue}, + {"is_zero_glue", lua_nodelib_is_zero_glue}, {"usedlist", lua_nodelib_usedlist}, {"vpack", lua_nodelib_vpack}, {"whatsits", lua_nodelib_whatsits}, {"write", lua_nodelib_append}, /* experiment */ - /* {"attributes_to_table",lua_nodelib_attributes_to_table}, */ /* hh experiment */ + /* {"attributes_to_table",lua_nodelib_attributes_to_table}, */ /* experiment */ - {"set_properties_mode",lua_nodelib_properties_set_mode}, /* hh experiment */ - {"flush_properties_table",lua_nodelib_properties_flush_table}, /* hh experiment */ - {"get_properties_table",lua_nodelib_properties_get_table}, /* bonus */ /* hh experiment */ - {"getproperty", lua_nodelib_get_property}, /* hh experiment */ - {"setproperty", lua_nodelib_set_property}, /* hh experiment */ + {"set_properties_mode", lua_nodelib_properties_set_mode}, + {"flush_properties_table", lua_nodelib_properties_flush_table}, + {"get_properties_table", lua_nodelib_properties_get_table}, + {"getproperty", lua_nodelib_get_property}, + {"setproperty", lua_nodelib_set_property}, {"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}, */ + {"flatten_discretionaries", lua_nodelib_flatten_discretionaries}, + {"prepend_prevdepth", lua_nodelib_prepend_prevdepth}, + {"make_extensible", lua_nodelib_make_extensible}, /* done */ {"fix_node_lists", lua_nodelib_fix_node_lists}, {NULL, NULL} /* sentinel */ @@ -8255,12 +9032,12 @@ void nodelist_to_lua(lua_State * L, int n) lua_nodelib_push(L); } -int nodelist_from_lua(lua_State * L) +int nodelist_from_lua(lua_State * L, int n) { - if (lua_isnil(L, -1)) { + if (lua_isnil(L, n)) { return null; } else { - halfword n= *check_isnode(L, -1); - return (n ? n : null); + halfword list = *check_isnode(L, n); + return (list ? list : null); } } diff --git a/Build/source/texk/web2c/luatexdir/lua/loslibext.c b/Build/source/texk/web2c/luatexdir/lua/loslibext.c index 309d636c4f6..979f724720f 100644 --- a/Build/source/texk/web2c/luatexdir/lua/loslibext.c +++ b/Build/source/texk/web2c/luatexdir/lua/loslibext.c @@ -703,28 +703,49 @@ static int uname(struct utsname *uts) GetVersionEx(&osver); GetSystemInfo(&sysinfo); + + /* + Windows 10 10.0* + Windows Server 2016 10.0* + Windows 8.1 6.3* + Windows Server 2012 R2 6.3* + Windows 8 6.2 + Windows Server 2012 6.2 + Windows 7 6.1 + Windows Server 2008 R2 6.1 + Windows Server 2008 6.0 + Windows Vista 6.0 + Windows Server 2003 R2 5.2 + Windows Server 2003 5.2 + Windows XP 64-Bit Edition 5.2 + Windows XP 5.1 + Windows 2000 5.0 + */ + switch (osver.dwPlatformId) { - case VER_PLATFORM_WIN32_NT: /* NT, Windows 2000 or Windows XP */ + case VER_PLATFORM_WIN32_NT: if (osver.dwMajorVersion == 4) - strcpy(uts->sysname, "Windows NT4x"); /* NT4x */ + strcpy(uts->sysname, "Windows NT 4"); else if (osver.dwMajorVersion <= 3) - strcpy(uts->sysname, "Windows NT3x"); /* NT3x */ + strcpy(uts->sysname, "Windows NT 3"); else if (osver.dwMajorVersion == 5) { if (osver.dwMinorVersion == 0) - strcpy(uts->sysname, "Windows 2000"); /* 2k */ + strcpy(uts->sysname, "Windows 2000"); else if (osver.dwMinorVersion == 1) - strcpy(uts->sysname, "Windows XP"); /* XP */ + strcpy(uts->sysname, "Windows XP"); else if (osver.dwMinorVersion == 2) - strcpy(uts->sysname, "Windows Server 2003"); /* Server 2003 */ + strcpy(uts->sysname, "Windows XP 64-Bit"); } else if (osver.dwMajorVersion == 6) { - /* - if( osver.wProductType == VER_NT_WORKSTATION ) - */ - strcpy(uts->sysname, "Windows Vista"); /* Vista */ - /* - else - strcpy (uts->sysname, "Windows Server 2008"); - */ + if (osver.dwMinorVersion == 0) + strcpy(uts->sysname, "Windows Vista"); + else if (osver.dwMinorVersion == 1) + strcpy(uts->sysname, "Windows 7"); + else if (osver.dwMinorVersion == 2) + strcpy(uts->sysname, "Windows 8"); + else if (osver.dwMinorVersion == 3) + strcpy(uts->sysname, "Windows 8.1"); + } else if (osver.dwMajorVersion == 10) { + strcpy(uts->sysname, "Windows 10"); } os = WinNT; break; diff --git a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c index 096600de34f..d8e051f3fd0 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c @@ -22,7 +22,7 @@ #include "lua/luatex-api.h" #include "pdf/pdftables.h" -static int luapdfprint(lua_State * L) +int luapdfprint(lua_State * L) { int n; const_lstring st; @@ -82,6 +82,7 @@ static int luapdfprint(lua_State * L) } st.s = lua_tolstring(L, n, &st.l); pdf_out_block(static_pdf, st.s, st.l); +/* pdf_out(pdf, '\n'); */ return 0; } @@ -193,6 +194,7 @@ static int table_obj(lua_State * L) const_lstring attr, st; lstring buf; int immediate = 0; /* default: not immediate */ + int nolength = 0; attr.s = st.s = NULL; attr.l = 0; assert(lua_istable(L, 1)); /* t */ @@ -213,6 +215,12 @@ static int table_obj(lua_State * L) immediate = lua_toboolean(L, -1); /* 0 or 1 */ } lua_pop(L, 1); /* t */ + lua_key_rawgeti(nolength); + if (!lua_isnil(L, -1)) { /* b? t */ + if (lua_isboolean(L, -1)) /* !b t */ + nolength = lua_toboolean(L, -1); /* 0 or 1 */ + } + lua_pop(L, 1); /* t */ /* is a reserved object referenced by "objnum"? */ @@ -335,19 +343,29 @@ static int table_obj(lua_State * L) } else { if (immediate == 1) { pdf_begin_obj(static_pdf, k, OBJSTM_NEVER); /* 0 = not an object stream candidate! */ - pdf_begin_dict(static_pdf); - if (attr.s != NULL) { + if (nolength && attr.s != NULL) { + /* we have a direct copy possible with compressed data */ + pdf_begin_dict(static_pdf); pdf_out_block(static_pdf, attr.s, attr.l); - if (attr.s[attr.l - 1] != '\n') - pdf_out(static_pdf, '\n'); + static_pdf->compress_level = 0; + static_pdf->stream_deflate = false; + pdf_end_dict(static_pdf); + } else { + pdf_begin_dict(static_pdf); + if (attr.s != NULL) { + pdf_check_space(static_pdf); + pdf_out_block(static_pdf, attr.s, attr.l); + pdf_set_space(static_pdf); + } + if (compress_level > -1) + static_pdf->compress_level = compress_level; + pdf_dict_add_streaminfo(static_pdf); + pdf_end_dict(static_pdf); } - if (compress_level > -1) - static_pdf->compress_level = compress_level; - pdf_dict_add_streaminfo(static_pdf); - pdf_end_dict(static_pdf); pdf_begin_stream(static_pdf); } else { set_obj_obj_is_stream(static_pdf, k); + set_obj_obj_no_length(static_pdf, k); if (compress_level > -1) obj_obj_pdfcompresslevel(static_pdf, k) = compress_level; } @@ -404,42 +422,42 @@ static int orig_obj(lua_State * L) obj_data_ptr(static_pdf, k) = pdf_get_mem(static_pdf, pdfmem_obj_size); init_obj_obj(static_pdf, k); switch (n - first_arg + 1) { - case 0: - luaL_error(L, "pdf.obj() needs at least one argument"); - break; - case 1: - if (!lua_isstring(L, first_arg)) /* or number */ - luaL_error(L, "pdf.obj() 1st argument must be string"); - break; - case 2: - case 3: - if (lua_type(L, first_arg) != LUA_TSTRING) - luaL_error(L, "pdf.obj() 1st argument must be string"); - if (!lua_isstring(L, first_arg + 1)) /* or number */ - luaL_error(L, "pdf.obj() 2nd argument must be string"); - st_s = lua_tostring(L, first_arg); - if (lua_key_eq(st_s, file)) { - if (n == first_arg + 2) - luaL_error(L, "pdf.obj() 3rd argument forbidden in file mode"); - set_obj_obj_is_file(static_pdf, k); - } else { - if (n == first_arg + 2) { /* write attr text */ - if (!lua_isstring(L, -1)) /* or number */ - luaL_error(L, "pdf.obj() 3rd argument must be string"); - obj_obj_stream_attr(static_pdf, k) = - luaL_ref(Luas, LUA_REGISTRYINDEX); - } - if (lua_key_eq(st_s, stream)) { - set_obj_obj_is_stream(static_pdf, k); - } else if (lua_key_eq(st_s, streamfile)) { - set_obj_obj_is_stream(static_pdf, k); + case 0: + luaL_error(L, "pdf.obj() needs at least one argument"); + break; + case 1: + if (!lua_isstring(L, first_arg)) /* or number */ + luaL_error(L, "pdf.obj() 1st argument must be string"); + break; + case 2: + case 3: + if (lua_type(L, first_arg) != LUA_TSTRING) + luaL_error(L, "pdf.obj() 1st argument must be string"); + if (!lua_isstring(L, first_arg + 1)) /* or number */ + luaL_error(L, "pdf.obj() 2nd argument must be string"); + st_s = lua_tostring(L, first_arg); + if (lua_key_eq(st_s, file)) { + if (n == first_arg + 2) + luaL_error(L, "pdf.obj() 3rd argument forbidden in file mode"); set_obj_obj_is_file(static_pdf, k); - } else - luaL_error(L, "pdf.obj() invalid argument"); - } - break; - default: - luaL_error(L, "pdf.obj() allows max. 3 arguments"); + } else { + if (n == first_arg + 2) { /* write attr text */ + if (!lua_isstring(L, -1)) /* or number */ + luaL_error(L, "pdf.obj() 3rd argument must be string"); + obj_obj_stream_attr(static_pdf, k) = + luaL_ref(Luas, LUA_REGISTRYINDEX); + } + if (lua_key_eq(st_s, stream)) { + set_obj_obj_is_stream(static_pdf, k); + } else if (lua_key_eq(st_s, streamfile)) { + set_obj_obj_is_stream(static_pdf, k); + set_obj_obj_is_file(static_pdf, k); + } else + luaL_error(L, "pdf.obj() invalid argument"); + } + break; + default: + luaL_error(L, "pdf.obj() allows max. 3 arguments"); } obj_obj_data(static_pdf, k) = luaL_ref(L, LUA_REGISTRYINDEX); return k; @@ -478,23 +496,23 @@ static int l_reserveobj(lua_State * L) const char *st_s = NULL; n = lua_gettop(L); switch (n) { - case 0: - static_pdf->obj_count++; - pdf_last_obj = pdf_create_obj(static_pdf, obj_type_obj, static_pdf->obj_ptr + 1); - break; - case 1: - if (lua_type(L, -1) != LUA_TSTRING) - luaL_error(L, "pdf.reserveobj() optional argument must be string"); - st_s = luaL_checkstring(L, 1); - if (lua_key_eq(st_s, annot)) { - pdf_last_annot = pdf_create_obj(static_pdf, obj_type_annot, 0); - } else { - luaL_error(L, "pdf.reserveobj() optional string must be \"annot\""); - } - lua_pop(L, 1); - break; - default: - luaL_error(L, "pdf.reserveobj() allows max. 1 argument"); + case 0: + static_pdf->obj_count++; + pdf_last_obj = pdf_create_obj(static_pdf, obj_type_obj, static_pdf->obj_ptr + 1); + break; + case 1: + if (lua_type(L, -1) != LUA_TSTRING) + luaL_error(L, "pdf.reserveobj() optional argument must be string"); + st_s = luaL_checkstring(L, 1); + if (lua_key_eq(st_s, annot)) { + pdf_last_annot = pdf_create_obj(static_pdf, obj_type_annot, 0); + } else { + luaL_error(L, "pdf.reserveobj() optional string must be \"annot\""); + } + lua_pop(L, 1); + break; + default: + luaL_error(L, "pdf.reserveobj() allows max. 1 argument"); } lua_pushinteger(L, static_pdf->obj_ptr); return 1; @@ -505,16 +523,16 @@ static int l_registerannot(lua_State * L) int n, i; n = lua_gettop(L); switch (n) { - case 1: - if (global_shipping_mode == NOT_SHIPPING) - luaL_error(L, "pdf.registerannot() can only be used in late lua"); - i = (int) luaL_checkinteger(L, 1); - if (i <= 0) - luaL_error(L, "pdf.registerannot() can only register positive object numbers"); - addto_page_resources(static_pdf, obj_type_annot, i); - break; - default: - luaL_error(L, "pdf.registerannot() needs exactly 1 argument"); + case 1: + if (global_shipping_mode == NOT_SHIPPING) + luaL_error(L, "pdf.registerannot() can only be used in late lua"); + i = (int) luaL_checkinteger(L, 1); + if (i <= 0) + luaL_error(L, "pdf.registerannot() can only register positive object numbers"); + addto_page_resources(static_pdf, obj_type_annot, i); + break; + default: + luaL_error(L, "pdf.registerannot() needs exactly 1 argument"); } return 0; } @@ -599,55 +617,30 @@ static int l_set_xformresources (lua_State * L) { l_set_pdf_value(xformresources static int l_set_xformattributes(lua_State * L) { l_set_pdf_value(xformattributes); } static int l_set_trailerid (lua_State * L) { l_set_pdf_value(trailerid); } -/* - -static int setpdf(lua_State * L) +static int getpdfobjtype(lua_State * L) { - const char *s ; - if (lua_gettop(L) != 3) { - return 0; - } - if (lua_type(L, -2) == LUA_TSTRING) { - s = lua_tostring(L, -1); - if (valid_pdf_key) { - lua_get_metatablelua(pdf_data); - lua_replace(L, -4); + if (lua_type(L, 1) == LUA_TNUMBER) { + int n = (int) lua_tointeger(L, 1); + if (n > 0 && n <= static_pdf->obj_ptr) { + lua_pushstring(L, pdf_obj_typenames[obj_type(static_pdf, n)]); + return 1; } } - lua_rawset(L, -3); - return 0; -} - -*/ - -static int l_objtype(lua_State * L) -{ - int n = lua_gettop(L); - if (n != 1) - luaL_error(L, "pdf.objtype() needs exactly 1 argument"); - n = (int) luaL_checkinteger(L, 1); - if (n < 0 || n > static_pdf->obj_ptr) - lua_pushnil(L); - else - lua_pushstring(L, pdf_obj_typenames[obj_type(static_pdf, n)]); + lua_pushnil(L); return 1; } -static int l_maxobjnum(lua_State * L) +static int getpdfmaxobjnum(lua_State * L) { - int n = lua_gettop(L); - if (n != 0) - luaL_error(L, "pdf.maxobjnum() needs 0 arguments"); lua_pushinteger(L, static_pdf->obj_ptr); return 1; } static int l_mapfile(lua_State * L) { - char *s; const char *st; - if ((lua_type(L,-1) == LUA_TSTRING) && (st = lua_tostring(L, -1)) != NULL) { - s = xstrdup(st); + if ((lua_type(L, 1) == LUA_TSTRING) && (st = lua_tostring(L, 1)) != NULL) { + char *s = xstrdup(st); process_map_item(s, MAPFILE); free(s); } @@ -656,29 +649,15 @@ static int l_mapfile(lua_State * L) static int l_mapline(lua_State * L) { - char *s; const char *st; - if ((lua_type(L,-1) == LUA_TSTRING) && (st = lua_tostring(L, -1)) != NULL) { - s = xstrdup(st); + if ((lua_type(L, 1) == LUA_TSTRING) && (st = lua_tostring(L, 1)) != NULL) { + char *s = xstrdup(st); process_map_item(s, MAPLINE); free(s); } return 0; } -static int l_pageref(lua_State * L) -{ - int n = lua_gettop(L); - if (n != 1) - luaL_error(L, "pdf.pageref() needs exactly 1 argument"); - n = (int) luaL_checkinteger(L, 1); - if (n <= 0) - luaL_error(L, "pdf.pageref() needs page number > 0"); - n = pdf_get_obj(static_pdf, obj_type_page, n, false); - lua_pushinteger(L, n); - return 1; -} - static int l_getpos(lua_State * L) { lua_pushinteger(L, static_pdf->posstruct->pos.h); @@ -770,6 +749,12 @@ static int l_get_obj_compress_level(lua_State * L) return 1 ; } +static int l_get_recompress(lua_State * L) +{ + lua_pushinteger(L, (pdf_recompress)); + return 1 ; +} + static int l_set_compress_level(lua_State * L) { if (lua_type(L, 1) == LUA_TNUMBER) { @@ -796,6 +781,19 @@ static int l_set_obj_compress_level(lua_State * L) return 0 ; } + static int l_set_recompress(lua_State * L) +{ + if (lua_type(L, 1) == LUA_TNUMBER) { + int c = (int) lua_tointeger(L, 1); + if (c<0) + c = 0 ; + else if (c>9) + c = 9 ; + set_pdf_recompress(c); + } + return 0 ; +} + /* fonts */ static int getpdfgentounicode(lua_State * L) @@ -826,6 +824,18 @@ static int setpdfomitcidset(lua_State * L) return 0 ; } +/* for tracing purposes when no pages are flushed */ + +static int setforcefile(lua_State * L) +{ + if (lua_type(L, 1) == LUA_TBOOLEAN) { + static_pdf->force_file = lua_toboolean(L,1); + } else { + static_pdf->force_file = 0; + } + return 0 ; +} + /* accuracy */ static int l_get_decimal_digits(lua_State * L) @@ -879,9 +889,10 @@ static int getpdffontname(lua_State * L) int c, ff ; if (lua_type(L, 1) == LUA_TNUMBER) { c = (int) lua_tointeger(L, 1); - pdf_check_vf(c); - if (!font_used(c)) + /* pdf_check_vf(c); */ + if (!font_used(c)) { pdf_init_font(static_pdf,c); + } set_ff(c); lua_pushinteger(L, (obj_info(static_pdf, pdf_font_num(ff)))); } else { @@ -895,9 +906,10 @@ static int getpdffontobjnum(lua_State * L) if (lua_type(L, 1) == LUA_TNUMBER) { int ff; int c = (int) lua_tointeger(L, 1); - pdf_check_vf(c); - if (!font_used(c)) + /* pdf_check_vf(c); */ + if (!font_used(c)) { pdf_init_font(static_pdf,c); + } set_ff(c); lua_pushinteger(L, (pdf_font_num(ff))); } else { @@ -917,21 +929,19 @@ static int getpdffontsize(lua_State * L) return 1 ; } -/* - static int getpdfpageref(lua_State * L) { if (lua_type(L, 1) == LUA_TNUMBER) { int c = (int) lua_tointeger(L, 1); - lua_pushinteger(L, (pdf_get_obj(static_pdf, obj_type_page, c, false))); - } else { - lua_pushnil(L); + if (c > 0) { + lua_pushinteger(L, (pdf_get_obj(static_pdf, obj_type_page, c, false))); + return 1; + } } + lua_pushnil(L); return 1 ; } -*/ - static int getpdfxformname(lua_State * L) { if (lua_type(L, 1) == LUA_TNUMBER) { @@ -944,12 +954,6 @@ static int getpdfxformname(lua_State * L) return 1 ; } -static int getpdfversion(lua_State * L) -{ - lua_pushinteger(L,1); - return 1 ; -} - static int getpdfcreationdate(lua_State * L) { initialize_start_time(static_pdf); @@ -1169,6 +1173,76 @@ static int l_set_font_attributes(lua_State * L) return 0; } +static int pdfincludechar(lua_State * L) +{ + int f = lua_tointeger(L, 1); + if (lua_type(L,2) == LUA_TTABLE) { + int i, c; + int n = lua_rawlen(L, 2); + for (i=1; i<=n; i++) { + lua_rawgeti(L, 2, i); + c = lua_tointeger(L, 3); + pdf_mark_char(f,c); + lua_pop(L, 1); + } + } else { + int c = lua_tointeger(L, 2); + pdf_mark_char(f,c); + } + return 0; +} + +static int pdfincludefont(lua_State * L) +{ + int f = lua_tointeger(L, 1); + pdf_init_font(static_pdf,f); + return 0; +} + +static int pdfincludeimage(lua_State * L) +{ + /*tex How to check for a valid entry? */ + image_dict *idict = idict_array[lua_tointeger(L,1)]; + int objnum = img_objnum(idict); + if (img_state(idict) < DICT_OUTIMG) { + img_state(idict) = DICT_OUTIMG; + } + if (! is_obj_written(static_pdf, objnum)) { + pdf_write_image(static_pdf, objnum); + } + lua_pushinteger(L,img_type(idict)); + lua_pushinteger(L,img_xorig(idict)); + lua_pushinteger(L,img_yorig(idict)); + lua_pushinteger(L,img_xsize(idict)); + lua_pushinteger(L,img_ysize(idict)); + lua_pushinteger(L,img_rotation(idict)); + lua_pushinteger(L,objnum); + if (img_type(idict) == IMG_TYPE_PNG) { + lua_pushinteger(L,img_group_ref(idict)); + } else { + lua_pushnil(L); + } + return 8; +} + +static int getpdfnofobjects(lua_State * L) +{ + int k; + int written = 0; + int dropped = 0; + for (k = 1; k <= static_pdf->obj_ptr; k++) { + if (is_obj_written(static_pdf, k)) { + written += 1; + } else { + dropped += 1; + } + } + lua_pushinteger(L,written); + lua_pushinteger(L,dropped); + return 2; +} + +/*tex For normal output see |pdflistout.c|: */ static const struct luaL_Reg pdflib[] = { { "gethpos", l_gethpos }, @@ -1179,11 +1253,10 @@ static const struct luaL_Reg pdflib[] = { { "registerannot", l_registerannot }, { "reserveobj", l_reserveobj }, { "getpos", l_getpos }, - /* { "pageref", getpdfpageref }, */ - { "maxobjnum", l_maxobjnum }, - { "pageref", l_pageref }, + { "getpageref", getpdfpageref }, + { "getmaxobjnum", getpdfmaxobjnum }, { "print", luapdfprint }, - { "objtype", l_objtype }, + { "getobjtype", getpdfobjtype }, { "getmatrix", l_getmatrix }, { "hasmatrix", l_hasmatrix }, { "setfontattributes", l_set_font_attributes }, @@ -1213,20 +1286,20 @@ static const struct luaL_Reg pdflib[] = { { "getlastannot", l_get_lastannot }, { "getcompresslevel", l_get_compress_level }, { "getobjcompresslevel", l_get_obj_compress_level }, + { "getrecompress", l_get_recompress }, { "setcompresslevel", l_set_compress_level }, { "setobjcompresslevel", l_set_obj_compress_level }, + { "setrecompress", l_set_recompress }, { "getdecimaldigits", l_get_decimal_digits }, { "setdecimaldigits", l_set_decimal_digits }, { "getpkresolution", l_get_pk_resolution }, { "setpkresolution", l_set_pk_resolution }, { "getsuppressoptionalinfo", l_get_suppress_optional_info }, { "setsuppressoptionalinfo", l_set_suppress_optional_info }, - /* moved from tex table */ - { "fontname", getpdffontname }, - { "fontobjnum", getpdffontobjnum }, - { "fontsize", getpdffontsize }, - { "xformname", getpdfxformname }, - { "getversion", getpdfversion }, + { "getfontname", getpdffontname }, + { "getfontobjnum", getpdffontobjnum }, + { "getfontsize", getpdffontsize }, + { "getxformname", getpdfxformname }, { "getcreationdate", getpdfcreationdate }, { "getmajorversion", getpdfmajorversion }, { "setmajorversion", setpdfmajorversion }, @@ -1253,8 +1326,22 @@ static const struct luaL_Reg pdflib[] = { { "setignoreunknownimages", setpdfignoreunknownimages }, { "setgentounicode", setpdfgentounicode }, { "setomitcidset", setpdfomitcidset }, + { "setforcefile", setforcefile }, { "mapfile", l_mapfile }, { "mapline", l_mapline }, + { "includechar", pdfincludechar }, + { "includefont", pdfincludefont }, + /* might go, used when sanitizing backend */ + { "includeimage", pdfincludeimage }, + { "getnofobjects", getpdfnofobjects }, + /* for a while */ + { "maxobjnum", getpdfmaxobjnum }, + { "pageref", getpdfpageref }, + { "objtype", getpdfobjtype }, + { "fontname", getpdffontname }, + { "fontobjnum", getpdffontobjnum }, + { "fontsize", getpdffontsize }, + { "xformname", getpdfxformname }, /* sentinel */ {NULL, NULL} }; diff --git a/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc b/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc index 8bafd61229c..56452b2ff39 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc +++ b/Build/source/texk/web2c/luatexdir/lua/lpdfscannerlib.cc @@ -17,6 +17,70 @@ You should have received a copy of the GNU General Public License along with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */ +/* converted example in manual: + +local operatortable = { } + +operatortable.Do = function(scanner,info) + local resources = info.resources + if resources then + local val = scanner:pop() + local name = val[2] + local xobject = pdfe.dictionarytotable(resources.XObject[2]) + print(info.space .. "Uses XObject " .. name) + local kind, + entry = unpack(xobject[name]) + local dict + if kind == 10 then -- reference + kind, + entry, + dict = pdfe.getfromreference(entry) + end + if kind == 9 then -- stream + dict = pdfe.dictionarytotable(dict) + local resources = dict.Resources + if resources then + local newinfo = { + space = info.space .. " " , + resources = Resources[2], + } + pdfscanner.scan(entry, operatortable, newinfo) + end + end + end +end + +local function Analyze(filename) + local doc = pdfe.open(filename) + if doc then + local pagenum = 1 + local n = 1 -- pdfe.getnofpages(doc) + for i=1,n do + local page = pdfe.getpage(doc,i) + local kind, + data = pdfe.getfromdictionarybyname(page,"Resources") + if kind == 10 then -- reference + kind, data = pdfe.getfromreference(data) + end + data = pdfe.dictionarytotable(data) + local info = { + space = " " , + resources = data, + } + print("Page " .. i) + kind, data = pdfe.getfromdictionarybyname(page,"Contents") + if kind == 10 then -- reference + kind, data = pdfe.getfromreference(data) + end + pdfscanner.scan(data,operatortable,info) + end + end +end + +Analyze("e:/tmp/oeps.pdf") + +*/ + # include <stdlib.h> # include <stdio.h> # include <stdarg.h> @@ -28,26 +92,9 @@ extern "C" { # include <lua.h> # include <lauxlib.h> # include <lualib.h> -} -# include <poppler-config.h> -# include <goo/GooString.h> -# include <goo/gmem.h> -# include <goo/gfile.h> -# include <Object.h> -# include <Stream.h> -# include <Gfx.h> -# include <Annot.h> -# include <Array.h> -# include <Dict.h> -# include <XRef.h> -# include <Catalog.h> -# include <Link.h> -# include <Page.h> -# include <GfxFont.h> -# include <PDFDoc.h> -# include <GlobalParams.h> -# include <Error.h> +# include "luapplib/pplib.h" +} # include <lua/luatex-api.h> @@ -57,48 +104,47 @@ extern "C" { #define MAXOPERANDS 1000 typedef enum { - pdf_integer = 1, - pdf_real, - pdf_boolean, - pdf_name, - pdf_operator, - pdf_string, - pdf_startarray, - pdf_stoparray, - pdf_startdict, - pdf_stopdict, + pdf_integer = 1, + pdf_real, + pdf_boolean, + pdf_name, + pdf_operator, + pdf_string, + pdf_startarray, + pdf_stoparray, + pdf_startdict, + pdf_stopdict, } pdf_token_type ; - typedef struct Token { - pdf_token_type type; - double value; - char *string; + pdf_token_type type; + double value; + char *string; } Token; typedef struct ObjectList { - struct ObjectList *next; - Object *stream; + struct ObjectList *next; + ppstream *stream; } ObjectList; typedef struct scannerdata { - int _ininlineimage; - int _nextoperand; - Token ** _operandstack; - Object * _stream; - ObjectList * _streams; + int _ininlineimage; + int _nextoperand; + Token ** _operandstack; + ppstream * _stream; + ObjectList * _streams; + const char *buffer; + size_t position; + size_t size; } scannerdata; -typedef enum { ALLOC_POPPLER, ALLOC_LEPDF } alloctype; - -#define M_Object "Object" -#define M_Stream "Stream" +#define PDFE_METATABLE_ARRAY "luatex.pdfe.array" +#define PDFE_METATABLE_STREAM "luatex.pdfe.stream" typedef struct { void *d; - alloctype atype; // was it allocated by poppler or the lepdflib.cc? void *pd; // reference to PdfDocument, or NULL - unsigned long pc; // counter to detect PDFDoc change + unsigned long pc; // counter to detect PDFDoc change } udstruct; static void clear_operand_stack (scannerdata *self, int from); @@ -119,8 +165,8 @@ static void *priv_xrealloc (void *old_ptr, size_t size) { void *new_mem = (void *)realloc(old_ptr, size); if (new_mem == NULL) { - fprintf(stderr,"fatal: memory exhausted (realloc of %lu bytes).\n", (unsigned long)size); - exit(EXIT_FAILURE); + fprintf(stderr,"fatal: memory exhausted (realloc of %lu bytes).\n", (unsigned long)size); + exit(EXIT_FAILURE); } return new_mem; } @@ -129,20 +175,20 @@ static void *priv_xrealloc (void *old_ptr, size_t size) #define INITBUFSIZE 64 -#define define_buffer(a) \ - char *a = (char *)priv_xmalloc (INITBUFSIZE); \ - int a##_size = INITBUFSIZE; \ - int a##index = 0; \ +#define define_buffer(a) \ + char *a = (char *)priv_xmalloc (INITBUFSIZE); \ + int a##_size = INITBUFSIZE; \ + int a##index = 0; \ memset (a,0,INITBUFSIZE) -#define check_overflow(a, wsize) do { \ - if (wsize >= a##_size) { \ - int nsize = a##_size + a##_size / 4; \ - a = (char *) xreallocarray(a, char, (unsigned) nsize); \ - memset (a+a##_size, 0, a##_size / 4); \ - a##_size = nsize; \ - } \ - } while (0) +#define check_overflow(a, wsize) do { \ + if (wsize >= a##_size) { \ + int nsize = a##_size + a##_size / 4; \ + a = (char *) xreallocarray(a, char, (unsigned) nsize); \ + memset (a+a##_size, 0, a##_size / 4); \ + a##_size = nsize; \ + } \ +} while (0) static scannerdata * scanner_push(lua_State * L) @@ -155,769 +201,814 @@ static scannerdata * scanner_push(lua_State * L) static scannerdata *scanner_check (lua_State *L, int index) { - scannerdata *bar; - luaL_checktype(L, index, LUA_TUSERDATA); - bar = (scannerdata *)luaL_checkudata(L, index, SCANNER); - if (bar == NULL) luaL_argerror(L, index, SCANNER " expected"); - return bar; + scannerdata *bar; + luaL_checktype(L, index, LUA_TUSERDATA); + bar = (scannerdata *)luaL_checkudata(L, index, SCANNER); + if (bar == NULL) + luaL_argerror(L, index, SCANNER " expected"); + return bar; } static void free_token (Token *token) { - if (token->string) { - free(token->string); - } - free(token); + if (token->string) { + free(token->string); + } + free(token); } static void clear_operand_stack (scannerdata *self, int from) { - int i = self->_nextoperand-1; - while (i>=from) { - if (self->_operandstack[i]) { - free_token(self->_operandstack[i]); - self->_operandstack[i] = NULL; + int i = self->_nextoperand-1; + while (i>=from) { + if (self->_operandstack[i]) { + free_token(self->_operandstack[i]); + self->_operandstack[i] = NULL; + } + i--; } - i--; - } - self->_nextoperand = from; + self->_nextoperand = from; } static void push_operand (scannerdata *self, Token *token) { - if (self->_nextoperand+1> MAXOPERANDS) { - fprintf(stderr, "out of operand stack space"); - exit(1); - } - self->_operandstack[self->_nextoperand++] = token; + if (self->_nextoperand+1> MAXOPERANDS) { + fprintf(stderr, "out of operand stack space"); + exit(1); + } + self->_operandstack[self->_nextoperand++] = token; } static Token * new_operand (pdf_token_type c) { - Token *token = (Token *)priv_xmalloc(sizeof(Token)); - memset (token, 0, sizeof(Token)); - token->type = c; - return token; + Token *token = (Token *)priv_xmalloc(sizeof(Token)); + memset (token, 0, sizeof(Token)); + token->type = c; + return token; +} + +static void _nextStream (scannerdata *self) +{ + if (self->buffer != NULL) { + ppstream_done(self->_stream); + } + ObjectList *rover = self->_streams; + self->_stream = rover->stream; + self->buffer = (const char*) ppstream_all(self->_stream,&self->size,1); + self->position = 0; + self->_streams = rover->next; + free(rover); +} + +static int streamGetChar (scannerdata *self) +{ + int i = EOF ; + if (self->position < self->size) { + const char c = self->buffer[self->position]; + ++self->position; + i = (int) c; + } + if (i<0 && self->_streams) { + _nextStream(self); + i = streamGetChar(self); + } + return i; } -static void _nextStream (scannerdata *self) { - self->_stream->streamClose(); - ObjectList *rover = self->_streams; - self->_stream = rover->stream; - self->_stream->streamReset(); - self->_streams = rover->next; - free(rover); +static int streamLookChar (scannerdata *self) +{ + int i = EOF ; + if (self->position < self->size) { + const char c = self->buffer[self->position]; + /* ++self->position; */ + i = (int) c; + } + if (i<0 && self->_streams) { + _nextStream(self); + i = streamGetChar(self); + } + return i; } -static int streamGetChar (scannerdata *self) { - int i = self->_stream->streamGetChar(); - if (i<0 && self->_streams) { - _nextStream(self); - i = streamGetChar(self); - } - return i; +static void streamReset (scannerdata *self) +{ + self->buffer = (const char*) ppstream_all(self->_stream,&self->size,1); + self->position = 0; } -static int streamLookChar (scannerdata *self) { - int i= self->_stream->streamLookChar(); - if (i<0 && self->_streams) { - _nextStream(self); - i = streamLookChar(self); - } - return i; +static void streamClose (scannerdata *self) { + ppstream_done(self->_stream); + self->buffer = NULL; + self->_stream = NULL; } +/* end of stream interface */ + static Token * _parseSpace (scannerdata *self) { - return _parseToken (self,streamGetChar(self)); + return _parseToken (self,streamGetChar(self)); } static Token * _parseString (scannerdata *self, int c) { - // local token = {type = pdf_string,value = ''} - define_buffer(found); - int level = 1; - while (1) { - c = streamGetChar(self); - if (c == '(') { - level = level + 1 ; - } - if (c == ')') { - level = level - 1 ; - if (level < 1) break; - } - if (c == '\\') { - int next = streamGetChar(self); - if (next == '(' || next == ')' || next == '\\') { - c = next; - } else if (next == '\n' || next == '\r') { - c = '\0'; - } else if (next == 'n') { - c = '\n'; - } else if (next == 'r') { - c = '\r'; - } else if (next == 't') { - c = '\t'; - } else if (next == 'b') { - c = '\b'; - } else if (next == 'f') { - c = '\f'; - } else if (next >= '0' && next <= '7') { - next = next - '0'; - int next2 = streamLookChar(self); - if (next2 >= '0' && next2 <= '7') { - next2 = streamGetChar(self); - next2 = next2 - '0'; - int next3 = streamLookChar(self); - if (next3 >= '0' && next3 <= '7') { - next3 = streamGetChar(self); - next3 = next3 - '0'; - c = (next*64+next2*8+next3); - } else { - c = (next*8+next2); - } - } else { - c = next; - } - } else { - c = next; - } - } - check_overflow(found,foundindex); - if (c>=0) { - found[foundindex++] = c; - } - } - Token *token = new_operand(pdf_string); - token->value = foundindex; - token->string = found; - return token; + define_buffer(found); + int level = 1; + while (1) { + c = streamGetChar(self); + if (c == '(') { + level = level + 1 ; + } else if (c == ')') { + level = level - 1 ; + if (level < 1) break; + } else if (c == '\\') { + int next = streamGetChar(self); + if (next == '(' || next == ')' || next == '\\') { + c = next; + } else if (next == '\n' || next == '\r') { + c = '\0'; + } else if (next == 'n') { + c = '\n'; + } else if (next == 'r') { + c = '\r'; + } else if (next == 't') { + c = '\t'; + } else if (next == 'b') { + c = '\b'; + } else if (next == 'f') { + c = '\f'; + } else if (next >= '0' && next <= '7') { + next = next - '0'; + int next2 = streamLookChar(self); + if (next2 >= '0' && next2 <= '7') { + next2 = streamGetChar(self); + next2 = next2 - '0'; + int next3 = streamLookChar(self); + if (next3 >= '0' && next3 <= '7') { + next3 = streamGetChar(self); + next3 = next3 - '0'; + c = (next*64+next2*8+next3); + } else { + c = (next*8+next2); + } + } else { + c = next; + } + } else { + c = next; + } + } + check_overflow(found,foundindex); + if (c>=0) { + found[foundindex++] = c; + } + } + Token *token = new_operand(pdf_string); + token->value = foundindex; + token->string = found; + return token; } - static Token * _parseNumber (scannerdata *self, int c) { - double value = 0; - pdf_token_type type = pdf_integer; - int isfraction = 0; - int isnegative = 0; - int i = 0; - if (c == '-') { - isnegative = 1; - c = streamGetChar(self); - } - if (c == '.') { - type = pdf_real; - isfraction = 1; - } else { - value = c - '0'; - } - c = streamLookChar(self); - if ((c>= '0'&& c<= '9') || c == '.') { - c = streamGetChar(self); - while (1) { - if (c == '.') { - type = pdf_real; - isfraction = 1; - } else { - i = c - '0'; - if (isfraction>0) { - value = value + (i/(pow(10.0,isfraction))); - isfraction = isfraction + 1; - } else { - value = (value * 10) + i; - } - } - c = streamLookChar(self); - if (! ((c>= '0' && c<= '9') || c == '.')) break ; - c = streamGetChar(self); - } - } - if (isnegative) { - value = -value; - } - Token *token = new_operand(type); - token->value = value; - return token; + double value = 0; + pdf_token_type type = pdf_integer; + int isfraction = 0; + int isnegative = 0; + int i = 0; + if (c == '-') { + isnegative = 1; + c = streamGetChar(self); + } + if (c == '.') { + type = pdf_real; + isfraction = 1; + } else { + value = c - '0'; + } + c = streamLookChar(self); + if ((c>= '0'&& c<= '9') || c == '.') { + c = streamGetChar(self); + while (1) { + if (c == '.') { + type = pdf_real; + isfraction = 1; + } else { + i = c - '0'; + if (isfraction>0) { + value = value + (i/(pow(10.0,isfraction))); + isfraction = isfraction + 1; + } else { + value = (value * 10) + i; + } + } + c = streamLookChar(self); + if (! ((c>= '0' && c<= '9') || c == '.')) + break ; + c = streamGetChar(self); + } + } + if (isnegative) { + value = -value; + } + Token *token = new_operand(type); + token->value = value; + return token; } - static Token *_parseName (scannerdata *self, int c) { - define_buffer(found); - c = streamGetChar(self); - while (1) { - check_overflow(found,foundindex); - found[foundindex++] = c; - c = streamLookChar(self); - if (c == ' ' || c == '\n' || c == '\r' || c == '\t' || - c == '/' || c == '[' || c == '(' || c == '<') break ; + define_buffer(found); c = streamGetChar(self); - } - Token *token = new_operand(pdf_name); - token->string = found; - token->value = strlen(found); - return token; + while (1) { + check_overflow(found,foundindex); + found[foundindex++] = c; + c = streamLookChar(self); + if (c == ' ' || c == '\n' || c == '\r' || c == '\t' || + c == '/' || c == '[' || c == '(' || c == '<') break ; + c = streamGetChar(self); + } + Token *token = new_operand(pdf_name); + token->string = found; + token->value = strlen(found); + return token; } -#define hexdigit(c) \ +#define hexdigit(c) \ (c>= '0' && c<= '9') ? (c - '0') : ((c>= 'A' && c<= 'F') ? (c - 'A' + 10) : (c - 'a' + 10)) static Token *_parseHexstring (scannerdata *self, int c) { - int isodd = 1; - int hexval = 0; - define_buffer(found); - while (c != '>') { - if ((c>= '0' && c<= '9') || - (c>= 'A' && c<= 'F') || - (c>= 'a' && c<= 'f')) { - if (isodd==1) { - int v = hexdigit(c); - hexval = 16 * v; - } else { - hexval += hexdigit(c); - check_overflow(found,foundindex); - found[foundindex++] = hexval; - } - isodd = (isodd==1 ? 0 : 1); + int isodd = 1; + int hexval = 0; + define_buffer(found); + while (c != '>') { + if ((c>= '0' && c<= '9') || (c>= 'A' && c<= 'F') || (c>= 'a' && c<= 'f')) { + if (isodd==1) { + int v = hexdigit(c); + hexval = 16 * v; + } else { + hexval += hexdigit(c); + check_overflow(found,foundindex); + found[foundindex++] = hexval; + } + isodd = (isodd==1 ? 0 : 1); + } + c = streamGetChar(self); } - c = streamGetChar(self); - } - Token *token = new_operand(pdf_string); - token->value = foundindex; - token->string = found; - return token; + Token *token = new_operand(pdf_string); + token->value = foundindex; + token->string = found; + return token; } #define pdf_isspace(a) (a == '\0' || a == ' ' || a == '\n' || a == '\r' || a == '\t' || a == '\v') // -- this is rather horrible + static Token *_parseInlineImage (scannerdata *self, int c) { - define_buffer(found); - if (c == ' ') { // first space can be ignored - c = streamGetChar(self); - } - check_overflow(found, foundindex); - found[foundindex++] = c; - while (1) { - c = streamLookChar(self); - if (c == 'E' && (found[foundindex-1] == '\n' || found[foundindex-1] == '\r')) { - c = streamGetChar(self); - check_overflow(found, foundindex); - found[foundindex++] = c; - c = streamLookChar(self); - if (c == 'I') { - c = streamGetChar(self); - check_overflow(found, foundindex); - found[foundindex++] = c; - c = streamLookChar(self); - if (pdf_isspace(c)) { - found[--foundindex] = '\0'; /* I */ - found[--foundindex] = '\0'; /* E */ - /* remove end-of-line before EI */ - if (found[foundindex-1] == '\n') { - found[--foundindex] = '\0'; - } - if (found[foundindex-1] == '\r') { - found[--foundindex] = '\0'; - } - break; - } else { - c = streamGetChar(self); - check_overflow(found, foundindex); - found[foundindex++] = c; - } - } else { - c = streamGetChar(self); - check_overflow(found, foundindex); - found[foundindex++] = c; - } - } else { - c = streamGetChar(self); - check_overflow(found, foundindex); - found[foundindex++] = c; + define_buffer(found); + if (c == ' ') { // first space can be ignored + c = streamGetChar(self); } - } - Token *token = new_operand(pdf_string); - token->value = foundindex; - token->string = found; - return token; -} - -static Token *_parseOperator (scannerdata *self, int c) -{ - define_buffer(found); - while (1) { check_overflow(found, foundindex); found[foundindex++] = c; - c = streamLookChar(self); - if ((c<0) || (c == ' ' || c == '\n' || c == '\r' || c == '\t' || - c == '/' || c == '[' || c == '(' || c == '<')) - break ; - c = streamGetChar(self); - } - // print (found) - if (strcmp(found, "ID") == 0) { - self->_ininlineimage = 1; - } - if (strcmp(found,"false") == 0) { - Token *token = new_operand(pdf_boolean); - token->value = 0; - free(found); - return token; - } else if (strcmp(found,"true") == 0) { - Token *token = new_operand(pdf_boolean); - token->value = 1.0; - free(found); - return token; - } else { - Token *token = new_operand(pdf_operator); + while (1) { + c = streamLookChar(self); + if (c == 'E' && (found[foundindex-1] == '\n' || found[foundindex-1] == '\r')) { + c = streamGetChar(self); + check_overflow(found, foundindex); + found[foundindex++] = c; + c = streamLookChar(self); + if (c == 'I') { + c = streamGetChar(self); + check_overflow(found, foundindex); + found[foundindex++] = c; + c = streamLookChar(self); + if (pdf_isspace(c)) { + found[--foundindex] = '\0'; /* I */ + found[--foundindex] = '\0'; /* E */ + /* remove end-of-line before EI */ + if (found[foundindex-1] == '\n') { + found[--foundindex] = '\0'; + } + if (found[foundindex-1] == '\r') { + found[--foundindex] = '\0'; + } + break; + } else { + c = streamGetChar(self); + check_overflow(found, foundindex); + found[foundindex++] = c; + } + } else { + c = streamGetChar(self); + check_overflow(found, foundindex); + found[foundindex++] = c; + } + } else { + c = streamGetChar(self); + check_overflow(found, foundindex); + found[foundindex++] = c; + } + } + Token *token = new_operand(pdf_string); + token->value = foundindex; token->string = found; return token; - } +} + +static Token *_parseOperator (scannerdata *self, int c) +{ + define_buffer(found); + while (1) { + check_overflow(found, foundindex); + found[foundindex++] = c; + c = streamLookChar(self); + if ((c<0) || (c == ' ' || c == '\n' || c == '\r' || c == '\t' || + c == '/' || c == '[' || c == '(' || c == '<')) + break ; + c = streamGetChar(self); + } + // print (found) + if (strcmp(found, "ID") == 0) { + self->_ininlineimage = 1; + } + if (strcmp(found,"false") == 0) { + Token *token = new_operand(pdf_boolean); + token->value = 0; + free(found); + return token; + } else if (strcmp(found,"true") == 0) { + Token *token = new_operand(pdf_boolean); + token->value = 1.0; + free(found); + return token; + } else { + Token *token = new_operand(pdf_operator); + token->string = found; + return token; + } } static Token * _parseComment (scannerdata *self, int c) { - do { - c = streamGetChar(self); - } while (c != '\n' && c != '\r' && c != -1); - return _parseToken(self,streamGetChar(self)); + do { + c = streamGetChar(self); + } while (c != '\n' && c != '\r' && c != -1); + return _parseToken(self,streamGetChar(self)); } static Token *_parseLt (scannerdata *self, int c) { - c = streamGetChar(self); - if (c == '<') { - return new_operand(pdf_startdict); - } else { - return _parseHexstring(self,c); - } + c = streamGetChar(self); + if (c == '<') { + return new_operand(pdf_startdict); + } else { + return _parseHexstring(self,c); + } } static Token * _parseGt (scannerdata *self, int c) { - c = streamGetChar(self); - if (c== '>') { - return new_operand(pdf_stopdict); - } else { - fprintf(stderr,"stray > in stream"); - return NULL; - } + c = streamGetChar(self); + if (c== '>') { + return new_operand(pdf_stopdict); + } else { + fprintf(stderr,"stray > in stream"); + return NULL; + } } - static Token *_parseError (int c) { - fprintf(stderr, "stray %c [%d] in stream", c, c); - return NULL; + fprintf(stderr, "stray %c [%d] in stream", c, c); + return NULL; } static Token *_parseStartarray () { - return new_operand (pdf_startarray); + return new_operand (pdf_startarray); } static Token *_parseStoparray () { - return new_operand (pdf_stoparray); + return new_operand (pdf_stoparray); } static Token *_parseToken (scannerdata *self, int c) { - if (self->_ininlineimage==1) { - self->_ininlineimage = 2; - return _parseInlineImage(self,c); - } else if (self->_ininlineimage==2) { - self->_ininlineimage = 0; - Token *token = new_operand(pdf_operator); - token->string = strdup("EI"); - return token; - } - if (c<0) return NULL ; - switch (c) { - case '(': return _parseString(self,c); break; - case ')': return _parseError(c); break; - case '[': return _parseStartarray(); break; - case ']': return _parseStoparray(); break; - case '/': return _parseName(self,c); break; - case '<': return _parseLt(self,c); break; - case '>': return _parseGt(self,c); break; - case '%': return _parseComment(self,c); break; - case ' ': - case '\r': - case '\n': - case '\t': - return _parseSpace(self); break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '-': - case '.': - return _parseNumber(self,c); break; - default: - if (c<=127) { - return _parseOperator(self,c); - } else { - return _parseError(c); - } - } + if (self->_ininlineimage==1) { + self->_ininlineimage = 2; + return _parseInlineImage(self,c); + } else if (self->_ininlineimage==2) { + self->_ininlineimage = 0; + Token *token = new_operand(pdf_operator); + token->string = strdup("EI"); + return token; + } + if (c<0) + return NULL ; + switch (c) { + case '(': + return _parseString(self,c); + break; + case ')': + return _parseError(c); + break; + case '[': + return _parseStartarray(); + break; + case ']': + return _parseStoparray(); + break; + case '/': + return _parseName(self,c); + break; + case '<': + return _parseLt(self,c); + break; + case '>': + return _parseGt(self,c); + break; + case '%': + return _parseComment(self,c); + break; + case ' ': + case '\r': + case '\n': + case '\t': + return _parseSpace(self); + break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '-': + case '.': + return _parseNumber(self,c); + break; + default: + if (c<=127) { + return _parseOperator(self,c); + } else { + return _parseError(c); + } + } } static int scanner_scan(lua_State * L) { - Token *token; - scannerdata *self; - if (lua_gettop(L) != 3) { - return 0; - } - luaL_checktype(L, 2, LUA_TTABLE); - luaL_checktype(L, 3, LUA_TTABLE); - self = scanner_push(L); - memset(self,0,sizeof(scannerdata)); - self->_operandstack = (Token **)priv_xmalloc (MAXOPERANDS * sizeof (Token)); - memset (self->_operandstack,0,(MAXOPERANDS * sizeof (Token))); - // 4 = self - if (lua_type(L,1)== LUA_TTABLE) { - udstruct *uin; - int i = 1; - while (1) { - lua_rawgeti(L,1,i); - if (lua_type(L,-1)== LUA_TUSERDATA) { - uin = (udstruct *) luaL_checkudata(L, -1, M_Object); - if (((Object *) uin->d)->isStream()) { - ObjectList *rover = self->_streams; - ObjectList *item = (ObjectList *)priv_xmalloc (sizeof(ObjectList)); - item->stream = ((Object *) uin->d); - item->next = NULL; - if (!rover) { - rover = item; - self->_streams = rover; - } else { - while (rover->next) - rover = rover->next; - rover->next = item; - } - } - } else { // done - ObjectList *rover = self->_streams; - self->_stream = rover->stream; - self->_streams = rover->next; - free(rover); - lua_pop(L,1); - break; - } - lua_pop(L,1); - i++; - } - - } else { - udstruct *uin; - luaL_checktype(L, 1, LUA_TUSERDATA); - uin = (udstruct *) luaL_checkudata(L, 1, M_Object); - if (((Object *) uin->d)->isStream()) { - self->_stream = ((Object *) uin->d); - } else if (((Object *) uin->d)->isArray()) { - Array *arrayref = ((Object *) uin->d)->getArray(); - int count = arrayref->getLength(); - int i; - for (i=0;i<count;i++) { - Object *val = new Object(); - *val = arrayref->get(i); - if (val->isStream()) { - ObjectList *rover = self->_streams; - ObjectList *item = (ObjectList *)priv_xmalloc (sizeof(ObjectList)); - item->stream = val; - item->next = NULL; - if (!rover) { - rover = item; - self->_streams = rover; - } else { - while (rover->next) - rover = rover->next; - rover->next = item; - } - } - } - ObjectList *rover = self->_streams; - self->_stream = rover->stream; - self->_streams = rover->next; - } - - } - assert (lua_gettop(L) == 4); - self->_stream->streamReset(); - token = _parseToken(self,streamGetChar(self)); - while (token) { - if (token->type == pdf_operator) { - lua_pushstring(L, token->string); - free_token(token); - lua_rawget(L,2); // operator table - if (lua_isfunction(L,-1)) { - lua_pushvalue(L,4); - lua_pushvalue(L,3); - (void)lua_call(L,2,0); - } else { - lua_pop(L,1); // nil - } - clear_operand_stack(self,0); - } else { - push_operand(self, token); + Token *token; + scannerdata *self; + if (lua_gettop(L) != 3) { + return 0; } - if (!self->_stream) { - break; + luaL_checktype(L, 2, LUA_TTABLE); + luaL_checktype(L, 3, LUA_TTABLE); + self = scanner_push(L); + memset(self,0,sizeof(scannerdata)); + self->_operandstack = (Token **)priv_xmalloc (MAXOPERANDS * sizeof (Token)); + memset (self->_operandstack,0,(MAXOPERANDS * sizeof (Token))); + // 4 = self + if (lua_type(L,1)== LUA_TTABLE) { + udstruct *uin; + void *ud; + int i = 1; + while (1) { + lua_rawgeti(L,1,i); + if (lua_type(L,-1)== LUA_TUSERDATA) { + ud = luaL_checkudata(L, -1, PDFE_METATABLE_STREAM); + if (ud != NULL) { + uin = (udstruct *) ud; + ObjectList *rover = self->_streams; + ObjectList *item = (ObjectList *)priv_xmalloc (sizeof(ObjectList)); + item->stream = ((ppstream *) uin->d); + item->next = NULL; + if (!rover) { + rover = item; + self->_streams = rover; + } else { + while (rover->next) + rover = rover->next; + rover->next = item; + } + } + } else { + ObjectList *rover = self->_streams; + self->_stream = rover->stream; + self->_streams = rover->next; + free(rover); + lua_pop(L,1); + break; + } + lua_pop(L,1); + i++; + } + } else { + udstruct *uin; + void *ud; + luaL_checktype(L, 1, LUA_TUSERDATA); + ud = luaL_checkudata(L, 1, PDFE_METATABLE_STREAM); + if (ud != NULL) { + uin = (udstruct *) ud; + self->_stream = ((ppstream *) uin->d); + } else { + ud = luaL_checkudata(L, 1, PDFE_METATABLE_ARRAY); + if (ud != NULL) { + uin = (udstruct *) ud; + pparray * array = (pparray *) uin->d; + int count = array->size; + int i; + for (i=0;i<count;i++) { + ppobj *obj = pparray_at(array,i); + if (obj->type == PPSTREAM) { + ObjectList *rover = self->_streams; + ObjectList *item = (ObjectList *)priv_xmalloc (sizeof(ObjectList)); + item->stream = obj->stream; + item->next = NULL; + if (!rover) { + rover = item; + self->_streams = rover; + } else { + while (rover->next) + rover = rover->next; + rover->next = item; + } + } + } + ObjectList *rover = self->_streams; + self->_stream = rover->stream; + self->_streams = rover->next; + } + } } + streamReset(self); token = _parseToken(self,streamGetChar(self)); - } - /* wrap up */ - if (self->_stream) { - self->_stream->streamClose(); - self->_stream = NULL; - } - clear_operand_stack(self,0); - free(self->_operandstack); - return 0; + while (token) { + if (token->type == pdf_operator) { + lua_pushstring(L, token->string); + free_token(token); + lua_rawget(L,2); // operator table + if (lua_isfunction(L,-1)) { + lua_pushvalue(L,4); + lua_pushvalue(L,3); + (void)lua_call(L,2,0); + } else { + lua_pop(L,1); // nil + } + clear_operand_stack(self,0); + } else { + push_operand(self, token); + } + if (!self->_stream) { + break; + } + token = _parseToken(self,streamGetChar(self)); + } + /* wrap up */ + if (self->_stream) { + streamClose(self); + } + clear_operand_stack(self,0); + free(self->_operandstack); + return 0; } static int scanner_done(lua_State * L) { - int c; - scannerdata *self = scanner_check(L,1); - while ((c=streamGetChar(self))>=0) - ; - return 0; + int c; + scannerdata *self = scanner_check(L,1); + while ((c=streamGetChar(self))>=0) ; + return 0; } // here are the stack popping functions, and their helpers static void operandstack_backup (scannerdata *self) { - int i = self->_nextoperand-1; - int balance = 0; - int backupstart = 0; - int backupstop = self->_operandstack[i]->type; - if (backupstop == pdf_stopdict) { - backupstart = pdf_startdict; - } else if (backupstop == pdf_stoparray) { - backupstart = pdf_startarray; - } else { - return; - } - for (;i>=0;i--) { - if (self->_operandstack[i]->type == backupstop) { - balance++; - } else if (self->_operandstack[i]->type == backupstart) { - balance--; - } - if (balance==0) { - break; - } - } - self->_nextoperand = i+1; + int i = self->_nextoperand-1; + int balance = 0; + int backupstart = 0; + int backupstop = self->_operandstack[i]->type; + if (backupstop == pdf_stopdict) { + backupstart = pdf_startdict; + } else if (backupstop == pdf_stoparray) { + backupstart = pdf_startarray; + } else { + return; + } + for (;i>=0;i--) { + if (self->_operandstack[i]->type == backupstop) { + balance++; + } else if (self->_operandstack[i]->type == backupstart) { + balance--; + } + if (balance==0) { + break; + } + } + self->_nextoperand = i+1; } static void push_array (lua_State *L, scannerdata *self) { - int balance = 1; // nesting tracking - int index = 1; // lua array index - Token *token = self->_operandstack[self->_nextoperand++]; - lua_newtable(L); - while (token) { - if (token->type == pdf_stoparray) - balance --; - if (token->type == pdf_startarray) - balance ++; - if (!balance) { - break; - } else { - push_token(L,self); - lua_rawseti(L,-2, index++); + int balance = 1; // nesting tracking + int index = 1; // lua array index + Token *token = self->_operandstack[self->_nextoperand++]; + lua_newtable(L); + while (token) { + if (token->type == pdf_stoparray) + balance --; + if (token->type == pdf_startarray) + balance ++; + if (!balance) { + break; + } else { + push_token(L,self); + lua_rawseti(L,-2, index++); + } + token = self->_operandstack[self->_nextoperand++]; } - token = self->_operandstack[self->_nextoperand++]; - } } static void push_dict (lua_State *L, scannerdata *self) { - int balance = 1; // nesting tracking - int needskey = 1; // toggle between lua value and lua key - Token *token = self->_operandstack[self->_nextoperand++]; - lua_newtable(L); - while (token) { - if (token->type == pdf_stopdict) - balance --; - if (token->type == pdf_startdict) - balance ++; - if (!balance) { - break; - } else { - if (needskey) { - lua_pushlstring(L, token->string, token->value); - needskey = 0; - } else { - push_token(L,self); - needskey = 1; - lua_rawset(L,-3); - } + int balance = 1; // nesting tracking + int needskey = 1; // toggle between lua value and lua key + Token *token = self->_operandstack[self->_nextoperand++]; + lua_newtable(L); + while (token) { + if (token->type == pdf_stopdict) + balance --; + if (token->type == pdf_startdict) + balance ++; + if (!balance) { + break; + } else if (needskey) { + lua_pushlstring(L, token->string, token->value); + needskey = 0; + } else { + push_token(L,self); + needskey = 1; + lua_rawset(L,-3); + } + token = self->_operandstack[self->_nextoperand++]; } - token = self->_operandstack[self->_nextoperand++]; - } } -const char *typenames[pdf_stopdict+1] = - { "unknown", "integer", "real", "boolean", "name", "operator", - "string", "array", "array", "dict", "dict" }; +const char *typenames[pdf_stopdict+1] = { + "unknown", "integer", "real", "boolean", "name", "operator", + "string", "array", "array", "dict", "dict" +}; static void push_token (lua_State *L, scannerdata *self) { - Token *token = self->_operandstack[self->_nextoperand-1]; - lua_createtable(L,2,0); - lua_pushstring (L, typenames[token->type]); - lua_rawseti(L,-2,1); - if (token->type == pdf_string || token->type == pdf_name) { - lua_pushlstring(L, token->string, token->value); - } else if (token->type == pdf_real || token->type == pdf_integer) { - lua_pushnumber(L, token->value); /* integer or float */ - } else if (token->type == pdf_boolean) { - lua_pushboolean(L, (int)token->value); - } else if (token->type == pdf_startarray) { - push_array(L, self); - } else if (token->type == pdf_startdict) { - push_dict(L, self); - } else { - lua_pushnil(L); - } - lua_rawseti(L,-2, 2); + Token *token = self->_operandstack[self->_nextoperand-1]; + lua_createtable(L,2,0); + lua_pushstring (L, typenames[token->type]); + lua_rawseti(L,-2,1); + if (token->type == pdf_string || token->type == pdf_name) { + lua_pushlstring(L, token->string, token->value); + } else if (token->type == pdf_real || token->type == pdf_integer) { + lua_pushnumber(L, token->value); /* integer or float */ + } else if (token->type == pdf_boolean) { + lua_pushboolean(L, (int)token->value); + } else if (token->type == pdf_startarray) { + push_array(L, self); + } else if (token->type == pdf_startdict) { + push_dict(L, self); + } else { + lua_pushnil(L); + } + lua_rawseti(L,-2, 2); } static int scanner_popsingular (lua_State * L, int token_type) { - int clear = 0; // how much of the operand stack needs deleting - scannerdata *self = scanner_check(L,1); - if (self->_nextoperand==0) { - return 0; - } - clear = self->_nextoperand-1; - Token *token = self->_operandstack[self->_nextoperand-1]; - if (token ==NULL || (token->type != token_type )) { - return 0; - } - // the simple cases can be written out directly, but dicts and - // arrays are better done via the recursive function - if (token_type == pdf_stoparray || token_type == pdf_stopdict) { - operandstack_backup(self); + int clear = 0; // how much of the operand stack needs deleting + scannerdata *self = scanner_check(L,1); + if (self->_nextoperand==0) { + return 0; + } clear = self->_nextoperand-1; - push_token(L, self); - lua_rawgeti(L,-1,2); - } else if (token_type == pdf_real || token_type == pdf_integer) { - lua_pushnumber(L, token->value); /* integer or float */ - } else if (token_type == pdf_boolean) { - lua_pushboolean(L,(int)token->value); - } else if (token_type == pdf_name || token_type == pdf_string) { - lua_pushlstring(L, token->string, token->value); - } else { - return 0; - } - clear_operand_stack(self,clear); - return 1; + Token *token = self->_operandstack[self->_nextoperand-1]; + if (token ==NULL || (token->type != token_type )) { + return 0; + } + // the simple cases can be written out directly, but dicts and + // arrays are better done via the recursive function + if (token_type == pdf_stoparray || token_type == pdf_stopdict) { + operandstack_backup(self); + clear = self->_nextoperand-1; + push_token(L, self); + lua_rawgeti(L,-1,2); + } else if (token_type == pdf_real || token_type == pdf_integer) { + lua_pushnumber(L, token->value); /* integer or float */ + } else if (token_type == pdf_boolean) { + lua_pushboolean(L,(int)token->value); + } else if (token_type == pdf_name || token_type == pdf_string) { + lua_pushlstring(L, token->string, token->value); + } else { + return 0; + } + clear_operand_stack(self,clear); + return 1; } static int scanner_popanything (lua_State * L) { - int clear = 0; // how much of the operand stack needs deleting - scannerdata *self = scanner_check(L,1); - if (self->_nextoperand==0) { - return 0; - } - clear = self->_nextoperand-1; - Token *token = self->_operandstack[self->_nextoperand-1]; - if (token ==NULL) { - return 0; - } - int token_type = token->type; - // the simple cases can be written out directly, but dicts and - // arrays are better done via the recursive function - if (token_type == pdf_stoparray || token_type == pdf_stopdict) { - operandstack_backup(self); + int clear = 0; // how much of the operand stack needs deleting + scannerdata *self = scanner_check(L,1); + if (self->_nextoperand==0) { + return 0; + } clear = self->_nextoperand-1; - push_token(L, self); - } else { - push_token(L, self); - } - clear_operand_stack(self,clear); - return 1; + Token *token = self->_operandstack[self->_nextoperand-1]; + if (token ==NULL) { + return 0; + } + int token_type = token->type; + // the simple cases can be written out directly, but dicts and + // arrays are better done via the recursive function + if (token_type == pdf_stoparray || token_type == pdf_stopdict) { + operandstack_backup(self); + clear = self->_nextoperand-1; + push_token(L, self); + } else { + push_token(L, self); + } + clear_operand_stack(self,clear); + return 1; } static int scanner_popnumber(lua_State * L) { - if(scanner_popsingular(L,pdf_real)) - return 1; - if (scanner_popsingular(L,pdf_integer)) - return 1; - lua_pushnil(L); + if(scanner_popsingular(L,pdf_real)) + return 1; + if (scanner_popsingular(L,pdf_integer)) + return 1; + lua_pushnil(L); return 1; } static int scanner_popboolean(lua_State * L) { - if(scanner_popsingular(L,pdf_boolean)) + if(scanner_popsingular(L,pdf_boolean)) + return 1; + lua_pushnil(L); return 1; - lua_pushnil(L); - return 1; } static int scanner_popstring(lua_State * L) { - if (scanner_popsingular(L,pdf_string)) + if (scanner_popsingular(L,pdf_string)) + return 1; + lua_pushnil(L); return 1; - lua_pushnil(L); - return 1; } static int scanner_popname(lua_State * L) { - if (scanner_popsingular(L,pdf_name)) + if (scanner_popsingular(L,pdf_name)) + return 1; + lua_pushnil(L); return 1; - lua_pushnil(L); - return 1; } static int scanner_poparray(lua_State * L) { - if (scanner_popsingular(L,pdf_stoparray)) + if (scanner_popsingular(L,pdf_stoparray)) + return 1; + lua_pushnil(L); return 1; - lua_pushnil(L); - return 1; } static int scanner_popdictionary(lua_State * L) { - if (scanner_popsingular(L,pdf_stopdict)) + if (scanner_popsingular(L,pdf_stopdict)) + return 1; + lua_pushnil(L); return 1; - lua_pushnil(L); - return 1; } static int scanner_popany(lua_State * L) { - if (scanner_popanything(L)) + if (scanner_popanything(L)) + return 1; + lua_pushnil(L); return 1; - lua_pushnil(L); - return 1; } static const luaL_Reg scannerlib_meta[] = { - {0, 0} + {0, 0} }; static const struct luaL_Reg scannerlib_m[] = { @@ -929,10 +1020,9 @@ static const struct luaL_Reg scannerlib_m[] = { {"popDict", scanner_popdictionary}, {"popBool", scanner_popboolean}, {"pop", scanner_popany}, - {NULL, NULL} /* sentinel */ + {NULL, NULL} /* sentinel */ }; - static const luaL_Reg scannerlib[] = { {"scan", scanner_scan}, {NULL, NULL} diff --git a/Build/source/texk/web2c/luatexdir/lua/lstatslib.c b/Build/source/texk/web2c/luatexdir/lua/lstatslib.c index 43f33008db4..5f3b72262c6 100644 --- a/Build/source/texk/web2c/luatexdir/lua/lstatslib.c +++ b/Build/source/texk/web2c/luatexdir/lua/lstatslib.c @@ -147,13 +147,15 @@ static lua_Number get_luatexhashchars(void) static const char *get_luatexhashtype(void) { #ifdef LuajitTeX - return (const char *)jithash_hashname; + if (jithash_hashname) + return (const char *)jithash_hashname; + else + return "???"; #else return "lua"; #endif } - static lua_Number get_pdf_gone(void) { if (static_pdf != NULL) @@ -266,8 +268,22 @@ static lua_Number get_development_id(void) return (lua_Number) luatex_svn_revision ; } +static lua_Number get_dvi_gone(void) +{ + if (static_pdf != NULL) + return (lua_Number) dvi_get_status_gone(static_pdf); + return (lua_Number) 0; +} + +static lua_Number get_dvi_ptr(void) +{ + if (static_pdf != NULL) + return (lua_Number) dvi_get_status_ptr(static_pdf); + return (lua_Number) 0; +} /* temp, for backward compat */ + static int init_pool_ptr = 0; static struct statistic stats[] = { @@ -291,8 +307,9 @@ static struct statistic stats[] = { {"pdf_gone", 'N', &get_pdf_gone}, {"pdf_ptr", 'N', &get_pdf_ptr}, - {"dvi_gone", 'g', &dvi_offset}, - {"dvi_ptr", 'g', &dvi_ptr}, + {"dvi_gone", 'g', &get_dvi_gone}, + {"dvi_ptr", 'g', &get_dvi_ptr}, + {"total_pages", 'g', &total_pages}, {"output_file_name", 'S', (void *) &get_output_file_name}, {"log_name", 'S', (void *) &getlogname}, @@ -355,9 +372,14 @@ static struct statistic stats[] = { {"luabytecodes", 'g', &luabytecode_max}, {"luabytecode_bytes", 'g', &luabytecode_bytes}, {"luastate_bytes", 'g', &luastate_bytes}, + {"callbacks", 'g', &callback_count}, + {"indirect_callbacks", 'g', &saved_callback_count}, /* these are file io callbacks */ - {"indirect_callbacks", 'g', &saved_callback_count}, + {"saved_callbacks", 'g', &saved_callback_count}, + {"late_callbacks", 'g', &late_callback_count}, + {"direct_callbacks", 'g', &direct_callback_count}, + {"function_callbacks", 'g', &function_callback_count}, {"lc_ctype", 'S', (void *) &get_lc_ctype}, {"lc_collate", 'S', (void *) &get_lc_collate}, diff --git a/Build/source/texk/web2c/luatexdir/lua/ltexiolib.c b/Build/source/texk/web2c/luatexdir/lua/ltexiolib.c index f0fa5d369fe..5f1786c65c0 100644 --- a/Build/source/texk/web2c/luatexdir/lua/ltexiolib.c +++ b/Build/source/texk/web2c/luatexdir/lua/ltexiolib.c @@ -155,10 +155,26 @@ static int texio_setescape(lua_State * L) return 0 ; } +static int texio_closeinput(lua_State * L) +{ + /* + printf("before, first %i, index %i, iname %i, inopen %i, pointer %i\n",istart,iindex,iname,in_open,input_ptr); + */ + if (iindex > 0) { + end_token_list(); + end_file_reading(); + /* + printf("after, first %i, index %i, iname %i, inopen %i, pointer %i\n",istart,iindex,iname,in_open,input_ptr); + */ + } + return 0 ; +} + static const struct luaL_Reg texiolib[] = { {"write", texio_print}, {"write_nl", texio_printnl}, {"setescape", texio_setescape}, + {"closeinput",texio_closeinput}, {NULL, NULL} }; diff --git a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c index 65e55705e44..c3e459b2211 100644 --- a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c +++ b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c @@ -35,7 +35,8 @@ typedef struct { void *next; boolean partial; int cattable; - /* halfword tok; */ + halfword tok; + halfword nod; } rope; typedef struct { @@ -54,33 +55,64 @@ static int spindle_size = 0; static spindle *spindles = NULL; static int spindle_index = 0; -static void luac_store(lua_State * L, int i, int partial, int cattable) +static int luac_store(lua_State * L, int i, int partial, int cattable) { - const char *sttemp; - char *st; - size_t tsize; + char *st = NULL; + size_t tsize = 0; rope *rn = NULL; - sttemp = lua_tolstring(L, i, &tsize); - st = xmalloc((unsigned) (tsize + 1)); - memcpy(st, sttemp, (tsize + 1)); - if (st) { - luacstrings++; - rn = (rope *) xmalloc(sizeof(rope)); - rn->text = st; - rn->tsize = (unsigned) tsize; - rn->partial = partial; - rn->cattable = cattable; - rn->next = NULL; - /* rn->tok = 0; */ - if (write_spindle.head == NULL) { - assert(write_spindle.tail == NULL); - write_spindle.head = rn; + halfword tok = null; + halfword nod = null; + int t = lua_type(L, i); + if (t == LUA_TNUMBER || t == LUA_TSTRING) { + const char *sttemp; + sttemp = lua_tolstring(L, i, &tsize); + st = xmalloc((unsigned) (tsize + 1)); + memcpy(st, sttemp, (tsize + 1)); + } else if (t == LUA_TUSERDATA) { + void *p ; + p = lua_touserdata(L, i); + if (p == NULL) { + return 0; + } else if (lua_getmetatable(L, i)) { + lua_get_metatablelua(luatex_token); + if (lua_rawequal(L, -1, -2)) { + tok = (halfword) token_info((*((lua_token *)p)).token); + lua_pop(L, 2); + } else { + lua_get_metatablelua(luatex_node); + if (lua_rawequal(L, -1, -3)) { + nod = *((halfword *)p); + lua_pop(L, 3); + } else { + lua_pop(L, 3); + return 0; + } + } } else { - write_spindle.tail->next = rn; + return 0; } - write_spindle.tail = rn; - write_spindle.complete = 0; + } else { + return 0; + } + /* common */ + luacstrings++; + rn = (rope *) xmalloc(sizeof(rope)); + rn->text = st; + rn->tsize = (unsigned) tsize; + rn->tok = tok; + rn->nod = nod; + rn->next = NULL; + rn->partial = partial; + rn->cattable = cattable; + /* add */ + if (write_spindle.head == NULL) { + write_spindle.head = rn; + } else { + write_spindle.tail->next = rn; } + write_spindle.tail = rn; + write_spindle.complete = 0; + return 1; } static int do_luacprint(lua_State * L, int partial, int deftable) @@ -93,47 +125,33 @@ static int do_luacprint(lua_State * L, int partial, int deftable) cattable = lua_tointeger(L, 1); startstrings = 2; if (cattable != -1 && cattable != -2 && !valid_catcode_table(cattable)) { - cattable = DEFAULT_CAT_TABLE; - } + cattable = DEFAULT_CAT_TABLE; + } } } if (lua_type(L, startstrings) == LUA_TTABLE) { int i; for (i = 1;; i++) { lua_rawgeti(L, startstrings, i); - if (lua_isstring(L,-1)) { /* or number */ - luac_store(L, -1, partial, cattable); + if (luac_store(L, -1, partial, cattable)) { lua_pop(L, 1); } else { + lua_pop(L, 1); break; } } } else { int i; for (i = startstrings; i <= n; i++) { - if (!lua_isstring(L,i)) { /* or number */ - luaL_error(L, "no string to print"); - } luac_store(L, i, partial, cattable); } - /* hh: We could use this but it makes not much different, apart from allocating more ropes so less - memory. To be looked into: lua 5.2 buffer mechanism as now we still hash the concatination. This - test was part of the why-eis-luajit-so-slow on crited experiments. */ - /* - if (startstrings == n) { - luac_store(L, n, partial, cattable); - } else { - lua_concat(L,n-startstrings+1); - luac_store(L, startstrings, partial, cattable); - } - */ } return 0; } -/* +/* the next one writes a raw token (number) */ -// some first experiments .. somewhat tricky at the other end +/* int luatwrite(lua_State * L) { @@ -148,6 +166,7 @@ int luatwrite(lua_State * L) rn->cattable = DEFAULT_CAT_TABLE; rn->next = NULL; rn->tok = 0; + rn->nod = 0; if (write_spindle.head == NULL) { write_spindle.head = rn; } else { @@ -165,6 +184,7 @@ int luatwrite(lua_State * L) r->cattable = DEFAULT_CAT_TABLE; r->next = NULL; r->tok = 0; + r->nod = 0; rn->next = r; rn = r; write_spindle.tail = rn; @@ -179,21 +199,79 @@ int luatwrite(lua_State * L) */ +/* the next one writes a raw node (number) */ + +/* + +int luanwrite(lua_State * L) +{ + int top = lua_gettop(L); + if (top>0) { + rope *rn = xmalloc(sizeof(rope)); // overkill + int i = 1 ; + luacstrings++; // should be luactokens + rn->text = NULL; + rn->tsize = 0; + rn->partial = 0; + rn->cattable = DEFAULT_CAT_TABLE; + rn->next = NULL; + rn->tok = 0; + rn->nod = 0; + if (write_spindle.head == NULL) { + write_spindle.head = rn; + } else { + write_spindle.tail->next = rn; + } + write_spindle.tail = rn; + write_spindle.complete = 0; + while (1) { + rn->nod = lua_tointeger(L,i); + if (i<top) { + rope *r = xmalloc(sizeof(rope)); // overkill + r->text = NULL; + r->tsize = 0; + r->partial = 0; + r->cattable = DEFAULT_CAT_TABLE; + r->next = NULL; + r->tok = 0; + r->nod = 0; + rn->next = r; + rn = r; + write_spindle.tail = rn; + i++; + } else { + break; + } + } + } + return 0; +} + +*/ + +/* lua.write */ + static int luacwrite(lua_State * L) { return do_luacprint(L, FULL_LINE, NO_CAT_TABLE); } +/* lua.print */ + static int luacprint(lua_State * L) { return do_luacprint(L, FULL_LINE, DEFAULT_CAT_TABLE); } +/* lua.sprint */ + static int luacsprint(lua_State * L) { return do_luacprint(L, PARTIAL_LINE, DEFAULT_CAT_TABLE); } +/* lua.cprint */ + static int luaccprint(lua_State * L) { /* so a negative value is a specific catcode with offset 1 */ @@ -207,10 +285,10 @@ static int luaccprint(lua_State * L) int i; for (i = 1;; i++) { lua_rawgeti(L, 2, i); - if (lua_isstring(L,-1)) { /* or number */ - luac_store(L, -1, PARTIAL_LINE, cattable); + if (luac_store(L, -1, PARTIAL_LINE, cattable)) { lua_pop(L, 1); } else { + lua_pop(L, 1); break; } } @@ -218,15 +296,14 @@ static int luaccprint(lua_State * L) int i; int n = lua_gettop(L); for (i = 2; i <= n; i++) { - if (!lua_isstring(L,i)) { /* or number */ - luaL_error(L, "no string to print"); - } luac_store(L, i, PARTIAL_LINE, cattable); } } return 0; } +/* lua.tprint */ + static int luactprint(lua_State * L) { int i, j; @@ -238,7 +315,7 @@ static int luactprint(lua_State * L) if (lua_type(L, i) != LUA_TTABLE) { luaL_error(L, "no string to print"); } - lua_pushvalue(L, i); /* push the table */ + lua_pushvalue(L, i); /* push the table */ lua_pushinteger(L, 1); lua_gettable(L, -2); if (lua_type(L, -1) == LUA_TNUMBER) { @@ -252,15 +329,14 @@ static int luactprint(lua_State * L) for (j = startstrings;; j++) { lua_pushinteger(L, j); lua_gettable(L, -2); - if (lua_isstring(L, -1)) { /* or number */ - luac_store(L, -1, PARTIAL_LINE, cattable); + if (luac_store(L, -1, PARTIAL_LINE, cattable)) { lua_pop(L, 1); } else { lua_pop(L, 1); break; } } - lua_pop(L, 1); /* pop the table */ + lua_pop(L, 1); /* pop the table */ } return 0; } @@ -280,7 +356,7 @@ int luacstring_final_line(void) return (read_spindle.tail->next == NULL); } -int luacstring_input(void) +int luacstring_input(halfword *n) { rope *t = read_spindle.head; int ret = 1 ; @@ -308,12 +384,15 @@ int luacstring_input(void) } free(t->text); t->text = NULL; - /* } else if (t->tok > 0) { - ret = - t->tok; - */ - } - if (read_spindle.tail != NULL) { /* not a one-liner */ + *n = t->tok; + ret = 2; + } else if (t->nod > 0) { + *n = t->nod; + ret = 3; + } + if (read_spindle.tail != NULL) { + /* not a one-liner */ free(read_spindle.tail); } read_spindle.tail = t; @@ -322,11 +401,13 @@ int luacstring_input(void) } /* open for reading, and make a new one for writing */ + void luacstring_start(int n) { - (void) n; /* for -W */ + (void) n; /* for -W */ spindle_index++; - if (spindle_size == spindle_index) { /* add a new one */ + if (spindle_size == spindle_index) { + /* add a new one */ spindles = xrealloc(spindles, (unsigned) (sizeof(spindle) * (unsigned) (spindle_size + 1))); spindles[spindle_index].head = NULL; spindles[spindle_index].tail = NULL; @@ -340,7 +421,7 @@ void luacstring_start(int n) void luacstring_close(int n) { rope *next, *t; - (void) n; /* for -W */ + (void) n; /* for -W */ next = read_spindle.head; while (next != NULL) { if (next->text != NULL) @@ -378,15 +459,15 @@ void luacstring_close(int n) static const char *scan_integer_part(lua_State * L, const char *ss, int *ret, int *radix_ret) { - boolean negative = false; /* should the answer be negated? */ - int m = 214748364; /* |$2^{31}$ / radix|, the threshold of danger */ - int d; /* the digit just scanned */ - boolean vacuous = true; /* have no digits appeared? */ - boolean OK_so_far = true; /* has an error message been issued? */ - int radix1 = 10; /* the radix of the integer */ - int c = 0; /* the current character */ - const char *s; /* where we stopped in the string |ss| */ - integer val = 0; /* return value */ + boolean negative = false; /* should the answer be negated? */ + int m = 214748364; /* |$2^{31}$ / radix|, the threshold of danger */ + int d; /* the digit just scanned */ + boolean vacuous = true; /* have no digits appeared? */ + boolean OK_so_far = true; /* has an error message been issued? */ + int radix1 = 10; /* the radix of the integer */ + int c = 0; /* the current character */ + const char *s; /* where we stopped in the string |ss| */ + integer val = 0; /* return value */ s = ss; do { do { @@ -448,9 +529,9 @@ static const char *scan_integer_part(lua_State * L, const char *ss, int *ret, in #define set_conversion(A,B) do { num=(A); denom=(B); } while(0) +/* sets |cur_val| to a dimension */ static const char *scan_dimen_part(lua_State * L, const char *ss, int *ret) -/* sets |cur_val| to a dimension */ { boolean negative = false; /* should the answer be negated? */ int f = 0; /* numerator of a fraction whose denominator is $2^{16}$ */ @@ -460,7 +541,7 @@ static const char *scan_dimen_part(lua_State * L, const char *ss, int *ret) int save_cur_val; /* temporary storage of |cur_val| */ int c; /* the current character */ const char *s = ss; /* where we are in the string */ - int radix1 = 0; /* the current radix */ + int radix1 = 0; /* the current radix */ int rdig[18]; /* to save the |dig[]| array */ int saved_tex_remainder; /* to save |tex_remainder| */ int saved_arith_error; /* to save |arith_error| */ @@ -468,9 +549,9 @@ static const char *scan_dimen_part(lua_State * L, const char *ss, int *ret) saved_tex_remainder = tex_remainder; saved_arith_error = arith_error; saved_cur_val = cur_val; - /* Get the next non-blank non-sign... */ + /* get the next non-blank non-sign */ do { - /* Get the next non-blank non-call token */ + /* get the next non-blank non-call token */ do { c = *s++; } while (c && c == ' '); @@ -493,16 +574,18 @@ static const char *scan_dimen_part(lua_State * L, const char *ss, int *ret) if (c == ',') c = '.'; if ((radix1 == 10) && (c == '.')) { - /* Scan decimal fraction */ + /* scan decimal fraction */ for (k = 0; k < 18; k++) rdig[k] = dig[k]; k = 0; - s++; /* get rid of the '.' */ + s++; + /* get rid of the '.' */ while (1) { c = *s++; if ((c > '0' + 9) || (c < '0')) break; - if (k < 17) { /* digits for |k>=17| cannot affect the result */ + if (k < 17) { + /* digits for |k>=17| cannot affect the result */ dig[k++] = c - '0'; } } @@ -516,8 +599,10 @@ static const char *scan_dimen_part(lua_State * L, const char *ss, int *ret) negative = !negative; cur_val = -cur_val; } - /* Scan for (u)units that are internal dimensions; - |goto attach_sign| with |cur_val| set if found */ + /* + Scan for (u)units that are internal dimensions; |goto attach_sign| with + |cur_val| set if found. + */ save_cur_val = cur_val; /* Get the next non-blank non-call... */ do { @@ -570,8 +655,10 @@ static const char *scan_dimen_part(lua_State * L, const char *ss, int *ret) s += 2; goto ATTACH_FRACTION; /* the easy case */ } - /* Scan for (a)all other units and adjust |cur_val| and |f| accordingly; - |goto done| in the case of scaled points */ + /* + Scan for (a)all other units and adjust |cur_val| and |f| accordingly; |goto done| + in the case of scaled points + */ if (strncmp(s, "mm", 2) == 0) { s += 2; set_conversion(7227, 2540); @@ -715,7 +802,7 @@ static int get_item_index(lua_State * L, int i, int base) s = lua_tolstring(L, i, &kk); cur_cs1 = string_lookup(s, kk); if (cur_cs1 == undefined_control_sequence || cur_cs1 == undefined_cs_cmd) - k = -1; /* guarandeed invalid */ + k = -1; /* guarandeed invalid */ else k = (equiv(cur_cs1) - base); break; @@ -724,7 +811,7 @@ static int get_item_index(lua_State * L, int i, int base) break; default: luaL_error(L, "argument must be a string or a number"); - k = -1; /* not a valid index */ + k = -1; /* not a valid index */ } return k; } @@ -1311,7 +1398,7 @@ static int vsetbox(lua_State * L, int is_global) } else if (t == LUA_TNIL) { j = null; } else { - j = nodelist_from_lua(L); + j = nodelist_from_lua(L,-1); if (j != null && type(j) != hlist_node && type(j) != vlist_node) { luaL_error(L, "setbox: incompatible node type (%s)\n", get_node_name(type(j), subtype(j))); return 0; @@ -2112,6 +2199,7 @@ static int gettex(lua_State * L) case assign_int_cmd: case assign_attr_cmd: case assign_dir_cmd: + case assign_direction_cmd: case assign_dimen_cmd: case set_aux_cmd: case set_prev_graf_cmd: @@ -2141,8 +2229,9 @@ static int gettex(lua_State * L) static int getlist(lua_State * L) { const char *str; - if (lua_type(L,2) == LUA_TSTRING) { - str = lua_tostring(L, 2); + int top = lua_gettop(L); + if (lua_type(L,top) == LUA_TSTRING) { + str = lua_tostring(L, top); if (lua_key_eq(str,page_ins_head)) { if (vlink(page_ins_head) == page_ins_head) lua_pushinteger(L, null); @@ -2203,17 +2292,18 @@ static int getlist(lua_State * L) static int setlist(lua_State * L) { - if (lua_type(L,2) == LUA_TSTRING) { - const char *str = lua_tostring(L, 2); + int top = (lua_type(L,1) == LUA_TTABLE) ? 2 : 1 ; + if (lua_type(L,top) == LUA_TSTRING) { + const char *str = lua_tostring(L, top); if (lua_key_eq(str,best_size)) { - best_size = (int) lua_tointeger(L, 3); + best_size = (int) lua_tointeger(L, top+1); } else if (lua_key_eq(str,least_page_cost)) { - least_page_cost = (int) lua_tointeger(L, 3); + least_page_cost = (int) lua_tointeger(L, top+1); } else { halfword *n_ptr; halfword n = 0; - if (!lua_isnil(L, 3)) { - n_ptr = check_isnode(L, 3); + if (!lua_isnil(L, top+1)) { + n_ptr = check_isnode(L, top+1); n = *n_ptr; } if (lua_key_eq(str,page_ins_head)) { @@ -2359,24 +2449,32 @@ static void init_nest_lib(lua_State * L) static int getnest(lua_State * L) { list_state_record **nestitem; - int t = lua_type(L, 2); - if (t == LUA_TNUMBER) { - int ptr = lua_tointeger(L, 2); - if (ptr >= 0 && ptr <= nest_ptr) { - nestitem = lua_newuserdata(L, sizeof(list_state_record *)); - *nestitem = &nest[ptr]; - luaL_getmetatable(L, NEST_METATABLE); - lua_setmetatable(L, -2); - } else { - lua_pushnil(L); - } - } else if (t == LUA_TSTRING) { - const char *s = lua_tostring(L, 2); - if (lua_key_eq(s,ptr)) { - lua_pushinteger(L, nest_ptr); - } else { - lua_pushnil(L); + int n = lua_gettop(L); + int p = -1 ; + if (n == 0) { + p = nest_ptr; + } else { + int t = lua_type(L, n); + if (t == LUA_TNUMBER) { + int ptr = lua_tointeger(L, n); + if (ptr >= 0 && ptr <= nest_ptr) { + p = ptr; + } + } else if (t == LUA_TSTRING) { + const char *s = lua_tostring(L, n); + if (lua_key_eq(s,top)) { + p = nest_ptr; + } else if (lua_key_eq(s,ptr)) { + lua_pushinteger(L, nest_ptr); + return 1; + } } + } + if (p > -1) { + nestitem = lua_newuserdata(L, sizeof(list_state_record *)); + *nestitem = &nest[p]; + luaL_getmetatable(L, NEST_METATABLE); + lua_setmetatable(L, -2); } else { lua_pushnil(L); } @@ -2386,7 +2484,7 @@ static int getnest(lua_State * L) static int setnest(lua_State * L) { luaL_error(L, "You can't modify the semantic nest array directly"); - return 2; + return 0; } static int do_integer_error(double m) @@ -2859,7 +2957,7 @@ static int tex_run_linebreak(lua_State * L) } lua_key_rawgeti(pardir); if (lua_type(L, -1) == LUA_TSTRING) { - paragraph_dir = nodelib_getdir(L, -1, 1); + paragraph_dir = nodelib_getdir(L, -1); } lua_pop(L, 1); @@ -3117,8 +3215,21 @@ static int tex_save_box_resource(lua_State * L) int type = 0; int margin = pdf_xform_margin; boolean immediate = false; + /* more or less same as scanner variant */ + if (lua_type(L,1) == LUA_TNUMBER) { + halfword boxnumber = lua_tointeger(L,1); + boxdata = box(boxnumber); + box(boxnumber) = null; + } else { + boxdata = nodelist_from_lua(L,1); + if (type(boxdata) != hlist_node && type(boxdata) != vlist_node) { + normal_error("pdf backend", "xforms can only be used with a box or [h|v]list"); + } + } + if (boxdata == null) { + normal_error("pdf backend", "xforms cannot be used with a void box or empty [h|v]list"); + } /* box attributes resources */ - halfword boxnumber = lua_tointeger(L,1); if (lua_type(L,2) == LUA_TSTRING) { lua_pushvalue(L, 2); attributes = luaL_ref(L, LUA_REGISTRYINDEX); @@ -3136,10 +3247,6 @@ static int tex_save_box_resource(lua_State * L) 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) - normal_error("pdf backend", "xforms cannot be used with a void box"); static_pdf->xform_count++; index = pdf_create_obj(static_pdf, obj_type_xform, static_pdf->xform_count); set_obj_data_ptr(static_pdf, index, pdf_get_mem(static_pdf, pdfmem_xform_size)); @@ -3153,7 +3260,6 @@ static int tex_save_box_resource(lua_State * L) 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); if (immediate) { @@ -3229,12 +3335,35 @@ static int tex_get_box_resource_dimensions(lua_State * L) return 4; } +static int tex_get_box_resource_box(lua_State * L) +{ + /* no checking yet as this might go */ + halfword b; + int index = lua_tointeger(L,1); + check_obj_type(static_pdf, obj_type_xform, index); + b = obj_xform_box(static_pdf, index); + nodelist_to_lua(L, b); + return 1; +} + static int tex_build_page(lua_State * L) { build_page(); return 0; } +static int lua_get_page_state(lua_State * L) +{ + lua_pushinteger(L,page_contents); + return 1; +} + +static int lua_get_local_level(lua_State * L) +{ + lua_pushinteger(L,current_local_level()); + return 1; +} + /* synctex */ static int lua_set_synctex_mode(lua_State * L) @@ -3296,6 +3425,82 @@ static int lua_set_synctex_no_files(lua_State * L) return 0; } +/* + This is experimental and might change. In version 10 we hope to have the + final version available. It actually took quite a bit of time to understand + the implications of mixing lua prints in here. The current variant is (so far) + the most robust (wrt crashes and side effects). +*/ + +#define mode mode_par + +/* + When we add save levels then we can get crashes when one flushed bad + groups due to out of order flushing. So we play safe! But still we can + have issues so best make sure you're in hmode. +*/ + +static int forcehmode(lua_State * L) +{ + if (abs(mode) == vmode) { + if (lua_type(L,1) == LUA_TBOOLEAN) { + new_graf(lua_toboolean(L,1)); + } else { + new_graf(1); + } + } + return 0; +} + +static int runtoks(lua_State * L) +{ + if (lua_type(L,1) == LUA_TFUNCTION) { + int old_mode = mode; + int ref; + pointer r = get_avail(); + pointer t = get_avail(); + token_info(r) = token_val(extension_cmd,end_local_code); + lua_pushvalue(L, 1); + ref = luaL_ref(L,LUA_REGISTRYINDEX); + token_info(t) = token_val(lua_local_call_cmd, ref); + begin_token_list(r,inserted); + begin_token_list(t,inserted); + if (luacstrings > 0) { + lua_string_start(); + } + if (tracing_nesting_par > 2) { + local_control_message("entering token scanner via function"); + } + mode = -hmode; + local_control(); + mode = old_mode; + luaL_unref(L,LUA_REGISTRYINDEX,ref); + } else { + int k = get_item_index(L, lua_gettop(L), toks_base); + halfword t = toks(k); + check_index_range(k, "gettoks"); + if (t != null) { + int old_mode = mode; + pointer r = get_avail(); + token_info(r) = token_val(extension_cmd,end_local_code); + begin_token_list(r,inserted); + /* new_save_level(semi_simple_group); */ + begin_token_list(t,local_text); + if (luacstrings > 0) { + lua_string_start(); + } + if (tracing_nesting_par > 2) { + local_control_message("entering token scanner via register"); + } + mode = -hmode; + local_control(); + mode = old_mode; + /* unsave(); */ + } + } + return 0; +} + /* till here */ void init_tex_table(lua_State * L) @@ -3315,10 +3520,14 @@ static const struct luaL_Reg texlib[] = { { "finish", tex_run_end }, /* may be needed */ { "write", luacwrite }, { "print", luacprint }, + { "sprint", luacsprint }, { "tprint", luactprint }, { "cprint", luaccprint }, + /* + { "twrite", luatwrite }, + { "nwrite", luanwrite }, + */ { "error", texerror }, - { "sprint", luacsprint }, { "set", settex }, { "get", gettex }, { "isdimen", isdimen }, @@ -3327,11 +3536,13 @@ static const struct luaL_Reg texlib[] = { { "isskip", isskip }, { "setskip", setskip }, { "getskip", getskip }, + { "isglue", isskip }, { "setglue", setglue }, { "getglue", getglue }, { "ismuskip", ismuskip }, { "setmuskip", setmuskip }, { "getmuskip", getmuskip }, + { "ismuglue", ismuskip }, { "setmuglue", setmuglue }, { "getmuglue", getmuglue }, { "isattribute", isattribute }, @@ -3350,7 +3561,7 @@ static const struct luaL_Reg texlib[] = { { "splitbox", splitbox }, { "setlist", setlist }, { "getlist", getlist }, - { "setnest", setnest }, + { "setnest", setnest }, /* only a message */ { "getnest", getnest }, { "setcatcode", setcatcode }, { "getcatcode", getcatcode }, @@ -3395,8 +3606,12 @@ static const struct luaL_Reg texlib[] = { { "saveboxresource", tex_save_box_resource }, { "useboxresource", tex_use_box_resource }, { "getboxresourcedimensions", tex_get_box_resource_dimensions }, + /* might go, used when sanitizing backend */ + { "getboxresourcebox", tex_get_box_resource_box }, /* just for testing: it will probably stay but maybe with options */ { "triggerbuildpage", tex_build_page }, + { "getpagestate", lua_get_page_state }, + { "getlocallevel", lua_get_local_level }, /* not the best place but better than in node */ { "set_synctex_mode", lua_set_synctex_mode }, { "get_synctex_mode", lua_get_synctex_mode }, @@ -3407,6 +3622,9 @@ static const struct luaL_Reg texlib[] = { { "force_synctex_line", lua_force_synctex_line }, { "set_synctex_line", lua_set_synctex_line }, { "get_synctex_line", lua_get_synctex_line }, + /* test */ + { "runtoks", runtoks }, + { "forcehmode", forcehmode }, /* sentinel */ { NULL, NULL } }; @@ -3451,6 +3669,8 @@ int luaopen_tex(lua_State * L) spindles[0].tail = NULL; spindle_size = 1; /* a somewhat odd place for this assert, maybe */ - assert(command_names[data_cmd].command_offset == data_cmd); + if (command_names[data_cmd].id != data_cmd) { + fatal_error("mismatch between tex and lua command name tables"); + }; return 1; } diff --git a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h index 36b2f5979e1..399dccb04f2 100644 --- a/Build/source/texk/web2c/luatexdir/lua/luatex-api.h +++ b/Build/source/texk/web2c/luatexdir/lua/luatex-api.h @@ -35,8 +35,10 @@ extern int draft_mode_value; /* get_o_mode translates from output_mode to output_mode_used */ /* fix_o_mode freezes output_mode as soon as anything goes through the backend */ +/* extern output_mode get_o_mode(void); extern void fix_o_mode(void); +*/ /* till here */ @@ -66,8 +68,7 @@ typedef struct LoadS { extern lua_State *Luas; -extern void make_table(lua_State * L, const char *tab, const char *mttab, const char *getfunc, - const char *setfunc); +extern void make_table(lua_State * L, const char *tab, const char *mttab, const char *getfunc, const char *setfunc); extern int luac_main(int argc, char *argv[]); @@ -76,6 +77,8 @@ extern int luaopen_pdf(lua_State * L); extern int luaopen_texio(lua_State * L); extern int luaopen_lang(lua_State * L); +extern int luapdfprint(lua_State * L); + # define LUA_TEXFILEHANDLE "TEXFILE*" extern lua_State *luatex_error(lua_State * L, int fatal); @@ -85,6 +88,7 @@ extern int luaopen_zip(lua_State * L); extern int luaopen_lfs(lua_State * L); extern int luaopen_lpeg(lua_State * L); extern int luaopen_md5(lua_State * L); +extern int luaopen_sha2(lua_State * L); #ifndef LuajitTeX extern int luaopen_ffi(lua_State * L); @@ -101,14 +105,13 @@ extern void luatex_socketlua_open(lua_State * L); extern int luaopen_img(lua_State * L); extern int l_new_image(lua_State * L); -extern int luaopen_epdf(lua_State * L); +extern int luaopen_pdfe(lua_State * L); extern int luaopen_pdfscanner(lua_State * L); extern int luaopen_mplib(lua_State * L); extern int luaopen_fio(lua_State * L); extern void open_oslibext(lua_State * L); extern void open_strlibext(lua_State * L); -extern void open_lfslibext(lua_State * L); extern void initfilecallbackids(int max); extern void setinputfilecallbackid(int n, int i); @@ -118,6 +121,8 @@ extern int getreadfilecallbackid(int n); extern void lua_initialize(int ac, char **av); +extern void luacall_vf(int p, int f, int c); + extern int luaopen_kpse(lua_State * L); extern int luaopen_callback(lua_State * L); @@ -138,12 +143,12 @@ extern void tokenlist_to_luastring(lua_State * L, int p); extern int tokenlist_from_lua(lua_State * L); extern void lua_nodelib_push(lua_State * L); -extern int nodelib_getdir(lua_State * L, int n, int absolute_only); +extern int nodelib_getdir(lua_State * L, int n); extern int nodelib_getlist(lua_State * L, int n); extern int luaopen_node(lua_State * L); extern void nodelist_to_lua(lua_State * L, int n); -extern int nodelist_from_lua(lua_State * L); +extern int nodelist_from_lua(lua_State * L, int n); extern int dimen_to_number(lua_State * L, const char *s); @@ -158,8 +163,6 @@ extern const char *lc_ctype; extern const char *lc_collate; extern const char *lc_numeric; - - #ifdef LuajitTeX extern int luajiton; extern char *jithash_hashname ; @@ -177,9 +180,9 @@ extern void unhide_lua_value(lua_State * lua, const char *name, const char *item extern int hide_lua_value(lua_State * lua, const char *name, const char *item); typedef struct command_item_ { - const char *cmd_name; - int command_offset; - const char **commands; + int id; + const char *name; + int lua; } command_item; extern command_item command_names[]; @@ -193,6 +196,9 @@ extern int luastate_bytes; extern int callback_count; extern int saved_callback_count; +extern int direct_callback_count; +extern int late_callback_count; +extern int function_callback_count; extern const char *luatex_banner; extern const char *engine_name; @@ -256,7 +262,13 @@ extern char **environ; } #endif +typedef struct lua_token { + int token; + int origin; +} lua_token; + extern int luatwrite(lua_State * L); +extern int luanwrite(lua_State * L); /* Same as in lnodelib.c, but with prefix G_ for now. @@ -342,22 +354,58 @@ preassign these at startup time. */ #define LOCAL_PAR_SIZE 5 #define MATH_STYLE_NAME_SIZE 8 #define APPEND_LIST_SIZE 5 -#define DIR_PAR_SIZE 8 -#define DIR_TEXT_SIZE 8 +#define DIR_PAR_SIZE 4 +#define DIR_TEXT_SIZE 4 extern int l_pack_type_index [PACK_TYPE_SIZE]; extern int l_group_code_index [GROUP_CODE_SIZE]; extern int l_local_par_index [LOCAL_PAR_SIZE]; extern int l_math_style_name_index [MATH_STYLE_NAME_SIZE]; extern int l_dir_par_index [DIR_PAR_SIZE]; -extern int l_dir_text_index [DIR_TEXT_SIZE]; +extern int l_dir_text_index_normal [DIR_TEXT_SIZE]; +extern int l_dir_text_index_cancel [DIR_TEXT_SIZE]; #define lua_push_pack_type(L,pack_type) lua_rawgeti(L, LUA_REGISTRYINDEX, l_pack_type_index[pack_type] ); #define lua_push_group_code(L,group_code) lua_rawgeti(L, LUA_REGISTRYINDEX, l_group_code_index[group_code]); #define lua_push_local_par_mode(L,par_mode) lua_rawgeti(L, LUA_REGISTRYINDEX, l_local_par_index[par_mode]); #define lua_push_math_style_name(L,style_name) lua_rawgeti(L, LUA_REGISTRYINDEX, l_math_style_name_index[style_name]); -#define lua_push_dir_par(L,dir) lua_rawgeti(L, LUA_REGISTRYINDEX, l_dir_par_index[dir+dir_swap]) -#define lua_push_dir_text(L,dir) lua_rawgeti(L, LUA_REGISTRYINDEX, l_dir_text_index[dir+dir_swap]) + +#define lua_push_direction(L,direction) \ + if (direction < 0) { \ + lua_pushnil(L); \ + } else { \ + lua_pushinteger(L,direction); \ + } + +#define lua_push_dir_par(L,dir) \ + if (dir < 0) { \ + lua_pushnil(L); \ + } else { \ + lua_rawgeti(L, LUA_REGISTRYINDEX, l_dir_par_index[dir]); \ + } + +#define lua_push_dir_text_normal(L,dir) \ + if (dir < 0) { \ + lua_pushnil(L); \ + } else { \ + lua_rawgeti(L, LUA_REGISTRYINDEX, l_dir_text_index_normal[dir]); \ + } + +#define lua_push_dir_text_cancel(L,dir) \ + if (dir < 0) { \ + lua_pushnil(L); \ + } else { \ + lua_rawgeti(L, LUA_REGISTRYINDEX, l_dir_text_index_cancel[dir]); \ + } + +#define lua_push_dir_text(L,dir,sub) \ + if (dir < 0) { \ + lua_pushnil(L); \ + } else if (sub) { \ + lua_rawgeti(L, LUA_REGISTRYINDEX, l_dir_text_index_cancel[dir]); \ + } else { \ + lua_rawgeti(L, LUA_REGISTRYINDEX, l_dir_text_index_normal[dir]); \ + } #define lua_push_string_by_index(L,index) lua_rawgeti(L, LUA_REGISTRYINDEX, index) #define lua_push_string_by_name(L,index) lua_rawgeti(L, LUA_REGISTRYINDEX, lua_key_index(index)) @@ -414,21 +462,17 @@ l_math_style_name_index[cramped_script_script_style] = lua_key_index(crampedscri l_dir_par_index[dir_TLT] = lua_key_index(TLT);\ l_dir_par_index[dir_TRT] = lua_key_index(TRT);\ l_dir_par_index[dir_LTL] = lua_key_index(LTL);\ -l_dir_par_index[dir_RTT] = lua_key_index(RTT);\ -l_dir_par_index[dir_TLT+4] = lua_key_index(TLT);\ -l_dir_par_index[dir_TRT+4] = lua_key_index(TRT);\ -l_dir_par_index[dir_LTL+4] = lua_key_index(LTL);\ -l_dir_par_index[dir_RTT+4] = lua_key_index(RTT);\ +l_dir_par_index[dir_RTT] = lua_key_index(RTT); #define set_l_dir_text_index \ -l_dir_text_index[dir_TLT] = lua_key_index(mTLT);\ -l_dir_text_index[dir_TRT] = lua_key_index(mTRT);\ -l_dir_text_index[dir_LTL] = lua_key_index(mLTL);\ -l_dir_text_index[dir_RTT] = lua_key_index(mRTT);\ -l_dir_text_index[dir_TLT+4] = lua_key_index(pTLT);\ -l_dir_text_index[dir_TRT+4] = lua_key_index(pTRT);\ -l_dir_text_index[dir_LTL+4] = lua_key_index(pLTL);\ -l_dir_text_index[dir_RTT+4] = lua_key_index(pRTT);\ +l_dir_text_index_normal[dir_TLT] = lua_key_index(pTLT);\ +l_dir_text_index_normal[dir_TRT] = lua_key_index(pTRT);\ +l_dir_text_index_normal[dir_LTL] = lua_key_index(pLTL);\ +l_dir_text_index_normal[dir_RTT] = lua_key_index(pRTT);\ +l_dir_text_index_cancel[dir_TLT] = lua_key_index(mTLT);\ +l_dir_text_index_cancel[dir_TRT] = lua_key_index(mTRT);\ +l_dir_text_index_cancel[dir_LTL] = lua_key_index(mLTL);\ +l_dir_text_index_cancel[dir_RTT] = lua_key_index(mRTT); #define img_parms_max 25 #define img_pageboxes_max 6 @@ -438,6 +482,7 @@ extern int img_pageboxes [img_pageboxes_max]; # define set_l_img_keys_index \ img_parms[ 0] = lua_key_index(attr); \ +img_parms[ 0] = lua_key_index(attribute_list); \ img_parms[ 1] = lua_key_index(bbox); \ img_parms[ 2] = lua_key_index(colordepth); \ img_parms[ 3] = lua_key_index(colorspace); \ @@ -474,17 +519,16 @@ img_pageboxes[5] = lua_key_index(art); \ #define lua_push_img_key(L,key) lua_rawgeti(L, LUA_REGISTRYINDEX, img_parms[key] ); #define lua_push_img_pagebox(L,box) lua_rawgeti(L, LUA_REGISTRYINDEX, img_pageboxes[box]); -extern int lua_show_valid_list(lua_State *L, const char **list, int max); +extern int lua_show_valid_list(lua_State *L, const char **list, int offset, int max); extern int lua_show_valid_keys(lua_State *L, int *list, int max); #define set_make_keys \ -make_lua_key(cmdname);make_lua_key(expandable);make_lua_key(protected);\ -make_lua_key(LTL);\ -make_lua_key(MathConstants);\ -make_lua_key(RTT);\ -make_lua_key(TLT);\ -make_lua_key(TRT);\ +make_lua_key(__index);\ +make_lua_key(above);\ +make_lua_key(abovedisplayshortskip);\ +make_lua_key(abovedisplayskip);\ make_lua_key(accent);\ +make_lua_key(accentkern);\ make_lua_key(action);\ make_lua_key(action_id);\ make_lua_key(action_type);\ @@ -496,53 +540,107 @@ make_lua_key(adjust_head);\ make_lua_key(adjusted_hbox);\ make_lua_key(adjustspacing);\ make_lua_key(advance);\ +make_lua_key(after_assignment);\ make_lua_key(after_display);\ +make_lua_key(after_group);\ make_lua_key(after_output);\ +make_lua_key(afterdisplaypenalty);\ make_lua_key(align);\ make_lua_key(align_head);\ +make_lua_key(align_record);\ make_lua_key(align_set);\ +make_lua_key(align_stack);\ make_lua_key(alignment);\ +make_lua_key(always);\ make_lua_key(annot);\ make_lua_key(area);\ make_lua_key(art);\ +make_lua_key(assign_attr);\ +make_lua_key(assign_box_dir);\ +make_lua_key(assign_box_direction);\ +make_lua_key(assign_dimen);\ +make_lua_key(assign_dir);\ +make_lua_key(assign_direction);\ +make_lua_key(assign_font_dimen);\ +make_lua_key(assign_font_int);\ +make_lua_key(assign_glue);\ +make_lua_key(assign_hang_indent);\ +make_lua_key(assign_int);\ +make_lua_key(assign_local_box);\ +make_lua_key(assign_mu_glue);\ +make_lua_key(assign_toks);\ make_lua_key(attr);\ +make_lua_key(attribute);\ +make_lua_key(attribute_list);\ make_lua_key(attributes);\ +make_lua_key(automatic);\ +make_lua_key(baselineskip);\ make_lua_key(bbox);\ make_lua_key(before_display);\ +make_lua_key(beforedisplaypenalty);\ +make_lua_key(begin_group);\ +make_lua_key(beginmath);\ +make_lua_key(belowdisplayshortskip);\ +make_lua_key(belowdisplayskip);\ make_lua_key(best_ins_ptr);\ make_lua_key(best_page_break);\ make_lua_key(best_size);\ +make_lua_key(bin);\ make_lua_key(bleed);\ make_lua_key(bot);\ make_lua_key(bot_accent);\ +make_lua_key(bothflexible);\ make_lua_key(bottom_left);\ make_lua_key(bottom_right);\ make_lua_key(boundary);\ make_lua_key(box);\ make_lua_key(box_left);\ make_lua_key(box_left_width);\ +make_lua_key(box_ref);\ make_lua_key(box_right);\ make_lua_key(box_right_width);\ +make_lua_key(box_there);\ +make_lua_key(break_penalty);\ make_lua_key(broken_ins);\ make_lua_key(broken_ptr);\ make_lua_key(brokenpenalty);\ make_lua_key(cache);\ make_lua_key(cal_expand_ratio);\ +make_lua_key(call);\ +make_lua_key(cancel);\ +make_lua_key(car_ret);\ +make_lua_key(case_shift);\ +make_lua_key(Catalog);\ make_lua_key(catalog);\ +make_lua_key(cell);\ make_lua_key(char);\ +make_lua_key(char_ghost);\ +make_lua_key(char_given);\ +make_lua_key(char_num);\ +make_lua_key(character);\ make_lua_key(characters);\ make_lua_key(checksum);\ +make_lua_key(choice);\ make_lua_key(cidinfo);\ make_lua_key(class);\ +make_lua_key(cleaders);\ +make_lua_key(close);\ make_lua_key(clubpenalty);\ +make_lua_key(cmd);\ +make_lua_key(cmdname);\ +make_lua_key(color_stack);\ make_lua_key(colordepth);\ make_lua_key(colorspace);\ +make_lua_key(combinetoks);\ make_lua_key(command);\ make_lua_key(commands);\ make_lua_key(comment);\ make_lua_key(components);\ make_lua_key(compresslevel);\ +make_lua_key(conditionalmathskip);\ make_lua_key(contrib_head);\ +make_lua_key(convert);\ +make_lua_key(copy_font);\ make_lua_key(core);\ make_lua_key(cost);\ make_lua_key(count);\ @@ -551,11 +649,21 @@ make_lua_key(crampedscript);\ make_lua_key(crampedscriptscript);\ make_lua_key(crampedtext);\ make_lua_key(crop);\ +make_lua_key(cs_name);\ make_lua_key(csname);\ +make_lua_key(current);\ make_lua_key(data);\ +make_lua_key(def);\ +make_lua_key(def_char_code);\ +make_lua_key(def_del_code);\ +make_lua_key(def_family);\ +make_lua_key(def_font);\ +make_lua_key(def_lua_call);\ make_lua_key(degree);\ make_lua_key(delim);\ +make_lua_key(delim_num);\ make_lua_key(delimptr);\ +make_lua_key(delta);\ make_lua_key(demerits);\ make_lua_key(denom);\ make_lua_key(depth);\ @@ -568,46 +676,92 @@ make_lua_key(direct);\ make_lua_key(direction);\ make_lua_key(dirs);\ make_lua_key(disc);\ +make_lua_key(discretionary);\ make_lua_key(display);\ +make_lua_key(divide);\ +make_lua_key(dont_expand);\ make_lua_key(doublehyphendemerits);\ make_lua_key(down);\ make_lua_key(embedding);\ make_lua_key(emergencystretch);\ +make_lua_key(empty);\ make_lua_key(empty_string);\ make_lua_key(encodingbytes);\ make_lua_key(encodingname);\ make_lua_key(end);\ -make_lua_key(etex);\ +make_lua_key(end_cs_name);\ +make_lua_key(end_group);\ +make_lua_key(end_template);\ +make_lua_key(endmath);\ +make_lua_key(endv);\ +make_lua_key(eq_no);\ make_lua_key(equation);\ make_lua_key(equation_number);\ +make_lua_key(equationnumber);\ +make_lua_key(equationnumberpenalty);\ +make_lua_key(etex);\ +make_lua_key(ex_space);\ make_lua_key(exactly);\ +make_lua_key(expand_after);\ +make_lua_key(expand_font);\ +make_lua_key(expandable);\ make_lua_key(expansion_factor);\ +make_lua_key(explicit);\ +make_lua_key(expr_stack);\ make_lua_key(ext);\ +make_lua_key(extdef_del_code);\ +make_lua_key(extdef_math_code);\ make_lua_key(extend);\ make_lua_key(extender);\ make_lua_key(extensible);\ +make_lua_key(extension);\ make_lua_key(extra_space);\ make_lua_key(fam);\ make_lua_key(fast);\ +make_lua_key(feedback);\ make_lua_key(fence);\ +make_lua_key(fi);\ +make_lua_key(fi_or_else);\ +make_lua_key(fil);\ make_lua_key(file);\ make_lua_key(filename);\ make_lua_key(filepath);\ make_lua_key(fill);\ +make_lua_key(filll);\ +make_lua_key(fillll);\ make_lua_key(fin_row);\ make_lua_key(finalhyphendemerits);\ +make_lua_key(finalpenalty);\ +make_lua_key(first);\ +make_lua_key(fit);\ +make_lua_key(fitb);\ +make_lua_key(fitbh);\ +make_lua_key(fitbv);\ +make_lua_key(fith);\ +make_lua_key(fitr);\ +make_lua_key(fitv);\ +make_lua_key(fixedboth);\ +make_lua_key(fixedbottom);\ +make_lua_key(fixedtop);\ make_lua_key(font);\ +make_lua_key(fontkern);\ make_lua_key(fonts);\ make_lua_key(format);\ make_lua_key(fraction);\ make_lua_key(fullname);\ +make_lua_key(ghost);\ +make_lua_key(gleaders);\ make_lua_key(global);\ make_lua_key(glue);\ make_lua_key(glue_order);\ +make_lua_key(glue_ref);\ make_lua_key(glue_set);\ make_lua_key(glue_sign);\ +make_lua_key(glue_spec);\ make_lua_key(glyph);\ +make_lua_key(goto);\ make_lua_key(h);\ +make_lua_key(halign);\ make_lua_key(hangafter);\ make_lua_key(hangindent);\ make_lua_key(hbox);\ @@ -615,20 +769,37 @@ make_lua_key(head);\ make_lua_key(height);\ make_lua_key(hlist);\ make_lua_key(hmode_par);\ +make_lua_key(hmove);\ make_lua_key(hold_head);\ make_lua_key(horiz_variants);\ +make_lua_key(hrule);\ make_lua_key(hsize);\ +make_lua_key(hskip);\ +make_lua_key(hyph_data);\ +make_lua_key(hyphenated);\ make_lua_key(hyphenchar);\ make_lua_key(id);\ make_lua_key(identity);\ +make_lua_key(if_stack);\ +make_lua_key(if_test);\ +make_lua_key(ignore_spaces);\ make_lua_key(image);\ make_lua_key(imagetype);\ make_lua_key(immediate);\ +make_lua_key(in_stream);\ +make_lua_key(indent);\ make_lua_key(index);\ make_lua_key(info);\ +make_lua_key(Info);\ +make_lua_key(inner);\ +make_lua_key(input);\ +make_lua_key(ins);\ make_lua_key(insert);\ +make_lua_key(inserts_only);\ make_lua_key(interlinepenalty);\ +make_lua_key(ital_corr);\ make_lua_key(italic);\ +make_lua_key(italiccorrection);\ make_lua_key(keepopen);\ make_lua_key(kern);\ make_lua_key(kerns);\ @@ -636,95 +807,191 @@ make_lua_key(lang);\ make_lua_key(large_char);\ make_lua_key(large_fam);\ make_lua_key(last_ins_ptr);\ +make_lua_key(last_item);\ make_lua_key(lastlinefit);\ +make_lua_key(late_lua);\ make_lua_key(leader);\ +make_lua_key(leader_ship);\ +make_lua_key(leaders);\ make_lua_key(least_page_cost);\ make_lua_key(left);\ make_lua_key(left_boundary);\ +make_lua_key(left_brace);\ make_lua_key(left_protruding);\ +make_lua_key(left_right);\ make_lua_key(leftskip);\ +make_lua_key(let);\ +make_lua_key(letter);\ +make_lua_key(letterspace_font);\ make_lua_key(level);\ +make_lua_key(ligature);\ make_lua_key(ligatures);\ +make_lua_key(limit_switch);\ +make_lua_key(line);\ +make_lua_key(linebreakpenalty);\ make_lua_key(linepenalty);\ +make_lua_key(lineskip);\ make_lua_key(link_attr);\ make_lua_key(list);\ make_lua_key(local_box);\ +make_lua_key(local_par);\ make_lua_key(log);\ +make_lua_key(long_call);\ +make_lua_key(long_outer_call);\ make_lua_key(looseness);\ +make_lua_key(LTL);\ make_lua_key(lua);\ +make_lua_key(lua_bytecode_call);\ make_lua_key(lua_bytecodes_indirect);\ +make_lua_key(lua_call);\ +make_lua_key(lua_expandable_call);\ +make_lua_key(lua_local_call);\ +make_lua_key(lua_function_call);\ make_lua_key(lua_functions);\ make_lua_key(luatex);\ make_lua_key(luatex_node);\ make_lua_key(luatex_token);\ -make_lua_key(mLTL);\ -make_lua_key(mRTT);\ -make_lua_key(mTLT);\ -make_lua_key(mTRT);\ +make_lua_key(luatex_pdfe);\ +make_lua_key(luatex_pdfe_dictionary);\ +make_lua_key(luatex_pdfe_array);\ +make_lua_key(luatex_pdfe_stream);\ +make_lua_key(luatex_pdfe_reference);\ +make_lua_key(mac_param);\ +make_lua_key(make_box);\ +make_lua_key(margin_kern);\ make_lua_key(marginkern);\ make_lua_key(mark);\ make_lua_key(math);\ +make_lua_key(math_accent);\ +make_lua_key(math_char);\ +make_lua_key(math_char_num);\ make_lua_key(math_choice);\ +make_lua_key(math_comp);\ +make_lua_key(math_given);\ make_lua_key(math_left);\ make_lua_key(math_shift);\ +make_lua_key(math_shift_cs);\ +make_lua_key(math_style);\ +make_lua_key(math_sub_box);\ +make_lua_key(math_sub_mlist);\ +make_lua_key(math_text_char);\ +make_lua_key(MathConstants);\ make_lua_key(mathdir);\ make_lua_key(mathkern);\ +make_lua_key(mathskip);\ make_lua_key(mathstyle);\ make_lua_key(media);\ +make_lua_key(medmuskip);\ +make_lua_key(message);\ make_lua_key(mid);\ make_lua_key(middle);\ +make_lua_key(mkern);\ +make_lua_key(mLTL);\ make_lua_key(mode);\ make_lua_key(modeline);\ +make_lua_key(movement_stack);\ +make_lua_key(mRTT);\ +make_lua_key(mskip);\ +make_lua_key(mTLT);\ +make_lua_key(mTRT);\ +make_lua_key(muglue);\ +make_lua_key(multiply);\ make_lua_key(name);\ make_lua_key(named_id);\ make_lua_key(names);\ +make_lua_key(nested_list);\ +make_lua_key(new);\ make_lua_key(new_graf);\ make_lua_key(new_window);\ make_lua_key(next);\ make_lua_key(no);\ +make_lua_key(nolength);\ make_lua_key(no_align);\ +make_lua_key(no_expand);\ +make_lua_key(no_super_sub_script);\ make_lua_key(noad);\ +make_lua_key(noadpenalty);\ make_lua_key(node);\ make_lua_key(node_properties);\ make_lua_key(node_properties_indirect);\ +make_lua_key(nohrule);\ make_lua_key(nomath);\ +make_lua_key(non_script);\ make_lua_key(none);\ +make_lua_key(nonew);\ make_lua_key(nop);\ +make_lua_key(normal);\ +make_lua_key(novrule);\ make_lua_key(nucleus);\ make_lua_key(num);\ make_lua_key(number);\ make_lua_key(objcompression);\ make_lua_key(objnum);\ make_lua_key(oldmath);\ -make_lua_key(ordering);\ +make_lua_key(omit);\ +make_lua_key(opdisplaylimits);\ +make_lua_key(open);\ +make_lua_key(oplimits);\ +make_lua_key(opnolimits);\ +make_lua_key(option);\ make_lua_key(options);\ +make_lua_key(ord);\ +make_lua_key(ordering);\ make_lua_key(orientation);\ make_lua_key(origin);\ +make_lua_key(other_char);\ +make_lua_key(outer_call);\ +make_lua_key(outline);\ make_lua_key(output);\ +make_lua_key(over);\ make_lua_key(overlay_accent);\ -make_lua_key(pLTL);\ -make_lua_key(pRTT);\ -make_lua_key(pTLT);\ -make_lua_key(pTRT);\ +make_lua_key(ownerpassword);\ make_lua_key(page);\ -make_lua_key(pages);\ make_lua_key(page_discards_head);\ make_lua_key(page_head);\ make_lua_key(page_ins_head);\ +make_lua_key(page_insert);\ make_lua_key(pageattributes);\ make_lua_key(pagebox);\ make_lua_key(pageresources);\ +make_lua_key(pages);\ +make_lua_key(Pages);\ make_lua_key(pagesattributes);\ +make_lua_key(pagestate);\ +make_lua_key(par_end);\ make_lua_key(parameters);\ make_lua_key(pardir);\ +make_lua_key(parfillskip);\ make_lua_key(parshape);\ +make_lua_key(parskip);\ +make_lua_key(passive);\ make_lua_key(pdf);\ +make_lua_key(pdfe);\ +make_lua_key(pdf_action);\ +make_lua_key(pdf_annot);\ +make_lua_key(pdf_colorstack);\ make_lua_key(pdf_data);\ +make_lua_key(pdf_dest);\ make_lua_key(pdf_destination);\ +make_lua_key(pdf_end_link);\ +make_lua_key(pdf_end_thread);\ +make_lua_key(pdf_link_data);\ make_lua_key(pdf_literal);\ +make_lua_key(pdf_refobj);\ +make_lua_key(pdf_restore);\ +make_lua_key(pdf_save);\ +make_lua_key(pdf_setmatrix);\ +make_lua_key(pdf_setobj);\ +make_lua_key(pdf_start);\ +make_lua_key(pdf_start_link);\ +make_lua_key(pdf_start_thread);\ +make_lua_key(pdf_thread);\ +make_lua_key(pdf_thread_data);\ +make_lua_key(pdf_window);\ make_lua_key(pen_broken);\ make_lua_key(pen_inter);\ make_lua_key(penalty);\ +make_lua_key(pLTL);\ make_lua_key(pop);\ make_lua_key(post);\ make_lua_key(post_linebreak);\ @@ -734,35 +1001,71 @@ make_lua_key(pre_adjust_head);\ make_lua_key(pre_align);\ make_lua_key(pre_box);\ make_lua_key(preamble);\ +make_lua_key(prefix);\ make_lua_key(pretolerance);\ make_lua_key(prev);\ make_lua_key(prevdepth);\ make_lua_key(prevgraf);\ +make_lua_key(protected);\ make_lua_key(protrudechars);\ +make_lua_key(protrusion);\ +make_lua_key(pRTT);\ +make_lua_key(pseudo_file);\ +make_lua_key(pseudo_line);\ make_lua_key(psname);\ +make_lua_key(pTLT);\ make_lua_key(ptr);\ +make_lua_key(pTRT);\ +make_lua_key(punct);\ make_lua_key(push);\ make_lua_key(quad);\ make_lua_key(radical);\ make_lua_key(raw);\ +make_lua_key(read_to_cs);\ +make_lua_key(recompress);\ make_lua_key(ref_count);\ make_lua_key(reg);\ +make_lua_key(register);\ make_lua_key(registry);\ +make_lua_key(regular);\ +make_lua_key(rel);\ +make_lua_key(relax);\ +make_lua_key(remove_item);\ make_lua_key(renew);\ make_lua_key(rep);\ make_lua_key(replace);\ make_lua_key(resources);\ make_lua_key(right);\ make_lua_key(right_boundary);\ +make_lua_key(right_brace);\ make_lua_key(right_protruding);\ make_lua_key(rightskip);\ make_lua_key(rotation);\ +make_lua_key(RTT);\ make_lua_key(rule);\ +make_lua_key(save_pos);\ make_lua_key(scale);\ make_lua_key(script);\ make_lua_key(scriptscript);\ +make_lua_key(second);\ make_lua_key(semi_simple);\ +make_lua_key(set);\ +make_lua_key(set_aux);\ +make_lua_key(set_box);\ +make_lua_key(set_box_dimen);\ +make_lua_key(set_etex_shape);\ +make_lua_key(set_font);\ +make_lua_key(set_font_id);\ +make_lua_key(set_interaction);\ +make_lua_key(set_math_param);\ +make_lua_key(set_page_dimen);\ +make_lua_key(set_page_int);\ +make_lua_key(set_prev_graf);\ +make_lua_key(set_tex_shape);\ +make_lua_key(shape);\ +make_lua_key(shape_ref);\ make_lua_key(shift);\ +make_lua_key(shorthand_def);\ make_lua_key(shrink);\ make_lua_key(shrink_order);\ make_lua_key(simple);\ @@ -776,13 +1079,22 @@ make_lua_key(space);\ make_lua_key(space_shrink);\ make_lua_key(space_stretch);\ make_lua_key(spacefactor);\ +make_lua_key(spacer);\ +make_lua_key(spaceskip);\ +make_lua_key(span);\ +make_lua_key(spec);\ make_lua_key(special);\ make_lua_key(split_discards_head);\ +make_lua_key(split_insert);\ make_lua_key(split_keep);\ make_lua_key(split_off);\ +make_lua_key(splittopskip);\ +make_lua_key(squeeze);\ make_lua_key(stack);\ make_lua_key(start);\ +make_lua_key(start_par);\ make_lua_key(step);\ +make_lua_key(stop);\ make_lua_key(stream);\ make_lua_key(streamfile);\ make_lua_key(streamprovider);\ @@ -791,72 +1103,122 @@ make_lua_key(stretch_order);\ make_lua_key(string);\ make_lua_key(style);\ make_lua_key(sub);\ +make_lua_key(sub_box);\ +make_lua_key(sub_mark);\ +make_lua_key(sub_mlist);\ make_lua_key(subst_ex_font);\ make_lua_key(subtype);\ make_lua_key(sup);\ +make_lua_key(sup_mark);\ +make_lua_key(super_sub_script);\ make_lua_key(supplement);\ make_lua_key(surround);\ +make_lua_key(tab_mark);\ +make_lua_key(tabskip);\ make_lua_key(tail);\ +make_lua_key(temp);\ make_lua_key(temp_head);\ make_lua_key(term);\ make_lua_key(term_and_log);\ make_lua_key(tex);\ make_lua_key(text);\ +make_lua_key(the);\ +make_lua_key(thickmuskip);\ +make_lua_key(thinmuskip);\ +make_lua_key(thread);\ make_lua_key(thread_attr);\ make_lua_key(thread_id);\ -make_lua_key(tolerance);\ +make_lua_key(TLT);\ make_lua_key(tok);\ make_lua_key(token);\ +make_lua_key(toks_register);\ +make_lua_key(tolerance);\ make_lua_key(top);\ make_lua_key(top_accent);\ +make_lua_key(top_bot_mark);\ make_lua_key(top_left);\ make_lua_key(top_right);\ +make_lua_key(topskip);\ make_lua_key(tounicode);\ make_lua_key(tracingparagraphs);\ make_lua_key(trailer);\ +make_lua_key(Trailer);\ make_lua_key(trailerid);\ make_lua_key(transform);\ make_lua_key(trim);\ +make_lua_key(TRT);\ make_lua_key(type);\ make_lua_key(uchyph);\ +make_lua_key(udelimiterover);\ +make_lua_key(udelimiterunder);\ +make_lua_key(un_hbox);\ +make_lua_key(un_vbox);\ +make_lua_key(undefined_cs);\ +make_lua_key(under);\ +make_lua_key(unhyphenated);\ make_lua_key(units_per_em);\ +make_lua_key(unknown);\ +make_lua_key(unset);\ +make_lua_key(uoverdelimiter);\ +make_lua_key(uradical);\ +make_lua_key(uroot);\ make_lua_key(used);\ +make_lua_key(user);\ +make_lua_key(userpassword);\ +make_lua_key(user_defined);\ make_lua_key(user_id);\ +make_lua_key(userkern);\ +make_lua_key(userpenalty);\ +make_lua_key(userskip);\ +make_lua_key(uunderdelimiter);\ make_lua_key(v);\ +make_lua_key(vadjust);\ +make_lua_key(valign);\ make_lua_key(value);\ +make_lua_key(variable);\ make_lua_key(vbox);\ make_lua_key(vcenter);\ make_lua_key(version);\ make_lua_key(vert_italic);\ make_lua_key(vert_variants);\ -make_lua_key(vmode_par);\ make_lua_key(visiblefilename);\ make_lua_key(vlist);\ +make_lua_key(vmode_par);\ +make_lua_key(vmove);\ +make_lua_key(vrule);\ +make_lua_key(vskip);\ make_lua_key(vtop);\ +make_lua_key(whatsit);\ make_lua_key(widowpenalty);\ make_lua_key(width);\ +make_lua_key(word);\ +make_lua_key(wordpenalty);\ +make_lua_key(write); \ +make_lua_key(writingmode); \ make_lua_key(x_height);\ make_lua_key(xadvance);\ -make_lua_key(xformresources);\ make_lua_key(xformattributes);\ +make_lua_key(xformresources);\ +make_lua_key(xleaders);\ +make_lua_key(xmath_given);\ make_lua_key(xoffset);\ +make_lua_key(xray);\ make_lua_key(xres);\ make_lua_key(xsize);\ +make_lua_key(xspaceskip);\ +make_lua_key(xyz);\ make_lua_key(xyz_zoom);\ make_lua_key(yoffset); \ make_lua_key(yres); \ -make_lua_key(ysize); \ -make_lua_key(writingmode); \ -make_lua_key(__index) +make_lua_key(ysize); #define set_init_keys \ -init_lua_key(cmdname);init_lua_key(expandable);init_lua_key(protected);\ -init_lua_key(LTL);\ -init_lua_key(MathConstants);\ -init_lua_key(RTT);\ -init_lua_key(TLT);\ -init_lua_key(TRT);\ +init_lua_key(__index);\ +init_lua_key(above);\ +init_lua_key(abovedisplayshortskip);\ +init_lua_key(abovedisplayskip);\ init_lua_key(accent);\ +init_lua_key(accentkern);\ init_lua_key(action);\ init_lua_key(action_id);\ init_lua_key(action_type);\ @@ -868,53 +1230,107 @@ init_lua_key(adjust_head);\ init_lua_key(adjusted_hbox);\ init_lua_key(adjustspacing);\ init_lua_key(advance);\ +init_lua_key(after_assignment);\ init_lua_key(after_display);\ +init_lua_key(after_group);\ init_lua_key(after_output);\ +init_lua_key(afterdisplaypenalty);\ init_lua_key(align);\ init_lua_key(align_head);\ +init_lua_key(align_record);\ init_lua_key(align_set);\ +init_lua_key(align_stack);\ init_lua_key(alignment);\ +init_lua_key(always);\ init_lua_key(annot);\ init_lua_key(area);\ init_lua_key(art);\ +init_lua_key(assign_attr);\ +init_lua_key(assign_box_dir);\ +init_lua_key(assign_box_direction);\ +init_lua_key(assign_dimen);\ +init_lua_key(assign_dir);\ +init_lua_key(assign_direction);\ +init_lua_key(assign_font_dimen);\ +init_lua_key(assign_font_int);\ +init_lua_key(assign_glue);\ +init_lua_key(assign_hang_indent);\ +init_lua_key(assign_int);\ +init_lua_key(assign_local_box);\ +init_lua_key(assign_mu_glue);\ +init_lua_key(assign_toks);\ init_lua_key(attr);\ +init_lua_key(attribute);\ +init_lua_key(attribute_list);\ init_lua_key(attributes);\ +init_lua_key(automatic);\ +init_lua_key(baselineskip);\ init_lua_key(bbox);\ init_lua_key(before_display);\ +init_lua_key(beforedisplaypenalty);\ +init_lua_key(begin_group);\ +init_lua_key(beginmath);\ +init_lua_key(belowdisplayshortskip);\ +init_lua_key(belowdisplayskip);\ init_lua_key(best_ins_ptr);\ init_lua_key(best_page_break);\ init_lua_key(best_size);\ +init_lua_key(bin);\ init_lua_key(bleed);\ init_lua_key(bot);\ init_lua_key(bot_accent);\ +init_lua_key(bothflexible);\ init_lua_key(bottom_left);\ init_lua_key(bottom_right);\ init_lua_key(boundary);\ init_lua_key(box);\ init_lua_key(box_left);\ init_lua_key(box_left_width);\ +init_lua_key(box_ref);\ init_lua_key(box_right);\ init_lua_key(box_right_width);\ +init_lua_key(box_there);\ +init_lua_key(break_penalty);\ init_lua_key(broken_ins);\ init_lua_key(broken_ptr);\ init_lua_key(brokenpenalty);\ init_lua_key(cache);\ init_lua_key(cal_expand_ratio);\ +init_lua_key(call);\ +init_lua_key(cancel);\ +init_lua_key(car_ret);\ +init_lua_key(case_shift);\ +init_lua_key(Catalog);\ init_lua_key(catalog);\ +init_lua_key(cell);\ init_lua_key(char);\ +init_lua_key(char_ghost);\ +init_lua_key(char_given);\ +init_lua_key(char_num);\ +init_lua_key(character);\ init_lua_key(characters);\ init_lua_key(checksum);\ +init_lua_key(choice);\ init_lua_key(cidinfo);\ init_lua_key(class);\ +init_lua_key(cleaders);\ +init_lua_key(close);\ init_lua_key(clubpenalty);\ +init_lua_key(cmd);\ +init_lua_key(cmdname);\ +init_lua_key(color_stack);\ init_lua_key(colordepth);\ init_lua_key(colorspace);\ +init_lua_key(combinetoks);\ init_lua_key(command);\ init_lua_key(commands);\ init_lua_key(comment);\ init_lua_key(components);\ init_lua_key(compresslevel);\ +init_lua_key(conditionalmathskip);\ init_lua_key(contrib_head);\ +init_lua_key(convert);\ +init_lua_key(copy_font);\ init_lua_key(core);\ init_lua_key(cost);\ init_lua_key(count);\ @@ -923,11 +1339,21 @@ init_lua_key(crampedscript);\ init_lua_key(crampedscriptscript);\ init_lua_key(crampedtext);\ init_lua_key(crop);\ +init_lua_key(cs_name);\ init_lua_key(csname);\ +init_lua_key(current);\ init_lua_key(data);\ +init_lua_key(def);\ +init_lua_key(def_char_code);\ +init_lua_key(def_del_code);\ +init_lua_key(def_family);\ +init_lua_key(def_font);\ +init_lua_key(def_lua_call);\ init_lua_key(degree);\ init_lua_key(delim);\ +init_lua_key(delim_num);\ init_lua_key(delimptr);\ +init_lua_key(delta);\ init_lua_key(demerits);\ init_lua_key(denom);\ init_lua_key(depth);\ @@ -940,45 +1366,91 @@ init_lua_key(direct);\ init_lua_key(direction);\ init_lua_key(dirs);\ init_lua_key(disc);\ +init_lua_key(discretionary);\ init_lua_key(display);\ +init_lua_key(divide);\ +init_lua_key(dont_expand);\ init_lua_key(doublehyphendemerits);\ init_lua_key(down);\ init_lua_key(embedding);\ init_lua_key(emergencystretch);\ +init_lua_key(empty);\ init_lua_key(encodingbytes);\ init_lua_key(encodingname);\ init_lua_key(end);\ -init_lua_key(etex);\ +init_lua_key(end_cs_name);\ +init_lua_key(end_group);\ +init_lua_key(end_template);\ +init_lua_key(endmath);\ +init_lua_key(endv);\ +init_lua_key(eq_no);\ init_lua_key(equation);\ init_lua_key(equation_number);\ +init_lua_key(equationnumber);\ +init_lua_key(equationnumberpenalty);\ +init_lua_key(etex);\ +init_lua_key(ex_space);\ init_lua_key(exactly);\ +init_lua_key(expand_after);\ +init_lua_key(expand_font);\ +init_lua_key(expandable);\ init_lua_key(expansion_factor);\ +init_lua_key(explicit);\ +init_lua_key(expr_stack);\ init_lua_key(ext);\ +init_lua_key(extdef_del_code);\ +init_lua_key(extdef_math_code);\ init_lua_key(extend);\ init_lua_key(extender);\ init_lua_key(extensible);\ +init_lua_key(extension);\ init_lua_key(extra_space);\ init_lua_key(fam);\ init_lua_key(fast);\ +init_lua_key(feedback);\ init_lua_key(fence);\ +init_lua_key(fi);\ +init_lua_key(fi_or_else);\ +init_lua_key(fil);\ init_lua_key(file);\ init_lua_key(filename);\ init_lua_key(filepath);\ init_lua_key(fill);\ +init_lua_key(filll);\ +init_lua_key(fillll);\ init_lua_key(fin_row);\ init_lua_key(finalhyphendemerits);\ +init_lua_key(finalpenalty);\ +init_lua_key(first);\ +init_lua_key(fit);\ +init_lua_key(fitb);\ +init_lua_key(fitbh);\ +init_lua_key(fitbv);\ +init_lua_key(fith);\ +init_lua_key(fitr);\ +init_lua_key(fitv);\ +init_lua_key(fixedboth);\ +init_lua_key(fixedbottom);\ +init_lua_key(fixedtop);\ init_lua_key(font);\ +init_lua_key(fontkern);\ init_lua_key(fonts);\ init_lua_key(format);\ init_lua_key(fraction);\ init_lua_key(fullname);\ +init_lua_key(ghost);\ +init_lua_key(gleaders);\ init_lua_key(global);\ init_lua_key(glue);\ init_lua_key(glue_order);\ +init_lua_key(glue_ref);\ init_lua_key(glue_set);\ init_lua_key(glue_sign);\ +init_lua_key(glue_spec);\ init_lua_key(glyph);\ +init_lua_key(goto);\ init_lua_key(h);\ +init_lua_key(halign);\ init_lua_key(hangafter);\ init_lua_key(hangindent);\ init_lua_key(hbox);\ @@ -986,20 +1458,37 @@ init_lua_key(head);\ init_lua_key(height);\ init_lua_key(hlist);\ init_lua_key(hmode_par);\ +init_lua_key(hmove);\ init_lua_key(hold_head);\ init_lua_key(horiz_variants);\ +init_lua_key(hrule);\ init_lua_key(hsize);\ +init_lua_key(hskip);\ +init_lua_key(hyph_data);\ +init_lua_key(hyphenated);\ init_lua_key(hyphenchar);\ init_lua_key(id);\ init_lua_key(identity);\ +init_lua_key(if_stack);\ +init_lua_key(if_test);\ +init_lua_key(ignore_spaces);\ init_lua_key(image);\ init_lua_key(imagetype);\ init_lua_key(immediate);\ +init_lua_key(in_stream);\ +init_lua_key(indent);\ init_lua_key(index);\ init_lua_key(info);\ +init_lua_key(Info);\ +init_lua_key(inner);\ +init_lua_key(input);\ +init_lua_key(ins);\ init_lua_key(insert);\ +init_lua_key(inserts_only);\ init_lua_key(interlinepenalty);\ +init_lua_key(ital_corr);\ init_lua_key(italic);\ +init_lua_key(italiccorrection);\ init_lua_key(keepopen);\ init_lua_key(kern);\ init_lua_key(kerns);\ @@ -1007,82 +1496,179 @@ init_lua_key(lang);\ init_lua_key(large_char);\ init_lua_key(large_fam);\ init_lua_key(last_ins_ptr);\ +init_lua_key(last_item);\ init_lua_key(lastlinefit);\ -init_lua_key(leftskip);\ +init_lua_key(late_lua);\ init_lua_key(leader);\ +init_lua_key(leader_ship);\ +init_lua_key(leaders);\ init_lua_key(least_page_cost);\ init_lua_key(left);\ init_lua_key(left_boundary);\ +init_lua_key(left_brace);\ init_lua_key(left_protruding);\ +init_lua_key(left_right);\ init_lua_key(leftskip);\ +init_lua_key(let);\ +init_lua_key(letter);\ +init_lua_key(letterspace_font);\ init_lua_key(level);\ +init_lua_key(ligature);\ init_lua_key(ligatures);\ -init_lua_key(leftskip);\ +init_lua_key(limit_switch);\ +init_lua_key(line);\ +init_lua_key(linebreakpenalty);\ init_lua_key(linepenalty);\ +init_lua_key(lineskip);\ init_lua_key(link_attr);\ init_lua_key(list);\ init_lua_key(local_box);\ +init_lua_key(local_par);\ init_lua_key(log);\ +init_lua_key(long_call);\ +init_lua_key(long_outer_call);\ init_lua_key(looseness);\ +init_lua_key(LTL);\ init_lua_key(lua);\ +init_lua_key(lua_bytecode_call);\ init_lua_key(lua_bytecodes_indirect);\ +init_lua_key(lua_call);\ +init_lua_key(lua_expandable_call);\ +init_lua_key(lua_local_call);\ +init_lua_key(lua_function_call);\ init_lua_key(lua_functions);\ init_lua_key(luatex);\ init_lua_key(luatex_node);\ init_lua_key(luatex_token);\ +init_lua_key(luatex_pdfe);\ +init_lua_key(luatex_pdfe_dictionary);\ +init_lua_key(luatex_pdfe_array);\ +init_lua_key(luatex_pdfe_stream);\ +init_lua_key(luatex_pdfe_reference);\ +init_lua_key(mac_param);\ +init_lua_key(make_box);\ +init_lua_key(margin_kern);\ init_lua_key(marginkern);\ init_lua_key(mark);\ init_lua_key(math);\ +init_lua_key(math_accent);\ +init_lua_key(math_char);\ +init_lua_key(math_char_num);\ init_lua_key(math_choice);\ +init_lua_key(math_comp);\ +init_lua_key(math_given);\ init_lua_key(math_left);\ init_lua_key(math_shift);\ +init_lua_key(math_shift_cs);\ +init_lua_key(math_style);\ +init_lua_key(math_sub_box);\ +init_lua_key(math_sub_mlist);\ +init_lua_key(math_text_char);\ +init_lua_key(MathConstants);\ init_lua_key(mathdir);\ init_lua_key(mathkern);\ +init_lua_key(mathskip);\ init_lua_key(mathstyle);\ init_lua_key(media);\ +init_lua_key(medmuskip);\ +init_lua_key(message);\ init_lua_key(mid);\ init_lua_key(middle);\ +init_lua_key(mkern);\ init_lua_key(mode);\ init_lua_key(modeline);\ +init_lua_key(movement_stack);\ +init_lua_key(mskip);\ +init_lua_key(muglue);\ +init_lua_key(multiply);\ init_lua_key(name);\ init_lua_key(named_id);\ init_lua_key(names);\ +init_lua_key(nested_list);\ +init_lua_key(new);\ init_lua_key(new_graf);\ init_lua_key(new_window);\ init_lua_key(next);\ init_lua_key(no);\ +init_lua_key(nolength);\ init_lua_key(no_align);\ +init_lua_key(no_expand);\ +init_lua_key(no_super_sub_script);\ init_lua_key(noad);\ +init_lua_key(noadpenalty);\ init_lua_key(node);\ +init_lua_key(nohrule);\ init_lua_key(nomath);\ +init_lua_key(non_script);\ init_lua_key(none);\ +init_lua_key(nonew);\ init_lua_key(nop);\ +init_lua_key(normal);\ +init_lua_key(novrule);\ init_lua_key(nucleus);\ init_lua_key(num);\ init_lua_key(number);\ init_lua_key(objcompression);\ init_lua_key(objnum);\ init_lua_key(oldmath);\ +init_lua_key(omit);\ +init_lua_key(opdisplaylimits);\ +init_lua_key(open);\ +init_lua_key(oplimits);\ +init_lua_key(opnolimits);\ +init_lua_key(option);\ init_lua_key(options);\ +init_lua_key(ord);\ +init_lua_key(ordering);\ init_lua_key(orientation);\ init_lua_key(origin);\ -init_lua_key(ordering);\ +init_lua_key(other_char);\ +init_lua_key(outer_call);\ +init_lua_key(outline);\ init_lua_key(output);\ +init_lua_key(over);\ init_lua_key(overlay_accent);\ +init_lua_key(ownerpassword);\ init_lua_key(page);\ -init_lua_key(pages);\ init_lua_key(page_discards_head);\ init_lua_key(page_head);\ init_lua_key(page_ins_head);\ +init_lua_key(page_insert);\ init_lua_key(pageattributes);\ init_lua_key(pagebox);\ init_lua_key(pageresources);\ +init_lua_key(pages);\ +init_lua_key(Pages);\ init_lua_key(pagesattributes);\ +init_lua_key(pagestate);\ +init_lua_key(par_end);\ init_lua_key(parameters);\ init_lua_key(pardir);\ +init_lua_key(parfillskip);\ init_lua_key(parshape);\ +init_lua_key(parskip);\ +init_lua_key(passive);\ +init_lua_key(pdfe);\ +init_lua_key(pdf_action);\ +init_lua_key(pdf_annot);\ +init_lua_key(pdf_colorstack);\ +init_lua_key(pdf_dest);\ init_lua_key(pdf_destination);\ +init_lua_key(pdf_end_link);\ +init_lua_key(pdf_end_thread);\ +init_lua_key(pdf_link_data);\ init_lua_key(pdf_literal);\ +init_lua_key(pdf_refobj);\ +init_lua_key(pdf_restore);\ +init_lua_key(pdf_save);\ +init_lua_key(pdf_setmatrix);\ +init_lua_key(pdf_setobj);\ +init_lua_key(pdf_start);\ +init_lua_key(pdf_start_link);\ +init_lua_key(pdf_start_thread);\ +init_lua_key(pdf_thread);\ +init_lua_key(pdf_thread_data);\ +init_lua_key(pdf_window);\ init_lua_key(pen_broken);\ init_lua_key(pen_inter);\ init_lua_key(penalty);\ @@ -1095,35 +1681,68 @@ init_lua_key(pre_adjust_head);\ init_lua_key(pre_align);\ init_lua_key(pre_box);\ init_lua_key(preamble);\ +init_lua_key(prefix);\ init_lua_key(pretolerance);\ init_lua_key(prev);\ init_lua_key(prevdepth);\ init_lua_key(prevgraf);\ +init_lua_key(protected);\ init_lua_key(protrudechars);\ +init_lua_key(protrusion);\ +init_lua_key(pseudo_file);\ +init_lua_key(pseudo_line);\ init_lua_key(psname);\ init_lua_key(ptr);\ +init_lua_key(punct);\ init_lua_key(push);\ init_lua_key(quad);\ init_lua_key(radical);\ init_lua_key(raw);\ +init_lua_key(read_to_cs);\ init_lua_key(ref_count);\ +init_lua_key(recompress);\ init_lua_key(reg);\ +init_lua_key(register);\ init_lua_key(registry);\ +init_lua_key(regular);\ +init_lua_key(rel);\ +init_lua_key(relax);\ +init_lua_key(remove_item);\ init_lua_key(renew);\ init_lua_key(rep);\ init_lua_key(replace);\ init_lua_key(resources);\ init_lua_key(right);\ init_lua_key(right_boundary);\ +init_lua_key(right_brace);\ init_lua_key(right_protruding);\ init_lua_key(rightskip);\ init_lua_key(rotation);\ +init_lua_key(RTT);\ init_lua_key(rule);\ +init_lua_key(save_pos);\ init_lua_key(scale);\ init_lua_key(script);\ init_lua_key(scriptscript);\ +init_lua_key(second);\ init_lua_key(semi_simple);\ +init_lua_key(set);\ +init_lua_key(set_aux);\ +init_lua_key(set_box);\ +init_lua_key(set_box_dimen);\ +init_lua_key(set_etex_shape);\ +init_lua_key(set_font);\ +init_lua_key(set_font_id);\ +init_lua_key(set_interaction);\ +init_lua_key(set_math_param);\ +init_lua_key(set_page_dimen);\ +init_lua_key(set_page_int);\ +init_lua_key(set_prev_graf);\ +init_lua_key(set_tex_shape);\ +init_lua_key(shape);\ +init_lua_key(shape_ref);\ init_lua_key(shift);\ +init_lua_key(shorthand_def);\ init_lua_key(shrink);\ init_lua_key(shrink_order);\ init_lua_key(simple);\ @@ -1137,13 +1756,22 @@ init_lua_key(space);\ init_lua_key(space_shrink);\ init_lua_key(space_stretch);\ init_lua_key(spacefactor);\ +init_lua_key(spacer);\ +init_lua_key(spaceskip);\ +init_lua_key(span);\ +init_lua_key(spec);\ init_lua_key(special);\ init_lua_key(split_discards_head);\ +init_lua_key(split_insert);\ init_lua_key(split_keep);\ init_lua_key(split_off);\ +init_lua_key(splittopskip);\ +init_lua_key(squeeze);\ init_lua_key(stack);\ init_lua_key(start);\ +init_lua_key(start_par);\ init_lua_key(step);\ +init_lua_key(stop);\ init_lua_key(stream);\ init_lua_key(streamfile);\ init_lua_key(streamprovider);\ @@ -1152,67 +1780,123 @@ init_lua_key(stretch_order);\ init_lua_key(string);\ init_lua_key(style);\ init_lua_key(sub);\ +init_lua_key(sub_box);\ +init_lua_key(sub_mark);\ +init_lua_key(sub_mlist);\ init_lua_key(subst_ex_font);\ init_lua_key(subtype);\ init_lua_key(sup);\ +init_lua_key(sup_mark);\ +init_lua_key(super_sub_script);\ init_lua_key(supplement);\ init_lua_key(surround);\ +init_lua_key(tab_mark);\ +init_lua_key(tabskip);\ init_lua_key(tail);\ +init_lua_key(temp);\ init_lua_key(temp_head);\ init_lua_key(term);\ init_lua_key(tex);\ init_lua_key(text);\ +init_lua_key(the);\ +init_lua_key(thickmuskip);\ +init_lua_key(thinmuskip);\ +init_lua_key(thread);\ init_lua_key(thread_attr);\ init_lua_key(thread_id);\ -init_lua_key(tolerance);\ +init_lua_key(TLT);\ init_lua_key(tok);\ init_lua_key(token);\ +init_lua_key(toks_register);\ +init_lua_key(tolerance);\ init_lua_key(top);\ init_lua_key(top_accent);\ +init_lua_key(top_bot_mark);\ init_lua_key(top_left);\ init_lua_key(top_right);\ +init_lua_key(topskip);\ init_lua_key(tounicode);\ init_lua_key(tracingparagraphs);\ init_lua_key(trailer);\ +init_lua_key(Trailer);\ init_lua_key(trailerid);\ init_lua_key(transform);\ init_lua_key(trim);\ +init_lua_key(TRT);\ init_lua_key(type);\ init_lua_key(uchyph);\ +init_lua_key(udelimiterover);\ +init_lua_key(udelimiterunder);\ +init_lua_key(un_hbox);\ +init_lua_key(un_vbox);\ +init_lua_key(undefined_cs);\ +init_lua_key(under);\ +init_lua_key(unhyphenated);\ init_lua_key(units_per_em);\ +init_lua_key(unknown);\ +init_lua_key(unset);\ +init_lua_key(uoverdelimiter);\ +init_lua_key(uradical);\ +init_lua_key(uroot);\ init_lua_key(used);\ +init_lua_key(user);\ +init_lua_key(userpassword);\ +init_lua_key(user_defined);\ init_lua_key(user_id);\ +init_lua_key(userkern);\ +init_lua_key(userpenalty);\ +init_lua_key(userskip);\ +init_lua_key(uunderdelimiter);\ init_lua_key(v);\ +init_lua_key(vadjust);\ +init_lua_key(valign);\ init_lua_key(value);\ +init_lua_key(variable);\ init_lua_key(vbox);\ init_lua_key(vcenter);\ init_lua_key(version);\ init_lua_key(vert_italic);\ init_lua_key(vert_variants);\ -init_lua_key(vmode_par);\ init_lua_key(visiblefilename);\ init_lua_key(vlist);\ +init_lua_key(vmode_par);\ +init_lua_key(vmove);\ +init_lua_key(vrule);\ +init_lua_key(vskip);\ init_lua_key(vtop);\ +init_lua_key(whatsit);\ init_lua_key(widowpenalty);\ init_lua_key(width);\ +init_lua_key(word);\ +init_lua_key(wordpenalty);\ +init_lua_key(write);\ +init_lua_key(writingmode);\ init_lua_key(x_height);\ init_lua_key(xadvance);\ -init_lua_key(xformresources);\ init_lua_key(xformattributes);\ +init_lua_key(xformresources);\ +init_lua_key(xleaders);\ +init_lua_key(xmath_given);\ init_lua_key(xoffset);\ +init_lua_key(xray);\ init_lua_key(xres);\ init_lua_key(xsize);\ +init_lua_key(xspaceskip);\ +init_lua_key(xyz);\ init_lua_key(xyz_zoom);\ init_lua_key(yoffset);\ init_lua_key(yres);\ init_lua_key(ysize);\ -init_lua_key(writingmode);\ -init_lua_key(__index);\ init_lua_key_alias(empty_string,"");\ init_lua_key_alias(lua_bytecodes_indirect,"lua.bytecodes.indirect");\ init_lua_key_alias(lua_functions,"lua.functions");\ init_lua_key_alias(luatex_node, "luatex.node");\ init_lua_key_alias(luatex_token, "luatex.token");\ +init_lua_key_alias(luatex_pdfe, "luatex.pdfe");\ +init_lua_key_alias(luatex_pdfe_dictionary, "luatex.pdfe.dictionary");\ +init_lua_key_alias(luatex_pdfe_array, "luatex.pdfe.array");\ +init_lua_key_alias(luatex_pdfe_stream, "luatex.pdfe.stream");\ +init_lua_key_alias(luatex_pdfe_reference, "luatex.pdfe.reference");\ init_lua_key_alias(mLTL,"-LTL");\ init_lua_key_alias(mRTT,"-RTT");\ init_lua_key_alias(mTLT,"-TLT");\ @@ -1268,14 +1952,12 @@ extern FILE *_cairo_win_tmpfile( void ); /* These keys have to available to different files */ /* */ -use_lua_key(cmdname);use_lua_key(expandable);use_lua_key(protected); - -use_lua_key(LTL); -use_lua_key(MathConstants); -use_lua_key(RTT); -use_lua_key(TLT); -use_lua_key(TRT); +use_lua_key(__index); +use_lua_key(above); +use_lua_key(abovedisplayshortskip); +use_lua_key(abovedisplayskip); use_lua_key(accent); +use_lua_key(accentkern); use_lua_key(action); use_lua_key(action_id); use_lua_key(action_type); @@ -1287,53 +1969,107 @@ use_lua_key(adjust_head); use_lua_key(adjusted_hbox); use_lua_key(adjustspacing); use_lua_key(advance); +use_lua_key(after_assignment); use_lua_key(after_display); +use_lua_key(after_group); use_lua_key(after_output); +use_lua_key(afterdisplaypenalty); use_lua_key(align); use_lua_key(align_head); +use_lua_key(align_record); use_lua_key(align_set); +use_lua_key(align_stack); use_lua_key(alignment); +use_lua_key(always); use_lua_key(annot); use_lua_key(area); use_lua_key(art); +use_lua_key(assign_attr); +use_lua_key(assign_box_dir); +use_lua_key(assign_box_direction); +use_lua_key(assign_dimen); +use_lua_key(assign_dir); +use_lua_key(assign_direction); +use_lua_key(assign_font_dimen); +use_lua_key(assign_font_int); +use_lua_key(assign_glue); +use_lua_key(assign_hang_indent); +use_lua_key(assign_int); +use_lua_key(assign_local_box); +use_lua_key(assign_mu_glue); +use_lua_key(assign_toks); use_lua_key(attr); +use_lua_key(attribute); +use_lua_key(attribute_list); use_lua_key(attributes); +use_lua_key(automatic); +use_lua_key(baselineskip); use_lua_key(bbox); use_lua_key(before_display); +use_lua_key(beforedisplaypenalty); +use_lua_key(begin_group); +use_lua_key(beginmath); +use_lua_key(belowdisplayshortskip); +use_lua_key(belowdisplayskip); use_lua_key(best_ins_ptr); use_lua_key(best_page_break); use_lua_key(best_size); +use_lua_key(bin); use_lua_key(bleed); use_lua_key(bot); use_lua_key(bot_accent); +use_lua_key(bothflexible); use_lua_key(bottom_left); use_lua_key(bottom_right); use_lua_key(boundary); use_lua_key(box); use_lua_key(box_left); use_lua_key(box_left_width); +use_lua_key(box_ref); use_lua_key(box_right); use_lua_key(box_right_width); +use_lua_key(box_there); +use_lua_key(break_penalty); use_lua_key(broken_ins); use_lua_key(broken_ptr); use_lua_key(brokenpenalty); use_lua_key(cache); use_lua_key(cal_expand_ratio); +use_lua_key(call); +use_lua_key(cancel); +use_lua_key(car_ret); +use_lua_key(case_shift); +use_lua_key(Catalog); use_lua_key(catalog); +use_lua_key(cell); use_lua_key(char); +use_lua_key(char_ghost); +use_lua_key(char_given); +use_lua_key(char_num); +use_lua_key(character); use_lua_key(characters); use_lua_key(checksum); +use_lua_key(choice); use_lua_key(cidinfo); use_lua_key(class); +use_lua_key(cleaders); +use_lua_key(close); use_lua_key(clubpenalty); +use_lua_key(cmd); +use_lua_key(cmdname); +use_lua_key(color_stack); use_lua_key(colordepth); use_lua_key(colorspace); +use_lua_key(combinetoks); use_lua_key(command); use_lua_key(commands); use_lua_key(comment); use_lua_key(components); use_lua_key(compresslevel); +use_lua_key(conditionalmathskip); use_lua_key(contrib_head); +use_lua_key(convert); +use_lua_key(copy_font); use_lua_key(core); use_lua_key(cost); use_lua_key(count); @@ -1342,11 +2078,21 @@ use_lua_key(crampedscript); use_lua_key(crampedscriptscript); use_lua_key(crampedtext); use_lua_key(crop); +use_lua_key(cs_name); use_lua_key(csname); +use_lua_key(current); use_lua_key(data); +use_lua_key(def); +use_lua_key(def_char_code); +use_lua_key(def_del_code); +use_lua_key(def_family); +use_lua_key(def_font); +use_lua_key(def_lua_call); use_lua_key(degree); use_lua_key(delim); +use_lua_key(delim_num); use_lua_key(delimptr); +use_lua_key(delta); use_lua_key(demerits); use_lua_key(denom); use_lua_key(depth); @@ -1359,46 +2105,92 @@ use_lua_key(direct); use_lua_key(direction); use_lua_key(dirs); use_lua_key(disc); +use_lua_key(discretionary); use_lua_key(display); +use_lua_key(divide); +use_lua_key(dont_expand); use_lua_key(doublehyphendemerits); use_lua_key(down); use_lua_key(embedding); use_lua_key(emergencystretch); +use_lua_key(empty); use_lua_key(empty_string); use_lua_key(encodingbytes); use_lua_key(encodingname); use_lua_key(end); -use_lua_key(etex); +use_lua_key(end_cs_name); +use_lua_key(end_group); +use_lua_key(end_template); +use_lua_key(endmath); +use_lua_key(endv); +use_lua_key(eq_no); use_lua_key(equation);\ use_lua_key(equation_number);\ +use_lua_key(equationnumber); +use_lua_key(equationnumberpenalty); +use_lua_key(etex); +use_lua_key(ex_space); use_lua_key(exactly); +use_lua_key(expand_after); +use_lua_key(expand_font); +use_lua_key(expandable); use_lua_key(expansion_factor); +use_lua_key(explicit); +use_lua_key(expr_stack); use_lua_key(ext); +use_lua_key(extdef_del_code); +use_lua_key(extdef_math_code); use_lua_key(extend); use_lua_key(extender); use_lua_key(extensible); +use_lua_key(extension); use_lua_key(extra_space); use_lua_key(fam); use_lua_key(fast); +use_lua_key(feedback); use_lua_key(fence); +use_lua_key(fi); +use_lua_key(fi_or_else); +use_lua_key(fil); use_lua_key(file); use_lua_key(filename); use_lua_key(filepath); use_lua_key(fill); +use_lua_key(filll); +use_lua_key(fillll); use_lua_key(fin_row); use_lua_key(finalhyphendemerits); +use_lua_key(finalpenalty); +use_lua_key(first); +use_lua_key(fit); +use_lua_key(fitb); +use_lua_key(fitbh); +use_lua_key(fitbv); +use_lua_key(fith); +use_lua_key(fitr); +use_lua_key(fitv); +use_lua_key(fixedboth); +use_lua_key(fixedbottom); +use_lua_key(fixedtop); use_lua_key(font); +use_lua_key(fontkern); use_lua_key(fonts); use_lua_key(format); use_lua_key(fraction); use_lua_key(fullname); +use_lua_key(ghost); +use_lua_key(gleaders); use_lua_key(global); use_lua_key(glue); use_lua_key(glue_order); +use_lua_key(glue_ref); use_lua_key(glue_set); use_lua_key(glue_sign); +use_lua_key(glue_spec); use_lua_key(glyph); +use_lua_key(goto); use_lua_key(h); +use_lua_key(halign); use_lua_key(hangafter); use_lua_key(hangindent); use_lua_key(hbox); @@ -1406,20 +2198,37 @@ use_lua_key(head); use_lua_key(height); use_lua_key(hlist); use_lua_key(hmode_par); +use_lua_key(hmove); use_lua_key(hold_head); use_lua_key(horiz_variants); +use_lua_key(hrule); use_lua_key(hsize); +use_lua_key(hskip); +use_lua_key(hyph_data); +use_lua_key(hyphenated); use_lua_key(hyphenchar); use_lua_key(id); use_lua_key(identity); +use_lua_key(if_stack); +use_lua_key(if_test); +use_lua_key(ignore_spaces); use_lua_key(image); use_lua_key(imagetype); use_lua_key(immediate); +use_lua_key(in_stream); +use_lua_key(indent); use_lua_key(index); use_lua_key(info); +use_lua_key(Info); +use_lua_key(inner); +use_lua_key(input); +use_lua_key(ins); use_lua_key(insert); +use_lua_key(inserts_only); use_lua_key(interlinepenalty); +use_lua_key(ital_corr); use_lua_key(italic); +use_lua_key(italiccorrection); use_lua_key(keepopen); use_lua_key(kern); use_lua_key(kerns); @@ -1427,95 +2236,191 @@ use_lua_key(lang); use_lua_key(large_char); use_lua_key(large_fam); use_lua_key(last_ins_ptr); +use_lua_key(last_item); use_lua_key(lastlinefit); +use_lua_key(late_lua); use_lua_key(leader); +use_lua_key(leader_ship); +use_lua_key(leaders); use_lua_key(least_page_cost); use_lua_key(left); use_lua_key(left_boundary); +use_lua_key(left_brace); use_lua_key(left_protruding); +use_lua_key(left_right); use_lua_key(leftskip); +use_lua_key(let); +use_lua_key(letter); +use_lua_key(letterspace_font); use_lua_key(level); +use_lua_key(ligature); use_lua_key(ligatures); +use_lua_key(limit_switch); +use_lua_key(line); +use_lua_key(linebreakpenalty); use_lua_key(linepenalty); +use_lua_key(lineskip); use_lua_key(link_attr); use_lua_key(list); use_lua_key(local_box); +use_lua_key(local_par); use_lua_key(log); +use_lua_key(long_call); +use_lua_key(long_outer_call); use_lua_key(looseness); +use_lua_key(LTL); use_lua_key(lua); +use_lua_key(lua_bytecode_call); use_lua_key(lua_bytecodes_indirect); +use_lua_key(lua_call); +use_lua_key(lua_expandable_call); +use_lua_key(lua_local_call); +use_lua_key(lua_function_call); use_lua_key(lua_functions); use_lua_key(luatex); use_lua_key(luatex_node); use_lua_key(luatex_token); -use_lua_key(mLTL); -use_lua_key(mRTT); -use_lua_key(mTLT); -use_lua_key(mTRT); +use_lua_key(luatex_pdfe); +use_lua_key(luatex_pdfe_dictionary); +use_lua_key(luatex_pdfe_array); +use_lua_key(luatex_pdfe_stream); +use_lua_key(luatex_pdfe_reference); +use_lua_key(mac_param); +use_lua_key(make_box); +use_lua_key(margin_kern); use_lua_key(marginkern); use_lua_key(mark); use_lua_key(math); +use_lua_key(math_accent); +use_lua_key(math_char); +use_lua_key(math_char_num); use_lua_key(math_choice); +use_lua_key(math_comp); +use_lua_key(math_given); use_lua_key(math_left); use_lua_key(math_shift); +use_lua_key(math_shift_cs); +use_lua_key(math_style); +use_lua_key(math_sub_box); +use_lua_key(math_sub_mlist); +use_lua_key(math_text_char); +use_lua_key(MathConstants); use_lua_key(mathdir); use_lua_key(mathkern); +use_lua_key(mathskip); use_lua_key(mathstyle); use_lua_key(media); +use_lua_key(medmuskip); +use_lua_key(message); use_lua_key(mid); use_lua_key(middle); +use_lua_key(mkern); +use_lua_key(mLTL); use_lua_key(mode); use_lua_key(modeline); +use_lua_key(movement_stack); +use_lua_key(mRTT); +use_lua_key(mskip); +use_lua_key(mTLT); +use_lua_key(mTRT); +use_lua_key(muglue); +use_lua_key(multiply); use_lua_key(name); use_lua_key(named_id); use_lua_key(names); +use_lua_key(nested_list); +use_lua_key(new); use_lua_key(new_graf); use_lua_key(new_window); use_lua_key(next); use_lua_key(no); +use_lua_key(nolength); use_lua_key(no_align); +use_lua_key(no_expand); +use_lua_key(no_super_sub_script); use_lua_key(noad); +use_lua_key(noadpenalty); use_lua_key(node); use_lua_key(node_properties); use_lua_key(node_properties_indirect); +use_lua_key(nohrule); use_lua_key(nomath); +use_lua_key(non_script); use_lua_key(none); +use_lua_key(nonew); use_lua_key(nop); +use_lua_key(normal); +use_lua_key(novrule); use_lua_key(nucleus); use_lua_key(num); use_lua_key(number); use_lua_key(objcompression); use_lua_key(objnum); use_lua_key(oldmath); +use_lua_key(omit); +use_lua_key(opdisplaylimits); +use_lua_key(open); +use_lua_key(oplimits); +use_lua_key(opnolimits); +use_lua_key(option); use_lua_key(options); +use_lua_key(ord); +use_lua_key(ordering); use_lua_key(orientation); use_lua_key(origin); -use_lua_key(ordering); +use_lua_key(other_char); +use_lua_key(outer_call); +use_lua_key(outline); use_lua_key(output); +use_lua_key(over); use_lua_key(overlay_accent); -use_lua_key(pLTL); -use_lua_key(pRTT); -use_lua_key(pTLT); -use_lua_key(pTRT); +use_lua_key(ownerpassword); use_lua_key(page); -use_lua_key(pages); use_lua_key(page_discards_head); use_lua_key(page_head); use_lua_key(page_ins_head); -use_lua_key(pagebox); +use_lua_key(page_insert); use_lua_key(pageattributes); +use_lua_key(pagebox); use_lua_key(pageresources); +use_lua_key(pages); +use_lua_key(Pages); use_lua_key(pagesattributes); +use_lua_key(pagestate); +use_lua_key(par_end); use_lua_key(parameters); use_lua_key(pardir); +use_lua_key(parfillskip); use_lua_key(parshape); +use_lua_key(parskip); +use_lua_key(passive); use_lua_key(pdf); +use_lua_key(pdfe); +use_lua_key(pdf_action); +use_lua_key(pdf_annot); +use_lua_key(pdf_colorstack); use_lua_key(pdf_data); +use_lua_key(pdf_dest); use_lua_key(pdf_destination); +use_lua_key(pdf_end_link); +use_lua_key(pdf_end_thread); +use_lua_key(pdf_link_data); use_lua_key(pdf_literal); +use_lua_key(pdf_refobj); +use_lua_key(pdf_restore); +use_lua_key(pdf_save); +use_lua_key(pdf_setmatrix); +use_lua_key(pdf_setobj); +use_lua_key(pdf_start); +use_lua_key(pdf_start_link); +use_lua_key(pdf_start_thread); +use_lua_key(pdf_thread); +use_lua_key(pdf_thread_data); +use_lua_key(pdf_window); use_lua_key(pen_broken); use_lua_key(pen_inter); use_lua_key(penalty); +use_lua_key(pLTL); use_lua_key(pop); use_lua_key(post); use_lua_key(post_linebreak); @@ -1525,35 +2430,71 @@ use_lua_key(pre_adjust_head); use_lua_key(pre_align); use_lua_key(pre_box); use_lua_key(preamble); +use_lua_key(prefix); use_lua_key(pretolerance); use_lua_key(prev); use_lua_key(prevdepth); use_lua_key(prevgraf); +use_lua_key(protected); use_lua_key(protrudechars); +use_lua_key(protrusion); +use_lua_key(pRTT); +use_lua_key(pseudo_file); +use_lua_key(pseudo_line); use_lua_key(psname); +use_lua_key(pTLT); use_lua_key(ptr); +use_lua_key(pTRT); +use_lua_key(punct); use_lua_key(push); use_lua_key(quad); use_lua_key(radical); use_lua_key(raw); +use_lua_key(read_to_cs); use_lua_key(ref_count); +use_lua_key(recompress); use_lua_key(reg); +use_lua_key(register); use_lua_key(registry); +use_lua_key(regular); +use_lua_key(rel); +use_lua_key(relax); +use_lua_key(remove_item); use_lua_key(renew); use_lua_key(rep); use_lua_key(replace); use_lua_key(resources); use_lua_key(right); use_lua_key(right_boundary); +use_lua_key(right_brace); use_lua_key(right_protruding); use_lua_key(rightskip); use_lua_key(rotation); +use_lua_key(RTT); use_lua_key(rule); +use_lua_key(save_pos); use_lua_key(scale); use_lua_key(script); use_lua_key(scriptscript); +use_lua_key(second); use_lua_key(semi_simple); +use_lua_key(set); +use_lua_key(set_aux); +use_lua_key(set_box); +use_lua_key(set_box_dimen); +use_lua_key(set_etex_shape); +use_lua_key(set_font); +use_lua_key(set_font_id); +use_lua_key(set_interaction); +use_lua_key(set_math_param); +use_lua_key(set_page_dimen); +use_lua_key(set_page_int); +use_lua_key(set_prev_graf); +use_lua_key(set_tex_shape); +use_lua_key(shape); +use_lua_key(shape_ref); use_lua_key(shift); +use_lua_key(shorthand_def); use_lua_key(shrink); use_lua_key(shrink_order); use_lua_key(simple); @@ -1567,13 +2508,22 @@ use_lua_key(space); use_lua_key(space_shrink); use_lua_key(space_stretch); use_lua_key(spacefactor); +use_lua_key(spacer); +use_lua_key(spaceskip); +use_lua_key(span); +use_lua_key(spec); use_lua_key(special); use_lua_key(split_discards_head); +use_lua_key(split_insert); use_lua_key(split_keep); use_lua_key(split_off); +use_lua_key(splittopskip); +use_lua_key(squeeze); use_lua_key(stack); use_lua_key(start); +use_lua_key(start_par); use_lua_key(step); +use_lua_key(stop); use_lua_key(stream); use_lua_key(streamfile); use_lua_key(streamprovider); @@ -1582,60 +2532,111 @@ use_lua_key(stretch_order); use_lua_key(string); use_lua_key(style); use_lua_key(sub); +use_lua_key(sub_box); +use_lua_key(sub_mark); +use_lua_key(sub_mlist); use_lua_key(subst_ex_font); use_lua_key(subtype); use_lua_key(sup); +use_lua_key(sup_mark); +use_lua_key(super_sub_script); use_lua_key(supplement); use_lua_key(surround); +use_lua_key(tab_mark); +use_lua_key(tabskip); use_lua_key(tail); +use_lua_key(temp); use_lua_key(temp_head); use_lua_key(term); use_lua_key(term_and_log); use_lua_key(tex); use_lua_key(text); +use_lua_key(the); +use_lua_key(thickmuskip); +use_lua_key(thinmuskip); +use_lua_key(thread); use_lua_key(thread_attr); use_lua_key(thread_id); -use_lua_key(tolerance); +use_lua_key(TLT); use_lua_key(tok); use_lua_key(token); +use_lua_key(toks_register); +use_lua_key(tolerance); use_lua_key(top); use_lua_key(top_accent); +use_lua_key(top_bot_mark); use_lua_key(top_left); use_lua_key(top_right); +use_lua_key(topskip); use_lua_key(tounicode); use_lua_key(tracingparagraphs); use_lua_key(trailer); +use_lua_key(Trailer); use_lua_key(trailerid); use_lua_key(transform); use_lua_key(trim); +use_lua_key(TRT); use_lua_key(type); use_lua_key(uchyph); +use_lua_key(udelimiterover); +use_lua_key(udelimiterunder); +use_lua_key(un_hbox); +use_lua_key(un_vbox); +use_lua_key(undefined_cs); +use_lua_key(under); +use_lua_key(unhyphenated); use_lua_key(units_per_em); +use_lua_key(unknown); +use_lua_key(unset); +use_lua_key(uoverdelimiter); +use_lua_key(uradical); +use_lua_key(uroot); use_lua_key(used); +use_lua_key(user); +use_lua_key(userpassword); +use_lua_key(user_defined); use_lua_key(user_id); +use_lua_key(userkern); +use_lua_key(userpenalty); +use_lua_key(userskip); +use_lua_key(uunderdelimiter); use_lua_key(v); +use_lua_key(vadjust); +use_lua_key(valign); use_lua_key(value); +use_lua_key(variable); use_lua_key(vbox); use_lua_key(vcenter); use_lua_key(version); use_lua_key(vert_italic); use_lua_key(vert_variants); -use_lua_key(vmode_par); use_lua_key(visiblefilename); use_lua_key(vlist); +use_lua_key(vmode_par); +use_lua_key(vmove); +use_lua_key(vrule); +use_lua_key(vskip); use_lua_key(vtop); +use_lua_key(whatsit); use_lua_key(widowpenalty); use_lua_key(width); +use_lua_key(word); +use_lua_key(wordpenalty); +use_lua_key(write); +use_lua_key(writingmode); use_lua_key(x_height); use_lua_key(xadvance); -use_lua_key(xformresources); use_lua_key(xformattributes); +use_lua_key(xformresources); +use_lua_key(xleaders); +use_lua_key(xmath_given); use_lua_key(xoffset); +use_lua_key(xray); use_lua_key(xres); use_lua_key(xsize); +use_lua_key(xspaceskip); +use_lua_key(xyz); use_lua_key(xyz_zoom); use_lua_key(yoffset); use_lua_key(yres); use_lua_key(ysize); -use_lua_key(writingmode); -use_lua_key(__index); diff --git a/Build/source/texk/web2c/luatexdir/lua/luatex-core.c b/Build/source/texk/web2c/luatexdir/lua/luatex-core.c index 6551b0bc443..5cb58af6513 100644 --- a/Build/source/texk/web2c/luatexdir/lua/luatex-core.c +++ b/Build/source/texk/web2c/luatexdir/lua/luatex-core.c @@ -17,7 +17,7 @@ int load_luatex_core_lua (lua_State * L) 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x20, 0x5b, 0x27, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x27, 0x5d, 0x20, 0x3d, 0x20, 0x7b, 0x0a, 0x2d, 0x2d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x31, 0x2e, - 0x30, 0x30, 0x35, 0x2c, 0x0a, 0x2d, 0x2d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6d, 0x6d, + 0x30, 0x38, 0x30, 0x2c, 0x0a, 0x2d, 0x2d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x27, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x6f, 0x20, 0x6c, 0x75, 0x61, 0x74, 0x65, 0x78, 0x27, 0x2c, 0x0a, 0x2d, 0x2d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x20, 0x20, 0x20, 0x20, @@ -27,536 +27,609 @@ int load_luatex_core_lua (lua_State * L) 0x3d, 0x20, 0x27, 0x4c, 0x75, 0x61, 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, 0x35, 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, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x73, 0x20, 0x70, - 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x61, 0x6d, 0x65, 0x0a, - 0x2d, 0x2d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, - 0x20, 0x61, 0x73, 0x20, 0x4c, 0x75, 0x61, 0x54, 0x65, 0x58, 0x20, 0x3c, 0x3d, 0x20, 0x31, 0x2e, - 0x30, 0x34, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x64, 0x6f, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x74, 0x20, - 0x74, 0x68, 0x69, 0x73, 0x20, 0x77, 0x61, 0x79, 0x20, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x74, 0x73, - 0x20, 0x75, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x6b, 0x65, 0x65, 0x70, 0x20, 0x74, 0x68, 0x65, 0x0a, - 0x2d, 0x2d, 0x20, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x20, 0x69, 0x6f, 0x20, 0x6c, - 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, 0x20, 0x63, 0x6c, 0x65, 0x61, 0x6e, 0x2e, 0x20, - 0x50, 0x65, 0x72, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x6e, 0x63, 0x65, 0x20, 0x69, 0x73, 0x20, 0x70, - 0x72, 0x6f, 0x62, 0x61, 0x62, 0x6c, 0x79, 0x20, 0x65, 0x76, 0x65, 0x6e, 0x20, 0x61, 0x20, 0x62, - 0x69, 0x74, 0x20, 0x62, 0x65, 0x74, 0x74, 0x65, 0x72, 0x20, 0x6e, 0x6f, 0x77, 0x2e, 0x0a, 0x0a, - 0x6c, 0x6f, 0x63, 0x61, 0x6c, 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, 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, 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, 0x2d, 0x2d, 0x20, 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, 0x2d, 0x2d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6e, - 0x61, 0x6d, 0x65, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x2d, 0x2d, 0x20, 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, 0x2d, 0x2d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x69, 0x66, 0x20, 0x66, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x2d, 0x2d, 0x20, 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, 0x2d, 0x2d, 0x20, - 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, 0x2d, 0x2d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x2d, 0x2d, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x2d, 0x2d, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x2d, 0x2d, 0x20, 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, 0x2d, 0x2d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x2d, 0x2d, 0x20, - 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x2d, 0x2d, 0x20, 0x46, 0x6f, 0x72, 0x20, 0x73, 0x6f, 0x6d, 0x65, - 0x20, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x67, 0x63, 0x20, 0x64, - 0x6f, 0x65, 0x73, 0x6e, 0x27, 0x74, 0x20, 0x6b, 0x69, 0x63, 0x6b, 0x20, 0x69, 0x6e, 0x20, 0x73, - 0x6f, 0x20, 0x77, 0x65, 0x20, 0x6e, 0x65, 0x65, 0x64, 0x20, 0x74, 0x6f, 0x20, 0x63, 0x6c, 0x6f, - 0x73, 0x65, 0x20, 0x65, 0x78, 0x70, 0x6c, 0x69, 0x74, 0x6c, 0x79, 0x0a, 0x2d, 0x2d, 0x20, 0x73, - 0x6f, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, - 0x65, 0x20, 0x69, 0x73, 0x20, 0x66, 0x6c, 0x75, 0x73, 0x68, 0x65, 0x64, 0x2e, 0x0a, 0x0a, 0x6c, - 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x2c, 0x20, 0x74, 0x79, 0x70, 0x65, - 0x20, 0x3d, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x2c, 0x20, 0x74, 0x79, 0x70, 0x65, 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, - 0x74, 0x79, 0x70, 0x65, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x20, 0x3d, 0x3d, 0x20, 0x22, 0x73, - 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 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, + 0x53, 0x49, 0x4f, 0x4e, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x38, 0x30, 0x20, 0x2d, 0x2d, 0x20, + 0x77, 0x65, 0x20, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, + 0x75, 0x61, 0x74, 0x65, 0x78, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x77, 0x68, + 0x65, 0x72, 0x65, 0x20, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x73, 0x20, 0x68, 0x61, 0x70, 0x70, + 0x65, 0x6e, 0x65, 0x64, 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, 0x76, 0x61, + 0x72, 0x69, 0x61, 0x6e, 0x74, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x20, 0x74, + 0x68, 0x65, 0x20, 0x73, 0x61, 0x6d, 0x65, 0x0a, 0x2d, 0x2d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x20, 0x61, 0x73, 0x20, 0x4c, 0x75, 0x61, 0x54, + 0x65, 0x58, 0x20, 0x3c, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x34, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x64, + 0x6f, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x74, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x77, 0x61, 0x79, + 0x20, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x74, 0x73, 0x20, 0x75, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x6b, + 0x65, 0x65, 0x70, 0x20, 0x74, 0x68, 0x65, 0x0a, 0x2d, 0x2d, 0x20, 0x6f, 0x72, 0x69, 0x67, 0x69, + 0x6e, 0x61, 0x6c, 0x20, 0x69, 0x6f, 0x20, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x69, 0x65, 0x73, + 0x20, 0x63, 0x6c, 0x65, 0x61, 0x6e, 0x2e, 0x20, 0x50, 0x65, 0x72, 0x66, 0x6f, 0x72, 0x6d, 0x61, + 0x6e, 0x63, 0x65, 0x20, 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x62, 0x61, 0x62, 0x6c, 0x79, 0x20, + 0x65, 0x76, 0x65, 0x6e, 0x20, 0x61, 0x20, 0x62, 0x69, 0x74, 0x20, 0x62, 0x65, 0x74, 0x74, 0x65, + 0x72, 0x20, 0x6e, 0x6f, 0x77, 0x2e, 0x0a, 0x0a, 0x2d, 0x2d, 0x20, 0x57, 0x65, 0x20, 0x74, 0x65, + 0x73, 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, + 0x20, 0x61, 0x6c, 0x72, 0x65, 0x61, 0x64, 0x79, 0x20, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x20, 0x64, + 0x65, 0x66, 0x69, 0x6e, 0x65, 0x64, 0x20, 0x73, 0x6f, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x77, + 0x65, 0x20, 0x64, 0x6f, 0x6e, 0x27, 0x74, 0x20, 0x6f, 0x76, 0x65, 0x72, 0x6c, 0x6f, 0x61, 0x64, + 0x20, 0x6f, 0x6e, 0x65, 0x73, 0x20, 0x74, 0x68, 0x61, 0x74, 0x0a, 0x2d, 0x2d, 0x20, 0x61, 0x72, + 0x65, 0x20, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x64, 0x20, 0x69, 0x6e, 0x20, 0x74, 0x68, + 0x65, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x75, 0x70, 0x20, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, + 0x2e, 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 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, 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, 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, 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, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6c, 0x20, 0x3d, - 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, 0x20, 0x20, 0x20, - 0x20, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6c, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x66, 0x3a, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x28, 0x29, 0x0a, 0x20, 0x20, 0x20, - 0x20, 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, 0x20, 0x20, 0x20, - 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6c, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 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, 0x2d, 0x2d, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x6f, 0x73, 0x65, 0x20, - 0x77, 0x68, 0x6f, 0x20, 0x6c, 0x69, 0x6b, 0x65, 0x20, 0x69, 0x74, 0x20, 0x74, 0x68, 0x69, 0x73, - 0x20, 0x77, 0x61, 0x79, 0x3a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x28, 0x22, 0x70, 0x61, 0x74, 0x63, 0x68, 0x65, 0x64, - 0x20, 0x27, 0x69, 0x6f, 0x2e, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x27, 0x20, 0x63, 0x61, 0x6e, 0x27, - 0x74, 0x20, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x27, 0x22, 0x20, 0x2e, 0x2e, 0x20, 0x6e, 0x61, 0x6d, - 0x65, 0x20, 0x2e, 0x2e, 0x20, 0x22, 0x27, 0x22, 0x29, 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, + 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, 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, + 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, 0x2d, 0x2d, 0x20, 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, 0x2d, 0x2d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, + 0x66, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x2d, 0x2d, 0x20, 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, 0x2d, 0x2d, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x66, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x2d, + 0x2d, 0x20, 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, + 0x2d, 0x2d, 0x20, 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, 0x2d, 0x2d, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x2d, 0x2d, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x2d, 0x2d, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x2d, 0x2d, 0x20, 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, 0x2d, 0x2d, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, + 0x2d, 0x2d, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x2d, 0x2d, 0x20, 0x46, 0x6f, 0x72, 0x20, 0x73, + 0x6f, 0x6d, 0x65, 0x20, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x67, + 0x63, 0x20, 0x64, 0x6f, 0x65, 0x73, 0x6e, 0x27, 0x74, 0x20, 0x6b, 0x69, 0x63, 0x6b, 0x20, 0x69, + 0x6e, 0x20, 0x73, 0x6f, 0x20, 0x77, 0x65, 0x20, 0x6e, 0x65, 0x65, 0x64, 0x20, 0x74, 0x6f, 0x20, + 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x20, 0x65, 0x78, 0x70, 0x6c, 0x69, 0x74, 0x6c, 0x79, 0x0a, 0x2d, + 0x2d, 0x20, 0x73, 0x6f, 0x20, 0x74, 0x68, 0x61, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20, 0x68, 0x61, + 0x6e, 0x64, 0x6c, 0x65, 0x20, 0x69, 0x73, 0x20, 0x66, 0x6c, 0x75, 0x73, 0x68, 0x65, 0x64, 0x2e, + 0x0a, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x2c, 0x20, 0x74, + 0x79, 0x70, 0x65, 0x20, 0x3d, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x2c, 0x20, 0x74, 0x79, 0x70, + 0x65, 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, 0x74, 0x79, 0x70, 0x65, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x20, 0x3d, 0x3d, + 0x20, 0x22, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 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, - 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, 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, + 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, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, + 0x6c, 0x20, 0x3d, 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, + 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6c, 0x20, 0x74, 0x68, 0x65, + 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x3a, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0x28, 0x29, 0x0a, + 0x20, 0x20, 0x20, 0x20, 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, + 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6c, 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, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x6f, + 0x73, 0x65, 0x20, 0x77, 0x68, 0x6f, 0x20, 0x6c, 0x69, 0x6b, 0x65, 0x20, 0x69, 0x74, 0x20, 0x74, + 0x68, 0x69, 0x73, 0x20, 0x77, 0x61, 0x79, 0x3a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x28, 0x22, 0x70, 0x61, 0x74, 0x63, + 0x68, 0x65, 0x64, 0x20, 0x27, 0x69, 0x6f, 0x2e, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x27, 0x20, 0x63, + 0x61, 0x6e, 0x27, 0x74, 0x20, 0x6f, 0x70, 0x65, 0x6e, 0x20, 0x27, 0x22, 0x20, 0x2e, 0x2e, 0x20, + 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x2e, 0x2e, 0x20, 0x22, 0x27, 0x22, 0x29, 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, 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, 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, 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, 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, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6d, + 0x64, 0x35, 0x2e, 0x73, 0x75, 0x6d, 0x68, 0x65, 0x78, 0x61, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, + 0x20, 0x20, 0x20, 0x20, 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, 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, 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, 0x2d, 0x2d, 0x20, 0x63, - 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x3a, 0x20, 0x74, 0x68, - 0x69, 0x73, 0x20, 0x6d, 0x69, 0x67, 0x68, 0x74, 0x20, 0x67, 0x6f, 0x20, 0x61, 0x77, 0x61, 0x79, - 0x0a, 0x0a, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x75, 0x6e, 0x70, 0x61, 0x63, 0x6b, 0x20, - 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x75, 0x6e, 0x70, 0x61, 0x63, 0x6b, 0x20, - 0x3d, 0x20, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x75, 0x6e, 0x70, 0x61, 0x63, 0x6b, 0x0a, 0x65, - 0x6e, 0x64, 0x0a, 0x0a, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x70, 0x61, 0x63, 0x6b, 0x61, - 0x67, 0x65, 0x2e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x72, 0x73, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, - 0x20, 0x20, 0x20, 0x20, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2e, 0x6c, 0x6f, 0x61, 0x64, - 0x65, 0x72, 0x73, 0x20, 0x3d, 0x20, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2e, 0x73, 0x65, - 0x61, 0x72, 0x63, 0x68, 0x65, 0x72, 0x73, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x69, 0x66, 0x20, - 0x6e, 0x6f, 0x74, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x74, - 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x74, 0x72, 0x69, - 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x2d, + 0x22, 0x25, 0x30, 0x32, 0x78, 0x22, 0x2c, 0x62, 0x79, 0x74, 0x65, 0x28, 0x63, 0x29, 0x29, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x29, + 0x29, 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, 0x69, 0x66, 0x20, 0x6e, 0x6f, + 0x74, 0x20, 0x6d, 0x64, 0x35, 0x2e, 0x73, 0x75, 0x6d, 0x48, 0x45, 0x58, 0x41, 0x20, 0x74, 0x68, + 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 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, 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, 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, 0x20, 0x20, 0x20, 0x20, 0x65, + 0x6e, 0x64, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x2d, 0x2d, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x3a, - 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x6d, 0x69, 0x67, 0x68, 0x74, 0x20, 0x73, 0x74, 0x61, 0x79, - 0x0a, 0x0a, 0x69, 0x66, 0x20, 0x62, 0x69, 0x74, 0x33, 0x32, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, - 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x6c, 0x75, 0x61, 0x20, 0x35, 0x2e, 0x32, 0x3a, - 0x20, 0x77, 0x65, 0x27, 0x72, 0x65, 0x20, 0x6f, 0x6b, 0x61, 0x79, 0x0a, 0x0a, 0x65, 0x6c, 0x73, - 0x65, 0x69, 0x66, 0x20, 0x75, 0x74, 0x66, 0x38, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x0a, 0x20, - 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x6c, 0x75, 0x61, 0x20, 0x35, 0x2e, 0x33, 0x3a, 0x20, 0x20, - 0x62, 0x69, 0x74, 0x77, 0x69, 0x73, 0x65, 0x2e, 0x6c, 0x75, 0x61, 0x2c, 0x20, 0x76, 0x20, 0x31, - 0x2e, 0x32, 0x34, 0x20, 0x32, 0x30, 0x31, 0x34, 0x2f, 0x31, 0x32, 0x2f, 0x32, 0x36, 0x20, 0x31, - 0x37, 0x3a, 0x32, 0x30, 0x3a, 0x35, 0x33, 0x20, 0x72, 0x6f, 0x62, 0x65, 0x72, 0x74, 0x6f, 0x0a, - 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x69, 0x74, 0x33, 0x32, 0x20, 0x3d, 0x20, 0x6c, 0x6f, 0x61, - 0x64, 0x20, 0x28, 0x20, 0x5b, 0x5b, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x73, 0x65, 0x6c, - 0x65, 0x63, 0x74, 0x20, 0x3d, 0x20, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x20, 0x2d, 0x2d, 0x20, - 0x69, 0x6e, 0x73, 0x74, 0x65, 0x61, 0x64, 0x20, 0x6f, 0x66, 0x3a, 0x20, 0x61, 0x72, 0x67, 0x20, - 0x3d, 0x20, 0x7b, 0x20, 0x2e, 0x2e, 0x2e, 0x20, 0x7d, 0x0a, 0x0a, 0x62, 0x69, 0x74, 0x33, 0x32, - 0x20, 0x3d, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x62, 0x6e, 0x6f, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, - 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x61, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, - 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x7e, 0x61, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, - 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x62, - 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, - 0x78, 0x2c, 0x20, 0x79, 0x2c, 0x20, 0x7a, 0x2c, 0x20, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, - 0x20, 0x20, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x7a, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, 0x28, 0x78, - 0x20, 0x6f, 0x72, 0x20, 0x2d, 0x31, 0x29, 0x20, 0x26, 0x20, 0x28, 0x79, 0x20, 0x6f, 0x72, 0x20, - 0x2d, 0x31, 0x29, 0x29, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, - 0x46, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x72, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x78, 0x20, 0x26, - 0x20, 0x79, 0x20, 0x26, 0x20, 0x7a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, - 0x20, 0x69, 0x3d, 0x31, 0x2c, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x28, 0x22, 0x23, 0x22, 0x2c, - 0x2e, 0x2e, 0x2e, 0x29, 0x20, 0x64, 0x6f, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x72, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x72, 0x65, 0x73, 0x20, 0x26, 0x20, 0x73, 0x65, 0x6c, 0x65, - 0x63, 0x74, 0x28, 0x69, 0x2c, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, - 0x20, 0x72, 0x65, 0x73, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, - 0x46, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, - 0x0a, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, + 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x6d, 0x69, 0x67, 0x68, 0x74, 0x20, 0x67, 0x6f, 0x20, 0x61, + 0x77, 0x61, 0x79, 0x0a, 0x0a, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x75, 0x6e, 0x70, 0x61, + 0x63, 0x6b, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x75, 0x6e, 0x70, 0x61, + 0x63, 0x6b, 0x20, 0x3d, 0x20, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x2e, 0x75, 0x6e, 0x70, 0x61, 0x63, + 0x6b, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x70, 0x61, + 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x72, 0x73, 0x20, 0x74, 0x68, + 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2e, 0x6c, + 0x6f, 0x61, 0x64, 0x65, 0x72, 0x73, 0x20, 0x3d, 0x20, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, + 0x2e, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x65, 0x72, 0x73, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, + 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x73, + 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x3d, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x0a, 0x65, 0x6e, 0x64, + 0x0a, 0x0a, 0x2d, 0x2d, 0x20, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x74, 0x69, 0x62, 0x69, 0x6c, 0x69, + 0x74, 0x79, 0x3a, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x6d, 0x69, 0x67, 0x68, 0x74, 0x20, 0x73, + 0x74, 0x61, 0x79, 0x0a, 0x0a, 0x69, 0x66, 0x20, 0x62, 0x69, 0x74, 0x33, 0x32, 0x20, 0x74, 0x68, + 0x65, 0x6e, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x6c, 0x75, 0x61, 0x20, 0x35, + 0x2e, 0x32, 0x3a, 0x20, 0x77, 0x65, 0x27, 0x72, 0x65, 0x20, 0x6f, 0x6b, 0x61, 0x79, 0x0a, 0x0a, + 0x65, 0x6c, 0x73, 0x65, 0x69, 0x66, 0x20, 0x75, 0x74, 0x66, 0x38, 0x20, 0x74, 0x68, 0x65, 0x6e, + 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x6c, 0x75, 0x61, 0x20, 0x35, 0x2e, 0x33, + 0x3a, 0x20, 0x20, 0x62, 0x69, 0x74, 0x77, 0x69, 0x73, 0x65, 0x2e, 0x6c, 0x75, 0x61, 0x2c, 0x20, + 0x76, 0x20, 0x31, 0x2e, 0x32, 0x34, 0x20, 0x32, 0x30, 0x31, 0x34, 0x2f, 0x31, 0x32, 0x2f, 0x32, + 0x36, 0x20, 0x31, 0x37, 0x3a, 0x32, 0x30, 0x3a, 0x35, 0x33, 0x20, 0x72, 0x6f, 0x62, 0x65, 0x72, + 0x74, 0x6f, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x69, 0x74, 0x33, 0x32, 0x20, 0x3d, 0x20, + 0x6c, 0x6f, 0x61, 0x64, 0x20, 0x28, 0x20, 0x5b, 0x5b, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, + 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x20, 0x3d, 0x20, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x20, + 0x2d, 0x2d, 0x20, 0x69, 0x6e, 0x73, 0x74, 0x65, 0x61, 0x64, 0x20, 0x6f, 0x66, 0x3a, 0x20, 0x61, + 0x72, 0x67, 0x20, 0x3d, 0x20, 0x7b, 0x20, 0x2e, 0x2e, 0x2e, 0x20, 0x7d, 0x0a, 0x0a, 0x62, 0x69, + 0x74, 0x33, 0x32, 0x20, 0x3d, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x62, 0x6e, 0x6f, 0x74, 0x20, 0x3d, + 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x61, 0x29, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x7e, 0x61, 0x20, 0x26, 0x20, 0x30, 0x78, + 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, + 0x20, 0x20, 0x62, 0x61, 0x6e, 0x64, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x78, 0x2c, 0x20, 0x79, 0x2c, 0x20, 0x7a, 0x2c, 0x20, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x7a, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, - 0x28, 0x28, 0x78, 0x20, 0x6f, 0x72, 0x20, 0x30, 0x29, 0x20, 0x7c, 0x20, 0x28, 0x79, 0x20, 0x6f, - 0x72, 0x20, 0x30, 0x29, 0x29, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, - 0x46, 0x46, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x72, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x78, 0x20, - 0x7c, 0x20, 0x79, 0x20, 0x7c, 0x20, 0x7a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, - 0x72, 0x20, 0x69, 0x3d, 0x31, 0x2c, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x28, 0x22, 0x23, 0x22, - 0x2c, 0x2e, 0x2e, 0x2e, 0x29, 0x20, 0x64, 0x6f, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x72, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x72, 0x65, 0x73, 0x20, 0x7c, 0x20, 0x73, 0x65, 0x6c, - 0x65, 0x63, 0x74, 0x28, 0x69, 0x2c, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, - 0x6e, 0x20, 0x72, 0x65, 0x73, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, - 0x46, 0x46, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, - 0x2c, 0x0a, 0x20, 0x20, 0x62, 0x78, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x78, 0x2c, 0x20, 0x79, 0x2c, 0x20, 0x7a, 0x2c, 0x20, 0x2e, 0x2e, - 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x7a, 0x20, - 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, - 0x6e, 0x20, 0x28, 0x28, 0x78, 0x20, 0x6f, 0x72, 0x20, 0x30, 0x29, 0x20, 0x7e, 0x20, 0x28, 0x79, - 0x20, 0x6f, 0x72, 0x20, 0x30, 0x29, 0x29, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, + 0x28, 0x28, 0x78, 0x20, 0x6f, 0x72, 0x20, 0x2d, 0x31, 0x29, 0x20, 0x26, 0x20, 0x28, 0x79, 0x20, + 0x6f, 0x72, 0x20, 0x2d, 0x31, 0x29, 0x29, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x72, 0x65, 0x73, 0x20, 0x3d, 0x20, - 0x78, 0x20, 0x7e, 0x20, 0x79, 0x20, 0x7e, 0x20, 0x7a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x78, 0x20, 0x26, 0x20, 0x79, 0x20, 0x26, 0x20, 0x7a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x69, 0x3d, 0x31, 0x2c, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x28, 0x22, 0x23, 0x22, 0x2c, 0x2e, 0x2e, 0x2e, 0x29, 0x20, 0x64, 0x6f, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x72, 0x65, 0x73, 0x20, 0x7e, 0x20, 0x73, + 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x72, 0x65, 0x73, 0x20, 0x26, 0x20, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x28, 0x69, 0x2c, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x72, 0x65, 0x73, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x65, - 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x62, 0x74, 0x65, 0x73, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, + 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x78, 0x2c, 0x20, 0x79, 0x2c, 0x20, 0x7a, 0x2c, 0x20, 0x2e, + 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x7a, + 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, + 0x72, 0x6e, 0x20, 0x28, 0x28, 0x78, 0x20, 0x6f, 0x72, 0x20, 0x30, 0x29, 0x20, 0x7c, 0x20, 0x28, + 0x79, 0x20, 0x6f, 0x72, 0x20, 0x30, 0x29, 0x29, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, + 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x72, 0x65, 0x73, 0x20, 0x3d, + 0x20, 0x78, 0x20, 0x7c, 0x20, 0x79, 0x20, 0x7c, 0x20, 0x7a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x66, 0x6f, 0x72, 0x20, 0x69, 0x3d, 0x31, 0x2c, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x28, + 0x22, 0x23, 0x22, 0x2c, 0x2e, 0x2e, 0x2e, 0x29, 0x20, 0x64, 0x6f, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x72, 0x65, 0x73, 0x20, 0x7c, 0x20, + 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x28, 0x69, 0x2c, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, + 0x74, 0x75, 0x72, 0x6e, 0x20, 0x72, 0x65, 0x73, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, + 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, + 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x62, 0x78, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x78, 0x2c, 0x20, 0x79, 0x2c, 0x20, 0x7a, 0x2c, 0x20, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x7a, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, - 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, 0x28, 0x28, 0x78, 0x20, 0x6f, 0x72, 0x20, 0x2d, 0x31, 0x29, - 0x20, 0x26, 0x20, 0x28, 0x79, 0x20, 0x6f, 0x72, 0x20, 0x2d, 0x31, 0x29, 0x29, 0x20, 0x26, 0x20, - 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x29, 0x20, 0x7e, 0x3d, 0x20, 0x30, - 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x72, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x78, 0x20, 0x26, 0x20, - 0x79, 0x20, 0x26, 0x20, 0x7a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20, - 0x69, 0x3d, 0x31, 0x2c, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x28, 0x22, 0x23, 0x22, 0x2c, 0x2e, - 0x2e, 0x2e, 0x29, 0x20, 0x64, 0x6f, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x72, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x72, 0x65, 0x73, 0x20, 0x26, 0x20, 0x73, 0x65, 0x6c, - 0x65, 0x63, 0x74, 0x28, 0x69, 0x2c, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, - 0x6e, 0x20, 0x28, 0x72, 0x65, 0x73, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, - 0x46, 0x46, 0x46, 0x29, 0x20, 0x7e, 0x3d, 0x20, 0x30, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, - 0x64, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x6c, 0x73, 0x68, 0x69, 0x66, - 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x61, 0x2c, - 0x20, 0x62, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, - 0x28, 0x61, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x29, - 0x20, 0x3c, 0x3c, 0x20, 0x62, 0x29, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, - 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x72, 0x73, 0x68, - 0x69, 0x66, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, - 0x61, 0x2c, 0x20, 0x62, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, - 0x20, 0x28, 0x28, 0x61, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, - 0x46, 0x29, 0x20, 0x3e, 0x3e, 0x20, 0x62, 0x29, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, - 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x61, + 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, 0x28, 0x78, 0x20, 0x6f, 0x72, 0x20, 0x30, 0x29, 0x20, 0x7e, + 0x20, 0x28, 0x79, 0x20, 0x6f, 0x72, 0x20, 0x30, 0x29, 0x29, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, + 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x72, 0x65, 0x73, + 0x20, 0x3d, 0x20, 0x78, 0x20, 0x7e, 0x20, 0x79, 0x20, 0x7e, 0x20, 0x7a, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x69, 0x3d, 0x31, 0x2c, 0x73, 0x65, 0x6c, 0x65, 0x63, + 0x74, 0x28, 0x22, 0x23, 0x22, 0x2c, 0x2e, 0x2e, 0x2e, 0x29, 0x20, 0x64, 0x6f, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x72, 0x65, 0x73, 0x20, + 0x7e, 0x20, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x28, 0x69, 0x2c, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x72, 0x65, 0x73, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, + 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, + 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x62, 0x74, 0x65, 0x73, 0x74, 0x20, 0x3d, + 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x78, 0x2c, 0x20, 0x79, 0x2c, + 0x20, 0x7a, 0x2c, 0x20, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, + 0x6e, 0x6f, 0x74, 0x20, 0x7a, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, 0x28, 0x28, 0x78, 0x20, 0x6f, 0x72, 0x20, + 0x2d, 0x31, 0x29, 0x20, 0x26, 0x20, 0x28, 0x79, 0x20, 0x6f, 0x72, 0x20, 0x2d, 0x31, 0x29, 0x29, + 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x29, 0x20, 0x7e, + 0x3d, 0x20, 0x30, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x72, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x78, + 0x20, 0x26, 0x20, 0x79, 0x20, 0x26, 0x20, 0x7a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, + 0x6f, 0x72, 0x20, 0x69, 0x3d, 0x31, 0x2c, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x28, 0x22, 0x23, + 0x22, 0x2c, 0x2e, 0x2e, 0x2e, 0x29, 0x20, 0x64, 0x6f, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x72, 0x65, 0x73, 0x20, 0x26, 0x20, + 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x28, 0x69, 0x2c, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, + 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, 0x72, 0x65, 0x73, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, + 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x29, 0x20, 0x7e, 0x3d, 0x20, 0x30, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x6c, 0x73, + 0x68, 0x69, 0x66, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, + 0x28, 0x61, 0x2c, 0x20, 0x62, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, + 0x6e, 0x20, 0x28, 0x28, 0x61, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, + 0x46, 0x46, 0x29, 0x20, 0x3c, 0x3c, 0x20, 0x62, 0x29, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, + 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x72, 0x73, 0x68, 0x69, 0x66, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x20, 0x28, 0x61, 0x2c, 0x20, 0x62, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x61, 0x20, 0x3d, - 0x20, 0x61, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, - 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x62, 0x20, 0x3c, 0x3d, 0x20, 0x30, 0x20, 0x6f, 0x72, - 0x20, 0x28, 0x61, 0x20, 0x26, 0x20, 0x30, 0x78, 0x38, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, - 0x29, 0x20, 0x3d, 0x3d, 0x20, 0x30, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, 0x61, 0x20, 0x3e, 0x3e, 0x20, 0x62, - 0x29, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, - 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, - 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, 0x28, 0x61, 0x20, 0x3e, 0x3e, 0x20, 0x62, 0x29, 0x20, 0x7c, - 0x20, 0x7e, 0x28, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x20, 0x3e, 0x3e, - 0x20, 0x62, 0x29, 0x29, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, - 0x46, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, - 0x0a, 0x20, 0x20, 0x6c, 0x72, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x61, 0x20, 0x2c, 0x62, 0x29, 0x0a, 0x20, 0x20, 0x20, - 0x20, 0x62, 0x20, 0x3d, 0x20, 0x62, 0x20, 0x26, 0x20, 0x33, 0x31, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x6e, 0x20, 0x28, 0x61, 0x2c, 0x20, 0x62, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, + 0x75, 0x72, 0x6e, 0x20, 0x28, 0x28, 0x61, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, + 0x46, 0x46, 0x46, 0x46, 0x29, 0x20, 0x3e, 0x3e, 0x20, 0x62, 0x29, 0x20, 0x26, 0x20, 0x30, 0x78, + 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, + 0x20, 0x20, 0x61, 0x72, 0x73, 0x68, 0x69, 0x66, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x61, 0x2c, 0x20, 0x62, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x61, 0x20, 0x3d, 0x20, 0x61, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, - 0x46, 0x46, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x61, 0x20, 0x3d, 0x20, 0x28, 0x61, 0x20, 0x3c, 0x3c, - 0x20, 0x62, 0x29, 0x20, 0x7c, 0x20, 0x28, 0x61, 0x20, 0x3e, 0x3e, 0x20, 0x28, 0x33, 0x32, 0x20, - 0x2d, 0x20, 0x62, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, - 0x20, 0x61, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, - 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x72, 0x72, 0x6f, 0x74, 0x61, 0x74, 0x65, - 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x61, 0x2c, 0x20, - 0x62, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x20, 0x3d, 0x20, 0x2d, 0x62, 0x20, 0x26, 0x20, - 0x33, 0x31, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x61, 0x20, 0x3d, 0x20, 0x61, 0x20, 0x26, 0x20, 0x30, - 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x61, 0x20, - 0x3d, 0x20, 0x28, 0x61, 0x20, 0x3c, 0x3c, 0x20, 0x62, 0x29, 0x20, 0x7c, 0x20, 0x28, 0x61, 0x20, - 0x3e, 0x3e, 0x20, 0x28, 0x33, 0x32, 0x20, 0x2d, 0x20, 0x62, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x20, - 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, - 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, - 0x65, 0x78, 0x74, 0x72, 0x61, 0x63, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x20, 0x28, 0x61, 0x2c, 0x20, 0x66, 0x2c, 0x20, 0x77, 0x29, 0x0a, 0x20, 0x20, 0x20, - 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, 0x61, 0x20, 0x3e, 0x3e, 0x20, 0x66, 0x29, - 0x20, 0x26, 0x20, 0x7e, 0x28, 0x2d, 0x31, 0x20, 0x3c, 0x3c, 0x20, 0x28, 0x77, 0x20, 0x6f, 0x72, - 0x20, 0x31, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x72, 0x65, - 0x70, 0x6c, 0x61, 0x63, 0x65, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x20, 0x28, 0x61, 0x2c, 0x20, 0x76, 0x2c, 0x20, 0x66, 0x2c, 0x20, 0x77, 0x29, 0x0a, 0x20, 0x20, - 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x20, 0x3d, 0x20, 0x7e, - 0x28, 0x2d, 0x31, 0x20, 0x3c, 0x3c, 0x20, 0x28, 0x77, 0x20, 0x6f, 0x72, 0x20, 0x31, 0x29, 0x29, - 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, 0x28, 0x61, 0x20, - 0x26, 0x20, 0x7e, 0x28, 0x6d, 0x61, 0x73, 0x6b, 0x20, 0x3c, 0x3c, 0x20, 0x66, 0x29, 0x29, 0x20, - 0x7c, 0x20, 0x28, 0x28, 0x76, 0x20, 0x26, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x29, 0x20, 0x3c, 0x3c, - 0x20, 0x66, 0x29, 0x29, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, - 0x46, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x5d, 0x5d, 0x20, 0x29, 0x0a, 0x0a, 0x65, 0x6c, 0x73, 0x65, 0x69, 0x66, 0x20, - 0x62, 0x69, 0x74, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2d, 0x2d, - 0x20, 0x6c, 0x75, 0x61, 0x6a, 0x69, 0x74, 0x20, 0x28, 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x77, - 0x29, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x69, 0x74, 0x33, 0x32, 0x20, 0x3d, 0x20, 0x6c, - 0x6f, 0x61, 0x64, 0x20, 0x28, 0x20, 0x5b, 0x5b, 0x0a, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x62, - 0x61, 0x6e, 0x64, 0x2c, 0x20, 0x62, 0x6e, 0x6f, 0x74, 0x2c, 0x20, 0x72, 0x73, 0x68, 0x69, 0x66, - 0x74, 0x2c, 0x20, 0x6c, 0x73, 0x68, 0x69, 0x66, 0x74, 0x20, 0x3d, 0x20, 0x62, 0x69, 0x74, 0x2e, - 0x62, 0x61, 0x6e, 0x64, 0x2c, 0x20, 0x62, 0x69, 0x74, 0x2e, 0x62, 0x6e, 0x6f, 0x74, 0x2c, 0x20, - 0x62, 0x69, 0x74, 0x2e, 0x72, 0x73, 0x68, 0x69, 0x66, 0x74, 0x2c, 0x20, 0x62, 0x69, 0x74, 0x2e, - 0x6c, 0x73, 0x68, 0x69, 0x66, 0x74, 0x0a, 0x0a, 0x62, 0x69, 0x74, 0x33, 0x32, 0x20, 0x3d, 0x20, - 0x7b, 0x0a, 0x20, 0x20, 0x61, 0x72, 0x73, 0x68, 0x69, 0x66, 0x74, 0x20, 0x3d, 0x20, 0x62, 0x69, - 0x74, 0x2e, 0x61, 0x72, 0x73, 0x68, 0x69, 0x66, 0x74, 0x2c, 0x0a, 0x20, 0x20, 0x62, 0x61, 0x6e, - 0x64, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x62, 0x61, 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x62, - 0x6e, 0x6f, 0x74, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x62, 0x6e, 0x6f, 0x74, 0x2c, 0x0a, 0x20, - 0x20, 0x62, 0x6f, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x62, 0x69, 0x74, 0x2e, 0x62, - 0x6f, 0x72, 0x2c, 0x0a, 0x20, 0x20, 0x62, 0x78, 0x6f, 0x72, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, - 0x62, 0x69, 0x74, 0x2e, 0x62, 0x78, 0x6f, 0x72, 0x2c, 0x0a, 0x20, 0x20, 0x62, 0x74, 0x65, 0x73, - 0x74, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x2e, - 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x62, - 0x61, 0x6e, 0x64, 0x28, 0x2e, 0x2e, 0x2e, 0x29, 0x20, 0x7e, 0x3d, 0x20, 0x30, 0x0a, 0x20, 0x20, - 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x65, 0x78, 0x74, 0x72, 0x61, 0x63, 0x74, 0x20, 0x3d, - 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x61, 0x2c, 0x66, 0x2c, 0x77, 0x29, - 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x62, 0x61, 0x6e, 0x64, - 0x28, 0x72, 0x73, 0x68, 0x69, 0x66, 0x74, 0x28, 0x61, 0x2c, 0x66, 0x29, 0x2c, 0x32, 0x5e, 0x28, - 0x77, 0x20, 0x6f, 0x72, 0x20, 0x31, 0x29, 0x2d, 0x31, 0x29, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, - 0x2c, 0x0a, 0x20, 0x20, 0x6c, 0x72, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x20, 0x3d, 0x20, 0x62, 0x69, - 0x74, 0x2e, 0x72, 0x6f, 0x6c, 0x2c, 0x0a, 0x20, 0x20, 0x6c, 0x73, 0x68, 0x69, 0x66, 0x74, 0x20, - 0x20, 0x3d, 0x20, 0x6c, 0x73, 0x68, 0x69, 0x66, 0x74, 0x2c, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x70, - 0x6c, 0x61, 0x63, 0x65, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, - 0x61, 0x2c, 0x76, 0x2c, 0x66, 0x2c, 0x77, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, - 0x61, 0x6c, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x20, 0x3d, 0x20, 0x32, 0x5e, 0x28, 0x77, 0x20, 0x6f, - 0x72, 0x20, 0x31, 0x29, 0x2d, 0x31, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, - 0x6e, 0x20, 0x62, 0x61, 0x6e, 0x64, 0x28, 0x61, 0x2c, 0x62, 0x6e, 0x6f, 0x74, 0x28, 0x6c, 0x73, - 0x68, 0x69, 0x66, 0x74, 0x28, 0x6d, 0x61, 0x73, 0x6b, 0x2c, 0x66, 0x29, 0x29, 0x29, 0x2b, 0x6c, - 0x73, 0x68, 0x69, 0x66, 0x74, 0x28, 0x62, 0x61, 0x6e, 0x64, 0x28, 0x76, 0x2c, 0x6d, 0x61, 0x73, - 0x6b, 0x29, 0x2c, 0x66, 0x29, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x72, - 0x72, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x20, 0x3d, 0x20, 0x62, 0x69, 0x74, 0x2e, 0x72, 0x6f, 0x72, - 0x2c, 0x0a, 0x20, 0x20, 0x72, 0x73, 0x68, 0x69, 0x66, 0x74, 0x20, 0x20, 0x3d, 0x20, 0x72, 0x73, - 0x68, 0x69, 0x66, 0x74, 0x2c, 0x0a, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x5d, 0x5d, 0x20, 0x29, 0x0a, 0x0a, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, - 0x2d, 0x2d, 0x20, 0x68, 0x6f, 0x70, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, - 0x62, 0x65, 0x73, 0x74, 0x20, 0x6f, 0x72, 0x20, 0x66, 0x61, 0x69, 0x6c, 0x0a, 0x0a, 0x20, 0x20, - 0x20, 0x20, 0x62, 0x69, 0x74, 0x33, 0x32, 0x20, 0x3d, 0x20, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, - 0x65, 0x28, 0x22, 0x62, 0x69, 0x74, 0x33, 0x32, 0x22, 0x29, 0x0a, 0x0a, 0x65, 0x6e, 0x64, 0x0a, - 0x0a, 0x2d, 0x2d, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x6e, 0x65, 0x65, 0x64, - 0x65, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x67, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x72, - 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x28, 0x22, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x22, 0x29, - 0x20, 0x72, 0x69, 0x67, 0x68, 0x74, 0x0a, 0x0a, 0x64, 0x6f, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, - 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x70, - 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x64, 0x0a, 0x0a, 0x20, - 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x64, - 0x2e, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x20, 0x6c, 0x6f, 0x61, - 0x64, 0x65, 0x64, 0x2e, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x20, 0x3d, 0x20, 0x6c, 0x6f, 0x61, - 0x64, 0x65, 0x64, 0x5b, 0x22, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, 0x6f, 0x72, 0x65, - 0x22, 0x5d, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6e, 0x6f, - 0x74, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x64, 0x2e, 0x6d, 0x69, 0x6d, 0x65, 0x20, 0x20, 0x20, - 0x74, 0x68, 0x65, 0x6e, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x64, 0x2e, 0x6d, 0x69, 0x6d, 0x65, - 0x20, 0x20, 0x20, 0x3d, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x64, 0x5b, 0x22, 0x6d, 0x69, 0x6d, - 0x65, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x22, 0x5d, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x0a, - 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x2d, 0x2d, 0x20, 0x73, 0x6f, 0x20, 0x66, 0x61, 0x72, 0x0a, 0x0a, 0x00 + 0x46, 0x46, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x62, 0x20, 0x3c, 0x3d, 0x20, 0x30, + 0x20, 0x6f, 0x72, 0x20, 0x28, 0x61, 0x20, 0x26, 0x20, 0x30, 0x78, 0x38, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x29, 0x20, 0x3d, 0x3d, 0x20, 0x30, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, 0x61, 0x20, 0x3e, + 0x3e, 0x20, 0x62, 0x29, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, + 0x46, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, 0x28, 0x61, 0x20, 0x3e, 0x3e, 0x20, 0x62, + 0x29, 0x20, 0x7c, 0x20, 0x7e, 0x28, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, + 0x20, 0x3e, 0x3e, 0x20, 0x62, 0x29, 0x29, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, + 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x65, + 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x6c, 0x72, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x20, 0x3d, 0x20, + 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x61, 0x20, 0x2c, 0x62, 0x29, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x62, 0x20, 0x3d, 0x20, 0x62, 0x20, 0x26, 0x20, 0x33, 0x31, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x61, 0x20, 0x3d, 0x20, 0x61, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, + 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x61, 0x20, 0x3d, 0x20, 0x28, 0x61, + 0x20, 0x3c, 0x3c, 0x20, 0x62, 0x29, 0x20, 0x7c, 0x20, 0x28, 0x61, 0x20, 0x3e, 0x3e, 0x20, 0x28, + 0x33, 0x32, 0x20, 0x2d, 0x20, 0x62, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, + 0x75, 0x72, 0x6e, 0x20, 0x61, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, + 0x46, 0x46, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x72, 0x72, 0x6f, 0x74, + 0x61, 0x74, 0x65, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, + 0x61, 0x2c, 0x20, 0x62, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x20, 0x3d, 0x20, 0x2d, 0x62, + 0x20, 0x26, 0x20, 0x33, 0x31, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x61, 0x20, 0x3d, 0x20, 0x61, 0x20, + 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x61, 0x20, 0x3d, 0x20, 0x28, 0x61, 0x20, 0x3c, 0x3c, 0x20, 0x62, 0x29, 0x20, 0x7c, 0x20, + 0x28, 0x61, 0x20, 0x3e, 0x3e, 0x20, 0x28, 0x33, 0x32, 0x20, 0x2d, 0x20, 0x62, 0x29, 0x29, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x61, 0x20, 0x26, 0x20, 0x30, + 0x78, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, + 0x0a, 0x20, 0x20, 0x65, 0x78, 0x74, 0x72, 0x61, 0x63, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x61, 0x2c, 0x20, 0x66, 0x2c, 0x20, 0x77, 0x29, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, 0x61, 0x20, 0x3e, 0x3e, + 0x20, 0x66, 0x29, 0x20, 0x26, 0x20, 0x7e, 0x28, 0x2d, 0x31, 0x20, 0x3c, 0x3c, 0x20, 0x28, 0x77, + 0x20, 0x6f, 0x72, 0x20, 0x31, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x20, + 0x20, 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x61, 0x2c, 0x20, 0x76, 0x2c, 0x20, 0x66, 0x2c, 0x20, 0x77, 0x29, + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x20, + 0x3d, 0x20, 0x7e, 0x28, 0x2d, 0x31, 0x20, 0x3c, 0x3c, 0x20, 0x28, 0x77, 0x20, 0x6f, 0x72, 0x20, + 0x31, 0x29, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x28, + 0x28, 0x61, 0x20, 0x26, 0x20, 0x7e, 0x28, 0x6d, 0x61, 0x73, 0x6b, 0x20, 0x3c, 0x3c, 0x20, 0x66, + 0x29, 0x29, 0x20, 0x7c, 0x20, 0x28, 0x28, 0x76, 0x20, 0x26, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x29, + 0x20, 0x3c, 0x3c, 0x20, 0x66, 0x29, 0x29, 0x20, 0x26, 0x20, 0x30, 0x78, 0x46, 0x46, 0x46, 0x46, + 0x46, 0x46, 0x46, 0x46, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x7d, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5d, 0x5d, 0x20, 0x29, 0x0a, 0x0a, 0x65, 0x6c, 0x73, 0x65, + 0x69, 0x66, 0x20, 0x62, 0x69, 0x74, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x2d, 0x2d, 0x20, 0x6c, 0x75, 0x61, 0x6a, 0x69, 0x74, 0x20, 0x28, 0x66, 0x6f, 0x72, 0x20, + 0x6e, 0x6f, 0x77, 0x29, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x69, 0x74, 0x33, 0x32, 0x20, + 0x3d, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x20, 0x28, 0x20, 0x5b, 0x5b, 0x0a, 0x6c, 0x6f, 0x63, 0x61, + 0x6c, 0x20, 0x62, 0x61, 0x6e, 0x64, 0x2c, 0x20, 0x62, 0x6e, 0x6f, 0x74, 0x2c, 0x20, 0x72, 0x73, + 0x68, 0x69, 0x66, 0x74, 0x2c, 0x20, 0x6c, 0x73, 0x68, 0x69, 0x66, 0x74, 0x20, 0x3d, 0x20, 0x62, + 0x69, 0x74, 0x2e, 0x62, 0x61, 0x6e, 0x64, 0x2c, 0x20, 0x62, 0x69, 0x74, 0x2e, 0x62, 0x6e, 0x6f, + 0x74, 0x2c, 0x20, 0x62, 0x69, 0x74, 0x2e, 0x72, 0x73, 0x68, 0x69, 0x66, 0x74, 0x2c, 0x20, 0x62, + 0x69, 0x74, 0x2e, 0x6c, 0x73, 0x68, 0x69, 0x66, 0x74, 0x0a, 0x0a, 0x62, 0x69, 0x74, 0x33, 0x32, + 0x20, 0x3d, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x61, 0x72, 0x73, 0x68, 0x69, 0x66, 0x74, 0x20, 0x3d, + 0x20, 0x62, 0x69, 0x74, 0x2e, 0x61, 0x72, 0x73, 0x68, 0x69, 0x66, 0x74, 0x2c, 0x0a, 0x20, 0x20, + 0x62, 0x61, 0x6e, 0x64, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x62, 0x61, 0x6e, 0x64, 0x2c, 0x0a, + 0x20, 0x20, 0x62, 0x6e, 0x6f, 0x74, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x62, 0x6e, 0x6f, 0x74, + 0x2c, 0x0a, 0x20, 0x20, 0x62, 0x6f, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x62, 0x69, + 0x74, 0x2e, 0x62, 0x6f, 0x72, 0x2c, 0x0a, 0x20, 0x20, 0x62, 0x78, 0x6f, 0x72, 0x20, 0x20, 0x20, + 0x20, 0x3d, 0x20, 0x62, 0x69, 0x74, 0x2e, 0x62, 0x78, 0x6f, 0x72, 0x2c, 0x0a, 0x20, 0x20, 0x62, + 0x74, 0x65, 0x73, 0x74, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x28, 0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, + 0x6e, 0x20, 0x62, 0x61, 0x6e, 0x64, 0x28, 0x2e, 0x2e, 0x2e, 0x29, 0x20, 0x7e, 0x3d, 0x20, 0x30, + 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x65, 0x78, 0x74, 0x72, 0x61, 0x63, + 0x74, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x61, 0x2c, 0x66, + 0x2c, 0x77, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x62, + 0x61, 0x6e, 0x64, 0x28, 0x72, 0x73, 0x68, 0x69, 0x66, 0x74, 0x28, 0x61, 0x2c, 0x66, 0x29, 0x2c, + 0x32, 0x5e, 0x28, 0x77, 0x20, 0x6f, 0x72, 0x20, 0x31, 0x29, 0x2d, 0x31, 0x29, 0x0a, 0x20, 0x20, + 0x65, 0x6e, 0x64, 0x2c, 0x0a, 0x20, 0x20, 0x6c, 0x72, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x20, 0x3d, + 0x20, 0x62, 0x69, 0x74, 0x2e, 0x72, 0x6f, 0x6c, 0x2c, 0x0a, 0x20, 0x20, 0x6c, 0x73, 0x68, 0x69, + 0x66, 0x74, 0x20, 0x20, 0x3d, 0x20, 0x6c, 0x73, 0x68, 0x69, 0x66, 0x74, 0x2c, 0x0a, 0x20, 0x20, + 0x72, 0x65, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x28, 0x61, 0x2c, 0x76, 0x2c, 0x66, 0x2c, 0x77, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x20, 0x3d, 0x20, 0x32, 0x5e, 0x28, + 0x77, 0x20, 0x6f, 0x72, 0x20, 0x31, 0x29, 0x2d, 0x31, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, + 0x74, 0x75, 0x72, 0x6e, 0x20, 0x62, 0x61, 0x6e, 0x64, 0x28, 0x61, 0x2c, 0x62, 0x6e, 0x6f, 0x74, + 0x28, 0x6c, 0x73, 0x68, 0x69, 0x66, 0x74, 0x28, 0x6d, 0x61, 0x73, 0x6b, 0x2c, 0x66, 0x29, 0x29, + 0x29, 0x2b, 0x6c, 0x73, 0x68, 0x69, 0x66, 0x74, 0x28, 0x62, 0x61, 0x6e, 0x64, 0x28, 0x76, 0x2c, + 0x6d, 0x61, 0x73, 0x6b, 0x29, 0x2c, 0x66, 0x29, 0x0a, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x2c, 0x0a, + 0x20, 0x20, 0x72, 0x72, 0x6f, 0x74, 0x61, 0x74, 0x65, 0x20, 0x3d, 0x20, 0x62, 0x69, 0x74, 0x2e, + 0x72, 0x6f, 0x72, 0x2c, 0x0a, 0x20, 0x20, 0x72, 0x73, 0x68, 0x69, 0x66, 0x74, 0x20, 0x20, 0x3d, + 0x20, 0x72, 0x73, 0x68, 0x69, 0x66, 0x74, 0x2c, 0x0a, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x5d, 0x5d, 0x20, 0x29, 0x0a, 0x0a, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x68, 0x6f, 0x70, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x74, + 0x68, 0x65, 0x20, 0x62, 0x65, 0x73, 0x74, 0x20, 0x6f, 0x72, 0x20, 0x66, 0x61, 0x69, 0x6c, 0x0a, + 0x0a, 0x20, 0x20, 0x20, 0x20, 0x62, 0x69, 0x74, 0x33, 0x32, 0x20, 0x3d, 0x20, 0x72, 0x65, 0x71, + 0x75, 0x69, 0x72, 0x65, 0x28, 0x22, 0x62, 0x69, 0x74, 0x33, 0x32, 0x22, 0x29, 0x0a, 0x0a, 0x65, + 0x6e, 0x64, 0x0a, 0x0a, 0x2d, 0x2d, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x6e, + 0x65, 0x65, 0x64, 0x65, 0x64, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x67, 0x65, 0x74, 0x74, 0x69, 0x6e, + 0x67, 0x20, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x28, 0x22, 0x73, 0x6f, 0x63, 0x6b, 0x65, + 0x74, 0x22, 0x29, 0x20, 0x72, 0x69, 0x67, 0x68, 0x74, 0x0a, 0x0a, 0x64, 0x6f, 0x0a, 0x0a, 0x20, + 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x64, 0x20, + 0x3d, 0x20, 0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x2e, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x64, + 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6c, 0x6f, 0x61, + 0x64, 0x65, 0x64, 0x2e, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x20, + 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x64, 0x2e, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x20, 0x3d, 0x20, + 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x64, 0x5b, 0x22, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x63, + 0x6f, 0x72, 0x65, 0x22, 0x5d, 0x20, 0x65, 0x6e, 0x64, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, + 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x64, 0x2e, 0x6d, 0x69, 0x6d, 0x65, + 0x20, 0x20, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x64, 0x2e, 0x6d, + 0x69, 0x6d, 0x65, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x6c, 0x6f, 0x61, 0x64, 0x65, 0x64, 0x5b, 0x22, + 0x6d, 0x69, 0x6d, 0x65, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x22, 0x5d, 0x20, 0x20, 0x20, 0x65, 0x6e, + 0x64, 0x0a, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x64, 0x6f, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, + 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6c, 0x66, 0x73, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, + 0x74, 0x65, 0x73, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3d, 0x20, 0x6c, 0x66, 0x73, 0x2e, 0x61, 0x74, + 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, + 0x61, 0x6c, 0x20, 0x73, 0x79, 0x6d, 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, + 0x75, 0x74, 0x65, 0x73, 0x20, 0x3d, 0x20, 0x6c, 0x66, 0x73, 0x2e, 0x73, 0x79, 0x6d, 0x6c, 0x69, + 0x6e, 0x6b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x0a, 0x0a, 0x20, 0x20, + 0x20, 0x20, 0x2d, 0x2d, 0x20, 0x74, 0x68, 0x65, 0x73, 0x65, 0x20, 0x63, 0x61, 0x6e, 0x20, 0x6e, + 0x6f, 0x77, 0x20, 0x62, 0x65, 0x20, 0x64, 0x6f, 0x6e, 0x65, 0x20, 0x75, 0x73, 0x69, 0x6e, 0x67, + 0x20, 0x6c, 0x66, 0x73, 0x20, 0x28, 0x77, 0x61, 0x73, 0x20, 0x64, 0x65, 0x61, 0x64, 0x20, 0x73, + 0x6c, 0x6f, 0x77, 0x20, 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x29, 0x0a, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6c, 0x66, 0x73, 0x2e, 0x69, 0x73, 0x66, 0x69, + 0x6c, 0x65, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x66, 0x73, 0x2e, 0x69, 0x73, 0x66, + 0x69, 0x6c, 0x65, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6d, 0x20, 0x3d, 0x20, + 0x6c, 0x66, 0x73, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x28, 0x6e, 0x61, + 0x6d, 0x65, 0x2c, 0x22, 0x6d, 0x6f, 0x64, 0x65, 0x22, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6d, 0x20, + 0x3d, 0x3d, 0x20, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x22, 0x20, 0x6f, 0x72, 0x20, 0x6d, 0x20, 0x3d, + 0x3d, 0x20, 0x22, 0x6c, 0x69, 0x6e, 0x6b, 0x22, 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, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6c, 0x66, 0x73, 0x2e, 0x69, 0x73, 0x64, + 0x69, 0x72, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x66, 0x73, 0x2e, 0x69, 0x73, 0x64, + 0x69, 0x72, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6d, 0x20, 0x3d, 0x20, 0x6c, + 0x66, 0x73, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x28, 0x6e, 0x61, 0x6d, + 0x65, 0x2c, 0x22, 0x6d, 0x6f, 0x64, 0x65, 0x22, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6d, 0x20, 0x3d, + 0x3d, 0x20, 0x22, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x22, 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, 0x2d, 0x2d, 0x20, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x6e, + 0x61, 0x6d, 0x65, 0x73, 0x20, 0x68, 0x61, 0x76, 0x65, 0x20, 0x61, 0x6c, 0x73, 0x6f, 0x20, 0x62, + 0x65, 0x20, 0x73, 0x6f, 0x72, 0x74, 0x20, 0x6f, 0x66, 0x20, 0x64, 0x72, 0x6f, 0x70, 0x70, 0x65, + 0x64, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x6b, 0x70, 0x73, 0x65, 0x0a, 0x0a, 0x20, 0x20, 0x20, + 0x20, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x6c, 0x66, 0x73, 0x2e, 0x73, 0x68, 0x6f, 0x72, + 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x66, 0x73, 0x2e, + 0x73, 0x68, 0x6f, 0x72, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x0a, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, + 0x72, 0x6e, 0x20, 0x6e, 0x61, 0x6d, 0x65, 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, 0x2d, 0x2d, 0x20, 0x6e, 0x6f, 0x77, 0x20, 0x74, 0x68, 0x65, 0x72, 0x65, 0x20, 0x69, 0x73, + 0x20, 0x61, 0x20, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x20, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x2c, + 0x20, 0x73, 0x6f, 0x20, 0x2e, 0x2e, 0x2e, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, + 0x6e, 0x6f, 0x74, 0x20, 0x6c, 0x66, 0x73, 0x2e, 0x72, 0x65, 0x61, 0x64, 0x6c, 0x69, 0x6e, 0x6b, + 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x75, + 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x66, 0x73, 0x2e, 0x72, 0x65, 0x61, 0x64, 0x6c, + 0x69, 0x6e, 0x6b, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x73, 0x79, 0x6d, + 0x6c, 0x69, 0x6e, 0x6b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x28, 0x6e, + 0x61, 0x6d, 0x65, 0x2c, 0x22, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0x29, 0x20, 0x6f, 0x72, + 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, 0x0a, 0x65, 0x6e, 0x64, 0x0a, 0x0a, 0x2d, + 0x2d, 0x20, 0x73, 0x6f, 0x20, 0x66, 0x61, 0x72, 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 35005d1c885..f2d55fd99b3 100644 --- a/Build/source/texk/web2c/luatexdir/lua/luatex-core.lua +++ b/Build/source/texk/web2c/luatexdir/lua/luatex-core.lua @@ -1,419 +1,465 @@ --- luatex-core security and io overloads ........... - --- if not modules then modules = { } end modules ['luatex-core'] = { --- version = 1.005, --- comment = 'companion to luatex', --- author = 'Hans Hagen & Luigi Scarso', --- copyright = 'LuaTeX Development Team', --- } - -LUATEXCOREVERSION = 1.005 - --- 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 - --- For some reason the gc doesn't kick in so we need to close explitly --- so that the handle is flushed. - -local error, type = error, type - -local function luatex_io_lines(name,how) - if type(name) == "string" then - local f = io_open(name,how or 'r') - if f then - return function() - local l = fio_readline(f) - if not l then - f:close() - end - return l - end - else - -- for those who like it this way: - error("patched 'io.lines' can't open '" .. name .. "'") - 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 - --- compatibility: this might go away - -if not unpack then - unpack = table.unpack -end - -if not package.loaders then - package.loaders = package.searchers -end - -if not loadstring then - loadstring = load -end - --- compatibility: this might stay - -if bit32 then - - -- lua 5.2: we're okay - -elseif utf8 then - - -- lua 5.3: bitwise.lua, v 1.24 2014/12/26 17:20:53 roberto - - bit32 = load ( [[ -local select = select -- instead of: arg = { ... } - -bit32 = { - bnot = function (a) - return ~a & 0xFFFFFFFF - end, - band = function (x, y, z, ...) - if not z then - return ((x or -1) & (y or -1)) & 0xFFFFFFFF - else - local res = x & y & z - for i=1,select("#",...) do - res = res & select(i,...) - end - return res & 0xFFFFFFFF - end - end, - bor = function (x, y, z, ...) - if not z then - return ((x or 0) | (y or 0)) & 0xFFFFFFFF - else - local res = x | y | z - for i=1,select("#",...) do - res = res | select(i,...) - end - return res & 0xFFFFFFFF - end - end, - bxor = function (x, y, z, ...) - if not z then - return ((x or 0) ~ (y or 0)) & 0xFFFFFFFF - else - local res = x ~ y ~ z - for i=1,select("#",...) do - res = res ~ select(i,...) - end - return res & 0xFFFFFFFF - end - end, - btest = function (x, y, z, ...) - if not z then - return (((x or -1) & (y or -1)) & 0xFFFFFFFF) ~= 0 - else - local res = x & y & z - for i=1,select("#",...) do - res = res & select(i,...) - end - return (res & 0xFFFFFFFF) ~= 0 - end - end, - lshift = function (a, b) - return ((a & 0xFFFFFFFF) << b) & 0xFFFFFFFF - end, - rshift = function (a, b) - return ((a & 0xFFFFFFFF) >> b) & 0xFFFFFFFF - end, - arshift = function (a, b) - a = a & 0xFFFFFFFF - if b <= 0 or (a & 0x80000000) == 0 then - return (a >> b) & 0xFFFFFFFF - else - return ((a >> b) | ~(0xFFFFFFFF >> b)) & 0xFFFFFFFF - end - end, - lrotate = function (a ,b) - b = b & 31 - a = a & 0xFFFFFFFF - a = (a << b) | (a >> (32 - b)) - return a & 0xFFFFFFFF - end, - rrotate = function (a, b) - b = -b & 31 - a = a & 0xFFFFFFFF - a = (a << b) | (a >> (32 - b)) - return a & 0xFFFFFFFF - end, - extract = function (a, f, w) - return (a >> f) & ~(-1 << (w or 1)) - end, - replace = function (a, v, f, w) - local mask = ~(-1 << (w or 1)) - return ((a & ~(mask << f)) | ((v & mask) << f)) & 0xFFFFFFFF - end, -} - ]] ) - -elseif bit then - - -- luajit (for now) - - bit32 = load ( [[ -local band, bnot, rshift, lshift = bit.band, bit.bnot, bit.rshift, bit.lshift - -bit32 = { - arshift = bit.arshift, - band = band, - bnot = bnot, - bor = bit.bor, - bxor = bit.bxor, - btest = function(...) - return band(...) ~= 0 - end, - extract = function(a,f,w) - return band(rshift(a,f),2^(w or 1)-1) - end, - lrotate = bit.rol, - lshift = lshift, - replace = function(a,v,f,w) - local mask = 2^(w or 1)-1 - return band(a,bnot(lshift(mask,f)))+lshift(band(v,mask),f) - end, - rrotate = bit.ror, - rshift = rshift, -} - ]] ) - -else - - -- hope for the best or fail - - bit32 = require("bit32") - -end - --- this is needed for getting require("socket") right - -do - - local loaded = package.loaded - - if not loaded.socket then loaded.socket = loaded["socket.core"] end - if not loaded.mime then loaded.mime = loaded["mime.core"] end - -end - --- so far - -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 +-- luatex-core security and io overloads ...........
+
+-- if not modules then modules = { } end modules ['luatex-core'] = {
+-- version = 1.080,
+-- comment = 'companion to luatex',
+-- author = 'Hans Hagen & Luigi Scarso',
+-- copyright = 'LuaTeX Development Team',
+-- }
+
+LUATEXCOREVERSION = 1.080 -- we reflect the luatex version where changes happened
+
+-- 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.
+
+-- We test for functions already being defined so that we don't overload ones that
+-- are provided in the startup script.
+
+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
+
+-- For some reason the gc doesn't kick in so we need to close explitly
+-- so that the handle is flushed.
+
+local error, type = error, type
+
+local function luatex_io_lines(name,how)
+ if type(name) == "string" then
+ local f = io_open(name,how or 'r')
+ if f then
+ return function()
+ local l = fio_readline(f)
+ if not l then
+ f:close()
+ end
+ return l
+ end
+ else
+ -- for those who like it this way:
+ error("patched 'io.lines' can't open '" .. name .. "'")
+ 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
+
+ if not md5.sumhexa then
+ function md5.sumhexa(k)
+ return (gsub(sum(k), ".", function(c)
+ return format("%02x",byte(c))
+ end))
+ end
+ end
+
+ if not md5.sumHEXA then
+ function md5.sumHEXA(k)
+ return (gsub(sum(k), ".", function(c)
+ return format("%02X",byte(c))
+ end))
+ end
+ end
+
+end
+
+-- compatibility: this might go away
+
+if not unpack then
+ unpack = table.unpack
+end
+
+if not package.loaders then
+ package.loaders = package.searchers
+end
+
+if not loadstring then
+ loadstring = load
+end
+
+-- compatibility: this might stay
+
+if bit32 then
+
+ -- lua 5.2: we're okay
+
+elseif utf8 then
+
+ -- lua 5.3: bitwise.lua, v 1.24 2014/12/26 17:20:53 roberto
+
+ bit32 = load ( [[
+local select = select -- instead of: arg = { ... }
+
+bit32 = {
+ bnot = function (a)
+ return ~a & 0xFFFFFFFF
+ end,
+ band = function (x, y, z, ...)
+ if not z then
+ return ((x or -1) & (y or -1)) & 0xFFFFFFFF
+ else
+ local res = x & y & z
+ for i=1,select("#",...) do
+ res = res & select(i,...)
+ end
+ return res & 0xFFFFFFFF
+ end
+ end,
+ bor = function (x, y, z, ...)
+ if not z then
+ return ((x or 0) | (y or 0)) & 0xFFFFFFFF
+ else
+ local res = x | y | z
+ for i=1,select("#",...) do
+ res = res | select(i,...)
+ end
+ return res & 0xFFFFFFFF
+ end
+ end,
+ bxor = function (x, y, z, ...)
+ if not z then
+ return ((x or 0) ~ (y or 0)) & 0xFFFFFFFF
+ else
+ local res = x ~ y ~ z
+ for i=1,select("#",...) do
+ res = res ~ select(i,...)
+ end
+ return res & 0xFFFFFFFF
+ end
+ end,
+ btest = function (x, y, z, ...)
+ if not z then
+ return (((x or -1) & (y or -1)) & 0xFFFFFFFF) ~= 0
+ else
+ local res = x & y & z
+ for i=1,select("#",...) do
+ res = res & select(i,...)
+ end
+ return (res & 0xFFFFFFFF) ~= 0
+ end
+ end,
+ lshift = function (a, b)
+ return ((a & 0xFFFFFFFF) << b) & 0xFFFFFFFF
+ end,
+ rshift = function (a, b)
+ return ((a & 0xFFFFFFFF) >> b) & 0xFFFFFFFF
+ end,
+ arshift = function (a, b)
+ a = a & 0xFFFFFFFF
+ if b <= 0 or (a & 0x80000000) == 0 then
+ return (a >> b) & 0xFFFFFFFF
+ else
+ return ((a >> b) | ~(0xFFFFFFFF >> b)) & 0xFFFFFFFF
+ end
+ end,
+ lrotate = function (a ,b)
+ b = b & 31
+ a = a & 0xFFFFFFFF
+ a = (a << b) | (a >> (32 - b))
+ return a & 0xFFFFFFFF
+ end,
+ rrotate = function (a, b)
+ b = -b & 31
+ a = a & 0xFFFFFFFF
+ a = (a << b) | (a >> (32 - b))
+ return a & 0xFFFFFFFF
+ end,
+ extract = function (a, f, w)
+ return (a >> f) & ~(-1 << (w or 1))
+ end,
+ replace = function (a, v, f, w)
+ local mask = ~(-1 << (w or 1))
+ return ((a & ~(mask << f)) | ((v & mask) << f)) & 0xFFFFFFFF
+ end,
+}
+ ]] )
+
+elseif bit then
+
+ -- luajit (for now)
+
+ bit32 = load ( [[
+local band, bnot, rshift, lshift = bit.band, bit.bnot, bit.rshift, bit.lshift
+
+bit32 = {
+ arshift = bit.arshift,
+ band = band,
+ bnot = bnot,
+ bor = bit.bor,
+ bxor = bit.bxor,
+ btest = function(...)
+ return band(...) ~= 0
+ end,
+ extract = function(a,f,w)
+ return band(rshift(a,f),2^(w or 1)-1)
+ end,
+ lrotate = bit.rol,
+ lshift = lshift,
+ replace = function(a,v,f,w)
+ local mask = 2^(w or 1)-1
+ return band(a,bnot(lshift(mask,f)))+lshift(band(v,mask),f)
+ end,
+ rrotate = bit.ror,
+ rshift = rshift,
+}
+ ]] )
+
+else
+
+ -- hope for the best or fail
+
+ bit32 = require("bit32")
+
+end
+
+-- this is needed for getting require("socket") right
+
+do
+
+ local loaded = package.loaded
+
+ if not loaded.socket then loaded.socket = loaded["socket.core"] end
+ if not loaded.mime then loaded.mime = loaded["mime.core"] end
+
+end
+
+do
+
+ local lfsattributes = lfs.attributes
+ local symlinkattributes = lfs.symlinkattributes
+
+ -- these can now be done using lfs (was dead slow before)
+
+ if not lfs.isfile then
+ function lfs.isfile(name)
+ local m = lfsattributes(name,"mode")
+ return m == "file" or m == "link"
+ end
+ end
+
+ if not lfs.isdir then
+ function lfs.isdir(name)
+ local m = lfsattributes(name,"mode")
+ return m == "directory"
+ end
+ end
+
+ -- shortnames have also be sort of dropped from kpse
+
+ if not lfs.shortname then
+ function lfs.shortname(name)
+ return name
+ end
+ end
+
+ -- now there is a target field, so ...
+
+ if not lfs.readlink then
+ function lfs.readlink(name)
+ return symlinkattributes(name,"target") or nil
+ end
+ end
+
+end
+
+-- so far
+
+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/luafontloader/fontforge/fontforge/parsepfa.c b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsepfa.c index 1cff6a4858a..df369b45e6f 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsepfa.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/fontforge/fontforge/parsepfa.c @@ -2667,9 +2667,9 @@ static void FontInfoFree(struct fontinfo *fi) { void PSFontFree(FontDict *fd) { int i; - if ( fd->encoding!=NULL ) - for ( i=0; i<256; ++i ) - free( fd->encoding[i]); + /*if ( fd->encoding!=NULL ): useless: fd->encoding is *char[256] */ + for ( i=0; i<256; ++i ) + free( fd->encoding[i]); free(fd->fontname); free(fd->cidfontname); free(fd->registry); diff --git a/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c b/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c index 8717fe8e39d..434413b0054 100644 --- a/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c +++ b/Build/source/texk/web2c/luatexdir/luafontloader/src/luafflib.c @@ -358,7 +358,7 @@ static void dump_intfield(lua_State * L, const char *name, long int field) { lua_checkstack(L, 2); lua_pushstring(L, name); - lua_pushnumber(L, field); + lua_pushinteger(L, field); lua_rawset(L, -3); } @@ -366,7 +366,7 @@ static void dump_uintfield(lua_State * L, const char *name, unsigned int field) { lua_checkstack(L, 2); lua_pushstring(L, name); - lua_pushnumber(L, field); + lua_pushinteger(L, field); lua_rawset(L, -3); } @@ -465,7 +465,7 @@ static void dump_subtable_name(lua_State * L, const char *name, struct lookup_su next = b; \ while (next != NULL) { \ lua_checkstack(L,2); \ - lua_pushnumber(L,k); k++; \ + lua_pushinteger(L,k); k++; \ lua_createtable(L,0,c); \ a(L, next); \ lua_rawset(L,-3); \ @@ -478,7 +478,7 @@ static void dump_subtable_name(lua_State * L, const char *name, struct lookup_su next = b; \ while (next != NULL) { \ lua_checkstack(L,2); \ - lua_pushnumber(L,k); k++; \ + lua_pushinteger(L,k); k++; \ lua_createtable(L,0,d); \ if (a(L, next, c)) \ lua_rawset(L,-3); \ @@ -498,7 +498,7 @@ static void do_handle_scriptlanglist(lua_State * L, struct scriptlanglist *sl) lua_newtable(L); for (k = 0; k < MAX_LANG; k++) { if (sl->langs[k] != 0) { - lua_pushnumber(L, (k + 1)); + lua_pushinteger(L, (k + 1)); lua_pushstring(L, make_tag_string(sl->langs[k])); lua_rawset(L, -3); } @@ -506,7 +506,7 @@ static void do_handle_scriptlanglist(lua_State * L, struct scriptlanglist *sl) if (sl->lang_cnt >= MAX_LANG) { for (k = MAX_LANG; k < sl->lang_cnt; k++) { - lua_pushnumber(L, (k + 1)); + lua_pushinteger(L, (k + 1)); lua_pushstring(L, make_tag_string(sl->morelangs[k - MAX_LANG])); lua_rawset(L, -3); } @@ -672,7 +672,7 @@ static void handle_splinecharlist(lua_State * L, struct splinecharlist *scl) lua_checkstack(L, 10); while (next != NULL) { if (next->sc != NULL) { - lua_pushnumber(L, k); + lua_pushinteger(L, k); k++; lua_pushstring(L, next->sc->name); lua_rawset(L, -3); @@ -772,8 +772,8 @@ static void do_handle_generic_pst(lua_State * L, struct generic_pst *pst) } } else if (pst->type == pst_lcaret) { for (k = 0; k < pst->u.lcaret.cnt; k++) { - lua_pushnumber(L, (k + 1)); - lua_pushnumber(L, pst->u.lcaret.carets[k]); + lua_pushinteger(L, (k + 1)); + lua_pushinteger(L, pst->u.lcaret.carets[k]); lua_rawset(L, -3); } } @@ -800,7 +800,7 @@ static void handle_generic_pst(lua_State * L, struct generic_pst *pst) lua_getfield(L, -1, next->subtable->subtable_name); } k = lua_rawlen(L, -1) + 1; - lua_pushnumber(L, k); + lua_pushinteger(L, k); lua_createtable(L, 0, 4); do_handle_generic_pst(L, next); lua_rawset(L, -3); @@ -808,7 +808,7 @@ static void handle_generic_pst(lua_State * L, struct generic_pst *pst) lua_pop(L, 1); /* pop the subtable */ } else { /* Found a pst without subtable, or without subtable name */ - lua_pushnumber(L, l); + lua_pushinteger(L, l); l++; lua_createtable(L, 0, 4); do_handle_generic_pst(L, next); @@ -970,17 +970,17 @@ static void handle_splinechar(lua_State * L, struct splinechar *glyph, int hasvm dump_stringfield(L, "name", glyph->name); dump_intfield(L, "unicode", glyph->unicodeenc); lua_createtable(L, 4, 0); - lua_pushnumber(L, 1); - lua_pushnumber(L, glyph->xmin); + lua_pushinteger(L, 1); + lua_pushinteger(L, glyph->xmin); lua_rawset(L, -3); - lua_pushnumber(L, 2); - lua_pushnumber(L, glyph->ymin); + lua_pushinteger(L, 2); + lua_pushinteger(L, glyph->ymin); lua_rawset(L, -3); - lua_pushnumber(L, 3); - lua_pushnumber(L, glyph->xmax); + lua_pushinteger(L, 3); + lua_pushinteger(L, glyph->xmax); lua_rawset(L, -3); - lua_pushnumber(L, 4); - lua_pushnumber(L, glyph->ymax); + lua_pushinteger(L, 4); + lua_pushinteger(L, glyph->ymax); lua_rawset(L, -3); lua_setfield(L, -2, "boundingbox"); if (hasvmetrics) { @@ -1260,21 +1260,21 @@ static void handle_pfminfo(lua_State * L, struct pfminfo pfm) dump_intfield(L, "os2_breakchar", pfm.os2_breakchar); if (pfm.hascodepages) { lua_newtable(L); - lua_pushnumber(L, pfm.codepages[0]); + lua_pushinteger(L, pfm.codepages[0]); lua_rawseti(L, -2, 1); - lua_pushnumber(L, pfm.codepages[1]); + lua_pushinteger(L, pfm.codepages[1]); lua_rawseti(L, -2, 2); lua_setfield(L, -2, "codepages"); } if (pfm.hasunicoderanges) { lua_newtable(L); - lua_pushnumber(L, pfm.unicoderanges[0]); + lua_pushinteger(L, pfm.unicoderanges[0]); lua_rawseti(L, -2, 1); - lua_pushnumber(L, pfm.unicoderanges[1]); + lua_pushinteger(L, pfm.unicoderanges[1]); lua_rawseti(L, -2, 2); - lua_pushnumber(L, pfm.unicoderanges[2]); + lua_pushinteger(L, pfm.unicoderanges[2]); lua_rawseti(L, -2, 3); - lua_pushnumber(L, pfm.unicoderanges[3]); + lua_pushinteger(L, pfm.unicoderanges[3]); lua_rawseti(L, -2, 4); lua_setfield(L, -2, "unicoderanges"); } @@ -1292,8 +1292,8 @@ static char *do_handle_enc(lua_State * L, struct enc *enc) if (enc->char_cnt && enc->unicode != NULL) { lua_createtable(L, enc->char_cnt, 1); for (i = 0; i < enc->char_cnt; i++) { - lua_pushnumber(L, i); - lua_pushnumber(L, enc->unicode[i]); + lua_pushinteger(L, i); + lua_pushinteger(L, enc->unicode[i]); lua_rawset(L, -3); } lua_setfield(L, -2, "unicode"); @@ -1302,7 +1302,7 @@ static char *do_handle_enc(lua_State * L, struct enc *enc) if (enc->char_cnt && enc->psnames != NULL) { lua_createtable(L, enc->char_cnt, 1); for (i = 0; i < enc->char_cnt; i++) { - lua_pushnumber(L, i); + lua_pushinteger(L, i); lua_pushstring(L, enc->psnames[i]); lua_rawset(L, -3); } @@ -1363,13 +1363,13 @@ static void handle_encmap(lua_State * L, struct encmap *map, int notdef_loc) for (i = 0; i < map->encmax; i++) { if (map->map[i] != -1) { int l = map->map[i]; - lua_pushnumber(L, i); + lua_pushinteger(L, i); /* if (l < notdef_loc) - lua_pushnumber(L, (l + 1)); + lua_pushinteger(L, (l + 1)); else */ - lua_pushnumber(L, l); + lua_pushinteger(L, l); lua_rawset(L, -3); } } @@ -1382,11 +1382,11 @@ static void handle_encmap(lua_State * L, struct encmap *map, int notdef_loc) if (map->backmap[i] != -1) { /* if (i < notdef_loc) - lua_pushnumber(L, (i + 1)); + lua_pushinteger(L, (i + 1)); else */ - lua_pushnumber(L, i); - lua_pushnumber(L, map->backmap[i]); + lua_pushinteger(L, i); + lua_pushinteger(L, map->backmap[i]); lua_rawset(L, -3); } } @@ -1488,7 +1488,7 @@ static int do_handle_kernclass(lua_State * L, struct kernclass *kerns, const cha lua_checkstack(L, 4); lua_createtable(L, kerns->first_cnt, 1); for (k = 0; k < kerns->first_cnt; k++) { - lua_pushnumber(L, (k + 1)); + lua_pushinteger(L, (k + 1)); lua_pushstring(L, kerns->firsts[k]); lua_rawset(L, -3); } @@ -1496,7 +1496,7 @@ static int do_handle_kernclass(lua_State * L, struct kernclass *kerns, const cha lua_createtable(L, kerns->second_cnt, 1); for (k = 0; k < kerns->second_cnt; k++) { - lua_pushnumber(L, (k + 1)); + lua_pushinteger(L, (k + 1)); lua_pushstring(L, kerns->seconds[k]); lua_rawset(L, -3); } @@ -1508,8 +1508,8 @@ static int do_handle_kernclass(lua_State * L, struct kernclass *kerns, const cha lua_createtable(L, kerns->second_cnt * kerns->first_cnt, 1); for (k = 0; k < (kerns->second_cnt * kerns->first_cnt); k++) { if (kerns->offsets[k] != 0) { - lua_pushnumber(L, (k + 1)); - lua_pushnumber(L, kerns->offsets[k]); + lua_pushinteger(L, (k + 1)); + lua_pushinteger(L, kerns->offsets[k]); lua_rawset(L, -3); } } @@ -1529,8 +1529,8 @@ static void handle_kernclass(lua_State * L, struct kernclass *kerns, const char int kk; \ lua_newtable(L); \ for (kk=0;kk<cnt;kk++) { \ - lua_pushnumber(L,(kk+1)); \ - lua_pushnumber(L,item[kk]); \ + lua_pushinteger(L,(kk+1)); \ + lua_pushinteger(L,item[kk]); \ lua_rawset(L,-3); } \ lua_setfield(L,-2,s); } } @@ -1540,7 +1540,7 @@ static void handle_kernclass(lua_State * L, struct kernclass *kerns, const char int kk; \ lua_newtable(L); \ for (kk=0;kk<cnt;kk++) { \ - lua_pushnumber(L,(kk+1)); \ + lua_pushinteger(L,(kk+1)); \ lua_pushstring(L,item[kk]); \ lua_rawset(L,-3); } \ lua_setfield(L,-2,s); } } @@ -1550,7 +1550,7 @@ static void handle_kernclass(lua_State * L, struct kernclass *kerns, const char int kk; \ lua_newtable(L); \ for (kk=0;kk<cnt;kk++) { \ - lua_pushnumber(L,(kk)); \ + lua_pushinteger(L,(kk)); \ lua_pushstring(L,item[kk]); \ lua_rawset(L,-3); } \ lua_setfield(L,-2,s); } } @@ -1609,7 +1609,7 @@ static void handle_fpst_rule(lua_State * L, struct fpst_rule *rule, int format) if (rule->lookup_cnt > 0) { lua_newtable(L); for (k = 0; k < rule->lookup_cnt; k++) { - lua_pushnumber(L, (rule->lookups[k].seq + 1)); + lua_pushinteger(L, (rule->lookups[k].seq + 1)); if (rule->lookups[k].lookup != NULL) { lua_pushstring(L, rule->lookups[k].lookup->lookup_name); } else { @@ -1650,7 +1650,7 @@ static void do_handle_generic_fpst(lua_State * L, struct generic_fpst *fpst) if (fpst->rule_cnt > 0) { lua_createtable(L, fpst->rule_cnt, 1); for (k = 0; k < fpst->rule_cnt; k++) { - lua_pushnumber(L, (k + 1)); + lua_pushinteger(L, (k + 1)); lua_newtable(L); handle_fpst_rule(L, &(fpst->rules[k]), fpst->format); lua_rawset(L, -3); @@ -1668,7 +1668,7 @@ static void handle_generic_fpst(lua_State * L, struct generic_fpst *fpst) if (fpst->subtable != NULL && fpst->subtable->subtable_name != NULL) { lua_pushstring(L, fpst->subtable->subtable_name); } else { - lua_pushnumber(L, k); + lua_pushinteger(L, k); k++; } lua_createtable(L, 0, 10); @@ -1680,7 +1680,7 @@ static void handle_generic_fpst(lua_State * L, struct generic_fpst *fpst) if (next->subtable != NULL && next->subtable->subtable_name != NULL) { lua_pushstring(L, next->subtable->subtable_name); } else { - lua_pushnumber(L, k); + lua_pushinteger(L, k); k++; } lua_createtable(L, 0, 10); @@ -1801,9 +1801,9 @@ static void handle_base(lua_State * L, struct Base *Base) lua_newtable(L); for (i = 0; i < Base->baseline_cnt; i++) { if (next->baseline_pos != NULL) /* default omitted */ - lua_pushnumber(L, next->baseline_pos[i]); + lua_pushinteger(L, next->baseline_pos[i]); else - lua_pushnumber(L, 0); + lua_pushinteger(L, 0); lua_rawseti(L, -2, (i + 1)); } lua_setfield(L, -2, "baseline"); @@ -1823,13 +1823,13 @@ static void handle_axismap(lua_State * L, struct axismap *am) lua_checkstack(L, 3); lua_newtable(L); for (i = 0; i < am->points; i++) { - lua_pushnumber(L, am->blends[i]); + lua_pushinteger(L, am->blends[i]); lua_rawseti(L, -2, (i + 1)); } lua_setfield(L, -2, "blends"); lua_newtable(L); for (i = 0; i < am->points; i++) { - lua_pushnumber(L, am->designs[i]); + lua_pushinteger(L, am->designs[i]); lua_rawseti(L, -2, (i + 1)); } lua_setfield(L, -2, "designs"); @@ -1853,7 +1853,7 @@ static void handle_mmset(lua_State * L, struct mmset *mm) if (mm->instance_count > 0) { lua_newtable(L); for (i = 0; i < mm->instance_count * mm->axis_count; i++) { - lua_pushnumber(L, mm->positions[i]); + lua_pushinteger(L, mm->positions[i]); lua_rawseti(L, -2, (i + 1)); } lua_setfield(L, -2, "positions"); @@ -1878,7 +1878,7 @@ static void handle_mmset(lua_State * L, struct mmset *mm) lua_newtable(L); for (i = 0; i < mm->instance_count; i++) { - lua_pushnumber(L, mm->defweights[i]); + lua_pushinteger(L, mm->defweights[i]); lua_rawseti(L, -2, (i + 1)); } lua_setfield(L, -2, "defweights"); @@ -1980,14 +1980,14 @@ static void handle_splinefont(lua_State * L, struct splinefont *sf) } for (k = 0; k < l; k++) { if (sf->glyphs[k]) { - lua_pushnumber(L, (k + 1)); + lua_pushinteger(L, (k + 1)); lua_createtable(L, 0, 12); handle_splinechar(L, sf->glyphs[k], sf->hasvmetrics); lua_rawset(L, -3); } } if (sf->glyphs != NULL && l < sf->glyphcnt) { - lua_pushnumber(L, 0); + lua_pushinteger(L, 0); if (sf->glyphs[l]) { lua_createtable(L, 0, 12); handle_splinechar(L, sf->glyphs[l], sf->hasvmetrics); @@ -2000,7 +2000,7 @@ static void handle_splinefont(lua_State * L, struct splinefont *sf) if ((l + 1) < sf->glyphcnt) { for (k = (l + 1); k < sf->glyphcnt; k++) { if (sf->glyphs[k]) { - lua_pushnumber(L, k); + lua_pushinteger(L, k); lua_createtable(L, 0, 12); handle_splinechar(L, sf->glyphs[k], sf->hasvmetrics); lua_rawset(L, -3); @@ -2098,8 +2098,8 @@ static void handle_splinefont(lua_State * L, struct splinefont *sf) dump_enumfield(L, "type", sf->texdata.type, tex_type_enum); lua_newtable(L); for (k = 0; k < 22; k++) { - lua_pushnumber(L, k); - lua_pushnumber(L, sf->texdata.params[k]); + lua_pushinteger(L, k); + lua_pushinteger(L, sf->texdata.params[k]); lua_rawset(L, -3); } lua_setfield(L, -2, "params"); @@ -2590,7 +2590,7 @@ static int ff_glyph_index(lua_State * L) lua_pushstring(L, glyph->name); break; case GK_unicode: - lua_pushnumber(L, glyph->unicodeenc); + lua_pushinteger(L, glyph->unicodeenc); break; case GK_boundingbox: if (glyph->xmax == 0 && glyph->ymax == 0 && glyph->xmin == 0 && glyph->ymin == 0) { @@ -2602,27 +2602,27 @@ static int ff_glyph_index(lua_State * L) glyph->ymax = bb.maxy; } lua_createtable(L, 4, 0); - lua_pushnumber(L, 1); - lua_pushnumber(L, glyph->xmin); + lua_pushinteger(L, 1); + lua_pushinteger(L, glyph->xmin); lua_rawset(L, -3); - lua_pushnumber(L, 2); - lua_pushnumber(L, glyph->ymin); + lua_pushinteger(L, 2); + lua_pushinteger(L, glyph->ymin); lua_rawset(L, -3); - lua_pushnumber(L, 3); - lua_pushnumber(L, glyph->xmax); + lua_pushinteger(L, 3); + lua_pushinteger(L, glyph->xmax); lua_rawset(L, -3); - lua_pushnumber(L, 4); - lua_pushnumber(L, glyph->ymax); + lua_pushinteger(L, 4); + lua_pushinteger(L, glyph->ymax); lua_rawset(L, -3); break; case GK_vwidth: - lua_pushnumber(L, glyph->vwidth); + lua_pushinteger(L, glyph->vwidth); break; case GK_width: - lua_pushnumber(L, glyph->width); + lua_pushinteger(L, glyph->width); break; case GK_lsidebearing: - lua_pushnumber(L, glyph->lsidebearing); + lua_pushinteger(L, glyph->lsidebearing); break; case GK_class: if (glyph->glyph_class > 0) { @@ -2692,31 +2692,31 @@ static int ff_glyph_index(lua_State * L) break; case GK_tex_height: if (glyph->tex_height != TEX_UNDEF) { - lua_pushnumber(L, glyph->tex_height); + lua_pushinteger(L, glyph->tex_height); } else { lua_pushnil(L); } break; case GK_tex_depth: if (glyph->tex_height != TEX_UNDEF) { - lua_pushnumber(L, glyph->tex_depth); + lua_pushinteger(L, glyph->tex_depth); } else { lua_pushnil(L); } break; case GK_is_extended_shape: - lua_pushnumber(L, glyph->is_extended_shape); + lua_pushinteger(L, glyph->is_extended_shape); break; case GK_italic_correction: if (glyph->italic_correction != TEX_UNDEF) { - lua_pushnumber(L, glyph->italic_correction); + lua_pushinteger(L, glyph->italic_correction); } else { lua_pushnil(L); } break; case GK_top_accent: if (glyph->top_accent_horiz != TEX_UNDEF) { - lua_pushnumber(L, glyph->top_accent_horiz); + lua_pushinteger(L, glyph->top_accent_horiz); } else { lua_pushnil(L); } @@ -2794,38 +2794,38 @@ static int ff_index(lua_State * L) lua_pushstring(L, sf->version); break; case FK_italicangle: - lua_pushnumber(L, sf->italicangle); + lua_pushinteger(L, sf->italicangle); break; case FK_upos: - lua_pushnumber(L, sf->upos); + lua_pushinteger(L, sf->upos); break; case FK_uwidth: - lua_pushnumber(L, sf->uwidth); + lua_pushinteger(L, sf->uwidth); break; case FK_ascent: - lua_pushnumber(L, sf->ascent); + lua_pushinteger(L, sf->ascent); break; case FK_descent: - lua_pushnumber(L, sf->descent); + lua_pushinteger(L, sf->descent); break; case FK_uniqueid: - lua_pushnumber(L, sf->uniqueid); + lua_pushinteger(L, sf->uniqueid); break; case FK_glyphcnt: if (sf->glyphcnt > 0) { - lua_pushnumber(L, sf->glyphmax - sf->glyphmin + 1); + lua_pushinteger(L, sf->glyphmax - sf->glyphmin + 1); } else { - lua_pushnumber(L, 0); + lua_pushinteger(L, 0); } break; case FK_glyphmax: - lua_pushnumber(L, sf->glyphmax - 1); + lua_pushinteger(L, sf->glyphmax - 1); break; case FK_glyphmin: - lua_pushnumber(L, sf->glyphmin); + lua_pushinteger(L, sf->glyphmin); break; case FK_units_per_em: - lua_pushnumber(L, sf->units_per_em); + lua_pushinteger(L, sf->units_per_em); break; case FK_lookups: if (sf->possub != NULL) { @@ -2844,34 +2844,34 @@ static int ff_index(lua_State * L) lua_setmetatable(L, -2); /* assign the metatable */ break; case FK_hasvmetrics: - lua_pushnumber(L, sf->hasvmetrics); + lua_pushinteger(L, sf->hasvmetrics); break; case FK_onlybitmaps: - lua_pushnumber(L, sf->onlybitmaps); + lua_pushinteger(L, sf->onlybitmaps); break; case FK_serifcheck: - lua_pushnumber(L, sf->serifcheck); + lua_pushinteger(L, sf->serifcheck); break; case FK_isserif: - lua_pushnumber(L, sf->isserif); + lua_pushinteger(L, sf->isserif); break; case FK_issans: - lua_pushnumber(L, sf->issans); + lua_pushinteger(L, sf->issans); break; case FK_encodingchanged: - lua_pushnumber(L, sf->encodingchanged); + lua_pushinteger(L, sf->encodingchanged); break; case FK_strokedfont: - lua_pushnumber(L, sf->strokedfont); + lua_pushinteger(L, sf->strokedfont); break; case FK_use_typo_metrics: - lua_pushnumber(L, sf->use_typo_metrics); + lua_pushinteger(L, sf->use_typo_metrics); break; case FK_weight_width_slope_only: - lua_pushnumber(L, sf->weight_width_slope_only); + lua_pushinteger(L, sf->weight_width_slope_only); break; case FK_head_optimized_for_cleartype: - lua_pushnumber(L, sf->head_optimized_for_cleartype); + lua_pushinteger(L, sf->head_optimized_for_cleartype); break; case FK_uni_interp: lua_pushstring(L, uni_interp_enum[(sf->uni_interp + 1)]); @@ -2967,8 +2967,8 @@ static int ff_index(lua_State * L) dump_enumfield(L, "type", sf->texdata.type, tex_type_enum); lua_newtable(L); for (k = 0; k < 22; k++) { - lua_pushnumber(L, k); - lua_pushnumber(L, sf->texdata.params[k]); + lua_pushinteger(L, k); + lua_pushinteger(L, sf->texdata.params[k]); lua_rawset(L, -3); } lua_setfield(L, -2, "params"); @@ -3028,16 +3028,16 @@ static int ff_index(lua_State * L) lua_pushstring(L, sf->chosenname); break; case FK_macstyle: - lua_pushnumber(L, sf->macstyle); + lua_pushinteger(L, sf->macstyle); break; case FK_fondname: lua_pushstring(L, sf->fondname); break; case FK_design_size: - lua_pushnumber(L, sf->design_size); + lua_pushinteger(L, sf->design_size); break; case FK_fontstyle_id: - lua_pushnumber(L, sf->fontstyle_id); + lua_pushinteger(L, sf->fontstyle_id); break; case FK_fontstyle_name: if (sf->fontstyle_name != NULL) { @@ -3048,13 +3048,13 @@ static int ff_index(lua_State * L) } break; case FK_design_range_bottom: - lua_pushnumber(L, sf->design_range_bottom); + lua_pushinteger(L, sf->design_range_bottom); break; case FK_design_range_top: - lua_pushnumber(L, sf->design_range_top); + lua_pushinteger(L, sf->design_range_top); break; case FK_strokewidth: - lua_pushnumber(L, sf->strokewidth); + lua_pushinteger(L, sf->strokewidth); break; case FK_mark_classes: if (sf->mark_class_cnt > 0) { @@ -3071,16 +3071,16 @@ static int ff_index(lua_State * L) } break; case FK_creationtime: - lua_pushnumber(L, sf->creationtime); + lua_pushinteger(L, sf->creationtime); break; case FK_modificationtime: - lua_pushnumber(L, sf->modificationtime); + lua_pushinteger(L, sf->modificationtime); break; case FK_os2_version: - lua_pushnumber(L, sf->os2_version); + lua_pushinteger(L, sf->os2_version); break; case FK_sfd_version: - lua_pushnumber(L, sf->sfd_version); + lua_pushinteger(L, sf->sfd_version); break; case FK_math: if (sf->MATH != NULL) { @@ -3157,7 +3157,7 @@ static int ff_index(lua_State * L) } break; case FK_extrema_bound: - lua_pushnumber(L, sf->extrema_bound); + lua_pushinteger(L, sf->extrema_bound); break; case FK_notdef_loc: lua_pushinteger(L, notdef_loc(sf)); diff --git a/Build/source/texk/web2c/luatexdir/luamd5/md5lib.c b/Build/source/texk/web2c/luatexdir/luamd5/md5lib.c index 40fd2de386b..dfbc0865a6b 100644 --- a/Build/source/texk/web2c/luatexdir/luamd5/md5lib.c +++ b/Build/source/texk/web2c/luatexdir/luamd5/md5lib.c @@ -5,7 +5,6 @@ * @author Roberto Ierusalimschy */ - #include <stdlib.h> #include <string.h> #include <time.h> @@ -15,22 +14,21 @@ #include "luamd5.h" - /** * Hash function. Returns a hash for a given string. * @param message: arbitrary binary string. * @return A 128-bit hash string. */ + static int lmd5 (lua_State *L) { - char buff[16]; - size_t l; - const char *message = luaL_checklstring(L, 1, &l); - md5(message, l, buff); - lua_pushlstring(L, buff, 16L); - return 1; + char buff[16]; + size_t l; + const char *message = luaL_checklstring(L, 1, &l); + md5(message, l, buff); + lua_pushlstring(L, buff, 16L); + return 1; } - /** * X-Or. Does a bit-a-bit exclusive-or of two strings. * @param s1: arbitrary binary string. @@ -38,78 +36,73 @@ static int lmd5 (lua_State *L) { * @return a binary string with same length as s1 and s2, * where each bit is the exclusive-or of the corresponding bits in s1-s2. */ + static int ex_or (lua_State *L) { - size_t l1, l2; - const char *s1 = luaL_checklstring(L, 1, &l1); - const char *s2 = luaL_checklstring(L, 2, &l2); - luaL_Buffer b; - luaL_argcheck( L, l1 == l2, 2, "lengths must be equal" ); - luaL_buffinit(L, &b); - while (l1--) luaL_addchar(&b, (*s1++)^(*s2++)); - luaL_pushresult(&b); - return 1; + size_t l1, l2; + const char *s1 = luaL_checklstring(L, 1, &l1); + const char *s2 = luaL_checklstring(L, 2, &l2); + luaL_Buffer b; + luaL_argcheck( L, l1 == l2, 2, "lengths must be equal" ); + luaL_buffinit(L, &b); + while (l1--) + luaL_addchar(&b, (*s1++)^(*s2++)); + luaL_pushresult(&b); + return 1; } - static void checkseed (lua_State *L) { - if (lua_isnone(L, 3)) { /* no seed? */ - time_t tm = time(NULL); /* for `random' seed */ - lua_pushlstring(L, (char *)&tm, sizeof(tm)); - } + if (lua_isnone(L, 3)) { /* no seed? */ + time_t tm = time(NULL); /* for `random' seed */ + lua_pushlstring(L, (char *)&tm, sizeof(tm)); + } } - -#define MAXKEY 256 -#define BLOCKSIZE 16 - - +#define MAXKEY 256 +#define BLOCKSIZE 16 static int initblock (lua_State *L, const char *seed, int lseed, char *block) { - size_t lkey; - const char *key = luaL_checklstring(L, 2, &lkey); - if (lkey > MAXKEY) - luaL_error(L, "key too long (> %d)", MAXKEY); - memset(block, 0, BLOCKSIZE); - memcpy(block, seed, lseed); - memcpy(block+BLOCKSIZE, key, lkey); - return (int)lkey+BLOCKSIZE; + size_t lkey; + const char *key = luaL_checklstring(L, 2, &lkey); + if (lkey > MAXKEY) + luaL_error(L, "key too long (> %d)", MAXKEY); + memset(block, 0, BLOCKSIZE); + memcpy(block, seed, lseed); + memcpy(block+BLOCKSIZE, key, lkey); + return (int)lkey+BLOCKSIZE; } - static void codestream (lua_State *L, const char *msg, size_t lmsg, char *block, int lblock) { - luaL_Buffer b; - luaL_buffinit(L, &b); - while (lmsg > 0) { - char code[BLOCKSIZE]; - int i; - md5(block, lblock, code); - for (i=0; i<BLOCKSIZE && lmsg > 0; i++, lmsg--) - code[i] ^= *msg++; - luaL_addlstring(&b, code, i); - memcpy(block, code, i); /* update seed */ - } - luaL_pushresult(&b); + luaL_Buffer b; + luaL_buffinit(L, &b); + while (lmsg > 0) { + char code[BLOCKSIZE]; + int i; + md5(block, lblock, code); + for (i=0; i<BLOCKSIZE && lmsg > 0; i++, lmsg--) + code[i] ^= *msg++; + luaL_addlstring(&b, code, i); + memcpy(block, code, i); /* update seed */ + } + luaL_pushresult(&b); } - static void decodestream (lua_State *L, const char *cypher, size_t lcypher, char *block, int lblock) { - luaL_Buffer b; - luaL_buffinit(L, &b); - while (lcypher > 0) { - char code[BLOCKSIZE]; - int i; - md5(block, lblock, code); /* update seed */ - for (i=0; i<BLOCKSIZE && lcypher > 0; i++, lcypher--) - code[i] ^= *cypher++; - luaL_addlstring(&b, code, i); - memcpy(block, cypher-i, i); - } - luaL_pushresult(&b); + luaL_Buffer b; + luaL_buffinit(L, &b); + while (lcypher > 0) { + char code[BLOCKSIZE]; + int i; + md5(block, lblock, code); /* update seed */ + for (i=0; i<BLOCKSIZE && lcypher > 0; i++, lcypher--) + code[i] ^= *cypher++; + luaL_addlstring(&b, code, i); + memcpy(block, cypher-i, i); + } + luaL_pushresult(&b); } - /** * Encrypts a string. Uses the hash function md5 in CFB (Cipher-feedback * mode). @@ -117,28 +110,29 @@ static void decodestream (lua_State *L, const char *cypher, size_t lcypher, * @param key: arbitrary binary string to be used as a key. * @param [seed]: optional arbitrary binary string to be used as a seed. * if no seed is provided, the function uses the result of -* <code>time()</code> as a seed. +* <code>time()</code> as a seed. * @return The cyphertext (as a binary string). */ + static int crypt (lua_State *L) { - size_t lmsg; - const char *msg = luaL_checklstring(L, 1, &lmsg); - size_t lseed; - const char *seed; - int lblock; - char block[BLOCKSIZE+MAXKEY]; - checkseed(L); - seed = luaL_checklstring(L, 3, &lseed); - if (lseed > BLOCKSIZE) - luaL_error(L, "seed too long (> %d)", BLOCKSIZE); - /* put seed and seed length at the beginning of result */ - block[0] = (char)lseed; - memcpy(block+1, seed, lseed); - lua_pushlstring(L, block, lseed+1); /* to concat with result */ - lblock = initblock(L, seed, lseed, block); - codestream(L, msg, lmsg, block, lblock); - lua_concat(L, 2); - return 1; + size_t lmsg; + const char *msg = luaL_checklstring(L, 1, &lmsg); + size_t lseed; + const char *seed; + int lblock; + char block[BLOCKSIZE+MAXKEY]; + checkseed(L); + seed = luaL_checklstring(L, 3, &lseed); + if (lseed > BLOCKSIZE) + luaL_error(L, "seed too long (> %d)", BLOCKSIZE); + /* put seed and seed length at the beginning of result */ + block[0] = (char)lseed; + memcpy(block+1, seed, lseed); + lua_pushlstring(L, block, lseed+1); /* to concat with result */ + lblock = initblock(L, seed, lseed, block); + codestream(L, msg, lmsg, block, lblock); + lua_concat(L, 2); + return 1; } @@ -151,33 +145,104 @@ static int crypt (lua_State *L) { * @return The plaintext. */ static int decrypt (lua_State *L) { - size_t lcyphertext; - const char *cyphertext = luaL_checklstring(L, 1, &lcyphertext); - size_t lseed = cyphertext[0]; - const char *seed = cyphertext+1; - int lblock; - char block[BLOCKSIZE+MAXKEY]; - luaL_argcheck(L, lcyphertext >= lseed+1 && lseed <= BLOCKSIZE, 1, - "invalid cyphered string"); - cyphertext += lseed+1; - lcyphertext -= lseed+1; - lblock = initblock(L, seed, lseed, block); - decodestream(L, cyphertext, lcyphertext, block, lblock); - return 1; + size_t lcyphertext; + const char *cyphertext = luaL_checklstring(L, 1, &lcyphertext); + size_t lseed = cyphertext[0]; + const char *seed = cyphertext+1; + int lblock; + char block[BLOCKSIZE+MAXKEY]; + luaL_argcheck(L, lcyphertext >= lseed+1 && lseed <= BLOCKSIZE, 1, + "invalid cyphered string"); + cyphertext += lseed+1; + lcyphertext -= lseed+1; + lblock = initblock(L, seed, lseed, block); + decodestream(L, cyphertext, lcyphertext, block, lblock); + return 1; +} + +/* not now .. doesn't compile anyway + +#include "../luapplib/util/utilmd5.h" + +static int pdfelib_md_5(lua_State * L) +{ + if (lua_type(L,1) == LUA_TSTRING) { + uint8_t result[16]; + size_t size = 0; + const char *data = lua_tolstring(L,1,&size); + md5(data,size,result); + lua_pushlstring(L,(const char *)result,16); + return 1; + } + return 0; } +*/ static struct luaL_Reg md5lib[] = { - {"sum", lmd5}, - {"exor", ex_or}, - {"crypt", crypt}, - {"decrypt", decrypt}, - {NULL, NULL} + { "sum", lmd5}, + { "exor", ex_or}, + { "crypt", crypt}, + { "decrypt", decrypt}, + { NULL, NULL} }; +int luaopen_md5(lua_State *L) { + luaL_openlib(L, "md5", md5lib, 0); + return 1; +} + +/* We could use a different file but this is as easy. */ + +#include "../luapplib/util/utilsha.h" + +static int sha2_256(lua_State * L) +{ + if (lua_type(L,1) == LUA_TSTRING) { + uint8_t result[SHA256_DIGEST_LENGTH]; + size_t size = 0; + const char *data = lua_tolstring(L,1,&size); + sha256(data,size,result); + lua_pushlstring(L,(const char *)result,SHA256_DIGEST_LENGTH); + return 1; + } + return 0; +} + +static int sha2_384(lua_State * L) +{ + if (lua_type(L,1) == LUA_TSTRING) { + size_t size = 0; + uint8_t result[SHA384_DIGEST_LENGTH]; + const char *data = lua_tolstring(L,1,&size); + sha384(data,size,result); + lua_pushlstring(L,(const char *)result,SHA384_DIGEST_LENGTH); + return 1; + } + return 0; +} -int luaopen_md5 (lua_State *L) { - luaL_openlib(L, "md5", md5lib, 0); - return 1; +static int sha2_512(lua_State * L) +{ + if (lua_type(L,1) == LUA_TSTRING) { + uint8_t result[SHA512_DIGEST_LENGTH]; + size_t size = 0; + const char *data = lua_tolstring(L,1,&size); + sha512(data,size,result); + lua_pushlstring(L,(const char *)result,SHA512_DIGEST_LENGTH); + return 1; + } + return 0; } +static struct luaL_Reg sha2lib[] = { + { "digest256", sha2_256 }, + { "digest384", sha2_384 }, + { "digest512", sha2_512 }, + { NULL, NULL} +}; + +int luaopen_sha2(lua_State *L) { + luaL_openlib(L, "sha2", sha2lib, 0); + return 1; +} diff --git a/Build/source/texk/web2c/luatexdir/luasocket/src/lua_preload.c b/Build/source/texk/web2c/luatexdir/luasocket/src/lua_preload.c index e9433dfdb12..838871c1d66 100644 --- a/Build/source/texk/web2c/luatexdir/luasocket/src/lua_preload.c +++ b/Build/source/texk/web2c/luatexdir/luasocket/src/lua_preload.c @@ -15,6 +15,7 @@ int luatex_http_lua_open(lua_State*); int luatex_ftp_lua_open(lua_State*); +extern void luatex_socketlua_open (lua_State *) ; #include "ftp_lua.c" #include "headers_lua.c" #include "http_lua.c" diff --git a/Build/source/texk/web2c/luatexdir/luasocket/src/options.c b/Build/source/texk/web2c/luatexdir/luasocket/src/options.c index 20f4c280250..fabfe8ce3e6 100644 --- a/Build/source/texk/web2c/luatexdir/luasocket/src/options.c +++ b/Build/source/texk/web2c/luatexdir/luasocket/src/options.c @@ -37,7 +37,7 @@ int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps) while (opt->name && strcmp(name, opt->name)) opt++; if (!opt->func) { - char msg[45]; + char msg[57]; sprintf(msg, "unsupported option `%.35s'", name); luaL_argerror(L, 2, msg); } @@ -50,7 +50,7 @@ int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps) while (opt->name && strcmp(name, opt->name)) opt++; if (!opt->func) { - char msg[45]; + char msg[57]; sprintf(msg, "unsupported option `%.35s'", name); luaL_argerror(L, 2, msg); } diff --git a/Build/source/texk/web2c/luatexdir/luasocket/src/serial.c b/Build/source/texk/web2c/luatexdir/luasocket/src/serial.c index f121bbf0a61..b666e61f939 100644 --- a/Build/source/texk/web2c/luatexdir/luasocket/src/serial.c +++ b/Build/source/texk/web2c/luatexdir/luasocket/src/serial.c @@ -31,44 +31,44 @@ have only one object type. /*=========================================================================*\ * Internal function prototypes \*=========================================================================*/ -static int global_create(lua_State *L); -static int meth_send(lua_State *L); -static int meth_receive(lua_State *L); -static int meth_close(lua_State *L); -static int meth_settimeout(lua_State *L); -static int meth_getfd(lua_State *L); -static int meth_setfd(lua_State *L); -static int meth_dirty(lua_State *L); -static int meth_getstats(lua_State *L); -static int meth_setstats(lua_State *L); +/*static int global_create(lua_State *L);*/ +/* static int meth_send(lua_State *L); */ +/* static int meth_receive(lua_State *L); */ +/* static int meth_close(lua_State *L); */ +/* static int meth_settimeout(lua_State *L); */ +/* static int meth_getfd(lua_State *L); */ +/* static int meth_setfd(lua_State *L); */ +/* static int meth_dirty(lua_State *L); */ +/* static int meth_getstats(lua_State *L); */ +/* static int meth_setstats(lua_State *L); */ /* serial object methods */ -static luaL_Reg serial_methods[] = { - {"__gc", meth_close}, - {"__tostring", auxiliar_tostring}, - {"close", meth_close}, - {"dirty", meth_dirty}, - {"getfd", meth_getfd}, - {"getstats", meth_getstats}, - {"setstats", meth_setstats}, - {"receive", meth_receive}, - {"send", meth_send}, - {"setfd", meth_setfd}, - {"settimeout", meth_settimeout}, - {NULL, NULL} -}; +/* static luaL_Reg serial_methods[] = { */ +/* {"__gc", meth_close}, */ +/* {"__tostring", auxiliar_tostring}, */ +/* {"close", meth_close}, */ +/* {"dirty", meth_dirty}, */ +/* {"getfd", meth_getfd}, */ +/* {"getstats", meth_getstats}, */ +/* {"setstats", meth_setstats}, */ +/* {"receive", meth_receive}, */ +/* {"send", meth_send}, */ +/* {"setfd", meth_setfd}, */ +/* {"settimeout", meth_settimeout}, */ +/* {NULL, NULL} */ +/* }; */ /*-------------------------------------------------------------------------*\ -* Initializes module +* Initializes module (luatex extension, unused ) \*-------------------------------------------------------------------------*/ -LUASOCKET_API int luaopen_socket_serial(lua_State *L) { - /* create classes */ - auxiliar_newclass(L, "serial{client}", serial_methods); - /* create class groups */ - auxiliar_add2group(L, "serial{client}", "serial{any}"); - lua_pushcfunction(L, global_create); - return 1; -} +/* LUASOCKET_API int luaopen_socket_serial(lua_State *L) { */ +/* /\* create classes *\/ */ +/* auxiliar_newclass(L, "serial{client}", serial_methods); */ +/* /\* create class groups *\/ */ +/* auxiliar_add2group(L, "serial{client}", "serial{any}"); */ +/* lua_pushcfunction(L, global_create); */ +/* return 1; */ +/* } */ /*=========================================================================*\ * Lua methods @@ -76,67 +76,67 @@ LUASOCKET_API int luaopen_socket_serial(lua_State *L) { /*-------------------------------------------------------------------------*\ * Just call buffered IO methods \*-------------------------------------------------------------------------*/ -static int meth_send(lua_State *L) { - p_unix un = (p_unix) auxiliar_checkclass(L, "serial{client}", 1); - return buffer_meth_send(L, &un->buf); -} - -static int meth_receive(lua_State *L) { - p_unix un = (p_unix) auxiliar_checkclass(L, "serial{client}", 1); - return buffer_meth_receive(L, &un->buf); -} - -static int meth_getstats(lua_State *L) { - p_unix un = (p_unix) auxiliar_checkclass(L, "serial{client}", 1); - return buffer_meth_getstats(L, &un->buf); -} - -static int meth_setstats(lua_State *L) { - p_unix un = (p_unix) auxiliar_checkclass(L, "serial{client}", 1); - return buffer_meth_setstats(L, &un->buf); -} +/* static int meth_send(lua_State *L) { */ +/* p_unix un = (p_unix) auxiliar_checkclass(L, "serial{client}", 1); */ +/* return buffer_meth_send(L, &un->buf); */ +/* } */ + +/* static int meth_receive(lua_State *L) { */ +/* p_unix un = (p_unix) auxiliar_checkclass(L, "serial{client}", 1); */ +/* return buffer_meth_receive(L, &un->buf); */ +/* } */ + +/* static int meth_getstats(lua_State *L) { */ +/* p_unix un = (p_unix) auxiliar_checkclass(L, "serial{client}", 1); */ +/* return buffer_meth_getstats(L, &un->buf); */ +/* } */ + +/* static int meth_setstats(lua_State *L) { */ +/* p_unix un = (p_unix) auxiliar_checkclass(L, "serial{client}", 1); */ +/* return buffer_meth_setstats(L, &un->buf); */ +/* } */ /*-------------------------------------------------------------------------*\ * Select support methods \*-------------------------------------------------------------------------*/ -static int meth_getfd(lua_State *L) { - p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1); - lua_pushnumber(L, (int) un->sock); - return 1; -} - -/* this is very dangerous, but can be handy for those that are brave enough */ -static int meth_setfd(lua_State *L) { - p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1); - un->sock = (t_socket) luaL_checknumber(L, 2); - return 0; -} - -static int meth_dirty(lua_State *L) { - p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1); - lua_pushboolean(L, !buffer_isempty(&un->buf)); - return 1; -} +/* static int meth_getfd(lua_State *L) { */ +/* p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1); */ +/* lua_pushnumber(L, (int) un->sock); */ +/* return 1; */ +/* } */ + +/* /\* this is very dangerous, but can be handy for those that are brave enough *\/ */ +/* static int meth_setfd(lua_State *L) { */ +/* p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1); */ +/* un->sock = (t_socket) luaL_checknumber(L, 2); */ +/* return 0; */ +/* } */ + +/* static int meth_dirty(lua_State *L) { */ +/* p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1); */ +/* lua_pushboolean(L, !buffer_isempty(&un->buf)); */ +/* return 1; */ +/* } */ /*-------------------------------------------------------------------------*\ * Closes socket used by object \*-------------------------------------------------------------------------*/ -static int meth_close(lua_State *L) -{ - p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1); - socket_destroy(&un->sock); - lua_pushnumber(L, 1); - return 1; -} +/* static int meth_close(lua_State *L) */ +/* { */ +/* p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1); */ +/* socket_destroy(&un->sock); */ +/* lua_pushnumber(L, 1); */ +/* return 1; */ +/* } */ /*-------------------------------------------------------------------------*\ * Just call tm methods \*-------------------------------------------------------------------------*/ -static int meth_settimeout(lua_State *L) { - p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1); - return timeout_meth_settimeout(L, &un->tm); -} +/* static int meth_settimeout(lua_State *L) { */ +/* p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1); */ +/* return timeout_meth_settimeout(L, &un->tm); */ +/* } */ /*=========================================================================*\ * Library functions @@ -146,35 +146,35 @@ static int meth_settimeout(lua_State *L) { /*-------------------------------------------------------------------------*\ * Creates a serial object \*-------------------------------------------------------------------------*/ -static int global_create(lua_State *L) { - const char* path = luaL_checkstring(L, 1); - - /* allocate unix object */ - p_unix un = (p_unix) lua_newuserdata(L, sizeof(t_unix)); - - /* open serial device */ -#if defined(_WIN32) - t_socket sock = open(path, O_RDWR); -#else - t_socket sock = open(path, O_NOCTTY|O_RDWR); -#endif - - /*printf("open %s on %d\n", path, sock);*/ - - if (sock < 0) { - lua_pushnil(L); - lua_pushstring(L, socket_strerror(errno)); - lua_pushnumber(L, errno); - return 3; - } - /* set its type as client object */ - auxiliar_setclass(L, "serial{client}", -1); - /* initialize remaining structure fields */ - socket_setnonblocking(&sock); - un->sock = sock; - io_init(&un->io, (p_send) socket_write, (p_recv) socket_read, - (p_error) socket_ioerror, &un->sock); - timeout_init(&un->tm, -1, -1); - buffer_init(&un->buf, &un->io, &un->tm); - return 1; -} +/* static int global_create(lua_State *L) { */ +/* const char* path = luaL_checkstring(L, 1); */ + +/* /\* allocate unix object *\/ */ +/* p_unix un = (p_unix) lua_newuserdata(L, sizeof(t_unix)); */ + +/* /\* open serial device *\/ */ +/* #if defined(_WIN32) */ +/* t_socket sock = open(path, O_RDWR); */ +/* #else */ +/* t_socket sock = open(path, O_NOCTTY|O_RDWR); */ +/* #endif */ + +/* /\*printf("open %s on %d\n", path, sock);*\/ */ + +/* if (sock < 0) { */ +/* lua_pushnil(L); */ +/* lua_pushstring(L, socket_strerror(errno)); */ +/* lua_pushnumber(L, errno); */ +/* return 3; */ +/* } */ +/* /\* set its type as client object *\/ */ +/* auxiliar_setclass(L, "serial{client}", -1); */ +/* /\* initialize remaining structure fields *\/ */ +/* socket_setnonblocking(&sock); */ +/* un->sock = sock; */ +/* io_init(&un->io, (p_send) socket_write, (p_recv) socket_read, */ +/* (p_error) socket_ioerror, &un->sock); */ +/* timeout_init(&un->tm, -1, -1); */ +/* buffer_init(&un->buf, &un->io, &un->tm); */ +/* return 1; */ +/* } */ diff --git a/Build/source/texk/web2c/luatexdir/luatex.c b/Build/source/texk/web2c/luatexdir/luatex.c index 1c8694987a4..014d8bfd247 100644 --- a/Build/source/texk/web2c/luatexdir/luatex.c +++ b/Build/source/texk/web2c/luatexdir/luatex.c @@ -32,9 +32,9 @@ stick to "0" upto "9" so users can expect a number represented as string. */ -int luatex_version = 107; +int luatex_version = 109; int luatex_revision = '0'; -const char *luatex_version_string = "1.07.0"; +const char *luatex_version_string = "1.09.0"; const char *engine_name = my_name; #include <kpathsea/c-ctype.h> diff --git a/Build/source/texk/web2c/luatexdir/luatex_svnversion.h b/Build/source/texk/web2c/luatexdir/luatex_svnversion.h index 770aabbeb3d..90d51ef701c 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 6686 +#define luatex_svn_revision 6924 diff --git a/Build/source/texk/web2c/luatexdir/luatexcallbackids.h b/Build/source/texk/web2c/luatexdir/luatexcallbackids.h index 9cdef26c5df..a345edf64e6 100644 --- a/Build/source/texk/web2c/luatexdir/luatexcallbackids.h +++ b/Build/source/texk/web2c/luatexdir/luatexcallbackids.h @@ -68,8 +68,13 @@ typedef enum { call_edit_callback, build_page_insert_callback, glyph_stream_provider_callback, + font_descriptor_objnum_provider_callback, finish_synctex_callback, - total_callbacks + wrapup_run_callback, + new_graf_callback, + page_objnum_provider_callback, + make_extensible_callback, + total_callbacks, } callback_callback_types; /* lcallbacklib.c */ @@ -96,7 +101,6 @@ extern void get_lua_boolean(const char *table, const char *name, boolean * targe extern void get_lua_number(const char *table, const char *name, int *target); extern void get_lua_string(const char *table, const char *name, char **target); -extern int lua_reader_callback(int callback_id, pointer *buffloc); extern char *get_lua_name(int i); diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h index 01b0e74cd1e..00df7f36ed3 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h +++ b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.h @@ -114,6 +114,19 @@ printing ones but the output is going to PDF buffer. Subroutines with suffix pdf_out(pdf, '\n'); \ } while (0) +#define pdf_check_space(pdf) do { \ + if (pdf->cave > 0) { \ + pdf_out(pdf, ' '); \ + pdf->cave = 0; \ + } \ +} while (0) + +#define pdf_set_space(pdf) \ + pdf->cave = 1; + +#define pdf_reset_space(pdf) \ + pdf->cave = 0; + extern __attribute__ ((format(printf, 2, 3))) void pdf_printf(PDF, const char *, ...); @@ -125,6 +138,7 @@ extern void pdf_print_str(PDF, const char *); extern void pdf_add_null(PDF); extern void pdf_add_bool(PDF, int i); extern void pdf_add_int(PDF, int i); +extern void pdf_add_real(PDF, double d); extern void pdf_add_longint(PDF, longinteger n); extern void pdf_add_ref(PDF, int num); extern void pdf_add_string(PDF, const char *s); @@ -140,6 +154,18 @@ extern void pdf_dict_add_streaminfo(PDF); extern void pdf_begin_stream(PDF); extern void pdf_end_stream(PDF); +typedef unsigned char BYTE; +typedef unsigned long ULONG; + +typedef struct { + ULONG length; + BYTE *data; +} pdf_obj; + +extern pdf_obj *pdf_new_stream(void); +extern void pdf_add_stream(pdf_obj * stream, unsigned char *buf, long len); +extern void pdf_release_obj(pdf_obj * stream); + extern void pdf_add_bp(PDF, scaled); extern strbuf_s *new_strbuf(size_t size, size_t limit); @@ -191,8 +217,6 @@ extern char *convertStringToPDFString(const char *in, int len); extern void initialize_start_time(PDF); extern char *getcreationdate(PDF); -extern void check_o_mode(PDF pdf, const char *s, int o_mode, boolean errorflag); - extern void set_job_id(PDF, int, int, int, int); extern char *get_resname_prefix(PDF); extern void pdf_begin_page(PDF pdf); @@ -201,6 +225,10 @@ extern void print_pdf_table_string(PDF pdf, const char *s); extern const char *get_pdf_table_string(const char *s); extern int get_pdf_table_bool(PDF, const char *, int); +extern void pdf_open_file(PDF pdf); +extern void pdf_write_header(PDF pdf); +extern void pdf_finish_file(PDF pdf, int fatal_error); + extern void ensure_output_state(PDF pdf, output_state s); extern PDF init_pdf_struct(PDF pdf); @@ -210,8 +238,18 @@ extern halfword pdf_catalog_openaction; extern halfword pdf_names_toks; /* additional keys of Names dictionary */ extern halfword pdf_trailer_toks; /* additional keys of Trailer dictionary */ extern void scan_pdfcatalog(PDF pdf); -extern void finish_pdf_file(PDF pdf, int luatex_version, str_number luatex_revision); extern shipping_mode_e global_shipping_mode; +extern void pdf_push_list(PDF pdf, scaledpos *saved_pos, int *saved_loc); +extern void pdf_pop_list(PDF pdf, scaledpos *saved_pos, int *saved_loc); + +extern void pdf_set_reference_point(PDF pdf, posstructure *refpoint); + +/* not pdf specific */ + +extern void check_o_mode(PDF pdf, const char *s, int o_mode, boolean errorflag); +extern void ensure_output_file_open(PDF pdf, const char *ext); + + #endif diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdflistout.h b/Build/source/texk/web2c/luatexdir/pdf/pdflistout.h index 76c1d552f1a..dd3775816a3 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdflistout.h +++ b/Build/source/texk/web2c/luatexdir/pdf/pdflistout.h @@ -21,28 +21,12 @@ #ifndef PDFLISTOUT_H # define PDFLISTOUT_H -# define pos_right(A) pdf->posstruct->pos.h = pdf->posstruct->pos.h + (A) -# define pos_left(A) pdf->posstruct->pos.h = pdf->posstruct->pos.h - (A) -# define pos_up(A) pdf->posstruct->pos.v = pdf->posstruct->pos.v + (A) -# define pos_down(A) pdf->posstruct->pos.v = pdf->posstruct->pos.v - (A) - -typedef void (*backend_function) (); /* variadic arguments */ - -typedef struct { - char *name; /* name of the backend */ - backend_function *node_fu; /* array of node output functions */ - backend_function *whatsit_fu; /* array of whatsit output functions */ -} backend_struct; - -extern pos_info_structure pos_info; - -extern backend_function *backend_out; -extern backend_function *backend_out_whatsit; - -extern void init_backend_functionpointers(output_mode o_mode); +#define pos_right(A) pdf->posstruct->pos.h = pdf->posstruct->pos.h + (A) +#define pos_left(A) pdf->posstruct->pos.h = pdf->posstruct->pos.h - (A) +#define pos_up(A) pdf->posstruct->pos.v = pdf->posstruct->pos.v + (A) +#define pos_down(A) pdf->posstruct->pos.v = pdf->posstruct->pos.v - (A) extern void hlist_out(PDF pdf, halfword this_box, int rule_callback_id); extern void vlist_out(PDF pdf, halfword this_box, int rule_callback_id); -extern void out_what(PDF pdf, halfword p); #endif diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h index f8fac35eea7..f6e49450be9 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h +++ b/Build/source/texk/web2c/luatexdir/pdf/pdfobj.h @@ -35,6 +35,7 @@ # define OBJ_FLAG_ISSTREAM (1 << 0) # define OBJ_FLAG_ISFILE (1 << 1) +# define OBJ_FLAG_NOLENGTH (1 << 2) # define obj_obj_is_stream(pdf,A) ((obj_obj_flags((pdf), (A)) & OBJ_FLAG_ISSTREAM) != 0) # define set_obj_obj_is_stream(pdf,A) ((obj_obj_flags((pdf), (A)) |= OBJ_FLAG_ISSTREAM)) @@ -44,6 +45,10 @@ # define set_obj_obj_is_file(pdf,A) ((obj_obj_flags((pdf), (A)) |= OBJ_FLAG_ISFILE)) # define unset_obj_obj_is_file(pdf,A) ((obj_obj_flags((pdf), (A)) &= ~OBJ_FLAG_ISFILE)) +# define obj_obj_no_length(pdf,A) ((obj_obj_flags((pdf), (A)) & OBJ_FLAG_NOLENGTH) != 0) +# define set_obj_obj_no_length(pdf,A) ((obj_obj_flags((pdf), (A)) |= OBJ_FLAG_NOLENGTH)) +# define unset_obj_obj_no_length(pdf,A) ((obj_obj_flags((pdf), (A)) &= ~OBJ_FLAG_NOLENGTH)) + extern void init_obj_obj(PDF pdf, int k); extern void pdf_write_obj(PDF pdf, int n); extern void scan_obj(PDF pdf); diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftables.h b/Build/source/texk/web2c/luatexdir/pdf/pdftables.h index e29c5603d66..8aa7403c1f4 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdftables.h +++ b/Build/source/texk/web2c/luatexdir/pdf/pdftables.h @@ -139,6 +139,8 @@ typedef enum { c_pdf_pk_fixed_dpi, c_pdf_suppress_optional_info, c_pdf_omit_cidset, + c_pdf_recompress, + c_pdf_omit_charset, } pdf_backend_counters ; typedef enum { @@ -187,6 +189,8 @@ extern int pdf_cur_form; # define pdf_pk_fixed_dpi get_tex_extension_count_register(c_pdf_pk_fixed_dpi) # define pdf_suppress_optional_info get_tex_extension_count_register(c_pdf_suppress_optional_info) # define pdf_omit_cidset get_tex_extension_count_register(c_pdf_omit_cidset) +# define pdf_omit_charset get_tex_extension_count_register(c_pdf_omit_charset) +# define pdf_recompress get_tex_extension_count_register(c_pdf_recompress) # define pdf_h_origin get_tex_extension_dimen_register(d_pdf_h_origin) # define pdf_v_origin get_tex_extension_dimen_register(d_pdf_v_origin) @@ -208,7 +212,9 @@ extern int pdf_cur_form; # 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) # define set_pdf_omit_cidset(i) set_tex_extension_count_register(c_pdf_omit_cidset,i) +# define set_pdf_omit_charset(i) set_tex_extension_count_register(c_pdf_omit_charset,i) # define set_pdf_gen_tounicode(i) set_tex_extension_count_register(c_pdf_gen_tounicode,i) +# define set_pdf_recompress(i) set_tex_extension_count_register(c_pdf_recompress,i) # define set_pdf_decimal_digits(i) set_tex_extension_count_register(c_pdf_decimal_digits,i) # define set_pdf_pk_resolution(i) set_tex_extension_count_register(c_pdf_pk_resolution,i) diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h b/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h index c5f0393cc20..ef6a31e167d 100644 --- a/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h +++ b/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h @@ -90,10 +90,7 @@ typedef struct { typedef struct scaledpos_ { int64_t h; int64_t v; - } scaledpos; - - - +} scaledpos; typedef struct scaled_whd_ { scaled wd; /* TeX width */ @@ -106,11 +103,11 @@ typedef struct posstructure_ { int dir; /* direction of stuff to be put onto the page */ } posstructure; -typedef struct { - scaledpos curpos; /* \pdflastpos position */ - posstructure boxpos; /* box dir and position of the box origin on the page */ - scaled_whd boxdim; /* box dimensions (in hlist/vlist coordinate system) */ -} pos_info_structure; +/* typedef struct { */ +/* scaledpos curpos; */ /* \pdflastpos position */ +/* posstructure boxpos; */ /* box dir and position of the box origin on the page */ +/* scaled_whd boxdim; */ /* box dimensions (in hlist/vlist coordinate system) */ +/* } pos_info_structure; */ typedef enum { PMODE_NONE, @@ -159,6 +156,10 @@ typedef struct { int need_tf; /* flag whether Tf needs to be set */ int need_tm; /* flag whether Tm needs to be set */ int cur_ex; /* the current glyph ex factor */ + int need_width; + int need_mode; + int done_width; + int done_mode; } pdfstructure; typedef struct obj_entry_ { @@ -292,9 +293,11 @@ typedef struct pdf_output_file_ { int decimal_digits; int gen_tounicode; int omit_cidset; + int omit_charset; 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 recompress; int compress_level; /* level for zlib object stream compression */ int objcompresslevel; /* fixed level for activating PDF object streams */ char *job_id_string; /* the full job string */ @@ -351,6 +354,8 @@ typedef struct pdf_output_file_ { int xform_count; int ximage_count; + int force_file; + pdf_resource_struct *page_resources; scaledpos page_size; /* width and height of page being shipped */ diff --git a/Build/source/texk/web2c/luatexdir/ptexlib.h b/Build/source/texk/web2c/luatexdir/ptexlib.h index 21bb9348ce2..f63f480b000 100644 --- a/Build/source/texk/web2c/luatexdir/ptexlib.h +++ b/Build/source/texk/web2c/luatexdir/ptexlib.h @@ -153,7 +153,8 @@ size_t T##_limit # include "tex/expand.h" # include "tex/conditional.h" -# include "pdf/pdftypes.h" /* the backend data structure, shared between dvi and pdf */ +# include "pdf/pdftypes.h" /* the backend data structure, shared between dvi and pdf (might move to |tex/backend| */ +# include "tex/backend.h" /* more backend data */ # include "synctex.h" @@ -254,7 +255,7 @@ int lua_appendtovlist_callback( halfword box, int location, halfword prev_depth, boolean is_mirrored, halfword * result, int * next_depth, boolean * prev_set); -void lua_pdf_literal(PDF pdf, int i); +void lua_pdf_literal(PDF pdf, int i, int noline); void copy_pdf_literal(pointer r, pointer p); void free_pdf_literal(pointer p); void show_pdf_literal(pointer p); @@ -277,7 +278,7 @@ void undump_luac_registers(void); void luacstring_start(int n); void luacstring_close(int n); int luacstring_cattable(void); -int luacstring_input(void); +int luacstring_input(halfword *n); int luacstring_partial(void); int luacstring_final_line(void); @@ -293,6 +294,7 @@ void flush_loggable_info(void); /* lua/luastuff.w */ void luafunctioncall(int slot); +void luabytecodecall(int slot); /* lua/luastuff.c */ void luatokencall(int p, int nameptr); diff --git a/Build/source/texk/web2c/luatexdir/tex/commands.h b/Build/source/texk/web2c/luatexdir/tex/commands.h index 8eabaa4e7cc..c3a3ca30452 100644 --- a/Build/source/texk/web2c/luatexdir/tex/commands.h +++ b/Build/source/texk/web2c/luatexdir/tex/commands.h @@ -89,6 +89,7 @@ typedef enum { char_num_cmd, /* character specified numerically ( \.{\\char} ) */ math_char_num_cmd, /* explicit math code ( \.{\\mathchar} ) */ mark_cmd, /* mark definition ( \.{\\mark} ) */ + node_cmd, xray_cmd, /* peek inside of \TeX\ ( \.{\\show}, \.{\\showbox}, etc.~) */ make_box_cmd, /* make a box ( \.{\\box}, \.{\\copy}, \.{\\hbox}, etc.~) */ hmove_cmd, /* horizontal motion ( \.{\\moveleft}, \.{\\moveright} ) */ @@ -134,6 +135,9 @@ typedef enum { normal_cmd, /* general extensions to \TeX\ that don't fit into a category */ extension_cmd, /* extensions to \TeX\ ( \.{\\write}, \.{\\special}, etc.~) */ option_cmd, + lua_function_call_cmd, + lua_bytecode_call_cmd, + lua_call_cmd, in_stream_cmd, /* files for reading ( \.{\\openin}, \.{\\closein} ) */ begin_group_cmd, /* begin local grouping ( \.{\\begingroup} ) */ end_group_cmd, /* end local grouping ( \.{\\endgroup} ) */ @@ -179,7 +183,9 @@ typedef enum { set_font_cmd, /* set current font ( font identifiers ) */ def_font_cmd, /* define a font file ( \.{\\font} ) */ register_cmd, /* internal register ( \.{\\count}, \.{\\dimen}, etc.~) */ + assign_box_direction_cmd, /* (\.{\\boxdirection}) */ assign_box_dir_cmd, /* (\.{\\boxdir}) */ + assign_direction_cmd, /* (\.{\\pagedirection}, \.{\\textdirection}) */ assign_dir_cmd, /* (\.{\\pagedir}, \.{\\textdir}) */ # define max_internal_cmd assign_dir_cmd /* the largest code that can follow \.{\\the} */ advance_cmd, /* advance a register or parameter ( \.{\\advance} ) */ @@ -188,6 +194,7 @@ typedef enum { prefix_cmd, /* qualify a definition ( \.{\\global}, \.{\\long}, \.{\\outer} ) */ let_cmd, /* assign a command code ( \.{\\let}, \.{\\futurelet} ) */ shorthand_def_cmd, /* code definition ( \.{\\chardef}, \.{\\countdef}, etc.~) */ + def_lua_call_cmd, read_to_cs_cmd, /* read into a control sequence ( \.{\\read} ) */ def_cmd, /* macro definition ( \.{\\def}, \.{\\gdef}, \.{\\xdef}, \.{\\edef} ) */ set_box_cmd, /* set a box ( \.{\\setbox} ) */ @@ -201,6 +208,8 @@ typedef enum { expand_after_cmd, /* special expansion ( \.{\\expandafter} ) */ no_expand_cmd, /* special nonexpansion ( \.{\\noexpand} ) */ input_cmd, /* input a source file ( \.{\\input}, \.{\\endinput} or \.{\\scantokens} or \.{\\scantextokens} ) */ + lua_expandable_call_cmd, + lua_local_call_cmd, if_test_cmd, /* conditional text ( \.{\\if}, \.{\\ifcase}, etc.~) */ fi_or_else_cmd, /* delimiters for conditionals ( \.{\\else}, etc.~) */ cs_name_cmd, /* make a control sequence from tokens ( \.{\\csname} ) */ @@ -236,9 +245,12 @@ typedef enum { typedef enum { number_code = 0, /* command code for \.{\\number} */ - lua_function_code, /* command code for \.{\\luafunction} */ lua_code, /* command code for \.{\\directlua} */ + lua_function_code, /* command code for \.{\\luafunction} */ + lua_bytecode_code, /* command code for \.{\\luabytecode} */ expanded_code, /* command code for \.{\\expanded} */ + immediate_assignment_code, /* command code for \.{\\immediateassignment} */ + immediate_assigned_code, /* command code for \.{\\assigned} */ math_style_code, /* command code for \.{\\mathstyle} */ string_code, /* command code for \.{\\string} */ cs_string_code, /* command code for \.{\\csstring} */ @@ -324,6 +336,7 @@ typedef enum { set_random_seed_code, save_pos_code, late_lua_code, + late_lua_call_code, expand_font_code, } normal_codes; diff --git a/Build/source/texk/web2c/luatexdir/tex/conditional.h b/Build/source/texk/web2c/luatexdir/tex/conditional.h index b6abe7578d3..483496eece2 100644 --- a/Build/source/texk/web2c/luatexdir/tex/conditional.h +++ b/Build/source/texk/web2c/luatexdir/tex/conditional.h @@ -24,30 +24,31 @@ # define unless_code 32 /* amount added for `\.{\\unless}' prefix */ typedef enum { - if_char_code = 0, /* \.{\\if} */ - if_cat_code = 1, /* \.{\\ifcat} */ - if_int_code = 2, /* \.{\\ifnum} */ - if_dim_code = 3, /* \.{\\ifdim} */ - if_odd_code = 4, /* \.{\\ifodd} */ - if_vmode_code = 5, /* \.{\\ifvmode} */ - if_hmode_code = 6, /* \.{\\ifhmode} */ - if_mmode_code = 7, /* \.{\\ifmmode} */ - if_inner_code = 8, /* \.{\\ifinner} */ - if_void_code = 9, /* \.{\\ifvoid} */ - if_hbox_code = 10, /* \.{\\ifhbox} */ - if_vbox_code = 11, /* \.{\\ifvbox} */ - ifx_code = 12, /* \.{\\ifx} */ - if_eof_code = 13, /* \.{\\ifeof} */ - if_true_code = 14, /* \.{\\iftrue} */ - if_false_code = 15, /* \.{\\iffalse} */ - if_case_code = 16, /* \.{\\ifcase} */ - if_def_code = 17, /* \.{\\ifdefined} */ - if_cs_code = 18, /* \.{\\ifcsname} */ - if_font_char_code = 19, /* \.{\\iffontchar} */ - if_in_csname_code = 20, /* \.{\\ifincsname} */ - if_primitive_code = 21, /* \.{\\ifprimitive} */ - if_abs_num_code = 22, /* \.{\\ifabsnum} */ - if_abs_dim_code = 23, /* \.{\\ifabsdim} */ + if_char_code = 0, /* \.{\\if} */ + if_cat_code = 1, /* \.{\\ifcat} */ + if_int_code = 2, /* \.{\\ifnum} */ + if_dim_code = 3, /* \.{\\ifdim} */ + if_odd_code = 4, /* \.{\\ifodd} */ + if_vmode_code = 5, /* \.{\\ifvmode} */ + if_hmode_code = 6, /* \.{\\ifhmode} */ + if_mmode_code = 7, /* \.{\\ifmmode} */ + if_inner_code = 8, /* \.{\\ifinner} */ + if_void_code = 9, /* \.{\\ifvoid} */ + if_hbox_code = 10, /* \.{\\ifhbox} */ + if_vbox_code = 11, /* \.{\\ifvbox} */ + if_x_code = 12, /* \.{\\ifx} */ + if_eof_code = 13, /* \.{\\ifeof} */ + if_true_code = 14, /* \.{\\iftrue} */ + if_false_code = 15, /* \.{\\iffalse} */ + if_case_code = 16, /* \.{\\ifcase} */ + if_def_code = 17, /* \.{\\ifdefined} */ + if_cs_code = 18, /* \.{\\ifcsname} */ + if_font_char_code = 19, /* \.{\\iffontchar} */ + if_in_csname_code = 20, /* \.{\\ifincsname} */ + if_primitive_code = 21, /* \.{\\ifprimitive} */ + if_abs_num_code = 22, /* \.{\\ifabsnum} */ + if_abs_dim_code = 23, /* \.{\\ifabsdim} */ + if_condition_code = 24, /* \.{\\ifcondition} */ } if_type_codes; # define if_limit_subtype(A) subtype((A)+1) diff --git a/Build/source/texk/web2c/luatexdir/tex/directions.h b/Build/source/texk/web2c/luatexdir/tex/directions.h index 7ab524a1e79..92d6cc18f12 100644 --- a/Build/source/texk/web2c/luatexdir/tex/directions.h +++ b/Build/source/texk/web2c/luatexdir/tex/directions.h @@ -22,43 +22,19 @@ # define DIRECTIONS_H /* - # define dir_TLT 0 - # define dir_TRT 4 - # define dir_LTL 9 - # define dir_RTT 24 - - extern const char *dir_strings[128]; +#define dir_swap 4 */ -extern const char *dir_strings[8]; - -extern int dir_swap; - -/* -# define RETURN_DIR_VALUES(a) \ - if (s==luaS_##a##_ptr) { \ - return (dir_##a); \ - } else if (!absolute_only) { \ - if (s==luaS_p##a##_ptr) \ - return (dir_##a); \ - else if (s==luaS_m##a##_ptr) \ - return ((dir_##a)-4); \ - } -*/ +#define dir_min_value 0 +#define dir_max_value 3 -# define RETURN_DIR_VALUES(a) \ - if (s==lua_key(a)) { \ - return (dir_##a); \ - } else if (!absolute_only) { \ - if (s==lua_key_plus(a)) \ - return (dir_##a); \ - else if (s==lua_key_minus(a)) \ - return ((dir_##a)-4); \ - } +#define check_dir_value(d) \ + if ((d < dir_min_value) || (d > dir_max_value)) \ + d = dir_min_value; -# define is_mirrored(a) 0 +#define is_mirrored(a) 0 -# define is_rotated(a) (a == dir_RTT) +#define is_rotated(a) (a == dir_RTT) /* @@ -90,10 +66,12 @@ extern int dir_swap; (a == dir_RTT && b == dir_TRT) \ ) + # define dir_TLT_or_TRT(a) (a == dir_TLT || a == dir_TRT) + # define dir_LTL_or_RTT(a) (a == dir_LTL || a == dir_RTT) + */ -/* # define dir_TLT_or_TRT(a) (a == dir_TLT || a == dir_TRT) */ -/* # define dir_LTL_or_RTT(a) (a == dir_LTL || a == dir_RTT) */ +/* TLT TRT LTL RTT */ # define dir_TLT_or_TRT(a) (a < 2) # define dir_LTL_or_RTT(a) (a > 1) @@ -174,7 +152,8 @@ extern void initialize_directions(void); extern halfword new_dir(int s); extern const char *string_dir(int d); -extern void print_dir(int d); +extern void print_dir_par(int d); +extern void print_dir_text(halfword d); extern void scan_direction(void); diff --git a/Build/source/texk/web2c/luatexdir/tex/equivalents.h b/Build/source/texk/web2c/luatexdir/tex/equivalents.h index f478b4a41b2..3ff9ac16dbe 100644 --- a/Build/source/texk/web2c/luatexdir/tex/equivalents.h +++ b/Build/source/texk/web2c/luatexdir/tex/equivalents.h @@ -38,10 +38,10 @@ distinction. # define biggest_reg 65535 /* the largest allowed register number; must be |< max_quarterword| */ # define number_regs 65536 /* |biggest_reg+1| */ # define number_attrs 65536 /* total numbeer of attributes */ -# define biggest_char 1114111 /* the largest allowed character number; must be |< max_halfword| */ -# define too_big_char 1114112 /* |biggest_char+1| */ -# define special_char 1114113 /* |biggest_char+2| */ -# define number_chars 1114112 /* |biggest_char+1| */ +# define biggest_char 1114111 /* 0x10FFFF, the largest allowed character number; must be |< max_halfword| */ +# define too_big_char (biggest_char+1) /* 1114112, |biggest_char+1| */ +# define special_char (biggest_char+2) /* 1114113, |biggest_char+2| */ +# define number_chars (biggest_char+3) /* 1114112, |biggest_char+1| */ # define number_fonts (5535-font_base+1) # define biggest_lang 32767 # define too_big_lang 32768 @@ -292,15 +292,22 @@ the |number_regs| \.{\\dimen} registers. # 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 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 compound_hyphen_mode_code 104 +# define break_after_dir_mode_code 105 +# define exception_penalty_code 106 + +# define pre_bin_op_penalty_code 107 +# define pre_rel_penalty_code 108 +# define math_penalties_mode_code 109 +# define math_delimiters_mode_code 110 +# define math_script_box_mode_code 111 +# define math_script_char_mode_code 112 +# define math_rule_thickness_mode_code 113 +# define math_flatten_mode_code 114 + +# define copy_lua_input_nodes_code 115 +# define suppress_primitive_error_code 116 +# define fixup_boxes_code 117 # define math_option_code (suppress_primitive_error_code+1) @@ -441,7 +448,8 @@ We use the notation |saved(k)| to stand for an item that appears in location # define saved_boxspec 14 # define saved_boxdir 15 # define saved_boxattr 16 -# define saved_boxpack 18 +# define saved_boxpack 17 +# define saved_attrlist 18 # define saved_eqtb 19 extern void print_save_stack(void); @@ -453,10 +461,9 @@ extern void print_save_stack(void); typedef enum { c_mathoption_old_code = 0, /* this one is stable */ - c_mathoption_no_italic_compensation_code, /* just for tracing, can change */ - c_mathoption_no_char_italic_code, /* just for tracing, can change */ - c_mathoption_use_old_fraction_scaling_code, /* just for tracing, can change */ - c_mathoption_umathcode_meaning_code, /* this one is stable */ + /* + c_mathoption_umathcode_meaning_code, + */ } math_option_codes ; # define mathoption_int_par(A) eqtb[mathoption_int_base+(A)].cint @@ -525,7 +532,7 @@ typedef enum { cramped_script_script_style, /* |subtype| for \.{\\crampedscriptscriptstyle} */ } math_style_subtypes; -typedef enum { +typedef enum { /* this could move to directions.h */ dir_TLT = 0, dir_TRT, dir_LTL, @@ -663,6 +670,9 @@ extern halfword last_cs_name; #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 math_script_char_mode_par int_par(math_script_char_mode_code) +#define math_rule_thickness_mode_par int_par(math_rule_thickness_mode_code) +#define math_flatten_mode_par int_par(math_flatten_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) @@ -757,12 +767,13 @@ extern halfword last_cs_name; #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 copy_lua_input_nodes_par int_par(copy_lua_input_nodes_code) #define math_old_par mathoption_int_par(c_mathoption_old_code) -#define math_no_italic_compensation_par mathoption_int_par(c_mathoption_no_italic_compensation_code) -#define math_no_char_italic_par mathoption_int_par(c_mathoption_no_char_italic_code) -#define math_use_old_fraction_scaling_par mathoption_int_par(c_mathoption_use_old_fraction_scaling_code) + +/* #define math_umathcode_meaning_par mathoption_int_par(c_mathoption_umathcode_meaning_code) +*/ #define math_pre_display_gap_factor_par int_par(math_pre_display_gap_factor_code) @@ -790,11 +801,15 @@ extern halfword last_cs_name; #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 compound_hyphen_mode_par int_par(compound_hyphen_mode_code) #define break_after_dir_mode_par int_par(break_after_dir_mode_code) +#define exception_penalty_par int_par(exception_penalty_code) #define cur_lang_par int_par(cur_lang_code) #define cur_font_par equiv(cur_font_loc) +#define fixup_boxes_par int_par(fixup_boxes_code) + /* */ #define math_use_current_family_code 7 diff --git a/Build/source/texk/web2c/luatexdir/tex/extensions.h b/Build/source/texk/web2c/luatexdir/tex/extensions.h index b6839534439..5e22ddf26c3 100644 --- a/Build/source/texk/web2c/luatexdir/tex/extensions.h +++ b/Build/source/texk/web2c/luatexdir/tex/extensions.h @@ -136,9 +136,12 @@ typedef enum { use_box_resource_code, save_image_resource_code, use_image_resource_code, + end_local_code, /* backend */ dvi_extension_code, pdf_extension_code, } extension_codes ; +extern void wrapup_leader(halfword p); + #endif diff --git a/Build/source/texk/web2c/luatexdir/tex/inputstack.h b/Build/source/texk/web2c/luatexdir/tex/inputstack.h index 378fabe24b8..8c139a8332e 100644 --- a/Build/source/texk/web2c/luatexdir/tex/inputstack.h +++ b/Build/source/texk/web2c/luatexdir/tex/inputstack.h @@ -306,6 +306,7 @@ typedef enum { mark_text = 14, /* |token_type| code for \.{\\topmark}, etc. */ every_eof_text = 15, /* |token_type| code for \.{\\everyeof} */ write_text = 16, /* |token_type| code for \.{\\write} */ + local_text = 17, /* |token_type| code for special purposed */ } token_types; extern pointer *param_stack; diff --git a/Build/source/texk/web2c/luatexdir/tex/linebreak.h b/Build/source/texk/web2c/luatexdir/tex/linebreak.h index 1f49278314b..d1e1768f704 100644 --- a/Build/source/texk/web2c/luatexdir/tex/linebreak.h +++ b/Build/source/texk/web2c/luatexdir/tex/linebreak.h @@ -20,9 +20,6 @@ #ifndef LINEBREAK_H # define LINEBREAK_H -# define left_side 0 -# define right_side 1 - extern halfword just_box; /* the |hlist_node| for the last line of the new paragraph */ extern void line_break(boolean d, int line_break_context); diff --git a/Build/source/texk/web2c/luatexdir/tex/mainbody.h b/Build/source/texk/web2c/luatexdir/tex/mainbody.h index 4a5cb93a164..245535120c8 100644 --- a/Build/source/texk/web2c/luatexdir/tex/mainbody.h +++ b/Build/source/texk/web2c/luatexdir/tex/mainbody.h @@ -139,6 +139,9 @@ extern int filelineerrorstylep; extern int haltonerrorp; extern boolean quoted_filename; +extern int total_pages; +extern int dead_cycles; + /* In order to make efficient use of storage space, \TeX\ bases its major data structures on a |memory_word|, which contains either a (signed) integer, diff --git a/Build/source/texk/web2c/luatexdir/tex/maincontrol.h b/Build/source/texk/web2c/luatexdir/tex/maincontrol.h index 13e3c6ff3b0..04608c11e9b 100644 --- a/Build/source/texk/web2c/luatexdir/tex/maincontrol.h +++ b/Build/source/texk/web2c/luatexdir/tex/maincontrol.h @@ -151,6 +151,7 @@ extern void do_endv(void); extern void cs_error(void); extern void prefixed_command(void); extern void fixup_directions(void); +extern void fixup_directions_only(void); /* Assignments from Lua need helpers. */ @@ -205,5 +206,12 @@ extern void show_whatever(void); extern void initialize(void); /* this procedure gets things started properly */ +/*extern int local_level;*/ + +extern void local_control(void); +extern halfword local_scan_box(void); +extern int current_local_level(void); +extern void end_local_control(void); +extern void local_control_message(const char *s); #endif diff --git a/Build/source/texk/web2c/luatexdir/tex/mlist.h b/Build/source/texk/web2c/luatexdir/tex/mlist.h index bd156212220..1a15afe3c04 100644 --- a/Build/source/texk/web2c/luatexdir/tex/mlist.h +++ b/Build/source/texk/web2c/luatexdir/tex/mlist.h @@ -31,5 +31,6 @@ extern void fixup_math_parameters(int fam_id, int size_id, int f, int lvl); extern scaled get_math_quad_style(int a); extern scaled get_math_quad_size(int a); +extern pointer make_extensible(internal_font_number fnt, halfword chr, scaled v, scaled min_overlap, int horizontal, halfword att); #endif diff --git a/Build/source/texk/web2c/luatexdir/tex/packaging.h b/Build/source/texk/web2c/luatexdir/tex/packaging.h index 6a0802e4676..9353afeaf20 100644 --- a/Build/source/texk/web2c/luatexdir/tex/packaging.h +++ b/Build/source/texk/web2c/luatexdir/tex/packaging.h @@ -143,7 +143,8 @@ latter two are used denote \.{\\vbox} and \.{\\hbox}, respectively. # define global_box_flag (box_flag+number_regs) /* context code for `\.{\\global\\setbox0}' */ # define max_global_box_flag (global_box_flag+number_regs) # define ship_out_flag (max_global_box_flag+1) /* context code for `\.{\\shipout}' */ -# define leader_flag ship_out_flag+1 /* context code for `\.{\\leaders}' */ +# define lua_scan_flag (max_global_box_flag+2) /* context code for |scan_list| */ +# define leader_flag (max_global_box_flag+3) /* context code for `\.{\\leaders}' */ extern void begin_box(int box_context); diff --git a/Build/source/texk/web2c/luatexdir/tex/printing.h b/Build/source/texk/web2c/luatexdir/tex/printing.h index 1619c6072de..79ca524ef6f 100644 --- a/Build/source/texk/web2c/luatexdir/tex/printing.h +++ b/Build/source/texk/web2c/luatexdir/tex/printing.h @@ -77,7 +77,7 @@ extern void print_esc(str_number s); extern void print_the_digs(eight_bits k); extern void print_int(longinteger n); extern void print_two(int n); -extern void print_hex(int n); +extern void print_qhex(int n); extern void print_roman_int(int n); extern void print_current_string(void); diff --git a/Build/source/texk/web2c/luatexdir/tex/scanning.h b/Build/source/texk/web2c/luatexdir/tex/scanning.h index f5f620c6746..e4189a0f67a 100644 --- a/Build/source/texk/web2c/luatexdir/tex/scanning.h +++ b/Build/source/texk/web2c/luatexdir/tex/scanning.h @@ -63,9 +63,13 @@ extern void scan_fifty_one_bit_int(void); # define hex_token (other_token+'"') /* double quote, indicates a hex constant */ # define alpha_token (other_token+'`') /* reverse apostrophe, precedes alpha constants */ # define point_token (other_token+'.') /* decimal point */ +# define comma_token (other_token+',') /* decimal comma */ +# define plus_token (other_token + '+') +# define minus_token (other_token + '-') # define continental_point_token (other_token+',') /* decimal point, Eurostyle */ # define infinity 017777777777 /* the largest positive value that \TeX\ knows */ # define zero_token (other_token+'0') /* zero, the smallest digit */ +# define nine_token (other_token+'9') /* zero, the smallest digit */ # define A_token (letter_token+'A') /* the smallest special hex digit */ # define other_A_token (other_token+'A') /* special hex digit of type |other_char| */ extern int radix; @@ -78,7 +82,6 @@ extern int cur_order; extern void scan_dimen(boolean mu, boolean inf, boolean shortcut); extern void scan_glue(int level); -extern void scan_scaled(void); extern halfword the_toks(void); extern str_number the_scanned_result(void); diff --git a/Build/source/texk/web2c/luatexdir/tex/stringpool.h b/Build/source/texk/web2c/luatexdir/tex/stringpool.h index a969547e763..2ba156046fd 100644 --- a/Build/source/texk/web2c/luatexdir/tex/stringpool.h +++ b/Build/source/texk/web2c/luatexdir/tex/stringpool.h @@ -1,5 +1,5 @@ /* stringpool.h - + Copyright 2009 Taco Hoekwater <taco@luatex.org> This file is part of LuaTeX. @@ -43,9 +43,10 @@ extern str_number init_str_ptr; # define get_nullstr() STRING_OFFSET -# define biggest_char 1114111 -# define number_chars 1114112 -# define special_char 1114113 /* |biggest_char+2| */ +# define biggest_char 1114111 /* 0x10FFFF, the largest allowed character number; must be |< max_halfword| */ +# define too_big_char (biggest_char+1) /* 1114112, |biggest_char+1| */ +# define special_char (biggest_char+2) /* 1114113, |biggest_char+2| */ +# define number_chars (biggest_char+3) /* 1114112, |biggest_char+1| */ /* Several of the elementary string operations are performed using diff --git a/Build/source/texk/web2c/luatexdir/tex/texmath.h b/Build/source/texk/web2c/luatexdir/tex/texmath.h index 24bb34dc977..23fc5a0e42e 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texmath.h +++ b/Build/source/texk/web2c/luatexdir/tex/texmath.h @@ -38,22 +38,6 @@ extern halfword new_sub_box(halfword); # define default_code 010000000000 /* denotes |default_rule_thickness| */ -typedef enum { - ord_noad_type = 0, - op_noad_type_normal, - op_noad_type_limits, - op_noad_type_no_limits, - bin_noad_type, - rel_noad_type, - open_noad_type, - close_noad_type, - punct_noad_type, - inner_noad_type, - under_noad_type, - over_noad_type, - vcenter_noad_type, -} noad_types; - extern void initialize_math(void); extern void initialize_math_spacing(void); extern halfword math_vcenter_group(halfword); diff --git a/Build/source/texk/web2c/luatexdir/tex/texnodes.h b/Build/source/texk/web2c/luatexdir/tex/texnodes.h index eb9b2da4a48..e77e2916e71 100644 --- a/Build/source/texk/web2c/luatexdir/tex/texnodes.h +++ b/Build/source/texk/web2c/luatexdir/tex/texnodes.h @@ -97,8 +97,30 @@ extern halfword do_set_attribute(halfword p, int i, int val); # define list_offset 6 typedef enum { + user_skip_glue, + line_skip_glue, + baseline_skip_glue, + par_skip_glue, + above_display_skip_glue, + below_display_skip_glue, + above_display_short_skip_glue, + below_display_short_skip_glue, + left_skip_glue, + right_skip_glue, + top_skip_glue, + split_top_skip_glue, + tab_skip_glue, + space_skip_glue, + xspace_skip_glue, + par_fill_skip_glue, + math_skip_glue, + thin_mu_skip_glue, + med_mu_skip_glue, + thick_mu_skip_glue, + /* math */ cond_math_glue = 98, /* special |subtype| to suppress glue in the next node */ mu_glue, /* |subtype| for math glue */ + /* leaders */ a_leaders, /* |subtype| for aligned leaders */ c_leaders, /* |subtype| for centered leaders */ x_leaders, /* |subtype| for expanded leaders */ @@ -199,7 +221,7 @@ typedef enum { # define disc_penalty(a) vlink((a)+2) # define pre_break(a) vinfo((a)+3) # define post_break(a) vlink((a)+3) -# define no_break(a) vlink((a)+4) +# define no_break(a) vlink((a)+4) /* we have vinfo((a)+4) for later usage */ # define vlink_pre_break(a) vlink(pre_break_head(a)) # define vlink_post_break(a) vlink(post_break_head(a)) @@ -264,14 +286,17 @@ typedef enum { math_under_rule, math_fraction_rule, math_radical_rule, + outline_rule, } rule_subtypes; -# define rule_node_size 8 +# define rule_node_size 9 # define rule_dir(a) vlink((a)+5) # define rule_index(a) vinfo((a)+6) # define rule_transform(a) vlink((a)+6) -# define synctex_tag_rule(a) vinfo((a)+7) -# define synctex_line_rule(a) vlink((a)+7) +# define rule_left(a) vinfo((a)+7) +# define rule_right(a) vlink((a)+7) +# define synctex_tag_rule(a) vinfo((a)+8) +# define synctex_line_rule(a) vlink((a)+8) # define rule_math_size rule_index # define rule_math_font rule_transform @@ -292,7 +317,7 @@ typedef enum { # 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 glyph_node_data(a) vlink((a)+5) # define synctex_tag_glyph(a) vinfo((a)+6) # define synctex_line_glyph(a) vlink((a)+6) @@ -318,11 +343,15 @@ typedef enum { /*@# {|subtype| of marginal kerns}*/ -# define left_side 0 -# define right_side 1 +typedef enum { + left_side = 0, + right_side +} margin_kern_subtypes ; -# define before 0 /* |subtype| for math node that introduces a formula */ -# define after 1 /* |subtype| for math node that winds up a formula */ +typedef enum { + before = 0, + after +} math_subtypes ; # define math_node_size 7 /* define width(a) vinfo((a)+2) */ @@ -487,6 +516,24 @@ typedef enum { # define noadextra3(a) vlink((a)+7) /* see (!) below */ # define noadextra4(a) vinfo((a)+7) /* used to store samesize */ +# define noad_fam(a) vlink((a)+6) /* noadextra1 */ + +typedef enum { + ord_noad_type = 0, + op_noad_type_normal, + op_noad_type_limits, + op_noad_type_no_limits, + bin_noad_type, + rel_noad_type, + open_noad_type, + close_noad_type, + punct_noad_type, + inner_noad_type, + under_noad_type, + over_noad_type, + vcenter_noad_type, +} noad_types; + /* accent noads */ # define accent_noad_size 8 @@ -495,6 +542,13 @@ typedef enum { # define overlay_accent_chr(a) vinfo((a)+7) /* the |overlay_accent_chr| field of an accent noad */ # define accentfraction(a) vlink((a)+7) +typedef enum { + bothflexible_accent, + fixedtop_accent, + fixedbottom_accent, + fixedboth_accent, +} math_accent_subtypes ; + /* left and right noads */ # define fence_noad_size 8 /* needs to match noad size */ @@ -540,22 +594,36 @@ typedef enum { noad_delimiter_mode_noshift = 0x01, noad_delimiter_mode_italics = 0x02, noad_delimiter_mode_ordinal = 0x04, + noad_delimiter_mode_samenos = 0x08, + noad_delimiter_mode_charnos = 0x10, } 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) +# define delimitermodesamenos ((math_delimiters_mode_par & noad_delimiter_mode_samenos) == noad_delimiter_mode_samenos) +# define delimitermodecharnos ((math_delimiters_mode_par & noad_delimiter_mode_charnos) == noad_delimiter_mode_charnos) /* subtype of fence noads */ +/* # define left_noad_side 1 # define middle_noad_side 2 # define right_noad_side 3 # define no_noad_side 4 +*/ + +typedef enum { + unset_noad_side = 0, + left_noad_side = 1, + middle_noad_side = 2, + right_noad_side = 3, + no_noad_side = 4, +} fence_subtypes ; /* fraction noads */ -# define fraction_noad_size 7 +# define fraction_noad_size 8 # define thickness(a) vlink((a)+2) /* |thickness| field in a fraction noad */ # define numerator(a) vlink((a)+3) /* |numerator| field in a fraction noad */ # define denominator(a) vinfo((a)+3) /* |denominator| field in a fraction noad */ @@ -563,6 +631,7 @@ typedef enum { # define right_delimiter(a) vinfo((a)+5) /* second delimiter field of a fraction noad */ # define middle_delimiter(a) vlink((a)+6) # define fractionoptions(a) vinfo((a)+6) +# define fraction_fam(a) vlink((a)+7) # define fractionoptionset(a) ((fractionoptions(a) & noad_option_set ) == noad_option_set ) # define fractionexact(a) ((fractionoptions(a) & noad_option_exact ) == noad_option_exact ) @@ -582,6 +651,16 @@ typedef enum { # define radicalmiddle(a) ((radicaloptions(a) & noad_option_middle) == noad_option_middle) # define radicalright(a) ((radicaloptions(a) & noad_option_right ) == noad_option_right) +typedef enum { + radical_noad_type, + uradical_noad_type, + uroot_noad_type, + uunderdelimiter_noad_type, + uoverdelimiter_noad_type, + udelimiterunder_noad_type, + udelimiterover_noad_type, +} radical_subtypes; + /* accessors for the |nucleus|-style node fields */ # define math_kernel_node_size 3 @@ -659,6 +738,15 @@ typedef enum { # define GLYPH_LEFT (1 << 3) # define GLYPH_RIGHT (1 << 4) +typedef enum { + glyph_unset = 0, + glyph_character = GLYPH_CHARACTER, + glyph_ligature = GLYPH_LIGATURE, + glyph_ghost = GLYPH_GHOST, + glyph_left = GLYPH_LEFT, + glyph_right = GLYPH_RIGHT, +} glyph_subtypes; + # define is_character(p) ((subtype(p)) & GLYPH_CHARACTER) # define is_ligature(p) ((subtype(p)) & GLYPH_LIGATURE ) # define is_ghost(p) ((subtype(p)) & GLYPH_GHOST ) @@ -698,6 +786,11 @@ typedef enum { # define special_node_size 3 +typedef enum { + normal_dir = 0, + cancel_dir, +} dir_subtypes ; + # define dir_node_size 5 # define dir_dir(a) vinfo((a)+2) # define dir_level(a) vlink((a)+2) @@ -737,6 +830,7 @@ typedef enum { /* type of literal data */ # define lua_refid_literal 1 /* not a |normal| string */ +# define lua_refid_call 2 /* not a |normal| string */ /* begin of pdf backend nodes */ @@ -899,40 +993,60 @@ extern void print_short_node_contents(halfword n); extern void show_node_list(int i); extern pointer actual_box_width(pointer r, scaled base_width); -/* from luanode.c */ +typedef struct _subtype_info { + int id; + const char *name; + int lua; +} subtype_info; + +typedef struct _field_info { + const char *name; + int lua; +} field_info; typedef struct _node_info { int id; int size; - const char **fields; + subtype_info *subtypes; + field_info *fields; const char *name; int etex; + int lua; } node_info; extern node_info node_data[]; extern node_info whatsit_node_data[]; -extern const char *node_subtypes_glue[]; -extern const char *node_subtypes_mathglue[]; -extern const char *node_subtypes_leader[]; -extern const char *node_subtypes_fill[]; -extern const char *node_subtypes_boundary[]; -extern const char *node_subtypes_penalty[]; -extern const char *node_subtypes_kern[]; -extern const char *node_subtypes_rule[]; -extern const char *node_subtypes_glyph[]; -extern const char *node_subtypes_disc[]; -extern const char *node_subtypes_marginkern[]; -extern const char *node_subtypes_list[]; -extern const char *node_subtypes_adjust[]; -extern const char *node_subtypes_math[]; -extern const char *node_subtypes_noad[]; -extern const char *node_subtypes_radical[]; -extern const char *node_subtypes_accent[]; -extern const char *node_subtypes_fence[]; - -extern const char *node_subtypes_pdf_destination[]; -extern const char *node_subtypes_pdf_literal[]; +extern subtype_info node_subtypes_dir[]; +extern subtype_info node_subtypes_glue[]; +extern subtype_info node_subtypes_mathglue[]; +extern subtype_info node_subtypes_leader[]; +extern subtype_info node_subtypes_boundary[]; +extern subtype_info node_subtypes_penalty[]; +extern subtype_info node_subtypes_kern[]; +extern subtype_info node_subtypes_rule[]; +extern subtype_info node_subtypes_glyph[]; +extern subtype_info node_subtypes_disc[]; +extern subtype_info node_subtypes_marginkern[]; +extern subtype_info node_subtypes_list[]; +extern subtype_info node_subtypes_adjust[]; +extern subtype_info node_subtypes_math[]; +extern subtype_info node_subtypes_noad[]; +extern subtype_info node_subtypes_radical[]; +extern subtype_info node_subtypes_accent[]; +extern subtype_info node_subtypes_fence[]; + +extern subtype_info node_values_pdf_destination[]; +extern subtype_info node_values_pdf_literal[]; +extern subtype_info node_values_pdf_literal[]; +extern subtype_info node_values_pdf_action[]; +extern subtype_info node_values_pdf_window[]; + +extern subtype_info node_values_fill[]; +extern subtype_info node_values_dir[]; +extern subtype_info node_values_color_stack[]; + +extern subtype_info other_values_page_states[]; extern halfword new_node(int i, int j); extern void flush_node_list(halfword); @@ -958,7 +1072,7 @@ extern void show_node_wrapup_dvi(halfword); extern void show_node_wrapup_pdf(halfword); typedef enum { - normal_g = 0, + normal_g = 0, /* normal */ sfi, fil, fill, @@ -1037,5 +1151,8 @@ extern void synctex_set_no_files(int flag); extern int synctex_get_no_files(void); extern int synctex_get_line(void); +extern void l_set_node_data(void) ; +extern void l_set_whatsit_data(void) ; + #endif diff --git a/Build/source/texk/web2c/luatexdir/tex/textoken.h b/Build/source/texk/web2c/luatexdir/tex/textoken.h index 4f46a48c819..4b33b099ab3 100644 --- a/Build/source/texk/web2c/luatexdir/tex/textoken.h +++ b/Build/source/texk/web2c/luatexdir/tex/textoken.h @@ -25,19 +25,19 @@ # define null 0 # define cs_token_flag 0x1FFFFFFF -# define left_brace_token 0x200000 /* $2^{21}\cdot|left_brace|$ */ -# define right_brace_token 0x400000 /* $2^{21}\cdot|right_brace|$ */ -# define left_brace_limit 0x400000 /* $2^{21}\cdot(|left_brace|+1)$ */ -# define right_brace_limit 0x600000 /* $2^{21}\cdot(|right_brace|+1)$ */ -# define math_shift_token 0x600000 /* $2^{21}\cdot|math_shift|$ */ -# define tab_token 0x800000 /* $2^{21}\cdot|tab_mark|$ */ -# define out_param_token 0xA00000 /* $2^{21}\cdot|out_param|$ */ -# define space_token 0x1400020 /* $2^{21}\cdot|spacer|+|" "|$ */ -# define letter_token 0x1600000 /* $2^{21}\cdot|letter|$ */ -# define other_token 0x1800000 /* $2^{21}\cdot|other_char|$ */ -# define match_token 0x1A00000 /* $2^{21}\cdot|match|$ */ -# define end_match_token 0x1C00000 /* $2^{21}\cdot|end_match|$ */ -# define protected_token 0x1C00001 /* $2^{21}\cdot|end_match|+1$ */ +# define left_brace_token 0x0200000 /* $2^{21}\cdot|left_brace|$ */ +# define right_brace_token 0x0400000 /* $2^{21}\cdot|right_brace|$ */ +# define left_brace_limit 0x0400000 /* $2^{21}\cdot(|left_brace|+1)$ */ +# define right_brace_limit 0x0600000 /* $2^{21}\cdot(|right_brace|+1)$ */ +# define math_shift_token 0x0600000 /* $2^{21}\cdot|math_shift|$ */ +# define tab_token 0x0800000 /* $2^{21}\cdot|tab_mark|$ */ +# define out_param_token 0x0A00000 /* $2^{21}\cdot|out_param|$ */ +# define space_token 0x1400020 /* $2^{21}\cdot|spacer|+|" "|$ */ +# define letter_token 0x1600000 /* $2^{21}\cdot|letter|$ */ +# define other_token 0x1800000 /* $2^{21}\cdot|other_char|$ */ +# define match_token 0x1A00000 /* $2^{21}\cdot|match|$ */ +# define end_match_token 0x1C00000 /* $2^{21}\cdot|end_match|$ */ +# define protected_token 0x1C00001 /* $2^{21}\cdot|end_match|+1$ */ # include "tex/stringpool.h" @@ -126,6 +126,7 @@ extern void make_token_table(lua_State * L, int cmd, int chr, int cs); extern void get_next(void); extern void check_outer_validity(void); extern boolean scan_keyword(const char *); +extern boolean scan_keyword_case_sensitive(const char *); extern halfword active_to_cs(int, int); extern void get_token_lua(void); halfword string_to_toks(const char *); @@ -183,4 +184,6 @@ extern void free_lstring(lstring * ls); # define token_chr(A) ((A) & (STRING_OFFSET - 1)) # define token_val(A,B) (((A)<<STRING_OFFSET_BITS)+(B)) +extern void l_set_token_data(void) ; + #endif diff --git a/Build/source/texk/web2c/luatexdir/unilib/gwwiconv.c b/Build/source/texk/web2c/luatexdir/unilib/gwwiconv.c index 3671116cf30..57db98fc7e8 100644 --- a/Build/source/texk/web2c/luatexdir/unilib/gwwiconv.c +++ b/Build/source/texk/web2c/luatexdir/unilib/gwwiconv.c @@ -46,7 +46,8 @@ struct gww_iconv_t { enum encoding to; }; -enum extended_encoding { e_jisgbpk = e_encodingmax }; +/*enum extended_encoding { e_jisgbpk = e_encodingmax };*/ +#define e_jisgbpk e_encodingmax static enum endian { end_big, end_little, end_unknown } endian = end_unknown; diff --git a/Build/source/texk/web2c/mplibdir/ChangeLog b/Build/source/texk/web2c/mplibdir/ChangeLog index 9f69e0665b9..e2c7244ebf0 100644 --- a/Build/source/texk/web2c/mplibdir/ChangeLog +++ b/Build/source/texk/web2c/mplibdir/ChangeLog @@ -1,3 +1,7 @@ +2018-08-27 Luigi Scarso <luigi.scarso@gmail.com> + * separation of mpmathbinary from the the core + + 2018-02-19 Luigi Scarso <luigi.scarso@gmail.com> * Small cleanup of the code * Bump to version 2.0rc2: the current version is 2.00 diff --git a/Build/source/texk/web2c/mplibdir/am/libmplib.am b/Build/source/texk/web2c/mplibdir/am/libmplib.am index 3d57231194f..a4be39e68b7 100644 --- a/Build/source/texk/web2c/mplibdir/am/libmplib.am +++ b/Build/source/texk/web2c/mplibdir/am/libmplib.am @@ -5,15 +5,18 @@ ## libmplib.a, used by MetaPost and luaTeX ## -EXTRA_LIBRARIES += libmplibcore.a libmplibbackends.a +EXTRA_LIBRARIES += libmplibcore.a libmplibextramath.a libmplibbackends.a -libmplibcore_a_CPPFLAGS = $(MPFR_INCLUDES) $(GMP_INCLUDES) $(LIBPNG_INCLUDES) $(ZLIB_INCLUDES) $(AM_CPPFLAGS) -I$(srcdir)/mplibdir + +libmplibcore_a_CPPFLAGS = $(LIBPNG_INCLUDES) $(ZLIB_INCLUDES) $(AM_CPPFLAGS) -I$(srcdir)/mplibdir +libmplibextramath_a_CPPFLAGS = $(MPFR_INCLUDES) $(GMP_INCLUDES) -I${top_builddir}/../../libs $(AM_CPPFLAGS) -I$(srcdir)/mplibdir libmplibbackends_a_CPPFLAGS = $(MPFR_INCLUDES) $(GMP_INCLUDES) $(CAIRO_INCLUDES) $(PIXMAN_INCLUDES) \ $(LIBPNG_INCLUDES) $(ZLIB_INCLUDES) $(AM_CPPFLAGS) -I$(srcdir)/mplibdir -## libmplib C sources core + backends -nodist_libmplibcore_a_SOURCES = tfmin.c $(mp_c_h) $(mpmath_c_h) $(mpmathbinary_c_h) $(mpmathdecimal_c_h) \ +## libmplib C sources core + extramath + backends +nodist_libmplibcore_a_SOURCES = tfmin.c $(mp_c_h) $(mpmath_c_h) $(mpmathdecimal_c_h) \ $(mpmathdouble_c_h) $(mpstrings_c_h) $(psout_c_h) +nodist_libmplibextramath_a_SOURCES = $(mpmathbinary_c_h) nodist_libmplibbackends_a_SOURCES = $(pngout_c_h) $(svgout_c_h) @@ -84,15 +87,16 @@ libmplib_web += mplibdir/mpmath.w mplibdir/mpmathbinary.w mplibdir/mpmathdecimal libmplib_web += mplibdir/mpmathdouble.w mplibdir/mpstrings.w mplibdir/tfmin.w ## core need headers backends -$(nodist_libmplibcore_a_SOURCES): $(svgout_c_h) $(pngout_c_h) +$(nodist_libmplibcore_a_SOURCES): $(mpmathbinary_c_h) $(svgout_c_h) $(pngout_c_h) -$(libmplibcore_a_OBJECTS): $(nodist_libmplibcore_a_SOURCES) $(KPATHSEA_DEPEND) $(MPFR_DEPEND) +$(libmplibcore_a_OBJECTS): $(nodist_libmplibcore_a_SOURCES) $(KPATHSEA_DEPEND) +$(libmplibextramath_a_OBJECTS): $(nodist_libmplibextramath_a_SOURCES) $(KPATHSEA_DEPEND) $(MPFR_DEPEND) $(libmplibbackends_a_OBJECTS): $(nodist_libmplibbackends_a_SOURCES) $(KPATHSEA_DEPEND) $(CAIRO_DEPEND) $(MPFR_DEPEND) EXTRA_DIST += $(libmplib_web) -DISTCLEANFILES += $(nodist_libmplibcore_a_SOURCES) $(nodist_libmplibbackends_a_SOURCES) \ - mp-tangle mpmath-tangle mpmathbinary-tangle mpmathdecimal-tangle mpmathdouble-tangle \ +DISTCLEANFILES += $(nodist_libmplibcore_a_SOURCES) $(nodist_libmplibextramath_a_SOURCES) $(nodist_libmplibbackends_a_SOURCES) \ + mp-tangle mpmath-tangle mpmathdecimal-tangle mpmathdouble-tangle \ mpstrings-tangle psout-tangle svgout-tangle pngout-tangle diff --git a/Build/source/texk/web2c/mplibdir/am/mplib.am b/Build/source/texk/web2c/mplibdir/am/mplib.am index f58658de18f..10b1fe4aa44 100644 --- a/Build/source/texk/web2c/mplibdir/am/mplib.am +++ b/Build/source/texk/web2c/mplibdir/am/mplib.am @@ -18,9 +18,7 @@ endif MP EXTRA_PROGRAMS += mpost mpost_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_INCLUDES) $(LIBPNG_INCLUDES) -I$(srcdir)/mplibdir -#mpost_LDADD = libmplib.a $(KPATHSEA_LIBS) $(MPFR_LIBS) $(GMP_LIBS) \ -# $(CAIRO_LIBS) $(PIXMAN_LIBS) $(LIBPNG_LIBS) $(ZLIB_LIBS) libmputil.a -mpost_LDADD = libmplibcore.a libmplibbackends.a $(KPATHSEA_LIBS) $(MPFR_LIBS) $(GMP_LIBS) \ +mpost_LDADD = libmplibcore.a libmplibextramath.a libmplibbackends.a $(KPATHSEA_LIBS) $(MPFR_LIBS) $(GMP_LIBS) \ $(CAIRO_LIBS) $(PIXMAN_LIBS) $(LIBPNG_LIBS) $(ZLIB_LIBS) libmputil.a @@ -60,7 +58,7 @@ mpxout-tangle: ctangle$(EXEEXT) mplibdir/mpxout.w tangle-sh mpost_web = mplibdir/mpost.w mplibdir/mpxout.w #$(mpost_OBJECTS): $(nodist_mpost_SOURCES) libmplib.a $(LIBPNG_DEPEND) -$(mpost_OBJECTS): $(nodist_mpost_SOURCES) libmplibcore.a libmplibbackends.a $(LIBPNG_DEPEND) +$(mpost_OBJECTS): $(nodist_mpost_SOURCES) libmplibcore.a libmplibextramath.a libmplibbackends.a $(LIBPNG_DEPEND) EXTRA_DIST += mplibdir/ChangeLog $(mpost_web) diff --git a/Build/source/texk/web2c/mplibdir/lmplib.c b/Build/source/texk/web2c/mplibdir/lmplib.c index d90482b887e..eb8432bb507 100644 --- a/Build/source/texk/web2c/mplibdir/lmplib.c +++ b/Build/source/texk/web2c/mplibdir/lmplib.c @@ -15,7 +15,9 @@ License for more details. You should have received a copy of the GNU Lesser General Public License along - with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */ + with LuaTeX; if not, see <http://www.gnu.org/licenses/>. + +*/ #include <w2c/config.h> #include <stdlib.h> @@ -23,7 +25,7 @@ #ifdef HAVE_UNISTD_H #include <unistd.h> #endif -#include <math.h> /* temporary */ +#include <math.h> #ifndef pdfTeX # include <lua.h> @@ -41,20 +43,23 @@ #define luaL_reg luaL_Reg #endif - #ifndef lua_objlen #define lua_objlen lua_rawlen #endif - #include "mplib.h" #include "mplibps.h" #include "mplibsvg.h" #include "mplibpng.h" -int luaopen_mplib(lua_State * L); /* forward */ +int luaopen_mplib(lua_State * L); -/* metatable identifiers and tests */ +/*tex + + We need a few metatable identifiers in order to access the metatables for the + main object and result userdata. + +*/ #define MPLIB_METATABLE "MPlib.meta" #define MPLIB_FIG_METATABLE "MPlib.fig" @@ -64,25 +69,33 @@ int luaopen_mplib(lua_State * L); /* forward */ #define is_fig(L,b) (struct mp_edge_object **)luaL_checkudata(L,b,MPLIB_FIG_METATABLE) #define is_gr_object(L,b) (struct mp_graphic_object **)luaL_checkudata(L,b,MPLIB_GR_METATABLE) -/* Lua string pre-hashing */ +/*tex -#define mplib_init_S(a) do { \ - lua_pushliteral(L,#a); \ - mplib_##a##_ptr = lua_tostring(L,-1); \ - mplib_##a##_index = luaL_ref (L,LUA_REGISTRYINDEX); \ - } while (0) + We pre-hash the \LUA\ strings which is much faster. The approach is similar to the one + used at the \TEX\ end. -#define mplib_push_S(a) do { \ - lua_rawgeti(L,LUA_REGISTRYINDEX,mplib_##a##_index); \ - } while (0) +*/ + +#define mplib_init_S(a) do { \ + lua_pushliteral(L,#a); \ + mplib_##a##_ptr = lua_tostring(L,-1); \ + mplib_##a##_index = luaL_ref (L,LUA_REGISTRYINDEX); \ +} while (0) + +#define mplib_push_S(a) do { \ + lua_rawgeti(L,LUA_REGISTRYINDEX,mplib_##a##_index); \ +} while (0) -#define mplib_is_S(a,i) (mplib_##a##_ptr==lua_tostring(L,i)) +#define mplib_is_S(a,i) \ + (mplib_##a##_ptr==lua_tostring(L,i)) -#define mplib_make_S(a) \ - static int mplib_##a##_index = 0; \ - static const char *mplib_##a##_ptr = NULL +#define mplib_make_S(a) \ + static int mplib_##a##_index = 0; \ + static const char *mplib_##a##_ptr = NULL -static int mplib_type_Ses[mp_special_code + 1] = { 0 }; /* [0] is not used */ +/*tex In the next array entry 0 is not used */ + +static int mplib_type_Ses[mp_special_code + 1] = { 0 }; mplib_make_S(term); mplib_make_S(error); @@ -94,6 +107,7 @@ mplib_make_S(memory); mplib_make_S(hash); mplib_make_S(params); mplib_make_S(open); +mplib_make_S(cycle); mplib_make_S(offset); mplib_make_S(dashes); @@ -153,6 +167,7 @@ static void mplib_init_Ses(lua_State * L) mplib_init_S(hash); mplib_init_S(params); mplib_init_S(open); + mplib_init_S(cycle); mplib_init_S(offset); mplib_init_S(dashes); @@ -210,11 +225,15 @@ static void mplib_init_Ses(lua_State * L) mplib_init_S(elliptical); } +/*tex + + Here are some enumeration arrays to map MPlib enums to \LUA\ strings. If needed + we can also predefine keys here, as we do with nodes. -/* Enumeration arrays to map MPlib enums to Lua strings */ +*/ static const char *math_options[] = - { "scaled", "double", "binary", "decimal", NULL }; + { "scaled", "double", "binary", "decimal", NULL }; static const char *interaction_options[] = { "unknown", "batch", "nonstop", "scroll", "errorstop", NULL }; @@ -255,18 +274,34 @@ static const char *stop_clip_fields[] = static const char *no_fields[] = { NULL }; +/*tex -/* The list of supported MPlib options (not all make sense) */ + The list of supported MPlib options (not all make sense). + +*/ typedef enum { - P_ERROR_LINE, P_MAX_LINE, P_RANDOM_SEED, P_MATH_MODE, - P_INTERACTION, P_INI_VERSION, P_MEM_NAME, P_JOB_NAME, P_FIND_FILE, - P_RUN_SCRIPT, P_MAKE_TEXT, P_SCRIPT_ERROR, P_EXTENSIONS, - P__SENTINEL } mplib_parm_idx; + P_ERROR_LINE, + P_MAX_LINE, + P_RANDOM_SEED, + P_MATH_MODE, + P_INTERACTION, + P_INI_VERSION, + P_MEM_NAME, + P_JOB_NAME, + P_FIND_FILE, + P_RUN_SCRIPT, + P_MAKE_TEXT, + P_SCRIPT_ERROR, + P_EXTENSIONS, + P__SENTINEL +} mplib_parm_idx; typedef struct { - const char *name; /* parameter name */ - mplib_parm_idx idx; /* parameter index */ + /*tex parameter name */ + const char *name; + /*tex parameter index */ + mplib_parm_idx idx; } mplib_parm_struct; static mplib_parm_struct mplib_parms[] = { @@ -284,10 +319,11 @@ static mplib_parm_struct mplib_parms[] = { {NULL, P__SENTINEL } }; +/*tex -/* Start by defining the needed callback routines for the library */ + We start by defining the needed callback routines for the library. -/* todo: make subtable in registry, beware, for all mp instances */ +*/ static char *mplib_find_file(MP mp, const char *fname, const char *fmode, int ftype) { @@ -300,7 +336,7 @@ static char *mplib_find_file(MP mp, const char *fname, const char *fmode, int ft lua_pushstring(L, fname); lua_pushstring(L, fmode); if (ftype >= mp_filetype_text) { - lua_pushnumber(L, (lua_Number)(ftype - mp_filetype_text)); + lua_pushinteger(L, (ftype - mp_filetype_text)); } else { lua_pushstring(L, mplib_filetype_names[ftype]); } @@ -311,7 +347,8 @@ static char *mplib_find_file(MP mp, const char *fname, const char *fmode, int ft x = lua_tostring(L, -1); if (x != NULL) s = strdup(x); - lua_pop(L, 1); /* pop the string */ + /*tex pop the string */ + lua_pop(L, 1); return s; } else { lua_pop(L, 1); @@ -325,7 +362,8 @@ static char *mplib_find_file(MP mp, const char *fname, const char *fmode, int ft static int mplib_find_file_function(lua_State * L) { if (!(lua_isfunction(L, -1) || lua_isnil(L, -1))) { - return 1; /* error */ + /*tex An error. */ + return 1; } lua_pushstring(L, "mplib.file_finder"); lua_pushvalue(L, -2); @@ -333,6 +371,11 @@ static int mplib_find_file_function(lua_State * L) return 0; } +static void mplib_warning(const char *str) +{ + fprintf(stdout,"mplib warning: %s\n",str); +} + static void mplib_script_error(MP mp, const char *str) { lua_State *L = (lua_State *)mp_userdata(mp); @@ -340,9 +383,10 @@ static void mplib_script_error(MP mp, const char *str) lua_getfield(L, LUA_REGISTRYINDEX, "mplib.script_error"); if (lua_isfunction(L, -1)) { lua_pushstring(L, str); - lua_pcall(L, 1, 0, 0); /* assume the function is ok */ + /*tex We assume that the function is okay. */ + lua_pcall(L, 1, 0, 0); } else { - fprintf(stdout,"Error in script: %s\n",str); + mplib_warning(str); lua_pop(L, 1); } } @@ -350,7 +394,8 @@ static void mplib_script_error(MP mp, const char *str) static int mplib_script_error_function(lua_State * L) { if (!(lua_isfunction(L, -1) || lua_isnil(L, -1))) { - return 1; /* error */ + /*tex An error. */ + return 1; } lua_pushstring(L, "mplib.script_error"); lua_pushvalue(L, -2); @@ -368,13 +413,14 @@ static char *mplib_run_script(MP mp, const char *str) const char *x = NULL; lua_pushstring(L, str); if (lua_pcall(L, 1, 1, 0) != 0) { - mplib_script_error(mp, lua_tostring(L, -1)); + fprintf(stdout,"mplib warning: error in script: %s\n",lua_tostring(L, -1)); return NULL; } x = lua_tostring(L, -1); if (x != NULL) s = strdup(x); - lua_pop(L, 1); /* pop the string */ + /*tex Pop the string. */ + lua_pop(L, 1); return s; } else { lua_pop(L, 1); @@ -385,7 +431,7 @@ static char *mplib_run_script(MP mp, const char *str) static int mplib_run_script_function(lua_State * L) { if (!(lua_isfunction(L, -1) || lua_isnil(L, -1))) { - return 1; /* error */ + return 1; /* error */ } lua_pushstring(L, "mplib.run_script"); lua_pushvalue(L, -2); @@ -410,7 +456,8 @@ static char *mplib_make_text(MP mp, const char *str, int mode) x = lua_tostring(L, -1); if (x != NULL) s = strdup(x); - lua_pop(L, 1); /* pop the string */ + /*tex Pop the string. */ + lua_pop(L, 1); return s; } else { lua_pop(L, 1); @@ -421,7 +468,8 @@ static char *mplib_make_text(MP mp, const char *str, int mode) static int mplib_make_text_function(lua_State * L) { if (!(lua_isfunction(L, -1) || lua_isnil(L, -1))) { - return 1; /* error */ + /*tex An error. */ + return 1; } lua_pushstring(L, "mplib.make_text"); lua_pushvalue(L, -2); @@ -487,7 +535,8 @@ static int mplib_new(lua_State * L) int i; struct MP_options *options = mp_options(); options->userdata = (void *) L; - options->noninteractive = 1; /* required ! */ + /*tex Required: */ + options->noninteractive = 1; options->extensions = 0 ; options->find_file = mplib_find_file; options->run_script = mplib_run_script; @@ -500,56 +549,59 @@ static int mplib_new(lua_State * L) lua_getfield(L, 1, mplib_parms[i].name); if (lua_isnil(L, -1)) { lua_pop(L, 1); - continue; /* skip unset */ + continue; } switch (mplib_parms[i].idx) { - case P_ERROR_LINE: - options->error_line = (int)lua_tointeger(L, -1); - if (options->error_line<60) options->error_line =60; - if (options->error_line>250) options->error_line = 250; - options->half_error_line = (options->error_line/2)+10; - break; - case P_MAX_LINE: - options->max_print_line = (int)lua_tointeger(L, -1); - if (options->max_print_line<60) options->max_print_line = 60; - break; - case P_RANDOM_SEED: - options->random_seed = (int)lua_tointeger(L, -1); - break; - case P_INTERACTION: - options->interaction = luaL_checkoption(L, -1, "errorstopmode", interaction_options); - break; - case P_MATH_MODE: - options->math_mode = luaL_checkoption(L, -1, "scaled", math_options); - break; - case P_JOB_NAME: - options->job_name = strdup(lua_tostring(L, -1)); - break; - case P_FIND_FILE: - if (mplib_find_file_function(L)) { /* error here */ - fprintf(stdout,"Invalid arguments to mp.new { find_file = ... }\n"); - } - break; - case P_RUN_SCRIPT: - if (mplib_run_script_function(L)) { /* error here */ - fprintf(stdout,"Invalid arguments to mp.new { run_script = ... }\n"); - } - break; - case P_MAKE_TEXT: - if (mplib_make_text_function(L)) { /* error here */ - fprintf(stdout,"Invalid arguments to mp.new { make_text = ... }\n"); - } - break; - case P_SCRIPT_ERROR: - if (mplib_script_error_function(L)) { /* error here */ - fprintf(stdout,"Invalid arguments to mp.new { script_error = ... }\n"); - } - break; - case P_EXTENSIONS: - options->extensions = (int)lua_tointeger(L, -1); - break; - default: - break; + case P_ERROR_LINE: + options->error_line = (int)lua_tointeger(L, -1); + if (options->error_line < 60) + options->error_line = 60; + if (options->error_line > 250) + options->error_line = 250; + options->half_error_line = (options->error_line/2)+10; + break; + case P_MAX_LINE: + options->max_print_line = (int)lua_tointeger(L, -1); + if (options->max_print_line < 60) + options->max_print_line = 60; + break; + case P_RANDOM_SEED: + options->random_seed = (int)lua_tointeger(L, -1); + break; + case P_INTERACTION: + options->interaction = luaL_checkoption(L, -1, "errorstopmode", interaction_options); + break; + case P_MATH_MODE: + options->math_mode = luaL_checkoption(L, -1, "scaled", math_options); + break; + case P_JOB_NAME: + options->job_name = strdup(lua_tostring(L, -1)); + break; + case P_FIND_FILE: + if (mplib_find_file_function(L)) { + mplib_warning("function expected for 'find_file'"); + } + break; + case P_RUN_SCRIPT: + if (mplib_run_script_function(L)) { + mplib_warning("function expected for 'run_script'"); + } + break; + case P_MAKE_TEXT: + if (mplib_make_text_function(L)) { + mplib_warning("function expected for 'make_text'"); + } + break; + case P_SCRIPT_ERROR: + if (mplib_script_error_function(L)) { + mplib_warning("function expected for 'script_error'"); + } + break; + case P_EXTENSIONS: + options->extensions = (int)lua_tointeger(L, -1); + break; + default: + break; } lua_pop(L, 1); } @@ -626,7 +678,7 @@ static int mplib_wrapresults(lua_State * L, mp_run_data *res, int status) res->edges = NULL; } mplib_push_S(status); - lua_pushnumber(L, (lua_Number)status); + lua_pushinteger(L, status); lua_rawset(L,-3); return 1; } @@ -716,16 +768,16 @@ static int mplib_statistics(lua_State * L) if (*mp_ptr != NULL) { lua_newtable(L); mplib_push_S(memory); - lua_pushnumber(L, (lua_Number)mp_memory_usage(*mp_ptr)); + lua_pushinteger(L, mp_memory_usage(*mp_ptr)); lua_rawset(L,-3); mplib_push_S(hash); - lua_pushnumber(L, (lua_Number)mp_hash_usage(*mp_ptr)); + lua_pushinteger(L, mp_hash_usage(*mp_ptr)); lua_rawset(L,-3); mplib_push_S(params); - lua_pushnumber(L, (lua_Number)mp_param_usage(*mp_ptr)); + lua_pushinteger(L, mp_param_usage(*mp_ptr)); lua_rawset(L,-3); mplib_push_S(open); - lua_pushnumber(L, (lua_Number)mp_open_usage(*mp_ptr)); + lua_pushinteger(L, mp_open_usage(*mp_ptr)); lua_rawset(L,-3); } else { lua_pushnil(L); @@ -733,7 +785,6 @@ static int mplib_statistics(lua_State * L) return 1; } - static int set_direction (lua_State * L, MP mp, mp_knot p) { double direction_x = 0, direction_y = 0; direction_x = (double)lua_tonumber(L,-1); @@ -821,8 +872,8 @@ static int set_right_control (lua_State * L, MP mp, mp_knot p) { return 1; } - #if 0 + #define ROUNDED_ZERO(v) (fabs((v))<0.00001 ? 0 : (v)) #define PI 3.1415926535897932384626433832795028841971 #define RADIANS(a) (mp_number_as_double(mp,(a)) / 16.0) * PI/180.0 @@ -915,6 +966,7 @@ void mp_dump_path (MP mp, mp_knot h) { printf("cycle"); printf (";\n"); } + #endif static int mplib_solve_path(lua_State * L) @@ -938,10 +990,8 @@ static int mplib_solve_path(lua_State * L) mp = *mp_ptr; cyclic = lua_toboolean(L,3); lua_pop(L,1); - - /* build up the path */ + /*tex We build up the path. */ numpoints = lua_objlen(L,2); - first = p = NULL; for (i=1;i<=numpoints;i++) { int left_set = 0, right_set = 0; @@ -951,7 +1001,6 @@ static int mplib_solve_path(lua_State * L) errormsg = "Wrong argument types"; goto BAD; } - mplib_push_S(x_coord); lua_rawget(L,-2); if (!lua_isnumber(L,-1)) { @@ -960,7 +1009,6 @@ static int mplib_solve_path(lua_State * L) } x_coord = (double)lua_tonumber(L,-1); lua_pop(L,1); - mplib_push_S(y_coord); lua_rawget(L,-2); if (!lua_isnumber(L,-1)) { @@ -969,11 +1017,14 @@ static int mplib_solve_path(lua_State * L) } y_coord = (double)lua_tonumber(L,-1); lua_pop(L,1); - q = p; if (q!=NULL) { - /* we have to save the right_tension because |mp_append_knot| trashes - it, believing that it is as yet uninitialized */ + /*tex + + We have to save the right_tension because |mp_append_knot| + trashes it, believing that it is as yet uninitialized. + + */ double saved_tension = mp_number_as_double(mp, mp_knot_right_tension(mp,p)); p = mp_append_knot(mp, p, x_coord, y_coord); if ( ! p ) { @@ -988,10 +1039,8 @@ static int mplib_solve_path(lua_State * L) goto BAD; } } - if (first == NULL) first = p; - mplib_push_S(left_curl); lua_rawget(L,-2); if (lua_isnumber(L,-1)) { @@ -1001,9 +1050,9 @@ static int mplib_solve_path(lua_State * L) } left_set = 1; } else { - lua_pop(L,1); /* a nil value */ + /*tex A |nil| value. */ + lua_pop(L,1); } - mplib_push_S(left_tension); lua_rawget(L,-2); if (lua_isnumber(L,-1)) { @@ -1018,9 +1067,9 @@ static int mplib_solve_path(lua_State * L) left_set = 1; } } else { - lua_pop(L,1); /* a nil value */ + /*tex A |nil| value. */ + lua_pop(L,1); } - mplib_push_S(left_x); lua_rawget(L,-2); if (lua_isnumber(L,-1)) { @@ -1036,7 +1085,6 @@ static int mplib_solve_path(lua_State * L) } else { lua_pop(L,1); } - mplib_push_S(right_curl); lua_rawget(L,-2); if (lua_isnumber(L,-1)) { @@ -1046,9 +1094,9 @@ static int mplib_solve_path(lua_State * L) } right_set = 1; } else { - lua_pop(L,1); /* a nil value */ + /*tex A |nil| value. */ + lua_pop(L,1); } - mplib_push_S(right_tension); lua_rawget(L,-2); if (lua_isnumber(L,-1)) { @@ -1065,7 +1113,6 @@ static int mplib_solve_path(lua_State * L) } else { lua_pop(L,1); } - mplib_push_S(right_x); lua_rawget(L,-2); if (lua_isnumber(L,-1)) { @@ -1081,7 +1128,6 @@ static int mplib_solve_path(lua_State * L) } else { lua_pop(L,1); } - mplib_push_S(direction_x); lua_rawget(L,-2); if (lua_isnumber(L,-1)) { @@ -1090,12 +1136,12 @@ static int mplib_solve_path(lua_State * L) goto BAD; } } else { - lua_pop(L,1); /* a nil value */ + /*tex A |nil| value. */ + lua_pop(L,1); } - - lua_pop(L,1); /* done with this item */ + /*tex Up the next item */ + lua_pop(L,1); } - if (cyclic) { mp_close_path_cycle (mp, p, first); } else { @@ -1104,12 +1150,12 @@ static int mplib_solve_path(lua_State * L) #if 0 mp_dump_path(mp,first); #endif - /* finished reading arguments */ + /*tex We're finished reading arguments. */ if (!mp_solve_path(mp,first)) { errormsg = "Failed to solve the path"; goto BAD; } - /* squeeze the new values back into the table */ + /*tex Squeeze the new values back into the table. */ p = first; for (i=1;i<=numpoints;i++) { lua_rawgeti(L,-1, i); @@ -1117,14 +1163,14 @@ static int mplib_solve_path(lua_State * L) mplib_push_S(left_y); lua_pushnumber(L, mp_number_as_double(mp, mp_knot_left_y(mp, p))); lua_rawset(L,-3); mplib_push_S(right_x); lua_pushnumber(L, mp_number_as_double(mp, mp_knot_right_x(mp, p))); lua_rawset(L,-3); mplib_push_S(right_y); lua_pushnumber(L, mp_number_as_double(mp, mp_knot_right_y(mp, p))); lua_rawset(L,-3); - /* is this really needed */ - mplib_push_S(left_tension); lua_pushnil(L); lua_rawset(L,-3); - mplib_push_S(right_tension); lua_pushnil(L); lua_rawset(L,-3); - mplib_push_S(left_curl); lua_pushnil(L); lua_rawset(L,-3); - mplib_push_S(right_curl); lua_pushnil(L); lua_rawset(L,-3); - mplib_push_S(direction_x); lua_pushnil(L); lua_rawset(L,-3); - mplib_push_S(direction_y); lua_pushnil(L); lua_rawset(L,-3); - /* till here */ + /*tex This is a bit overkill \unknown */ + mplib_push_S(left_tension); lua_pushnil(L); lua_rawset(L,-3); + mplib_push_S(right_tension); lua_pushnil(L); lua_rawset(L,-3); + mplib_push_S(left_curl); lua_pushnil(L); lua_rawset(L,-3); + mplib_push_S(right_curl); lua_pushnil(L); lua_rawset(L,-3); + mplib_push_S(direction_x); lua_pushnil(L); lua_rawset(L,-3); + mplib_push_S(direction_y); lua_pushnil(L); lua_rawset(L,-3); + /*tex \unknown\ till here. */ mplib_push_S(left_type); lua_pushstring(L, knot_type_enum[mp_knot_left_type(mp, p)]); lua_rawset(L, -3); mplib_push_S(right_type); lua_pushstring(L, knot_type_enum[mp_knot_right_type(mp, p)]); lua_rawset(L, -3); lua_pop(L,1); @@ -1132,7 +1178,7 @@ static int mplib_solve_path(lua_State * L) } lua_pushboolean(L, 1); return 1; -BAD: + BAD: if (p != NULL) { mp_close_path (mp, p, first); mp_free_path (mp, p); @@ -1142,7 +1188,11 @@ BAD: return 2; } -/* figure methods */ +/*tex + + The next methods are for collecting the results from |fig|. + +*/ static int mplib_fig_collect(lua_State * L) { @@ -1171,7 +1221,8 @@ static int mplib_fig_body(lua_State * L) i++; p = p->next; } - (*hh)->body = NULL; /* prevent double free */ + /*tex Prevent a double free: */ + (*hh)->body = NULL; return 1; } @@ -1233,7 +1284,6 @@ static int mplib_fig_svg(lua_State * L) return 1; } - static int mplib_fig_png(lua_State * L) { mp_run_data *res; @@ -1316,8 +1366,6 @@ static int mplib_fig_charcode(lua_State * L) return 1; } - - static int mplib_fig_bb(lua_State * L) { struct mp_edge_object **hh = is_fig(L, 1); @@ -1333,7 +1381,11 @@ static int mplib_fig_bb(lua_State * L) return 1; } -/* object methods */ +/*tex + + The methods for the figure objects plus a few helpers. + +*/ static int mplib_gr_collect(lua_State * L) { @@ -1413,7 +1465,6 @@ static double coord_range_y (mp_gr_knot h, double dz) { return (zhi - zlo <= dz ? aspect_bound : aspect_default); } - static int mplib_gr_peninfo(lua_State * L) { double x_coord, y_coord, left_x, left_y, right_x, right_y; double wx, wy; @@ -1481,6 +1532,13 @@ static int mplib_gr_peninfo(lua_State * L) { return 1; } +/*tex + + Here is a helper that reports the valid field names of the possible + objects. + +*/ + static int mplib_gr_fields(lua_State * L) { const char **fields; @@ -1526,7 +1584,6 @@ static int mplib_gr_fields(lua_State * L) return 1; } - #define mplib_push_number(L,x) lua_pushnumber(L,(lua_Number)(x)) #define MPLIB_PATH 0 @@ -1534,7 +1591,7 @@ static int mplib_gr_fields(lua_State * L) static void mplib_push_path(lua_State * L, mp_gr_knot h, int is_pen) { - mp_gr_knot p; /* for scanning the path */ + mp_gr_knot p; int i = 1; p = h; if (p != NULL) { @@ -1583,16 +1640,63 @@ static void mplib_push_path(lua_State * L, mp_gr_knot h, int is_pen) } } -/* this assumes that the top of the stack is a table - or nil already in the case +static int mplib_get_path(lua_State * L) +{ + MP *mp = is_mp(L, 1); + if (*mp != NULL) { + size_t l; + const char *s = lua_tolstring(L, 2, &l); + if (s != NULL) { + mp_knot p = mp_get_path_value(*mp,s,l) ; + if (p != NULL) { + int i = 1; + mp_knot h = p; + lua_newtable(L); + do { + lua_createtable(L, 6, 1); + mplib_push_number(L, mp_number_as_double(*mp,p->x_coord)); + lua_rawseti(L,-2,1); + mplib_push_number(L, mp_number_as_double(*mp,p->y_coord)); + lua_rawseti(L,-2,2); + mplib_push_number(L, mp_number_as_double(*mp,p->left_x)); + lua_rawseti(L,-2,3); + mplib_push_number(L, mp_number_as_double(*mp,p->left_y)); + lua_rawseti(L,-2,4); + mplib_push_number(L, mp_number_as_double(*mp,p->right_x)); + lua_rawseti(L,-2,5); + mplib_push_number(L, mp_number_as_double(*mp,p->right_y)); + lua_rawseti(L,-2,6); + lua_rawseti(L,-2, i); + i++; + if (p->data.types.right_type == mp_endpoint) { + mplib_push_S(cycle); + lua_pushboolean(L,0); + lua_rawset(L,-3); + return 1; + } + p = p->next; + } while (p != h); + mplib_push_S(cycle); + lua_pushboolean(L,1); + lua_rawset(L,-3); + return 1; + } + } + } + return 0; +} + +/*tex + + This assumes that the top of the stack is a table or nil already in the case. */ static void mplib_push_pentype(lua_State * L, mp_gr_knot h) { - mp_gr_knot p; /* for scanning the path */ + mp_gr_knot p; p = h; if (p == NULL) { - /* do nothing */ + /*tex Do nothing. */ } else if (p == p->next) { mplib_push_S(type); mplib_push_S(elliptical); @@ -1643,7 +1747,11 @@ static void mplib_push_color(lua_State * L, struct mp_graphic_object *p) } } -/* the dash scale is not exported, the field has no external value */ +/*tex + + The dash scale is not exported, the field has no external value. + +*/ static void mplib_push_dash(lua_State * L, struct mp_stroked_object *h) { @@ -1811,7 +1919,6 @@ static int mplib_gr_index(lua_State * L) struct mp_graphic_object **hh = is_gr_object(L, 1); if (*hh) { struct mp_graphic_object *h = *hh; - if (mplib_is_S(type, 2)) { lua_rawgeti(L, LUA_REGISTRYINDEX, mplib_type_Ses[h->type]); } else { @@ -1847,61 +1954,77 @@ static int mplib_gr_index(lua_State * L) } static const struct luaL_reg mplib_meta[] = { - {"__gc", mplib_collect}, - {"__tostring", mplib_tostring}, - {NULL, NULL} /* sentinel */ + { "__gc", mplib_collect }, + { "__tostring", mplib_tostring }, + /*tex sentinel */ + { NULL, NULL} }; static const struct luaL_reg mplib_fig_meta[] = { - {"__gc", mplib_fig_collect}, - {"__tostring", mplib_fig_tostring}, - {"objects", mplib_fig_body}, - {"copy_objects", mplib_fig_copy_body}, - {"filename", mplib_fig_filename}, - {"postscript", mplib_fig_postscript}, - {"png", mplib_fig_png}, - {"svg", mplib_fig_svg}, - {"boundingbox", mplib_fig_bb}, - {"width", mplib_fig_width}, - {"height", mplib_fig_height}, - {"depth", mplib_fig_depth}, - {"italcorr", mplib_fig_italcorr}, - {"charcode", mplib_fig_charcode}, - {NULL, NULL} /* sentinel */ + { "__gc", mplib_fig_collect }, + { "__tostring", mplib_fig_tostring }, + { "objects", mplib_fig_body }, + { "copy_objects", mplib_fig_copy_body }, + { "filename", mplib_fig_filename }, + { "postscript", mplib_fig_postscript }, + { "png", mplib_fig_png }, + { "svg", mplib_fig_svg }, + { "boundingbox", mplib_fig_bb }, + { "width", mplib_fig_width }, + { "height", mplib_fig_height }, + { "depth", mplib_fig_depth }, + { "italcorr", mplib_fig_italcorr }, + { "charcode", mplib_fig_charcode }, + /*tex sentinel */ + { NULL, NULL} }; static const struct luaL_reg mplib_gr_meta[] = { - {"__gc", mplib_gr_collect}, - {"__tostring", mplib_gr_tostring}, - {"__index", mplib_gr_index}, - {NULL, NULL} /* sentinel */ + { "__gc", mplib_gr_collect}, + { "__tostring", mplib_gr_tostring}, + { "__index", mplib_gr_index}, + /*tex sentinel */ + { NULL, NULL} }; static const struct luaL_reg mplib_d[] = { - {"execute", mplib_execute}, - {"finish", mplib_finish}, - {"char_width", mplib_charwidth}, - {"char_height", mplib_charheight}, - {"char_depth", mplib_chardepth}, - {"statistics", mplib_statistics}, - {"solve_path", mplib_solve_path}, - {"get_numeric", mplib_get_numeric}, - {"get_number", mplib_get_numeric}, - {"get_boolean", mplib_get_boolean}, - {"get_string", mplib_get_string}, - {NULL, NULL} /* sentinel */ + { "execute", mplib_execute }, + { "finish", mplib_finish }, + { "char_width", mplib_charwidth }, + { "char_height", mplib_charheight }, + { "char_depth", mplib_chardepth }, + { "statistics", mplib_statistics }, + { "solve_path", mplib_solve_path }, + { "get_numeric", mplib_get_numeric }, + { "get_number", mplib_get_numeric }, + { "get_boolean", mplib_get_boolean }, + { "get_string", mplib_get_string }, + { "get_path", mplib_get_path }, + /*tex sentinel */ + {NULL, NULL } }; static const struct luaL_reg mplib_m[] = { - {"new", mplib_new}, - {"version", mplib_version}, - {"fields", mplib_gr_fields}, - {"pen_info", mplib_gr_peninfo}, - {"get_numeric", mplib_get_numeric}, - {"get_number", mplib_get_numeric}, - {"get_boolean", mplib_get_boolean}, - {"get_string", mplib_get_string}, - {NULL, NULL} /* sentinel */ + { "new", mplib_new }, + { "version", mplib_version }, + { "fields", mplib_gr_fields }, + /* indirect */ + { "execute", mplib_execute }, + { "finish", mplib_finish }, + { "char_width", mplib_charwidth }, + { "char_height", mplib_charheight }, + { "char_depth", mplib_chardepth }, + { "statistics", mplib_statistics }, + { "solve_path", mplib_solve_path }, + /* helpers */ + { "pen_info", mplib_gr_peninfo }, + { "get_numeric", mplib_get_numeric }, + { "get_number", mplib_get_numeric }, + { "get_boolean", mplib_get_boolean }, + { "get_string", mplib_get_string }, + { "get_path", mplib_get_path }, + /*tex sentinel */ + { NULL, NULL} }; int luaopen_mplib(lua_State * L) @@ -1909,22 +2032,23 @@ int luaopen_mplib(lua_State * L) mplib_init_Ses(L); luaL_newmetatable(L, MPLIB_GR_METATABLE); - lua_pushvalue(L, -1); /* push metatable */ - lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ - luaL_register(L, NULL, mplib_gr_meta); /* object meta methods */ + lua_pushvalue(L, -1); + lua_setfield(L, -2, "__index"); + luaL_register(L, NULL, mplib_gr_meta); lua_pop(L, 1); luaL_newmetatable(L, MPLIB_FIG_METATABLE); - lua_pushvalue(L, -1); /* push metatable */ - lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ - luaL_register(L, NULL, mplib_fig_meta); /* figure meta methods */ + lua_pushvalue(L, -1); + lua_setfield(L, -2, "__index"); + luaL_register(L, NULL, mplib_fig_meta); lua_pop(L, 1); luaL_newmetatable(L, MPLIB_METATABLE); - lua_pushvalue(L, -1); /* push metatable */ - lua_setfield(L, -2, "__index"); /* metatable.__index = metatable */ - luaL_register(L, NULL, mplib_meta); /* meta methods */ - luaL_register(L, NULL, mplib_d); /* dict methods */ - luaL_register(L, "mplib", mplib_m); /* module functions */ + lua_pushvalue(L, -1); + lua_setfield(L, -2, "__index"); + luaL_register(L, NULL, mplib_meta); + luaL_register(L, NULL, mplib_d); + luaL_register(L, "mplib", mplib_m); + return 1; } diff --git a/Build/source/texk/web2c/mplibdir/mp.w b/Build/source/texk/web2c/mplibdir/mp.w index 2c956ea5a83..d52ad37ce8b 100644 --- a/Build/source/texk/web2c/mplibdir/mp.w +++ b/Build/source/texk/web2c/mplibdir/mp.w @@ -139,7 +139,7 @@ typedef struct MP_instance { @ @c /*\#define DEBUGENVELOPE */ -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE static int DEBUGENVELOPECOUNTER=0; #define dbg_str(A) printf("\n--[==[%03d DEBUGENVELOPE ]==] %s", DEBUGENVELOPECOUNTER++, #A) #define dbg_n(A) printf("\n--[==[%03d DEBUGENVELOPE ]==] ['%s']=%s, ", DEBUGENVELOPECOUNTER++, #A, number_tostring(A)) @@ -176,8 +176,8 @@ static int DEBUGENVELOPECOUNTER=0; #include <png.h> /* for |PNG_LIBPNG_VER_STRING|, |png_libpng_ver| */ /*\#include <pixman.h>*/ /* for |PIXMAN_VERSION_STRING|, |pixman_version_string()| */ /*\#include <cairo.h>*/ /* for |CAIRO_VERSION_STRING|, |cairo_version_string()| */ -#include <gmp.h> /* for |gmp_version| */ -#include <mpfr.h> /* for |MPFR_VERSION_STRING|, |mpfr_get_version()| */ +/*\#include <gmp.h>*/ /* for |gmp_version| */ +/*\#include <mpfr.h>*/ /* for |MPFR_VERSION_STRING|, |mpfr_get_version()| */ #include "mplib.h" #include "mplibps.h" /* external header */ /*\#include "mplibsvg.h" */ /* external header */ @@ -189,7 +189,7 @@ static int DEBUGENVELOPECOUNTER=0; #include "mpmath.h" /* internal header */ #include "mpmathdouble.h" /* internal header */ #include "mpmathdecimal.h" /* internal header */ -#include "mpmathbinary.h" /* internal header */ +/*#include "mpmathbinary.h"*/ /* internal header */ #include "mpstrings.h" /* internal header */ /* BEGIN PATCH */ mp_number dx_ap; /* approximation of dx */ @@ -200,12 +200,19 @@ mp_number ueps_ap; /* epsilon for above approximations */ boolean is_dxdy, is_dxindyin; /* END PATCH */ -@ We move the {\tt cairo} and {\tt pixman} libraries outside {\tt mp.w}, +@ We move the {\tt cairo} and {\tt pixman} libraries outside {\tt mp.w}, to minimize dependencies. @c extern const char *COMPILED_CAIRO_VERSION_STRING; extern const char* cairo_version_string (void); +extern const char *COMPILED_MPFR_VERSION_STRING; +extern const char* mpfr_get_version (void); +extern void * mp_initialize_binary_math (MP mp) ; +extern int COMPILED__GNU_MP_VERSION; +extern int COMPILED__GNU_MP_VERSION_MINOR; +extern int COMPILED__GNU_MP_VERSION_PATCHLEVEL; +extern const char * const COMPILED_gmp_version; extern const char *COMPILED_PIXMAN_VERSION_STRING; extern const char* pixman_version_string (void); extern void mp_png_backend_initialize (MP mp); @@ -2628,7 +2635,7 @@ void mp_new_randoms (MP mp) { mp->j_random = 54; } -@ To consume a random fraction, the program below will say `|next_random|'. +@ To consume a random fraction, the program below will say `|next_random|'. Now each number system has its own implementation, true to the original as much as possibile. @@ -2657,7 +2664,7 @@ As said before, now each number system has its own implementation. @c /*Unused. static void mp\_unif\_rand (MP mp, mp\_number *ret, mp\_number x\_orig) { - mp\_number y; // trial value + mp\_number y; // trial value mp\_number x, abs\_x; mp\_number u; new\_fraction (y); @@ -2896,7 +2903,7 @@ void *do_alloc_node (MP mp, size_t size) { @c void mp_xfree (void *x) { - if (x != NULL) + if (x != NULL) free (x); } void *mp_xrealloc (MP mp, void *p, size_t nmem, size_t size) { @@ -3235,8 +3242,7 @@ mp_random_seed, /* initialize random number generator (\&{randomseed}) */ mp_message_command, /* communicate to user (\&{message}, \&{errmessage}) */ mp_every_job_command, /* designate a starting token (\&{everyjob}) */ mp_delimiters, /* define a pair of delimiters (\&{delimiters}) */ -mp_special_command, /* output special info (\&{special}) - or font map info (\&{fontmapfile}, \&{fontmapline}) */ +mp_special_command, /* output special info (\&{special}) or font map info (\&{fontmapfile}, \&{fontmapline}) */ mp_write_command, /* write text to a file (\&{write}) */ mp_type_name, /* declare a type (\&{numeric}, \&{pair}, etc.) */ mp_left_delimiter, /* the left delimiter of a matching pair */ @@ -3275,15 +3281,13 @@ mp_left_bracket, /* the operator `\.[' */ mp_right_bracket, /* the operator `\.]' */ mp_right_brace, /* the operator `\.{\char`\}}' */ mp_with_option, /* option for filling (\&{withpen}, \&{withweight}, etc.) */ -mp_thing_to_add, - /* variant of \&{addto} (\&{contour}, \&{doublepath}, \&{also}) */ +mp_thing_to_add, /* variant of \&{addto} (\&{contour}, \&{doublepath}, \&{also}) */ mp_of_token, /* the operator `\&{of}' */ mp_to_token, /* the operator `\&{to}' */ mp_step_token, /* the operator `\&{step}' */ mp_until_token, /* the operator `\&{until}' */ mp_within_token, /* the operator `\&{within}' */ -mp_lig_kern_token, - /* the operators `\&{kern}' and `\.{=:}' and `\.{=:\char'174}', etc. */ +mp_lig_kern_token, /* the operators `\&{kern}' and `\.{=:}' and `\.{=:\char'174}', etc. */ mp_assignment, /* the operator `\.{:=}' */ mp_skip_to, /* the operation `\&{skipto}' */ mp_bchar_label, /* the operator `\.{\char'174\char'174:}' */ @@ -4046,6 +4050,7 @@ enum mp_given_internal { mp_pausing, /* positive to display lines on the terminal before they are read */ mp_showstopping, /* positive to stop after each \&{show} command */ mp_fontmaking, /* positive if font metric output is to be produced */ + mp_texscriptmode, /* controls spacing in texmode */ mp_linejoin, /* as in \ps: 0 for mitered, 1 for round, 2 for beveled */ mp_linecap, /* as in \ps: 0 for butt, 1 for round, 2 for square */ mp_miterlimit, /* controls miter length as in \ps */ @@ -4196,6 +4201,8 @@ mp_primitive (mp, "showstopping", mp_internal_quantity, mp_showstopping); @:mp_showstopping_}{\&{showstopping} primitive@>; mp_primitive (mp, "fontmaking", mp_internal_quantity, mp_fontmaking); @:mp_fontmaking_}{\&{fontmaking} primitive@>; +mp_primitive (mp, "texscriptmode", mp_internal_quantity, mp_texscriptmode); +@:mp_texscriptmode_}{\&{texscriptmode} primitive@>; mp_primitive (mp, "linejoin", mp_internal_quantity, mp_linejoin); @:mp_linejoin_}{\&{linejoin} primitive@>; mp_primitive (mp, "linecap", mp_internal_quantity, mp_linecap); @@ -4214,8 +4221,7 @@ mp_primitive (mp, "mpprocset", mp_internal_quantity, mp_procset); @:mp_procset_}{\&{mpprocset} primitive@>; mp_primitive (mp, "troffmode", mp_internal_quantity, mp_gtroffmode); @:troffmode_}{\&{troffmode} primitive@>; -mp_primitive (mp, "defaultcolormodel", mp_internal_quantity, - mp_default_color_model); +mp_primitive (mp, "defaultcolormodel", mp_internal_quantity, mp_default_color_model); @:mp_default_color_model_}{\&{defaultcolormodel} primitive@>; mp_primitive (mp, "restoreclipcolor", mp_internal_quantity, mp_restore_clip_color); @:mp_restore_clip_color_}{\&{restoreclipcolor} primitive@>; @@ -4273,6 +4279,7 @@ set_internal_string (mp_output_format, mp_intern (mp, "eps")); set_internal_string (mp_output_format_options, mp_intern (mp, "")); set_internal_string (mp_number_system, mp_intern (mp, "scaled")); set_internal_from_number (mp_number_precision, precision_default); +set_internal_from_number (mp_texscriptmode, unity_t); #if DEBUG number_clone (internal_value (mp_tracing_titles), three_t); number_clone (internal_value (mp_tracing_equations), three_t); @@ -4320,6 +4327,7 @@ set_internal_name (mp_design_size, xstrdup ("designsize")); set_internal_name (mp_pausing, xstrdup ("pausing")); set_internal_name (mp_showstopping, xstrdup ("showstopping")); set_internal_name (mp_fontmaking, xstrdup ("fontmaking")); +set_internal_name (mp_texscriptmode, xstrdup ("texscriptmode")); set_internal_name (mp_linejoin, xstrdup ("linejoin")); set_internal_name (mp_linecap, xstrdup ("linecap")); set_internal_name (mp_miterlimit, xstrdup ("miterlimit")); @@ -4443,6 +4451,8 @@ class numbers in nonstandard extensions of \MP. @d invalid_class 20 /* bad character in the input */ @d max_class 20 /* the largest class number */ +@d semicolon_class 6 /* the ; */ + @<Glob...@>= #define digit_class 0 /* the class number of \.{0123456789} */ int char_class[256]; /* the class numbers */ @@ -4843,10 +4853,26 @@ char *mp_get_string_value (MP mp, const char *s, size_t l) { return NULL; } +mp_knot mp_get_path_value (MP mp, const char *s, size_t l) { + char *ss = mp_xstrdup(mp,s); + if (ss) { + mp_sym sym = mp_id_lookup(mp,ss,l,false); + if (sym != NULL) { + if (mp_type(sym->v.data.node) == mp_path_type) { + mp_xfree (ss); + return (mp_knot) sym->v.data.node->data.p; + } + } + } + mp_xfree (ss); + return NULL; +} + @ @<Exported function headers@>= double mp_get_numeric_value(MP mp,const char *s,size_t l); int mp_get_boolean_value(MP mp,const char *s,size_t l); char *mp_get_string_value(MP mp,const char *s,size_t l); +mp_knot mp_get_path_value(MP mp,const char *s,size_t l); @ We need to put \MP's ``primitive'' symbolic tokens into the hash table, together with their command code (which will be the |eq_type|) @@ -13270,26 +13296,26 @@ static mp_knot mp_offset_prep (MP mp, mp_knot c, mp_knot h) { c0 = c; k_needed = 0; #ifdef DEBUGENVELOPE -dbg_nl;dbg_str(--[==[BEGIN]==]);dbg_nl; -dbg_str(return {);dbg_nl; +dbg_nl;dbg_str(--[==[BEGIN]==]);dbg_nl; +dbg_str(return {);dbg_nl; dbg_n(w0->x_coord); dbg_n(w0->y_coord); #endif do { q = mp_next_knot (p); #ifdef DEBUGENVELOPE -dbg_nl;dbg_open_t;dbg_str(--[==[begin loop]==]);dbg_nl; +dbg_nl;dbg_open_t;dbg_str(--[==[begin loop]==]);dbg_nl; dbg_n(p->x_coord);dbg_n(p->y_coord); dbg_n(p->right_x);dbg_n(p->right_y); dbg_n(q->left_x);dbg_n(q->left_y); dbg_n(q->x_coord);dbg_n(q->y_coord); dbg_n(w0->x_coord); dbg_n(w0->y_coord); -#endif +#endif @<Split the cubic between |p| and |q|, if necessary, into cubics associated with single offsets, after which |q| should point to the end of the final such cubic@>; -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_key(end Split the cubic between |p| and |q|);dbg_open_t;dbg_nl; dbg_n(w->x_coord);dbg_n(w->y_coord); dbg_n(w0->x_coord);dbg_n(w0->y_coord); @@ -13301,7 +13327,7 @@ dbg_close_t; dbg_comma;dbg_nl; #ifdef DEBUGENVELOPE dbg_n(w0->x_coord);dbg_n(w0->y_coord); dbg_str(--[==[end loop]==]);dbg_nl; dbg_close_t;dbg_comma;dbg_nl; -#endif +#endif } while (q != c); #ifdef DEBUGENVELOPE dbg_key(Fix the offset change);dbg_open_t;dbg_nl; @@ -13312,7 +13338,7 @@ dbg_str(--[==[end loop]==]);dbg_nl; dbg_close_t;dbg_comma;dbg_nl; #endif @<Fix the offset change in |mp_knot_info(c)| and set |c| to the return value of |offset_prep|@>; -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_n(p->x_coord);dbg_n(p->y_coord); dbg_key_ival(info post,mp_knot_info(p));dbg_comma;dbg_nl; dbg_n(c->x_coord);dbg_n(c->y_coord); @@ -13412,7 +13438,7 @@ the testcase reported by Bogus\l{}aw Jackowski in tracker id 267, case 52c on Sarovar.) @<Advance |p| to node |q|, removing any ``dead'' cubics...@>= -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_comment(Advance |p| to node |q|);dbg_nl; #endif q0 = q; @@ -13437,11 +13463,11 @@ if ((q != q0) && (q != c || c == c0)) @ @<Remove the cubic following |p| and update the data structures...@>= { - #ifdef DEBUGENVELOPE + #ifdef DEBUGENVELOPE dbg_key(Remove the cubic following p);dbg_open_t;dbg_nl; dbg_n(p->x_coord);dbg_n(p->y_coord); dbg_key_ival(pre info p,mp_knot_info(p)); dbg_close_t;dbg_comma;dbg_nl; - #endif + #endif k_needed = mp_knot_info (p) - zero_off; if (r == q) { q = p; @@ -13459,11 +13485,11 @@ if ((q != q0) && (q != c || c == c0)) mp->spec_p2 = p; r = p; mp_remove_cubic (mp, p); - #ifdef DEBUGENVELOPE + #ifdef DEBUGENVELOPE dbg_key(Remove the cubic following p);dbg_open_t;dbg_nl; dbg_n(p->x_coord);dbg_n(p->y_coord); dbg_key_ival(post info p,mp_knot_info (p)); dbg_close_t;dbg_comma;dbg_nl; - #endif + #endif } @@ -13532,16 +13558,16 @@ We may have to split a cubic into many pieces before each piece corresponds to a unique offset. @<Split the cubic between |p| and |q|, if necessary, into cubics...@>= -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_comment(Split the cubic between |p| and |q|);dbg_nl; dbg_key(Split the cubic);dbg_open_t;dbg_nl; dbg_key_ival(pre info p,mp_knot_info(p));dbg_comma; dbg_n(w0->x_coord);dbg_n(w0->y_coord); -#endif +#endif mp_knot_info (p) = zero_off + k_needed; -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_key_ival(post info p,mp_knot_info(p));dbg_close_t;dbg_comma; dbg_nl; -#endif +#endif k_needed = 0; @<Prepare for derivative computations; |goto not_found| if the current cubic is dead@>; @@ -13708,7 +13734,7 @@ void mp_fin_offset_prep (MP mp, mp_knot p, mp_knot w, mp_number new_number(t2); new_fraction(s); new_fraction(t); -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_key(mp_fin_offset_prep);dbg_open_t;dbg_nl; #endif while (1) { @@ -13716,7 +13742,7 @@ dbg_key(mp_fin_offset_prep);dbg_open_t;dbg_nl; ww = mp_next_knot (w); /* a pointer to $w\k$ */ else ww = mp_prev_knot (w); /* a pointer to $w_{k-1}$ */ -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_comment(begin iteration); dbg_open_t;dbg_nl; dbg_n(w->x_coord);dbg_n(w->y_coord); @@ -13727,11 +13753,11 @@ dbg_in(rise); #endif @<Compute test coefficients |(t0,t1,t2)| for $d(t)$ versus $d_k$ or $d_{k-1}$@>; -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_comment(crossing_point); #endif crossing_point (t, t0, t1, t2); -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_n(t);dbg_n(t0);dbg_n(t1);dbg_n(t2); dbg_in(number_greaterequal(t, fraction_one_t)); dbg_in(turn_amt); @@ -13743,18 +13769,18 @@ dbg_close_t; dbg_comma;dbg_nl; else goto RETURN; } -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_comment(Split the cubic at $t$ and split off another cubic if the derivative crosses back); #endif @<Split the cubic at $t$, and split off another cubic if the derivative crosses back@>; w = ww; -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_comment(end iteration); #endif } RETURN: -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_comment(RETURN); dbg_n(t); #endif @@ -13766,7 +13792,7 @@ dbg_n(t); free_number (t0); free_number (t1); free_number (t2); -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_close_t; dbg_comma;dbg_nl; #endif } @@ -13782,7 +13808,7 @@ begins to fail. mp_number abs_du, abs_dv; new_number (abs_du); new_number (abs_dv); -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_key(Compute test coefficients |(t0,t1,t2)| for $d(t)$ versus...);dbg_open_t;dbg_nl; #endif set_number_from_substraction(du, ww->x_coord, w->x_coord); @@ -13791,7 +13817,7 @@ dbg_key(Compute test coefficients |(t0,t1,t2)| for $d(t)$ versus...);dbg_open_t; number_abs(abs_du); number_clone(abs_dv, dv); number_abs(abs_dv); -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_CUBIC; dbg_n(w->x_coord);dbg_n(w->y_coord); dbg_n(ww->x_coord);dbg_n(ww->y_coord); @@ -13838,7 +13864,7 @@ dbg_in(number_greaterequal(abs_du, abs_dv)); free_number (abs_dv); if (number_negative(t0)) set_number_to_zero(t0); /* should be positive without rounding error */ -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_n(t0);dbg_n(t1);dbg_n(t2); dbg_close_t; dbg_comma;dbg_nl; #endif @@ -13981,19 +14007,19 @@ if (number_zero(dxin) && number_zero(dyin)) { #ifdef DEBUGENVELOPE dbg_key(dxin dyin before);dbg_open_t;dbg_nl; dbg_n(dxin);dbg_n(dyin); -dbg_close_t;dbg_comma; +dbg_close_t;dbg_comma; #endif #ifdef DEBUGENVELOPE dbg_key(dxin dyin after);dbg_open_t;dbg_nl; dbg_n(dxin);dbg_n(dyin); -dbg_close_t;dbg_comma; +dbg_close_t;dbg_comma; #endif /* BEGIN PATCH */ #ifdef DEBUGENVELOPE dbg_key(dx dy dxin dyin after patch);dbg_open_t;dbg_nl; dbg_n(dx);dbg_n(dy);dbg_n(dx_ap);dbg_n(dy_ap); dbg_n(dxin);dbg_n(dyin);dbg_n(dxin_ap);dbg_n(dyin_ap); -dbg_close_t;dbg_comma; +dbg_close_t;dbg_comma; #endif /* END PATCH ****/ @@ -14012,13 +14038,13 @@ right.) This code depends on |w0| being the offset for |(dxin,dyin)|. #ifdef DEBUGENVELOPE dbg_nl; dbg_comment(Update |mp_knot_info(p)|);dbg_nl; -dbg_key(mp_get_turn_amt_dx_dy);dbg_open_t;dbg_str(--[==[call mp_get_turn_amt]==]);dbg_nl; +dbg_key(mp_get_turn_amt_dx_dy);dbg_open_t;dbg_str(--[==[call mp_get_turn_amt]==]);dbg_nl; dbg_n(w0->x_coord);dbg_n(w0->y_coord);dbg_n(dx);dbg_n(dy);dbg_in(number_nonnegative(ab_vs_cd)); dbg_n(ab_vs_cd); #endif is_dxdy=true; turn_amt = mp_get_turn_amt (mp, w0, dx, dy, number_nonnegative(ab_vs_cd)); - is_dxdy=false; + is_dxdy=false; #ifdef DEBUGENVELOPE dbg_dn(turn_amt); dbg_close_t;dbg_comma; @@ -14078,20 +14104,20 @@ integer mp_get_turn_amt (MP mp, mp_knot w, mp_number dx, mp_number dy, boolean c ab_vs_cd (t, dy, arg1, dx, arg2); #ifdef DEBUGENVELOPE dbg_sp; - dbg_open_t;dbg_str(--[==[inside mp_get_turn_amt do loop ]==]);dbg_nl; + dbg_open_t;dbg_str(--[==[inside mp_get_turn_amt do loop ]==]);dbg_nl; dbg_n(w->x_coord);dbg_n(w->y_coord);dbg_n(ww->x_coord);dbg_n(ww->y_coord); dbg_n(t);dbg_n(dy);dbg_n(arg1);dbg_n(dx);dbg_n(arg2); dbg_n(t_ap);dbg_n(dy_ap);dbg_n(dx_ap);dbg_n(dyin_ap);dbg_n(dxin_ap); dbg_close_t;dbg_comma; dbg_in(number_zero(dx) && number_zero(arg1) && number_positive(dy) && number_positive(arg2) && is_dxdy); - dbg_in(is_dxdy && number_zero(dx) && number_zero(arg1) && number_negative(dy) && number_negative(arg2) && number_positive(dyin_ap)); + dbg_in(is_dxdy && number_zero(dx) && number_zero(arg1) && number_negative(dy) && number_negative(arg2) && number_positive(dyin_ap)); dbg_in(is_dxindyin && number_zero(dx) && number_zero(arg1) && number_positive(dy) && number_positive(arg2) && number_negative(dyin_ap)); dbg_in(number_zero(dy) && number_zero(arg2) && number_negative(dx) && number_negative(arg1)); dbg_in(number_zero(dx) && number_zero(arg1) && number_negative(dy) && number_positive(arg2)); dbg_in(number_zero(dy) && number_zero(arg2) && number_positive(dx) && number_negative(arg1)); dbg_nl; #endif - if (number_negative(t)) + if (number_negative(t)) break; incr (s); w = ww; @@ -14104,7 +14130,7 @@ integer mp_get_turn_amt (MP mp, mp_knot w, mp_number dx, mp_number dy, boolean c ab_vs_cd (t, dy, arg1, dx, arg2); #ifdef DEBUGENVELOPE dbg_sp; - dbg_open_t;dbg_str(--[==[outside mp_get_turn_amt do loop ]==]);dbg_nl; + dbg_open_t;dbg_str(--[==[outside mp_get_turn_amt do loop ]==]);dbg_nl; dbg_n(w->x_coord);dbg_n(w->y_coord);dbg_n(ww->x_coord);dbg_n(ww->y_coord); dbg_n(t);dbg_n(dy);dbg_n(arg1);dbg_n(dx);dbg_n(arg2); dbg_n(t_ap);dbg_n(dy_ap);dbg_n(dx_ap);dbg_n(dyin_ap);dbg_n(dxin_ap); @@ -14120,7 +14146,7 @@ integer mp_get_turn_amt (MP mp, mp_knot w, mp_number dx, mp_number dy, boolean c ab_vs_cd (t, dy, arg1, dx, arg2); #ifdef DEBUGENVELOPE dbg_sp; - dbg_open_t;dbg_str(--[==[inside mp_get_turn_amt do loop for t<0 ]==]);dbg_nl; + dbg_open_t;dbg_str(--[==[inside mp_get_turn_amt do loop for t<0 ]==]);dbg_nl; dbg_n(w->x_coord);dbg_n(w->y_coord);dbg_n(ww->x_coord);dbg_n(ww->y_coord); dbg_n(t);dbg_n(dy);dbg_n(arg1);dbg_n(dx);dbg_n(arg2); dbg_n(t_ap);dbg_n(dy_ap);dbg_n(dx_ap); @@ -14173,14 +14199,14 @@ with respect to $d_{k-1}$, and apply |fin_offset_prep| to each part. @<Complete the offset splitting process@>= ww = mp_prev_knot (w); -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_key(Complete the offset splitting process);dbg_open_t;dbg_nl; dbg_n(w->x_coord);dbg_n(w->y_coord); dbg_n(ww->x_coord);dbg_n(ww->y_coord); dbg_close_t; dbg_comma;dbg_nl; #endif @<Compute test coeff...@>; -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_key(after Compute test coeff);dbg_open_t;dbg_nl; dbg_n(w->x_coord);dbg_n(w->y_coord); dbg_n(ww->x_coord);dbg_n(ww->y_coord); @@ -14189,7 +14215,7 @@ dbg_close_t; dbg_comma;dbg_nl; @<Find the first |t| where $d(t)$ crosses $d_{k-1}$ or set |t:=fraction_one+1|@>; if (number_greater(t, fraction_one_t)) { -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_key(t > fraction_one_t);dbg_open_t;dbg_nl; dbg_n(p->x_coord);dbg_n(p->y_coord); dbg_n(w->x_coord);dbg_n(w->y_coord); @@ -14207,7 +14233,7 @@ dbg_close_t; dbg_comma;dbg_nl; set_number_from_of_the_way(y1a, t, y0, y1); set_number_from_of_the_way(y1, t, y1, y2); set_number_from_of_the_way(y2a, t, y1a, y1); -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_key(t <= fraction_one_t);dbg_open_t;dbg_nl; dbg_n(p->x_coord);dbg_n(p->y_coord); dbg_n(t); @@ -14245,7 +14271,7 @@ dbg_close_t; dbg_comma;dbg_nl; mp_fin_offset_prep (mp, r, ww, x0, x1, x2, y0, y1, y2, -1, (-1 - turn_amt)); } } -#ifdef DEBUGENVELOPE +#ifdef DEBUGENVELOPE dbg_key(end Complete the offset splitting process);dbg_open_t;dbg_nl; dbg_n(w->x_coord);dbg_n(w->y_coord); dbg_n(w0->x_coord);dbg_n(w0->y_coord); @@ -14278,7 +14304,7 @@ crossing and the first crossing cannot be antiparallel. @<Find the first |t| where $d(t)$ crosses $d_{k-1}$ or set...@>= #ifdef DEBUGENVELOPE dbg_key(Find the first |t| where);dbg_open_t;dbg_nl; -#endif +#endif crossing_point (t, t0, t1, t2); if (turn_amt >= 0) { if (number_negative(t2)) { @@ -14316,7 +14342,7 @@ if (turn_amt >= 0) { #ifdef DEBUGENVELOPE dbg_n(t); dbg_close_t; dbg_comma;dbg_nl; -#endif +#endif @ @<Other local variables for |offset_prep|@>= @@ -19845,6 +19871,7 @@ is less than |loop_text|. @ @<Run a script@>= if (s != NULL) { int k ; + mp_value new_expr; size_t size = strlen(s); memset(&new_expr,0,sizeof(mp_value)); new_number(new_expr.data.n); @@ -19860,7 +19887,6 @@ if (s != NULL) { } limit = (halfword) k; (void) memcpy ((mp->buffer + mp->first), s, size); - free(s); mp->buffer[limit] = xord ('%'); mp->first = (size_t) (limit + 1); loc = start; @@ -19891,26 +19917,42 @@ if (s != NULL) { } else { mp_back_input (mp); if (cur_exp_str ()->len > 0) { - mp_value new_expr; char *s = mp->run_script(mp,(const char*) cur_exp_str()->str) ; @<Run a script@> + free(s); } } } -@ @<Pass btex ... etex to script@>= +@ The |texscriptmode| parameter controls how spaces and newlines get honoured in +|btex| or |verbatimtex| ... |etex|. The default value is~1. Possible values are: +0: no newlines, 1: newlines in |verbatimtex|, 2: newlines in |verbatimtex| and +|etex|, 3: no leading and trailing strip in |verbatimtex|, 4: no leading and +trailing strip in |verbatimtex| and |btex|. That way the Lua handler can do what +it likes. An |etex| has to be followed by a space or |;| or be at the end of a +line and preceded by a space or at the beginning of a line. + +@<Pass btex ... etex to script@>= { - int first ; - while ((loc < limit - 4) && (mp->buffer[loc] == ' ')) { + char *txt = NULL; + char *ptr = NULL; + int slin = line; + int size = 0; + int done = 0; + int mode = round_unscaled(internal_value(mp_texscriptmode)) ; /* default: 1 */ + int verb = cur_mod() == verbatim_code; + int first; + /* we had a (mandate) trailing space */ + if (loc <= limit && mp->char_class[mp->buffer[loc]] == space_class) { incr(loc); + } else { + /* maybe issue an error message and quit */ } - first = loc ; - if (mp->buffer[loc-1] == ' ') { - decr(loc); - } - while (loc < limit - 5) { - if (mp->buffer[loc] == ' ') { - incr(loc); + /* we loop over lines */ + first = loc; + while (1) { + /* we don't need to check when we have less than 4 characters left */ + if (loc < limit - 4) { if (mp->buffer[loc] == 'e') { incr(loc); if (mp->buffer[loc] == 't') { @@ -19918,39 +19960,135 @@ if (s != NULL) { if (mp->buffer[loc] == 'e') { incr(loc) ; if (mp->buffer[loc] == 'x') { - /* start action */ - char *s, *txt ; - int size ; - mp_value new_expr; - size = loc - first + 1 - 4 ; - if (size < 0) { - size = 0 ; - } else { - while ((size > 1) && (mp->buffer[first+size-1] == ' ')) { - decr(size); - } + /* let's see if we have the right boundary */ + if (first == (loc - 3)) { + /* when we're at the start of a line no leading space is required */ + done = 1; + } else if (mp->char_class[mp->buffer[loc - 4]] == space_class) { + /* when we're beyond the start of a line a leading space is required */ + done = 2; } - txt = malloc(size+1); - if (size > 0) { - (void) memcpy (txt, mp->buffer + first, size); + if (done) { + if ((loc + 1) <= limit) { + quarterword c = mp->char_class[mp->buffer[loc + 1]] ; + if (c != letter_class) { + incr(loc) ; + /* we're past the 'x' */ + break; + } else { + /* this is no valid etex */ + done = 0; + } + } else { + /* when we're at the end of a line we're ok */ + incr(loc) ; + /* we're past the 'x' */ + break; + } } - txt[size] = '\0'; - incr(loc); - s = mp->make_text(mp,txt,(cur_mod() == verbatim_code)) ; /* we could pass the size */ - @<Run a script@> - /* done */ - free(txt); - break ; - } else { - // decr(loc) ; } } } } + } + /* no etex seen (yet) */ + if (loc >= limit) { + if (size) { + txt = realloc(txt, size + limit - first + 1); + } else { + txt = malloc(limit - first + 1); + } + (void) memcpy (txt + size, mp->buffer + first, limit - first); + size += limit - first + 1; + if (mode <= 0) { + txt[size - 1] = ' '; + } else if (verb) { + /* modes >= 1 permit a newline in verbatimtex */ + txt[size - 1] = '\n'; + } else if (mode >= 2) { + /* modes >= 2 permit a newline in btex */ + txt[size - 1] = '\n'; + } else { + txt[size - 1] = ' '; + } + if (move_to_next_line(mp)) { + /* we abort the scanning */ + goto FATAL_ERROR; + } + first = loc; } else { incr(loc); } } + if (done) { + /* we're past the 'x' */ + int l = loc - 5 ; // 4 + int n = l - first + 1 ; + /* we're before the 'etex' */ + if (done == 2) { + /* we had ' etex' */ + l -= 1; + n -= 1; + /* we're before the ' etex' */ + } + if (size) { + txt = realloc(txt, size + n + 1); + } else { + txt = malloc(n + 1); + } + (void) memcpy (txt + size, mp->buffer + first, n); /* 0 */ + size += n; + if (verb && mode >= 3) { + /* don't strip verbatimtex */ + txt[size] = '\0'; + ptr = txt; + } else if (mode >= 4) { + /* don't strip btex */ + txt[size] = '\0'; + ptr = txt; + } else { + /* strip trailing whitespace, we have a \0 so we're one off */ + /* while ((size > 1) && (mp->char_class[(ASCII_code) txt[size-2]] == space_class || txt[size-2] == '\n')) { */ + while ((size > 1) && (mp->char_class[(ASCII_code) txt[size-1]] == space_class || txt[size-1] == '\n')) { + decr(size); + } + /* prune the string */ + txt[size] = '\0'; + /* strip leading whitespace */ + ptr = txt; + while ((size > 1) && (mp->char_class[(ASCII_code) ptr[0]] == space_class || ptr[0] == '\n')) { + incr(ptr); + decr(size); + } + } + /* action */ + { + char *s = mp->make_text(mp,ptr,verb) ; + @<Run a script@> + free(s); + } + free(txt); + /* really needed */ + mp_get_next(mp); + return; + } + /* + we don't recover because in practice the graphic will be broken anyway and + we're not really interacting in mplib .. just fix the input + */ + FATAL_ERROR: + { + /* line numbers are not always meaningfull so we can get a 0 reported */ + char msg[256]; + const char *hlp[] = { "An 'etex' is missing at this input level, nothing gets done.", NULL }; + if (slin > 0) { + mp_snprintf(msg, 256, "No matching 'etex' for '%stex'.", verb ? "verbatim" : "b"); + } else { + mp_snprintf(msg, 256, "No matching 'etex' for '%stex' in line %d.", verb ? "verbatim" : "b",slin); + } + mp_error (mp, msg, hlp, false); + free(txt); + } } @ @<Put a maketext result string into the input buffer@>= @@ -19964,7 +20102,7 @@ if (s != NULL) { mp_value new_expr; const char *hlp[] = { "I'm going to flush this expression, since", - "makete should be followed by a known string.", + "maketext should be followed by a known string.", NULL }; memset(&new_expr,0,sizeof(mp_value)); new_number(new_expr.data.n); @@ -19976,9 +20114,9 @@ if (s != NULL) { } else { mp_back_input (mp); if (cur_exp_str ()->len > 0) { - mp_value new_expr; char *s = mp->make_text(mp,(const char*) cur_exp_str()->str,0) ; @<Run a script@> + free(s); } } } @@ -23295,7 +23433,7 @@ RESTART: q = mp_get_value_node (mp); mp_name_type (q) = mp_capsule; - if (cur_cmd() == mp_comma) { + if (cur_cmd() == mp_comma) { mp_init_color_node (mp, q); r = value_node (q); mp_stash_in (mp, y_part (r)); @@ -23321,7 +23459,7 @@ RESTART: } mp_stash_in (mp, blue_part (r)); - if (cur_cmd() == mp_comma) { + if (cur_cmd() == mp_comma) { mp_node t; /* a token */ mp_init_cmykcolor_node (mp, q); t = value_node (q); @@ -23337,13 +23475,13 @@ RESTART: set_dep_list (cyan_part(t),dep_list ((mp_value_node) red_part(r))); set_prev_dep (cyan_part(t),prev_dep ((mp_value_node) red_part(r))); set_mp_link (prev_dep (cyan_part(t)), (mp_node) cyan_part(t)); - } + } if ( ((mp_type (magenta_part (t))) != mp_independent) && ((mp_type (magenta_part (t))) != mp_known) ) { /* Copy the dep list */ set_dep_list (magenta_part(t),dep_list ((mp_value_node) green_part(r))); set_prev_dep (magenta_part(t),prev_dep ((mp_value_node) green_part(r))); set_mp_link (prev_dep (magenta_part(t)), (mp_node) magenta_part(t)); - } + } if ( ((mp_type (yellow_part (t))) != mp_independent) && ((mp_type (yellow_part (t))) != mp_known)) { /* Copy the dep list */ set_dep_list (yellow_part(t),dep_list ((mp_value_node) blue_part(r))); @@ -28985,7 +29123,7 @@ static void mp_set_up_boundingpath (MP mp, mp_node p) { unsigned char ljoin, lcap; mp_number miterlim; mp_knot q = mp_copy_path (mp, cur_exp_knot ()); /* the original path */ - mp_knot pen; + mp_knot pen; mp_knot qq; new_number(miterlim); @@ -30671,8 +30809,8 @@ void mp_show_library_versions (void) { fprintf(stdout, "Compiled with pixman %s; using %s\n",COMPILED_PIXMAN_VERSION_STRING, pixman_version_string()); fprintf(stdout, "Compiled with libpng %s; using %s\n", PNG_LIBPNG_VER_STRING, png_libpng_ver); fprintf(stdout, "Compiled with zlib %s; using %s\n", ZLIB_VERSION, zlibVersion()); - fprintf(stdout, "Compiled with mpfr %s; using %s\n", MPFR_VERSION_STRING, mpfr_get_version()); - fprintf(stdout, "Compiled with gmp %d.%d.%d; using %s\n\n", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR, __GNU_MP_VERSION_PATCHLEVEL, gmp_version); + fprintf(stdout, "Compiled with mpfr %s; using %s\n", COMPILED_MPFR_VERSION_STRING, mpfr_get_version()); + fprintf(stdout, "Compiled with gmp %d.%d.%d; using %s\n\n", COMPILED__GNU_MP_VERSION, COMPILED__GNU_MP_VERSION_MINOR, COMPILED__GNU_MP_VERSION_PATCHLEVEL, COMPILED_gmp_version); } @ @<Exported function headers@>= @@ -33230,7 +33368,7 @@ We may need to cancel skips that span more than 127 lig/kern steps. @ The header could contain ASCII zeroes, so can't use |strdup|. -The index |j| can be beyond the index |header_last|, hence we +The index |j| can be beyond the index |header_last|, hence we have to sure to update the end of stream marker to reflect the actual position. @@ -34555,8 +34693,9 @@ extreme cases so it may have to be shortened on some systems. @<Use |c| to compute the file extension |s|@>= { - s = xmalloc (7, 1); - mp_snprintf (s, 7, ".%i", (int) c); + s = xmalloc (12, 1); + mp_snprintf (s, 12, ".%i", (int) c); + s[7]='\0'; } diff --git a/Build/source/texk/web2c/mplibdir/mpmath.w b/Build/source/texk/web2c/mplibdir/mpmath.w index 772f8042bfc..6c0ee6d00a6 100644 --- a/Build/source/texk/web2c/mplibdir/mpmath.w +++ b/Build/source/texk/web2c/mplibdir/mpmath.w @@ -1,4 +1,4 @@ -% $Id$ +% $Id: mpmath.w 2118 2017-02-15 17:49:54Z luigi $ % % This file is part of MetaPost; % the MetaPost program is in the public domain. diff --git a/Build/source/texk/web2c/mplibdir/mpmathbinary.w b/Build/source/texk/web2c/mplibdir/mpmathbinary.w index c6df9ced4c8..f3d9ed947a8 100644 --- a/Build/source/texk/web2c/mplibdir/mpmathbinary.w +++ b/Build/source/texk/web2c/mplibdir/mpmathbinary.w @@ -39,6 +39,19 @@ #include "mpmp.h" /* internal header */ #include <gmp.h> #include <mpfr.h> + +#ifdef HAVE_CONFIG_H +#include <gmp/config.h> +const char * const COMPILED_gmp_version = VERSION; +#else +const char * const COMPILED_gmp_version = "unknown"; +#endif + +const char *COMPILED_MPFR_VERSION_STRING = MPFR_VERSION_STRING; +int COMPILED__GNU_MP_VERSION = __GNU_MP_VERSION ; +int COMPILED__GNU_MP_VERSION_MINOR = __GNU_MP_VERSION_MINOR ; +int COMPILED__GNU_MP_VERSION_PATCHLEVEL = __GNU_MP_VERSION_PATCHLEVEL ; + @<Internal library declarations@>; #endif diff --git a/Build/source/texk/web2c/mplibdir/mpmathdouble.w b/Build/source/texk/web2c/mplibdir/mpmathdouble.w index 4834876e5c3..cb14969365f 100644 --- a/Build/source/texk/web2c/mplibdir/mpmathdouble.w +++ b/Build/source/texk/web2c/mplibdir/mpmathdouble.w @@ -1,4 +1,4 @@ -% $Id$ +% $Id: mpmathdouble.w 2118 2017-02-15 17:49:54Z luigi $ % % This file is part of MetaPost; % the MetaPost program is in the public domain. |