[latex3-commits] [git/LaTeX3-latex3-latex3] main: Expand active chars in \text_expand:n (5b0ec5426)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Jun 28 09:29:54 CEST 2022


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/5b0ec542614eb3dd9f3dcb2a6b9babb91a339740

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

commit 5b0ec542614eb3dd9f3dcb2a6b9babb91a339740
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Jun 28 08:29:54 2022 +0100

    Expand active chars in \text_expand:n
    
    This allows the expl3 code to handle legacy input
    encodings directly, as we end up doing more-or-less
    the same as \protected at edef would.


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

5b0ec542614eb3dd9f3dcb2a6b9babb91a339740
 l3kernel/CHANGELOG.md                  |  3 +++
 l3kernel/l3text.dtx                    | 18 +++++++++++++++---
 l3kernel/testfiles/m3text002.lvt       |  1 +
 l3kernel/testfiles/m3text002.tlg       |  2 +-
 l3kernel/testfiles/m3text002.uptex.tlg |  2 +-
 5 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 878434b38..d9e783fd6 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -10,6 +10,9 @@ this project uses date-based 'snapshot' version identifiers.
 ### Added
 - `\cs_parameter_spec:N`
 
+### Changed
+- `\text_expand:n` now acts on active chars to support legacy input encodings
+
 ### Deprecated
 - `\cs_argument_spec:N`
 
diff --git a/l3kernel/l3text.dtx b/l3kernel/l3text.dtx
index 529020ebb..240c187e7 100644
--- a/l3kernel/l3text.dtx
+++ b/l3kernel/l3text.dtx
@@ -901,15 +901,27 @@
   }
 %    \end{macrocode}
 %   At this stage, either we have a control sequence or a simple character:
-%   split and handle.
+%   split and handle. The need to check for non-protected actives arises
+%   from handling of legacy input encodings: they need to end up in a
+%   representation we can deal with in further processing.
 %    \begin{macrocode}
 \cs_new:Npn \@@_expand_explicit:N #1
   {
     \token_if_cs:NTF #1
       { \@@_expand_exclude:N #1 }
       {
-        \@@_expand_store:n {#1}
-        \@@_expand_loop:w
+        \bool_lazy_and:nnTF
+          { \token_if_active_p:N #1 }
+          {
+            ! \bool_lazy_or_p:nn
+              { \token_if_protected_macro_p:N #1 }
+              { \token_if_protected_long_macro_p:N #1 }
+          }
+          { \exp_after:wN \@@_expand_loop:w #1 }
+          {
+            \@@_expand_store:n {#1}
+            \@@_expand_loop:w
+          }
       }
   }
 %    \end{macrocode}
diff --git a/l3kernel/testfiles/m3text002.lvt b/l3kernel/testfiles/m3text002.lvt
index e51d28849..838f57960 100644
--- a/l3kernel/testfiles/m3text002.lvt
+++ b/l3kernel/testfiles/m3text002.lvt
@@ -337,6 +337,7 @@
 \group_begin:
 
 \char_set_catcode_active:N "
+\cs_gset_eq:NN " \scan_stop:
 
 \TESTEXP { Active~chars }
   {
diff --git a/l3kernel/testfiles/m3text002.tlg b/l3kernel/testfiles/m3text002.tlg
index c2ab0dfac..7e9989eb3 100644
--- a/l3kernel/testfiles/m3text002.tlg
+++ b/l3kernel/testfiles/m3text002.tlg
@@ -320,7 +320,7 @@ TEST 27: Active chars
 ============================================================
 "`lo"=rem"'
 "`LO"=REM"'
-"`lo"=rem"'
+"`Lo"=rem"'
 "`Lo"=rem"'
 ============================================================
 ============================================================
diff --git a/l3kernel/testfiles/m3text002.uptex.tlg b/l3kernel/testfiles/m3text002.uptex.tlg
index 92ef1c557..54b17748f 100644
--- a/l3kernel/testfiles/m3text002.uptex.tlg
+++ b/l3kernel/testfiles/m3text002.uptex.tlg
@@ -320,7 +320,7 @@ TEST 27: Active chars
 ============================================================
 "`lo"=rem"'
 "`LO"=REM"'
-"`lo"=rem"'
+"`Lo"=rem"'
 "`Lo"=rem"'
 ============================================================
 ============================================================





More information about the latex3-commits mailing list.