[latex3-commits] [git/LaTeX3-latex3-latex3] luaintarray: Integrate some suggestions (ed6777521)

Marcel Fabian Krüger tex at 2krueger.de
Sat Nov 13 15:44:23 CET 2021


Repository : https://github.com/latex3/latex3
On branch  : luaintarray
Link       : https://github.com/latex3/latex3/commit/ed6777521b850233408865e65117036904f8d458

>---------------------------------------------------------------

commit ed6777521b850233408865e65117036904f8d458
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Sat Nov 13 15:44:23 2021 +0100

    Integrate some suggestions


>---------------------------------------------------------------

ed6777521b850233408865e65117036904f8d458
 l3kernel/l3intarray.dtx                     | 28 ++++++++++------------------
 l3kernel/l3luatex.dtx                       |  2 +-
 l3kernel/testfiles/m3intarray001.luatex.tlg |  4 ++++
 3 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/l3kernel/l3intarray.dtx b/l3kernel/l3intarray.dtx
index f9e927619..fb5c6152e 100644
--- a/l3kernel/l3intarray.dtx
+++ b/l3kernel/l3intarray.dtx
@@ -273,8 +273,6 @@ tex.runtoks(function()
 end)
 
 local scan_token = token.scan_token
-local scan_toks = token.scan_toks
-local get_csname = token.get_csname
 local put_next = token.put_next
 local s_@@ = token_create's_@@'
 local use_none = token_create'use_none:n'
@@ -282,7 +280,6 @@ local use_i = token_create'use:n'
 local expand_after_scan_stop = {token_create'exp_after:wN',
                                 token_create'scan_stop:'}
 local comma = token_create(string.byte',')
-local scan_argument = token.scan_argument
 %    \end{macrocode}
 %
 % \begin{macro}{@@_table}
@@ -380,11 +377,7 @@ end, 'protected', 'global')
 luacmd('@@_gset:w', function()
   local i = scan_int()
   local t = @@_table()
-  if t[i] then
-    t[i] = scan_int()
-  else
-    scan_int()
-  end
+  t[i] = scan_int()
 end, 'protected', 'global')
 %</lua>
 %    \end{macrocode}
@@ -450,7 +443,9 @@ luacmd('@@_item:wF', function()
   end
   put_next(expand_after_scan_stop)
   scan_token()
-  sprint(-2, item or 0)
+  if item then
+    sprint(-2, item)
+  end
 end, 'global')
 
 luacmd('@@_item:w', function()
@@ -471,6 +466,7 @@ end, 'global')
       {
         \msg_expandable_error:nnfff { kernel } { out-of-bounds }
           { \token_to_str:N #1 } { \int_use:N \l_@@_bad_index_int } { \intarray_count:N #1 }
+        0
       }
   }
 \cs_generate_variant:Nn \intarray_item:Nn { c }
@@ -500,7 +496,6 @@ end, 'global')
 \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}
       {
@@ -532,24 +527,21 @@ end, 'global')
 % \end{macro}
 % \end{macro}
 %
-% \begin{macro}[rEXP]{\__kernel_intarray_range_to_clist:Nnn, \@@_range_to_clist:ww}
+% \begin{macro}[rEXP]{\__kernel_intarray_range_to_clist:Nnn, \@@_range_to_clist:w}
 %   Loop through part of the array.
 %    \begin{macrocode}
 %<*tex>
 \cs_new:Npn \__kernel_intarray_range_to_clist:Nnn #1#2#3
   {
-    \exp_after:wN \@@_range_to_clist:ww
-    \int_value:w \int_eval:w #2 \exp_after:wN ;
-    \int_value:w \int_eval:w #3
-    #1
+    \@@_range_to_clist:w #1
+    \int_eval:n {#2} ~ \int_eval:n {#3} ~
   }
 %</tex>
 %<*lua>
-luacmd('@@_range_to_clist:ww', function()
+luacmd('@@_range_to_clist:w', function()
+  local t = @@_table()
   local from = scan_int()
-  scan_token()
   local to = scan_int()
-  local t = @@_table()
   sprint(-2, concat(t, ',', from, to))
 end, 'global')
 %</lua>
diff --git a/l3kernel/l3luatex.dtx b/l3kernel/l3luatex.dtx
index d28f3b9e9..0c945dd0c 100644
--- a/l3kernel/l3luatex.dtx
+++ b/l3kernel/l3luatex.dtx
@@ -722,7 +722,7 @@ if luatexbase then
 % 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()
+    luatexbase.add_to_callback("pre_dump", function()
       if next(luadata) then
         local str = "return {"
         for i=1, #luadata_order do
diff --git a/l3kernel/testfiles/m3intarray001.luatex.tlg b/l3kernel/testfiles/m3intarray001.luatex.tlg
index 815e31c8c..58d761232 100644
--- a/l3kernel/testfiles/m3intarray001.luatex.tlg
+++ b/l3kernel/testfiles/m3intarray001.luatex.tlg
@@ -61,9 +61,13 @@ followed by the required stuff, so I'm ignoring it.
 TEST 3: Unsafe array operations with errors
 ============================================================
 Defining \g_testb_intarray on line ...
+2000000000
 -2000000000
 0
+123456
+1234567
 Defining \g_testc_intarray on line ...
+12345678
 ============================================================
 ============================================================
 TEST 4: Any stray non-zero?





More information about the latex3-commits mailing list.