[latex3-commits] [git/LaTeX3-latex3-latex3] gh433-regex-case: Correct regex_case for a single-token explicit regex (see #433) (ba1d11395)

Bruno Le Floch blflatex at gmail.com
Mon May 17 18:39:33 CEST 2021


Repository : https://github.com/latex3/latex3
On branch  : gh433-regex-case
Link       : https://github.com/latex3/latex3/commit/ba1d11395c1e3318adb705861cc3a1f1addc7922

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

commit ba1d11395c1e3318adb705861cc3a1f1addc7922
Author: Bruno Le Floch <blflatex at gmail.com>
Date:   Mon May 17 18:39:33 2021 +0200

    Correct regex_case for a single-token explicit regex (see #433)


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

ba1d11395c1e3318adb705861cc3a1f1addc7922
 l3kernel/l3regex.dtx              | 9 +++++++--
 l3kernel/testfiles/m3regex012.lvt | 8 ++++++++
 l3kernel/testfiles/m3regex012.tlg | 1 +
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/l3kernel/l3regex.dtx b/l3kernel/l3regex.dtx
index e7aa9614d..b77bd7b62 100644
--- a/l3kernel/l3regex.dtx
+++ b/l3kernel/l3regex.dtx
@@ -2463,11 +2463,16 @@
   {
     \tl_if_single_token:nT {#1}
       {
-        \exp_args:No \tl_if_head_eq_meaning:nNT #1 \@@_branch:n
-          { \use_ii:nnn }
+        \exp_after:wN \@@_compile_use_aux:w
+        \token_to_meaning:N #1 ~ \q_@@_nil
       }
     \@@_compile:n {#1} \l_@@_internal_regex
   }
+\cs_new_protected:Npn \@@_compile_use_aux:w #1 ~ #2 \q_@@_nil
+  {
+    \str_if_eq:nnT { #1 ~ } { macro:->\@@_branch:n }
+      { \use_ii:nnn }
+  }
 %    \end{macrocode}
 % \end{macro}
 %
diff --git a/l3kernel/testfiles/m3regex012.lvt b/l3kernel/testfiles/m3regex012.lvt
index e0187f90b..bb6a4e4f5 100644
--- a/l3kernel/testfiles/m3regex012.lvt
+++ b/l3kernel/testfiles/m3regex012.lvt
@@ -123,6 +123,14 @@
       }
       \l_tmpa_tl
     \tl_analysis_log:N \l_tmpa_tl
+    \tl_clear:N \l_tmpa_tl
+    \regex_case_replace_all:nN
+      {
+        { \A } { A }
+        \Z { Z }
+      }
+      \l_tmpa_tl
+    \TYPE { \l_tmpa_tl }
   }
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/l3kernel/testfiles/m3regex012.tlg b/l3kernel/testfiles/m3regex012.tlg
index 5e35c3df2..47c49cede 100644
--- a/l3kernel/testfiles/m3regex012.tlg
+++ b/l3kernel/testfiles/m3regex012.tlg
@@ -85,6 +85,7 @@ The token list \l_tmpa_tl contains the tokens:
 >  | (the character |)
 >  } (end-group character })
 >  e (the letter e)
+A
 ============================================================
 ============================================================
 TEST 4: regex_case errors





More information about the latex3-commits mailing list.