[latex3-commits] [git/LaTeX3-latex3-latex2e] gh479: Do not allocate registers that already exist (04b8a4c8)
PhelypeOleinik
phelype.oleinik at latex-project.org
Fri Mar 19 02:21:36 CET 2021
Repository : https://github.com/latex3/latex2e
On branch : gh479
Link : https://github.com/latex3/latex2e/commit/04b8a4c870bf64f5a003595497d3da999182c733
>---------------------------------------------------------------
commit 04b8a4c870bf64f5a003595497d3da999182c733
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date: Thu Mar 18 22:21:36 2021 -0300
Do not allocate registers that already exist
>---------------------------------------------------------------
04b8a4c870bf64f5a003595497d3da999182c733
base/latexrelease.dtx | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/base/latexrelease.dtx b/base/latexrelease.dtx
index c390a360..c67ff9af 100644
--- a/base/latexrelease.dtx
+++ b/base/latexrelease.dtx
@@ -517,6 +517,9 @@ of this package available from CTAN}
{ \@star at or@long \@@_declare_command:Nw }
\cs_new_protected:Npn \@@_declare_command:Nw #1
{ \cs_if_exist:NTF #1 { \renew at command } { \new at command } #1 }
+\cs_set_protected:Npn \@@_e at alloc:NnnnnN #1 #2 #3 #4 #5 #6
+ { \cs_if_free:NTF #6 { \@@_e at alloc #1 {#2} {#3} {#4} {#5} #6 }
+ { \typeout{Not~defining~\string#1~\string#6} } }
% \end{macrocode}
%
% Now create a token list to hold the list of changed commands, and
@@ -543,6 +546,12 @@ of this package available from CTAN}
% and give an error otherwise (similar to \cs{@ifdefinable}).
% Making it a no-op is enough for most cases (except when defining
% new registers);
+% \item[e at alloc] In the case of new registers, we waste an allocation
+% number if we do \cs[no-index]{new\meta{thing}} in a register
+% that's already allocated, so the redefinition of \cs{e at alloc}
+% checks if the new register is really necessary. This code does
+% not clear the register, which might cause problems in the future,
+% if a register is allocated but not properly cleared before using;
% \item[__kernel_msg_error:nnx] This command is used to error on
% already defined scan marks. Just making the error do nothing is
% enough, as no action is taken in that case;
@@ -560,6 +569,7 @@ of this package available from CTAN}
% \begin{macrocode}
\@@_tmp:w
\__kernel_chk_if_free_cs:N \use_none:n
+ \e at alloc \@@_e at alloc:NnnnnN
\__kernel_msg_error:nnx \use_none:nnn
\__kernel_msg_new:nnn \__kernel_msg_set:nnn
\__kernel_msg_new:nnnn \__kernel_msg_set:nnnn
More information about the latex3-commits
mailing list.