Skip to content

Commit

Permalink
Protect against latexrelease loaded in another package
Browse files Browse the repository at this point in the history
  • Loading branch information
PhelypeOleinik committed Nov 25, 2020
1 parent 6a4c4e3 commit 2d07818
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions base/lthooks.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -3892,23 +3885,42 @@
% 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.
% \begin{macrocode}
\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:
Expand Down

0 comments on commit 2d07818

Please sign in to comment.