[latex3-commits] [git/LaTeX3-latex3-latex3] master: Fix l3regex bug with trying to apply catcode test to a group inside a class (f4c6ec6)

Bruno Le Floch bruno at le-floch.fr
Tue Apr 3 05:55:21 CEST 2018


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/f4c6ec6e128b1afe75caa85d0b48f3c173c08851

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

commit f4c6ec6e128b1afe75caa85d0b48f3c173c08851
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Mon Apr 2 23:55:21 2018 -0400

    Fix l3regex bug with trying to apply catcode test to a group inside a class


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

f4c6ec6e128b1afe75caa85d0b48f3c173c08851
 l3kernel/l3regex.dtx              |   22 ++++++++++++++++++----
 l3kernel/testfiles/m3regex009.lvt |    1 +
 l3kernel/testfiles/m3regex009.tlg |   16 ++++++++++++++++
 3 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/l3kernel/l3regex.dtx b/l3kernel/l3regex.dtx
index b410ad8..1067d86 100644
--- a/l3kernel/l3regex.dtx
+++ b/l3kernel/l3regex.dtx
@@ -2919,14 +2919,22 @@
 % \end{macro}
 %
 % \begin{macro}{\@@_compile_(:}
-%   In a class, parentheses are not special. Outside, check for a |?|,
-%   denoting special groups, and run the code for the corresponding
-%   special group.
+%   In a class, parentheses are not special.  In a catcode test inside a
+%   class, a left parenthesis gives an error, to catch |[a\cL(bcd)e]|.
+%   Otherwise check for a |?|, denoting special groups, and run the code
+%   for the corresponding special group.
 %    \begin{macrocode}
 \cs_new_protected:cpn { @@_compile_(: }
   {
     \@@_if_in_class:TF { \@@_compile_raw:N ( }
-      { \@@_compile_lparen:w }
+      {
+        \if_int_compare:w \l_@@_mode_int = \c_@@_catcode_in_class_mode_int
+          \__kernel_msg_error:nn { kernel } { c-lparen-in-class }
+          \exp_after:wN \@@_compile_raw:N \exp_after:wN (
+        \else:
+          \exp_after:wN \@@_compile_lparen:w
+        \fi:
+      }
   }
 \cs_new_protected:Npn \@@_compile_lparen:w #1#2#3#4
   {
@@ -6315,6 +6323,12 @@
     control~sequence~or~the~next~group~to~be~made~of~control~sequences.~
     It~only~makes~sense~to~follow~it~by~'.'~or~by~a~group.
   }
+\__kernel_msg_new:nnnn { kernel } { c-lparen-in-class }
+  { Catcode~test~cannot~apply~to~group~in~character~class }
+  {
+    Construction~such~as~'\iow_char:N\\cL(abc)'~are~not~allowed~inside~a~
+    class~'[...]'~because~classes~do~not~match~multiple~characters~at~once.
+  }
 \__kernel_msg_new:nnnn { kernel } { c-missing-rbrace }
   { Missing~right~brace~inserted~for~'\iow_char:N\\c'~escape. }
   {
diff --git a/l3kernel/testfiles/m3regex009.lvt b/l3kernel/testfiles/m3regex009.lvt
index 6365b97..a2f3442 100644
--- a/l3kernel/testfiles/m3regex009.lvt
+++ b/l3kernel/testfiles/m3regex009.lvt
@@ -154,6 +154,7 @@
     \test:x { \iow_char:N \\c C \iow_char:N \\A }
     \test:x { \iow_char:N \\c C (?i) A } % not detected
     \test:x { \iow_char:N \\c C (...) } % ok
+    \test:x { [ \iow_char:N \\c L (...) ] }
   }
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/l3kernel/testfiles/m3regex009.tlg b/l3kernel/testfiles/m3regex009.tlg
index 7c0d49b..cd92c9c 100644
--- a/l3kernel/testfiles/m3regex009.tlg
+++ b/l3kernel/testfiles/m3regex009.tlg
@@ -862,6 +862,22 @@ l. ...  }
 |...............................................
 "\cC(?i)A"
 "\cC(...)"
+"[\cL(...)]"
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "kernel/c-lparen-in-class"
+! 
+! Catcode test cannot apply to group in character class
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! For immediate help type H <return>.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| Construction such as '\cL(abc)' are not allowed inside a class '[...]'
+| because classes do not match multiple characters at once.
+|...............................................
 ============================================================
 ============================================================
 TEST 7: Malformed u escape





More information about the latex3-commits mailing list