[latex3-commits] [git/LaTeX3-latex3-latex2e] develop: add warning to \include for issue #645 (#692) (14f9aecf)
GitHub
noreply at github.com
Sat Oct 16 17:10:00 CEST 2021
Repository : https://github.com/latex3/latex2e
On branch : develop
Link : https://github.com/latex3/latex2e/commit/14f9aecf245b5e9d0205578f175853f5d628e3e0
>---------------------------------------------------------------
commit 14f9aecf245b5e9d0205578f175853f5d628e3e0
Author: David Carlisle <d.p.carlisle at gmail.com>
Date: Sat Oct 16 16:10:00 2021 +0100
add warning to \include for issue #645 (#692)
* add warning to \include for issue #645
* s.tex not on place in a clean build, use custom file
* newline at end
* update tlg
* 3 is a big number
>---------------------------------------------------------------
14f9aecf245b5e9d0205578f175853f5d628e3e0
base/changes.txt | 6 +++++-
base/doc/ltnews34.tex | 13 ++++++++++++-
base/ltfiles.dtx | 20 ++++++++++++++++++--
base/testfiles/github-0645.lvt | 15 +++++++++++++++
base/testfiles/github-0645.tlg | 8 ++++++++
5 files changed, 58 insertions(+), 4 deletions(-)
diff --git a/base/changes.txt b/base/changes.txt
index 1e015a6c..c58b70a6 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -5,12 +5,16 @@ It is provided for convenience only. It therefore makes no claims to
completeness or accuracy and it contains some references to files that
are not part of the distribution.
================================================================================
-
2021-10-15 Marcel Krüger <Marcel.Krueger at latex-project.org>
* ltluatex.dtx:
Added missing callback process_charproc_data
+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-14 Frank Mittelbach <Frank.Mittelbach at latex-project.org>
* ltfloat.dtx (subsection{Footnotes}):
diff --git a/base/doc/ltnews34.tex b/base/doc/ltnews34.tex
index 83c0fa7e..5191de89 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..4c24716d 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.2p 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.2p}{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..c716af5b
--- /dev/null
+++ b/base/testfiles/github-0645.lvt
@@ -0,0 +1,15 @@
+\begin{filecontents}{github-0645.tex}
+\typeout{yes}
+\end{filecontents}
+\documentclass{article}
+
+\input{test2e}
+
+\START
+
+% neither of these should echo \@input{zzz.aux} to the terminal
+\include{foobar}
+
+\include{github-0645}
+
+\END
diff --git a/base/testfiles/github-0645.tlg b/base/testfiles/github-0645.tlg
new file mode 100644
index 00000000..2ce664d8
--- /dev/null
+++ b/base/testfiles/github-0645.tlg
@@ -0,0 +1,8 @@
+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 ....
+(github-0645.tex
+yes
+)
More information about the latex3-commits
mailing list.