[latex3-commits] [git/LaTeX3-latex3-latex3] main: fix overflow issue (708ee4f3a)

Joseph Wright joseph.wright at morningstar2.co.uk
Mon Jan 10 14:45:55 CET 2022


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/708ee4f3a266dad9e18ee25f46cf083eaaf3a7b3

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

commit 708ee4f3a266dad9e18ee25f46cf083eaaf3a7b3
Author: Jonathan Spratte <jspratte at yahoo.de>
Date:   Tue Nov 17 00:52:37 2020 +0100

    fix overflow issue


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

708ee4f3a266dad9e18ee25f46cf083eaaf3a7b3
 l3kernel/l3prop.dtx | 35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/l3kernel/l3prop.dtx b/l3kernel/l3prop.dtx
index f25f738d8..89593da0d 100644
--- a/l3kernel/l3prop.dtx
+++ b/l3kernel/l3prop.dtx
@@ -1084,11 +1084,6 @@
 %   \cs{__kernel_exp_not:w} to start the expansion context to expand in two
 %   steps. If the \meta{property list} is empty they just leave an empty set of
 %   braces in the input stream for \cs{__kernel_exp_not:w}.
-%   In order to not have to read the contents of the \meta{property list} more
-%   often than necessary, in both versions an unmatched closing brace is used to
-%   mark the end of the result. Once we're done we can then leave an unmatched
-%   opening brace in the input stream so that \cs{__kernel_exp_not:w} grabs its
-%   argument.
 %    \begin{macrocode}
 \cs_if_exist:NTF \tex_expanded:D
   {
@@ -1096,7 +1091,11 @@
 %   The variant using \cs{tex_expanded:D} can just iterate over the
 %   \meta{property list} and remove the leading comma afterwards. Only the value
 %   has to be protected in \cs{exp_not:n} as the property name is always a
-%   string.
+%   string. In order to not have to read the contents of the
+%   \meta{property list} more often than necessary, this version uses an
+%   unmatched closing brace to mark the end of the result. Once we're done we
+%   just remove the leading comma and leave an unmatched opening brace in the
+%   input stream so that \cs{__kernel_exp_not:w} grabs its argument.
 %    \begin{macrocode}
     \cs_new:Npn \prop_to_keyval:N #1
       {
@@ -1118,9 +1117,12 @@
   }
 %    \end{macrocode}
 %   The other variant will iterate over the \meta{property list} and has to
-%   output the result behind a marker. As a result this is considerably slower
-%   than the \cs{tex_expanded:D} using variant.
-%   After the loop the leading comma can be gobbled.
+%   output the result in a group after a marker. As a result this is
+%   considerably slower than the \cs{tex_expanded:D} using variant as it has to
+%   read the entire contents of the \meta{property list} for each item.
+%   After the loop the marker is removed and the leading comma is gobbled by
+%   \cs{use_none:n}, leaving the result as the argument to
+%   \cs{__kernel_exp_not:w}.
 %    \begin{macrocode}
   {
     \cs_new:Npn \prop_to_keyval:N #1
@@ -1129,17 +1131,14 @@
           \prop_if_empty:NTF #1
             { {} }
             {
-              \if_false: { \fi:
-                \prop_map_function:NN #1 \@@_to_keyval_aux:nnw
-                \@@_to_keyval_aux:w
-                \s_@@_mark
-              }
+              \prop_map_function:NN #1 \@@_to_keyval_aux:nnw
+              \@@_to_keyval_aux:w
+              \s_@@_mark { \use_none:n }
             }
       }
-    \cs_new:Npn \@@_to_keyval_aux:w \s_@@_mark ,
-      { \exp_after:wN { \if_false: } \fi: }
-    \cs_new:Npn \@@_to_keyval_aux:nnw #1#2#3 \s_@@_mark
-      { #3 \s_@@_mark , #1 =~ {#2} }
+    \cs_new:Npn \@@_to_keyval_aux:w \s_@@_mark { \exp_after:wN }
+    \cs_new:Npn \@@_to_keyval_aux:nnw #1#2#3 \s_@@_mark #4
+      { #3 \s_@@_mark { #4 , #1 =~ {#2} } }
   }
 %    \end{macrocode}
 % \end{macro}





More information about the latex3-commits mailing list.