[latex3-commits] [git/LaTeX3-latex3-latex3] text-map: Handle Control codepoints with Prepend (cc4ca2fa7)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Aug 9 14:22:50 CEST 2022


Repository : https://github.com/latex3/latex3
On branch  : text-map
Link       : https://github.com/latex3/latex3/commit/cc4ca2fa7ce9d1d1b6062556b574b05f9b2ca534

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

commit cc4ca2fa7ce9d1d1b6062556b574b05f9b2ca534
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Aug 9 13:22:50 2022 +0100

    Handle Control codepoints with Prepend


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

cc4ca2fa7ce9d1d1b6062556b574b05f9b2ca534
 l3kernel/l3text-map.dtx                 | 45 +++++++++++++++++++++++++++++++--
 l3kernel/testfiles/m3text006.luatex.tlg |  6 ++---
 l3kernel/testfiles/m3text006.ptex.tlg   |  6 ++---
 l3kernel/testfiles/m3text006.tlg        |  6 ++---
 l3kernel/testfiles/m3text006.xetex.tlg  |  6 ++---
 5 files changed, 55 insertions(+), 14 deletions(-)

diff --git a/l3kernel/l3text-map.dtx b/l3kernel/l3text-map.dtx
index f611bc994..e1b75cb7f 100644
--- a/l3kernel/l3text-map.dtx
+++ b/l3kernel/l3text-map.dtx
@@ -86,6 +86,8 @@
 %     \@@_map_Prepend:Nnn     ,
 %     \@@_map_Prepend_aux:Nnn
 %   }
+% \begin{macro}[EXP]{\@@_map_Prepend:nNnn}
+% \begin{macro}[EXP]{\@@_map_Prepend_loop:Nnnw}
 % \begin{macro}[EXP]
 %   {
 %     \@@_map_not_Control:Nnn     ,
@@ -291,7 +293,8 @@
   { \@@_map_loop:Nnw #1 {#2#3} }
 \cs_new_eq:NN \@@_map_SpacingMark:Nnn \@@_map_Extend:Nnn
 %    \end{macrocode}
-%   Outputting anything earlier, the combine with what follows.
+%   Outputting anything earlier, the combine with what follows. The only
+%   exclusions are control characters.
 %    \begin{macrocode}
 \cs_new:Npn \@@_map_Prepend:Nnn #1#2#3
   {
@@ -299,7 +302,43 @@
     \@@_map_lookahead:NnNw #1 {#3} \@@_map_Prepend_aux:Nnn
   }
 \cs_new:Npn \@@_map_Prepend_aux:Nnn #1#2#3
-  { \@@_map_loop:Nnw #1 {#2#3} }
+  {
+    \bool_lazy_or:nnTF
+      { \@@_codepoint_compare_p:nNn {#3} = { "0A } }
+      { \@@_codepoint_compare_p:nNn {#3} = { "0D } }
+      {
+        #1 {#2}
+        \@@_map_loop:Nnw #1 {#3}
+      }
+      {
+        \exp_args:NV \@@_map_Prepend:nNnn
+          \c_@@_grapheme_Control_clist
+          #1 {#2} {#3}
+      }
+  }
+\cs_new:Npn \@@_map_Prepend:nNnn #1#2#3#4
+  {
+    \@@_map_Prepend_loop:Nnnw #2 {#3} {#4}
+      #1 , \q_@@_recursion_tail .. , \q_@@_recursion_stop
+  }
+\cs_new:Npn \@@_map_Prepend_loop:Nnnw #1#2#3 #4 .. #5 ,
+  {
+    \@@_if_q_recursion_tail_stop_do:nn {#4}
+      { \@@_map_loop:Nnw #1 {#2#3} }
+    \@@_codepoint_compare:nNnTF {#3} < { "#4 }
+      {
+        \@@_map_class_end:nw
+          { \@@_map_loop:Nnw #1 {#2#3} }
+      }
+      {
+        \@@_codepoint_compare:nNnTF {#3} > { "#5 }
+          { \@@_map_Prepend_loop:Nnnw #1 {#2} {#3} }
+          {
+            \@@_map_class_end:nw
+              { \@@_map_loop:Nnw #1 {#2} #3 }
+          }
+      }
+  }
 %    \end{macrocode}
 %   Dealing with end-of-class is done such that we can be flexible.
 %    \begin{macrocode}
@@ -519,6 +558,8 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
+% \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\text_map_inline:nn}
 %   The standard non-expandable inline version.
diff --git a/l3kernel/testfiles/m3text006.luatex.tlg b/l3kernel/testfiles/m3text006.luatex.tlg
index d42a0e604..4baafac08 100644
--- a/l3kernel/testfiles/m3text006.luatex.tlg
+++ b/l3kernel/testfiles/m3text006.luatex.tlg
@@ -142,11 +142,11 @@ TRUE
 TRUE
 TRUE
 TRUE
-  ^^f7 [0.2] ARABIC NUMBER SIGN (Prepend) ^^f7 [5.0] <CARRIAGE RETURN (CR)> (CR) ^^f7 [0.3]
 TRUE
-  ^^f7 [0.2] ARABIC NUMBER SIGN (Prepend) ^^f7 [5.0] <LINE FEED (LF)> (LF) ^^f7 [0.3]
 TRUE
-  ^^f7 [0.2] ARABIC NUMBER SIGN (Prepend) ^^f7 [5.0] <START OF HEADING> (Control) ^^f7 [0.3]
+TRUE
+TRUE
+TRUE
 TRUE
 TRUE
 TRUE
diff --git a/l3kernel/testfiles/m3text006.ptex.tlg b/l3kernel/testfiles/m3text006.ptex.tlg
index d42a0e604..4baafac08 100644
--- a/l3kernel/testfiles/m3text006.ptex.tlg
+++ b/l3kernel/testfiles/m3text006.ptex.tlg
@@ -142,11 +142,11 @@ TRUE
 TRUE
 TRUE
 TRUE
-  ^^f7 [0.2] ARABIC NUMBER SIGN (Prepend) ^^f7 [5.0] <CARRIAGE RETURN (CR)> (CR) ^^f7 [0.3]
 TRUE
-  ^^f7 [0.2] ARABIC NUMBER SIGN (Prepend) ^^f7 [5.0] <LINE FEED (LF)> (LF) ^^f7 [0.3]
 TRUE
-  ^^f7 [0.2] ARABIC NUMBER SIGN (Prepend) ^^f7 [5.0] <START OF HEADING> (Control) ^^f7 [0.3]
+TRUE
+TRUE
+TRUE
 TRUE
 TRUE
 TRUE
diff --git a/l3kernel/testfiles/m3text006.tlg b/l3kernel/testfiles/m3text006.tlg
index e700ca364..8073379c4 100644
--- a/l3kernel/testfiles/m3text006.tlg
+++ b/l3kernel/testfiles/m3text006.tlg
@@ -142,11 +142,11 @@ TRUE
 TRUE
 TRUE
 TRUE
-  ^^c3^^b7 [0.2] ARABIC NUMBER SIGN (Prepend) ^^c3^^b7 [5.0] <CARRIAGE RETURN (CR)> (CR) ^^c3^^b7 [0.3]
 TRUE
-  ^^c3^^b7 [0.2] ARABIC NUMBER SIGN (Prepend) ^^c3^^b7 [5.0] <LINE FEED (LF)> (LF) ^^c3^^b7 [0.3]
 TRUE
-  ^^c3^^b7 [0.2] ARABIC NUMBER SIGN (Prepend) ^^c3^^b7 [5.0] <START OF HEADING> (Control) ^^c3^^b7 [0.3]
+TRUE
+TRUE
+TRUE
 TRUE
 TRUE
 TRUE
diff --git a/l3kernel/testfiles/m3text006.xetex.tlg b/l3kernel/testfiles/m3text006.xetex.tlg
index d42a0e604..4baafac08 100644
--- a/l3kernel/testfiles/m3text006.xetex.tlg
+++ b/l3kernel/testfiles/m3text006.xetex.tlg
@@ -142,11 +142,11 @@ TRUE
 TRUE
 TRUE
 TRUE
-  ^^f7 [0.2] ARABIC NUMBER SIGN (Prepend) ^^f7 [5.0] <CARRIAGE RETURN (CR)> (CR) ^^f7 [0.3]
 TRUE
-  ^^f7 [0.2] ARABIC NUMBER SIGN (Prepend) ^^f7 [5.0] <LINE FEED (LF)> (LF) ^^f7 [0.3]
 TRUE
-  ^^f7 [0.2] ARABIC NUMBER SIGN (Prepend) ^^f7 [5.0] <START OF HEADING> (Control) ^^f7 [0.3]
+TRUE
+TRUE
+TRUE
 TRUE
 TRUE
 TRUE





More information about the latex3-commits mailing list.