[latex3-commits] [git/LaTeX3-latex3-latex3] master: Use new tl_build functions in l3regex (f8de3c9)

Bruno Le Floch bruno at le-floch.fr
Sun Apr 1 20:58:56 CEST 2018


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/f8de3c9a659badc441536cef415e762609b92b07

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

commit f8de3c9a659badc441536cef415e762609b92b07
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Sun Apr 1 11:06:56 2018 -0400

    Use new tl_build functions in l3regex
    
    That's slightly tricky because l3regex relied on the group that old
    tl_build functions created.


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

f8de3c9a659badc441536cef415e762609b92b07
 l3kernel/l3regex.dtx |  215 ++++++++++++++++++++++++++++++--------------------
 1 file changed, 129 insertions(+), 86 deletions(-)

diff --git a/l3kernel/l3regex.dtx b/l3kernel/l3regex.dtx
index f39cae8..9dfcae0 100644
--- a/l3kernel/l3regex.dtx
+++ b/l3kernel/l3regex.dtx
@@ -1038,6 +1038,14 @@
 %    \end{macrocode}
 % \end{variable}
 %
+% \begin{variable}{\l_@@_build_tl}
+%   This temporary variable is specifically for use with the |tl_build|
+%   machinery.
+%    \begin{macrocode}
+\tl_new:N \l_@@_build_tl
+%    \end{macrocode}
+% \end{variable}
+%
 % \begin{variable}{\c_@@_no_match_regex}
 %   This regular expression matches nothing, but is still a valid
 %   regular expression. We could use a failing assertion, but I went for
@@ -1455,28 +1463,30 @@
 %
 % The conversion is mostly done within an \texttt{x}-expanding
 % assignment, except for the |\x| escape sequence, which is not amenable
-% to that in general. For this, we use the general framework of
-% \cs{tl_build:Nw}.
+% to that in general. For this, we use the general framework of |tl_build|.
 %
 % \begin{macro}{\@@_escape_use:nnnn}
 %   The result is built in \cs{l_@@_internal_a_tl}, which is then
 %   left in the input stream.  Go through |#4| once, applying |#1|,
 %   |#2|, or |#3| as relevant to each character (after de-escaping
 %   it). Note that we cannot replace \cs{tl_set:Nx} and
-%   \cs{tl_build_add:o} by a single call to \cs{tl_build_add:x}, because
+%   \cs{tl_build_put_right:Nx} by a single call to \cs{tl_build_put_right:Nx}, because
 %   the \texttt{x}-expanding assignment may be interrupted by |\x|.
 %    \begin{macrocode}
 \__kernel_patch:nnNNpn
   {
     \@@_trace_push:nnN { regex } { 1 } \@@_escape_use:nnnn
-    \tl_build:Nw \l_@@_internal_a_tl
-      \tl_build_add:n { \@@_trace_pop:nnN { regex } { 1 } \@@_escape_use:nnnn }
-      \use_none:nn
+    \group_begin:
+      \tl_build_begin:N \l_@@_build_tl
+      \tl_build_put_right:Nn \l_@@_build_tl
+        { \@@_trace_pop:nnN { regex } { 1 } \@@_escape_use:nnnn }
+      \use_none:nnn
   }
   { }
 \cs_new_protected:Npn \@@_escape_use:nnnn #1#2#3#4
   {
-    \tl_build:Nw \l_@@_internal_a_tl
+    \group_begin:
+      \tl_build_begin:N \l_@@_build_tl
       \cs_set:Npn \@@_escape_unescaped:N ##1 { #1 }
       \cs_set:Npn \@@_escape_escaped:N ##1 { #2 }
       \cs_set:Npn \@@_escape_raw:N ##1 { #3 }
@@ -1487,9 +1497,12 @@
           \exp_after:wN \@@_escape_loop:N \g_@@_internal_tl
           { break } \prg_break_point:
         }
-      \tl_build_add:o \l_@@_internal_b_tl
-    \tl_build_end:
-    \l_@@_internal_a_tl
+      \tl_build_put_right:Nx \l_@@_build_tl
+        { \exp_not:o \l_@@_internal_b_tl }
+      \tl_build_end:N \l_@@_build_tl
+      \exp_after:wN
+    \group_end:
+    \l_@@_build_tl
   }
 %    \end{macrocode}
 % \end{macro}
@@ -1583,7 +1596,8 @@
     \int_compare:nNnTF {#1} > \c_max_char_int
       {
         \if_false: { \fi: }
-        \tl_build_add:o \l_@@_internal_b_tl
+        \tl_build_put_right:Nx \l_@@_build_tl
+          { \exp_not:o \l_@@_internal_b_tl }
         \__kernel_msg_error:nnx { kernel } { x-overflow } {#1}
         \tl_set:Nx \l_@@_internal_b_tl
           { \if_false: } \fi:
@@ -1672,7 +1686,8 @@
 \cs_new:Npn \@@_escape_x_loop_error:n #1
   {
     \if_false: { \fi: }
-    \tl_build_add:o \l_@@_internal_b_tl
+    \tl_build_put_right:Nx \l_@@_build_tl
+      { \exp_not:o \l_@@_internal_b_tl }
     \__kernel_msg_error:nnx { kernel } { x-missing-rbrace } {#1}
     \tl_set:Nx \l_@@_internal_b_tl
       { \if_false: } \fi: \@@_escape_loop:N #1
@@ -2126,13 +2141,15 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_compile:w
   {
-    \tl_build_x:Nw \l_@@_internal_regex
+    \group_begin:
+      \tl_build_begin:N \l_@@_build_tl
       \int_zero:N \l_@@_group_level_int
       \int_set_eq:NN \l_@@_default_catcodes_int \c_@@_all_catcodes_int
       \int_set_eq:NN \l_@@_catcodes_int \l_@@_default_catcodes_int
       \cs_set:Npn \@@_item_equal:n  { \@@_item_caseful_equal:n }
       \cs_set:Npn \@@_item_range:nn { \@@_item_caseful_range:nn }
-      \tl_build_add:n { \@@_branch:n { \if_false: } \fi: }
+      \tl_build_put_right:Nn \l_@@_build_tl
+        { \@@_branch:n { \if_false: } \fi: }
   }
 \cs_new_protected:Npn \@@_compile_end:
   {
@@ -2149,17 +2166,23 @@
         \prg_replicate:nn
           { \l_@@_group_level_int }
           {
-              \tl_build_add:n
+              \tl_build_put_right:Nn \l_@@_build_tl
                 {
                   \if_false: { \fi: }
                   \if_false: { \fi: } { 1 } { 0 } \c_true_bool
                 }
-            \tl_build_end:
-            \tl_build_add:o \l_@@_internal_regex
+              \tl_build_end:N \l_@@_build_tl
+              \exp_args:NNNo
+            \group_end:
+            \tl_build_put_right:Nn \l_@@_build_tl
+              { \l_@@_build_tl }
           }
       \fi:
-      \tl_build_add:n { \if_false: { \fi: } }
-    \tl_build_end:
+      \tl_build_put_right:Nn \l_@@_build_tl { \if_false: { \fi: } }
+      \tl_build_end:N \l_@@_build_tl
+      \exp_args:NNNx
+    \group_end:
+    \tl_set:Nn \l_@@_internal_regex { \l_@@_build_tl }
   }
 %    \end{macrocode}
 % \end{macro}
@@ -2241,10 +2264,10 @@
     \@@_mode_quit_c:
     \@@_if_in_class:TF { }
       {
-        \tl_build_add:n
+        \tl_build_put_right:Nn \l_@@_build_tl
           { \@@_class:NnnnN \c_true_bool { \if_false: } \fi: }
       }
-    \tl_build_add:x
+    \tl_build_put_right:Nx \l_@@_build_tl
       {
         \if_int_compare:w \l_@@_catcodes_int < \c_@@_all_catcodes_int
           \@@_item_catcode:nT { \int_use:N \l_@@_catcodes_int }
@@ -2301,7 +2324,10 @@
 %   whatever characters were grabbed are left raw).
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_compile_quantifier_none:
-  { \tl_build_add:n { \if_false: { \fi: } { 1 } { 0 } \c_false_bool } }
+  {
+    \tl_build_put_right:Nn \l_@@_build_tl
+      { \if_false: { \fi: } { 1 } { 0 } \c_false_bool }
+  }
 \cs_new_protected:Npn \@@_compile_quantifier_abort:xNN #1#2#3
   {
     \@@_compile_quantifier_none:
@@ -2324,9 +2350,13 @@
 \cs_new_protected:Npn \@@_compile_quantifier_lazyness:nnNN #1#2#3#4
   {
     \str_if_eq:nnTF { #3 #4 } { \@@_compile_special:N ? }
-      { \tl_build_add:n { \if_false: { \fi: } { #1 } { #2 } \c_true_bool } }
       {
-        \tl_build_add:n { \if_false: { \fi: } { #1 } { #2 } \c_false_bool }
+        \tl_build_put_right:Nn \l_@@_build_tl
+          { \if_false: { \fi: } { #1 } { #2 } \c_true_bool }
+      }
+      {
+        \tl_build_put_right:Nn \l_@@_build_tl
+          { \if_false: { \fi: } { #1 } { #2 } \c_false_bool }
         #3 #4
       }
   }
@@ -2513,7 +2543,7 @@
         \if_int_compare:w `#1 > `#3 \exp_stop_f:
           \__kernel_msg_error:nnxx { kernel } { range-backwards } {#1} {#3}
         \else:
-          \tl_build_add:x
+          \tl_build_put_right:Nx \l_@@_build_tl
             {
               \if_int_compare:w `#1 = `#3 \exp_stop_f:
                 \@@_item_equal:n
@@ -2527,7 +2557,7 @@
       {
         \__kernel_msg_warning:nnxx { kernel } { range-missing-end }
           {#1} { \c_backslash_str #3 }
-        \tl_build_add:x
+        \tl_build_put_right:Nx \l_@@_build_tl
           {
             \@@_item_equal:n { \int_value:w `#1 \exp_stop_f: }
             \@@_item_equal:n { \int_value:w `- \exp_stop_f: }
@@ -2611,7 +2641,7 @@
   {
     \@@_if_in_class_or_catcode:TF {#2}
       {
-        \tl_build_add:n
+        \tl_build_put_right:Nn \l_@@_build_tl
           { \@@_assertion:Nn \c_true_bool { \@@_anchor:N #1 } }
       }
   }
@@ -2648,7 +2678,7 @@
     \@@_if_in_class_or_catcode:TF
       { \@@_compile_raw_error:N b }
       {
-        \tl_build_add:n
+        \tl_build_put_right:Nn \l_@@_build_tl
           { \@@_assertion:Nn \c_true_bool { \@@_b_test: } }
       }
   }
@@ -2657,7 +2687,7 @@
     \@@_if_in_class_or_catcode:TF
       { \@@_compile_raw_error:N B }
       {
-        \tl_build_add:n
+        \tl_build_put_right:Nn \l_@@_build_tl
           { \@@_assertion:Nn \c_false_bool { \@@_b_test: } }
       }
   }
@@ -2678,7 +2708,7 @@
     \@@_if_in_class:TF
       {
         \if_int_compare:w \l_@@_mode_int > \c_@@_catcode_in_class_mode_int
-          \tl_build_add:n { \if_false: { \fi: } }
+          \tl_build_put_right:Nn \l_@@_build_tl { \if_false: { \fi: } }
         \fi:
         \tex_advance:D \l_@@_mode_int - 15 \exp_stop_f:
         \tex_divide:D \l_@@_mode_int 13 \exp_stop_f:
@@ -2742,7 +2772,7 @@
 \cs_new_protected:Npn \@@_compile_class_catcode:w #1;
   {
     \if_int_compare:w \l_@@_mode_int = \c_@@_catcode_mode_int
-      \tl_build_add:n
+      \tl_build_put_right:Nn \l_@@_build_tl
         { \@@_class:NnnnN \c_true_bool { \if_false: } \fi: }
     \fi:
     \int_set_eq:NN \l_@@_catcodes_int \l_@@_default_catcodes_int
@@ -2764,11 +2794,11 @@
     \l_@@_mode_int = \int_value:w \l_@@_mode_int 3 \exp_stop_f:
     \str_if_eq:nnTF { #3 #4 } { \@@_compile_special:N ^ }
       {
-        \tl_build_add:n { #2 { \if_false: } \fi: }
+        \tl_build_put_right:Nn \l_@@_build_tl { #2 { \if_false: } \fi: }
         \@@_compile_class:NN
       }
       {
-        \tl_build_add:n { #1 { \if_false: } \fi: }
+        \tl_build_put_right:Nn \l_@@_build_tl { #1 { \if_false: } \fi: }
         \@@_compile_class:NN #3 #4
       }
   }
@@ -2866,7 +2896,7 @@
 %
 % \begin{macro}{\@@_compile_group_begin:N, \@@_compile_group_end:}
 %   The contents of a regex group are turned into compiled code in
-%   \cs{l_@@_internal_regex}, which ends up with items of the form
+%   \cs{l_@@_build_tl}, which ends up with items of the form
 %   \cs{@@_branch:n} \Arg{concatenation}. This construction is done
 %   using \pkg{l3tl-build} within a \TeX{} group, which automatically
 %   makes sure that options (case-sensitivity and default catcode) are
@@ -2879,20 +2909,23 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_compile_group_begin:N #1
   {
-    \tl_build_add:n { #1 { \if_false: } \fi: }
+    \tl_build_put_right:Nn \l_@@_build_tl { #1 { \if_false: } \fi: }
     \@@_mode_quit_c:
-    \tl_build:Nw \l_@@_internal_regex
+    \group_begin:
+      \tl_build_begin:N \l_@@_build_tl
       \int_set_eq:NN \l_@@_default_catcodes_int \l_@@_catcodes_int
       \int_incr:N \l_@@_group_level_int
-      \tl_build_add:n { \@@_branch:n { \if_false: } \fi: }
+      \tl_build_put_right:Nn \l_@@_build_tl { \@@_branch:n { \if_false: } \fi: }
   }
 \cs_new_protected:Npn \@@_compile_group_end:
   {
     \if_int_compare:w \l_@@_group_level_int > 0 \exp_stop_f:
-        \tl_build_add:n { \if_false: { \fi: } }
-      \tl_build_end:
+        \tl_build_put_right:Nn \l_@@_build_tl { \if_false: { \fi: } }
+        \tl_build_end:N \l_@@_build_tl
+        \exp_args:NNNx
+      \group_end:
+      \tl_build_put_right:Nn \l_@@_build_tl { \l_@@_build_tl }
       \int_set_eq:NN \l_@@_catcodes_int \l_@@_default_catcodes_int
-      \tl_build_add:o \l_@@_internal_regex
       \exp_after:wN \@@_compile_quantifier:w
     \else:
       \__kernel_msg_warning:nn { kernel } { extra-rparen }
@@ -2941,7 +2974,7 @@
   {
     \@@_if_in_class:TF { \@@_compile_raw:N | }
       {
-        \tl_build_add:n
+        \tl_build_put_right:Nn \l_@@_build_tl
           { \if_false: { \fi: } \@@_branch:n { \if_false: } \fi: }
       }
   }
@@ -3315,7 +3348,7 @@
   {
     \tl_gset:Nx \g_@@_internal_tl
       { \exp_args:No \__str_to_other_fast:n { \l_@@_internal_a_tl } }
-    \tl_build_add:x
+    \tl_build_put_right:Nx \l_@@_build_tl
       {
         \tl_map_function:NN \g_@@_internal_tl
           \@@_compile_u_in_cs_aux:n
@@ -3340,7 +3373,7 @@
   {
     \exp_args:No \__tl_analysis_map_inline:nn { \l_@@_internal_a_tl }
       {
-        \tl_build_add:n
+        \tl_build_put_right:Nx \l_@@_build_tl
           {
             \@@_class:NnnnN \c_true_bool
               {
@@ -3368,7 +3401,7 @@
 \cs_new_protected:cpn { @@_compile_/K: }
   {
     \int_compare:nNnTF \l_@@_mode_int = \c_@@_outer_mode_int
-      { \tl_build_add:n { \@@_command_K: } }
+      { \tl_build_put_right:Nn \l_@@_build_tl { \@@_command_K: } }
       { \@@_compile_raw_error:N K }
   }
 %    \end{macrocode}
@@ -3377,14 +3410,15 @@
 % \subsubsection{Showing regexes}
 %
 % \begin{macro}{\@@_show:N}
-%   Within a \cs{tl_build:Nw} \ldots{} \cs{tl_build_end:} group, we
+%   Within a group and within \cs{tl_build_begin:N} \ldots{} \cs{tl_build_end:N} we
 %   redefine all the function that can appear in a compiled regex, then
 %   run the regex. The result stored in \cs{l_@@_internal_a_tl} is then
 %   meant to be shown.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_show:N #1
   {
-    \tl_build:Nw \l_@@_internal_a_tl
+    \group_begin:
+      \tl_build_begin:N \l_@@_build_tl
       \cs_set_protected:Npn \@@_branch:n
         {
           \seq_pop_right:NN \l_@@_show_prefix_seq \l_@@_internal_a_tl
@@ -3431,7 +3465,10 @@
       \seq_clear:N \l_@@_show_prefix_seq
       \@@_show_push:n { ~ }
       \cs_if_exist_use:N #1
-    \tl_build_end:
+      \tl_build_end:N \l_@@_build_tl
+      \exp_args:NNNo
+    \group_end:
+    \tl_set:Nn \l_@@_internal_a_tl { \l_@@_build_tl }
   }
 %    \end{macrocode}
 % \end{macro}
@@ -3443,7 +3480,7 @@
 \cs_new_protected:Npn \@@_show_one:n #1
   {
     \int_incr:N \l_@@_show_lines_int
-    \tl_build_add:x
+    \tl_build_put_right:Nx \l_@@_build_tl
       {
         \exp_not:N \iow_newline:
         \seq_map_function:NN \l_@@_show_prefix_seq \use:n
@@ -3504,42 +3541,39 @@
 %    \begin{macrocode}
 \cs_set:Npn \@@_show_class:NnnnN #1#2#3#4#5
   {
-    \tl_build:Nw \l_@@_internal_a_tl
+    \group_begin:
+      \tl_build_begin:N \l_@@_build_tl
       \int_zero:N \l_@@_show_lines_int
       \@@_show_push:n {~}
       #2
-      \exp_last_unbraced:Nf
-    \int_case:nnF { \l_@@_show_lines_int }
+    \int_compare:nTF { \l_@@_show_lines_int = 0 }
+      {
+        \group_end:
+        \@@_show_one:n { \bool_if:NTF #1 { Fail } { Pass } }
+      }
       {
-        {0}
+        \bool_if:nTF
+          { #1 && \int_compare_p:n { \l_@@_show_lines_int = 1 } }
           {
-            \tl_build_end:
-            \@@_show_one:n { \bool_if:NTF #1 { Fail } { Pass } }
+            \group_end:
+            #2
+            \tl_build_put_right:Nn \l_@@_build_tl
+              { \@@_msg_repeated:nnN {#3} {#4} #5 }
           }
-        {1}
           {
-            \tl_build_end:
-            \bool_if:NTF #1
-              {
-                #2
-                \tl_build_add:n { \@@_msg_repeated:nnN {#3} {#4} #5 }
-              }
+              \tl_build_end:N \l_@@_build_tl
+              \exp_args:NNNo
+            \group_end:
+            \tl_set:Nn \l_@@_internal_a_tl \l_@@_build_tl
+            \@@_show_one:n
               {
-                \@@_show_one:n
-                  { Don't~match~\@@_msg_repeated:nnN {#3} {#4} #5 }
-                \tl_build_add:o \l_@@_internal_a_tl
+                \bool_if:NTF #1 { Match } { Don't~match }
+                \@@_msg_repeated:nnN {#3} {#4} #5
               }
+            \tl_build_put_right:Nx \l_@@_build_tl
+              { \exp_not:o \l_@@_internal_a_tl }
           }
       }
-      {
-        \tl_build_end:
-        \@@_show_one:n
-          {
-            \bool_if:NTF #1 { M } { Don't~m } atch
-            \@@_msg_repeated:nnN {#3} {#4} #5
-          }
-        \tl_build_add:o \l_@@_internal_a_tl
-      }
   }
 %    \end{macrocode}
 % \end{macro}
@@ -5112,7 +5146,8 @@
   { \@@_trace_pop:nnN { regex } { 1 } \@@_replacement:n }
 \cs_new_protected:Npn \@@_replacement:n #1
   {
-    \tl_build:Nw \l_@@_internal_a_tl
+    \group_begin:
+      \tl_build_begin:N \l_@@_build_tl
       \int_zero:N \l_@@_balance_int
       \tl_clear:N \l_@@_balance_tl
       \@@_escape_use:nnnn
@@ -5131,7 +5166,7 @@
       \if_int_compare:w \l_@@_replacement_csnames_int > 0 \exp_stop_f:
         \__kernel_msg_error:nnx { kernel } { replacement-missing-rbrace }
           { \int_use:N \l_@@_replacement_csnames_int }
-        \tl_build_add:x
+        \tl_build_put_right:Nx \l_@@_build_tl
           { \prg_replicate:nn \l_@@_replacement_csnames_int \cs_end: }
       \fi:
       \seq_if_empty:NF \l_@@_replacement_category_seq
@@ -5146,8 +5181,10 @@
           \l_@@_balance_tl
           - \@@_submatch_balance:n {##1}
         }
-    \tl_build_end:
-    \exp_args:No \@@_replacement_aux:n \l_@@_internal_a_tl
+      \tl_build_end:N \l_@@_build_tl
+      \exp_args:NNo
+    \group_end:
+    \@@_replacement_aux:n \l_@@_build_tl
   }
 \cs_new_protected:Npn \@@_replacement_aux:n #1
   {
@@ -5165,7 +5202,7 @@
 %
 % \begin{macro}{\@@_replacement_normal:n}
 %   Most characters are simply sent to the output by
-%   \cs{tl_build_add:n}, unless a particular category code has been
+%   \cs{tl_build_put_right:Nn}, unless a particular category code has been
 %   requested: then \cs{@@_replacement_c_A:w} or a similar auxiliary is
 %   called.  One exception is right parentheses, which restore the
 %   category code in place before the group started.  Note that the
@@ -5176,7 +5213,7 @@
 \cs_new_protected:Npn \@@_replacement_normal:n #1
   {
     \tl_if_empty:NTF \l_@@_replacement_category_tl
-      { \tl_build_add:n {#1} }
+      { \tl_build_put_right:Nn \l_@@_build_tl {#1} }
       { % (
         \token_if_eq_charcode:NNTF #1 )
           {
@@ -5228,7 +5265,8 @@
 \cs_new_protected:Npn \@@_replacement_put_submatch:n #1
   {
     \if_int_compare:w #1 < \l_@@_capturing_group_int
-      \tl_build_add:n { \@@_query_submatch:n { \int_eval:n { #1 + ##1 } } }
+      \tl_build_put_right:Nn \l_@@_build_tl
+        { \@@_query_submatch:n { \int_eval:n { #1 + ##1 } } }
       \if_int_compare:w \l_@@_replacement_csnames_int = 0 \exp_stop_f:
         \tl_put_right:Nn \l_@@_balance_tl
           {
@@ -5320,9 +5358,11 @@
 \cs_new_protected:Npn \@@_replacement_cu_aux:Nw #1
   {
     \if_case:w \l_@@_replacement_csnames_int
-      \tl_build_add:n { \exp_not:n { \exp_after:wN #1 \cs:w } }
+      \tl_build_put_right:Nn \l_@@_build_tl
+        { \exp_not:n { \exp_after:wN #1 \cs:w } }
     \else:
-      \tl_build_add:n { \exp_not:n { \exp_after:wN \tl_to_str:V \cs:w } }
+      \tl_build_put_right:Nn \l_@@_build_tl
+        { \exp_not:n { \exp_after:wN \tl_to_str:V \cs:w } }
     \fi:
     \int_incr:N \l_@@_replacement_csnames_int
   }
@@ -5351,7 +5391,7 @@
 \cs_new_protected:Npn \@@_replacement_rbrace:N #1
   {
     \if_int_compare:w \l_@@_replacement_csnames_int > 0 \exp_stop_f:
-      \tl_build_add:n \cs_end:
+      \tl_build_put_right:Nn \l_@@_build_tl { \cs_end: }
       \int_decr:N \l_@@_replacement_csnames_int
     \else:
       \@@_replacement_normal:n {#1}
@@ -5428,7 +5468,7 @@
   \cs_new_protected:Npn \@@_replacement_char:nNN #1#2#3
     {
       \tex_lccode:D 0 = `#3 \scan_stop:
-      \tex_lowercase:D { \tl_build_add:n {#1} }
+      \tex_lowercase:D { \tl_build_put_right:Nn \l_@@_build_tl {#1} }
     }
 %    \end{macrocode}
 % \end{macro}
@@ -5472,7 +5512,10 @@
 %   character, we prepare for two \texttt{x}-expansions.
 %    \begin{macrocode}
   \cs_new_protected:Npn \@@_replacement_c_C:w #1#2
-    { \tl_build_add:n { \exp_not:N \exp_not:N \exp_not:c {#2} } }
+    {
+      \tl_build_put_right:Nn \l_@@_build_tl
+        { \exp_not:N \exp_not:N \exp_not:c {#2} }
+    }
 %    \end{macrocode}
 % \end{macro}
 %
@@ -5558,7 +5601,7 @@
         \__kernel_msg_error:nn { kernel } { replacement-null-space }
       \fi:
       \tex_lccode:D `\ = `#2 \scan_stop:
-      \tex_lowercase:D { \tl_build_add:n {~} }
+      \tex_lowercase:D { \tl_build_put_right:Nn \l_@@_build_tl {~} }
     }
 %    \end{macrocode}
 % \end{macro}





More information about the latex3-commits mailing list