[latex3-commits] [l3svn] r6797 - Refactor l3sort error recovery

noreply at latex-project.org noreply at latex-project.org
Thu Dec 15 07:25:57 CET 2016


Author: bruno
Date: 2016-12-15 07:25:57 +0100 (Thu, 15 Dec 2016)
New Revision: 6797

Modified:
   trunk/l3experimental/l3sort/l3sort.dtx
Log:
Refactor l3sort error recovery


Modified: trunk/l3experimental/l3sort/l3sort.dtx
===================================================================
--- trunk/l3experimental/l3sort/l3sort.dtx	2016-12-15 06:17:05 UTC (rev 6796)
+++ trunk/l3experimental/l3sort/l3sort.dtx	2016-12-15 06:25:57 UTC (rev 6797)
@@ -1032,15 +1032,27 @@
 %
 % \subsection{Messages}
 %
+% \begin{macro}[aux]{\@@_error:}
+%   Bailing out of the sorting code is a bit tricky.  It may not be safe
+%   to use a delimited argument, so instead we redefine many
+%   \pkg{l3sort} commands to be trivial, with \cs{@@_level:} getting rid
+%   of the final assignment.  This error recovery won't work in a group.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_error:
+  {
+    \cs_set_eq:NN \@@_merge_blocks_aux: \prg_do_nothing:
+    \cs_set_eq:NN \@@_merge_blocks: \prg_do_nothing:
+    \cs_set_protected:Npn \@@_level: \use:x ##1 { \group_end: }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}[aux]{\@@_disable_toksdef:, \@@_disabled_toksdef:n}
 %   While sorting, \tn{toksdef} is locally disabled to prevent users
 %   from using \tn{newtoks} or similar commands in their comparison
 %   code: the \tn{toks} registers that would be assigned are in use by
-%   \pkg{l3sort}.  Since it may be unsafe to bail out of the user's code
-%   with a delimited argument, we redefine many \pkg{l3sort} commands to
-%   be trivial, with \cs{@@_level:} getting rid of the final assignment.
-%   This error recovery won't work in a group.  In format mode, none of
-%   this is needed since there is no \tn{toks} allocator.
+%   \pkg{l3sort}.  In format mode, none of this is needed since there is
+%   no \tn{toks} allocator.
 %    \begin{macrocode}
 %<*package>
 \cs_new_protected:Npn \@@_disable_toksdef:
@@ -1049,9 +1061,7 @@
   {
     \__msg_kernel_error:nnx { sort } { toksdef }
       { \token_to_str:N #1 }
-    \cs_set_eq:NN \@@_merge_blocks_aux: \prg_do_nothing:
-    \cs_set_eq:NN \@@_merge_blocks: \prg_do_nothing:
-    \cs_set_protected:Npn \@@_level: { \@@_error:w }
+    \@@_error:
     \tex_toksdef:D #1
   }
 \__msg_kernel_new:nnnn { sort } { toksdef }
@@ -1065,7 +1075,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}[aux]{\@@_too_long_error:NNw, \@@_error:w}
+% \begin{macro}[aux]{\@@_too_long_error:NNw}
 %   When there are too many items in a sequence, this is an error, and
 %   we clean up properly the mapping over items in the list: break using
 %   the type-specific breaking function |#1|.
@@ -1077,10 +1087,8 @@
       { \token_to_str:N #2 }
       { \int_eval:n { \l_@@_true_max_int - \l_@@_min_int } }
       { \int_eval:n { \l_@@_top_int - \l_@@_min_int } }
-    #1 \@@_error:w
+    #1 \@@_error:
   }
-\cs_new_protected:Npn \@@_error:w #1 \use:x #2
-  { \group_end: }
 \__msg_kernel_new:nnnn { sort } { too-large }
   { The~list~#1~is~too~long~to~be~sorted~by~TeX. }
   {



More information about the latex3-commits mailing list