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

Joseph Wright joseph.wright at morningstar2.co.uk
Mon Jan 10 19:08:09 CET 2022


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

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

commit b8b5338eaff4a31f259b29b526e2613ba1f4442a
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)


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

b8b5338eaff4a31f259b29b526e2613ba1f4442a
 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 81295c913..8893f1b9a 100644
--- a/l3kernel/l3regex.dtx
+++ b/l3kernel/l3regex.dtx
@@ -2475,11 +2475,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.