summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/base/ltfiles.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/base/ltfiles.dtx')
-rw-r--r--Master/texmf-dist/source/latex/base/ltfiles.dtx78
1 files changed, 64 insertions, 14 deletions
diff --git a/Master/texmf-dist/source/latex/base/ltfiles.dtx b/Master/texmf-dist/source/latex/base/ltfiles.dtx
index d99dfdcd48f..3bac7ea0b22 100644
--- a/Master/texmf-dist/source/latex/base/ltfiles.dtx
+++ b/Master/texmf-dist/source/latex/base/ltfiles.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 1993-2022
+% Copyright (C) 1993-2023
% The LaTeX Project and any individual authors listed elsewhere
% in this file.
%
@@ -32,7 +32,7 @@
%<*driver>
% \fi
\ProvidesFile{ltfiles.dtx}
- [2022/05/27 v1.2r LaTeX Kernel (File Handling)]
+ [2023/05/17 v1.2t LaTeX Kernel (File Handling)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltfiles.dtx}
@@ -417,6 +417,16 @@
\ignorespaces}
% \end{macrocode}
%
+% Provide a global definition for \cs{do} as well, so that it is
+% already defined in the preamble and not late as
+% \verb=\begin{document}= overwriting some definition given by the
+% unsuspecting user in the preamble.
+% \changes{v1.2s}{2023/01/05}{\cs{do} now with default definition in
+% the kernel (gh/975)}
+% \begin{macrocode}
+\let\do\noexpand
+% \end{macrocode}
+%
% The \hook{begindocument} hook already existed in the kernel since
% 1994 under the name \cs{atbegindocumenthook} the
% additional ones are originally from the \pkg{etoolbox}
@@ -1192,6 +1202,9 @@
% \changes{v1.0t}{1995/05/25}{(CAR) added \cs{long}}
% \changes{v1.2d}{2019/10/26}{quote on openin}
% \changes{v1.2k}{2021/03/12}{Allow unbalanced conditionals (gh/530)}
+% \changes{v1.2t}{2023/05/15}{Use \pkg{expl3} file existence test}
+% \begin{macro}{\IfFileExists@}
+% \changes{v1.2t}{2023/05/15}{Macro added}
% Argument |#1| is |\@curr@file| so catcode 12 string with no quotes.
%
% The original definition picked up arguments |#2| and |#3| in a
@@ -1201,23 +1214,35 @@
% \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.
+%
+% Earlier versions used |\openin| here, but this led to two
+% code paths, one in \pkg{expl3} and one here. To avoid that,
+% and as the \pkg{expl3} approach works by expansion, we use
+% that here. As we need the file name to include the path,
+% the actual \pkg{expl3} function used is not the file existence
+% test!
% \begin{macrocode}
%</2ekernel>
%<*2ekernel|latexrelease>
-%<latexrelease>\IncludeInRelease{2021/06/01}%
-%<latexrelease> {\IfFileExists@}{manage unbalanced conditionals}
+%<latexrelease>\IncludeInRelease{2023/05/01}%
+%<latexrelease> {\IfFileExists@}{IfFileExists}
\long\def \IfFileExists@#1#2#3{%
- \openin\@inputcheck"#1" %
- \ifeof\@inputcheck
- \ifx\input@path\@undefined
- \let\reserved@a\@secondoftwo
+ \edef\@filef@und{\IfFileExists@@{#1}}%
+% \end{macrocode}
+% The \pkg{expl3} function regards an empty argument as nothing at all,
+% but the \LaTeXe{} convention is that this is equal to the special
+% \texttt{.tex} file.
+% \begin{macrocode}
+ \ifx\@filef@und\@empty
+ \if\relax\detokenize{#1}\relax
+ \let\reserved@a\@firstoftwo
+ \def\@filef@und{".tex" }%
\else
- \def\reserved@a{\@iffileonpath{#1}}%
+ \let\reserved@a\@secondoftwo
\fi
\else
- \closein\@inputcheck
- \edef\@filef@und{"#1" }%
\let\reserved@a\@firstoftwo
+ \edef\@filef@und{"\@filef@und" }%
\fi
% \end{macrocode}
% This is just there so that any |#| inside |#2| or |#3| needs
@@ -1226,10 +1251,35 @@
\expandafter\def\expandafter\reserved@a
\expandafter{\reserved@a{#2}{#3}}%
\reserved@a}
+\ExplSyntaxOn
+\cs_new_eq:NN \IfFileExists@@ \file_full_name:n
+\ExplSyntaxOff
%</2ekernel|latexrelease>
%<latexrelease>\EndIncludeInRelease
+%<latexrelease>\IncludeInRelease{2021/06/01}%
+%<latexrelease> {\IfFileExists@}{IfFileExists}
+%<latexrelease>
+%<latexrelease>\long\def \IfFileExists@#1#2#3{%
+%<latexrelease> \openin\@inputcheck"#1" %
+%<latexrelease> \ifeof\@inputcheck
+%<latexrelease> \ifx\input@path\@undefined
+%<latexrelease> \let\reserved@a\@secondoftwo
+%<latexrelease> \else
+%<latexrelease> \def\reserved@a{\@iffileonpath{#1}}%
+%<latexrelease> \fi
+%<latexrelease> \else
+%<latexrelease> \closein\@inputcheck
+%<latexrelease> \edef\@filef@und{"#1" }%
+%<latexrelease> \let\reserved@a\@firstoftwo
+%<latexrelease> \fi
+%<latexrelease> \expandafter\def\expandafter\reserved@a
+%<latexrelease> \expandafter{\reserved@a{#2}{#3}}%
+%<latexrelease>\reserved@a}
+%<latexrelease>\let\IfFileExists@@\@undefined
+%<latexrelease>\EndIncludeInRelease
+%<latexrelease>
%<latexrelease>\IncludeInRelease{2019/10/01}%
-%<latexrelease> {\IfFileExists@}{manage unbalanced conditionals}
+%<latexrelease> {\IfFileExists@}{IfFileExists}
%<latexrelease>
%<latexrelease>\long\def \IfFileExists@#1#2#3{%
%<latexrelease> \openin\@inputcheck"#1" %
@@ -1247,7 +1297,7 @@
%<latexrelease> \reserved@a}
%<latexrelease>\EndIncludeInRelease
%<latexrelease>\IncludeInRelease{0000/00/00}%
-%<latexrelease> {\IfFileExists@}{manage unbalanced conditionals}
+%<latexrelease> {\IfFileExists@}{IfFileExists}
%<latexrelease>
%<latexrelease>\let\IfFileExists@\@undefined
%<latexrelease>
@@ -1256,7 +1306,7 @@
%<*2ekernel>
% \end{macrocode}
% \end{macro}
-%
+% \end{macro}
%
%
%