summaryrefslogtreecommitdiff
path: root/macros/latex/base/ltfiles.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-06-02 03:04:23 +0000
committerNorbert Preining <norbert@preining.info>2021-06-02 03:04:23 +0000
commit138d0a6cfd5f2187973fb6b83ad2fb0dcf5a8348 (patch)
treea95fba7d01d57bba550f5114c936ec76d57a49ac /macros/latex/base/ltfiles.dtx
parent0f69e2fd4a9928663f0cc64b8cac1f0d8baee9d6 (diff)
CTAN sync 202106020304
Diffstat (limited to 'macros/latex/base/ltfiles.dtx')
-rw-r--r--macros/latex/base/ltfiles.dtx179
1 files changed, 122 insertions, 57 deletions
diff --git a/macros/latex/base/ltfiles.dtx b/macros/latex/base/ltfiles.dtx
index 99be77c844..bcaac58220 100644
--- a/macros/latex/base/ltfiles.dtx
+++ b/macros/latex/base/ltfiles.dtx
@@ -1,7 +1,7 @@
% \iffalse meta-comment
%
-% Copyright (C) 1993-2020
-% The LaTeX3 Project and any individual authors listed elsewhere
+% Copyright (C) 1993-2021
+% The LaTeX Project and any individual authors listed elsewhere
% in this file.
%
% This file is part of the LaTeX base system.
@@ -32,7 +32,7 @@
%<*driver>
% \fi
\ProvidesFile{ltfiles.dtx}
- [2020/10/04 v1.2j LaTeX Kernel (File Handling)]
+ [2021/04/17 v1.2m LaTeX Kernel (File Handling)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltfiles.dtx}
@@ -49,6 +49,9 @@
\providecommand\pkg[1]{\texttt{#1}}
+\providecommand\InternalDetectionOff{}
+\providecommand\InternalDetectionOn{}
+
\begin{document}
\MaintainedByLaTeXTeam{latex}
\maketitle
@@ -192,19 +195,6 @@
% \end{oldcomments}
%
%
-% \task{???}{Do we use @unused or mainaux?}
-% \begin{macro}{\@inputcheck}
-% \begin{macro}{\@unused}
-% Allocate read stream for testing and output stream.
-% \changes{v1.0l}{1994/11/07}
-% {move here from ltdefns, remove duplicate \cs{@mainaux}}
-% \begin{macrocode}
-\newread\@inputcheck
-\newwrite\@unused
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-%
% \begin{macro}{\@mainaux}
% \begin{macro}{\@partaux}
% \begin{macrocode}
@@ -334,7 +324,7 @@
% locally in the output routine. In particular it allows hyphenation
% in the page head even if the page break happens in verbatim.
% If this has already been set by a package, set to the value of |\language|
-% at this spoint.
+% at this point.
% \changes{v1.1n}{2017/03/10}{Save language default}
% \begin{macrocode}
\ifx\document@default@language\m@ne
@@ -456,18 +446,25 @@
% harmless), however, in more complicated scenarios where several
% full documents are combined to a single document it might get
% applied several times with harmful effects. We therefore
-% explicitly drop it at this point. the coing is somewhat obscure
+% explicitly drop it at this point. the coding is somewhat obscure
% due to the name of the macro which requires constructing.
+% \InternalDetectionOff
% \begin{macrocode}
\edef \@kernel@after@begindocument@before {%
\let\expandafter\noexpand\csname
__hook env/document/begin\endcsname
\noexpand\@empty}
% \end{macrocode}
+% \InternalDetectionOn
%
+% These internal hooks are already declared earlier (in
+% \texttt{ltexpl}) so that other modules could write to them.
+% \changes{v1.2m}{2021/04/17}{Move \cs{@kernel@before@begindocument} and
+% \cs{@kernel@after@begindocument} init earlier so that other modules can
+% write to the hooks}
% \begin{macrocode}
-\let \@kernel@before@begindocument \@empty
-\let \@kernel@after@begindocument \@empty
+%\let \@kernel@before@begindocument \@empty
+%\let \@kernel@after@begindocument \@empty
% \end{macrocode}
%
% \end{macro}
@@ -710,15 +707,15 @@
\@latex@error{\string\include\space cannot be nested}\@eha
\else
% \end{macrocode}
-% Here the normalisation will add |.tex| for all files, (it uses the
-% the same normalisation as the hooks), so we need to remove that
+% Here the normalization will add |.tex| for all files, (it uses
+% the same normalization as the hooks), so we need to remove that
% manually. \cs{@strip@tex@ext} does that.
% \begin{macrocode}
\set@curr@file{#1}%
\edef\@curr@file{\@strip@tex@ext\@curr@file}%
% \end{macrocode}
% For historical reasons \cs{@include} expects an argument
-% delimited by a space. This is kept (though uncessary now) to avoid
+% delimited by a space. This is kept (though unnecessary now) to avoid
% errors in other packages that use \cs{@include} directly.
% \begin{macrocode}
\expandafter\@include\expandafter{\@curr@file} % deliberate space
@@ -726,13 +723,13 @@
% \end{macrocode}
%
% Here in \cs{includeonly} we also need to strip |.tex| after
-% normalisation:
+% normalization:
% \begin{macrocode}
\def\includeonly#1{%
\@partswtrue
% \end{macrocode}
% Because the argument to |\includeonly| is a comma-separated list
-% of filenames where there may be comma's precedeing some of the
+% of filenames where there may be comma's preceding some of the
% filenames or trailing them. Therefore we need to take the list
% apart, remove the unwanted spaces while leaving the spaces
% \emph{in} the filenames intact.
@@ -996,10 +993,11 @@
% A side effect of the new code is that we will see quotes around
% file name displays where there haven't been any before.
%
-% For compatibilty with existing code using |{abc}.tex| or |{one.two}.png|
-% an initial brace group is discarded before expansion and |\string| is applied
-% The content of the brace group is discarded. This means that a leading space
-% will be lost unless protected (by |{ }| or |" "| or |\space|) but filenames
+% For compatibility with existing code using |{abc}.tex| or
+% |{one.two}.png|, an initial brace group is discarded before
+% expansion and |\string| is applied. The content of the brace
+% group is discarded. This means that a leading space will be lost
+% unless protected (by |{ }| or |" "| or |\space|) but filenames
% with a space are hopefully rare.
%
% \changes{v1.2a}{2019/07/01}{Support UTF-8}
@@ -1058,7 +1056,7 @@
%
% \changes{v1.2a}{2019/07/01}{Support UTF-8}
% \changes{v1.2b}{2019/08/27}{Make command robust}
-% \changes{v1.2d}{2019/10/26}{dont quote name}
+% \changes{v1.2d}{2019/10/26}{don't quote name}
% \begin{macrocode}
\DeclareRobustCommand\IfFileExists[1]{%
\set@curr@file{#1}%
@@ -1066,30 +1064,114 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macrocode}
+%</2ekernel|latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{0000/00/00}%
+%<latexrelease> {\quote@name}{Quote file names}%
+%<latexrelease>
+%<latexrelease>\let\quote@name\@undefined
+%<latexrelease>\let\quote@@name\@undefined
+%<latexrelease>\let\unquote@name\@undefined
+%<latexrelease>
+%<latexrelease>\long\def \IfFileExists#1#2#3{%
+%<latexrelease> \openin\@inputcheck#1 %
+%<latexrelease> \ifeof\@inputcheck
+%<latexrelease> \ifx\input@path\@undefined
+%<latexrelease> \def\reserved@a{#3}%
+%<latexrelease> \else
+%<latexrelease> \def\reserved@a{\@iffileonpath{#1}{#2}{#3}}%
+%<latexrelease> \fi
+%<latexrelease> \else
+%<latexrelease> \closein\@inputcheck
+%<latexrelease> \edef\@filef@und{#1 }%
+%<latexrelease> \def\reserved@a{#2}%
+%<latexrelease> \fi
+%<latexrelease> \reserved@a}
+%<latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<*2ekernel>
+% \end{macrocode}
+%
+%
+%
% \begin{macro}{\IfFileExists@}
% \changes{v0.9b}{1993/12/04}{Macro added}
% \changes{v0.9p}{1994/01/18}{New Definition}
% \changes{v1.0t}{1995/05/25}{(CAR) added \cs{long}}
-% \changes{v1.2d}{2019/10/26}{quote on openin}%
+% \changes{v1.2d}{2019/10/26}{quote on openin}
+% \changes{v1.2k}{2021/03/12}{Allow unbalanced conditionals (gh/530)}
% Argument |#1| is |\@curr@file| so catcode 12 string with no quotes.
+%
+% The original definition picked up arguments |#2| and |#3| in a
+% way that they couldn't contain unbalanced conditionals. A better
+% implementation would have been not to pick up the arguments at
+% all but instead use the usual \cs{@firstoftwo} and
+% \cs{secondoftwo}. However, that changes how |#| is interpreted
+% and so we can't do that nowaways without invalidating a lot of
+% code. Therefore the somewhat curious construction near the end.
% \begin{macrocode}
+%</2ekernel>
+%<*2ekernel|latexrelease>
+%<latexrelease>\IncludeInRelease{2021/06/01}%
+%<latexrelease> {\IfFileExists@}{manage unbalanced conditionals}
\long\def \IfFileExists@#1#2#3{%
\openin\@inputcheck"#1" %
\ifeof\@inputcheck
\ifx\input@path\@undefined
- \def\reserved@a{#3}%
+ \let\reserved@a\@secondoftwo
\else
- \def\reserved@a{\@iffileonpath{#1}{#2}{#3}}%
+ \def\reserved@a{\@iffileonpath{#1}}%
\fi
\else
\closein\@inputcheck
\edef\@filef@und{"#1" }%
- \def\reserved@a{#2}%
+ \let\reserved@a\@firstoftwo
\fi
- \reserved@a}
+% \end{macrocode}
+% This is just there so that any |#| inside |#2| or |#3| needs
+% doubling (as that was the case in the past).
+% \begin{macrocode}
+ \expandafter\def\expandafter\reserved@a
+ \expandafter{\reserved@a{#2}{#3}}%
+\reserved@a}
+%</2ekernel|latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{2019/10/01}%
+%<latexrelease> {\IfFileExists@}{manage unbalanced conditionals}
+%<latexrelease>
+%<latexrelease>\long\def \IfFileExists@#1#2#3{%
+%<latexrelease> \openin\@inputcheck"#1" %
+%<latexrelease> \ifeof\@inputcheck
+%<latexrelease> \ifx\input@path\@undefined
+%<latexrelease> \def\reserved@a{#3}%
+%<latexrelease> \else
+%<latexrelease> \def\reserved@a{\@iffileonpath{#1}{#2}{#3}}%
+%<latexrelease> \fi
+%<latexrelease> \else
+%<latexrelease> \closein\@inputcheck
+%<latexrelease> \edef\@filef@und{"#1" }%
+%<latexrelease> \def\reserved@a{#2}%
+%<latexrelease> \fi
+%<latexrelease> \reserved@a}
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{0000/00/00}%
+%<latexrelease> {\IfFileExists@}{manage unbalanced conditionals}
+%<latexrelease>
+%<latexrelease>\let\IfFileExists@\@undefined
+%<latexrelease>
+%<latexrelease>
+%<latexrelease>\EndIncludeInRelease
+%<*2ekernel>
% \end{macrocode}
% \end{macro}
%
+%
+%
+%
+%
+%
+%
% \begin{macro}{\@iffileonpath}
% If the file is not found by |\openin|, and |\input@path| is defined,
% look in all the directories specified in |\input@path|.
@@ -1103,6 +1185,10 @@
% \changes{v1.2d}{2019/10/26}{quote on openin}%
% \changes{v1.2f}{2019/11/11}{make \cs{@filef@und} match quoting used on \cs{openin}}%
% \begin{macrocode}
+%</2ekernel>
+%<*2ekernel|latexrelease>
+%<latexrelease>\IncludeInRelease{2019/10/01}%
+%<latexrelease> {\@iffileonpath}{Quote file names}
\long\def\@iffileonpath#1{%
\let\reserved@a\@secondoftwo
\expandafter\@tfor\expandafter\reserved@b\expandafter
@@ -1122,28 +1208,7 @@
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}%
-%<latexrelease> {\quote@name}{Quote file names}%
-%<latexrelease>
-%<latexrelease>\let\quote@name\@undefined
-%<latexrelease>\let\quote@@name\@undefined
-%<latexrelease>\let\unquote@name\@undefined
-%<latexrelease>
-%<latexrelease>\let\IfFileExists@\@undefined
-%<latexrelease>
-%<latexrelease>\long\def \IfFileExists#1#2#3{%
-%<latexrelease> \openin\@inputcheck#1 %
-%<latexrelease> \ifeof\@inputcheck
-%<latexrelease> \ifx\input@path\@undefined
-%<latexrelease> \def\reserved@a{#3}%
-%<latexrelease> \else
-%<latexrelease> \def\reserved@a{\@iffileonpath{#1}{#2}{#3}}%
-%<latexrelease> \fi
-%<latexrelease> \else
-%<latexrelease> \closein\@inputcheck
-%<latexrelease> \edef\@filef@und{#1 }%
-%<latexrelease> \def\reserved@a{#2}%
-%<latexrelease> \fi
-%<latexrelease> \reserved@a}
+%<latexrelease> {\quote@name}{Quote file names}
%<latexrelease>
%<latexrelease>\long\def\@iffileonpath#1{%
%<latexrelease> \let\reserved@a\@secondoftwo