[latex3-commits] [git/LaTeX3-latex3-latex2e] hotfix/gh434: Protect against latexrelease loaded in another package (2d07818e)
PhelypeOleinik
phelype.oleinik at latex-project.org
Wed Nov 25 18:37:49 CET 2020
Repository : https://github.com/latex3/latex2e
On branch : hotfix/gh434
Link : https://github.com/latex3/latex2e/commit/2d07818e89f7b85bfd7be821d3d81763a4d4d51b
>---------------------------------------------------------------
commit 2d07818e89f7b85bfd7be821d3d81763a4d4d51b
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date: Wed Nov 25 14:37:49 2020 -0300
Protect against latexrelease loaded in another package
>---------------------------------------------------------------
2d07818e89f7b85bfd7be821d3d81763a4d4d51b
base/lthooks.dtx | 38 +++++++++++++++++++++++++-------------
1 file changed, 25 insertions(+), 13 deletions(-)
diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index 65d8a0ac..43d03765 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -1749,13 +1749,6 @@
\tl_new:N \g_@@_hook_curr_name_tl
\seq_new:N \g_@@_name_stack_seq
% \end{macrocode}
-%
-% Inside \pkg{latexrelease} we also push something on the stack to
-% support roll forward.
-% \changes{v1.0f}{2020/11/24}{Support for roll forward (gh/434)}
-% \begin{macrocode}
-%<latexrelease>\seq_gpush:Nn \g__hook_name_stack_seq { }
-% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_tmp:w}
@@ -3892,15 +3885,35 @@
% current package/file to be used as label for hooks.
% Providing a consistent interface is tricky, because packages can
% be loaded within packages, and some packages may not use
-% \cs{DeclareDefaultHookLabel} to change the default label (in which case
-% \cs{@currname} is used, if set).
+% \cs{DeclareDefaultHookLabel} to change the default label (in which
+% case \cs{@currname} is used, if set).
%
% To pull that off, we keep a stack that contains the default label
% for each level of input. The bottom of the stack contains the
% default label for the top-level. Since the string \verb|top-level|
-% is hardcoded, here this item of the stack is empty. Also, since
-% we're in an input level, add \verb|lthooks| to the stack as well.
-% This stack should never go empty. An empty entry is added to the
+% is hardcoded, here this item of the stack is empty. This stack
+% should never go empty.
+%
+% But first, in case we're in \pkg{latexrelease} we push something on
+% the stack to support roll forward. But in some rare cases,
+% \pkg{latexrelease} may be loaded inside another package (notably
+% \pkg{platexrelease}), so we'll dissect the \cs{@currnamestack},
+% adding empty items to the stack (empty so that defaults can kick in
+% if needed):
+% \changes{v1.0f}{2020/11/24}{Support for roll forward (gh/434)}
+% \begin{macrocode}
+%<latexrelease>\cs_set_protected:Npn \@@_tmp:w #1 #2 #3
+%<latexrelease> {
+%<latexrelease> \quark_if_recursion_tail_stop:n {#1}
+%<latexrelease> \seq_gput_right:Nn \g_@@_name_stack_seq { }
+%<latexrelease> \@@_tmp:w
+%<latexrelease> }
+%<latexrelease>\exp_after:wN \@@_tmp:w \@currnamestack
+%<latexrelease> \q_recursion_tail \q_recursion_tail
+%<latexrelease> \q_recursion_tail \q_recursion_stop
+% \end{macrocode}
+%
+% Finally, an empty entry is added to the
% stack to account for the \verb|top-level|. The item is empty so
% that the hard-coded default is used, but a call to
% \cs{DeclareDefaultHookLabel} will change it if needed.
@@ -3908,7 +3921,6 @@
\seq_gpush:Nn \g_@@_name_stack_seq { }
% \end{macrocode}
%
-%
% Two commands keep track of the stack: when a file is input,
% \cs{@@_curr_name_push:n} pushes an (empty by default) label to the
% stack:
More information about the latex3-commits
mailing list.