[latex3-commits] [git/LaTeX3-latex3-latex3] master: Fix the code detecting bad nesting of cctab and groups (147edb699)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu Jul 16 12:13:16 CEST 2020


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

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

commit 147edb69922a55b8ec79d8060331ab9c38521259
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Wed Jul 15 00:24:33 2020 +0200

    Fix the code detecting bad nesting of cctab and groups


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

147edb69922a55b8ec79d8060331ab9c38521259
 l3kernel/l3cctab.dtx              | 23 ++++++++++-------------
 l3kernel/testfiles/m3cctab002.tlg |  7 +++++++
 2 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/l3kernel/l3cctab.dtx b/l3kernel/l3cctab.dtx
index a50b17cdf..37f9bcad3 100644
--- a/l3kernel/l3cctab.dtx
+++ b/l3kernel/l3cctab.dtx
@@ -600,9 +600,10 @@
 %   the \cs{cctab_end:} is reached, we had a problem.
 %
 %   Unfortunately these tests only flag the wrong usage at the
-%   \cs{cctab_end:}, which might be farfrom the \cs{cctab_begin:N}.
+%   \cs{cctab_end:}, which might be far from the \cs{cctab_begin:N}.
 %   However it isn't possible to signal the wrong usage at the
-%   \cs{group_end:} without abusing \cs{tex_aftergroup:D}.
+%   \cs{group_end:} without using \cs{tex_aftergroup:D}, which is
+%   unsafe in certain types of groups.
 %
 %   The three cases checked here just raise an error, and no recovery is
 %   attempted:  usually interleaving groups and catcode tables will work
@@ -617,24 +618,20 @@
 \cs_new_protected:Npn \@@_chk_group_end:n #1
   {
     \seq_gpop:NN \g_@@_group_seq \l_@@_internal_b_tl
-    \int_compare:nNnTF
-        { \tex_currentgrouplevel:D } = { \l_@@_internal_b_tl }
+    \bool_lazy_and:nnF
       {
-        \cs_if_exist:cTF { @@_group_ #1 _chk: }
-          { \cs_set_eq:cN { @@_group_ #1 _chk: } \tex_undefined:D }
-          {
-            \__kernel_msg_error:nnx { kernel } { cctab-group-mismatch }
-              { 0 }
-          }
+        \int_compare_p:nNn
+          { \tex_currentgrouplevel:D } = { \l_@@_internal_b_tl }
       }
+      { \cs_if_exist_p:c { @@_group_ #1 _chk: } }
       {
         \__kernel_msg_error:nnx { kernel } { cctab-group-mismatch }
           {
-            \int_compare:nNnTF
-                { \tex_currentgrouplevel:D } < { \l_@@_internal_b_tl }
-                { -1 } { 1 }
+            \int_sign:n
+              { \tex_currentgrouplevel:D - \l_@@_internal_b_tl }
           }
       }
+    \cs_undefine:c { @@_group_ #1 _chk: }
   }
 %    \end{macrocode}
 % \end{macro}
diff --git a/l3kernel/testfiles/m3cctab002.tlg b/l3kernel/testfiles/m3cctab002.tlg
index 172492d9b..4af04cf76 100644
--- a/l3kernel/testfiles/m3cctab002.tlg
+++ b/l3kernel/testfiles/m3cctab002.tlg
@@ -158,6 +158,13 @@ TRUE
 TRUE
 TRUE
 TRUE
+! LaTeX3 Error: \cctab_end: occurred in a different group than the matching
+(LaTeX3)        \cctab_begin:N.
+For immediate help type H <return>.
+ ...                                              
+l. ...  }
+Catcode tables and groups must be properly nested, but you tried to interleave
+them. LaTeX will try to proceed, but results may be unexpected.
 TRUE
 TRUE
 ============================================================





More information about the latex3-commits mailing list.