% \iffalse meta-comment
%
% Copyright 1994 the LaTeX3 project and the individual authors.
% All rights reserved. For further copyright information see the file
% legal.txt, and any other copyright indicated in this file.
% 
% This file is part of the LaTeX2e system.
% ----------------------------------------
% 
%  This system is distributed in the hope that it will be useful,
%  but WITHOUT ANY WARRANTY; without even the implied warranty of
%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% 
% 
% IMPORTANT NOTICE:
% 
% For error reports in case of UNCHANGED versions see bugs.txt.
% 
% Please do not request updates from us directly.  Distribution is
% done through Mail-Servers and TeX organizations.
% 
% You are not allowed to change this file.
% 
% You are allowed to distribute this file under the condition that
% it is distributed together with all files mentioned in manifest.txt.
% 
% If you receive only some of these files from someone, complain!
% 
% You are NOT ALLOWED to distribute this file alone.  You are NOT
% ALLOWED to take money for the distribution or use of either this
% file or a changed version, except for a nominal charge for copying
% etc.
% \fi
%
% \ProvidesFile{ltdirchk.dtx}
%             [1994/05/25 v1.0g LaTeX Kernel (System Dependant Parts)]
%
% \iffalse
%%% File: ltdirchk
%
%<*unstripped>
\ifx\documentclass\undefined\let\next\relax\else\def\next{%
%</unstripped>
%<*driver>
% \fi
\ProvidesFile{ltdirchk.dtx}
             [1994/05/23 v1.0f LaTeX Kernel (System Dependant Parts)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltdirchk.dtx}
\title{dircheck.dtx\thanks{%
 this file also includes the source for texsys.cfg and ltxcheck.tex}}
\author{David Carlisle}
\date{\filedate}
\begin{document}
 \maketitle
 \DocInput{\filename}
\end{document}
%</driver>
%<*unstripped>
}\fi\next
%</unstripped>
% \fi
%
% \changes{v0.2j}{1994/02/25}
%         {Remove need for drv file}
% \changes{v0.2k}{1994/03/01}
%         {Add unstripped module, 
%          so that dircheck.dtx may be used with initex}
% \changes{v1.0a}{1994/03/08}
%         {Reorganise driver module into `new style'}
% \changes{v1.0b}{1994/03/12}
%         {Change name from dircheck.dtx}
% \changes{v1.0b}{1994/03/12}
%         {Minor edits to the typeouts in ltxcheck}
% \changes{v1.0d}{1994/03/28}
%         {Improve documentation}
%
% \CheckSum{777}
%
% \section{\LaTeX\ System Dependant Initialisations}
%
% \changes{v0.2g}{1994/01/21}
%         {Improve documentation, reorganise docstrip module}
%
% This file implements the semi-automatic determination of various
% system dependant parts of the initialisation. The actual definitions
% may be placed in a file |texsys.cfg|. Thus for operating systems for
% which the tests here do not result in acceptable settings, a `hand
% written' |texsys.cfg| may be produced.
%
% The macros that must be defined are:
%
% \DescribeMacro{\@currdir}
% |\@currdir|\meta{filename}\meta{space} should expand to a form of the
% filename that uniquely refers to the `current directory' if this is
% possible. (The expansion should also end with a space.) on UNIX,
% this is |\def\@currdir{./}|. For more exotic operating systems you may
% want to make |\@currdir| a macro with arguments delimited by |.|
% and/or \meta{space}. If the operating system has no concept of
% directory structure, this macro should be defined to be empty.
% 
%
% \DescribeMacro{\input@path}
% If the primitive |\openin| searches the same directories as the
% primitive |\input|, then it is possible to tell (using |\ifeof|)
% whether a file exists before trying to input it. For systems like
% this, |\input@path| should be left undefined.
%
% If |\openin| does not `follow' |\input| then |\input@path| must be
% defined to be a list of directories to search for input files. The
% format for each directory is as for |\@currdir|, normally just a
% prefix is required, but it may be a macro with space-delimited
% argument. That is, if \meta{dir} is an entry in the input path, 
% \TeX\ will try to load the expansion of 
%   \meta{dir}\meta{filename}\meta{space}
%
% So either \meta{dir} should be defined as a macro with argument
% delimited by space, or it should just expand to a directory name,
% including the final directory separator, so that it may be
% concatenated with the \meta{filename}. This means that for UNIX-like
% syntax, each \meta{dir} should end with a slash, |/|.
%
% |\input@path| should expand to a list of such directories, each in a
% |{}| group. 
%
% \DescribeMacro{\filename@parse}
% After a call of the form: |\filename@parse{|\meta{filename}|}|, the
% three macros |\filename@area|,|\filename@base|,|\filename@ext| should
% be defined to be the `area' (or directory), basename and
% extension respectively. If there was no extension specified in
% \meta{filename}, |\filename@ext| should be |\let| to |\relax| (so this
% case may be tested with |\@ifundefined{filename@ext}| and, perhaps a
% default extension substituted).
% 
% Normally one would not need to define this macro in |texsys.cfg| as
% the automatic tests can supply parsers that work with UNIX and VMS and
% Macintosh syntax, as well as a basic parser that will cover many other
% cases. However some operating systems may need a `hand produced'
% parser in which case it should be defined in this file.
%
% The UNIX parser also works for most MSDOS \TeX\ versions.
% Currently if the UNIX, VMS or Macintosh parser is not used,
% |\filename@parse| is  defined to always return an empty area, and to
% split the argument into  basename and extension at the first `|.|'
% that occurs in the name. 
% Parsers for other formats may be defined in |texsys.cfg|,
% in which case they will be used in preference to the default
% definitions.
%
% \DescribeMacro{\@TeXversion}
% \changes{v1.0f}{1994/05/23}{Document \cmd\@TeXversion}
% If your \TeX\ is older than version 3.141, then you should define
% |\@TeXversion| (using |\def|) to be the version number. If you do not
% do this\footnote
%       {Actually if you \TeX\ is really old, version~2, \LaTeX\ can
%       detect this, and set \cs{@TeXversion} to~2 if it is not set in
%       the \texttt{cfg} file}
%, \LaTeX\ will not work around a bug in old \TeX\ versions, and
% so error messages will appear in a very strange format, with |^^J|
% appearing instead of line breaks:
% \begingroup\catcode`\==\active \def=#1#2{}\hfuzz\maxdimen
%\begin{verbatim}
%! LaTeX Error: \rubbish undefined.^^J^^JSee the LaTeX manual or LaTeX=
% Companion
% for explanation.^^JType  H <return>  for immediate help.
% ...                                              
%                                                  
%l.3 \renewcommand{\rubbish}
%                           {}
%? 
%\end{verbatim}
% \endgroup\noindent
% However if you put |\def\@TeXversion{3.14}| in \texttt{texsys.cfg}
% the following format will be used:
%\begin{verbatim}
%! LaTeX Error: \rubbish undefined.
%
%See the LaTeX manual or LaTeX Companion for explanation.
%Type  H <return>  for immediate help.
%! .
% ...                                              
%                                                  
%l.3 \renewcommand{\rubbish}
%                           {}
%? 
%\end{verbatim}
% Note that this has an extra line |! .| which does not appear in 
% error messages that use the default settings with a current version of
% \TeX, but this should not cause any confusion we hope.
%
% \StopEventually{}
%
% \section{Initialisation}
% As this file is read at a very early stage, some definitions that
% are normally considered to be part of the format must be made here.
%
% \subsection{INITEX}
% \changes{v0.2i}{1994/01/25}
%         {Protect against looping on \cmd{\@@input} and \cmd{\@@end}}
%    \begin{macrocode}
%<*dircheck>
%<*initex>
\catcode`\{=1
\catcode`\}=2
\catcode`\#=6
\catcode`\^=7
\chardef\active=13
\catcode`\@=11
\countdef\count@=255
\let\bgroup={ \let\egroup=}
\ifx\@@input\@undefined\let\@@input\input\fi
\ifx\@@end\@undefined\let\@@end\end\fi
\chardef\@inputcheck0
\chardef\sixt@@n=16
\newlinechar`\^^J
\def\typeout{\immediate\write17}
\def\dospecials{\do\ \do\\\do\{\do\}\do\$\do\&%
  \do\#\do\^\do\_\do\%\do\~}
\def\@makeother#1{\catcode`#1=12\relax}
\def\space{ }
\def\@tempswafalse{\let\if@tempswa\iffalse}
\def\@tempswatrue{\let\if@tempswa\iftrue}
\let\if@tempswa\iffalse
\def\loop#1\repeat{\def\body{#1}\iterate}
\def\iterate{\body \let\next\iterate \else\let\next\relax\fi \next}
\let\repeat\fi
%</initex>
%    \end{macrocode}
%
% \subsection{Some bits of 2e}
%    \begin{macrocode}
%<*2ekernel>
\def\two@digits#1{\ifnum#1<10 0\fi\number#1}
\long\def\@firstoftwo#1#2{#1}
\long\def\@secondoftwo#1#2{#2}
%    \end{macrocode}
% \changes{v1.0e}{1994/05/11}
%         {Add \cs{ProvidesFile} as used in fd files.}
%    \begin{macrocode}
\def\ProvidesFile#1{%
  \begingroup
    \catcode`\ 10 %
    \@makeother\/%
    \@ifnextchar[{\@providesfile{#1}}{\@providesfile{#1}[]}}
\def\@providesfile#1[#2]{%
    \wlog{File: #1 #2}%
    \expandafter\xdef\csname ver@#1\endcsname{#2}%
  \endgroup}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@empty{}
\catcode`\%=12
\def\@percentchar{%}
\catcode`\%=14
\let\@currdir\@undefined
\let\input@path\@undefined
\let\filename@parse\@undefined
%    \end{macrocode}
% \begin{macro}{\strip@prefix}
% \changes{v0.2a}{1993/12/13}
%         {modified, name changed from \cmd\stripmeaning}
% \changes{v0.2e}{1994/01/19}
%         {name changed from \cmd{\strip@meaning}, to match NFSS}
%    \begin{macrocode}
\def\strip@prefix#1>{}
%</2ekernel>
%    \end{macrocode}
% \end{macro}
%
% \section{texsys.cfg}
% As mentioned above, any site specific definitions required to describe
% the filename handling must be entered into a file |texsys.cfg|. If
% |texsys.cfg| can not be located by |\openin|, we write a default
% version out. The default version only contains comments, so we do not
% actually input the file in that case. The automatic tests later will,
% hopefully, correctly define the required macros.
%
% The tricky code below checks to see if |texsys.cfg| exists. If it does
% not, all the text in this file between START and END is copied
% verbatim to a new file |texsys,cfg|. If |texsys.cfg| is found, then it
% is simply input. This is only done when this file is being used
% unstripped.  
%    \begin{macrocode}
%<*docstrip>
\openin15=texsys.cfg
\ifeof15
\typeout{** Writing a default texsys.cfg}
\immediate\openout15=texsys.cfg
\begingroup
\catcode`\^^M\active%
\let^^M\par%
\def\@tempa#1^^M{%
 \def\@tempb{#1}%
 \ifx\@tempb\@tempc\endgroup\else%
     \immediate\write15{#1}%
     \expandafter\@tempa\fi}%
\def\@tempd#1START^^M{\let\do\@makeother\dospecials\@tempa}%
\catcode`\%=12 
\def\@tempc{%END}
\@tempd
%    \end{macrocode}
%START
% \subsection{texsys.cfg}
%
% This file contains the site specific definitions of the four macros\\
% |\@currdir|, |\input@path|, |\filename@parse| and |\@TeXversion|.
%
% As distributed it only contains comments, however this `empty'
% file will work on many systems because of the automatic tests built
% into |dircheck.dtx|. You \emph{are} allowed to edit this file to add
% definitions of these macros appropriate to your system.
%
% David Carlisle 1994/12/17
%
%
% The macros that must be defined are:
%
% \DescribeMacro{\@currdir}
% |\@currdir|\meta{filename}\meta{space} should expand to a form of the
% filename that uniquely refers to the `current directory' if this is
% possible. (The expansion should also end with a space.) on UNIX,
% this is |\def\@currdir{./}|. For more exotic operating systems you may
% want to make |\@currdir| a macro with arguments delimited by |.|
% and/or \meta{space}. If the operating system has no concept of
% directory structure, this macro should be defined to be empty.
% 
%
% \DescribeMacro{\input@path}
% If the primitive |\openin| searches the same directories as the
% primitive |\input|, then it is possible to tell (using |\ifeof|)
% whether a file exists before trying to input it. For systems like
% this, |\input@path| should be left undefined.
%
% If |\openin| does not `follow' |\input| then |\input@path| must be
% defined to be a list of directories to search for input files. The
% format for each directory is as for |\@currdir|, normally just a
% prefix is required, but it may be a macro with space-delimited
% argument. That is, if \meta{dir} is an entry in the input path, 
% \TeX will try to load the expansion of 
%
%   \meta{dir}\meta{filename}\meta{space}
%
% So either \meta{dir} should be defined as a macro with argument
% delimited by space, or it should just expand to a directory name,
% including the final directory separator, so that it may be
% concatenated with the \meta{filename}. This means that for UNIX-like
% syntax, each \meta{dir} should end with a slash, |/|. One exception to
% this rule is that the input path should \emph{always} contain the
% empty directory |{}| as this will allow `full pathnames' to be used,
% and the  `current directory' to be searched.
%
% |\input@path| should expand to a list of such directories, each in a
% |{}| group. 
%
%
% \DescribeMacro{\filename@parse}
% After a call of the form: |\filename@parse{|\meta{filename}|}|, the
% three macros |\filename@area|,|\filename@base|,|\filename@ext| should
% be defined to be the `area' (or directory), basename and
% extension respectively. If there was no extension specified in
% \meta{filename}, |\filename@ext| should be |\let| to |\relax| (so this
% case may be tested with |\@ifundefined{filename@ext}| and, perhaps a
% default extension substituted).
% 
% Normally one would not need to define this macro in |texsys.cfg| as
% the automatic tests can supply parsers that work with UNIX and VMS
% syntax, as well as a basic parser that willcover many other cases.
% However some operating systems may need a `hand produced' parser
% in which case it should be defined in this file.
%
% The UNIX parser also works for most MSDOS \TeX\ versions.
% Currently if the UNIX or VMS parser is not used, |\filename@parse| is
% defined to always return an empty area, and to split the argument into
% basename and extension at the first `|.|' that occurs in the name.
% Parsers for other formats may be defined in |texsys.cfg|,
% in which case they will be used in preference to the default
% definitions.
%
%
% \DescribeMacro{\@TeXversion}
% If your \TeX\ is older than version 3.141, then you should define
% |\@TeXversion| (using |\def|) to be the version number. If you do not
% do this, \LaTeX\ will not work around a bug in old \TeX\ versions, and
% so error messages will appear in a very strange format, see the
% example in the opening section of \texttt{ltdirchk.dtx}.
%
%
%
% The following sections give examples of definitions which might
% work on various systems. These are currently mainly untested as I only
% have access to a few systems, all of which do not need this file as
% the automatic tests work. All the code is commented out.
%
% \subsection{UNIX (web2c)}
% This implementation does make |\openin| and |\input| look in the same
% places. Acceptable settings are made by |dircheck.dtx|, and so this
% file may be empty. The definitions below are therefore just for
% information. 
%    \begin{macrocode}
%\def\@currdir{./}
%\let\input@path\@undefined
%    \end{macrocode}
%
% \subsection{UNIX (other)}
% Apparently some commercial UNIX implementations have different paths
% for |\openin| and |\input|. For these one could use definitions like
% the following (with whatever directories are used at your site):
% note that the directory names should end with |/|.
%    \begin{macrocode}
% \def\@currdir{./}
% \def\input@path{%
%   {/usr/local/lib/tex/inputs/distrib/}%
%   {/usr/local/lib/tex/inputs/contrib/}%
%   {/usr/local/lib/tex/inputs/local/}%
% }
%    \end{macrocode}
%
% \subsection{MSDOS (emtex)}
% This implementation does make |\openin| and |\input| look in the same
% places. Acceptable settings are made by |dircheck.dtx|, and so this
% file may be empty. The definitions below are therefore just for
% information. 
%    \begin{macrocode}
% \def\@currdir{./}
% \let\input@path\@undefined
%    \end{macrocode}
%
% \subsection{MSDOS (other)}
% Some PC implementations have different paths
% for |\openin| and |\input|. For these one could use definitions like
% the following (with whatever directories are used at your site):
% note that the directory names should end with |/|.
% This assumes the implementation uses UNIX style |/| as the directory
% separator. 
%    \begin{macrocode}
% \def\@currdir{./}
% \def\input@path{%
%   {c:/tex/inputs/distrib/}%
%   {c:/tex/inputs/contrib/}%
%   {c:/tex/inputs/local/}%
% }
%    \end{macrocode}
%
% \subsection{VMS (???)}
% This implementation does make |\openin| and |\input| look in the same
% places. Acceptable settings are made by |dircheck.dtx|, and so this
% file may be empty. The definitions below are therefore just for
% information. 
%    \begin{macrocode}
% \def\@currdir{[]}
% \let\input@path\@undefined
%    \end{macrocode}
%
% \subsection{VMS (???)}
% Some VMS implementations have different paths
% for |\openin| and |\input|. For these one could use definitions like
% the following:
%    \begin{macrocode}
% \def\@currdir{[]}
% \def\input@path{%
%   {texinputs:}%
%   {[SOME.TEX.DIRECTORY]}%
% }
%    \end{macrocode}
%
% \subsection{MACINTOSH (OzTeX 1.6)}
% This implementation does make |\openin| and |\input| look in the same
% places. Acceptable settings are made by |dircheck.dtx|, and so this
% file may be empty. The definitions below are therefore just for
% information. 
%    \begin{macrocode}
% \def\@currdir{:}
% \let\input@path\@undefined
%    \end{macrocode}
%
% \subsection{MACINTOSH (other)}
% Some Macintosh implementations have different paths
% for |\openin| and |\input|. For these one could use definitions like
% the following (with whatever folders are used on your machine):
% note that the directory names should end with |:|, and they should
% contain {\em no\/} spaces.
%    \begin{macrocode}
% \def\@currdir{:}
% \def\input@path{%
%   {Hard-Disk:Applications:TeX:TeX-inputs:}%
%   {Hard-Disk:Applications:TeX:My-inputs:}%
% }
%    \end{macrocode}
%
% \subsection{FAKE EXAMPLE}
%  This example is for an operating system that has filenames of the
%  form |<area>name|  For maximum compatability with macro sets,
%  you want |name.ext| to be mapped to |<ext>name|.
%  and |<area>name.ext| to be mapped to |<area.ext>name|.
%  |\input| does this mapping automatically, but |\openin| does not, and
%  does not look in the same places as |\input|.
%  |<>name| is the desired `current directory' syntax.
%
% the following code would possibly work:
%    \begin{macrocode}
% \def\@dir#1#2 {%
%   \@d@r{#1}#2..\@nil}
% \def\@d@r#1#2.#3.#4\@nil{%
%   <\ifx\@dir#1\@dir\else#1\ifx\@dir#3\@dir\else.\fi\fi#3>#2 }
%
% \def\@currdir{\@dir{}}
% \def\input@path{%
%   {\@dir{area.one}}%
%   {\@dir{area.two}}%
% }
%    \end{macrocode}
%END
%    \begin{macrocode}
\immediate\closeout15
%    \end{macrocode}
% If |texsys.cfg| did exist, then input it.
%    \begin{macrocode}
\else
\typeout{** Using the existing texsys.cfg}
\closein15
\input texsys.cfg
\fi
%</docstrip>
%    \end{macrocode}
%
% If the stripped version of this file is being used (in latex2e.ltx)
% then texsys.cfg should be there, so just input it.
%    \begin{macrocode}
%<dircheck>\input texsys.cfg
%    \end{macrocode}
%
% \changes{v0.2f}{1994/01/20}
%         {\cmd{\@copytexsys} and the texsys.new file removed}
%
% \section{Setting \texttt{\cmd{\@currdir}}}
%
% \begin{macro}{\@currdir}
% \begin{macro}{\IfFileExists}
% \changes{v0.2e}{1994/01/19}
%         {name changed from \cmd\test}
% This is a local definition of |\IfFileExists|. It tries to relocate
% |texsxys.aux|. If it succeeds, then the |\@currdir| syntax has been
% determined. If all the tests fail then |\@currdir| will be set to
% |\@empty|, and |ltxcheck| will warn of this when it checks the format.
%    \begin{macrocode}
\begingroup
\count@\time
\divide\count@ 60
\count2=-\count@
\multiply\count2 60
\advance\count2 \time
%    \end{macrocode}
%
% \begin{macro}{\today}
% The current date and time stamp.
% \changes{v0.2g}{1994/01/21}
%         {Name changeed from \cmd\stamp, to save memory}
%    \begin{macrocode}
\edef\today{%
  \the\year/\two@digits{\the\month}/\two@digits{\the\day}:%
    \two@digits{\the\count@}:\two@digits{\the\count2}}
%    \end{macrocode}
% \end{macro}
%
% Create a file |texsys.aux| (hopefully in the current directory),
% then try to locate it again.
%    \begin{macrocode}
\immediate\openout15=texsys.aux
\immediate\write15{\today^^J}
\immediate\closeout15 %
%    \end{macrocode}
%
% |#1| is the file to try, |#2| is what to do on success, |#3| on
% failure.
%    \begin{macrocode}
\def\IfFileExists#1#2#3{%
  \openin\@inputcheck#1 %
  \ifeof\@inputcheck
     #3\relax
  \else
    \read\@inputcheck to \@tempa
    \ifx\@tempa\today
      \typeout{#1 found}#2\relax
    \else
      \typeout{BAD: old file \@tempa (should be \today)}%
      #3\relax
    \fi
  \fi
  \closein\@inputcheck}
%    \end{macrocode}
%
%    \begin{macrocode}
\endlinechar=-1
%    \end{macrocode}
%
% If |\@currdir| has not been pre-defined in |texsys.cfg| then test for
%  UNIX, VMS and  Oz-\TeX-Mac. syntax.
% \changes{v0.2h}{1994/01/24}
%         {Stop testing once texsys.aux has been found}
%    \begin{macrocode}
\ifx\@currdir\@undefined
  \IfFileExists{./texsys.aux}{\gdef\@currdir{./}}%
    {\IfFileExists{[]texsys.aux}{\gdef\@currdir{[]}}%
      {\IfFileExists{:texsys.aux}{\gdef\@currdir{:}}{}}}
%    \end{macrocode}
% If it is still undefined at this point, all the above tests failed.
% Earlier versions interactively prompted for a definition at this
% point, but it seems impossible to reliably obtain information from
% users at this point in the installation. This version of the file
% produces a format with no user-interaction. Later if the format is not
% suitable for the system, |texsys.cfg| may be edited and the format
% re-made.
% \changes{v0.2a}{1993/12/13}
%         {Removed interactive prompting for current directory syntax}
% \changes{v0.2f}{1994/01/20}
%         {\cmd{\@copytexsys} removed}
%    \begin{macrocode}
  \ifx\@currdir\@undefined
    \global\let\@currdir\@empty
    \typeout{^^J***^^J%
      No syntax for the current directory could be found^^J%
      ***}%
  \fi
%    \end{macrocode}
% Otherwise |\@currdir| was defined in |texsys.cfg|. In this case check
% that the syntax specified works on this system. (In case a complete
% \LaTeX\  system has been copied from  one system to another.) If the
% test fails, give up. The installer should remove or correct the
% offending |texsys.cfg| and try again. 
%    \begin{macrocode}
\else
  \IfFileExists{\@currdir texsys.aux}{}{%
    \edef\@tempa{\errhelp{%
      texsys.cfg specifies the current directory syntax to be^^J%
      \meaning\@currdir^^J%
      but this does not work on this system.^^J%
      Remove texsys.cfg and restart.}}\@tempa
    \errmessage{Bad texsys.cfg file: \noexpand\@currdir}\@@end}
%    \end{macrocode}
% The version of |\@currdir| in |texsys.cfg| looks OK.
%    \begin{macrocode}
\fi
%    \end{macrocode}
% \changes{v0.2d}{1994/01/14}
%         {Close the texsys.aux output stream}
%    \begin{macrocode}
\immediate\closeout15 %  
\endgroup
%    \end{macrocode}
%
%    \begin{macrocode}
\typeout{^^J***^^J%
         \noexpand\@currdir set to: 
           \expandafter\strip@prefix\meaning\@currdir.^^J%
         ***}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \changes{v0.2a}{1993/12/13}
%         {on the `docstrip' pass, do not check openin path}
%   
% Stop here if the file is being used unstripped.
%    \begin{macrocode}
%<*docstrip>
\relax\endinput
%</docstrip>
%    \end{macrocode}
%
% \section{Setting \texttt{\cmd{\input@path}}}
%
% Earlier versions of this file attempted to automatically test whether
% |\input@path| was required, and interactively prompt for a path if
% necessary. This was not found to be very reliable The first-time
% installer of \LaTeXe\ can not be expected to have enough information
% to supply the correct information to the prompts. Now the interaction
% is omitted. After the format is made the installer can attempt to run
% the test document |ltxcheck.tex| through \LaTeXe. This will check,
% amongst other things, whether |texsys.cfg| will need to be edited and
% the format remade.
%
% \begin{macro}{\input@path}
% Now set up the |\input@path|.
%
% |input@path| should either be undefined, or a list of directories as
% described in the introduction. 
% \changes{v0.2e}{1994/01/19}
%         {No longer check that an empty group is in the path}
%    \begin{macrocode}
  \typeout{***^^J%
    Assuming \noexpand\openin and \noexpand\input^^J%
    \ifx\input@path\@undefined
%    \end{macrocode}
% |\input@path| has not been pre-defined.
%    \begin{macrocode}
      have the same search path.^^J%
    \else
%    \end{macrocode}
% |\input@path| has  been defined in |texsys.cfg|.
%    \begin{macrocode}
      have different  search paths.^^J%
      LaTeX will use the path specified by \noexpand\input@path:^^J%
    \fi
    ***}
%    \end{macrocode}
% \end{macro}

%
% \section{Filename Parsing}
%
% \begin{macro}{\filename@parse}
% Split a filename into its components.
% \changes{v0.2g}{1994/01/21}
%         {Minor changes, and add Mac version (:)}
%    \begin{macrocode}
\ifx\filename@parse\@undefined
  \def\@tempa{./}\ifx\@currdir\@tempa
%    \end{macrocode}
% |\filename@parse| was not specified in |texsys.cfg|, but |\@currdir|
% looks like UNIX\ldots
%    \begin{macrocode}
    \typeout{^^J***^^JDefining UNIX/DOS style filename parser.^^J***}
    \def\filename@parse#1{%
      \let\filename@area\@empty
      \expandafter\filename@path#1/\\}
%    \end{macrocode}
%
% Search for the last |/|. 
%    \begin{macrocode}
    \def\filename@path#1/#2\\{%
      \ifx\\#2\\%
         \def\@tempa{\filename@simple#1.\\}%
      \else
         \edef\filename@area{\filename@area#1/}%
         \def\@tempa{\filename@path#2\\}%
      \fi
      \@tempa}
%    \end{macrocode}
%
%    \begin{macrocode}
  \else\def\@tempa{[]}\ifx\@currdir\@tempa
%    \end{macrocode}
% |\filename@parse| was not specified in |texsys.cfg|, but |\@currdir|
% looks like VMS\ldots
%    \begin{macrocode}
    \typeout{^^J***^^JDefining VMS style filename parser.^^J***}
    \def\filename@parse#1{%
      \let\filename@area\@empty
      \expandafter\filename@path#1]\\}
%    \end{macrocode}
%
% Search for the last |]|.
%    \begin{macrocode}
    \def\filename@path#1]#2\\{%
      \ifx\\#2\\%
         \def\@tempa{\filename@simple#1.\\}%
      \else
         \edef\filename@area{\filename@area#1]}%
         \def\@tempa{\filename@path#2\\}%
      \fi
      \@tempa}
%    \end{macrocode}
%
%    \begin{macrocode}
  \else\def\@tempa{:}\ifx\@currdir\@tempa
%    \end{macrocode}
% |\filename@parse| was not specified in |texsys.cfg|, but |\@currdir|
% looks like Macintosh\ldots
%    \begin{macrocode}
    \typeout{^^J***^^JDefining Mac style filename parser.^^J***}
    \def\filename@parse#1{%
      \let\filename@area\@empty
      \expandafter\filename@path#1:\\}
%    \end{macrocode}
%
% Search for the last |:|.
% \changes{v1.0g}{1994/05/25}
%         {Mac parser had " typo for :}
%    \begin{macrocode}
    \def\filename@path#1:#2\\{%
      \ifx\\#2\\%
         \def\@tempa{\filename@simple#1.\\}%
      \else
         \edef\filename@area{\filename@area#1:}%
         \def\@tempa{\filename@path#2\\}%
      \fi
      \@tempa}
%    \end{macrocode}
%
%    \begin{macrocode}
  \else
%    \end{macrocode}
% |\filename@parse| was not specified in |texsys.cfg|.
% So just make a simple parser that always sets |\filename@area| to
% empty. 
%    \begin{macrocode}
    \typeout{^^J***^^JDefining generic filename parser.^^J***}
    \def\filename@parse#1{%
      \let\filename@area\@empty
      \expandafter\filename@simple#1.\\}
  \fi\fi\fi
%    \end{macrocode}
%
% |\filename@simple| is used by all three versions.
% Finally we can split off the extension.
%    \begin{macrocode}
  \def\filename@simple#1.#2\\{%
    \ifx\\#2\\%
       \let\filename@ext\relax
    \else
       \edef\filename@ext{\filename@dot#2\\}%
    \fi
    \edef\filename@base{#1}}
%    \end{macrocode}
%
% Remove a final dot, added earlier.
%    \begin{macrocode}
  \def\filename@dot#1.\\{#1}
%    \end{macrocode}
%
%    \begin{macrocode}
\else
%    \end{macrocode}
% Otherwise, |\filename@parse| was specified in |texsys.cfg|.
%    \begin{macrocode}
  \typeout{^^J***^^J%
    \noexpand\filename@parse was defined in texsys.cfg:^^J%
    \expandafter\strip@prefix\meaning\filename@parse.^^J%
    ***}
\fi
%    \end{macrocode}
% \end{macro}
%
% \section{\TeX\ Versions}
%
% \begin{macro}{\@TeXversion}
% \TeX\ versions older than than 3.141 require |\@TeXversion| to be
% set. This is normally done in |texsys.cfg|, however for really old
% (version 2) \TeX{}s, we can set it here to 2 if it has not been set
% in the |cfg| file. This just leaves \TeX\ versions between 3.0 and
% 3.14 for which |\@TeXversion| \emph{must} be set in the
% configuration file.
%    \begin{macrocode}
\ifx\@TeXversion\@undefined
  \ifx\undefined\inputlineno
    \def\@TeXversion{2}
  \fi
\fi
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
%</dircheck>
%    \end{macrocode}
%
% \section{ltxcheck.tex}
% After the format has been made, and article.cls moved with the
% other files to the `standard input directory' as specified in
% |install.l2e|, the format may be checked by running the file
% |ltxcheck.tex|. 
% \changes{v0.2f}{1994/01/20}
%         {Modify all of ltxcheck}
%
% 
% 
%    \begin{macrocode}
%<*ltxcheck>
%    \end{macrocode}
%
% \changes{v1.0c}{1994/03/15}
%         {Add \cmd{\NeedsTeXFormat}}
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
%    \end{macrocode}
%
%    \begin{macrocode}
\makeatletter
%    \end{macrocode}
%
%    \begin{macrocode}
\typeout{^^J%
LaTeX2e installation check file^^J%
===============================}

\typeout{^^J%
 Before running this file through LaTeX2e you should have installed^^J%
 the Standard LaTeX2e files in their final `system' directories.^^J%
 This file should *not* be run in a directory that contains article.cls}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\pause{%
  \typeout{}%
  \message{** Hit return to continue: }%
  \read -1  to \xxx
  \typeout{}}
%    \end{macrocode}
%
%    \begin{macrocode}
\typeout{^^J%
  After certain tests, LaTeX will pause so that you can read the^^J%
  output without it scrolling off the screen.^^J%
  When you are ready just hit <return> and LaTeX will continue.^^J%
  When LaTeX pauses, you will see a prompt like the one below.^^J^^J%
  If a test fails, a message will be displayed followed by^^J%
  an error message starting `! BAD'.^^J%
  LaTeX will quit if you try to scroll past such an error message.}
\pause
%    \end{macrocode}
%
%    \begin{macrocode}
\typeout{^^J%
  Checking the current directory syntax^^J%
  =====================================}
%    \end{macrocode}
%
%    \begin{macrocode}
\newif\iftest\testfalse
%    \end{macrocode}
%
%    \begin{macrocode}
\ifx\@currdir\@undefined
  \typeout{^^J%
  \noexpand\@currdir is undefined !!^^J%
  Something is seriously wrong with the LaTeX2e initialisation.^^J%
  Either you have corrupted files or this is a LaTeX bug.}
  \errmessage{BAD LaTeX2e system!!}
  \expandafter\@@end
\fi
%    \end{macrocode}
%
%    \begin{macrocode}
\ifx\@currdir\@empty
  \typeout{^^J%
  \noexpand\@currdir is defined to be empty.^^J%
  This means that LaTeX can not distinguish between a file^^J%
  aaaaa.tex^^J%
  that exists in the current directory, and  a file aaaaa.tex^^J%
  in another directory.^^J%
  It may be that this Operating System has no concept of `directory'^^J%
  in which case the setting is correct. If however it is possible to^^J%
  uniquely refer to a file then a suitable definition of
    \noexpand\@currdir^^J%
  should be added to texsys.cfg, and the format remade.}
  \pause
%    \end{macrocode}
%
%    \begin{macrocode}
\else
  \typeout{^^J%
\noexpand\@currdir is defined as
    \expandafter\strip@prefix\meaning\@currdir^^J%
  (Testing...)}
%    \end{macrocode}
%
%    \begin{macrocode}
\begingroup
\endlinechar=-1
\count@\time
\divide\count@ 60
\count2=-\count@
\multiply\count2 60
\advance\count2 \time
\edef\today{%
  \the\year/\two@digits{\the\month}/\two@digits{\the\day}:%
    \two@digits{\the\count@}:\two@digits{\the\count2}}
%    \end{macrocode}
%
%    \begin{macrocode}
  \immediate\openout15=ltxcheck.aux
  \immediate\write15{\today^^J}
  \immediate\closeout15 %
%    \end{macrocode}
%
%    \begin{macrocode}
  \openin\@inputcheck\@currdir ltxcheck.aux %
  \ifeof\@inputcheck
    \typeout{\@currdir ltxcheck.aux  not found}%
  \else
    \read\@inputcheck to \@tempa
    \ifx\@tempa\today
      \typeout{\@currdir ltxcheck.aux found}
      \testtrue
    \else
      \typeout{BAD: old file \@tempa (should be \today)}%
      \testfalse
    \fi
  \fi
  \closein\@inputcheck
%    \end{macrocode}
%
%    \begin{macrocode}
  \iftest
    \endgroup
    \typeout{\noexpand \@currdir OK!}
  \else
  \endgroup
%    \end{macrocode}
%
%    \begin{macrocode}
  \typeout{^^J%
    The LaTeX2e installation has defined \noexpand\@currdir^^J%
    to be \expandafter\strip@prefix\meaning\@currdir.^^J%
    This appears to be incorrect.^^J%
    You should add a correct definition to texsys.cfg^^J%
    and rebuild the format.}
  \errmessage{BAD LaTeX2e system!!}
  \expandafter\expandafter\expandafter\@@end
  \fi
  \pause
%    \end{macrocode}
%
%    \begin{macrocode}
\fi
%    \end{macrocode}
%
%    \begin{macrocode}
\typeout{^^J%
  Checking the input path^^J%
  =======================^^J}
%    \end{macrocode}
%
%    \begin{macrocode}
\begingroup
\let\input@path\@undefined
\ifx\@currdir\@empty\else
  \IfFileExists{\@currdir article.cls}
   {\typeout{article.cls in current directory!}%
    \errmessage{This file should not be run in a `system directory'}}{}
\fi
\endgroup
%    \end{macrocode}
%
%    \begin{macrocode}
\IfFileExists{article.cls}
  {\typeout{input path OK!}}
  {\typeout{^^J%
     LaTeX claims that article.cls is not on the system.^^J%
     Either LaTeX has been incorrectly installed, or the
     \noexpand\input@path^^J%
     is incorrect. A correct definition should be added to^^J%
     texsys.cfg, and the format remade.}
   \pause
   \typeout{^^J%
     Typical definitions of \noexpand\input@path include:^^J^^J%
     \string\let\string\input@path=\noexpand\@undefined
      (the default definition)^^J^^J%
     \string\def\string\input@path{\@percentchar^^J
       {/usr/lib/tex/inputs/} {/usr/local/lib/tex/inputs/} }^^J^^J%
     \string\def\string\input@path{\@percentchar^^J
       {c:/tex/inputs/} {a:/} }^^J^^J%
     \string\def\string\input@path{\@percentchar^^J
       {tex_inputs:} {[SOMEWHERE.TEX.INPUTS]} }^^J}%
   \pause
   \typeout{^^J%
     Note that \noexpand\input@path should be undefined
       unless your^^J%
     TeX installation does not make
       \noexpand\openin and \noexpand\input^^J%
     search the same directories.^^J%
     If \noexpand\input@path is defined, entries should be^^J%
     in the same syntax as \noexpand\@currdir^^J%
     ie full directory names that may be concatenated with the^^J%
     basename (note the final / and ] in the above examples).^^J%
     Some systems may need more complicated settings.^^J%
     See texsys.cfg for more examples.^^J%
    ! BAD \noexpand\input@path!!}
   \@@end}%
\pause
%    \end{macrocode}
%
%    \begin{macrocode}
\typeout{^^J%
  Checking the TeX version^^J%
  ========================}
%    \end{macrocode}
%
% \changes{v0.2j}{1994/02/25}
%         {\cs{noboundary} is \cs{relax} not undef in TeX2 (initialised
%         in 2e format)}
%    \begin{macrocode}
\ifx\noboundary\relax
  \typeout{^^J%
    This is TeX 2. You will not be able to use all the new features^^J%
    of LaTeX2e with such an old TeX.^^J%
    The current version (1993/12/16) is TeX 3.1415^^J%
    Consider upgrading your TeX}
\else
    \typeout{^^J%
    This is at least TeX3. Good!^^J%
    If the following `lines' appear on the same line, separated by
    \string^\string^J^^J%
    then consider upgrading to a TeX newer than 3.141.^^J%
    The current version (1994/05/24) is TeX 3.1415}
%    \end{macrocode}
%
%    \begin{macrocode}
\message{line1^^Jline2^^Jline3}
   \ifx\@TeXversion\@undefined
   \typeout{^^J%
      If the above message does contain \string^\string^J's^^J%
      You have a TeX between 3.0 and 3.14. Please add a line^^J%
      \@spaces\string\def\string\@TeXversion{3.<your TeX version>}^^J%
      to texsys.cfg, and rebuild the format.}
   \fi
\pause
%    \end{macrocode}
%
%    \begin{macrocode}
\fi
%    \end{macrocode}
%
%    \begin{macrocode}
\@@end
%</ltxcheck>
%    \end{macrocode}
%
% \Finale
%
