[latex3-commits] [git/LaTeX3-latex3-latex2e] hotfix/gh441: Do not revert code within the top-level chunk (43c2bafc)

PhelypeOleinik phelype.oleinik at latex-project.org
Sat Dec 12 16:59:49 CET 2020


Repository : https://github.com/latex3/latex2e
On branch  : hotfix/gh441
Link       : https://github.com/latex3/latex2e/commit/43c2bafc6ef007dc0791127ee7ddbe01720b30b6

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

commit 43c2bafc6ef007dc0791127ee7ddbe01720b30b6
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Sat Dec 12 12:59:49 2020 -0300

    Do not revert code within the top-level chunk


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

43c2bafc6ef007dc0791127ee7ddbe01720b30b6
 base/lthooks.dtx | 69 +++++++++-----------------------------------------------
 1 file changed, 11 insertions(+), 58 deletions(-)

diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index 0fc80722..5dc0d1cf 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -1886,17 +1886,6 @@
 %
 %    \begin{macrocode}
         \@@_include_legacy_code_chunk:n {#1}
-%    \end{macrocode}
-%    Then finally, if the |top-level| chunk is not empty (that is, code
-%    was added before the hook was declared), remove the braces around
-%    the code chunks that were added for reversing (see definition of
-%    \cs{@@_hook_gput_code_do:nnn}).
-%    \begin{macrocode}
-        \tl_if_empty:cF { @@_toplevel~#1 }
-          {
-            \tl_set:cx { @@_toplevel~#1 }
-              { \tl_map_function:cN { @@_toplevel~#1 } \exp_not:n }
-          }
      }
   }
 %    \end{macrocode}
@@ -1934,16 +1923,6 @@
   { \@@_normalize_hook_args:Nn \@@_new_reversed:n {#1} }
 \cs_new_protected:Npn \@@_new_reversed:n #1
   {
-%    \end{macrocode}
-%    If there was already code in the |top-level| chunk, then reverse it
-%    (see definition of \cs{@@_hook_gput_code_do:nnn}).
-%    \begin{macrocode}
-    \tl_if_exist:cT { @@_toplevel~#1 }
-      {
-        \debug_suspend:
-        \tl_greverse:c { @@_toplevel~#1 }
-        \debug_resume:
-      }
     \@@_new:n {#1}
 %    \end{macrocode}
 %    If the hook already exists the above will generate an error
@@ -2244,30 +2223,18 @@
 %    otherwise just put \verb=#3=.  If the current label is |top-level|,
 %    the code is added to a dedicated token list
 %    \cs[no-index]{@@_toplevel~\meta{hook}} that goes at the end of the
-%    hook, just before \cs[no-index]{@@_next~\meta{hook}}.
+%    hook (or at the beginning, for a reversed hook), just before
+%   \cs[no-index]{@@_next~\meta{hook}}.
 %    \begin{macrocode}
     \str_if_eq:nnTF {#2} { top-level }
       {
         \debug_suspend:
 %    \end{macrocode}
-%    If the hook exists, its order (if it's reversed or not) is already
-%    set, so we can just use the correct
-%    \cs[no-index]{tl_gput_\meta{side}:cn}.  Otherwise, add the code
-%    chunk with an extra pair of braces so it can be easily revesed
-%    later if needed.
+%    If the hook's basic structure does not exist, we need to declare it
+%    with \cs{@@_declare:n}.
 %    \begin{macrocode}
-        \hook_if_exist:nTF {#1}
-          {
-            \@@_if_reversed:nTF {#1}
-              { \tl_gput_left:cn }
-              { \tl_gput_right:cn }
-                  { @@_toplevel~#1 } {#3}
-          }
-          {
-            \@@_declare:n {#1}
-            \tl_gput_right:cn
-              { @@_toplevel~#1 } { {#3} }
-          }
+        \@@_declare:n {#1}
+        \tl_gput_right:cn { @@_toplevel~#1 } {#3}
         \debug_resume:
       }
       {
@@ -3451,26 +3418,12 @@
 %
 %    If there is code in the |top-level| token list, print it:
 %    \begin{macrocode}
-        \@@_log_line:x
-          {
-            Document-level~(top-level)~code
-            \bool_lazy_or:nnF
-                { \hook_if_exist_p:n {#1} }
-                { \tl_if_empty_p:c { @@_toplevel~#1 } }
-              { ~(order~not~set~yet) } :
-          }
-        \tl_if_empty:cTF { @@_toplevel~#1 }
-          { \@@_log_line_indent:x { --- } }
+        \@@_log_line:x { Document-level~(top-level)~code: }
+        \@@_log_line_indent:x
           {
-            \hook_if_exist:nTF {#1}
-              {
-                \@@_log_line_indent:x
-                  { -> ~ \exp_args:Nv \tl_to_str:n { @@_toplevel~#1 } }
-              }
-              {
-                \tl_map_inline:cn { @@_toplevel~#1 }
-                  { \@@_log_line_indent:x { -> ~ \tl_to_str:n {##1} } }
-              }
+            \tl_if_empty:cTF { @@_toplevel~#1 }
+              { --- }
+              { -> ~ \exp_args:Nv \tl_to_str:n { @@_toplevel~#1 } }
           }
 %    \end{macrocode}
 %





More information about the latex3-commits mailing list.