Skip to content

Commit

Permalink
fix for #1407 (#1408)
Browse files Browse the repository at this point in the history
* fix for #1407

* corrections

* further suggestions by CAR
  • Loading branch information
FrankMittelbach authored Jul 13, 2024
1 parent 962bb9d commit 79583f9
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 1 deletion.
6 changes: 6 additions & 0 deletions base/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ to completeness or accuracy and it contains some references to files that are
not part of the distribution.
================================================================================

2024-07-10 Frank Mittelbach <[email protected]>

* ltmiscen.dtx (subsection{Environments}):
Drop code chunks before adding them to avoid duplication in
rollback (gh/1407)

2024-07-06 Yukai Chou <[email protected]>

* ltcmd.dtx (subsection{User functions}):
Expand Down
13 changes: 13 additions & 0 deletions base/doc/ltnews40.tex
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,19 @@ \section{Improvement to \XeTeX\ \cs{showhyphens}}
%
\githubissue{1380}

\section{Avoid code duplication in rollback}

When the kernel uses \cs{AddToHook} in a region that might be
rolled back (which happens in a few places) and a document requests a
rollback, then we have the situation that the hook already contains code to which we added the same
(or slightly different) code during the
rollback; this results in code duplication or, worse, in errors. This has
now been corrected by dropping any such code chunk (if there is one) prior to
adding the rollback code.
%
\githubissue{1407}


%\section{Changes to packages in the \pkg{amsmath} category}

%\section{Changes to packages in the \pkg{graphics} category}
Expand Down
29 changes: 28 additions & 1 deletion base/ltmiscen.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
%<*driver>
% \fi
\ProvidesFile{ltmiscen.dtx}
[2024/06/23 v1.2d LaTeX Kernel (Misc. Environments)]
[2024/07/10 v1.2e LaTeX Kernel (Misc. Environments)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltmiscen.dtx}
Expand Down Expand Up @@ -276,6 +276,21 @@
% \changes{v1.0w}{1994/11/30}{(DPC) Use \cs{@dofilelist}}
% \changes{v1.2a}{2022/11/06}{Repeat release info at the end (gh/944)}
% \begin{macrocode}
% \end{macrocode}
% If we roll back we have to drop stuff before adding chunks,
% otherwise the code will just be appended, and thus doubled.
% This would result in a harmless warning during the format
% generation, because in that case the code chunk label doesn't
% exist, and therefore can't be dropped.
% \changes{v1.2e}{2024/07/10}{Drop code chunks before adding them to
% avoid duplication in rollback (gh/1407)}
% \begin{macrocode}
%<latexrelease>\RemoveFromHook{enddocument/info}[kernel/filelist]
%<latexrelease>\RemoveFromHook{enddocument/info}[kernel/warnings]
%<latexrelease>\RemoveFromHook{enddocument/info}[kernel/release]
% \end{macrocode}
%
% \begin{macrocode}
\AddToHook{enddocument/info}[kernel/filelist]{\@dofilelist}
\AddToHook{enddocument/info}[kernel/warnings]{\@enddocument@kernel@warnings}
\AddToHook{enddocument/info}[kernel/release]{%
Expand Down Expand Up @@ -389,6 +404,18 @@
%<latexrelease>\NewHook{enddocument/afteraux}
%<latexrelease>\NewHook{enddocument/info}
%<latexrelease>\NewHook{enddocument/end}
% \end{macrocode}
% If we roll back we have to drop stuff before adding chunks,
% otherwise the code will just be appended, and thus doubled.
% \changes{v1.2e}{2024/07/10}{Drop code chunks before adding them to
% avoid duplication in rollback (gh/1407)}
% \begin{macrocode}
%<latexrelease>\RemoveFromHook{enddocument/info}[kernel/filelist]
%<latexrelease>\RemoveFromHook{enddocument/info}[kernel/warnings]
%<latexrelease>\RemoveFromHook{enddocument/info}[kernel/release]
% \end{macrocode}
%
% \begin{macrocode}
%<latexrelease>\AddToHook{enddocument/info}[kernel/filelist]{\@dofilelist}
%<latexrelease>\AddToHook{enddocument/info}[kernel/warnings]{\@enddocument@kernel@warnings}
%<latexrelease>\AddToHook{enddocument/info}[kernel/release]{%
Expand Down
13 changes: 13 additions & 0 deletions base/testfiles/github-1407-rollback.lvt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
\RequirePackage[2023-11-01]{latexrelease}

\documentclass{article}

\input{test2e}


\START

\typeout{--> Code should not be doubled in chunks}

\ShowHook{enddocument/info}
\END
21 changes: 21 additions & 0 deletions base/testfiles/github-1407-rollback.tlg
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
This is a generated file for the LaTeX2e validation system.
Don't change this file in any respect.
--> Code should not be doubled in chunks
-> The hook 'enddocument/info':
> Code chunks:
> kernel/filelist -> \@dofilelist
> kernel/warnings -> \@enddocument@kernel@warnings
> kernel/release -> \let \show@release@info \wlog \show@release@info { ***********}\the \LaTeXReleaseInfo \show@release@info { ***********}
> kernel/testmode ->
> Document-level (top-level) code (executed last):
> ---
> Extra code for next invocation:
> ---
> Rules:
> kernel/warnings|kernel/filelist with relation >
> kernel/release|kernel/filelist with relation <
> kernel/testmode|kernel/release with relation ->
> Execution order (after applying rules):
> kernel/release, kernel/testmode, kernel/filelist, kernel/warnings.
<recently read> }
l. ...\ShowHook{enddocument/info}

0 comments on commit 79583f9

Please sign in to comment.