[latex3-commits] [git/LaTeX3-latex3-latex3] luaintarray: Initial draft for Lua based intarrays (85b493d9a)
Marcel Fabian Krüger
tex at 2krueger.de
Mon Aug 10 21:40:33 CEST 2020
Repository : https://github.com/latex3/latex3
On branch : luaintarray
Link : https://github.com/latex3/latex3/commit/85b493d9a701e5a387d8945b5bbb3372e26eb581
>---------------------------------------------------------------
commit 85b493d9a701e5a387d8945b5bbb3372e26eb581
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date: Mon Aug 10 21:40:33 2020 +0200
Initial draft for Lua based intarrays
>---------------------------------------------------------------
85b493d9a701e5a387d8945b5bbb3372e26eb581
l3kernel/l3.ins | 7 +-
l3kernel/l3intarray.dtx | 472 ++++++++++++++++++++++++++++++++++-
l3kernel/l3luatex.dtx | 77 ++++++
l3kernel/testfiles/m3intarray001.lvt | 4 +-
4 files changed, 553 insertions(+), 7 deletions(-)
diff --git a/l3kernel/l3.ins b/l3kernel/l3.ins
index 5e7d1bfff..81b5e4a64 100644
--- a/l3kernel/l3.ins
+++ b/l3kernel/l3.ins
@@ -78,7 +78,7 @@ and all files in that bundle must be distributed together.
\from{l3file.dtx} {package}
\from{l3skip.dtx} {package}
\from{l3keys.dtx} {package}
- \from{l3intarray.dtx} {package}
+ \from{l3intarray.dtx} {package,tex}
\from{l3fp.dtx} {package}
\from{l3fp-aux.dtx} {package}
\from{l3fp-traps.dtx} {package}
@@ -165,6 +165,9 @@ and all files in that bundle must be distributed together.
\endpreamble
\nopostamble
-\generate{\file{expl3.lua}{\from{l3luatex.dtx}{package,lua}}}
+\generate{\file{expl3.lua}{
+ \from{l3luatex.dtx}{package,lua}
+ \from{l3intarray.dtx}{package,lua}
+}}
\endbatchfile
diff --git a/l3kernel/l3intarray.dtx b/l3kernel/l3intarray.dtx
index 208ec1cfe..c39b79bdc 100644
--- a/l3kernel/l3intarray.dtx
+++ b/l3kernel/l3intarray.dtx
@@ -173,7 +173,469 @@
%<@@=intarray>
% \end{macrocode}
%
-% \subsection{Allocating arrays}
+% There are two implementations for this module: One \csname{fontdimen} based one
+% for more traditional \TeX\ engines and a Lua based one for engines with Lua support.
+%
+% \subsection{Lua implementation}
+% First, let's look at the Lua variant:
+%
+% We select the Lua version if the Lua helpers were defined. This can be detected by
+% the presence of \cs{@@_gset_count:Nw}.
+%
+% \begin{macrocode}
+%<*tex>
+\cs_if_exist:NTF \@@_gset_count:Nw
+{
+%</tex>
+% \end{macrocode}
+%
+% This moves the decision which variant to use for Lua based engines to the Lua layer.
+% There, the primary criteriu is the existence of the required function \texttt{token.set_lua}
+% and an allocator for \cs{luafunction}s.
+%
+% \begin{macrocode}
+%<*lua>
+if token.set_lua and luatexbase and luatexbase.new_luafunction then
+%</lua>
+% \end{macrocode}
+%
+% \subsubsection{Allocating arrays}
+%
+% \begin{variable}{\l_@@_loop_int}
+% A loop index.
+% \begin{macrocode}
+%<*tex>
+\int_new:N \l_@@_loop_int
+% \end{macrocode}
+% \end{variable}
+%
+% \begin{variable}{\g_@@_table_int}
+% Used to differentiate intarrays in Lua
+% \begin{macrocode}
+\int_new:N \g_@@_table_int
+% \end{macrocode}
+% \end{variable}
+%
+% \begin{macrocode}
+\__kernel_msg_new:nnn { kernel } { negative-array-size }
+ { Size~of~array~may~not~be~negative:~#1 }
+% \end{macrocode}
+%
+% \begin{macro}{\s_@@}
+% Used as marker in for intarrays in Lua. Followed by an unbraced number
+% identifying the array and a single space. This format is used to make it
+% easy to scan from Lua.
+% \begin{macrocode}
+\scan_new:N \s_@@
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\intarray_new:Nn, \intarray_new:cn}
+% \begin{macro}{\@@_new:N}
+% Declare |#1| as a tokenlist with the scanmark and a unique number.
+% Pass the array's size to the Lua helper.
+% Every \texttt{intarray} must be global; it's enough to run this
+% check in \cs{intarray_new:Nn}.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_new:N #1
+ {
+ \__kernel_chk_if_free_cs:N #1
+ \int_gincr:N \g_@@_table_int
+ \cs_gset:Npx #1 { \s_@@ \int_use:N \g_@@_table_int \c_space_tl }
+ }
+\cs_new_protected:Npn \intarray_new:Nn #1#2
+ {
+ \@@_new:N #1
+ \@@_gset_count:Nw #1 \int_eval:n {#2} \scan_stop:
+ \int_compare:nNnT { \intarray_count:N #1 } < 0
+ {
+ \__kernel_msg_error:nnx { kernel } { negative-array-size }
+ { \intarray_count:N #1 }
+ }
+ }
+\cs_generate_variant:Nn \intarray_new:Nn { c }
+%</tex>
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}[EXP]{\intarray_count:N, \intarray_count:c}
+% \begin{macro}[EXP]{\@@_gset_count:Nw}
+% Set and get the size of an array. ``Setting the size'' means in this context that
+% we add zeros until we reach the desired size.
+% \begin{macrocode}
+%<*lua>
+local undefined_cs = token.command_id'undefined_cs'
+local functions = lua.get_functions_table()
+
+local @@_table do
+ local tables = {[0] = {}}
+ function @@_table()
+ local t = token.scan_token()
+ if t.csname ~= 's_@@' then
+ token.put_next(t)
+ tex.error'intarray expected'
+ return tables[0]
+ end
+ local i = token.scan_int()
+ local table = tables[i]
+ if table then return table end
+ table = {}
+ tables[i] = table
+ return table
+ end
+end
+
+local @@_gset_count_func do
+ local tok = token.create'@@_gset_count:Nw'
+ if tok.command == undefined_cs then
+ @@_gset_count_func = luatexbase.new_luafunction'@@_gset_count:Nw'
+ token.set_lua('@@_gset_count:Nw', @@_gset_count_func, 'protected', 'global')
+ else
+ @@_gset_count_func = tok.index or tok.mode
+ end
+end
+
+functions[@@_gset_count_func] = function()
+ local t = @@_table()
+ local n = token.scan_int()
+ for i=#t+1, n do t[i] = 0 end
+end
+
+local intarray_count_func do
+ local tok = token.create'intarray_count:N'
+ if tok.command == undefined_cs then
+ intarray_count_func = luatexbase.new_luafunction'intarray_count:N'
+ token.set_lua('intarray_count:N', intarray_count_func, 'global')
+ else
+ intarray_count_func = tok.index or tok.mode
+ end
+end
+
+functions[intarray_count_func] = function()
+ tex.write(#@@_table())
+end
+%</lua>
+%<*tex>
+\cs_generate_variant:Nn \intarray_count:N { c }
+%</tex>
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Array items}
+%
+% \begin{macro}{\@@_gset:wNwF}
+% The setter provided by Lua. The argument order somewhat emulates the |\fontdimen|
+% This has been chosen over a more conventional order to provide a delimiter for the numbers.
+% \begin{macrocode}
+%<*lua>
+
+local @@_gset_func do
+local tok = token.create'@@_gset:wNwF'
+ if tok.command == undefined_cs then
+ @@_gset_func = luatexbase.new_luafunction'@@_gset:wNwF'
+ token.set_lua('@@_gset:wNwF', @@_gset_func, 'protected', 'global')
+ else
+ @@_gset_func = tok.index or tok.mode
+ end
+end
+
+functions[@@_gset_func] = function()
+ local i = token.scan_int()
+ local t = @@_table()
+ if t[i] then
+ t[i] = token.scan_int()
+ token.scan_toks()
+ else
+ token.scan_int()
+ token.put_next(token.scan_toks())
+ end
+end
+%</lua>
+% \end{macrocode}
+% \begin{end}
+%
+% \begin{macro}{\intarray_gset:Nnn, \intarray_gset:cnn, \__kernel_intarray_gset:Nnn}
+% Set the appropriate \tn{fontdimen}. The
+% \cs{__kernel_intarray_gset:Nnn} function does not use
+% \cs{int_eval:n}, namely its arguments must be suitable for
+% \cs{int_value:w}. The user version checks the position and value
+% are within bounds.
+% \begin{macrocode}
+%<*tex>
+\cs_new_protected:Npn \__kernel_intarray_gset:Nnn #1#2#3
+{ \@@_gset:wNwF #2 #1 #3 { } }
+\cs_new_protected:Npn \intarray_gset:Nnn #1#2#3
+ {
+ \@@_gset:wNwF \int_eval:n {#2} #1 \int_eval:n{#3}
+ {
+ \__kernel_msg_error:nnxxx { kernel } { out-of-bounds }
+ { \token_to_str:N #1 } { \int_eval:n {#2} } { \intarray_count:N #1 }
+ }
+ }
+\cs_generate_variant:Nn \intarray_gset:Nnn { c }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\intarray_gzero:N, \intarray_gzero:c}
+% Set the appropriate \tn{fontdimen} to zero. No bound checking
+% needed. The \cs{prg_replicate:nn} possibly uses quite a lot of
+% memory, but this is somewhat comparable to the size of the array,
+% and it is much faster than an \cs{int_step_inline:nn} loop.
+% \begin{macrocode}
+\cs_new_protected:Npn \intarray_gzero:N #1
+ {
+ \int_zero:N \l_@@_loop_int
+ \prg_replicate:nn { \intarray_count:N #1 }
+ {
+ \int_incr:N \l_@@_loop_int
+ \@@_gset:wNwF \l_@@_loop_int #1 \c_zero_dim {}
+ }
+ }
+\cs_generate_variant:Nn \intarray_gzero:N { c }
+%</tex>
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[EXP]{\intarray_item:Nn, \intarray_item:cn, \__kernel_intarray_item:Nn}
+% \begin{macro}{\@@_item:NwF}
+% Get the appropriate \tn{fontdimen} and perform bound checks. The
+% \cs{__kernel_intarray_item:Nn} function omits bound checks and omits
+% \cs{int_eval:n}, namely its argument must be a \TeX{} integer
+% suitable for \cs{int_value:w}.
+% \begin{macrocode}
+%<*lua>
+local @@_item_func do
+local tok = token.create'@@_item:NwF'
+ if tok.command == undefined_cs then
+ @@_item_func = luatexbase.new_luafunction'@@_item:NwF'
+ token.set_lua('@@_item:NwF', @@_item_func, 'global')
+ else
+ @@_item_func = tok.index or tok.mode
+ end
+end
+
+functions[@@_item_func] = function()
+ local t = @@_table()
+ local item = t[token.scan_int()]
+ if item then
+ token.scan_toks()
+ else
+ token.put_next(token.scan_toks())
+ end
+ tex.write(item or 0)
+end
+%</lua>
+% \begin{macrocode}
+% \end{macrocode}
+%<*tex>
+\cs_new:Npn \__kernel_intarray_item:Nn #1#2
+ { \@@_item:NwF #1 #2 { } }
+\cs_new:Npn \intarray_item:Nn #1#2
+ {
+ \@@_item:NwF #1 \int_eval:n {#2}
+ {
+ \__kernel_msg_expandable_error:nnfff { kernel } { out-of-bounds }
+ { \token_to_str:N #1 } { \int_eval:n {#2} } { \intarray_count:N #1 }
+ }
+ }
+\cs_generate_variant:Nn \intarray_item:Nn { c }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\intarray_rand_item:N, \intarray_rand_item:c}
+% Importantly, \cs{intarray_item:Nn} only evaluates its argument once.
+% (Except if it's out of bounds, but that can't happen here.)
+% \begin{macrocode}
+\cs_new:Npn \intarray_rand_item:N #1
+ { \intarray_item:Nn #1 { \int_rand:n { \intarray_count:N #1 } } }
+\cs_generate_variant:Nn \intarray_rand_item:N { c }
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Working with contents of integer arrays}
+%
+% \begin{macro}{\intarray_const_from_clist:Nn, \intarray_const_from_clist:cn}
+% The current Lua helpers do not allow to avoid bound checking, so we have
+% to count the elements first. Otherwise it is basically the same as
+% \cs{intarray_new:Nn} (which we don't use because it would complain about the
+% wrong qualifier in debugging mode)
+% \begin{macrocode}
+\cs_new_protected:Npn \intarray_const_from_clist:Nn #1#2
+ {
+ \@@_new:N #1
+ \@@_gset_count:Nw #1 \clist_count:n {#2} \scan_stop:
+ \int_zero:N \l_@@_loop_int
+ \clist_map_inline:nn {#2}
+ {
+ \int_incr:N \l_@@_loop_int
+ \__kernel_intarray_gset:Nnn #1 \l_@@_loop_int { \int_eval:n {##1} } }
+ }
+\cs_generate_variant:Nn \intarray_const_from_clist:Nn { c }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[rEXP]{\intarray_to_clist:N, \intarray_to_clist:c}
+% \begin{macro}[rEXP]{\@@_to_clist:Nn, \@@_to_clist:w}
+% Loop through the array, putting a comma before each item. Remove
+% the leading comma with |f|-expansion. We also use the auxiliary in
+% \cs{intarray_show:N} with argument comma, space.
+% \begin{macrocode}
+\cs_new:Npn \intarray_to_clist:N #1 { \@@_to_clist:Nn #1 { , } }
+\cs_generate_variant:Nn \intarray_to_clist:N { c }
+\cs_new:Npn \@@_to_clist:Nn #1#2
+ {
+ \int_compare:nNnF { \intarray_count:N #1 } = \c_zero_int
+ {
+ \exp_last_unbraced:Nf \use_none:n
+ { \@@_to_clist:w 1 ; #1 {#2} \prg_break_point: }
+ }
+ }
+\cs_new:Npn \@@_to_clist:w #1 ; #2#3
+ {
+ \if_int_compare:w #1 > \intarray_count:N #2 ~
+ \prg_break:n
+ \fi:
+ #3 \__kernel_intarray_item:Nn #2 {#1}
+ \exp_after:wN \@@_to_clist:w
+ \int_value:w \int_eval:w #1 + \c_one_int ; #2 {#3}
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\intarray_show:N, \intarray_show:c, \intarray_log:N, \intarray_log:c}
+% Convert the list to a comma list (with spaces after each comma)
+% \begin{macrocode}
+\cs_new_protected:Npn \intarray_show:N { \@@_show:NN \msg_show:nnxxxx }
+\cs_generate_variant:Nn \intarray_show:N { c }
+\cs_new_protected:Npn \intarray_log:N { \@@_show:NN \msg_log:nnxxxx }
+\cs_generate_variant:Nn \intarray_log:N { c }
+\cs_new_protected:Npn \@@_show:NN #1#2
+ {
+ \__kernel_chk_defined:NT #2
+ {
+ #1 { LaTeX/kernel } { show-intarray }
+ { \token_to_str:N #2 }
+ { \intarray_count:N #2 }
+ { >~ \@@_to_clist:Nn #2 { , ~ } }
+ { }
+ }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{Random arrays}
+%
+% \begin{macro}{\intarray_gset_rand:Nn, \intarray_gset_rand:cn}
+% \begin{macro}{\intarray_gset_rand:Nnn, \intarray_gset_rand:cnn}
+% \begin{macro}
+% {
+% \@@_gset_rand:Nnn,
+% \@@_gset_rand:Nff,
+% \@@_gset_rand_auxi:Nnnn,
+% \@@_gset_rand_auxii:Nnnn,
+% \@@_gset_rand_auxiii:Nnnn,
+% \@@_gset_all_same:Nn,
+% }
+% We only perform the bounds checks once. This is done by two
+% \cs{@@_gset_overflow_test:nw}, with an appropriate empty argument to
+% avoid a spurious \enquote{at position \texttt{\#1}} part in the
+% error message. Then calculate the number of choices: this is at
+% most $(2^{30}-1)-(-(2^{30}-1))+1=2^{31}-1$, which just barely does
+% not overflow. For small ranges use \cs{__kernel_randint:n} (making
+% sure to subtract~$1$ \emph{before} adding the random number to the
+% \meta{min}, to avoid overflow when \meta{min} or \meta{max} are
+% $\pm\cs{c_max_int}$), otherwise \cs{__kernel_randint:nn}. Finally,
+% if there are no random numbers do not define any of the auxiliaries.
+% \begin{macrocode}
+\cs_new_protected:Npn \intarray_gset_rand:Nn #1
+ { \intarray_gset_rand:Nnn #1 { 1 } }
+\cs_generate_variant:Nn \intarray_gset_rand:Nn { c }
+\sys_if_rand_exist:TF
+ {
+ \cs_new_protected:Npn \intarray_gset_rand:Nnn #1#2#3
+ {
+ \@@_gset_rand:Nff #1
+ { \int_eval:n {#2} } { \int_eval:n {#3} }
+ }
+ \cs_new_protected:Npn \@@_gset_rand:Nnn #1#2#3
+ {
+ \int_compare:nNnTF {#2} > {#3}
+ {
+ \__kernel_msg_expandable_error:nnnn
+ { kernel } { randint-backward-range } {#2} {#3}
+ \@@_gset_rand:Nnn #1 {#3} {#2}
+ }
+ {
+ \@@_gset_rand_auxi:Nnnn #1 { } {#2} {#3}
+ }
+ }
+ \cs_generate_variant:Nn \@@_gset_rand:Nnn { Nff }
+ \cs_new_protected:Npn \@@_gset_rand_auxi:Nnnn #1#2#3#4
+ {
+ \@@_gset_rand_auxii:Nnnn #1 { } {#4} {#3}
+ }
+ \cs_new_protected:Npn \@@_gset_rand_auxii:Nnnn #1#2#3#4
+ {
+ \exp_args:NNf \@@_gset_rand_auxiii:Nnnn #1
+ { \int_eval:n { #3 - #4 + 1 } } {#4} {#3}
+ }
+ \cs_new_protected:Npn \@@_gset_rand_auxiii:Nnnn #1#2#3#4
+ {
+ \exp_args:NNf \@@_gset_all_same:Nn #1
+ {
+ \int_compare:nNnTF {#2} > \c__kernel_randint_max_int
+ {
+ \exp_stop_f:
+ \int_eval:n { \__kernel_randint:nn {#3} {#4} }
+ }
+ {
+ \exp_stop_f:
+ \int_eval:n { \__kernel_randint:n {#2} - 1 + #3 }
+ }
+ }
+ }
+ \cs_new_protected:Npn \@@_gset_all_same:Nn #1#2
+ {
+ \int_zero:N \l_@@_loop_int
+ \prg_replicate:nn { \intarray_count:N #1 }
+ {
+ \int_incr:N \l_@@_loop_int
+ \__kernel_intarray_gset:Nnn #1 \l_@@_loop_int {#2}
+ }
+ }
+ }
+ {
+ \cs_new_protected:Npn \intarray_gset_rand:Nnn #1#2#3
+ {
+ \__kernel_msg_error:nnn { kernel } { fp-no-random }
+ { \intarray_gset_rand:Nnn #1 {#2} {#3} }
+ }
+ }
+\cs_generate_variant:Nn \intarray_gset_rand:Nnn { c }
+%</tex>
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \end{macrocode}
+%<*lua>
+end
+%</lua>
+% \begin{macrocode}
+%
+% \subsection{Font dimension based implementation}
+%
+% Go to the false branch of the conditional above.
+% \begin{macrocode}
+%<*tex>
+}{
+% \end{macrocode}
+%
+% \subsubsection{Allocating arrays}
%
% \begin{macro}{\@@_entry:w, \@@_count:w}
% We use these primitives quite a lot in this module.
@@ -255,7 +717,7 @@
% \end{macrocode}
% \end{macro}
%
-% \subsection{Array items}
+% \subsubsection{Array items}
%
% \begin{macro}[EXP]{\@@_signed_max_dim:n}
% Used when an item to be stored is larger than \cs{c_max_dim} in
@@ -400,7 +862,7 @@
% \end{macrocode}
% \end{macro}
%
-% \subsection{Working with contents of integer arrays}
+% \subsubsection{Working with contents of integer arrays}
%
% \begin{macro}{\intarray_const_from_clist:Nn, \intarray_const_from_clist:cn}
% \begin{macro}{\@@_const_from_clist:nN}
@@ -482,7 +944,7 @@
% \end{macrocode}
% \end{macro}
%
-% \subsection{Random arrays}
+% \subsubsection{Random arrays}
%
% \begin{macro}{\intarray_gset_rand:Nn, \intarray_gset_rand:cn}
% \begin{macro}{\intarray_gset_rand:Nnn, \intarray_gset_rand:cnn}
@@ -579,6 +1041,8 @@
% \end{macro}
%
% \begin{macrocode}
+}
+%</tex>
%</package>
% \end{macrocode}
%
diff --git a/l3kernel/l3luatex.dtx b/l3kernel/l3luatex.dtx
index 01686ced0..f513a60c7 100644
--- a/l3kernel/l3luatex.dtx
+++ b/l3kernel/l3luatex.dtx
@@ -556,6 +556,83 @@ l3kernel.shellescape = shellescape
% \end{macrocode}
% \end{macro}
%
+% \subsection{Preserving iniTeX Lua data for runs}
+%
+% \begin{macrocode}
+%<@@=lua>
+% \end{macrocode}
+%
+% The Lua state is not dumped when a forat is written, therefore any Lua
+% variables filled doing format building need to be restored in order to
+% be accessible during normal runs.
+%
+% We provide some kernel-internal helpers for this. They will only be available if
+% \texttt{luatexbase} is available. This is not a big restriction though, because
+% ConTeXt (which does not use \texttt{luatexbase}) does not load expl3 in the format.
+%
+% \begin{macrocode}
+local register_luadata, get_luadata
+
+if luatexbase then
+ local register = token.create'luadata_bytecode_register'.index
+ if status.initex then
+% \end{macrocode}
+%
+% \begin{macro}{register_luadata}
+% \texttt{register_luadata} is only available during format generation.
+% It accept a string which uniquely identifies the data object and has to be
+% provided to retrieve it later. Additionally it accepts a function which is
+% called in the \texttt{pre_dump} callback and which has to return a string that
+% evaluates to a valid Lua object to be preserved.
+% \begin{macrocode}
+ local luadata, luadata_order = {}, {}
+
+ function register_luadata(name, func)
+ if luadata[name] then
+ error(string.format("LaTeX3 error: data name %q already in use", name))
+ end
+ luadata[name] = func
+ luadata_order[#luadata_order + 1] = func and name
+ end
+% \end{macrocode}
+% \end{macro}
+%
+% The actual work is done in \texttt{pre_dump}. The \texttt{luadata_order} is used
+% to ensure that the order is consistent over multiple runs.
+% \begin{macrocode}
+ luatexbase.add_to_callback("pre_dump", function()
+ if next(luadata) then
+ local str = "return {"
+ for i=1, #luadata_order do
+ local name = luadata_order[i]
+ str = string.format('%s["%q"]=%s,', str, name, luadata[name]())
+ end
+ lua.bytecode[register] = load(str .. "}")
+ end
+ end, "latex3.luadata")
+ else
+% \end{macrocode}
+%
+% \begin{macro}{get_luadata}
+% \texttt{get_luadata} is only available if data should be restored.
+% It accept the identifier which was used when the data object was registered and
+% returns the associated object. Every object can only be retrieved once.
+% \begin{macrocode}
+ local luadata = lua.bytecode[register]
+ if luadata then
+ luadata = luadata()
+ end
+ function get_luadata(name)
+ if not luadata then return end
+ local data = luadata[name]
+ luadata[name] = nil
+ return data
+ end
+ end
+end
+% \end{macro}
+% \end{macrocode}
+%
% \begin{macrocode}
%</lua>
% \end{macrocode}
diff --git a/l3kernel/testfiles/m3intarray001.lvt b/l3kernel/testfiles/m3intarray001.lvt
index 0cfe6b17f..77e2e4920 100644
--- a/l3kernel/testfiles/m3intarray001.lvt
+++ b/l3kernel/testfiles/m3intarray001.lvt
@@ -69,7 +69,9 @@
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\int_gadd:Nn \g__intarray_font_int { 100000 } % to make sure nothing is suppressed accidentally by scaling the font.
+\cs_if_exist:NT \g__intarray_font_int {
+ \int_gadd:Nn \g__intarray_font_int { 100000 } % to make sure nothing is suppressed accidentally by scaling the font.
+}
\TEST { Any~stray~non-zero? }
{
\intarray_new:Nn \g_testd_intarray { 10 }
More information about the latex3-commits
mailing list.