[latex3-commits] [git/LaTeX3-latex3-latex2e] hotfix/gh441: Some simplifications entailed by 6b2e81f (8fcc4ebf)
PhelypeOleinik
phelype.oleinik at latex-project.org
Mon Dec 14 21:50:45 CET 2020
Repository : https://github.com/latex3/latex2e
On branch : hotfix/gh441
Link : https://github.com/latex3/latex2e/commit/8fcc4ebf6f3377efc5dbbb4786e50c734a751232
>---------------------------------------------------------------
commit 8fcc4ebf6f3377efc5dbbb4786e50c734a751232
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date: Mon Dec 14 17:50:45 2020 -0300
Some simplifications entailed by 6b2e81f
>---------------------------------------------------------------
8fcc4ebf6f3377efc5dbbb4786e50c734a751232
base/lthooks.dtx | 90 ++++++++++++++++++++++++++++++--------------------------
1 file changed, 48 insertions(+), 42 deletions(-)
diff --git a/base/lthooks.dtx b/base/lthooks.dtx
index 833235e9..1b01b012 100644
--- a/base/lthooks.dtx
+++ b/base/lthooks.dtx
@@ -1997,80 +1997,76 @@
% \begin{macro}[EXP]{\@@_parse_label_default:n}
% This macro checks if a label was given (not \cs{c_novalue_tl}), and
% if so, tries to parse the label looking for a leading \verb|.| to
-% replace for \cs{@currname}. Otherwise \cs{@@_currname_or_default:n}
-% is used to pick \cs{@currname} or the fallback value.
-%
-% The default |top-level| is hard-coded here. It once was an
-% argument, but it's no longer needed. \pho{can't remember why}
+% replace by \cs{@@_currname_or_default:}.
% \begin{macrocode}
\cs_new:Npn \@@_parse_label_default:n #1
{
\tl_if_novalue:nTF {#1}
- { \@@_currname_or_default:n { top-level } }
- {
- \tl_trim_spaces_apply:nN {#1}
- \@@_parse_dot_label:nn { top-level }
- }
+ { \@@_currname_or_default: }
+ { \tl_trim_spaces_apply:nN {#1} \@@_parse_dot_label:n }
}
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}[EXP]{\@@_parse_dot_label:nn}
+% \begin{macro}[EXP]{\@@_parse_dot_label:n}
% \begin{macro}[EXP]{
-% \@@_parse_dot_label:nw,
+% \@@_parse_dot_label:w,
% \@@_parse_dot_label_cleanup:w,
-% \@@_parse_dot_label_aux:nw
+% \@@_parse_dot_label_aux:w
% }
% Start by checking if the label is empty, which raises an error, and
% uses the fallback value. If not,
% split the label at a \verb|./|, if any, and check if no tokens are
% before the \verb|./|, or if the only character is a \verb|.|.
% If these requirements are fulfilled, the leading
-% \verb|.| is replaced with \cs{@@_currname_or_default:n}. Otherwise
+% \verb|.| is replaced with \cs{@@_currname_or_default:}. Otherwise
% the label is returned unchanged.
% \begin{macrocode}
-\cs_new:Npn \@@_parse_dot_label:nn #1 #2
+\cs_new:Npn \@@_parse_dot_label:n #1
{
\tl_if_empty:nTF {#1}
{
- \msg_expandable_error:nnf { hooks } { empty-label }
- { \@@_currname_or_default:n {#2} }
- \@@_currname_or_default:n {#2}
+ \msg_expandable_error:nn { hooks } { empty-label }
+ \@@_currname_or_default:
}
{
\str_if_eq:nnTF {#1} { . }
- { \@@_currname_or_default:n {#2} }
- { \@@_parse_dot_label:nw {#2} #1 ./ \s_@@_mark }
+ { \@@_currname_or_default: }
+ { \@@_parse_dot_label:w #1 ./ \s_@@_mark }
}
}
-\cs_new:Npn \@@_parse_dot_label:nw #1 #2 ./ #3 \s_@@_mark
+\cs_new:Npn \@@_parse_dot_label:w #1 ./ #2 \s_@@_mark
{
- \tl_if_empty:nTF {#2}
- { \@@_parse_dot_label_aux:nw {#1} #3 \s_@@_mark }
+ \tl_if_empty:nTF {#1}
+ { \@@_parse_dot_label_aux:w #2 \s_@@_mark }
{
- \tl_if_empty:nTF {#3}
- { \@@_make_name:n {#2} }
- { \@@_parse_dot_label_cleanup:w #2 ./ #3 \s_@@_mark }
+ \tl_if_empty:nTF {#2}
+ { \@@_make_name:n {#1} }
+ { \@@_parse_dot_label_cleanup:w #1 ./ #2 \s_@@_mark }
}
}
\cs_new:Npn \@@_parse_dot_label_cleanup:w #1 ./ \s_@@_mark {#1}
-\cs_new:Npn \@@_parse_dot_label_aux:nw #1 #2 ./ \s_@@_mark
- { \@@_currname_or_default:n {#1} / \@@_make_name:n {#2} }
+\cs_new:Npn \@@_parse_dot_label_aux:w #1 ./ \s_@@_mark
+ { \@@_currname_or_default: / \@@_make_name:n {#1} }
% \end{macrocode}
% \end{macro}
% \end{macro}
%
-% \begin{macro}[EXP]{\@@_currname_or_default:n}
+% \begin{macro}[EXP]{\@@_currname_or_default:}
% Uses \cs{g_@@_hook_curr_name_tl} if it is set, otherwise tries
-% \cs{@currname}. If neither is set, uses the fallback value
-% \verb|#1| (usually \texttt{top-level}).
+% \cs{@currname}. If neither is set, raises an error and uses the
+% fallback value \verb|label-missing|.
% \begin{macrocode}
-\cs_new:Npn \@@_currname_or_default:n #1
+\cs_new:Npn \@@_currname_or_default:
{
\tl_if_empty:NTF \g_@@_hook_curr_name_tl
{
\tl_if_empty:NTF \@currname
- { \@@_make_name:n {#1} }
+ {
+ \msg_expandable_error:nnf { hooks } { no-default-label }
+ { label-missing }
+ \@@_make_name:n { label-missing }
+ }
{ \@currname }
}
{ \g_@@_hook_curr_name_tl }
@@ -2229,8 +2225,7 @@
% \begin{macrocode}
\str_if_eq:nnTF {#2} { top-level }
{
- \str_if_eq:eeTF { top-level }
- { \@@_currname_or_default:n { top-level } }
+ \str_if_eq:eeTF { top-level } { \@@_currname_or_default: }
{
\debug_suspend:
% \end{macrocode}
@@ -3906,7 +3901,18 @@
%
% \begin{macrocode}
\msg_new:nnn { hooks } { empty-label }
- { Empty~code~label~\msg_line_context:.~Using~`#1'~instead. }
+ {
+ Empty~code~label~\msg_line_context:.~
+ Using~`\@@_currname_or_default:'~instead.
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\msg_new:nnn { hooks } { no-default-label }
+ {
+ Missing~(empty)~default~label~\msg_line_context:. \\
+ Using~`#1'~instead.
+ }
% \end{macrocode}
%
% \begin{macrocode}
@@ -3936,7 +3942,7 @@
{
The~'top-level'~label~is~meant~for~user~code~only,~and~should~only~
be~used~(sparingly)~in~the~main~document.~Use~the~default~label~
- '\@@_currname_or_default:n { }'~for~this~\@cls at pkg,~or~another~
+ '\@@_currname_or_default:'~for~this~\@cls at pkg,~or~another~
suitable~label.
}
% \end{macrocode}
@@ -4010,9 +4016,7 @@
%
% 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. This stack
-% should never go empty.
+% default label for the |top-level|. 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,
@@ -4040,10 +4044,12 @@
% \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:
+% \cs{@@_curr_name_push:n} pushes a (\cs{@currname} by default) label
+% to the stack:
% \begin{macrocode}
\cs_new_protected:Npn \@@_curr_name_push:n #1
+ { \exp_args:Nx \@@_curr_name_push_aux:n { \@@_make_name:n {#1} } }
+\cs_new_protected:Npn \@@_curr_name_push_aux:n #1
{
\seq_gpush:Nn \g_@@_name_stack_seq {#1}
\tl_gset:Nn \g_@@_hook_curr_name_tl {#1}
More information about the latex3-commits
mailing list.