[latex3-commits] [git/LaTeX3-latex3-latex2e] gh645: add warning to \include for issue #645 (741c371d)
David Carlisle
d.p.carlisle at gmail.com
Thu Oct 14 22:12:52 CEST 2021
Repository : https://github.com/latex3/latex2e
On branch : gh645
Link : https://github.com/latex3/latex2e/commit/741c371d01c4f26ea5fdace434f3302121b75225
>---------------------------------------------------------------
commit 741c371d01c4f26ea5fdace434f3302121b75225
Author: David Carlisle <d.p.carlisle at gmail.com>
Date: Thu Oct 14 21:12:52 2021 +0100
add warning to \include for issue #645
>---------------------------------------------------------------
741c371d01c4f26ea5fdace434f3302121b75225
base/changes.txt | 5 +++++
base/doc/ltnews34.tex | 13 ++++++++++++-
base/ltfiles.dtx | 20 ++++++++++++++++++--
base/testfiles/github-0645.lvt | 12 ++++++++++++
base/testfiles/github-0645.tlg | 7 +++++++
5 files changed, 54 insertions(+), 3 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index 7c574782..4a9d533a 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -6,6 +6,11 @@ completeness or accuracy and it contains some references to files that
are not part of the distribution.
================================================================================
+2021-10-14 David Carlisle <David.Carlisle at latex-project.org>
+
+ * ltfiles.dtx: Warn if \include is used before \begin{document}
+ and do not try to write to the aux file (which is not open) gh/645
+
2021-10-04 Frank Mittelbach <Frank.Mittelbach at latex-project.org>
* classes.dtx, doc.dtx, makeindx.dtx, preload.dtx, slides.dtx, array.dtx
diff --git a/base/doc/ltnews34.tex b/base/doc/ltnews34.tex
index d2507f69..cad9ed4e 100644
--- a/base/doc/ltnews34.tex
+++ b/base/doc/ltnews34.tex
@@ -479,7 +479,18 @@ whether used or not.
-
+\subsection{Improvements to \cs{include}}
+If \cs{include} is used before \verb|\begin{document}| then previously
+ it would write \verb|\@include{...}| to the terminal and log as the
+ aux file has not yet been opened. It also locally changed
+ the aux filename which could have unintended effects. \LaTeX\ now
+ warns about any use of \cs{include} before \verb|\begin{document}|
+ and as a recovery action will input the specified file if it exists (as
+ before) but without any adjustments to the aux file settings, and
+ without running the \cs{include} file hooks (only the generic file
+ hooks from \cs{InputIfFileExists}).
+%
+\githubissue{645}
\subsection{???}
diff --git a/base/ltfiles.dtx b/base/ltfiles.dtx
index 4dee83c4..c2437913 100644
--- a/base/ltfiles.dtx
+++ b/base/ltfiles.dtx
@@ -32,7 +32,7 @@
%<*driver>
% \fi
\ProvidesFile{ltfiles.dtx}
- [2021/08/25 v1.2o LaTeX Kernel (File Handling)]
+ [2021/10/14 v1.3a LaTeX Kernel (File Handling)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltfiles.dtx}
@@ -823,8 +823,16 @@
%
% \changes{v1.2j}{2020/10/04}{Quotes around the aux file name removed,
% they are not needed and upset BibTeX (gh/400)}
+% \changes{v1.3a}{2021/10/14}{Warn about use in preamble}
% \begin{macrocode}
\def\@include#1 {%
+% \end{macrocode}
+%
+% \begin{macrocode}
+\ifx\@nodocument\relax
+% \end{macrocode}
+%
+% \begin{macrocode}
\clearpage
\if at filesw
\immediate\write\@mainaux{\string\@input{#1.aux}}%
@@ -892,7 +900,15 @@
\deadcycles\z@
\@nameuse{cp@#1}%
\fi
- \let\@auxout\@mainaux}
+ \let\@auxout\@mainaux
+% \end{macrocode}
+%
+% \begin{macrocode}
+\else
+\@latex at warning{%
+ \noexpand\include should only be used after \string\begin{document}}%
+\@input@{#1}%
+\fi}
% \end{macrocode}
%
% \changes{v1.2o}{2021/08/25}{Declare non-generic include hooks}
diff --git a/base/testfiles/github-0645.lvt b/base/testfiles/github-0645.lvt
new file mode 100644
index 00000000..d94290b5
--- /dev/null
+++ b/base/testfiles/github-0645.lvt
@@ -0,0 +1,12 @@
+\documentclass{article}
+
+\input{test2e}
+
+\START
+
+% neither of these should echo \@input{zzz.aux} to the terminal
+\include{foobar}
+
+\include{s}
+
+\END
\ No newline at end of file
diff --git a/base/testfiles/github-0645.tlg b/base/testfiles/github-0645.tlg
new file mode 100644
index 00000000..d2033b0c
--- /dev/null
+++ b/base/testfiles/github-0645.tlg
@@ -0,0 +1,7 @@
+This is a generated file for the LaTeX2e validation system.
+Don't change this file in any respect.
+LaTeX Warning: \include should only be used after \begin{document} on input line ....
+No file foobar.
+LaTeX Warning: \include should only be used after \begin{document} on input line ....
+(s.tex File ignored
+)
More information about the latex3-commits
mailing list.