dircheck.dtx

Alan Jeffrey

1994/05/13

This file defines a command \testdistribution{⟨filename⟩}{⟨error⟩}{⟨help⟩}, which reads a file, and checks that all the filenames listed in it can be read by TEX. It should be run after dircheck.dtx has defined \input@path.

\IfFileExists A version of the \IfFileExists macro which does no fancy searching, and we assume the directory is on the \openin path.

1 ⟨∗testdist⟩

 2 \def\IfFileExists#1{%
 3  \openin\@inputcheck#1 %
 4  \ifeof\@inputcheck
 5  \closein\@inputcheck
 6  \expandafter\@secondoftwo
 7  \else
 8  \closein\@inputcheck
 9  \expandafter\@firstoftwo
10  \fi

11 }

\testdistribution \@filemustexist \@filemustexist@ \@missingfiles  \testdistribution inputs a file of filenames and checks that all the files can be

read by TEX. The files should be separated by whitespace, and terminated by

\endinput.
12 \def\@filemustexist#1{
13 \ifx#1\endinput
14  \expandafter\endinput
15 \else
16  \expandafter\@filemustexist@\expandafter#1%
17 \fi

18 }

19 \def\@filemustexist@#1 {
20 \IfFileExists{#1}{
21  \wlog{Passed `#1'.}
22 }{
23  \wlog{Failed `#1'.}
24  \xdef\@missingfiles{\@missingfiles\message{#1}}

25 }

26 \@filemustexist

27 }

28 \def\testdistribution#1#2#3{
29 \global\let\@missingfiles=\@empty

30 {

31  \catcode`\^^M=\the\catcode`\ \relax
32  \expandafter\@filemustexist\@@input #1

33 }

34 \ifx\@missingfiles\@empty
35 \else
36  \immediate\write16{}
37  \immediate\write16{The following files are missing:}
38  \immediate\write16{}
39  \@missingfiles
40  \immediate\write16{}
41  \errhelp{#3}
42  \errmessage{#2}
43  \immediate\write16{}
44  \immediate\write16{Carrying on with fingers crossed...}
45  \immediate\write16{}
46 \fi

47 } 48 ⟨/testdist⟩

Change History

v0.02

General: This file now defines a

      command \testdistribution,

which reads an arbitrary file, rather than only reading manifest.l2e. . . . . . . . . . . . . . . . . . 1

v0.03

General: Added \@tfor. . . . . . . . . 1 Chris pointed out that we need ‘@tfor here . . . . . . . . . . . . . . . 1 v0.04

General: Removed all the directory searching . . . . . . . . . . . . . . . . 1 Removed directory searching… 1

v0.05

General: Corrected missing file

number bug. . . . . . . . . . . . . . . 1 \IfFileExists: Corrected missing

file number bug. . . . . . . . . . . . 1 v0.06

General: Improved documentation. 1

Index

Numbers written in italic refer to the page where the corresponding entry is described, the ones underlined to the code line of the definition, the rest to the code lines where the entry is used.

Symbols

\@@input . . . . . . . . . 32 \@empty . . . . . . . . 29, 34

\@filemustexist . . . \underline{12}

                          \@filemustexist@ . . \underline{12}
                          \@firstoftwo . . . . . . . 9
                          \@inputcheck . . . . 3–5, 8
                          \@missingfiles . . . . \underline{12}

                                                   \@secondoftwo . . . . . . 6

\^. . . . . . . . . . . . . . 31

\␣ . . . . . . . . . . . . . . 31 \catcode . . . . . . . . . 31 \closein . . . . . . . . 5, 8

D

\def . . . . . . 2, 12, 19, 28

E

\else . . . . . . . . 7, 15, 35 \endinput . . . . . . 13, 14 \errhelp . . . . . . . . . 41

\errmessage . . . . . . . 42
\expandafter . . . . . .

… 6, 9, 14, 16, 32

F

\fi . . . . . . . . 10, 17, 46

G \global . . . . . . . . . . 29

I \ifeof . . . . . . . . . . . . 4

                          \IfFileExists . . . . \underline{1}, 20

\ifx . . . . . . . . . . . 13, 34

                          \immediate . . . . . . .

. . 36–38, 40, 43–45

L \let . . . . . . . . . . . . . 29

M \message . . . . . . . . . 24

O \openin . . . . . . . . . . . 3

R \relax . . . . . . . . . . . 31

T

                                                   \testdistribution . \underline{12}

\the . . . . . . . . . . . . . 31

W \wlog . . . . . . . . . . 21, 23 \write . 36–38, 40, 43–45

X \xdef . . . . . . . . . . . . 24