updated
[latex2e.git] / base / ltdirchk.dtx
blob62de66d8f1611cec36be847a308fbe3060b597c0
1 % \iffalse meta-comment
3 % Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009
4 % The LaTeX3 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 %    http://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX 
16 % version 2005/12/01 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
30 % \ProvidesFile{ltdirchk.dtx}
31 %              [2001/06/04 v1.0y LaTeX Kernel (System Dependent Parts)]
33 % \iffalse
34 %%% From File: ltdirchk.dtx
36 %<*unstripped>
37 \ifx\documentclass\undefined\let\next\relax\else\def\next{%
38 %</unstripped>
39 %<*driver>
40 % \fi
41 \ProvidesFile{ltdirchk.dtx}
42              [2001/06/04 v1.0y LaTeX Kernel (System Dependent Parts)]
43 % \iffalse
44 \documentclass{ltxdoc}
45 \GetFileInfo{ltdirchk.dtx}
46 \title{\filename\thanks{%
47  this document also includes the source for
48  texsys.cfg and ltxcheck.tex}}
49 \author{David Carlisle}
50 \date{\filedate}
51 \begin{document}
52  \maketitle
53  \DocInput{\filename}
54 \end{document}
55 %</driver>
56 %<*unstripped>
57 }\fi\next
58 %</unstripped>
59 % \fi
61 % \changes{v0.2j}{1994/02/25}
62 %         {Remove need for drv file}
63 % \changes{v0.2k}{1994/03/01}
64 %         {Add unstripped module, 
65 %          so that dircheck.dtx may be used with initex}
66 % \changes{v1.0a}{1994/03/08}
67 %         {Reorganise driver module into `new style'}
68 % \changes{v1.0b}{1994/03/12}
69 %         {Change name from dircheck.dtx}
70 % \changes{v1.0b}{1994/03/12}
71 %         {Minor edits to the typeouts in ltxcheck}
72 % \changes{v1.0d}{1994/03/28}
73 %         {Improve documentation}
74 % \changes{v1.0i}{1994/11/03}
75 %         {Generate an error if latex.ltx not used with clean initex}
76 % \changes{v1.0j}{1994/11/17}
77 %         {\cs{@tempa} to \cs{reserved@a}}
78 % \changes{v1.0r}{1996/06/13}
79 %         {documentation improvements mainly from internal/2174}
80 % \changes{v1.0v}{1997/06/16}
81 %         {documentation improvements mainly from internal/2520}
82 % \changes{v1.0w}{1998/08/17}{(RmS) Documentation improvements.}
84 % \CheckSum{595}
86 % \section{\LaTeX\ System Dependent Initialisations}
88 % \changes{v0.2g}{1994/01/21}
89 %         {Improve documentation, reorganise docstrip module}
91 % This file implements the semi-automatic determination of various
92 % system dependent parts of the initialisation. The actual definitions
93 % may be placed in a file |texsys.cfg|. Thus for operating systems for
94 % which the tests here do not result in acceptable settings, a `hand
95 % written' |texsys.cfg| may be produced.
97 % The macros that must be defined are:
99 % \DescribeMacro{\@currdir}
100 % |\@currdir|\meta{filename}\meta{space} should expand to a form of the
101 % filename that uniquely refers to the `current directory' if this is
102 % possible. (The expansion should also end with a space.) on UNIX,
103 % this is |\def\@currdir{./}|. For more exotic operating systems you may
104 % want to make |\@currdir| a macro with arguments delimited by |.|
105 % and/or \meta{space}. If the operating system has no concept of
106 % directory structure, this macro should be defined to be empty.
109 % \DescribeMacro{\input@path}
110 % If the primitive |\openin| searches the same directories as the
111 % primitive |\input|, then it is possible to tell (using |\ifeof|)
112 % whether a file exists before trying to input it. For systems like
113 % this, |\input@path| should be left undefined.
115 % If |\openin| does not `follow' |\input| then |\input@path| must be
116 % defined to be a list of directories to search for input files. The
117 % format for each directory is as for |\@currdir|, normally just a
118 % prefix is required, but it may be a macro with space-delimited
119 % argument. That is, if \meta{dir} is an entry in the input path, 
120 % \TeX\ will try to load the expansion of 
121 %   \meta{dir}\meta{filename}\meta{space}
123 % So either \meta{dir} should be defined as a macro with argument
124 % delimited by space, or it should just expand to a directory name,
125 % including the final directory separator, so that it may be
126 % concatenated with the \meta{filename}. This means that for UNIX-like
127 % syntax, each \meta{dir} should end with a slash, |/|.
129 % |\input@path| should expand to a list of such directories, each in a
130 % |{}| group. 
132 % \DescribeMacro{\filename@parse}
133 % After a call of the form: |\filename@parse{|\meta{filename}|}|, the
134 % three macros |\filename@area|,|\filename@base|,|\filename@ext| should
135 % be defined to be the `area' (or directory), basename and
136 % extension respectively. If there was no extension specified in
137 % \meta{filename}, |\filename@ext| should be |\let| to |\relax| (so this
138 % case may be tested with |\@ifundefined{filename@ext}| and, perhaps a
139 % default extension substituted).
141 % Normally one would not need to define this macro in |texsys.cfg| as
142 % the automatic tests can supply parsers that work with UNIX and VMS and
143 % Macintosh syntax, as well as a basic parser that will cover many other
144 % cases. However some operating systems may need a `hand produced'
145 % parser in which case it should be defined in this file.
147 % The UNIX parser also works for most MSDOS \TeX\ versions.
148 % Currently if the UNIX, VMS or Macintosh parser is not used,
149 % |\filename@parse| is  defined to always return an empty area, and to
150 % split the argument into  basename and extension at the first `|.|'
151 % that occurs in the name. 
152 % Parsers for other formats may be defined in |texsys.cfg|,
153 % in which case they will be used in preference to the default
154 % definitions.
156 % \DescribeMacro{\@TeXversion}
157 % \changes{v1.0f}{1994/05/23}{Document \cs{@TeXversion}}
158 % |\@TeXversion| is now set automatically by the initialisation tests
159 % in this file. You should not need to set it in |texsys.cfg|, however
160 % the following documentation is left for information. \LaTeX\ does
161 % not set this variable exactly, the automatic tests set it to:\\
162 %  |2| for any version, $v$,  $v < 3.0$\\
163 %  |3| for any version, $v$,  $3.0 \leq v \leq 3.14$\\
164 %  \meta{undefined} otherwise.\\
165 % However these values are accurate enough for \LaTeX\ to take
166 % appropriate action for these old \TeX{}s.
168 % If your \TeX\ is older than version 3.141, then you should define
169 % |\@TeXversion| (using |\def|) to be the version number. If you do not
170 % do this\footnote
171 %       {Actually if your \TeX\ is really old, version~2, \LaTeX\ can
172 %       detect this, and sets \cs{@TeXversion} to~2 if it is not set in
173 %       the \texttt{cfg} file.}
174 %, \LaTeX\ will not work around a bug in old \TeX\ versions, and
175 % so error messages will appear in a very strange format, with |^^J|
176 % appearing instead of line breaks:
177 % \begingroup\catcode`\==\active \def=#1#2{}\hfuzz\maxdimen
178 %\begin{verbatim}
179 %! LaTeX Error: \rubbish undefined.^^J^^JSee the LaTeX manual or LaTeX=
180 % Companion
181 % for explanation.^^JType  H <return>  for immediate help.
182 % ...                                              
183 %                                                  
184 %l.3 \renewcommand{\rubbish}
185 %                           {}
186 %? 
187 %\end{verbatim}
188 % \endgroup\noindent
189 % However if you put |\def\@TeXversion{3.14}| in \texttt{texsys.cfg}
190 % the following format will be used:
191 %\begin{verbatim}
192 %! LaTeX Error: \rubbish undefined.
194 %See the LaTeX manual or LaTeX Companion for explanation.
195 %Type  H <return>  for immediate help.
196 %! .
197 % ...                                              
198 %                                                  
199 %l.3 \renewcommand{\rubbish}
200 %                           {}
201 %? 
202 %\end{verbatim}
203 % Note that this has an extra line |! .| which does not appear in 
204 % error messages that use the default settings with a current version of
205 % \TeX, but this should not cause any confusion we hope.
207 % \StopEventually{}
209 % \section{Initialisation}
210 % As this file is read at a very early stage, some definitions that
211 % are normally considered to be part of the format must be made here.
213 % \subsection{INITEX}
214 % \changes{v0.2i}{1994/01/25}
215 %         {Protect against looping on \cs{@@input} and \cs{@@end}.}
216 %    \begin{macrocode}
217 %<*dircheck>
218 %<*initex>
219 %<initex>\ifnum\catcode`\{=1
220 %<initex>  \errmessage
221 %<initex>  {LaTeX must be made using an initex with no format preloaded}
222 %<initex>\fi
223 \catcode`\{=1
224 \catcode`\}=2
225 \catcode`\#=6
226 \catcode`\^=7
227 \chardef\active=13
228 \catcode`\@=11
229 \countdef\count@=255
230 \let\bgroup={ \let\egroup=}
231 \ifx\@@input\@undefined\let\@@input\input\fi
232 \ifx\@@end\@undefined\let\@@end\end\fi
233 \chardef\@inputcheck0
234 \chardef\sixt@@n=16
235 \newlinechar`\^^J
236 \def\typeout{\immediate\write17}
237 \def\dospecials{\do\ \do\\\do\{\do\}\do\$\do\&%
238   \do\#\do\^\do\_\do\%\do\~}
239 \def\@makeother#1{\catcode`#1=12\relax}
240 \def\space{ }
241 \def\@tempswafalse{\let\if@tempswa\iffalse}
242 \def\@tempswatrue{\let\if@tempswa\iftrue}
243 \let\if@tempswa\iffalse
244 \def\loop#1\repeat{\def\iterate{#1\relax\expandafter\iterate\fi}%
245   \iterate \let\iterate\relax}
246 \let\repeat\fi
247 %</initex>
248 %    \end{macrocode}
250 % \subsection{Some bits of 2e}
251 %    \begin{macrocode}
252 %<*2ekernel>
253 \def\two@digits#1{\ifnum#1<10 0\fi\number#1}
254 \long\def\@firstoftwo#1#2{#1}
255 \long\def\@secondoftwo#1#2{#2}
256 %    \end{macrocode}
257 % \changes{v1.0e}{1994/05/11}
258 %         {Add \cs{ProvidesFile} as used in fd files.}
259 % \changes{v1.0l}{1995/10/17}
260 %         {Modify initex version of \cs{ProvidesFile}}
261 % \changes{v1.0n}{1995/11/01}
262 %         {Initialise \cs{@addtofilelist} to \cs{@gobble}}
263 % This is a special version of |\ProvidesFile| for initex use.
264 % \changes{v1.0x}{2001/05/25}{Explicitly set catcode of 
265 %                              \cs{endlinechar} to 10 (pr/3334)}
266 % \changes{v1.0y}{2001/06/04}{But only if it is a char (pr/3334)}
267 %    \begin{macrocode}
268 \def\ProvidesFile#1{%
269   \begingroup
270     \catcode`\ 10 %
271     \ifnum \endlinechar<256 %
272       \ifnum \endlinechar>\m@ne
273         \catcode\endlinechar 10 %
274       \fi
275     \fi
276     \@makeother\/%
277     \@ifnextchar[{\@providesfile{#1}}{\@providesfile{#1}[]}}
278 \def\@providesfile#1[#2]{%
279     \wlog{File: #1 #2}%
280     \@addtofilelist{ #2}%
281     \endgroup}
282 \long\def\@addtofilelist#1{}
283 %    \end{macrocode}
285 %    \begin{macrocode}
286 \def\@empty{}
287 \catcode`\%=12
288 \def\@percentchar{%}
289 \catcode`\%=14
290 \let\@currdir\@undefined
291 \let\input@path\@undefined
292 \let\filename@parse\@undefined
293 %    \end{macrocode}
294 % \begin{macro}{\strip@prefix}
295 % \changes{v0.2a}{1993/12/13}
296 %         {modified, name changed from \cs{stripmeaning}.}
297 % \changes{v0.2e}{1994/01/19}
298 %         {name changed from \cs{strip@meaning}, to match NFSS.}
299 %    \begin{macrocode}
300 \def\strip@prefix#1>{}
301 %</2ekernel>
302 %    \end{macrocode}
303 % \end{macro}
305 % \section{texsys.cfg}
306 % As mentioned above, any site specific definitions required to describe
307 % the filename handling must be entered into a file |texsys.cfg|. If
308 % |texsys.cfg| can not be located by |\openin|, we write a default
309 % version out. The default version only contains comments, so we do not
310 % actually input the file in that case. The automatic tests later will,
311 % hopefully, correctly define the required macros.
313 % The tricky code below checks to see if |texsys.cfg| exists. If it does
314 % not, all the text in this file between START and END is copied
315 % verbatim to a new file |texsys,cfg|. If |texsys.cfg| is found, then it
316 % is simply input. This is only done when this file is being used
317 % unstripped.  
318 %    \begin{macrocode}
319 %<*docstrip>
320 \openin15=texsys.cfg
321 \ifeof15
322 \typeout{** Writing a default texsys.cfg}
323 \immediate\openout15=texsys.cfg
324 \begingroup
325 \catcode`\^^M\active%
326 \let^^M\par%
327 \def\reserved@a#1^^M{%
328  \def\reserved@b{#1}%
329  \ifx\reserved@b\reserved@c\endgroup\else%
330      \immediate\write15{#1}%
331      \expandafter\reserved@a\fi}%
332 \def\reserved@d#1START^^M{\let\do\@makeother\dospecials\reserved@a}%
333 \catcode`\%=12 
334 \def\reserved@c{%END}
335 \reserved@d
336 %    \end{macrocode}
337 %START
338 % \subsection{texsys.cfg}
340 % This file contains the site specific definitions of the four macros\\
341 % |\@currdir|, |\input@path|, |\filename@parse| and |\@TeXversion|.
343 % As distributed it only contains comments, however this `empty'
344 % file will work on many systems because of the automatic tests built
345 % into |ltdirchk.dtx|. You \emph{are} allowed to edit this file to add
346 % definitions of these macros appropriate to your system.
349 % The macros that must be defined are:
351 % \DescribeMacro{\@currdir}
352 % |\@currdir|\meta{filename}\meta{space} should expand to a form of the
353 % filename that uniquely refers to the `current directory' if this is
354 % possible. (The expansion should also end with a space.) on UNIX,
355 % this is |\def\@currdir{./}|. For more exotic operating systems you may
356 % want to make |\@currdir| a macro with arguments delimited by |.|
357 % and/or \meta{space}. If the operating system has no concept of
358 % directory structure, this macro should be defined to be empty.
361 % \DescribeMacro{\input@path}
362 % If the primitive |\openin| searches the same directories as the
363 % primitive |\input|, then it is possible to tell (using |\ifeof|)
364 % whether a file exists before trying to input it. For systems like
365 % this, |\input@path| should be left undefined.
367 % If |\openin| does not `follow' |\input| then |\input@path| must be
368 % defined to be a list of directories to search for input files. The
369 % format for each directory is as for |\@currdir|, normally just a
370 % prefix is required, but it may be a macro with space-delimited
371 % argument. That is, if \meta{dir} is an entry in the input path, 
372 % \TeX will try to load the expansion of 
374 %   \meta{dir}\meta{filename}\meta{space}
376 % So either \meta{dir} should be defined as a macro with argument
377 % delimited by space, or it should just expand to a directory name,
378 % including the final directory separator, so that it may be
379 % concatenated with the \meta{filename}. This means that for UNIX-like
380 % syntax, each \meta{dir} should end with a slash, |/|. One exception to
381 % this rule is that the input path should \emph{always} contain the
382 % empty directory |{}| as this will allow `full pathnames' to be used,
383 % and the  `current directory' to be searched.
385 % |\input@path| should expand to a list of such directories, each in a
386 % |{}| group. 
389 % \DescribeMacro{\filename@parse}
390 % After a call of the form: |\filename@parse{|\meta{filename}|}|, the
391 % three macros |\filename@area|,|\filename@base|,|\filename@ext| should
392 % be defined to be the `area' (or directory), basename and
393 % extension respectively. If there was no extension specified in
394 % \meta{filename}, |\filename@ext| should be |\let| to |\relax| (so this
395 % case may be tested with |\@ifundefined{filename@ext}| and, perhaps a
396 % default extension substituted).
398 % Normally one would not need to define this macro in |texsys.cfg| as
399 % the automatic tests can supply parsers that work with UNIX and VMS
400 % syntax, as well as a basic parser that willcover many other cases.
401 % However some operating systems may need a `hand produced' parser
402 % in which case it should be defined in this file.
404 % The UNIX parser also works for most MSDOS \TeX\ versions.
405 % Currently if the UNIX or VMS parser is not used, |\filename@parse| is
406 % defined to always return an empty area, and to split the argument into
407 % basename and extension at the first `|.|' that occurs in the name.
408 % Parsers for other formats may be defined in |texsys.cfg|,
409 % in which case they will be used in preference to the default
410 % definitions.
413 % \DescribeMacro{\@TeXversion}
414 % You should not need to set this macro in |texsys.cfg|. \LaTeX\
415 % tests to set this automatically. See the comments in the opening
416 % section of \texttt{ltdirchk.dtx}.
419 % The following sections give examples of definitions which might
420 % work on various systems. These are currently mainly untested as I only
421 % have access to a few systems, all of which do not need this file as
422 % the automatic tests work. All the code is commented out.
424 % \subsection{UNIX (web2c)}
425 % This implementation does make |\openin| and |\input| look in the same
426 % places. Acceptable settings are made by |ltdirchk.dtx|, and so this
427 % file may be empty. The definitions below are therefore just for
428 % information. 
429 %    \begin{macrocode}
430 %\def\@currdir{./}
431 %\let\input@path\@undefined
432 %    \end{macrocode}
434 % \subsection{UNIX (other)}
435 % Apparently some commercial UNIX implementations have different paths
436 % for |\openin| and |\input|. For these one could use definitions like
437 % the following (with whatever directories are used at your site):
438 % note that the directory names should end with |/|.
439 %    \begin{macrocode}
440 % \def\@currdir{./}
441 % \def\input@path{%
442 %   {/usr/local/lib/tex/inputs/distrib/}%
443 %   {/usr/local/lib/tex/inputs/contrib/}%
444 %   {/usr/local/lib/tex/inputs/local/}%
445 % }
446 %    \end{macrocode}
448 % \subsection{MSDOS (emtex)}
449 % This implementation does make |\openin| and |\input| look in the same
450 % places. Acceptable settings are made by |ltdirchk.dtx|, and so this
451 % file may be empty. The definitions below are therefore just for
452 % information. 
453 %    \begin{macrocode}
454 % \def\@currdir{./}
455 % \let\input@path\@undefined
456 %    \end{macrocode}
458 % \subsection{MSDOS (other)}
459 % Some PC implementations have different paths
460 % for |\openin| and |\input|. For these one could use definitions like
461 % the following (with whatever directories are used at your site):
462 % note that the directory names should end with |/|.
463 % This assumes the implementation uses UNIX style |/| as the directory
464 % separator. 
465 %    \begin{macrocode}
466 % \def\@currdir{./}
467 % \def\input@path{%
468 %   {c:/tex/inputs/distrib/}%
469 %   {c:/tex/inputs/contrib/}%
470 %   {c:/tex/inputs/local/}%
471 % }
472 %    \end{macrocode}
474 % \subsection{VMS (DECUS \TeX, PD VMS 3.6)}
475 % This implementation does make |\openin| and |\input| look in the same
476 % places. Acceptable settings are made by |ltdirchk.dtx|, and so this
477 % file may be empty. The definitions below are therefore just for
478 % information. 
479 %    \begin{macrocode}
480 % \def\@currdir{[]}
481 % \let\input@path\@undefined
482 %    \end{macrocode}
484 % \subsection{VMS (???)}
485 % Some VMS implementations have different paths
486 % for |\openin| and |\input|. For these one could use definitions like
487 % the following:
488 %    \begin{macrocode}
489 % \def\@currdir{[]}
490 % \def\input@path{%
491 %   {tex_inputs:}%
492 %   {SOMEDISK:[SOME.TEX.DIRECTORY]}%
493 % }
494 %    \end{macrocode}
496 % \subsection{MACINTOSH (OzTeX 1.6)}
497 % This implementation does make |\openin| and |\input| look in the same
498 % places. Acceptable settings are made by |ltdirchk.dtx|, and so this
499 % file may be empty. The definitions below are therefore just for
500 % information. 
501 %    \begin{macrocode}
502 % \def\@currdir{:}
503 % \let\input@path\@undefined
504 %    \end{macrocode}
506 % \subsection{MACINTOSH (other)}
507 % Some Macintosh implementations have different paths
508 % for |\openin| and |\input|. For these one could use definitions like
509 % the following (with whatever folders are used on your machine):
510 % note that the directory names should end with |:|, and they should
511 % contain {\em no\/} spaces.
512 %    \begin{macrocode}
513 % \def\@currdir{:}
514 % \def\input@path{%
515 %   {Hard-Disk:Applications:TeX:TeX-inputs:}%
516 %   {Hard-Disk:Applications:TeX:My-inputs:}%
517 % }
518 %    \end{macrocode}
520 % \subsection{FAKE EXAMPLE}
521 %  This example is for an operating system that has filenames of the
522 %  form |<area>name|  For maximum compatability with macro sets,
523 %  you want |name.ext| to be mapped to |<ext>name|.
524 %  and |<area>name.ext| to be mapped to |<area.ext>name|.
525 %  |\input| does this mapping automatically, but |\openin| does not, and
526 %  does not look in the same places as |\input|.
527 %  |<>name| is the desired `current directory' syntax.
529 % the following code would possibly work:
530 %    \begin{macrocode}
531 % \def\@dir#1#2 {%
532 %   \@d@r{#1}#2..\@nil}
533 % \def\@d@r#1#2.#3.#4\@nil{%
534 %   <\ifx\@dir#1\@dir\else#1\ifx\@dir#3\@dir\else.\fi\fi#3>#2 }
536 % \def\@currdir{\@dir{}}
537 % \def\input@path{%
538 %   {\@dir{area.one}}%
539 %   {\@dir{area.two}}%
540 % }
541 %    \end{macrocode}
542 %END
543 %    \begin{macrocode}
544 \immediate\closeout15
545 %    \end{macrocode}
546 % If |texsys.cfg| did exist, then input it.
547 %    \begin{macrocode}
548 \else
549 \typeout{** Using the existing texsys.cfg}
550 \closein15
551 \input texsys.cfg
553 %</docstrip>
554 %    \end{macrocode}
556 % If the stripped version of this file is being used (in latex2e.ltx)
557 % then texsys.cfg should be there, so just input it.
558 %    \begin{macrocode}
559 %<dircheck>\input texsys.cfg
560 %    \end{macrocode}
562 % \changes{v0.2f}{1994/01/20}
563 %         {\cs{@copytexsys} and the texsys.new file removed}
565 % \section{Setting \texttt{\cs{@currdir}}}
567 % \begin{macro}{\@currdir}
568 % \begin{macro}{\IfFileExists}
569 % \changes{v0.2e}{1994/01/19}
570 %         {name changed from \cs{test}}
571 % This is a local definition of |\IfFileExists|. It tries to relocate
572 % |texsxys.aux|. If it succeeds, then the |\@currdir| syntax has been
573 % determined. If all the tests fail then |\@currdir| will be set to
574 % |\@empty|, and |ltxcheck| will warn of this when it checks the format.
575 %    \begin{macrocode}
576 \begingroup
577 \count@\time
578 \divide\count@ 60
579 \count2=-\count@
580 \multiply\count2 60
581 \advance\count2 \time
582 %    \end{macrocode}
584 % \begin{macro}{\today}
585 % The current date and time stamp.
586 % \changes{v0.2g}{1994/01/21}
587 %         {Name changed from \cs{stamp}, to save memory}
588 %    \begin{macrocode}
589 \edef\today{%
590   \the\year/\two@digits{\the\month}/\two@digits{\the\day}:%
591     \two@digits{\the\count@}:\two@digits{\the\count2}}
592 %    \end{macrocode}
593 % \end{macro}
595 % Create a file |texsys.aux| (hopefully in the current directory),
596 % then try to locate it again.
597 %    \begin{macrocode}
598 \immediate\openout15=texsys.aux
599 \immediate\write15{\today^^J}
600 \immediate\closeout15 %
601 %    \end{macrocode}
603 % |#1| is the file to try, |#2| is what to do on success, |#3| on
604 % failure.
605 %    \begin{macrocode}
606 \def\IfFileExists#1#2#3{%
607   \openin\@inputcheck#1 %
608   \ifeof\@inputcheck
609      #3\relax
610   \else
611     \read\@inputcheck to \reserved@a
612     \ifx\reserved@a\today
613       \typeout{#1 found}#2\relax
614     \else
615       \typeout{BAD: old file \reserved@a (should be \today)}%
616       #3\relax
617     \fi
618   \fi
619   \closein\@inputcheck}
620 %    \end{macrocode}
622 %    \begin{macrocode}
623 \endlinechar=-1
624 %    \end{macrocode}
626 % If |\@currdir| has not been pre-defined in |texsys.cfg| then test for
627 %  UNIX, VMS and  Oz-\TeX-Mac. syntax.
628 % \changes{v0.2h}{1994/01/24}
629 %         {Stop testing once texsys.aux has been found}
630 %    \begin{macrocode}
631 \ifx\@currdir\@undefined
632   \IfFileExists{./texsys.aux}{\gdef\@currdir{./}}%
633     {\IfFileExists{[]texsys.aux}{\gdef\@currdir{[]}}%
634       {\IfFileExists{:texsys.aux}{\gdef\@currdir{:}}{}}}
635 %    \end{macrocode}
636 % If it is still undefined at this point, all the above tests failed.
637 % Earlier versions interactively prompted for a definition at this
638 % point, but it seems impossible to reliably obtain information from
639 % users at this point in the installation. This version of the file
640 % produces a format with no user-interaction. Later if the format is not
641 % suitable for the system, |texsys.cfg| may be edited and the format
642 % re-made.
643 % \changes{v0.2a}{1993/12/13}
644 %         {Removed interactive prompting for current directory syntax}
645 % \changes{v0.2f}{1994/01/20}
646 %         {\cs{@copytexsys} removed}
647 % \changes{v1.0u}{1996/12/06}
648 %         {*** removed from various messages for GNU Make. 
649 %         internal/2338}
650 %    \begin{macrocode}
651   \ifx\@currdir\@undefined
652     \global\let\@currdir\@empty
653     \typeout{^^J^^J%
654       !! No syntax for the current directory could be found^^J%
655       }%
656   \fi
657 %    \end{macrocode}
658 % Otherwise |\@currdir| was defined in |texsys.cfg|. In this case check
659 % that the syntax specified works on this system. (In case a complete
660 % \LaTeX\  system has been copied from  one system to another.) If the
661 % test fails, give up. The installer should remove or correct the
662 % offending |texsys.cfg| and try again. 
663 %    \begin{macrocode}
664 \else
665   \IfFileExists{\@currdir texsys.aux}{}{%
666     \edef\reserved@a{\errhelp{%
667       texsys.cfg specifies the current directory syntax to be^^J%
668       \meaning\@currdir^^J%
669       but this does not work on this system.^^J%
670       Remove texsys.cfg and restart.}}\reserved@a
671     \errmessage{Bad texsys.cfg file: \noexpand\@currdir}\@@end}
672 %    \end{macrocode}
673 % The version of |\@currdir| in |texsys.cfg| looks OK.
674 %    \begin{macrocode}
676 %    \end{macrocode}
677 % \changes{v0.2d}{1994/01/14}
678 %         {Close the texsys.aux output stream}
679 %    \begin{macrocode}
680 \immediate\closeout15 %  
681 \endgroup
682 %    \end{macrocode}
684 %    \begin{macrocode}
685 \typeout{^^J^^J%
686          \noexpand\@currdir set to: 
687            \expandafter\strip@prefix\meaning\@currdir.^^J%
688          }
689 %    \end{macrocode}
690 % \end{macro}
691 % \end{macro}
694 % \changes{v0.2a}{1993/12/13}
695 %         {on the `docstrip' pass, do not check openin path}
696 %   
697 % Stop here if the file is being used unstripped.
698 %    \begin{macrocode}
699 %<*docstrip>
700 \relax\endinput
701 %</docstrip>
702 %    \end{macrocode}
704 % \section{Setting \texttt{\cs{input@path}}}
706 % Earlier versions of this file attempted to automatically test whether
707 % |\input@path| was required, and interactively prompt for a path if
708 % necessary. This was not found to be very reliable The first-time
709 % installer of \LaTeXe\ can not be expected to have enough information
710 % to supply the correct information to the prompts. Now the interaction
711 % is omitted. After the format is made the installer can attempt to run
712 % the test document |ltxcheck.tex| through \LaTeXe. This will check,
713 % amongst other things, whether |texsys.cfg| will need to be edited and
714 % the format remade.
716 % \begin{macro}{\input@path}
717 % Now set up the |\input@path|.
719 % |\input@path| should either be undefined, or a list of directories as
720 % described in the introduction. 
721 % \changes{v0.2e}{1994/01/19}
722 %         {No longer check that an empty group is in the path}
723 %    \begin{macrocode}
724   \typeout{^^J%
725     Assuming \noexpand\openin and \noexpand\input^^J%
726     \ifx\input@path\@undefined
727 %    \end{macrocode}
728 % |\input@path| has not been pre-defined.
729 %    \begin{macrocode}
730       have the same search path.^^J%
731     \else
732 %    \end{macrocode}
733 % |\input@path| has  been defined in |texsys.cfg|.
734 %    \begin{macrocode}
735       have different  search paths.^^J%
736       LaTeX will use the path specified by \noexpand\input@path:^^J%
737     \fi
738     }
739 %    \end{macrocode}
740 % \end{macro}
742 % \section{Filename Parsing}
744 % \begin{macro}{\filename@parse}
745 % Split a filename into its components.
746 % \changes{v0.2g}{1994/01/21}
747 %         {Minor changes, and add Mac version (:)}
748 %    \begin{macrocode}
749 \ifx\filename@parse\@undefined
750   \def\reserved@a{./}\ifx\@currdir\reserved@a
751 %    \end{macrocode}
752 % |\filename@parse| was not specified in |texsys.cfg|, but |\@currdir|
753 % looks like UNIX\ldots
754 %    \begin{macrocode}
755     \typeout{^^JDefining UNIX/DOS style filename parser.^^J}
756     \def\filename@parse#1{%
757       \let\filename@area\@empty
758       \expandafter\filename@path#1/\\}
759 %    \end{macrocode}
761 % Search for the last |/|. 
762 %    \begin{macrocode}
763     \def\filename@path#1/#2\\{%
764       \ifx\\#2\\%
765          \def\reserved@a{\filename@simple#1.\\}%
766       \else
767          \edef\filename@area{\filename@area#1/}%
768          \def\reserved@a{\filename@path#2\\}%
769       \fi
770       \reserved@a}
771 %    \end{macrocode}
773 %    \begin{macrocode}
774   \else\def\reserved@a{[]}\ifx\@currdir\reserved@a
775 %    \end{macrocode}
776 % |\filename@parse| was not specified in |texsys.cfg|, but |\@currdir|
777 % looks like VMS\ldots
778 %    \begin{macrocode}
779     \typeout{^^JDefining VMS style filename parser.^^J}
780     \def\filename@parse#1{%
781       \let\filename@area\@empty
782       \expandafter\filename@path#1]\\}
783 %    \end{macrocode}
785 % Search for the last |]|.
786 %    \begin{macrocode}
787     \def\filename@path#1]#2\\{%
788       \ifx\\#2\\%
789          \def\reserved@a{\filename@simple#1.\\}%
790       \else
791          \edef\filename@area{\filename@area#1]}%
792          \def\reserved@a{\filename@path#2\\}%
793       \fi
794       \reserved@a}
795 %    \end{macrocode}
797 %    \begin{macrocode}
798   \else\def\reserved@a{:}\ifx\@currdir\reserved@a
799 %    \end{macrocode}
800 % |\filename@parse| was not specified in |texsys.cfg|, but |\@currdir|
801 % looks like Macintosh\ldots
802 %    \begin{macrocode}
803     \typeout{^^JDefining Mac style filename parser.^^J}
804     \def\filename@parse#1{%
805       \let\filename@area\@empty
806       \expandafter\filename@path#1:\\}
807 %    \end{macrocode}
809 % Search for the last |:|.
810 % \changes{v1.0g}{1994/05/25}
811 %         {Mac parser had " typo for :}
812 %    \begin{macrocode}
813     \def\filename@path#1:#2\\{%
814       \ifx\\#2\\%
815          \def\reserved@a{\filename@simple#1.\\}%
816       \else
817          \edef\filename@area{\filename@area#1:}%
818          \def\reserved@a{\filename@path#2\\}%
819       \fi
820       \reserved@a}
821 %    \end{macrocode}
823 %    \begin{macrocode}
824   \else
825 %    \end{macrocode}
826 % |\filename@parse| was not specified in |texsys.cfg|.
827 % So just make a simple parser that always sets |\filename@area| to
828 % empty. 
829 %    \begin{macrocode}
830     \typeout{^^JDefining generic filename parser.^^J}
831     \def\filename@parse#1{%
832       \let\filename@area\@empty
833       \expandafter\filename@simple#1.\\}
834   \fi\fi\fi
835 %    \end{macrocode}
837 % |\filename@simple| is used by all three versions.
838 % Finally we can split off the extension.
839 %    \begin{macrocode}
840   \def\filename@simple#1.#2\\{%
841     \ifx\\#2\\%
842        \let\filename@ext\relax
843     \else
844        \edef\filename@ext{\filename@dot#2\\}%
845     \fi
846     \edef\filename@base{#1}}
847 %    \end{macrocode}
849 % Remove a final dot, added earlier.
850 %    \begin{macrocode}
851   \def\filename@dot#1.\\{#1}
852 %    \end{macrocode}
854 %    \begin{macrocode}
855 \else
856 %    \end{macrocode}
857 % Otherwise, |\filename@parse| was specified in |texsys.cfg|.
858 %    \begin{macrocode}
859   \typeout{^^J^^J%
860     \noexpand\filename@parse was defined in texsys.cfg:^^J%
861     \expandafter\strip@prefix\meaning\filename@parse.^^J%
862     }
864 %    \end{macrocode}
865 % \end{macro}
867 % \section{\TeX\ Versions}
869 % \begin{macro}{\@TeXversion}
870 % \TeX\ versions older than than 3.141 require |\@TeXversion| to be
871 % set. This can be determined automatically due to a trick suggested
872 % by Bernd Raichle. (Actually this will not always get the correct
873 % version number, eg \TeX3.14 would be detected as \TeX3, but \LaTeX\
874 % only needs to take account of \TeX's older than 3, or between 3 and
875 % 3.14.
876 % \changes{v1.0h}{1994/10/11}
877 %         {Check for TeX3.14}
878 %    \begin{macrocode}
879 \ifx\@TeXversion\@undefined
880   \ifx\@undefined\inputlineno
881     \def\@TeXversion{2}
882   \else
883    {\catcode`\^^J=\active
884      \def\reserved@a#1#2\@@{\if#1\string^3\fi}
885      \edef\reserved@a{\expandafter\reserved@a\string^^J\@@}
886      \ifx\reserved@a\@empty\else\gdef\@TeXversion{3}\fi}
887   \fi
889 %    \end{macrocode}
890 % \end{macro}
892 %    \begin{macrocode}
893 %</dircheck>
894 %    \end{macrocode}
896 % \section{ltxcheck.tex}
897 % After the format has been made, and article.cls moved with the
898 % other files to the `standard input directory' as specified in
899 % |install.txt|, the format may be checked by running the file
900 % |ltxcheck.tex|. 
901 % \changes{v0.2f}{1994/01/20}
902 %         {Modify all of ltxcheck}
903 % \changes{v1.0h}{1994/10/11}
904 %         {Modify all of ltxcheck again}
905 % \changes{v1.0t}{1996/09/25}
906 %         {Move ltxcheck to separate file}
910 % \Finale