[latex3-commits] [latex3/latex3] main: Leave implicit chars unchanged in \text_expand:n (fixes #874) (7998284c7)

github at latex-project.org github at latex-project.org
Thu May 18 10:05:24 CEST 2023


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/7998284c72c66cdd785c2ee38d3315e3c63e87ba

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

commit 7998284c72c66cdd785c2ee38d3315e3c63e87ba
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu May 18 08:32:14 2023 +0100

    Leave implicit chars unchanged in \text_expand:n (fixes #874)


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

7998284c72c66cdd785c2ee38d3315e3c63e87ba
 l3kernel/CHANGELOG.md            |  1 +
 l3kernel/l3text.dtx              | 81 ++--------------------------------------
 l3kernel/testfiles/m3text001.tlg |  2 +-
 3 files changed, 6 insertions(+), 78 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index be2a4dc45..365a3bd0c 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -14,6 +14,7 @@ this project uses date-based 'snapshot' version identifiers.
 
 ### Fixed
 - Omit `0123456789` from URL escaping (issue \#838)
+Leave implicit chars unchanged in `\text_expand:n` (fixes \#874)
 
 ## [2023-05-15]
 
diff --git a/l3kernel/l3text.dtx b/l3kernel/l3text.dtx
index 5190bd4d8..72f67c9cd 100644
--- a/l3kernel/l3text.dtx
+++ b/l3kernel/l3text.dtx
@@ -914,13 +914,7 @@
 % \begin{macro}[EXP]{\@@_expand_loop:w}
 % \begin{macro}[EXP]{\@@_expand_group:n}
 % \begin{macro}[EXP]{\@@_expand_space:w}
-% \begin{macro}[EXP]
-%   {
-%    \@@_expand_N_type:N       ,
-%    \@@_expand_N_type_auxi:N  ,
-%    \@@_expand_N_type_auxii:N ,
-%    \@@_expand_N_type_auxiii:N
-%   }
+% \begin{macro}[EXP]{\@@_expand_N_type:N}
 % \begin{macro}[EXP]{\@@_expand_math_search:NNN}
 % \begin{macro}[EXP]{\@@_expand_math_loop:Nw}
 % \begin{macro}[EXP]{\@@_expand_math_N_type:NN}
@@ -1030,75 +1024,6 @@
     \@@_expand_loop:w
   }
 %    \end{macrocode}
-%   Before we get into the real work, we have to watch out for problematic
-%   implicit characters: spaces and grouping tokens. Converting these to
-%   explicit characters later would lead to real issues as they are \emph{not}
-%   \texttt{N}-type. A space is the easy case, so it's dealt with first:
-%   just insert the explicit token and continue the loop.
-%    \begin{macrocode}
-\cs_new:Npx \@@_expand_N_type:N #1
-  {
-    \exp_not:N \@@_if_s_recursion_tail_stop_do:Nn #1
-      { \exp_not:N \@@_expand_end:w }
-    \exp_not:N \bool_lazy_any:nTF
-      {
-        { \exp_not:N \token_if_eq_meaning_p:NN #1 \c_space_token }
-        {
-          \exp_not:N \token_if_eq_meaning_p:NN #1
-            \c_@@_chardef_space_token
-        }
-        {
-          \exp_not:N \token_if_eq_meaning_p:NN #1
-            \c_@@_mathchardef_space_token
-        }
-      }
-      { \exp_not:N \@@_expand_space:w \c_space_tl }
-      { \exp_not:N \@@_expand_N_type_auxi:N #1 }
-  }
-%    \end{macrocode}
-%  Implicit |{|/|}| offer two issues. First, the token could be an implicit
-%  brace character: we need to avoid turning that into a brace group, so filter
-%  out the cases manually. Then we handle the case where an implicit group is
-%  present. That is done in an \enquote{open-ended} way: there's the possibility
-%  the closing token is hidden somewhere.
-%    \begin{macrocode}
-\cs_new:Npn \@@_expand_N_type_auxi:N #1
-  {
-    \bool_lazy_or:nnTF
-      { \token_if_eq_meaning_p:NN #1 \c_@@_chardef_group_begin_token }
-      { \token_if_eq_meaning_p:NN #1 \c_@@_mathchardef_group_begin_token }
-      {
-        \@@_expand_store:o \c_left_brace_str
-        \@@_expand_loop:w
-      }
-      {
-        \bool_lazy_or:nnTF
-          { \token_if_eq_meaning_p:NN #1 \c_@@_chardef_group_end_token }
-          { \token_if_eq_meaning_p:NN #1 \c_@@_mathchardef_group_end_token }
-          {
-            \@@_expand_store:o \c_right_brace_str
-            \@@_expand_loop:w
-          }
-          { \@@_expand_N_type_auxii:N #1 }
-      }
-  }
-\cs_new:Npn \@@_expand_N_type_auxii:N #1
-  {
-    \token_if_eq_meaning:NNTF #1 \c_group_begin_token
-      {
-        { \if_false: } \fi:
-        \@@_expand_loop:w
-      }
-      {
-        \token_if_eq_meaning:NNTF #1 \c_group_end_token
-          {
-            \if_false: { \fi: }
-            \@@_expand_loop:w
-          }
-          { \@@_expand_N_type_auxiii:N #1 }
-      }
-  }
-%    \end{macrocode}
 %   The first step in dealing with \texttt{N}-type tokens is to look for
 %   math mode material: that needs to be left alone. The starting function
 %   has to be split into two as we need \cs{quark_if_recursion_tail_stop:N}
@@ -1108,8 +1033,10 @@
 %   through unchanged, just checking the \texttt{N}-type ones against the
 %   end marker.
 %    \begin{macrocode}
-\cs_new:Npn \@@_expand_N_type_auxiii:N #1
+\cs_new:Npn \@@_expand_N_type:N #1
   {
+    \@@_if_s_recursion_tail_stop_do:Nn #1
+      { \@@_expand_end:w }
     \exp_after:wN \@@_expand_math_search:NNN
       \exp_after:wN #1 \l_text_math_delims_tl
       \q_@@_recursion_tail \q_@@_recursion_tail
diff --git a/l3kernel/testfiles/m3text001.tlg b/l3kernel/testfiles/m3text001.tlg
index aca51bd87..7fd0e0b23 100644
--- a/l3kernel/testfiles/m3text001.tlg
+++ b/l3kernel/testfiles/m3text001.tlg
@@ -35,7 +35,7 @@ TEST 5: Accents
 ============================================================
 TEST 6: Implicit tokens
 ============================================================
-"\AAA "\BBB "\CCC " " " "
+"\AAA "\BBB "\CCC "\SPACEA "\SPACEB "\SPACEC "
 ============================================================
 ============================================================
 TEST 7: Expansion exclusions





More information about the latex3-commits mailing list.