Debian Codegraph @

texmf-dist/source/latex/base/ltfiles.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 1993-2025
4 % The LaTeX Project and any individual authors listed elsewhere
5 % in this file.
6 %
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
9 %
10 % It may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either version 1.3c
12 % of this license or (at your option) any later version.
13 % The latest version of this license is in
14 % https://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2008 or later.
17 %
18 % This file has the LPPL maintenance status "maintained".
19 %
20 % The list of all files belonging to the LaTeX base distribution is
21 % given in the file `manifest.txt'. See also `legal.txt' for additional
22 % information.
23 %
24 % The list of derived (unpacked) files belonging to the distribution
25 % and covered by LPPL is defined by the unpacking scripts (with
26 % extension .ins) which are part of the distribution.
27 %
28 % \fi
29 %
30 % \iffalse
31 %%% From File: ltfiles.dtx
32 %<*driver>
33 % \fi
34 \ProvidesFile{ltfiles.dtx}
35 [2025/05/22 v1.2w LaTeX Kernel (File Handling)]
36 % \iffalse
37 \documentclass{ltxdoc}
38 \GetFileInfo{ltfiles.dtx}
39 \title{\filename}
40 \date{\filedate}
41 \author{%
42 Johannes Braams\and
43 David Carlisle\and
44 Alan Jeffrey\and
45 Leslie Lamport\and
46 Frank Mittelbach\and
47 Chris Rowley\and
48 Rainer Sch\"opf}
49
50 \providecommand\pkg[1]{\texttt{#1}}
51
52 \providecommand\InternalDetectionOff{}
53 \providecommand\InternalDetectionOn{}
54
55 \begin{document}
56 \MaintainedByLaTeXTeam{latex}
57 \maketitle
58 \DocInput{\filename}
59 \end{document}
60 %</driver>
61 % \fi
62 %
63 % \providecommand\hook[1]{\texttt{#1}}
64 %
65 %
66 % \changes{v1.0h}{1994/05/21}{Use new error commands}
67 % \changes{v1.0n}{1994/11/17}
68 % {\cs{@tempa} to \cs{reserved@a}}
69 % \changes{v1.0u}{1995/07/13}{Updates to docu}
70 % \changes{v1.1m}{2015/02/21}
71 % {Removed autoload support}
72 % \changes{v1.2i}{2020/08/21}{Integration of new hook management interface}
73 %
74 % \section{File Handling}
75 %
76 % The following user commands are defined in this part:
77 %
78 % \DescribeMacro{\document} (ie |\begin{document}|)\\
79 % Reads in the .AUX files and |\catcode|'s |@| to 12.
80 %
81 % \DescribeMacro{\nofiles}\\
82 % Suppresses all file output by setting |\@filesw| false.
83 %
84 % \DescribeMacro{\includeonly}\marg{NAME1, ... ,NAMEn}\\
85 % Causes only parts NAME1, ... ,NAMEn to be read by
86 % their |\include| commands. Works by setting \@partsw true
87 % and setting |\@partlist| to NAME1, ... ,NAMEn.
88 %
89 % \DescribeMacro{\include}\marg{NAME}\\
90 % Does an |\input| NAME unless |\@partsw| is true and
91 % NAME is not in |\@partlist|. If |\@filesw| is true, then
92 % it directs .AUX output to NAME.AUX, including a
93 % checkpoint at the end.
94 %
95 % \DescribeMacro{\input}\marg{NAME}\\
96 % The same as TeX's |\input|, except it allows optional
97 % braces around the file name. In \LaTeXe, it also avoids
98 % the primitive `missing file' error, if the file can not be
99 % found.
100 %
101 % \DescribeMacro{\IfFileExists}\marg{NAME}\marg{then}\marg{else}\\
102 % If the file exists on the system, execute \emph{then} otherwise
103 % execute \emph{else}.
104 %
105 % \DescribeMacro{\InputIfFileExists}\marg{NAME}\marg{then}\marg{else}\\
106 % If the file exists on the system, execute \emph{then} and input
107 % \emph{NAME} otherwise execute \emph{else}.
108 %
109 % \MaybeStop{}
110 %
111 % \changes{v1.0a}{1994/03/07}{Initial version, split from latex.dtx}
112 % \changes{v1.0a}{1994/03/07}{Long lines wrapped to 72 columns}
113 %
114 % \begin{oldcomments}
115 %
116 % \begin{macrocode}
117 %<*2ekernel>
118 \message{files,}
119 % \end{macrocode}
120 %
121 % VARIABLES, SWITCHES AND INTERNAL COMMANDS:
122 % \@mainaux : Output file number for main .AUX file.
123 % \@partaux : Output file number for current part's .AUX file.
124 % \@auxout : Either \@mainout or \@partout, depending on
125 % which .AUX file output goes to.
126 % \@input{foo} : If file foo exists, then \input's it,
127 % otherwise types a warning message.
128 % @filesw : Switch -- set false if no .AUX, .TOC, .IDX etc
129 % files are to be written
130 % @partsw : Set true by a \includeonly command.
131 % \@partlist : Set to the argument of the \includeonly command.
132 %
133 % \cp@FOO : The checkpoint for \include'd file FOO.TEX, written
134 % by \@writeckpt at the end of file FOO.AUX
135 %
136 %
137 % \includeonly{FILELIST} ==
138 % BEGIN
139 % \@partsw := T
140 % \@partlist := FILELIST
141 % END
142 %
143 % \include{FILE} ==
144 % BEGIN
145 % \clearpage
146 % if \@filesw = T
147 % then \immediate\write\@mainaux{\string\@input{FILE.AUX}}
148 % fi
149 % if \@partsw = T
150 % then \@tempswa := F
151 % \reserved@b == FILE
152 % for \reserved@a := \@partlist
153 % do if eval(\reserved@a) = eval(\reserved@b)
154 % then \@tempswa := T fi
155 % od
156 % fi
157 %
158 % if \@tempswa = T
159 % then \@auxout := \@partaux
160 % if \@filesw = T
161 % then \immediate\openout\@partaux{FILE.AUX}
162 % \immediate\write\@partaux{\relax}
163 % fi
164 % \@input{FILE.TEX}
165 % \clearpage
166 % \@writeckpt{FILE}
167 % if @filesw then \closeout \@partaux fi
168 % \@auxout := \@mainaux
169 % else \cp@FILE
170 % fi
171 % END
172 %
173 % \@writeckpt{FILE} ==
174 % BEGIN
175 % if \@filesw = T
176 % \immediate\write on file \@partaux:
177 % \@setckpt{FILE}{ %% }
178 % for \reserved@a := \cl@@ckpt
179 % do \immediate\write on file \@partaux:
180 % \global\string\setcounter
181 % {eval(\reserved@a)}{eval(\c@eval(\reserved@a))}
182 % od %% {
183 % \immediate\write on file \@partaux: }
184 % fi
185 % END
186 %
187 % \@setckpt{FILE}{LIST} ==
188 % BEGIN
189 % G \cp@FILE := LIST
190 % END
191 %
192 % INITIALIZATION
193 % \@tempswa := T
194 %
195 % \end{oldcomments}
196 %
197 %
198 % \begin{macro}{\@mainaux}
199 % \begin{macro}{\@partaux}
200 % \begin{macrocode}
201 \newwrite\@mainaux
202 \newwrite\@partaux
203 % \end{macrocode}
204 % \end{macro}
205 % \end{macro}
206 %
207 % \begin{macro}{\if@filesw}
208 % \begin{macro}{\if@partsw}
209 % \begin{macrocode}
210 \newif\if@filesw \@fileswtrue
211 \newif\if@partsw \@partswfalse
212 % \end{macrocode}
213 % \end{macro}
214 % \end{macro}
215 %
216 % \begin{macro}{\@clubpenalty}
217 % This stores the current normal (non-infinite) value of
218 % \cs{clubpenalty}; it should therefore be reset whenever the
219 % normal value is changed (as in the bibliography in the standard
220 % styles).
221 % \changes{v1.1h}{1996/10/05}{Added setting its value}
222 % \begin{macrocode}
223 \newcount\@clubpenalty
224 \@clubpenalty \clubpenalty
225 % \end{macrocode}
226 % \end{macro}
227 %
228 % \begin{macro}{\document}
229 % \changes{v0.9e}{1993/12/09}{Hook added}
230 % \begin{macrocode}
231 %</2ekernel>
232 %<latexrelease>\IncludeInRelease{2020/10/01}%
233 %<latexrelease> {\document}{Added hook to load l3backend code}%
234 %<*2ekernel|latexrelease>
235 \def\document{%
236 % \end{macrocode}
237 % We do cancel the grouping as part of the \cs{begin} handling
238 % (this is now done inside \cs{begin} instead) so that the
239 % \hook{env/\meta{env}/begin} hook is not hidden inside \cs{begingroup}
240 % \texttt{...} \cs{endgroup}.
241 % \begin{macrocode}
242 % \endgroup
243 % \end{macrocode}
244 %
245 % \begin{macrocode}
246 \UseOneTimeHook{begindocument/before}%
247 \@kernel@after@begindocument@before
248 % \end{macrocode}
249 %
250 % Added hook to load \textsf{l3backend} code:
251 % \changes{v1.2h}{2020/06/05}{Added hook to load \textsf{l3backend} code}
252 % \begin{macrocode}
253 \@expl@sys@load@backend@@
254 \ifx\@unusedoptionlist\@empty\else
255 \@latex@warning@no@line{Unused global option(s):^^J%
256 \@spaces[\@unusedoptionlist]}%
257 \fi
258 \@colht\textheight
259 \@colroom\textheight \vsize\textheight
260 \columnwidth\textwidth
261 \@clubpenalty\clubpenalty
262 \if@twocolumn
263 \advance\columnwidth -\columnsep
264 \divide\columnwidth\tw@ \hsize\columnwidth \@firstcolumntrue
265 \fi
266 \hsize\columnwidth \linewidth\hsize
267 \begingroup\@floatplacement\@dblfloatplacement
268 \makeatletter\let\@writefile\@gobbletwo
269 % \end{macrocode}
270 % \changes{v1.1a}{1995/10/24}
271 % {Removed multiplelabels switch}
272 % \begin{macrocode}
273 \global \let \@multiplelabels \relax
274 \@input{\jobname.aux}%
275 \endgroup
276 \if@filesw
277 \immediate\openout\@mainaux\jobname.aux
278 \immediate\write\@mainaux{\relax}%
279 \fi
280 % \end{macrocode}
281 %
282 % Dateline 1991/03/26: FMi added |\process@table| to support NFSS;
283 % This will also work with old lfonts if no other style defines
284 % |\process@table|. The following line forces the initialization of
285 % the math fonts.
286 % \begin{macrocode}
287 \process@table
288 \let\glb@currsize\@empty % Force math initialization.
289 % \end{macrocode}
290 % \changes{v0.9t}{1994/01/31}
291 % {set \cs{@normalsize} or \cs{normalsize} if necessary}
292 % \changes{v1.0d}{1994/03/28}
293 % {(DPC) remove \cs{@normalsize check}}
294 % \changes{v1.0d}{1994/03/28}
295 % {(DPC) Use \cs{normalsize} not \cs{@normalsize}}
296 % \changes{v1.0g}{1994/05/13}{Added execution of \cs{every@size}}
297 % \changes{v1.0m}{1994/11/07}{Renamed \cs{every@size} to
298 % \cs{every@math@size}.}
299 % \changes{v1.0q}{1995/04/25}
300 % {Removed execution of \cs{every@size} latex/1407}
301 % \begin{macrocode}
302 \normalsize
303 \everypar{}%
304 % \end{macrocode}
305 %
306 % So that punctuation in headings is not disturbed by verbatim
307 % or other local changes to the space factor codes, save the document
308 % default here. This will be locally reset by the output routine.
309 % For special cases a class may want to define |\normalsfcodes|
310 % directly, in case that definition will be used.
311 % (This is an old bug, problem existed in \LaTeX2.0x and plain \TeX.)
312 % \changes{v1.1k}{1997/04/14}
313 % {Set the document space factor defaults. latex/2404}
314 % \begin{macrocode}
315 \ifx\normalsfcodes\@empty
316 \ifnum\sfcode`\.=\@m
317 \let\normalsfcodes\frenchspacing
318 \else
319 \let\normalsfcodes\nonfrenchspacing
320 \fi
321 \fi
322 % \end{macrocode}
323 % For similar reasons also save the default language, this will be reset
324 % locally in the output routine. In particular it allows hyphenation
325 % in the page head even if the page break happens in verbatim.
326 % If this has already been set by a package, set to the value of |\language|
327 % at this point.
328 % \changes{v1.1n}{2017/03/10}{Save language default}
329 % \begin{macrocode}
330 \ifx\document@default@language\m@ne
331 \chardef\document@default@language\language
332 \fi
333 % \end{macrocode}
334 %
335 % Way back in 1991 (08/26) FMi \& RmS set the |@noskipsec| switch
336 % to true in the preamble and to false here.
337 % This was done to trap lists and related text in the preamble but it
338 % does not catch everything; hence Change 1.1g was introduced.
339 % \begin{macrocode}
340 \@noskipsecfalse
341 % \end{macrocode}
342 % \changes{v1.1a}{1995/10/24}
343 % {Removed refundefined switch}
344 % \begin{macrocode}
345 \let \@refundefined \relax
346 % \end{macrocode}
347 % Just before disabling the preamble commands we execute the begin
348 % document hook which contains any code contributed by
349 % |\AtBeginDocument|. Also disable the gathering of the file list,
350 % if no |\listfiles| has been issued. |\AtBeginDocument| is redefined
351 % at this point so that and such commands that get into the hook do
352 % not chase their tail\ldots
353 % \changes{v1.1e}{1996/04/24}
354 % {(DPC) Reset \cs{AtBeginDocument} eg for latex/1297}
355 % \begin{macrocode}
356 \@kernel@before@begindocument
357 \UseOneTimeHook{begindocument}%
358 \@kernel@after@begindocument
359 % \end{macrocode}
360 %
361 % Most of the following assignments will be done globally in case
362 % the user adds something like |\begin{multicols}| to the document
363 % hook, i.e. starts are group in |\begin{document}|.
364 % \changes{v1.0r}{1995/04/27}
365 % {Added \cs{global} to support groups in hook}
366 % \changes{v1.0c}{1994/03/16}
367 % {(DPC) directly add file list settings}
368 % \changes{v1.0v}{1995/08/16}{set \cs{topskip} globally}
369 % \changes{v1.0v}{1995/08/16}{set \cs{@maxdepth}}
370 %
371 % \changes{v1.0s}{1995/05/25}
372 % {Added check for \cs{topskip} zero}
373 % \changes{v1.0t}{1995/05/25}
374 % {Corrected typo}
375 % Since a value of exactly 0pt for \cs{topskip} causes
376 % \cs{twocolumn[]} to misbehave, we add this check, hoping
377 % that it will not cause any problems elsewhere.
378 % \begin{macrocode}
379 \ifdim\topskip<1sp\global\topskip 1sp\relax\fi
380 \global\@maxdepth\maxdepth
381 \global\let\@begindocumenthook\@undefined
382 \ifx\@listfiles\@undefined
383 \global\let\@filelist\relax
384 \global\let\@addtofilelist\@gobble
385 \fi
386 % \end{macrocode}
387 % At the very end we disable all preamble commands. This has to
388 % happen after the begin document hooks was executed so that this
389 % hook can still use such commands.
390 % \changes{v0.9o}{1994/01/15}
391 % {move \cs{@preamblecmds} after document hook}
392 % \changes{v1.0v}{1995/08/16}{set \cs{do} globally}
393 % \begin{macrocode}
394 \gdef\do##1{\global\let ##1\@notprerr}%
395 \@preamblecmds
396 % \end{macrocode}
397 % The next line saves tokens and also allows |\@nodocument| to be
398 % used directly to trap preamble errors.
399 % \changes{v1.1g}{1996/09/29}{Added disabling of \cs{@nodocument}}
400 % \begin{macrocode}
401 \global\let \@nodocument \relax
402 % \end{macrocode}
403 % The next line is a pure safety measure in case a do list is ever
404 % expanded at the wrong place. In addition it will save a few
405 % tokens to get rid of the above definition.
406 % \begin{macrocode}
407 \global\let\do\noexpand
408 % \end{macrocode}
409 %
410 % \begin{macrocode}
411 \UseOneTimeHook{begindocument/end}%
412 % \end{macrocode}
413 % \changes{v1.1c}{1995/12/05}{\cs{ignorespaces} added for latex/1933}
414 % Use of the hook might mean that we are already in
415 % horizontal mode, so ignore the space after |\begin{document}|.
416 % \begin{macrocode}
417 \ignorespaces}
418 % \end{macrocode}
419 %
420 % Provide a global definition for \cs{do} as well, so that it is
421 % already defined in the preamble and not late as
422 % \verb=\begin{document}= overwriting some definition given by the
423 % unsuspecting user in the preamble.
424 % \changes{v1.2s}{2023/01/05}{\cs{do} now with default definition in
425 % the kernel (gh/975)}
426 % \begin{macrocode}
427 \let\do\noexpand
428 % \end{macrocode}
429 %
430 % The \hook{begindocument} hook already existed in the kernel since
431 % 1994 under the name \cs{atbegindocumenthook} the
432 % additional ones are originally from the \pkg{etoolbox}
433 % package under the names \cs{@endpreamblehook} \cs{afterpreamble}.
434 % \begin{macrocode}
435 \NewHook{begindocument}
436 \NewHook{begindocument/before}
437 \NewHook{begindocument/end}
438 % \end{macrocode}
439
440
441
442 % \begin{macro}{\@kernel@after@begindocument@before,
443 % \@kernel@before@begindocument,
444 % \@kernel@after@begindocument}
445 %
446 % Above we used two kernel only hooks to be run after the public
447 % \hook{begindocument/before} and after \hook{begindocument}
448 % hooks.
449 %
450 % In \cs{@kernel@after@begindocument@before} we already place one
451 % action: drop the fast execution code for the
452 % \hook{env/document/begin} hook. That hook marks the end of the
453 % preamble and should therefore only be run once. In a normal
454 % document that is anyway the case (so the code would just sit
455 % there taking up space afterwards, which these days is rather
456 % harmless), however, in more complicated scenarios where several
457 % full documents are combined to a single document it might get
458 % applied several times with harmful effects. We therefore
459 % explicitly drop it at this point. the coding is somewhat obscure
460 % due to the name of the macro which requires constructing.
461 % \InternalDetectionOff
462 % \begin{macrocode}
463 \edef \@kernel@after@begindocument@before {%
464 \let\expandafter\noexpand\csname
465 __hook env/document/begin\endcsname
466 \noexpand\@empty}
467 % \end{macrocode}
468 % \InternalDetectionOn
469 %
470 % These internal hooks are already declared earlier (in
471 % \texttt{ltexpl}) so that other modules could write to them.
472 % \changes{v1.2m}{2021/04/17}{Move \cs{@kernel@before@begindocument} and
473 % \cs{@kernel@after@begindocument} init earlier so that other modules can
474 % write to the hooks}
475 % \begin{macrocode}
476 %\let \@kernel@before@begindocument \@empty
477 %\let \@kernel@after@begindocument \@empty
478 % \end{macrocode}
479 %
480 % \end{macro}
481 %
482
483 %
484 % \begin{macrocode}
485 %</2ekernel|latexrelease>
486 %<latexrelease>\EndIncludeInRelease
487 % \end{macrocode}
488 %
489 % \begin{macrocode}
490 %<latexrelease>\IncludeInRelease{2017/04/15}%
491 %<latexrelease> {\document}{Save language for hyphenation}%
492 %<latexrelease>
493 %<latexrelease>\def\document{\endgroup
494 %<latexrelease> \ifx\@unusedoptionlist\@empty\else
495 %<latexrelease> \@latex@warning@no@line{Unused global option(s):^^J%
496 %<latexrelease> \@spaces[\@unusedoptionlist]}%
497 %<latexrelease> \fi
498 %<latexrelease> \@colht\textheight
499 %<latexrelease> \@colroom\textheight \vsize\textheight
500 %<latexrelease> \columnwidth\textwidth
501 %<latexrelease> \@clubpenalty\clubpenalty
502 %<latexrelease> \if@twocolumn
503 %<latexrelease> \advance\columnwidth -\columnsep
504 %<latexrelease> \divide\columnwidth\tw@ \hsize\columnwidth \@firstcolumntrue
505 %<latexrelease> \fi
506 %<latexrelease> \hsize\columnwidth \linewidth\hsize
507 %<latexrelease> \begingroup\@floatplacement\@dblfloatplacement
508 %<latexrelease> \makeatletter\let\@writefile\@gobbletwo
509 %<latexrelease> \global \let \@multiplelabels \relax
510 %<latexrelease> \@input{\jobname.aux}%
511 %<latexrelease> \endgroup
512 %<latexrelease> \if@filesw
513 %<latexrelease> \immediate\openout\@mainaux\jobname.aux
514 %<latexrelease> \immediate\write\@mainaux{\relax}%
515 %<latexrelease> \fi
516 %<latexrelease> \process@table
517 %<latexrelease> \let\glb@currsize\@empty % Force math initialization.
518 %<latexrelease> \normalsize
519 %<latexrelease> \everypar{}%
520 %<latexrelease> \ifx\normalsfcodes\@empty
521 %<latexrelease> \ifnum\sfcode`\.=\@m
522 %<latexrelease> \let\normalsfcodes\frenchspacing
523 %<latexrelease> \else
524 %<latexrelease> \let\normalsfcodes\nonfrenchspacing
525 %<latexrelease> \fi
526 %<latexrelease> \fi
527 %<latexrelease> \ifx\document@default@language\m@ne
528 %<latexrelease> \chardef\document@default@language\language
529 %<latexrelease> \fi
530 %<latexrelease> \@noskipsecfalse
531 %<latexrelease> \let \@refundefined \relax
532 %<latexrelease> \let\AtBeginDocument\@firstofone
533 %<latexrelease> \@begindocumenthook
534 %<latexrelease> \ifdim\topskip<1sp\global\topskip 1sp\relax\fi
535 %<latexrelease> \global\@maxdepth\maxdepth
536 %<latexrelease> \global\let\@begindocumenthook\@undefined
537 %<latexrelease> \ifx\@listfiles\@undefined
538 %<latexrelease> \global\let\@filelist\relax
539 %<latexrelease> \global\let\@addtofilelist\@gobble
540 %<latexrelease> \fi
541 %<latexrelease> \gdef\do##1{\global\let ##1\@notprerr}%
542 %<latexrelease> \@preamblecmds
543 %<latexrelease> \global\let \@nodocument \relax
544 %<latexrelease> \global\let\do\noexpand
545 %<latexrelease> \ignorespaces}
546 %<latexrelease>\EndIncludeInRelease
547 %<latexrelease>
548 %<latexrelease>\IncludeInRelease{0000/00/00}%
549 %<latexrelease> {\document}{Save language for hyphenation}
550 %<latexrelease>\def\document{\endgroup
551 %<latexrelease> \ifx\@unusedoptionlist\@empty\else
552 %<latexrelease> \@latex@warning@no@line{Unused global option(s):^^J%
553 %<latexrelease> \@spaces[\@unusedoptionlist]}%
554 %<latexrelease> \fi
555 %<latexrelease> \@colht\textheight
556 %<latexrelease> \@colroom\textheight \vsize\textheight
557 %<latexrelease> \columnwidth\textwidth
558 %<latexrelease> \@clubpenalty\clubpenalty
559 %<latexrelease> \if@twocolumn
560 %<latexrelease> \advance\columnwidth -\columnsep
561 %<latexrelease> \divide\columnwidth\tw@ \hsize\columnwidth
562 %<latexrelease> \@firstcolumntrue
563 %<latexrelease> \fi
564 %<latexrelease> \hsize\columnwidth \linewidth\hsize
565 %<latexrelease> \begingroup\@floatplacement\@dblfloatplacement
566 %<latexrelease> \makeatletter\let\@writefile\@gobbletwo
567 %<latexrelease> \global \let \@multiplelabels \relax
568 %<latexrelease> \@input{\jobname.aux}%
569 %<latexrelease> \endgroup
570 %<latexrelease> \if@filesw
571 %<latexrelease> \immediate\openout\@mainaux\jobname.aux
572 %<latexrelease> \immediate\write\@mainaux{\relax}%
573 %<latexrelease> \fi
574 %<latexrelease> \process@table
575 %<latexrelease> \let\glb@currsize\@empty
576 %<latexrelease> \normalsize
577 %<latexrelease> \everypar{}%
578 %<latexrelease> \ifx\normalsfcodes\@empty
579 %<latexrelease> \ifnum\sfcode`\.=\@m
580 %<latexrelease> \let\normalsfcodes\frenchspacing
581 %<latexrelease> \else
582 %<latexrelease> \let\normalsfcodes\nonfrenchspacing
583 %<latexrelease> \fi
584 %<latexrelease> \fi
585 %<latexrelease> \@noskipsecfalse
586 %<latexrelease> \let \@refundefined \relax
587 %<latexrelease> \let\AtBeginDocument\@firstofone
588 %<latexrelease> \@begindocumenthook
589 %<latexrelease> \ifdim\topskip<1sp\global\topskip 1sp\relax\fi
590 %<latexrelease> \global\@maxdepth\maxdepth
591 %<latexrelease> \global\let\@begindocumenthook\@undefined
592 %<latexrelease> \ifx\@listfiles\@undefined
593 %<latexrelease> \global\let\@filelist\relax
594 %<latexrelease> \global\let\@addtofilelist\@gobble
595 %<latexrelease> \fi
596 %<latexrelease> \gdef\do##1{\global\let ##1\@notprerr}%
597 %<latexrelease> \@preamblecmds
598 %<latexrelease> \global\let \@nodocument \relax
599 %<latexrelease> \global\let\do\noexpand
600 %<latexrelease> \ignorespaces}
601 %<latexrelease>\EndIncludeInRelease
602 %<*2ekernel>
603 % \end{macrocode}
604 %
605 % \begin{macrocode}
606 \@onlypreamble\document
607 % \end{macrocode}
608 % \end{macro}
609 %
610 % \begin{macro}{\normalsfcodes}
611 % \changes{v1.1k}{1997/04/14}
612 % {Macro added (from patch file) latex/2404}
613 % The setting of |\@empty| is just a flag. This command may be defined
614 % in a class or package file. If it is still |\@empty| at
615 % |\begin{document}| it will be defined to be |\frenchspacing| or
616 % |\nonfrenchspacing|, depending on which of those appears to be in
617 % effect at that point.
618 % \begin{macrocode}
619 \let\normalsfcodes\@empty
620 % \end{macrocode}
621 % \end{macro}
622 %
623 % \begin{macro}{\nofiles}
624 % \changes{v1.0k}{1994/11/04}
625 % {Added setting of \cs{protected@write},
626 % \cs{makeindex} and \cs{makeglossary} to \cs{nofiles}. ASAJ.}
627 % \changes{v1.0o}{1994/11/30}
628 % {There is no \cs{@gobblethree}\ldots}
629 % \changes{v1.0t}{1995/05/25}
630 % {(CAR) added \cs{long}}
631 % \changes{v1.1f}{1996/05/17}
632 % {added \cs{write} to \cs{protected@write} for latex/2146}
633 % Set |\@fileswfalse| which suppresses the places where \LaTeX\ makes
634 % |\immediate| writes. The |\makeindex| and |\makeglossary| are
635 % disabled. |\protected@write| is redefined not to write to the file
636 % specified, but rather to write a blank line to the log file. This
637 % ensures that a \meta{whatsit} node is still created, and so spacing
638 % is not affected by the |\nofiles| command; to ensure this more
639 % generally, the |\if@nobreak| test is needed.
640 % \changes{v1.1i}{1996/11/05}
641 % {Standard \cs{if@nobreak} test added}
642 % \begin{macrocode}
643 \def\nofiles{%
644 \@fileswfalse
645 \typeout{No auxiliary output files.^^J}%
646 \long\def\protected@write##1##2##3%
647 {\write\m@ne{}\if@nobreak\ifvmode\nobreak\fi\fi}%
648 \let\makeindex\relax
649 \let\makeglossary\relax}
650 \@onlypreamble\nofiles
651 % \end{macrocode}
652 % \end{macro}
653 %
654 %
655 % \begin{macro}{\protected@write}
656 % This takes three arguments: an output stream, some initialization
657 % code, and some text to write. It then writes this, with
658 % appropriate handling of |\protect| and |\thepage|.
659 % \changes{v1.0k}{1994/11/04}{Macro added ASAJ.}
660 % \changes{v1.0t}{1995/05/25}{(CAR) added \cs{long}}
661 % \changes{v1.2w}{2025/04/25}{Move \cs{write} outside the group /gh1717}
662 %
663 % \begin{macrocode}
664 %</2ekernel>
665 %<*2ekernel|latexrelease>
666 %<latexrelease>\IncludeInRelease{2025/06/01}%
667 %<latexrelease> {\protected@write}{Allow for immediate write}%
668 \long\def \protected@write#1#2#3{%
669 \begingroup
670 \let\thepage\relax
671 #2%
672 \let\protect\@unexpandable@protect
673 \edef\reserved@a{\endgroup\write#1{#3}}%
674 \reserved@a
675 \if@nobreak\ifvmode\nobreak\fi\fi
676 }
677 %</2ekernel|latexrelease>
678 %<latexrelease>\EndIncludeInRelease
679 % \end{macrocode}
680 %
681 % \begin{macrocode}
682 %<latexrelease>\IncludeInRelease{0000/00/00}%
683 %<latexrelease> {\protected@write}{Allow for immediate write}%
684 %<latexrelease>\long\def \protected@write#1#2#3{%
685 %<latexrelease> \begingroup
686 %<latexrelease> \let\thepage\relax
687 %<latexrelease> #2%
688 %<latexrelease> \let\protect\@unexpandable@protect
689 %<latexrelease> \edef\reserved@a{\write#1{#3}}%
690 %<latexrelease> \reserved@a
691 %<latexrelease> \endgroup
692 %<latexrelease> \if@nobreak\ifvmode\nobreak\fi\fi
693 %<latexrelease>}
694 %<latexrelease>\EndIncludeInRelease
695 %<*2ekernel>
696 % \end{macrocode}
697 % \end{macro}
698 %
699 % \begin{macrocode}
700 \let\@auxout=\@mainaux
701 % \end{macrocode}
702 %
703 %
704 % \begin{macro}{\include,\includeonly}
705 % \changes{v0.9p}{1994/01/18}
706 % {Use \cs{@input@} so include files are listed.}
707 % \changes{v1.0p}{1995/04/22}{Allow blanks in argument}
708 % \changes{v1.2a}{2019/07/01}{Support UTF-8}
709 % \changes{v1.2g}{2020/05/02}{Improved support for spaces in filenames
710 % (gh/217)}
711 %
712 % In the definition of |\include|, |\def\reserved@b| changed to
713 % |\edef\reserved@b| to be consistent with the |\edef| in
714 % |\includeonly|.
715 % (Suggested by Rainer Sch\"opf \& Frank Mittelbach.
716 % Change made 20 Jul 88.)
717 %
718 % Changed definition of |\include| to allow space at end of file name
719 % --- otherwise, typing |\include{foo }| would cause \LaTeX\ to
720 % overwrite |foo.tex|. Change made 24 May 89, suggested by Rainer
721 % Sch\"opf and Frank Mittelbach
722 %
723 % Made |\include| check for being used inside an |\include|'d file, as
724 % this will not work and cause surprising results.
725 % \changes{v1.2g}{2020/05/02}{Get rid of leading and trailing spaces
726 % from the filename (gh/217)}
727 % \changes{v1.2g}{2020-05-02}{Pass the filename to \cs{@include} by
728 % value instead of by reference (gh/217)}
729 %
730 % \begin{macrocode}
731 %</2ekernel>
732 %<*2ekernel|latexrelease>
733 %<latexrelease>\IncludeInRelease{2020/10/01}%
734 %<latexrelease> {\includeonly}{Spaces in file names}%
735 % \end{macrocode}
736 %
737 % \begin{macrocode}
738 \def\include#1{\relax
739 \ifnum\@auxout=\@partaux
740 \@latex@error{\string\include\space cannot be nested}\@eha
741 \else
742 % \end{macrocode}
743 % Here the normalization will add |.tex| for all files, (it uses
744 % the same normalization as the hooks), so we need to remove that
745 % manually. \cs{@strip@tex@ext} does that.
746 % \begin{macrocode}
747 \set@curr@file{#1}%
748 \edef\@curr@file{\@strip@tex@ext\@curr@file}%
749 % \end{macrocode}
750 % For historical reasons \cs{@include} expects an argument
751 % delimited by a space. This is kept (though unnecessary now) to avoid
752 % errors in other packages that use \cs{@include} directly.
753 % \begin{macrocode}
754 \expandafter\@include\expandafter{\@curr@file} % deliberate space
755 \fi}
756 % \end{macrocode}
757 %
758 % Here in \cs{includeonly} we also need to strip |.tex| after
759 % normalization:
760 % \begin{macrocode}
761 \def\includeonly#1{%
762 \@partswtrue
763 % \end{macrocode}
764 % Because the argument to |\includeonly| is a comma-separated list
765 % of filenames where there may be comma's preceding some of the
766 % filenames or trailing them. Therefore we need to take the list
767 % apart, remove the unwanted spaces while leaving the spaces
768 % \emph{in} the filenames intact.
769 % \begin{macrocode}
770 \let\@partlist\@empty
771 \@for\reserved@a:=#1 \do
772 {%
773 \expandafter\set@curr@file\expandafter{\reserved@a}%
774 \ifx\@partlist\@empty
775 \edef\@partlist{\@strip@tex@ext\@curr@file}%
776 \else
777 \edef\@partlist{\@partlist,\@strip@tex@ext\@curr@file}%
778 \fi
779 }%
780 }
781 \@onlypreamble\includeonly
782 % \end{macrocode}
783 % \end{macro}
784 %
785 % \begin{macro}{\@strip@tex@ext,\@strip@tex@ext@aux}
786 % These macros take a (\cs{detokenize}d file name and remove any
787 % |.tex| extension). Extra care is taken to not remove the string
788 % |.tex| from the middle of a file name: it is only removed if it's
789 % the very last thing in the file name.
790 % \begin{macrocode}
791 \def\reserved@a#1{%
792 \def\@strip@tex@ext##1{%
793 \expandafter\@strip@tex@ext@aux
794 ##1\@nil\@nil
795 #1\@nil\relax\@nnil}
796 \def\@strip@tex@ext@aux##1#1\@nil##2\@nnil{%
797 \ifx\relax##2\@empty
798 \expandafter\@cdr\expandafter\@empty\@cdr{}##1%
799 \else##1\fi}}%
800 \expandafter\reserved@a
801 \expandafter{\detokenize{.tex}}
802 %</2ekernel|latexrelease>
803 % \end{macrocode}
804 % \end{macro}
805 %
806 % \begin{macrocode}
807 %<latexrelease>\EndIncludeInRelease
808 %<latexrelease>\IncludeInRelease{2019/10/01}%
809 %<latexrelease> {\includeonly}{Spaces in file names}%
810 %<latexrelease>
811 %<latexrelease>\def\includeonly#1{%
812 %<latexrelease> \@partswtrue
813 %<latexrelease> \set@curr@file{\zap@space#1 \@empty}%
814 %<latexrelease> \let\@partlist\@curr@file
815 %<latexrelease> }
816 %<latexrelease>
817 %<latexrelease>\def\include#1{\relax
818 %<latexrelease> \ifnum\@auxout=\@partaux
819 %<latexrelease> \@latex@error{\string\include\space cannot be nested}\@eha
820 %<latexrelease> \else
821 %<latexrelease> \set@curr@file{#1 }%
822 %<latexrelease> \expandafter\@include\@curr@file
823 %<latexrelease> \fi}
824 %<latexrelease>
825 %<latexrelease>\let\@strip@tex@ext\@undefined
826 %<latexrelease>\let\@strip@tex@ext@aux\@undefined
827 %<latexrelease>
828 %<latexrelease>\EndIncludeInRelease
829 % \end{macrocode}
830 %
831 % \begin{macrocode}
832 %<latexrelease>\IncludeInRelease{0000/00/00}%
833 %<latexrelease> {\includeonly}{Spaces in file names}%
834 %<latexrelease>\def\includeonly#1{%
835 %<latexrelease> \@partswtrue
836 %<latexrelease> \edef\@partlist{\zap@space#1 \@empty}}
837 %<latexrelease>
838 %<latexrelease>\def\include#1{\relax
839 %<latexrelease> \ifnum\@auxout=\@partaux
840 %<latexrelease> \@latex@error{\string\include\space cannot be nested}\@eha
841 %<latexrelease> \else \@include#1 \fi}
842 %<latexrelease>
843 %<latexrelease>\EndIncludeInRelease
844 %<*2ekernel>
845 % \end{macrocode}
846 %
847 % \begin{macro}{\@include}
848 % \changes{v1.2g}{2020/05/02}{Support spaces in filenames by enclosing
849 % the names of \texttt{.aux}-files in quotes (gh/217)}
850 % \begin{macrocode}
851 %</2ekernel>
852 %<*2ekernel|latexrelease>
853 %<latexrelease>\IncludeInRelease{2022/06/01}%
854 %<latexrelease> {\@include}{Spaces in file names and hooks}%
855 % \end{macrocode}
856 %
857 % \changes{v1.2j}{2020/10/04}{Quotes around the aux file name removed,
858 % they are not needed and upset BibTeX (gh/400)}
859 % \changes{v1.2p}{2021/10/14}{Warn about use in preamble}
860 % \begin{macrocode}
861 \def\@include#1 {%
862 % \end{macrocode}
863 %
864 % \begin{macrocode}
865 \ifx\@nodocument\relax
866 % \end{macrocode}
867 %
868 % \begin{macrocode}
869 \clearpage
870 \if@filesw
871 \immediate\write\@mainaux{\string\@input{#1.aux}}%
872 \fi
873 \@tempswatrue
874 \if@partsw
875 \@tempswafalse
876 \edef\reserved@b{#1}%
877 \@for\reserved@a:=\@partlist\do
878 {\ifx\reserved@a\reserved@b\@tempswatrue\fi}%
879 \fi
880 \if@tempswa
881 \let\@auxout\@partaux
882 \if@filesw
883 \immediate\openout\@partaux "#1.aux"
884 \immediate\write\@partaux{\relax}%
885 \fi
886 % \end{macrocode}
887 % Now before going to the hooks we need to set \cs{CurrentFile}:
888 % \begin{macrocode}
889 %-----------------------------------------
890 \@filehook@set@CurrentFile
891 % \end{macrocode}
892 % Execute the \texttt{before} hooks just after we switched the
893 % \texttt{.aux} file \ldots
894 % \changes{v1.2n}{2021/07/23}{Make include/name/before a one-time hook}
895 % \changes{v1.2o}{2021/08/25}{Standardise generic hook names (gh/648)}
896 % \begin{macrocode}
897 \UseHook{include/before}%
898 \UseOneTimeHook{include/#1/before}%
899 %-----------------------------------------
900 \@input@{#1.tex}%
901 %-----------------------------------------
902 % \end{macrocode}
903 % \ldots{} then \texttt{end} hooks \ldots
904 % \changes{v1.2n}{2021/07/23}{Make include/name/end a one-time hook}
905 % \begin{macrocode}
906 \UseOneTimeHook{include/#1/end}%
907 \UseHook{include/end}%
908 %-----------------------------------------
909 \clearpage
910 %-----------------------------------------
911 % \end{macrocode}
912 % \ldots{} and after the \cs{clearpage} the \texttt{after} hooks
913 % followed by another \cs{clearpage} just in case new material got
914 % added (after all we need to be in well defined state after the
915 % \cs{include}).
916 % \changes{v1.2n}{2021/07/23}{Make include/name/after a one-time hook}
917 % \begin{macrocode}
918 \UseOneTimeHook{include/#1/after}%
919 \UseHook{include/after}%
920 \clearpage
921 %-----------------------------------------
922 \@writeckpt{#1}%
923 \if@filesw
924 \immediate\closeout\@partaux
925 \fi
926 \else
927 % \end{macrocode}
928 % If the file is not included, reset |\deadcycles|, so that a long
929 % list of non-included files does not generate an `Output loop'
930 % error.
931 % \changes{v1.1j}{1997/01/08}{reset \cs{deadcycles} latex/2365}
932 % \begin{macrocode}
933 \deadcycles\z@
934 \@nameuse{cp@#1}%
935 % \end{macrocode}
936 % We also execute a hook in this case, first a general used for
937 % every include file that is exclude and then a specific one that
938 % contains the name of the include file.
939 % \changes{v1.2q}{2022/04/01}{Process some hooks is an include file is bypassed}
940 % \begin{macrocode}
941 %-----------------------------------------
942 \UseHook{include/excluded}%
943 \UseOneTimeHook{include/#1/excluded}%
944 %-----------------------------------------
945 \fi
946 \let\@auxout\@mainaux
947 % \end{macrocode}
948 %
949 % \begin{macrocode}
950 \else
951 \@latex@warning{%
952 \noexpand\include should only be used after \string\begin{document}}%
953 \@input@{#1}%
954 \fi}
955 % \end{macrocode}
956 %
957 % \changes{v1.2o}{2021/08/25}{Declare non-generic include hooks}
958 % Now declare the non-generic \hook{include} hooks used above:
959 % \begin{macrocode}
960 \NewHook{include/before}
961 \NewReversedHook{include/end}
962 \NewReversedHook{include/after}
963 \NewHook{include/excluded}
964 %<latexrelease>\EndIncludeInRelease
965 %</2ekernel|latexrelease>
966 % \end{macrocode}
967 %
968 % \begin{macrocode}
969 %<latexrelease>\IncludeInRelease{2020/10/01}%
970 %<latexrelease> {\@include}{Spaces in file names and hooks}%
971 %<latexrelease>\EndIncludeInRelease
972 %<latexrelease>\def\@include#1 {%
973 %<latexrelease>\ifx\@nodocument\relax
974 %<latexrelease> \clearpage
975 %<latexrelease> \if@filesw
976 %<latexrelease> \immediate\write\@mainaux{\string\@input{#1.aux}}%
977 %<latexrelease> \fi
978 %<latexrelease> \@tempswatrue
979 %<latexrelease> \if@partsw
980 %<latexrelease> \@tempswafalse
981 %<latexrelease> \edef\reserved@b{#1}%
982 %<latexrelease> \@for\reserved@a:=\@partlist\do
983 %<latexrelease> {\ifx\reserved@a\reserved@b\@tempswatrue\fi}%
984 %<latexrelease> \fi
985 %<latexrelease> \if@tempswa
986 %<latexrelease> \let\@auxout\@partaux
987 %<latexrelease> \if@filesw
988 %<latexrelease> \immediate\openout\@partaux "#1.aux"
989 %<latexrelease> \immediate\write\@partaux{\relax}%
990 %<latexrelease> \fi
991 %<latexrelease> \@filehook@set@CurrentFile
992 %<latexrelease> \UseHook{include/before}%
993 %<latexrelease> \UseOneTimeHook{include/#1/before}%
994 %<latexrelease> \@input@{#1.tex}%
995 %<latexrelease> \UseOneTimeHook{include/#1/end}%
996 %<latexrelease> \UseHook{include/end}%
997 %<latexrelease> \clearpage
998 %<latexrelease> \UseOneTimeHook{include/#1/after}%
999 %<latexrelease> \UseHook{include/after}%
1000 %<latexrelease> \clearpage
1001 %<latexrelease> \@writeckpt{#1}%
1002 %<latexrelease> \if@filesw
1003 %<latexrelease> \immediate\closeout\@partaux
1004 %<latexrelease> \fi
1005 %<latexrelease> \else
1006 %<latexrelease> \deadcycles\z@
1007 %<latexrelease> \@nameuse{cp@#1}%
1008 %<latexrelease> \fi
1009 %<latexrelease> \let\@auxout\@mainaux
1010 %<latexrelease>\else
1011 %<latexrelease>\@latex@warning{%
1012 %<latexrelease> \noexpand\include should only be used after \string\begin{document}}%
1013 %<latexrelease>\@input@{#1}%
1014 %<latexrelease>\fi}
1015 %<latexrelease>\NewHook{include/before}
1016 %<latexrelease>\NewReversedHook{include/end}
1017 %<latexrelease>\NewReversedHook{include/after}
1018 % \end{macrocode}
1019 %
1020 % \begin{macrocode}
1021 %<latexrelease>\IncludeInRelease{0000/00/00}%
1022 %<latexrelease> {\@include}{Spaces in file names and hooks}%
1023 %<latexrelease>\def\@include#1 {%
1024 %<latexrelease> \clearpage
1025 %<latexrelease> \if@filesw
1026 %<latexrelease> \immediate\write\@mainaux{\string\@input{#1.aux}}%
1027 %<latexrelease> \fi
1028 %<latexrelease> \@tempswatrue
1029 %<latexrelease> \if@partsw
1030 %<latexrelease> \@tempswafalse
1031 %<latexrelease> \edef\reserved@b{#1}%
1032 %<latexrelease> \@for\reserved@a:=\@partlist\do
1033 %<latexrelease> {\ifx\reserved@a\reserved@b\@tempswatrue\fi}%
1034 %<latexrelease> \fi
1035 %<latexrelease> \if@tempswa
1036 %<latexrelease> \let\@auxout\@partaux
1037 %<latexrelease> \if@filesw
1038 %<latexrelease> \immediate\openout\@partaux #1.aux
1039 %<latexrelease> \immediate\write\@partaux{\relax}%
1040 %<latexrelease> \fi
1041 %<latexrelease> \@input@{#1.tex}%
1042 %<latexrelease> \clearpage
1043 %<latexrelease> \@writeckpt{#1}%
1044 %<latexrelease> \if@filesw
1045 %<latexrelease> \immediate\closeout\@partaux
1046 %<latexrelease> \fi
1047 %<latexrelease> \else
1048 %<latexrelease> \deadcycles\z@
1049 %<latexrelease> \@nameuse{cp@#1}%
1050 %<latexrelease> \fi
1051 %<latexrelease> \let\@auxout\@mainaux}
1052 %<latexrelease>
1053 %<latexrelease>\EndIncludeInRelease
1054 %<*2ekernel>
1055 % \end{macrocode}
1056 % \end{macro}
1057 %
1058 % \begin{macro}{\@writeckpt}
1059 % \begin{macrocode}
1060 \def\@writeckpt#1{%
1061 \if@filesw
1062 \immediate\write\@partaux{\string\@setckpt{#1}\@charlb}%
1063 {\let\@elt\@wckptelt \cl@@ckpt}%
1064 \immediate\write\@partaux{\@charrb}%
1065 \fi}
1066 % \end{macrocode}
1067 % \end{macro}
1068 %
1069 % \begin{macro}{\@wckptelt}
1070 % \begin{macrocode}
1071 \def\@wckptelt#1{%
1072 \immediate\write\@partaux{%
1073 \string\setcounter{#1}{\the\@nameuse{c@#1}}}}
1074 % \end{macrocode}
1075 % \end{macro}
1076 %
1077 % \begin{macro}{\@setckpt}
1078 % RmS 93/08/31: introduced |\@setckpt|
1079 % \begin{macrocode}
1080 \def\@setckpt#1{\global\@namedef{cp@#1}}
1081 % \end{macrocode}
1082 % \end{macro}
1083 %
1084 % \begin{macro}{\@charlb}
1085 % \begin{macro}{\@charrb}
1086 % The following defines |\@charlb| and |\@charrb| to be |{| and |}|,
1087 % respectively with |\catcode| 11.
1088 % \begin{macrocode}
1089 {\catcode`[=1 \catcode`]=2
1090 \catcode`{=11 \catcode`}=11
1091 \gdef\@charlb[{]
1092 \gdef\@charrb[}]
1093 ]% }brace matching
1094 % \end{macrocode}
1095 % \end{macro}
1096 % \end{macro}
1097 %
1098 %
1099 % \subsection{Safe Input Macros}
1100 %
1101 %
1102 %
1103 % \begin{macro}{\@curr@file}
1104 % \begin{macro}{\set@curr@file}
1105 %
1106 % File name handling is done by generating a csname from the
1107 % provided file name (which means that UTF-8 octets gets turned into
1108 % strings as this is what happens if they appear in a csname due to
1109 % the code in \texttt{utf8.def}). By setting \cs{escapchar} to
1110 % \texttt{-1} we ensure that we don't get a backslash in front. As a
1111 % result we end up with all characters as catcode 12 (plus
1112 % spaces). We then sometimes add quotes around the construct
1113 % (removing any existing inner quotes). Sometimes we only remove the
1114 % quotes if they have been supplied by the user. There is clearly
1115 % some room for improvement.
1116 %
1117 % A side effect of the new code is that we will see quotes around
1118 % file name displays where there haven't been any before.
1119 %
1120 % For compatibility with existing code using |{abc}.tex| or
1121 % |{one.two}.png|, an initial brace group is discarded before
1122 % expansion and |\string| is applied. The content of the brace
1123 % group is discarded. This means that a leading space will be lost
1124 % unless protected (by |{ }| or |" "| or |\space|) but filenames
1125 % with a space are hopefully rare.
1126 %
1127 % \changes{v1.2a}{2019/07/01}{Support UTF-8}
1128 % \changes{v1.2c}{2019/10/11}{Remove one brace group}
1129 % \changes{v1.2d}{2019/10/26}{remove quotes}
1130 % \changes{v1.2e}{2019/11/09}{expand and \cs{string} before removing quotes}
1131 %
1132 % The definition below is from 2019 and only used during kernel
1133 % bootstrapping, later on in \texttt{ltfilehook.dtx} it will get
1134 % overwritten.
1135 % \begin{macrocode}
1136 \def\set@curr@file#1{%
1137 \begingroup
1138 \escapechar\m@ne
1139 \xdef\@curr@file{%
1140 \expandafter\expandafter\expandafter\unquote@name
1141 \expandafter\expandafter\expandafter{%
1142 \expandafter\string
1143 \csname\@firstofone#1\@empty\endcsname}}%
1144 \endgroup
1145 }
1146 % \end{macrocode}
1147 % \end{macro}
1148 % \end{macro}
1149 %
1150 %
1151 % \begin{macro}{\quote@name}
1152 % \begin{macro}{\quote@@name}
1153 % \begin{macro}{\unquote@name}
1154 % Quoting spaces
1155 %\begin{verbatim}
1156 % a b c -> "a b c"
1157 % "a b c" -> "a b c"
1158 % a" "b" "c -> "a b c"
1159 % -> ""
1160 %\end{verbatim}
1161 % \begin{macrocode}
1162 %</2ekernel>
1163 %<*2ekernel|latexrelease>
1164 %<latexrelease>\IncludeInRelease{2019/10/01}%
1165 %<latexrelease> {\quote@name}{Quote file names}%
1166 \def\quote@name#1{"\quote@@name#1\@gobble""}
1167 \def\quote@@name#1"{#1\quote@@name}
1168 % \end{macrocode}
1169 % and removing quotes \ldots
1170 % \begin{macrocode}
1171 \def\unquote@name#1{\quote@@name#1\@gobble"}
1172 % \end{macrocode}
1173 % \end{macro}
1174 % \end{macro}
1175 % \end{macro}
1176 %
1177 %
1178 %
1179 % \begin{macro}{\IfFileExists}
1180 %
1181 % \changes{v1.2a}{2019/07/01}{Support UTF-8}
1182 % \changes{v1.2b}{2019/08/27}{Make command robust}
1183 % \changes{v1.2d}{2019/10/26}{don't quote name}
1184 % \begin{macrocode}
1185 \DeclareRobustCommand\IfFileExists[1]{%
1186 \set@curr@file{#1}%
1187 \expandafter\IfFileExists@\expandafter{\@curr@file}}
1188 % \end{macrocode}
1189 % \end{macro}
1190 %
1191 % \begin{macrocode}
1192 %</2ekernel|latexrelease>
1193 %<latexrelease>\EndIncludeInRelease
1194 %<latexrelease>\IncludeInRelease{0000/00/00}%
1195 %<latexrelease> {\quote@name}{Quote file names}%
1196 %<latexrelease>
1197 %<latexrelease>\let\quote@name\@undefined
1198 %<latexrelease>\let\quote@@name\@undefined
1199 %<latexrelease>\let\unquote@name\@undefined
1200 %<latexrelease>
1201 %<latexrelease>\long\def \IfFileExists#1#2#3{%
1202 %<latexrelease> \openin\@inputcheck#1 %
1203 %<latexrelease> \ifeof\@inputcheck
1204 %<latexrelease> \ifx\input@path\@undefined
1205 %<latexrelease> \def\reserved@a{#3}%
1206 %<latexrelease> \else
1207 %<latexrelease> \def\reserved@a{\@iffileonpath{#1}{#2}{#3}}%
1208 %<latexrelease> \fi
1209 %<latexrelease> \else
1210 %<latexrelease> \closein\@inputcheck
1211 %<latexrelease> \edef\@filef@und{#1 }%
1212 %<latexrelease> \def\reserved@a{#2}%
1213 %<latexrelease> \fi
1214 %<latexrelease> \reserved@a}
1215 %<latexrelease>
1216 %<latexrelease>\EndIncludeInRelease
1217 %<*2ekernel>
1218 % \end{macrocode}
1219 %
1220 %
1221 %
1222 % \begin{macro}{\IfFileExists@}
1223 % \changes{v0.9b}{1993/12/04}{Macro added}
1224 % \changes{v0.9p}{1994/01/18}{New Definition}
1225 % \changes{v1.0t}{1995/05/25}{(CAR) added \cs{long}}
1226 % \changes{v1.2d}{2019/10/26}{quote on openin}
1227 % \changes{v1.2k}{2021/03/12}{Allow unbalanced conditionals (gh/530)}
1228 % \changes{v1.2t}{2023/05/15}{Use \pkg{expl3} file existence test}
1229 % \begin{macro}{\IfFileExists@@}
1230 % \changes{v1.2t}{2023/05/15}{Macro added}
1231 % \changes{v1.2u}{2023/06/16}{Support piped input}
1232 % Argument |#1| is |\@curr@file| so catcode 12 string with no quotes.
1233 %
1234 % The original definition picked up arguments |#2| and |#3| in a
1235 % way that they couldn't contain unbalanced conditionals. A better
1236 % implementation would have been not to pick up the arguments at
1237 % all but instead use the usual \cs{@firstoftwo} and
1238 % \cs{secondoftwo}. However, that changes how |#| is interpreted
1239 % and so we can't do that nowadays without invalidating a lot of
1240 % code. Therefore the somewhat curious construction near the end.
1241 %
1242 % Earlier versions used |\openin| here, but this led to two
1243 % code paths, one in \pkg{expl3} and one here. To avoid that,
1244 % and as the \pkg{expl3} approach works by expansion, we use
1245 % that here. As we need the file name to include the path,
1246 % the actual \pkg{expl3} function used is not the file existence
1247 % test!
1248 % \begin{macrocode}
1249 %</2ekernel>
1250 %<*2ekernel|latexrelease>
1251 %<latexrelease>\IncludeInRelease{2023/06/01}%
1252 %<latexrelease> {\IfFileExists@}{IfFileExists}
1253 \long\def \IfFileExists@#1#2#3{%
1254 \edef\@filef@und{\IfFileExists@@{#1}}%
1255 % \end{macrocode}
1256 % The \pkg{expl3} function regards an empty argument as nothing at all,
1257 % but the \LaTeXe{} convention is that this is equal to the special
1258 % \texttt{.tex} file.
1259 % \begin{macrocode}
1260 \ifx\@filef@und\@empty
1261 \if\relax\detokenize{#1}\relax
1262 \let\reserved@a\@firstoftwo
1263 \def\@filef@und{".tex" }%
1264 \else
1265 \let\reserved@a\@secondoftwo
1266 \fi
1267 \else
1268 \let\reserved@a\@firstoftwo
1269 \edef\@filef@und{"\@filef@und" }%
1270 \fi
1271 % \end{macrocode}
1272 % This is just there so that any |#| inside |#2| or |#3| needs
1273 % doubling (as that was the case in the past).
1274 % \begin{macrocode}
1275 \expandafter\def\expandafter\reserved@a
1276 \expandafter{\reserved@a{#2}{#3}}%
1277 \reserved@a}
1278 % \end{macrocode}
1279 % Pipes are not really files, but at the document level they are supported.
1280 % To quickly trim of any leading spaces, we use a blank test and \cs{use:n}
1281 % rather than \cs{\detokenize{tl_trim_spaces:n}} for speed as we don't care about the end
1282 % of the input.
1283 % \begin{macrocode}
1284 \ExplSyntaxOn
1285 \cs_new:Npn \IfFileExists@@ #1
1286 {
1287 \tl_if_blank:nF {#1}
1288 {
1289 \tl_if_head_eq_charcode:oNTF { \use:n #1 } |
1290 {#1}
1291 { \file_full_name:n {#1} }
1292 }
1293 }
1294 \cs_generate_variant:Nn \tl_if_head_eq_charcode:nNTF { o }
1295 \ExplSyntaxOff
1296 %</2ekernel|latexrelease>
1297 %<latexrelease>\EndIncludeInRelease
1298 %<latexrelease>\IncludeInRelease{2021/06/01}%
1299 %<latexrelease> {\IfFileExists@}{IfFileExists}
1300 %<latexrelease>
1301 %<latexrelease>\long\def \IfFileExists@#1#2#3{%
1302 %<latexrelease> \openin\@inputcheck"#1" %
1303 %<latexrelease> \ifeof\@inputcheck
1304 %<latexrelease> \ifx\input@path\@undefined
1305 %<latexrelease> \let\reserved@a\@secondoftwo
1306 %<latexrelease> \else
1307 %<latexrelease> \def\reserved@a{\@iffileonpath{#1}}%
1308 %<latexrelease> \fi
1309 %<latexrelease> \else
1310 %<latexrelease> \closein\@inputcheck
1311 %<latexrelease> \edef\@filef@und{"#1" }%
1312 %<latexrelease> \let\reserved@a\@firstoftwo
1313 %<latexrelease> \fi
1314 %<latexrelease> \expandafter\def\expandafter\reserved@a
1315 %<latexrelease> \expandafter{\reserved@a{#2}{#3}}%
1316 %<latexrelease>\reserved@a}
1317 %<latexrelease>\let\IfFileExists@@\@undefined
1318 %<latexrelease>\EndIncludeInRelease
1319 %<latexrelease>
1320 %<latexrelease>\IncludeInRelease{2019/10/01}%
1321 %<latexrelease> {\IfFileExists@}{IfFileExists}
1322 %<latexrelease>
1323 %<latexrelease>\long\def \IfFileExists@#1#2#3{%
1324 %<latexrelease> \openin\@inputcheck"#1" %
1325 %<latexrelease> \ifeof\@inputcheck
1326 %<latexrelease> \ifx\input@path\@undefined
1327 %<latexrelease> \def\reserved@a{#3}%
1328 %<latexrelease> \else
1329 %<latexrelease> \def\reserved@a{\@iffileonpath{#1}{#2}{#3}}%
1330 %<latexrelease> \fi
1331 %<latexrelease> \else
1332 %<latexrelease> \closein\@inputcheck
1333 %<latexrelease> \edef\@filef@und{"#1" }%
1334 %<latexrelease> \def\reserved@a{#2}%
1335 %<latexrelease> \fi
1336 %<latexrelease> \reserved@a}
1337 %<latexrelease>\EndIncludeInRelease
1338 %<latexrelease>\IncludeInRelease{0000/00/00}%
1339 %<latexrelease> {\IfFileExists@}{IfFileExists}
1340 %<latexrelease>
1341 %<latexrelease>\let\IfFileExists@\@undefined
1342 %<latexrelease>
1343 %<latexrelease>
1344 %<latexrelease>\EndIncludeInRelease
1345 %<*2ekernel>
1346 % \end{macrocode}
1347 % \end{macro}
1348 % \end{macro}
1349 %
1350 %
1351 %
1352 %
1353 %
1354 %
1355 % \begin{macro}{\@iffileonpath}
1356 % If the file is not found by |\openin|, and |\input@path| is defined,
1357 % look in all the directories specified in |\input@path|.
1358 % \changes{v0.9p}{1994/01/18}{Macro added}
1359 % \changes{v1.0f}{1994/05/02}
1360 % {\cs{@break@loop} renamed to \cs{@break@tfor}}
1361 % \changes{v1.0t}{1995/05/25}
1362 % {(CAR) added \cs{long}}
1363 % \changes{v1.1d}{1996/01/10}
1364 % {Change argument handling to not require doubled hash. latex/2024}
1365 % \changes{v1.2d}{2019/10/26}{quote on openin}%
1366 % \changes{v1.2f}{2019/11/11}{make \cs{@filef@und} match quoting used on \cs{openin}}%
1367 % \begin{macrocode}
1368 %</2ekernel>
1369 %<*2ekernel|latexrelease>
1370 %<latexrelease>\IncludeInRelease{2019/10/01}%
1371 %<latexrelease> {\@iffileonpath}{Quote file names}
1372 \long\def\@iffileonpath#1{%
1373 \let\reserved@a\@secondoftwo
1374 \expandafter\@tfor\expandafter\reserved@b\expandafter
1375 :\expandafter=\input@path\do{%
1376 \openin\@inputcheck\expandafter\quote@name\expandafter{\reserved@b#1} %
1377 \ifeof\@inputcheck\else
1378 \edef\@filef@und{\expandafter\quote@name\expandafter{\reserved@b#1} }%
1379 \let\reserved@a\@firstoftwo%
1380 \closein\@inputcheck
1381 \@break@tfor
1382 \fi}%
1383 \reserved@a}
1384 % \end{macrocode}
1385 % \end{macro}
1386 %
1387 % \begin{macrocode}
1388 %</2ekernel|latexrelease>
1389 %<latexrelease>\EndIncludeInRelease
1390 %<latexrelease>\IncludeInRelease{0000/00/00}%
1391 %<latexrelease> {\quote@name}{Quote file names}
1392 %<latexrelease>
1393 %<latexrelease>\long\def\@iffileonpath#1{%
1394 %<latexrelease> \let\reserved@a\@secondoftwo
1395 %<latexrelease> \expandafter\@tfor\expandafter\reserved@b\expandafter
1396 %<latexrelease> :\expandafter=\input@path\do{%
1397 %<latexrelease> \openin\@inputcheck\reserved@b#1 %
1398 %<latexrelease> \ifeof\@inputcheck\else
1399 %<latexrelease> \edef\@filef@und{\reserved@b#1 }%
1400 %<latexrelease> \let\reserved@a\@firstoftwo%
1401 %<latexrelease> \closein\@inputcheck
1402 %<latexrelease> \@break@tfor
1403 %<latexrelease> \fi}%
1404 %<latexrelease> \reserved@a}
1405 %<latexrelease>
1406 %<latexrelease>\EndIncludeInRelease
1407 %<*2ekernel>
1408 % \end{macrocode}
1409 %
1410 %
1411 %
1412 %
1413 % \begin{macro}{\InputIfFileExists}
1414 %
1415 % Now define |\InputIfFileExists| to input |#1| if it seems to exist.
1416 % Immediately prior to the input, |#2| is executed.
1417 % If the file |#1| does not exist, execute `|#3|'.
1418 %
1419 % This here is a temporary definition for the kernel. The real one
1420 % comes somewhat later in the file \texttt{ltfilehook.dtx}.
1421 %
1422 % \begin{macrocode}
1423 \DeclareRobustCommand \InputIfFileExists[2]{%
1424 \IfFileExists{#1}%
1425 {%
1426 \expandafter\@swaptwoargs\expandafter
1427 {\@filef@und}{#2\@addtofilelist{#1}\@@input}}}
1428 % \end{macrocode}
1429 % \end{macro}
1430 %
1431 %
1432 % \begin{macro}{\@swaptwoargs}
1433 %
1434 % \changes{v1.1o}{2019/02/07}{Helper macro added}
1435 % Swap two arguments and return them unbraced (like
1436 % \cs{@firstoftwo} etc).
1437 % \begin{macrocode}
1438 %</2ekernel>
1439 %<*2ekernel|latexrelease>
1440 %<latexrelease>\IncludeInRelease{2019/10/01}%
1441 %<latexrelease> {\@swaptwoargs}{Don't lose the file name}%
1442 \long\def\@swaptwoargs#1#2{#2#1}
1443 % \end{macrocode}
1444 %
1445 % \begin{macrocode}
1446 %</2ekernel|latexrelease>
1447 %<latexrelease>\EndIncludeInRelease
1448 %<latexrelease>\IncludeInRelease{0000/00/00}%
1449 %<latexrelease> {\@swaptwoargs}{Don't lose the file name}%
1450 %<latexrelease>\let\@swaptwoargs\@undefined
1451 %<latexrelease>\EndIncludeInRelease
1452 %<*2ekernel>
1453 % \end{macrocode}
1454 % \end{macro}
1455 %
1456 %
1457 % \begin{macro}{\input}
1458 % Input a file: if the argument is given in braces use safe input
1459 % macros, otherwise use \TeX's primitive |\input| command (which is
1460 % called |\@@input| in \LaTeX).
1461 % \changes{v0.9b}{1993/12/04}{Macro reimplemented}
1462 % \begin{macrocode}
1463 \def\input{\@ifnextchar\bgroup\@iinput\@@input}
1464 % \end{macrocode}
1465 % \end{macro}
1466 %
1467 % \begin{macro}{\@iinput}
1468 % Define |\@iinput| (i.e., |\input|) in terms of
1469 % |\InputIfIfileExists|.
1470 % \changes{v0.9b}{1993/12/04}{Macro reimplemented}
1471 %
1472 % Changes to \cs{@iinput}: adapt to the changes to
1473 % \cs{@missingfileerror}.
1474 % \begin{macrocode}
1475 %</2ekernel>
1476 %<*2ekernel|latexrelease>
1477 %<latexrelease>\IncludeInRelease{2020/10/01}%
1478 %<latexrelease> {\@iinput}{Change in file error handling}%
1479 \def\@iinput#1{%
1480 \InputIfFileExists{#1}{}%
1481 {\filename@parse\@curr@file
1482 \edef\reserved@a{\noexpand\@missingfileerror
1483 {\filename@area\filename@base}%
1484 {\ifx\filename@ext\relax tex\else\filename@ext\fi}}%
1485 % \end{macrocode}
1486 % This line now just sets \cs[no-index]{@missingfile@\meta{part}}:
1487 % \begin{macrocode}
1488 \reserved@a
1489 % \end{macrocode}
1490 % Now here we have to use it. The file here is guaranteed to exist,
1491 % because \cs{@missingfileerror} ensures so, but we have to use
1492 % \cs{InputIfFileExists} because it executes the file hooks.
1493 % \begin{macrocode}
1494 \edef\reserved@a{\noexpand\@iinput{%
1495 \@missingfile@area\@missingfile@base.\@missingfile@ext}}%
1496 \reserved@a}}
1497 %</2ekernel|latexrelease>
1498 %<latexrelease>\EndIncludeInRelease
1499 % \end{macrocode}
1500 %
1501 % \begin{macrocode}
1502 %<latexrelease>\IncludeInRelease{2019/10/01}%
1503 %<latexrelease> {\@iinput}{Quote file names}%
1504 %<latexrelease>
1505 %<latexrelease>\def\@iinput#1{%
1506 %<latexrelease> \InputIfFileExists{#1}{}%
1507 %<latexrelease> {\filename@parse\@curr@file
1508 %<latexrelease> \edef\reserved@a{\noexpand\@missingfileerror
1509 %<latexrelease> {\filename@area\filename@base}%
1510 %<latexrelease> {\ifx\filename@ext\relax tex\else\filename@ext\fi}}%
1511 %<latexrelease> \reserved@a}}
1512 %<latexrelease>\EndIncludeInRelease
1513 % \end{macrocode}
1514 %
1515 % \begin{macrocode}
1516 %<latexrelease>\IncludeInRelease{0000/00/00}%
1517 %<latexrelease> {\@iinput}{Quote file names}%
1518 %<latexrelease>\def\@iinput#1{%
1519 %<latexrelease> \InputIfFileExists{#1}{}%
1520 %<latexrelease> {\filename@parse{#1}%
1521 %<latexrelease> \edef\reserved@a{\noexpand\@missingfileerror
1522 %<latexrelease> {\filename@area\filename@base}%
1523 %<latexrelease> {\ifx\filename@ext\relax tex\else\filename@ext\fi}}%
1524 %<latexrelease> \reserved@a}}
1525 %<latexrelease>\EndIncludeInRelease
1526 %<*2ekernel>
1527 % \end{macrocode}
1528 % \end{macro}
1529
1530
1531
1532
1533 %
1534 % \begin{macro}{\@input}
1535 % \changes{v0.9b}{1993/12/04}{Macro reimplemented}
1536 % \changes{v0.9p}{1994/01/18}%
1537 % {do not use a different definition for \cs{input@path}}
1538 % Define |\@input| in terms of |\IfIfileExists|.
1539 % So this is a `safe input' command, but the files input are not
1540 % listed by |\listfiles|.
1541 %
1542 % We don't want |.aux|, |.toc| files etc be listed by |\listfiles|.
1543 % However, something like |.bbl| probably should be listed and thus
1544 % should be implemented not by |\@input|.
1545 % \begin{macrocode}
1546 \def\@input#1{%
1547 \IfFileExists{#1}{\@@input\@filef@und}{\typeout{No file #1.}}}
1548 % \end{macrocode}
1549 % \end{macro}
1550 %
1551 % \begin{macro}{\@input@}
1552 % \changes{v0.9p}{1994/01/18}{Macro added}
1553 % \task{???}{share code with `@input ?}
1554 % Version of |\@input| that does add the file to |\@filelist|.
1555 % \begin{macrocode}
1556 \def\@input@#1{\InputIfFileExists{#1}{}{\typeout{No file #1.}}}
1557 % \end{macrocode}
1558 % \end{macro}
1559 %
1560 %
1561 %
1562 %
1563 %
1564 %
1565 % \begin{macro}{\@missingfileerror}
1566 % This `error' command avoids \TeX's primitive missing file loop.
1567 %
1568 % Missing file error. Prompt for a new filename, offering a default
1569 % extension.
1570 % \changes{LaTeX2e}{1993/11/21}
1571 % {Stop infinite looping on \cs{@er@ext}}
1572 % \changes{LaTeX2e}{1993/11/28}
1573 % {Use filename parser from dircheck}
1574 % \changes{LaTeX2e}{1994/03/15}
1575 % {Quit on x or X just like a real error}
1576 % \changes{LaTeX2e}{1994/05/26}
1577 % {Modify message format}
1578 % \changes{v1.0j}{1994/11/03}
1579 % {Move here from ltclass}
1580 % \changes{v1.0w}{1995/10/06}
1581 % {Autoload error}
1582 %
1583 % Changes to \cs{@missingfileerror}: rather than trying to input the
1584 % file by force, now \cs{@missingfileerror} just returns three
1585 % \cs[no-index]{@missingfile@\meta{part}} and the caller macro is
1586 % responsible for doing the right thing with it.
1587 % \begin{macrocode}
1588 %</2ekernel>
1589 %<*2ekernel|latexrelease>
1590 %<latexrelease>\IncludeInRelease{2020/10/01}%
1591 %<latexrelease> {\@missingfileerror}{Do not load missing file immediately}%
1592 \gdef\@missingfileerror#1#2{%
1593 \typeout{^^J! LaTeX Error: File `#1.#2' not found.^^J^^J%
1594 Type X to quit or <RETURN> to proceed,^^J%
1595 or enter new name. (Default extension: #2)^^J}%
1596 \message{Enter file name: }%
1597 {\endlinechar\m@ne
1598 \global\read\m@ne to\@gtempa}%
1599 \ifx\@gtempa\@empty
1600 % \end{macrocode}
1601 % If the user answers with \meta{return}, fallback to the |.tex| file
1602 % (previously it did nothing).
1603 % \begin{macrocode}
1604 \let\@missingfile@area\@empty
1605 \let\@missingfile@base\@empty
1606 \def\@missingfile@ext{tex}%
1607 \else
1608 % \end{macrocode}
1609 % Use \cs{batchmode}\cs{read}|-1 to |\meta{tl} to end the \TeX{} run,
1610 % same as \pkg{expl3} does (it was \cs{batchmode}\cs{@@end} before).
1611 % \begin{macrocode}
1612 \def\reserved@b{\batchmode\read-1 to \reserved@a}%
1613 \def\reserved@a{x}\ifx\reserved@a\@gtempa\reserved@b\fi
1614 \def\reserved@a{X}\ifx\reserved@a\@gtempa\reserved@b\fi
1615 \filename@parse\@gtempa
1616 \edef\filename@ext{%
1617 \ifx\filename@ext\relax#2\else\filename@ext\fi}%
1618 \edef\reserved@a{%
1619 % \end{macrocode}
1620 % Only check \cs{IfFileExists} (it was \cs{InputIfFileExists}).
1621 % \begin{macrocode}
1622 \noexpand\IfFileExists
1623 {\filename@area\filename@base.\filename@ext}%
1624 % \end{macrocode}
1625 % If the file exists, define \cs[no-index]{@missingfile@\meta{part}}.
1626 % \begin{macrocode}
1627 {\def\noexpand\@missingfile@area{\filename@area}%
1628 \def\noexpand\@missingfile@base{\filename@base}%
1629 \def\noexpand\@missingfile@ext {\filename@ext}}%
1630 {\noexpand\@missingfileerror
1631 {\filename@area\filename@base}{\filename@ext}}}%
1632 \reserved@a
1633 \fi
1634 }
1635 %</2ekernel|latexrelease>
1636 %<latexrelease>\EndIncludeInRelease
1637 % \end{macrocode}
1638 %
1639 % \begin{macrocode}
1640 %<latexrelease>\IncludeInRelease{0000/00/00}%
1641 %<latexrelease> {\@missingfileerror}{Do not load missing file immediately}%
1642 %<latexrelease>
1643 %<latexrelease>\gdef\@missingfileerror#1#2{%
1644 %<latexrelease> \typeout{^^J! LaTeX Error: File `#1.#2' not found.^^J^^J%
1645 %<latexrelease> Type X to quit or <RETURN> to proceed,^^J%
1646 %<latexrelease> or enter new name. (Default extension: #2)^^J}%
1647 %<latexrelease> \message{Enter file name: }%
1648 %<latexrelease> {\endlinechar\m@ne
1649 %<latexrelease> \global\read\m@ne to\@gtempa}%
1650 %<latexrelease> \ifx\@gtempa\@empty
1651 %<latexrelease> \else
1652 %<latexrelease> \def\reserved@a{x}\ifx\reserved@a\@gtempa\batchmode\@@end\fi
1653 %<latexrelease> \def\reserved@a{X}\ifx\reserved@a\@gtempa\batchmode\@@end\fi
1654 %<latexrelease> \filename@parse\@gtempa
1655 %<latexrelease> \edef\filename@ext{%
1656 %<latexrelease> \ifx\filename@ext\relax#2\else\filename@ext\fi}%
1657 %<latexrelease> \edef\reserved@a{%
1658 %<latexrelease> \noexpand\InputIfFileExists
1659 %<latexrelease> {\filename@area\filename@base.\filename@ext}%
1660 %<latexrelease> {}%
1661 %<latexrelease> {\noexpand\@missingfileerror
1662 %<latexrelease> {\filename@area\filename@base}{\filename@ext}}}%
1663 %<latexrelease> \reserved@a
1664 %<latexrelease> \fi}
1665 %<latexrelease>
1666 %<latexrelease>\EndIncludeInRelease
1667 %<*2ekernel>
1668 % \end{macrocode}
1669 % \end{macro}
1670 %
1671 % \begin{macro}{\@obsoletefile}
1672 % For compatibility with \LaTeX~2.09 document styles, we distribute
1673 % files called |article.sty|, |book.sty|, |report.sty|,
1674 % |slides.sty| and |letter.sty|. These use the command
1675 % |\@obsoletefile|, which produces a warning message.
1676 % \changes{v0.9m}{1993/12/20}{Added this command, removed
1677 % @oldfilewarning}
1678 % \changes{v1.0f}{1994/05/02}{Make \cs{@onlypreamble}}
1679 % \begin{macrocode}
1680 \def\@obsoletefile#1#2{%
1681 \@latex@warning@no@line{inputting `#1' instead of obsolete `#2'}}
1682 \@onlypreamble\@obsoletefile
1683 % \end{macrocode}
1684 %
1685 % \subsection{Listing files}
1686 %
1687 % \begin{macro}{\@filelist}
1688 % A list of files input so far. The initial value of |\@gobble| eats
1689 % the comma before the first file name.
1690 % \begin{macrocode}
1691 \let\@filelist\@gobble
1692 % \end{macrocode}
1693 % \end{macro}
1694 %
1695 % \begin{macro}{\@addtofilelist}
1696 % Add to the list of files input so far.
1697 % \changes{LaTeX2e}{1994/03/13}
1698 % {Macro added}
1699 % \changes{LaTeX2e}{1995/10/01}
1700 % {Macro added}
1701 % This `real' definition is only used for `cfg' files during initex.
1702 % An initial definition of |\@gobble| has already been set.
1703 % \begin{macrocode}
1704 %\def\@addtofilelist#1{\xdef\@filelist{\@filelist,#1}}
1705 % \end{macrocode}
1706 % \end{macro}
1707 %
1708 % \begin{macro}{\if@listfiles@hashes}
1709 % \changes{v1.2v}{2023/11/15}{Extend file list information}
1710 % \begin{macro}{\if@listfiles@sizes}
1711 % \changes{v1.2v}{2023/11/15}{Extend file list information}
1712 % \begin{macrocode}
1713 \ExplSyntaxOn
1714 \keys_define:nn { __kernel / listfiles }
1715 {
1716 hashes .legacy_if_set:n = @listfiles@hashes ,
1717 sizes .legacy_if_set:n = @listfiles@sizes
1718 }
1719 \ExplSyntaxOff
1720 % \end{macrocode}
1721 % \end{macro}
1722 % \end{macro}
1723 %
1724 % \begin{macro}{\listfiles}
1725 % A preamble command to cause |\end{document}| to list files input
1726 % from the main file.
1727 % \changes{LaTeX2e}{1993/11/22}
1728 % {Removed checking for \cs{@unknownversion}}
1729 % \changes{LaTeX2e}{1994/01/17}
1730 % {New Version, adds `.tex' if needed, and lines up columns}
1731 % \changes{LaTeX2e}{1994/05/13}
1732 % {Stop \cs{listfiles} being run twice}
1733 % \changes{v1.0i}{1994/10/18}
1734 % {code moved here from ltclass}
1735 % \changes{v1.2v}{2023/11/15}{Extend file list information}
1736 % \begin{macrocode}
1737 \NewDocumentCommand\listfiles{O{}}{%
1738 \SetKeys[__kernel/listfiles]{#1}%
1739 \let\listfiles\relax
1740 \def\@listfiles##1##2##3##4##5##6##7##8##9\@@{%
1741 \def\reserved@d{\\}%
1742 \@tfor\reserved@c:=##1##2##3##4##5##6##7##8\do{%
1743 \ifx\reserved@c\reserved@d
1744 \edef\filename@area{ \filename@area}%
1745 \fi}}%
1746 % \end{macrocode}
1747 %
1748 % \changes{v1.0o}{1994/11/30}
1749 % {Use \cs{@dofilelist}}
1750 % \changes{v1.2r}{2022/05/27}{Try saved version string, if ver@.. is \cs{relax} (gh/825)}
1751 % \begin{macrocode}
1752 \def\@dofilelist{%
1753 \typeout{^^J *File List*}%
1754 \@for\@currname:=\@filelist\do{%
1755 \filename@parse\@currname
1756 \edef\reserved@a{%
1757 \filename@base.%
1758 \ifx\filename@ext\relax tex\else\filename@ext\fi}%
1759 \expandafter\let\expandafter\reserved@b
1760 \csname ver@\reserved@a\endcsname
1761 % \end{macrocode}
1762 % Packages that \cs{relax} their \cs{ver@...} string to allow for
1763 % multiple loading (e.g., \pkg{fontenc}) can use \cs{ver@@...} to
1764 % store the version information instead.
1765 % \begin{macrocode}
1766 \ifx\reserved@b\relax
1767 \expandafter\let\expandafter\reserved@b
1768 \csname ver@@\reserved@a\endcsname
1769 \fi
1770 \expandafter\expandafter\expandafter\@listfiles\expandafter
1771 \filename@area\filename@base\\\\\\\\\\\\\\\\\\\@@
1772 \typeout{%
1773 \filename@area\reserved@a
1774 \ifx\reserved@b\relax\else\@spaces\reserved@b\fi
1775 % \end{macrocode}
1776 % Now we add the additional information if requested.
1777 % \begin{macrocode}
1778 \ifnum0%
1779 \if@listfiles@hashes1\fi
1780 \if@listfiles@sizes1\fi
1781 >0 %
1782 ^^J\@spaces
1783 (%
1784 \if@listfiles@sizes
1785 size \@dofilelist@size\@currname
1786 \if@listfiles@hashes
1787 , %
1788 \fi
1789 \fi
1790 \if@listfiles@hashes
1791 hash \@dofilelist@hash\@currname
1792 \fi
1793 )%
1794 \fi
1795 }}%
1796 \typeout{ ***********^^J}}}
1797 % \end{macrocode}
1798 % \begin{macro}{\@dofilelist@hash}
1799 % \begin{macro}{\@dofilelist@size}
1800 % \begin{macrocode}
1801 \ExplSyntaxOn
1802 \cs_new_eq:NN \@dofilelist@hash \file_mdfive_hash:n
1803 \cs_new_eq:NN \@dofilelist@size \file_size:n
1804 \ExplSyntaxOff
1805 % \end{macrocode}
1806 % \end{macro}
1807 % \end{macro}
1808 %
1809 % \changes{LaTeX2e}{1994/03/13}
1810 % {Reset \cs{@addtofilelist} at begin document}
1811 % \changes{LaTeX2e}{1994/03/16}
1812 % {Move this code directly into \cs{document}}
1813 % The |\@filelist| will be de-activated if |\listfiles| does not
1814 % appear in the preamble. |\begin{document}| contains code equivalent
1815 % to the following:
1816 %\begin{verbatim}
1817 % \AtBeginDocument{%
1818 % \ifx\@listfiles\@undefined
1819 % \let\@filelist\relax
1820 % \let\@addtofilelist\@gobble
1821 % \fi}
1822 %\end{verbatim}
1823 % \begin{macrocode}
1824 \@onlypreamble\listfiles
1825 % \end{macrocode}
1826 % \end{macro}
1827 %
1828 % \begin{macro}{\@dofilelist}
1829 % \changes{v1.0o}{1994/11/30}
1830 % {Macro added}
1831 % \begin{macrocode}
1832 \let\@dofilelist\relax
1833 % \end{macrocode}
1834 % \end{macro}
1835 %
1836 % \begin{macrocode}
1837 %</2ekernel>
1838 % \end{macrocode}
1839 % \end{macro}
1840 %
1841 % \Finale
1842 %