diff options
author | Norbert Preining <norbert@preining.info> | 2020-10-03 03:01:09 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-10-03 03:01:09 +0000 |
commit | 0e644e6805342838052f46e6af93f81644d0390b (patch) | |
tree | 26169230ce62dc353013ad08fb824f46d9511980 /macros/latex/base/ltfiles.dtx | |
parent | 37f9a57b2f39142fbccb20b758af8e0502499671 (diff) |
CTAN sync 202010030301
Diffstat (limited to 'macros/latex/base/ltfiles.dtx')
-rw-r--r-- | macros/latex/base/ltfiles.dtx | 531 |
1 files changed, 454 insertions, 77 deletions
diff --git a/macros/latex/base/ltfiles.dtx b/macros/latex/base/ltfiles.dtx index 33594a7b91..835f600e32 100644 --- a/macros/latex/base/ltfiles.dtx +++ b/macros/latex/base/ltfiles.dtx @@ -32,7 +32,7 @@ %<*driver> % \fi \ProvidesFile{ltfiles.dtx} - [2019/11/11 v1.2f LaTeX Kernel (File Handling)] + [2020/08/21 v1.2i LaTeX Kernel (File Handling)] % \iffalse \documentclass{ltxdoc} \GetFileInfo{ltfiles.dtx} @@ -47,6 +47,8 @@ Chris Rowley\and Rainer Sch\"opf} +\providecommand\pkg[1]{\texttt{#1}} + \begin{document} \MaintainedByLaTeXTeam{latex} \maketitle @@ -55,6 +57,8 @@ %</driver> % \fi % +% \providecommand\hook[1]{\texttt{#1}} +% % % \changes{v1.0h}{1994/05/21}{Use new error commands} % \changes{v1.0n}{1994/11/17} @@ -62,6 +66,7 @@ % \changes{v1.0u}{1995/07/13}{Updates to docu} % \changes{v1.1m}{2015/02/21} % {Removed autoload support} +% \changes{v1.2i}{2020/08/21}{Integration of new hook management interface} % % \section{File Handling} % @@ -234,18 +239,28 @@ % \changes{v0.9e}{1993/12/09}{Hook added} % \begin{macrocode} %</2ekernel> -%<latexrelease>\IncludeInRelease{2017/04/15}% -%<latexrelease> {\document}{Save language for hyphenation}% +%<latexrelease>\IncludeInRelease{2020/10/01}% +%<latexrelease> {\document}{Added hook to load l3backend code}% %<*2ekernel|latexrelease> +\def\document{% % \end{macrocode} -% Cancel the |\begingroup| from |\begin|. +% We do cancel the grouping as part of the \cs{begin} handling +% (this is now done inside \cs{begin} instead) so that the +% \hook{env/\meta{env}/begin} hook is not hidden inside \cs{begingroup} +% \texttt{...} \cs{endgroup}. % \begin{macrocode} -\def\document{\endgroup +% \endgroup % \end{macrocode} -% If some options on |\documentclass| haven't been used by any -% package we will now give a warning since this is most certainly a -% misspelling. +% % \begin{macrocode} + \UseOneTimeHook{begindocument/before}% + \@kernel@after@begindocument@before +% \end{macrocode} +% +% Added hook to load \textsf{l3backend} code: +% \changes{v1.2h}{2020/06/05}{Added hook to load \textsf{l3backend} code} +% \begin{macrocode} + \@expl@sys@load@backend@@ \ifx\@unusedoptionlist\@empty\else \@latex@warning@no@line{Unused global option(s):^^J% \@spaces[\@unusedoptionlist]}% @@ -348,9 +363,11 @@ % \changes{v1.1e}{1996/04/24} % {(DPC) Reset \cs{AtBeginDocument} eg for latex/1297} % \begin{macrocode} - \let\AtBeginDocument\@firstofone - \@begindocumenthook + \@kernel@before@begindocument + \UseOneTimeHook{begindocument}% + \@kernel@after@begindocument % \end{macrocode} +% % Most of the following assignments will be done globally in case % the user adds something like |\begin{multicols}| to the document % hook, i.e. starts are group in |\begin{document}|. @@ -399,13 +416,128 @@ % \begin{macrocode} \global\let\do\noexpand % \end{macrocode} +% +% \begin{macrocode} + \UseOneTimeHook{begindocument/end}% +% \end{macrocode} % \changes{v1.1c}{1995/12/05}{\cs{ignorespaces} added for latex/1933} -% Use of |\AtBeginDocument| hook might mean that we are already in +% Use of the hook might mean that we are already in % horizontal mode, so ignore the space after |\begin{document}|. % \begin{macrocode} \ignorespaces} +% \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} +% package under the names \cs{@endpreamblehook} \cs{afterpreamble}. +% \begin{macrocode} +\NewHook{begindocument} +\NewHook{begindocument/before} +\NewHook{begindocument/end} +% \end{macrocode} + + + +% \begin{macro}{\@kernel@after@begindocument@before, +% \@kernel@before@begindocument, +% \@kernel@after@begindocument} +% +% Above we used two kernel only hooks to be run after the public +% \hook{begindocument/before} and after \hook{begindocument} +% hooks. +% +% In \cs{@kernel@after@begindocument@before} we already place one +% action: drop the fast execution code for the +% \hook{env/document/begin} hook. That hook marks the end of the +% preamble and should therefore only be run once. In a normal +% document that is anyway the case (so the code would just sit +% there taking up space afterwards, which these days is rather +% 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 +% due to the name of the macro which requires constructing. +% \begin{macrocode} +\edef \@kernel@after@begindocument@before {% + \let\expandafter\noexpand\csname + __hook env/document/begin\endcsname + \noexpand\@empty} +% \end{macrocode} +% +% \begin{macrocode} +\let \@kernel@before@begindocument \@empty +\let \@kernel@after@begindocument \@empty +% \end{macrocode} +% +% \end{macro} +% + +% +% \begin{macrocode} %</2ekernel|latexrelease> %<latexrelease>\EndIncludeInRelease +% \end{macrocode} +% +% \begin{macrocode} +%<latexrelease>\IncludeInRelease{2017/04/15}% +%<latexrelease> {\document}{Save language for hyphenation}% +%<latexrelease> +%<latexrelease>\def\document{\endgroup +%<latexrelease> \ifx\@unusedoptionlist\@empty\else +%<latexrelease> \@latex@warning@no@line{Unused global option(s):^^J% +%<latexrelease> \@spaces[\@unusedoptionlist]}% +%<latexrelease> \fi +%<latexrelease> \@colht\textheight +%<latexrelease> \@colroom\textheight \vsize\textheight +%<latexrelease> \columnwidth\textwidth +%<latexrelease> \@clubpenalty\clubpenalty +%<latexrelease> \if@twocolumn +%<latexrelease> \advance\columnwidth -\columnsep +%<latexrelease> \divide\columnwidth\tw@ \hsize\columnwidth \@firstcolumntrue +%<latexrelease> \fi +%<latexrelease> \hsize\columnwidth \linewidth\hsize +%<latexrelease> \begingroup\@floatplacement\@dblfloatplacement +%<latexrelease> \makeatletter\let\@writefile\@gobbletwo +%<latexrelease> \global \let \@multiplelabels \relax +%<latexrelease> \@input{\jobname.aux}% +%<latexrelease> \endgroup +%<latexrelease> \if@filesw +%<latexrelease> \immediate\openout\@mainaux\jobname.aux +%<latexrelease> \immediate\write\@mainaux{\relax}% +%<latexrelease> \fi +%<latexrelease> \process@table +%<latexrelease> \let\glb@currsize\@empty % Force math initialization. +%<latexrelease> \normalsize +%<latexrelease> \everypar{}% +%<latexrelease> \ifx\normalsfcodes\@empty +%<latexrelease> \ifnum\sfcode`\.=\@m +%<latexrelease> \let\normalsfcodes\frenchspacing +%<latexrelease> \else +%<latexrelease> \let\normalsfcodes\nonfrenchspacing +%<latexrelease> \fi +%<latexrelease> \fi +%<latexrelease> \ifx\document@default@language\m@ne +%<latexrelease> \chardef\document@default@language\language +%<latexrelease> \fi +%<latexrelease> \@noskipsecfalse +%<latexrelease> \let \@refundefined \relax +%<latexrelease> \let\AtBeginDocument\@firstofone +%<latexrelease> \@begindocumenthook +%<latexrelease> \ifdim\topskip<1sp\global\topskip 1sp\relax\fi +%<latexrelease> \global\@maxdepth\maxdepth +%<latexrelease> \global\let\@begindocumenthook\@undefined +%<latexrelease> \ifx\@listfiles\@undefined +%<latexrelease> \global\let\@filelist\relax +%<latexrelease> \global\let\@addtofilelist\@gobble +%<latexrelease> \fi +%<latexrelease> \gdef\do##1{\global\let ##1\@notprerr}% +%<latexrelease> \@preamblecmds +%<latexrelease> \global\let \@nodocument \relax +%<latexrelease> \global\let\do\noexpand +%<latexrelease> \ignorespaces} +%<latexrelease>\EndIncludeInRelease +%<latexrelease> %<latexrelease>\IncludeInRelease{0000/00/00}% %<latexrelease> {\document}{Save language for hyphenation} %<latexrelease>\def\document{\endgroup @@ -539,26 +671,14 @@ % \end{macrocode} % % -% \begin{macro}{\includeonly} +% \begin{macro}{\include,\includeonly} +% \changes{v0.9p}{1994/01/18} +% {Use \cs{@input@} so include files are listed.} % \changes{v1.0p}{1995/04/22}{Allow blanks in argument} % \changes{v1.2a}{2019/07/01}{Support UTF-8} -% \begin{macrocode} -%</2ekernel> -%<*2ekernel|latexrelease> -%<latexrelease>\IncludeInRelease{2019/10/01}% -%<latexrelease> {\includeonly}{Spaces in file names}% -\def\includeonly#1{% - \@partswtrue - \set@curr@file{\zap@space#1 \@empty}% - \let\@partlist\@curr@file - } -\@onlypreamble\includeonly -% \end{macrocode} -% \end{macro} +% \changes{v1.2g}{2020/05/02}{Improved support for spaces in filenames +% (gh/217)} % -% \begin{macro}{\include} -% \changes{v0.9p}{1994/01/18} -% {Use \cs{@input@} so include files are listed.} % In the definition of |\include|, |\def\reserved@b| changed to % |\edef\reserved@b| to be consistent with the |\edef| in % |\includeonly|. @@ -572,21 +692,113 @@ % % Made |\include| check for being used inside an |\include|'d file, as % this will not work and cause surprising results. +% \changes{v1.2g}{2020/05/02}{Get rid of leading and trailing spaces +% from the filename (gh/217)} +% \changes{v1.2g}{2020-05-02}{Pass the filename to \cs{@include} by +% value instead of by reference (gh/217)} +% +% \begin{macrocode} +%</2ekernel> +%<*2ekernel|latexrelease> +%<latexrelease>\IncludeInRelease{2020/10/01}% +%<latexrelease> {\includeonly}{Spaces in file names}% +% \end{macrocode} +% % \begin{macrocode} \def\include#1{\relax \ifnum\@auxout=\@partaux \@latex@error{\string\include\space cannot be nested}\@eha \else - \set@curr@file{#1 }% - \expandafter\@include\@curr@file +% \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 +% 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 +% errors in other packages that use \cs{@include} directly. +% \begin{macrocode} + \expandafter\@include\expandafter{\@curr@file} % deliberate space \fi} % \end{macrocode} -% \end{macro} % +% Here in \cs{includeonly} we also need to strip |.tex| after +% normalisation: +% \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 +% 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. +% \begin{macrocode} + \let\@partlist\@empty + \@for\reserved@a:=#1 \do + {% + \expandafter\set@curr@file\expandafter{\reserved@a}% + \ifx\@partlist\@empty + \edef\@partlist{\@strip@tex@ext\@curr@file}% + \else + \edef\@partlist{\@partlist,\@strip@tex@ext\@curr@file}% + \fi + }% + } +\@onlypreamble\includeonly +% \end{macrocode} +% \end{macro} % +% \begin{macro}{\@strip@tex@ext,\@strip@tex@ext@aux} +% These macros take a (\cs{detokenize}d file name and remove any +% |.tex| extension). Extra care is taken to not remove the string +% |.tex| from the middle of a file name: it is only removed if it's +% the very last thing in the file name. % \begin{macrocode} +\def\reserved@a#1{% +\def\@strip@tex@ext##1{% + \expandafter\@strip@tex@ext@aux + ##1\@nil\@nil + #1\@nil\relax\@nnil} +\def\@strip@tex@ext@aux##1#1\@nil##2\@nnil{% + \ifx\relax##2\@empty + \expandafter\@cdr\expandafter\@empty\@cdr{}##1% + \else##1\fi}}% +\expandafter\reserved@a +\expandafter{\detokenize{.tex}} %</2ekernel|latexrelease> +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +%<latexrelease>\EndIncludeInRelease +%<latexrelease>\IncludeInRelease{2019/10/01}% +%<latexrelease> {\includeonly}{Spaces in file names}% +%<latexrelease> +%<latexrelease>\def\includeonly#1{% +%<latexrelease> \@partswtrue +%<latexrelease> \set@curr@file{\zap@space#1 \@empty}% +%<latexrelease> \let\@partlist\@curr@file +%<latexrelease> } +%<latexrelease> +%<latexrelease>\def\include#1{\relax +%<latexrelease> \ifnum\@auxout=\@partaux +%<latexrelease> \@latex@error{\string\include\space cannot be nested}\@eha +%<latexrelease> \else +%<latexrelease> \set@curr@file{#1 }% +%<latexrelease> \expandafter\@include\@curr@file +%<latexrelease> \fi} +%<latexrelease> +%<latexrelease>\let\@strip@tex@ext\@undefined +%<latexrelease>\let\@strip@tex@ext@aux\@undefined +%<latexrelease> %<latexrelease>\EndIncludeInRelease +% \end{macrocode} +% +% \begin{macrocode} %<latexrelease>\IncludeInRelease{0000/00/00}% %<latexrelease> {\includeonly}{Spaces in file names}% %<latexrelease>\def\includeonly#1{% @@ -601,14 +813,22 @@ %<latexrelease>\EndIncludeInRelease %<*2ekernel> % \end{macrocode} - % % \begin{macro}{\@include} +% \changes{v1.2g}{2020/05/02}{Support spaces in filenames by enclosing +% the names of \texttt{.aux}-files in quotes (gh/217)} +% \begin{macrocode} +%</2ekernel> +%<*2ekernel|latexrelease> +%<latexrelease>\IncludeInRelease{2020/10/01}% +%<latexrelease> {\@include}{Spaces in file names and hooks}% +% \end{macrocode} +% % \begin{macrocode} \def\@include#1 {% \clearpage \if@filesw - \immediate\write\@mainaux{\string\@input{#1.aux}}% + \immediate\write\@mainaux{\string\@input{"#1.aux"}}% \fi \@tempswatrue \if@partsw @@ -620,11 +840,41 @@ \if@tempswa \let\@auxout\@partaux \if@filesw - \immediate\openout\@partaux #1.aux + \immediate\openout\@partaux "#1.aux" \immediate\write\@partaux{\relax}% \fi +% \end{macrocode} +% Now before going to the hooks we need to set \cs{CurrentFile}: +% \begin{macrocode} +%----------------------------------------- + \@filehook@set@CurrentFile +% \end{macrocode} +% Execute the \texttt{before} hooks just after we switched the +% \texttt{.aux} file \ldots +% \begin{macrocode} + \UseHook{include/before}% + \UseHook{include/before/#1}% +%----------------------------------------- \@input@{#1.tex}% +%----------------------------------------- +% \end{macrocode} +% \ldots{} then \texttt{end} hooks \ldots +% \begin{macrocode} + \UseHook{include/end/#1}% + \UseHook{include/end}% +%----------------------------------------- \clearpage +%----------------------------------------- +% \end{macrocode} +% \ldots{} and after the \cs{clearpage} the \texttt{after} hooks +% followed by another \cs{clearpage} just in case new material got +% added (after all we need to be in well defined state after the +% \cs{include}). +% \begin{macrocode} + \UseHook{include/after/#1}% + \UseHook{include/after}% + \clearpage +%----------------------------------------- \@writeckpt{#1}% \if@filesw \immediate\closeout\@partaux @@ -640,6 +890,45 @@ \@nameuse{cp@#1}% \fi \let\@auxout\@mainaux} +%<latexrelease>\EndIncludeInRelease +%</2ekernel|latexrelease> +% \end{macrocode} +% +% \begin{macrocode} +%<latexrelease>\IncludeInRelease{0000/00/00}% +%<latexrelease> {\@include}{Spaces in file names}% +%<latexrelease>\def\@include#1 {% +%<latexrelease> \clearpage +%<latexrelease> \if@filesw +%<latexrelease> \immediate\write\@mainaux{\string\@input{#1.aux}}% +%<latexrelease> \fi +%<latexrelease> \@tempswatrue +%<latexrelease> \if@partsw +%<latexrelease> \@tempswafalse +%<latexrelease> \edef\reserved@b{#1}% +%<latexrelease> \@for\reserved@a:=\@partlist\do +%<latexrelease> {\ifx\reserved@a\reserved@b\@tempswatrue\fi}% +%<latexrelease> \fi +%<latexrelease> \if@tempswa +%<latexrelease> \let\@auxout\@partaux +%<latexrelease> \if@filesw +%<latexrelease> \immediate\openout\@partaux #1.aux +%<latexrelease> \immediate\write\@partaux{\relax}% +%<latexrelease> \fi +%<latexrelease> \@input@{#1.tex}% +%<latexrelease> \clearpage +%<latexrelease> \@writeckpt{#1}% +%<latexrelease> \if@filesw +%<latexrelease> \immediate\closeout\@partaux +%<latexrelease> \fi +%<latexrelease> \else +%<latexrelease> \deadcycles\z@ +%<latexrelease> \@nameuse{cp@#1}% +%<latexrelease> \fi +%<latexrelease> \let\@auxout\@mainaux} +%<latexrelease> +%<latexrelease>\EndIncludeInRelease +%<*2ekernel> % \end{macrocode} % \end{macro} % @@ -688,7 +977,6 @@ % % % - % \begin{macro}{\@curr@file} % \begin{macro}{\set@curr@file} % @@ -698,8 +986,8 @@ % the code in \texttt{utf8.def}). By setting \cs{escapchar} to % \texttt{-1} we ensure that we don't get a backslash in front. As a % result we end up with all characters as catcode 12 (plus -% spaces). We then sometimes add quotes around the contruct -% (removing any existing inner quotes. Somes we only remove the +% spaces). We then sometimes add quotes around the construct +% (removing any existing inner quotes. Sometimes we only remove the % quotes if they have been supplied by the user. There is clearly % some room for improvement. % @@ -716,11 +1004,11 @@ % \changes{v1.2c}{2019/10/11}{Remove one brace group} % \changes{v1.2d}{2019/10/26}{remove quotes} % \changes{v1.2e}{2019/11/09}{expand and \cs{string} before removing quotes} +% +% The definition below is from 2019 and only used during kernel +% bootstrapping, later on in \texttt{ltfilehook.dtx} it will get +% overwritten. % \begin{macrocode} -%</2ekernel> -%<*2ekernel|latexrelease> -%<latexrelease>\IncludeInRelease{2019/10/01}% -%<latexrelease> {\set@curr@file}{Quote file names}% \def\set@curr@file#1{% \begingroup \escapechar\m@ne @@ -747,6 +1035,10 @@ % -> "" %\end{verbatim} % \begin{macrocode} +%</2ekernel> +%<*2ekernel|latexrelease> +%<latexrelease>\IncludeInRelease{2019/10/01}% +%<latexrelease> {\quote@name}{Quote file names}% \def\quote@name#1{"\quote@@name#1\@gobble""} \def\quote@@name#1"{#1\quote@@name} % \end{macrocode} @@ -828,12 +1120,11 @@ %</2ekernel|latexrelease> %<latexrelease>\EndIncludeInRelease %<latexrelease>\IncludeInRelease{0000/00/00}% -%<latexrelease> {\set@curr@file}{Quote file names}% +%<latexrelease> {\quote@name}{Quote file names}% %<latexrelease> %<latexrelease>\let\quote@name\@undefined %<latexrelease>\let\quote@@name\@undefined %<latexrelease>\let\unquote@name\@undefined -%<latexrelease>\let\set@curr@file\@undefined %<latexrelease> %<latexrelease>\let\IfFileExists@\@undefined %<latexrelease> @@ -873,25 +1164,14 @@ % % % \begin{macro}{\InputIfFileExists} -% \changes{v0.9b} -% {1993/12/04}{Macro added} -% \changes{v0.9p} -% {1994/01/18}{New Definition} -% \changes{v0.3b}{1994/03/13} -% {Use new cmd \cs{@addtofilelist}} -% Now define |\InputIfFileExists| to input |#1| if it seems to exist. -% Immediately prior to the input, |#2| is executed. -% If the file |#1| does not exist, execute `|#3|'. -% \changes{v1.0t}{1995/05/25} -% {(CAR) added \cs{long}} -% \changes{v1.1o}{2019/02/07}{Expand \cs{@filef@und} before executing -% second argument (github/109)} -% \changes{v1.2b}{2019/08/27}{Make command robust} -% \begin{macrocode} -%</2ekernel> -%<latexrelease>\IncludeInRelease{2019/10/01}% -%<latexrelease> {\InputIfFileExists}{Don't lose the file name}% -%<*2ekernel|latexrelease> +% +% Now define |\InputIfFileExists| to input |#1| if it seems to exist. +% Immediately prior to the input, |#2| is executed. +% If the file |#1| does not exist, execute `|#3|'. +% +% This here is a temporary definition for the kernel. The real one +% comes somewhat later in the file \texttt{ltfilehook.dtx}. +% % \begin{macrocode} \DeclareRobustCommand \InputIfFileExists[2]{% \IfFileExists{#1}% @@ -908,25 +1188,23 @@ % Swap two arguments and return them unbraced (like % \cs{@firstoftwo} etc). % \begin{macrocode} +%</2ekernel> +%<*2ekernel|latexrelease> +%<latexrelease>\IncludeInRelease{2019/10/01}% +%<latexrelease> {\@swaptwoargs}{Don't lose the file name}% \long\def\@swaptwoargs#1#2{#2#1} % \end{macrocode} -% \end{macro} -% % % \begin{macrocode} %</2ekernel|latexrelease> %<latexrelease>\EndIncludeInRelease %<latexrelease>\IncludeInRelease{0000/00/00}% -%<latexrelease> {\InputIfFileExists}{Don't lose the file name}% -%<latexrelease>\long\def \InputIfFileExists#1#2{% -%<latexrelease> \IfFileExists{#1}% -%<latexrelease> {#2\@addtofilelist{#1}\@@input \@filef@und}} -%<latexrelease> +%<latexrelease> {\@swaptwoargs}{Don't lose the file name}% %<latexrelease>\let\@swaptwoargs\@undefined %<latexrelease>\EndIncludeInRelease %<*2ekernel> % \end{macrocode} -% +% \end{macro} % % % \begin{macro}{\input} @@ -943,20 +1221,51 @@ % Define |\@iinput| (i.e., |\input|) in terms of % |\InputIfIfileExists|. % \changes{v0.9b}{1993/12/04}{Macro reimplemented} +% +% Changes to \cs{@iinput}: adapt to the changes to +% \cs{@missingfileerror}. % \begin{macrocode} %</2ekernel> %<*2ekernel|latexrelease> -%<latexrelease>\IncludeInRelease{2019/10/01}% -%<latexrelease> {\@iinput}{Quote file names}% +%<latexrelease>\IncludeInRelease{2020/10/01}% +%<latexrelease> {\@iinput}{Change in file error handling}% \def\@iinput#1{% \InputIfFileExists{#1}{}% {\filename@parse\@curr@file \edef\reserved@a{\noexpand\@missingfileerror {\filename@area\filename@base}% {\ifx\filename@ext\relax tex\else\filename@ext\fi}}% +% \end{macrocode} +% This line now just sets \cs[no-index]{@missingfile@\meta{part}}: +% \begin{macrocode} + \reserved@a +% \end{macrocode} +% Now here we have to use it. The file here is guaranteed to exist, +% because \cs{@missingfileerror} ensures so, but we have to use +% \cs{InputIfFileExists} because it executes the file hooks. +% \begin{macrocode} + \edef\reserved@a{\noexpand\@iinput{% + \@missingfile@area\@missingfile@base.\@missingfile@ext}}% \reserved@a}} %</2ekernel|latexrelease> %<latexrelease>\EndIncludeInRelease +% \end{macrocode} +% +% \begin{macrocode} +%<latexrelease>\IncludeInRelease{2019/10/01}% +%<latexrelease> {\@iinput}{Quote file names}% +%<latexrelease> +%<latexrelease>\def\@iinput#1{% +%<latexrelease> \InputIfFileExists{#1}{}% +%<latexrelease> {\filename@parse\@curr@file +%<latexrelease> \edef\reserved@a{\noexpand\@missingfileerror +%<latexrelease> {\filename@area\filename@base}% +%<latexrelease> {\ifx\filename@ext\relax tex\else\filename@ext\fi}}% +%<latexrelease> \reserved@a}} +%<latexrelease>\EndIncludeInRelease +% \end{macrocode} +% +% \begin{macrocode} %<latexrelease>\IncludeInRelease{0000/00/00}% %<latexrelease> {\@iinput}{Quote file names}% %<latexrelease>\def\@iinput#1{% @@ -1001,6 +1310,11 @@ % \end{macrocode} % \end{macro} % +% +% +% +% +% % \begin{macro}{\@missingfileerror} % This `error' command avoids \TeX's primitive missing file loop. % @@ -1018,7 +1332,16 @@ % {Move here from ltclass} % \changes{v1.0w}{1995/10/06} % {Autoload error} +% +% Changes to \cs{@missingfileerror}: rather than trying to input the +% file by force, now \cs{@missingfileerror} just returns three +% \cs[no-index]{@missingfile@\meta{part}} and the caller macro is +% responsible for doing the right thing with it. % \begin{macrocode} +%</2ekernel> +%<*2ekernel|latexrelease> +%<latexrelease>\IncludeInRelease{2020/10/01}% +%<latexrelease> {\@missingfileerror}{Do not load missing file immediately}% \gdef\@missingfileerror#1#2{% \typeout{^^J! LaTeX Error: File `#1.#2' not found.^^J^^J% Type X to quit or <RETURN> to proceed,^^J% @@ -1027,20 +1350,74 @@ {\endlinechar\m@ne \global\read\m@ne to\@gtempa}% \ifx\@gtempa\@empty +% \end{macrocode} +% If the user answers with \meta{return}, fallback to the |.tex| file +% (previously it did nothing). +% \begin{macrocode} + \let\@missingfile@area\@empty + \let\@missingfile@base\@empty + \def\@missingfile@ext{tex}% \else - \def\reserved@a{x}\ifx\reserved@a\@gtempa\batchmode\@@end\fi - \def\reserved@a{X}\ifx\reserved@a\@gtempa\batchmode\@@end\fi +% \end{macrocode} +% Use \cs{batchmode}\cs{read}|-1 to |\meta{tl} to end the \TeX{} run, +% same as \pkg{expl3} does (it was \cs{batchmode}\cs{@@end} before). +% \begin{macrocode} + \def\reserved@b{\batchmode\read-1 to \reserved@a}% + \def\reserved@a{x}\ifx\reserved@a\@gtempa\reserved@b\fi + \def\reserved@a{X}\ifx\reserved@a\@gtempa\reserved@b\fi \filename@parse\@gtempa \edef\filename@ext{% \ifx\filename@ext\relax#2\else\filename@ext\fi}% \edef\reserved@a{% - \noexpand\InputIfFileExists +% \end{macrocode} +% Only check \cs{IfFileExists} (it was \cs{InputIfFileExists}). +% \begin{macrocode} + \noexpand\IfFileExists {\filename@area\filename@base.\filename@ext}% - {}% +% \end{macrocode} +% If the file exists, define \cs[no-index]{@missingfile@\meta{part}}. +% \begin{macrocode} + {\def\noexpand\@missingfile@area{\filename@area}% + \def\noexpand\@missingfile@base{\filename@base}% + \def\noexpand\@missingfile@ext {\filename@ext}}% {\noexpand\@missingfileerror {\filename@area\filename@base}{\filename@ext}}}% \reserved@a - \fi} + \fi +} +%</2ekernel|latexrelease> +%<latexrelease>\EndIncludeInRelease +% \end{macrocode} +% +% \begin{macrocode} +%<latexrelease>\IncludeInRelease{0000/00/00}% +%<latexrelease> {\@missingfileerror}{Do not load missing file immediately}% +%<latexrelease> +%<latexrelease>\gdef\@missingfileerror#1#2{% +%<latexrelease> \typeout{^^J! LaTeX Error: File `#1.#2' not found.^^J^^J% +%<latexrelease> Type X to quit or <RETURN> to proceed,^^J% +%<latexrelease> or enter new name. (Default extension: #2)^^J}% +%<latexrelease> \message{Enter file name: }% +%<latexrelease> {\endlinechar\m@ne +%<latexrelease> \global\read\m@ne to\@gtempa}% +%<latexrelease> \ifx\@gtempa\@empty +%<latexrelease> \else +%<latexrelease> \def\reserved@a{x}\ifx\reserved@a\@gtempa\batchmode\@@end\fi +%<latexrelease> \def\reserved@a{X}\ifx\reserved@a\@gtempa\batchmode\@@end\fi +%<latexrelease> \filename@parse\@gtempa +%<latexrelease> \edef\filename@ext{% +%<latexrelease> \ifx\filename@ext\relax#2\else\filename@ext\fi}% +%<latexrelease> \edef\reserved@a{% +%<latexrelease> \noexpand\InputIfFileExists +%<latexrelease> {\filename@area\filename@base.\filename@ext}% +%<latexrelease> {}% +%<latexrelease> {\noexpand\@missingfileerror +%<latexrelease> {\filename@area\filename@base}{\filename@ext}}}% +%<latexrelease> \reserved@a +%<latexrelease> \fi} +%<latexrelease> +%<latexrelease>\EndIncludeInRelease +%<*2ekernel> % \end{macrocode} % \end{macro} % |