The DocStrip program ^{∗}

Frank Mittelbach

        Mittelbach@mzdmza.zdv.uni-mainz.de

Denys Duchier

duchier-denys@cs.yale.edu

Johannes Braams TeXniek Kooienswater 62 2715 AJ Zoetermeer

                             JLBraams@cistron.nl

Marcin Woliński

wolinski@mimuw.edu.pl

Mark Wooding

                         mdw@excessus.demon.co.uk

Printed July 1, 1998

Abstract

This document describes the implementation of the DocStrip program. The original version of this program was developed by Frank Mittelbach to accompany his doc.sty which enables literate programming in L^{A}TEX. Denys Duchier rewrote it to run either with TEX or with L^{A}TEX, and to allow full boolean expressions in conditional guards instead of just comma-separated lists. Johannes Braams re-united the two implementations, documented and debugged the code.

In September 1995 Marcin Woliński changed many parts of the program to make use of TEX’s ability to write to multiple files at the same time to avoid re-reading sources. The performance improvement of version 2.3 came at a price of compatibility with some more obscure operating systems which limit the number of files a process can keep open. This was corrected in September 1996 by Mark Wooding and his changes were “creatively merged” by Marcin Woliński who made at the same time changes in batch files processing, handling of preambles and introduced “verbatim mode”. After all that, David Carlisle merged the new version into the L^{A}TEX sources, and made a few other changes, principally making DocStrip work under initex, and removing the need for batch files to say \def\batchfile{...}.

∗This file has version number 2.4h, last revised 1997/07/07, documentation dated 1997/07/07.

1 Introduction

1.1 Why the DocStrip program?

When Frank Mittelbach created the doc package, he invented a way to combine TEX code and its documentation. From then on it was more or less possible to do literate programming in TEX.

This way of writing TEX programs obviously has great advantages, especially when the program becomes larger than a couple of macros. There is one drawback however, and that is that such programs may take longer than expected to run because TEX is an interpreter and has to decide for each line of the program file what it has to do with it. Therefore, TEX programs may be speeded up by removing all comments from them.

By removing the comments from a TEX program a new problem is introduced. We now have two versions of the program and both of them have to be maintained. Therefore it would be nice to have a possibility to remove the comments automatically, instead of doing it by hand. So we need a program to remove comments from TEX programs. This could be programmed in any high level language, but maybe not everybody has the right compiler to compile the program. Everybody who wants to remove comments from TEX programs has TEX. Therefore the DocStrip program is implemented entirely in TEX.

1.2 Functions of the DocStrip program

Having created the DocStrip program to remove comment lines from TEX programs^{1} it became feasible to do more than just strip comments. Wouldn’t it be nice to have a way to include parts of the code only when some condition is set true? Wouldn’t it be as nice to have the possibility to split the source of a TEX program into several smaller files and combine them later into one ‘executable’? Both these wishes have been implemented in the DocStrip program.

2 How to use the DocStrip program

A number of ways exist to use the DocStrip program:

1. The usual way to use DocStrip is to write a batch file in such a way that it can be directly processed by TEX. The batch file should contain the commands described below for controlling the DocStrip program. This allows you to set up a distribution where you can instruct the user to simply run

TEX ⟨batch file⟩

to generate the executable versions of your files from the distribution sources. Most of the L^{A}TEX distribution is packaged this way. To produce such a batch file include a statement in your ‘batch file’ that instructs TEX to read docstrip.tex. The beginning of such a file would look like:

1Note that only comment lines, that is lines that start with a single % character, are removed; all other comments stay in the code.

         \input docstrip
         ...

Normally the batch file should have extension .ins. If it has a different extension, you should specify the name of the batchfile first, before inputting DocStrip. This is done by adding a line such as

         \def\batchfile{install.me}

if the file is called install.me.

2. Alternatively you can instruct TEX to read the file docstrip.tex and to see what happens. TEX will ask you a few questions about the file you would like to be processed. When you have answered these questions it does its job and strips the comments from your TEX code.

3 Configuring DocStrip

3.1 Selecting output directories

Inspired by a desire to simplify reinstallations of L^{A}TEX 2ε and to support operating systems which have an upper limit on the number of files allowed in a directory, DocStrip now allows installation scripts to specify output directories for files it creates. We suggest using TDS (TEX directory structure) names of directories relative to texmf here. However these names should be thought of as a labels rather than actual names of directories. They get translated to actual systemdependent pathnames according to commands contained in a configuration file

named docstrip.cfg.

The configuration file is read by DocStrip just before it starts to process any batch file commands.

If this file is not present DocStrip uses some default settings which ensure that files are only written to the current directory. However by use of this configuration file, a site maintainer can ‘enable’ features of DocStrip that allow files to be written to alternative directories.

\usedir Using this macro package author can tell where a file should be installed. All \files generated in the scope of that declaration are written to a directory specified by its one argument. For example in L^{A}TEX 2ε installation following declarations are used:

    \usedir{tex/latex/base}
    \usedir{makeindex}

And standard packages use

    \usedir{tex/latex/tools}
    \usedir{tex/latex/babel}

etc.

\showdirectory Used to display directory names in messages. If some label is not defined it expands to UNDEFINED (label is ...) otherwise to a directory name. It is probably a good idea for every installation script to display at startup list of all directories that would be used and asking user to confirm that.

The above macros are used by package/installation script author. The following macros are used in a configuration file, docstrip.cfg, by a system administrator to describe her/his local directory structure.

\BaseDirectory This macro is administrator’s way of saying “yes, I want to use that directories support of yours”. DocStrip will write only to current directory unless your config has a call to this macro. (This means DocStrip won’t write to random directories unless you tell it to, which is nice.) Using this macro you can specify a base directory for TEX-related stuff. E.g., for many Unix systems that would be

    \BaseDirectory{/usr/local/lib/texmf}

and for standard emTEX installation

    \BaseDirectory{c:/emtex}

\DeclareDir Having specified the base directory you should tell DocStrip how to interpret labels used in \usedir commands. This is done with \DeclareDir with two arguments. The first is the label and the second is actual name of directory relative to base directory. For example to teach DocStrip using standard emTEX directories one would say:

    \BaseDirectory{c:/emtex}
    \DeclareDir{tex/latex/base}{texinput/latex2e}
    \DeclareDir{tex/latex/tools}{texinput/tools}
    \DeclareDir{makeindex}{idxstyle}

This will cause base latex files and font descriptions to be written to directory

c:\emtex\texinput\latex2e, files of tools package to c:\emtex\texinput\tools

and makeindex files to c:\emtex\idxstyle.

Sometimes it is desirable to put some files outside of the base directory. For that reason \DeclareDir has a star form specifying absolute pathname. For example one could say

    \DeclareDir*{makeindex}{d:/tools/texindex/styles}

\UseTDS Users of systems conforming to TDS may well ask here “do I really need to put a dozen of lines like

    \DeclareDir{tex/latex/base}{tex/latex/base}

in my config file”. The answer is \UseTDS. This macro causes DocStrip to use labels themselves for any directory you haven’t overriden with \DeclareDir. The default behaviour is to raise an error on undefined labels because some users may want to know exactly where files go and not to allow DocStrip to write to random places. However I (MW) think this is pretty cool and my config says just (I’m running teTEX under Linux)

    \BaseDirectory{/usr/local/teTeX/texmf}
    \UseTDS

The important thing to note here is that it is impossible to create a new directory from inside TEX. So however you configure DocStrip, you need to create all needed directories before running the installation. Authors may want to begin every installation script by displaying a list of directories that will be used and asking user if he’s sure all of them exist.

Since file name syntax is OS specific DocStrip tries to guess it from the current directory syntax. It should succeed for Unix, MSDOS, Macintosh and VMS. However DocStrip will only initially know the current directory syntax if it is used with L^{A}TEX. If used with plainTEX or initex it will not have this information^{2}. If you often use DocStrip with formats other than L^{A}TEX you should start the

file docstrip.cfg with a definition of \WriteToDir. E.g., \def\WriteToDir{./}
on MSDOS/Unix, \def\WriteToDir{:} on Macintosh, \def\WriteToDir{[]} on

VMS.

If your system requires something completely different you can define in

docstrip.cfg macros \dirsep and \makepathname. Check for their definition

in the implementation part. If you want some substantially different scheme of translating \usedir labels into directory names try redefining macro \usedir.

3.2 Setting maximum numbers of streams

\maxfiles In support of some of the more obscure operating systems, there’s a limit on the number of files a program can have open. This can be expressed to DocStrip through the \maxfiles macro. If the number of streams DocStrip is allowed to open is n, your configuration file can say \maxfiles{n}, and DocStrip won’t try to open more files than this. Note that this limit won’t include files which are already open. There’ll usually be two of these: the installation script which you started, and the file docstrip.tex which it included; you must bear these in mind yourself. DocStrip assumes that it can open at least four files before it hits some kind of maximum: if this isn’t the case, you have real problems.

\maxoutfiles Maybe instead of having a limit on the number of files TEX can have open, there’s a limit on the number of files it can write to (e.g., TEX itself imposes a limit of 16 files being written at a time). This can be expressed by saying \maxoutfiles{m} in a configuration file. You must be able to have at least one output file open at a time; otherwise DocStrip can’t do anything at all.

Both these options would typically be put in the docstrip.cfg file.

2Except when processing the main unpack.ins batch file for the L^{A}TEX distribution, which takes special measures so that initex can learn the directory syntax.

4 The user interface

4.1 The main program

\processbatchFile The ‘main program’ starts with trying to process a batch file, this is accomplished by calling the macro \processbatchFile. It counts the number of batch files it processes, so that when the number of files processed is still zero after the call to \processbatchFile appropriate action can be taken.

\interactive When no batch files have been processed the macro \interactive is called. It prompts the user for information. First the extensions of the input and output files is determined. Then a question about optional code is asked and finally the user can give a list of files that have to be processed.

\ReportTotals When the stats option is included in the DocStrip-program it keeps a record of the number of files and lines that are processed. Also the number of comments removed and passed as well as the number of code lines that were passed to the output are accounted. The macro \ReportTotals shows a summary of this information.

4.2 Batchfile commands

The commands described in this section are available to build a batch file for TEX. \input All DocStrip batch files should start with the line: \input docstrip

Do not use the L^{A}TEX syntax \input{docstrip} as batch files may be used with plain TEX or iniTEX. You may that old batch files always have a line \def\batchfile{⟨filename⟩} just before the input. Such usage is still supported but is now discouraged, as it causes TEX to re-input the same file, using up one of its limited number of input streams.

\endbatchfile All batch files should end with this command. Any lines after this in the file are ignored. In old files that start \def\batchfile{… this command is optional, but is a good idea anyway. If this command is omitted from a batchfile then normally TEX will go to its interactive * prompt, so you may stop DocStrip by typing \endbatchfile to this prompt.

\generate The main reason for constructing a DocStrip command file is to describe what

\file
\from

files should be generated, from what sources and what optional (‘guarded’) pieces of code should be included. The macro \generate is used to give TEX this information. Its syntax is:

\generate{[\file{⟨output⟩}{[\from{⟨input⟩}{⟨optionlist⟩}]*}]*}

The ⟨output⟩ and ⟨input⟩ are normal file specifications as are appropriate for your computer system. The ⟨optionlist⟩ is a comma separated list of ‘options’ that specify which optional code fragments in ⟨input⟩ should be included in ⟨output⟩. Argument to \generate may contain some local declarations (e.g., the \use... commands described below) that will apply to all \files after them. Argument to \generate is executed inside a group, so all local declarations are undone when \generate concludes.

It is possible to specify multiple input files, each with its own ⟨optionlist⟩. This is indicated by the notation […]*. Moreover there can be many \file specifications in one \generate clause. This means that all these ⟨output⟩ files should be generated while reading each of ⟨input⟩ files once. Input files are read in order of first appearance in this clause. E.g.

    \generate{\file{p1.sty}{\from{s1.dtx}{foo,bar}}
              \file{p2.sty}{\from{s2.dtx}{baz}
                            \from{s3.dtx}{baz}}
              \file{p3.sty}{\from{s1.dtx}{zip}
                            \from{s2.dtx}{zip}}
             }

will cause DocStrip to read files s1.dtx, s2.dtx, s3.dtx (in that order) and pro-

duce files p1.sty, p2.sty, p3.sty.

The restriction to at most 16 output streams open in a while does not mean that you can produce at most 16 files with one \generate. In the example above only 2 streams are needed, since while s1.dtx is processed only p1.sty and p3.sty are being generated; while reading s2.dtx only p2.sty and p3.sty; and while reading s3.dtx file p2.sty . However example below needs 3 streams:

    \generate{\file{p1.sty}{\from{s1.dtx}{foo,bar}}
              \file{p2.sty}{\from{s2.dtx}{baz}
                            \from{s3.dtx}{baz}}
              \file{p3.sty}{\from{s1.dtx}{zip}
                            \from{s3.dtx}{zip}}
             }

Although while reading s2.dtx file p3.sty is not written it must remain open since some parts of s3.dtx will go to it later.

Sometimes it is not possible to create a file by reading all sources once. Consider the following example:

    \generate{\file{p1.sty}{\from{s1.dtx}{head}
                            \from{s2.dtx}{foo}
                            \from{s1.dtx}{tail}}
              \file{s1.drv}{\from{s1.dtx}{driver}}
             }

To generate p1.sty file s1.dtx must be read twice: first time with option head, then file s2.dtx is read and then s1.dtx again this time with option tail. Doc-Strip handles this case correctly: if inside one \file declaration there are multiple \fromes with the same input file this file is read multiple times.

If the order of \froms specified in one of your \file specifications does not match the order of input files established by previous \files, DocStrip will raise an error and abort. Then you may either read one of next sections or give up and put that file in separate \generate (but then sources will be read again just for that file).

For impatient. Try following algorithm: Find file that is generated from largest number of sources, start writing \generate clause with this file and its sources in proper order. Take other files that are to be generated and add them checking if they don’t contradict order of sources for the first one. If this doesn’t work read next sections.

For mathematicians. Relation “file A must be read before file B” is a partial order on the set of all your source files. Each \from clause adds a chain to this order. What you have to do is to perform a topological sort i.e. to extend partial order to linear one. When you have done it just list your source files in \generate in such a way that order of their first appearance in the clause matches linear order. If this cannot be achieved read next paragraph. (Maybe future versions of DocStrip will perform this sort automatically, so all these troubles will disappear.)

For that who must know that all. There is a diverse case when it’s not possible to achieve proper order of reading source files. Suppose you have to generate two files, first from s1.dtx and s3.dtx (in that order) and second from s2.dtx and s3.dtx. Whatever way you specify this the files will be read in either as s1 s3 s2 or s2 s3 s1. The key to solution is magical macro \needed that marks a file as needed to be input but not directing any output from it to current \file. In our example proper specification is:

    \generate{\file{p1.sty}{\from{s1.dtx}{foo}
                            \needed{s2.dtx}
                            \from{s3.dtx}{bar}}
              \file{p2.sty}{\from{s2.dtx}{zip}
                            \from{s3.dtx}{zap}}
             }

\askforoverwritetrue These macros specify what should happen if a file that is to be generated \askforoverwritefalse already exists. If \askforoverwritetrue is active (the default) the user is asked

whether the file should be overwritten. If however \askforoverwritefalse was issued existing files will be overwritten silently. These switches are local and can be issued in any place in the file even inside \generate clause (between \files however).

\askonceonly You might not want to set \askforoverwritefalse in a batch file as that says that it us always all right to overwrite other people’s files. However for large installations, such as the base L^{A}TEX distribution, being asked individually about hundreds of files is not very helpful either. A batchfile may therefore specify \askonceonly. This means that after the first time the batchfile asks the user a question, the user is given an option of to change the behaviour so that ‘yes’ will be automatically assumed for all future questions. This applies to any use of the DocStrip commamnd \Ask including, but not restricted to, the file overwrite questions controlled by \askforoverwritetrue.

\preamble It is possible to add a number of lines to the output of the DocStrip pro-

\endpreamble
\postamble
\endpostamble

gram. The information you want to add to the start of the output file should be listed between the \preamble and \endpreamble commands; the lines you want to add to the end of the output file should be listed between the \postamble and \endpostamble commands. Everything that DocStrip finds for both the pre- and postamble it writes to the output file, but preceded with value of \MetaPrefix (default is two %-characters). If you include a ^^J character in one of these lines, everything that follows it on the same line is written to a new line in the output file. This ‘feature’ can be used to add a \typeout or \message to the the stripped file.

\declarepreamble Sometimes it is desirable to have different preambles for different files

\declarepostamble
\usepreamble
\usepostamble

of a larger package (e.g., because some of them are customisable configuration files and they should be marked as such). In such a case one can say \declarepreamble\somename, then type in his/her preamble, end it with \endpreamble, and later on \usepreamble\somename to switch to this preamble. The same mechanism works for postambles, \use... declarations are local and can appear inside \generate.

Commands \preamble and \postamble define and activate pre(post)ambles

named \defaultpreamble and \defaultpostamble.

\batchinput The batch file commands can be put into several batch files which are then executed from a master batch file. This is, for example, useful if a distribution consists of several distinct parts. You can then write individual batch files for every part and in addition a master file that simply calls the batch files for the parts. For this, call the individual batch files from the master file with the command \batchinput{⟨file⟩}. Don’t use \input for this purpose, this command should be used only for calling the DocStrip program as explained above and is ignored when used for any other purpose.

\ifToplevel When batch files are nested you may want to suppress certain commands in the lower-level batch files such as terminal messages. For this purpose you can use the \ifToplevel command which executes its argument only if the current batch file is the outermost one. Make sure that you put the opening brace of the argument into the same line as the command itself, otherwise the DocStrip program will get confused.

\showprogress When the option stats is included in DocStrip it can write message to the

\keepsilent terminal as each line of the input file(s) is processed. This message consists of a single character, indicating kind of that particular line. We use the following characters:

% Whenever an input line is a comment %-character is written to the terminal.

. Whenever a code line is encountered a .-character is written on the terminal.

/ When a number of empty lines appear in a row in the input file, at most one of them is retained. The DocStrip program signals the removal of an empty line with the /-character.

< When a ‘guard line’ is found in the input and it starts a block of optionally included code, this is signalled on the terminal by showing the <-character, together with the boolean expression of the guard.

> The end of a conditionally included block of code is indicated by showing the >-character.

This feature is turned on by default when the option stats is included, otherwise it is turned off. The feature can be toggled with the commands \showprogress

and \keepsilent.

4.2.1 Supporting old interface

\generateFile Here is the old syntax for specifing what files are to be generated. It allows specification of just one output file.

\generateFile{⟨output⟩}{⟨ask⟩}{[\from{⟨input⟩}{⟨optionlist⟩}]*}

The meaning of ⟨output⟩, ⟨input⟩ and ⟨optionslist⟩ is just as for \generate. With ⟨ask⟩ you can instruct TEX to either silently overwrite a previously existing file (f) or to issue a warning and ask you if it should overwrite the existing file (t) (it overrides the \askforoverwrite setting).

\include The earlier version of the DocStrip program supported a different kind of com- \processFile mand to tell TEX what to do. This command is less powerful than \generateFile;

it can be used when ⟨output⟩ is created from one ⟨input⟩. The syntax is:

\include{⟨optionlist⟩}

\processFile{⟨name⟩}{⟨inext⟩}{⟨outext⟩}{⟨ask⟩}

This command is based on environments where filenames are constructed of two parts, the name and the extension, separated with a dot. The syntax of this command assumes that the ⟨input⟩ and ⟨output⟩ share the same name and only differ in their extension. This command is retained to be backwards compatible with the older version of DocStrip, but its use is not encouraged.

5 Conditional inclusion of code

When you use the DocStrip program to strip comments out of TEX macro files you have the possibility to make more than one stripped macro file from one documented file. This is achieved by the support for optional code. The optional code is marked in the documented file with a ‘guard’.

A guard is a boolean expression that is enclosed in < and >. It also has to follow the % at the beginning of the line. For example:

    ...
    %<bool>\TeX code
    ...

In this example the line of code will be included in ⟨output⟩ if the option bool is present in the ⟨optionlist⟩ of the \generateFile command.

The syntax for the boolean expressions is:

⟨Expression⟩ ::= ⟨Secondary⟩ [{|, ,} ⟨Secondary⟩]*
⟨Secondary⟩ ::= ⟨Primary⟩ [& ⟨Primary⟩]*
⟨Primary⟩  ::= ⟨Terminal⟩ | !⟨Primary⟩ | (⟨Expression⟩)

The | stands for disjunction, the & stands for conjunction and the ! stands for negation. The ⟨Terminal⟩ is any sequence of letters and evaluates to ⟨true⟩ iff^{3} it occurs in the list of options that have to be included.

Two kinds of optional code are supported: one can either have optional code that ‘fits’ on one line of text, like the example above, or one can have blocks of optional code.

To distinguish both kinds of optional code the ‘guard modifier’ has been introduced. The ‘guard modifier’ is one character that immediately follows the < of the guard. It can be either * for the beginning of a block of code, or / for the end of a block of code^{4}. The beginning and ending guards for a block of code have to be on a line by themselves.

When a block of code is not included, any guards that occur within that block are not evaluated.

6 Those other languages

Since TEX is an open system some of TEX packages include non-TEX files. Some authors use DocStrip to generate PostScript headers, shell scripts or programs in other languages. For them the comments-stripping activity of DocStrip may cause some trouble. This section describes how to produce non-TEX files with DocStrip effectively.

6.1 Stuff DocStrip puts in every file

First problem when producing files in “other” languages is that DocStrip adds some bits to the begining and end of every generated file that may not fit with the syntax of the language in question. So we’ll study carefully what exactly goes where.

The whole text put on begining of file is kept in a macro defined by

\declarepreamble. Every line of input presented to \declarepreamble is

prepended with current value of \MetaPrefix. Standard DocStrip header is inserted before your text, and macros \inFileName, \outFileName and \ReferenceLines are used as placeholders for information which will be filled in later (specifically for each output file). Don’t try to redefine these macros. After

    \declarepreamble\foo
    ____________________________

3iff stands for ‘if and only if’

4To be compatible with the earlier version of DocStrip also + and - are supported as ‘guard modifiers’. However, there is an incompatibility with the earlier version since a line with a +- modified guard is not included inside a block with a guard that evaluates to false, in contrast to the previous behaviour.

    Package FOO for use with TeX
    \endpreamble

macro \foo is defined as

    %%^^J
    %% This is file `\outFileName ',^^J
    %% generated with the docstrip utility.^^J
    \ReferenceLines^^J
    %% ____________________________^^J
    %% Package FOO for use with TeX.

You can play with it freely or even define it from scratch. To embed the preamble in Adobe structured comments just use \edef:

    \edef\foo{\perCent!PS-Adobe-3.0^^J%
              \DoubleperCent\space Title: \outFileName^^J%
              \foo^^J%
              \DoubleperCent\space EndComments}

After that use \usepreamble\foo to select your new preamble. Everything above works as well for postambles.

You may also prevent DocStrip from adding anything to your file, and put any language specific invocations directly in your code:

    \generate{\usepreamble\empty
              \usepostamble\empty
              \file{foo.ps}{\from{mypackage.dtx}{ps}}}

6.2 Meta comments

You can change the prefix used for putting meta comments to output files by redefining \MetaPrefix. Its default value is \DoubleperCent. The preamble uses value of \MetaPrefix current at time of \declarepreamble while meta comments in the source file use value current at time of \generate. Note that this means that you cannot produce concurrently two files using different \MetaPrefixes.

6.3 Verbatim mode

If your programming language uses some construct that can interferes badly with DocStrip (e.g., percent in column one) you may need a way for preventing it from being stripped off. For that purpose DocStrip features ‘verbatim mode’.

A ‘Guard expression’ of the form %<<⟨END-TAG⟩ marks the start of a section that will be copied verbatim upto a line containing only a percent in column 1 followed by ⟨END-TAG⟩. You can select any ⟨END-TAG⟩ you want, but note that spaces count here. Example:

    %<*myblock>
    some stupid()
       #computer<program>

    %<<COMMENT
    % These two lines are copied verbatim (including percents
    %% even if \MetaPrefix is something different than %%).
    %COMMENT
       using*strange@programming<language>
    %</myblock>

And the output is (when stripped with myblock defined):

    some stupid()
       #computer<program>
    % These two lines are copied verbatim (including percents
    %% even if \MetaPrefix is something different than %%).
       using*strange@programming<language>

7 Producing the documentation

We provide a short driver file that can be extracted by the DocStrip program using the the conditional ‘driver’. To allow the use of docstrip.dtx as a program at IniTEX time (e.g., to strip off its own comments) we need to add a bit of primitive code. With this extra checking it is still possible to process this file with L^{A}TEX 2ε to typeset the documentation.

1 ⟨∗driver⟩

If \documentclass is undefined, e.g., if IniTEX or plain TEX is used for formatting, we bypass the driver file.

We use some trickery to avoid issuing \end{document} when the \ifx construction is unfinished. If condition below is true a \fi is constructed on the fly, the \ifx is completed, and the real \fi will never be seen as it comes after \end{document}. On the other hand if condition is false TEX skips over \csname fi\endcsname having no idea that this could stand for \fi, driver is skipped and only then the condition completed.

Additional guard gobble prevents DocStrip from extracting these tricks to real driver file.

2 ⟨∗gobble⟩

 3 \ifx\jobname\relax\let\documentclass\undefined\fi
 4 \ifx\documentclass\undefined
 5 \else \csname fi\endcsname

6 ⟨/gobble⟩

Otherwise we process the following lines which will result in formatting the documentation.

 7 \documentclass{ltxdoc}
 8  \EnableCrossrefs
 9 % \DisableCrossrefs
10 % use \DisableCrossrefs if the
11 % index is ready
12 \RecordChanges
13 % \OnlyDescription

14 \typeout{Expect some Under- and overfull boxes}
15 \begin{document}
16 \DocInput{docstrip.dtx}
17 \end{document}

18 ⟨∗gobble⟩

19 \fi

20 ⟨/gobble⟩ 21 ⟨/driver⟩

8 The implementation

8.1 Initex initializations

Allow this program to run with initex. The Z trickery saves the need to worry about \outer stuff in plain TEX.

22 ⟨∗initex⟩

23 \catcode`\Z=\catcode`\%
24 \ifnum13=\catcode`\~{\egroup\else
25 \catcode`\Z=9

26 Z

27 Z  \catcode`\{=1  \catcode`\}=2
28 Z  \catcode`\#=6  \catcode`\^=7
29 Z  \catcode`\@=11 \catcode`\^^L=13
30 Z  \let\bgroup={  \let\egroup=}

31 Z

32 Z  \dimendef\z@=10 \z@=0pt \chardef\@ne=1 \countdef\m@ne=22 \m@ne=-1
33 Z  \countdef\count@=255

34 Z

35 Z  \def\wlog{\immediate\write\m@ne} \def\space{ }

36 Z

37 Z  \count10=22 % allocates \count registers 23, 24, ...
38 Z  \count15=9 % allocates \toks registers 10, 11, ...
39 Z  \count16=-1 % allocates input streams 0, 1, ...
40 Z  \count17=-1 % allocates output streams 0, 1, ...

41 Z

42 Z  \def\alloc@#1#2#3{\advance\count1#1\@ne#2#3\count1#1\relax}

43 Z

44 Z  \def\newcount{\alloc@0\countdef} \def\newtoks{\alloc@5\toksdef}
45 Z  \def\newread{\alloc@6\chardef}   \def\newwrite{\alloc@7\chardef}

46 Z

47 Z \def\newif#1{%
48 Z   \count@\escapechar \escapechar\m@ne
49 Z     \let#1\iffalse
50 Z     \@if#1\iftrue
51 Z     \@if#1\iffalse
52 Z   \escapechar\count@}
53 Z \def\@if#1#2{%
54 Z   \expandafter\def\csname\expandafter\@gobbletwo\string#1%
55 Z                     \expandafter\@gobbletwo\string#2\endcsname

56 Z                        {\let#1#2}}

57 Z

58 Z  \def\@gobbletwo#1#2{}
59 Z  \def\@gobblethree#1#2#3{}

60 Z

61 Z  \def\loop#1\repeat{\def\body{#1}\iterate}
62 Z  \def\iterate{\body \let\next\iterate \else\let\next\relax\fi \next}
63 Z  \let\repeat\fi

64 Z

65 Z  \def\empty{}

66 Z

67 Z  \def\tracingall{\tracingcommands2 \tracingstats2
68 Z    \tracingpages1 \tracingoutput1 \tracinglostchars1
69 Z    \tracingmacros2 \tracingparagraphs1 \tracingrestores1
70 Z    \showboxbreadth 10000 \showboxdepth 10000 \errorstopmode
71 Z    \errorcontextlines 10000 \tracingonline1 }

72 Z

73 \bgroup}\fi\catcode`\Z=11
74 \let\bgroup={  \let\egroup=}

75 ⟨/initex⟩

8.2 Declarations and initializations

In order to be able to include the @-sign in control sequences its category code is changed to ⟨letter⟩. The ‘program’ guard here allows most of the code to be excluded when extracting the driver file.

76 ⟨∗program⟩

77 \catcode`\@=11

When we want to write multiple lines to the terminal with one statement, we need a character that tells TEX to break the lines. We use ^^J for this purpose.

78 \newlinechar=`\^^J

8.2.1 Switches

\ifGenerate The program will check if a file of the same name as the file it would be creating already exists. The switch \ifGenerate is used to indicate if the stripped file has to be generated.

79 \newif\ifGenerate

\ifContinue The switch \ifContinue is used in various places in the program to indicate if a \loop has to end.

80 \newif\ifContinue

\ifForlist The program contains an implementation of a for-loop, based on plain TEX’s \loop macros. The implementation needs a switch to terminate the loop.

81 \newif\ifForlist

\ifDefault The switch \ifDefault is used to indicate whether the default batch file has to be used.

82 \newif\ifDefault

\ifMoreFiles The switch \ifMoreFiles is used to decide if the user wants more files to be processed. It is used only in interactive mode; initially it evaluates to ⟨true⟩.

83 \newif\ifMoreFiles \MoreFilestrue

\ifaskforoverwrite The switch \askforoverwrite is used to decide if the user should be asked when a file is to be overwritten.

84 \newif\ifaskforoverwrite \askforoverwritetrue

8.2.2 Count registers

\blockLevel Optionally included blocks of code can be nested. The counter \blockLevel will be used to keep track of the level of nesting. Its initial value is zero.

85 \newcount\blockLevel \blockLevel\z@

\emptyLines The count register \emptyLines is used to count the number of consecutive empty input lines. Only the first will be copied to the output file.

86 \newcount\emptyLines \emptyLines \z@

\processedLines \commentsRemoved \commentsPassed \codeLinesPassed To be able to provide the user with some statistics about the stripping process four counters are allocated if the statistics have been included when this program was DocStripped. The number of lines processed is stored in the counter \processedLines. The number of lines containing comments that are not written on the output file is stored in the counter \commentsRemoved; the number of comments copied to the output file is stored in the counter \commentsPassed. The number of lines containing macro code that are copied to the output file is stored in the counter \codeLinesPassed.

87 ⟨∗stats⟩

88 \newcount\processedLines   \processedLines  \z@
89 \newcount\commentsRemoved  \commentsRemoved \z@
90 \newcount\commentsPassed   \commentsPassed  \z@
91 \newcount\codeLinesPassed  \codeLinesPassed \z@
\TotalprocessedLines \TotalcommentsRemoved \TotalcommentsPassed \TotalcodeLinesPassed When more than one file is processed and when statistics have been included we

provide the user also with information about the total amount of lines processed. For this purpose four more count registers are allocated here.

92 \newcount\TotalprocessedLines   \TotalprocessedLines  \z@
93 \newcount\TotalcommentsRemoved  \TotalcommentsRemoved \z@
94 \newcount\TotalcommentsPassed   \TotalcommentsPassed  \z@
95 \newcount\TotalcodeLinesPassed  \TotalcodeLinesPassed \z@

96 ⟨/stats⟩

\NumberOfFiles When more than one file is processed, the number of files is stored in the count

register \NumberOfFiles.
97 \newcount\NumberOfFiles \NumberOfFiles\z@

8.2.3 I/O streams

\inFile For reading the file with documented TEX-code, an input stream \inFile is allocated.

98 \newread\inFile

\ttyin \ttyout Communication with the user goes through (nonexistent) stream 16.

99 \chardef\ttyin16
100 \chardef\ttyout16

\inputcheck This stream is only used for checking for existence of files.

101 \newread\inputcheck

\ifToplevel Execute the argument if current batch file is the outermost one. Otherwise suppress it.

102 \newif\iftopbatchfile \topbatchfiletrue
103 \def\ifToplevel{\relax\iftopbatchfile
104 \expandafter\iden \else \expandafter\@gobble\fi}

\batchinput When the file docstrip.tex is read because of an \input statement in a batch file we have to prevent an endless loop (well, limited by TEX’s stack). Therefore we save the original primitive \input and define a new macro with an argument delimited by ␣ (i.e. a space) that just gobbles the argument. Since the end-of-line character is converted by TEX to a space. This means that \input is not available as a command within batch files.

\@@input We therefore keep a copy of the original under the name \@@input for internal use. If DocStrip runs under L^{A}TEX this command is already defined, so we make a quick test.

105 \ifx\undefined\@@input \let\@@input\input\fi

To allow the nesting of batch files the \batchinput command is provided it takes one argument, the name of the batch file to switch to.

106 \def\batchinput#1{%

We start a new group and locally redefine \batchFile to hold the new batch file name. We toggle the \iftopbatchfile switch since this definitely is not top batch file.

107 \begingroup
108  \def\batchfile{#1}%
109  \topbatchfilefalse
110  \Defaultfalse
111  \usepreamble\org@preamble
112  \usepostamble\org@postamble
113  \let\destdir\WriteToDir

After this we can simply call \processbatchFile which will open the new batch file and read it until it is exhausted. Note that if the batch file is not available, or misspelled this routine will produce a warning and return.

114  \processbatchFile

The value of \batchfile as well as local definitions of preambles, directories etc. will be restored at this closing \endgroup, so that further processing continues in the calling batch file.

115 \endgroup

116 }

\skip@input And here is the promised redefinition of \input:

117 \def\skip@input#1 {}
118 \let\input\skip@input

8.2.4 Empty macros and macros that expand to a string

\guardStack Because blocks of code that will conditionally be included in the output can be nested, a stack is maintained to keep track of these blocks. The main reason for this is that we want to be able to check if the blocks are properly nested. The stack itself is stored in \guardStack.

119 \def\guardStack{}

\blockHead The macro \blockHead is used for storing and retrieving the boolean expression that starts a block.

120 \def\blockHead{}

{\yes \atop \y} When the user is asked a question that he has to answer with either ⟨yes⟩ or ⟨no⟩, his response has to be evaluated. For this reason the macros \yes and \y are defined.

121 \def\yes{yes}
122 \def\y{y}

\n We also define \n for use in DocStrip command files.

123 \def\n{n}

\Defaultbatchile When the DocStrip program has to process a batch file it can look for a batch file with a default name. This name is stored in \DefaultbatchFile.

124 \def\DefaultbatchFile{docstrip.cmd}

\perCent \DoubleperCent \MetaPrefix To be able to display percent-signs on the terminal, a % with category code 12

is stored in \perCent and \DoubleperCent. The macro \MetaPrefix is put on

begining of every meta-comment line. It is defined indirect way since some applications need redefining it.

125 {\catcode`\%=12
126 \gdef\perCent{%}
127 \gdef\DoubleperCent{%%}

128 }

129 \let\MetaPrefix\DoubleperCent

In order to allow formfeeds in the input we define a one-character control sequence

^^L.
130 \def^^L{ }

The only result of using \Name is slowing down execution since its typical use (e.g., \Name\def{foo bar}...) has exactly the same number of tokens as its expansion. However I think that it’s easier to read. The meaning of \Name as a black box is: “construct a name from second parameter and then pass it to your first parameter as a parameter”.

\@stripstring is used to get tokens building name of a macro without leading backslash.

131 \def\Name#1#2{\expandafter#1\csname#2\endcsname}
132 \def\@stripstring{\expandafter\@gobble\string}

8.2.5 Miscellaneous variables

\sourceFileName The macro \sourceFileName is used to store the name of the current input file.

\batchfile The macro \batchfile is used to store the name of the batch file.

\inLine The macro \inLine is used to store the lines, read from the input file, before further processing.

\answer When some interaction with the user is needed the macro \answer is used to store his response.

\tmp Sometimes something has to be temporarily stored in a control sequence. For these purposes the control sequence \tmp is used.

8.3 Support macros

8.3.1 The stack mechanism

It is possible to have ‘nested guards’. This means that within a block of optionally included code a subgroup is only included when an additional option is specified. To keep track of the nesting of the guards the currently ‘open’ guard can be pushed on the stack \guardStack and later popped off the stack again. The macros that implement this stack mechanism are loosely based on code that is developed in the context of the L^{A}TEX3 project.

To be able to implement a stack mechanism we need a couple of support macros.

\eltStart \eltEnd The macros \eltStart and \eltEnd are used to delimit a stack element. They are both empty.

133 \def\eltStart{}
134 \def\eltEnd{}

\qStop The macro \qStop is a so-called ‘quark’, a macro that expands to itself^{5}.

135 \def\qStop{\qStop}

\pop The macro \pop⟨stack⟩⟨cs⟩ ‘pops’ the top element from the stack. It assigns the value of the top element to ⟨cs⟩ and removes it from ⟨stack⟩. When ⟨stack⟩ is empty a warning is issued and ⟨cs⟩ is assigned an empty value.

136 \def\pop#1#2{%
137 \ifx#1\empty
138  \Msg{Warning: Found end guard without matching begin}%
139  \let#2\empty
140 \else

To be able to ‘peel’ off the first guard we use an extra macro \popX that receives both the expanded and the unexpanded stack in its arguments. The expanded stack is delimited with the quark \qStop.

141  \def\tmp{\expandafter\popX #1\qStop #1#2}%
142  \expandafter\tmp\fi}

\popX When the stack is expanded the elements are surrounded with \eltStart and \eltEnd. The first element of the stack is assigned to #4.

143 \def\popX\eltStart #1\eltEnd #2\qStop #3#4{\def#3{#2}\def#4{#1}}

\push Guards can be pushed on the stack using the macro \push⟨stack⟩⟨guard⟩. Again we need a secondary macro (\pushX) that has both the expanded and the unexpanded stack as arguments.

144 \def\push#1#2{\expandafter\pushX #1\qStop #1{\eltStart #2\eltEnd}}

\pushX The macro \pushX picks up the complete expansion of the stack as its first argument and places the guard in #3 on the ‘top’.

145 \def\pushX #1\qStop #2#3{\def #2{#3#1}}

8.3.2 Programming structures

\forlist When the program is used in interactive mode the user can supply a list of files that have to be processed. In order to process this list a for-loop is needed. This implementation of such a programming construct is based on the use of the \loop{⟨body⟩}\repeat macro that is defined in plain TEX. The syntax for this loop is:

\for⟨control sequence⟩ := ⟨list⟩ \do ⟨body⟩

\od

The ⟨list⟩ should be a comma separated list.

The first actions that have to be taken are to set the switch \ifForlist to ⟨true⟩ and to store the loop condition in the macro \ListCondition. This is done using an \edef to allow for a control sequence that contains a ⟨list⟩.

5The concept of ‘quarks’ is developed for the L^{A}TEX3 project.

146 \def\forlist#1:=#2\do#3\od{%
147  \edef\ListCondition{#2}%
148  \Forlisttrue

Then we start the loop. We store the first element from the \ListCondition in the macro that was supplied as the first argument to \forlist. This element is then removed from the \ListCondition.

149  \loop
150  \edef#1{\expandafter\FirstElt\ListCondition,\empty.}%
151  \edef\ListCondition{\expandafter\OtherElts\ListCondition,\empty.}%

When the first element from the ⟨list⟩ is empty, we are done processing, so we switch \ifForlist to ⟨false⟩. When it is not empty we execute the third argument that should contain TEX commands to execute.

152  \ifx#1\empty \Forlistfalse \else#3\fi

Finally we test the switch \ifForlist to decide whether the loop has to be continued.

153  \ifForlist
154  \repeat}

\FirstElt The macro \FirstElt is used to get the first element from a comma-separated list.

155 \def\FirstElt#1,#2.{#1}

\OtherElts The macro \OtherElts is used to get all elements but the first element from a comma-separated list.

156 \def\OtherElts#1,#2.{#2}

\whileswitch When the program is used in interactive mode the user might want to process several files with different options or extensions. This goal could be reached by running the program several times, but it is more user-friendly to ask if he would like to process more files when we are done processing his last request. To accomplish this we need the implementation of a while-loop. Again plain TEX’s \loop{⟨body⟩}\repeat is used to implement this programming structure.

The syntax for this loop is:

\whileswitch⟨switch⟩ \fi ⟨list⟩ {⟨body⟩}

The first argument to this macro has to be a switch, defined using \newif; the second argument contains the statements to execute while the switch evaluates to ⟨true⟩.

157 \def\whileswitch#1\fi#2{#1\loop#2#1\repeat\fi}

8.3.3 Output streams allocator

For each of sixteen output streams available we have a macro named \s@0 through \s@15 saying if the stream is assigned to a file (1) or not (0). Initially all streams are not assigned.

We also declare 16 counters which will be needed by the conditional code inclusion algorithm.

158 \ifx\@tempcnta\undefined \newcount\@tempcnta \fi
159 \@tempcnta=0
160 \loop
161 \Name\chardef{s@\number\@tempcnta}=0
162 \csname newcount\expandafter\endcsname%
163 \csname off@\number\@tempcnta\endcsname
164 \advance\@tempcnta1
165 \ifnum\@tempcnta<16\repeat

We will use The TEXbook style list to search through streams.

166 \let\s@do\relax
167 \edef\@outputstreams{%
168 \s@do\Name\noexpand{s@0}\s@do\Name\noexpand{s@1}%
169 \s@do\Name\noexpand{s@2}\s@do\Name\noexpand{s@3}%
170 \s@do\Name\noexpand{s@4}\s@do\Name\noexpand{s@5}%
171 \s@do\Name\noexpand{s@6}\s@do\Name\noexpand{s@7}%
172 \s@do\Name\noexpand{s@8}\s@do\Name\noexpand{s@9}%
173 \s@do\Name\noexpand{s@10}\s@do\Name\noexpand{s@11}%
174 \s@do\Name\noexpand{s@12}\s@do\Name\noexpand{s@13}%
175 \s@do\Name\noexpand{s@14}\s@do\Name\noexpand{s@15}%
176 \noexpand\@nostreamerror

177 }

\@nostreamerror \@streamfound When \@outputstreams is executed \s@do is defined to do something on condition

of some test. If condition always fails macro \@nostreamerror on the end of the list causes an error. When condition succeeds \@streamfound is called, which gobbles rest of the list including the ending \@nostreamerror. It also gobbles \fi ending the condition, so the \fi is reinserted.

178 \def\@nostreamerror{\errmessage{No more output streams!}}
179 \def\@streamfound#1\@nostreamerror{\fi}

\@stripstr is auxiliary macro eating characters \s@ (backslash,s,@). It is defined in somewhat strange way since \s@ must have all category code 12 (other). This macro is used to extract stream numbers from stream names.

180 \bgroup\edef\x{\egroup
181 \def\noexpand\@stripstr\string\s@{}}

182 \x

\StreamOpen \StreamPut \StreamClose Here is stream opening operator. Its parameter should be a macro named the same as the external file being opened. E.g., to write to file foo.tex use

 \StreamOpen\foo, then \StreamPut\foo and \StreamClose\foo.
183 \chardef\stream@closed=16
184 \def\StreamOpen#1{%
185 \chardef#1=\stream@closed
186 \def\s@do##1{\ifnum##1=0
187  \chardef#1=\expandafter\@stripstr\string##1 %

188  \global\chardef##1=1 %
189  \immediate\openout#1=\csname pth@\@stripstring#1\endcsname %
190  \@streamfound
191  \fi}
192 \@outputstreams

193 }

194 \def\StreamClose#1{%
195 \immediate\closeout#1%
196 \def\s@do##1{\ifnum#1=\expandafter\@stripstr\string##1 %
197  \global\chardef##1=0 %
198  \@streamfound
199  \fi}
200 \@outputstreams
201 \chardef#1=\stream@closed

202 }

203 \def\StreamPut{\immediate\write}

8.3.4 Input and Output

\maybeMsg \showprogress \keepsilent When this program is used it can optionally show its progress on the terminal. In that case it will write a special character to the terminal (and the transcript file) for each input line. This option is on by default when statistics are included in docstrip.tex. It is off when statistics are excluded. The commands \showprogress and \keepsilent can be used to choose otherwise.

204 \def\showprogress{\let\maybeMsg\message}
205 \def\keepsilent{\let\maybeMsg\@gobble}

206 ⟨∗stats⟩

207 \showprogress

208 ⟨/stats⟩

209 ⟨−stats⟩\keepsilent

\Msg For displaying messages on the terminal the macro \Msg is defined to write immediately to \ttyout.

210 \def\Msg{\immediate\write\ttyout}

\Ask The macro \Ask{⟨cs⟩}{⟨string⟩} is a slightly modified copy of the L^{A}TEX macro \typein. It is used to ask the user a question. The ⟨string⟩ will be displayed on his terminal and the response will be stored in the ⟨cs⟩. The trailing space left over from the carriage return is stripped off by the macro \strip. If the user just types a carriage return, the result will be an empty macro.

211 \def\iden#1{#1}
212 \def\strip#1#2 \@gobble{\def #1{#2}}
213 \def\@defpar{\par}
214 \def\Ask#1#2{%
215  \message{#2}\read\ttyin to #1\ifx#1\@defpar\def#1{}\else
216  \iden{\expandafter\strip
217  \expandafter#1#1\@gobble\@gobble} \@gobble\fi}

\OriginalAsk
218 \let\OriginalAsk=\Ask
\askonceonly
219 \def\askonceonly{%
220 \def\Ask##1##2{%
221  \OriginalAsk{##1}{##2}%
222  \global\let\Ask\OriginalAsk
223  \Ask\noprompt{%
224  By default you will be asked this question for every file.^^J%
225  If you enter `y' now,^^J%
226  I will asssume `y' for all future questions^^J%
227  without prompting.}%
228  \ifx\y\noprompt\let\noprompt\yes\fi
229  \ifx\yes\noprompt\gdef\Ask####1####2{\def####1{y}}\fi}}

8.3.5 Miscellaneous

\@gobble A macro that has an argument and puts it in the bitbucket.

230 \def\@gobble#1{}

\Endinput When a doc file contains a \endinput on a line by itself this normally means that anything following in this file should be ignored. Therefore we need a macro containing \endinput as its replacement text to check this against \inLine (the current line from the current input file). Of course the backslash has to have the correct \catcode. One way of doing this is feeding \\ to the \string operation and afterwards removing one of the \ characters.

231 \edef\Endinput{\expandafter\@gobble\string\\endinput}

\makeOther During the process of reading a file with TEX code the category code of all special characters has to be changed to ⟨other⟩. The macro \makeOther serves this purpose.

232 \def\makeOther#1{\catcode`#1=12\relax}

\end For now we want the DocStrip program to be compatible with both plain TEX and L^{A}TEX. L^{A}TEX hides plain TEX’s \end command and calls it \@@end. We unhide it here.

233 \ifx\undefined\@@end\else\let\end\@@end\fi

\@addto A macro extending macro’s definition. The trick with \csname is necessary to get around \newtoks being outer in plain TEX and L^{A}TEX version 2.09.

234 \ifx\@temptokena\undefined \csname newtoks\endcsname\@temptokena\fi
235 \def\@addto#1#2{%
236 \@temptokena\expandafter{#1}%
237 \edef#1{\the\@temptokena#2}}

\@ifpresent This macro checks if its first argument is present on a list passed as the second argument. Depending on the result it executes either its third or fourth argument.

238 \def\@ifpresent#1#2#3#4{%
239 \def\tmp##1#1##2\qStop{\ifx!##2!}%
240 \expandafter\tmp#2#1\qStop #4\else #3\fi

241 }

\tospaces This macro converts its argument delimited with \secapsot to appropriate num-

ber of spaces. We need this for smart displaying messages on the screen.

\@spaces are used when we need many spaces in a row.

242 \def\tospaces#1{%
243 \ifx#1\secapsot\secapsot\fi\space\tospaces}
244 \def\secapsot\fi\space\tospaces{\fi}
245 \def\@spaces{\space\space\space\space\space}

\uptospace This macro extracts from its argument delimited with \qStop part up to first occurence of space.

246 \def\uptospace#1 #2\qStop{#1}

\afterfi This macro can be used in conditionals to perform some actions (its first parameter) after the condition is completed (i.e. after reading the matching \fi. Second parameter is used to gobble the rest of \if ... \fi construction (some \else maybe). Note that this won’t work in nested \ifs!

247 \def\afterfi#1#2\fi{\fi#1}

\@ifnextchar This is one of L^{A}TEX’s macros not defined by plain. My devious definition differs from the standard one but functionality is the same.

248 \def\@ifnextchar#1#2#3{\bgroup
249 \def\reserved@a{\ifx\reserved@c #1 \aftergroup\@firstoftwo
250  \else \aftergroup\@secondoftwo\fi\egroup
251  {#2}{#3}}%
252 \futurelet\reserved@c\@ifnch

253 }

254 \def\@ifnch{\ifx \reserved@c \@sptoken \expandafter\@xifnch
255  \else \expandafter\reserved@a
256  \fi}
257 \def\@firstoftwo#1#2{#1}
258 \def\@secondoftwo#1#2{#2}
259 \iden{\let\@sptoken= } %
260 \iden{\def\@xifnch} {\futurelet\reserved@c\@ifnch}

8.4 The evaluation of boolean expressions

For clarity we repeat here the syntax for the boolean expressions in a somewhat changed but equivalent way:

⟨Expression⟩ ::= ⟨Secondary⟩ | ⟨Secondary⟩ {|, ,} ⟨Expression⟩
⟨Secondary⟩ ::= ⟨Primary⟩ | ⟨Primary⟩ & ⟨Secondary⟩
⟨Primary⟩  ::= ⟨Terminal⟩ | !⟨Primary⟩ | (⟨Expression⟩)

The | stands for disjunction, the & stands for conjunction and the ! stands for negation. The ⟨Terminal⟩ is any sequence of letters and evaluates to ⟨true⟩ iff it occurs in the list of options that have to be included.

Since we can generate multiple output files from one input, same guard expressions can be computed several times with different options. For that reason we first “compile” the expression to the form of one parameter macro \Expr expanding to nested \ifs that when given current list of options produces 1 or 0 as a result. The idea is to say \if1\Expr{⟨current set of options⟩}...\fi for all output files.

Here is a table recursively defining translations for right sides of the grammar. τ(X) denotes translation of X.

            τ(⟨Terminal⟩) = \t@<Terminal>,#1,<Terminal>,\qStop

τ(!⟨Primary⟩) = \if1 τ(⟨Primary⟩) 0\else1\fi
τ((⟨Expression⟩)) = τ(⟨Expression⟩)
τ(⟨Primary⟩&⟨Secondary⟩) = \if0 τ(⟨Primary⟩) 0\else τ(⟨Secondary⟩) \fi
τ(⟨Secondary⟩|⟨Expression⟩) = \if1 τ(⟨Secondary⟩) 1\else τ(⟨Expression⟩) \fi

\t@<Terminal> denotes macro with name constructed from t@ with appended tokens of terminal. E.g., for terminal foo the translation would be

    \t@foo,#1,foo,\qStop

This will end up in definition of \Expr, so #1 here will be substituted by current list of options when \Expr is called. Macro \t@foo would be defined as

    \def\t@foo#1,foo,#2\qStop{\ifx>#2>0\else1\fi}

When called as above this will expand to 1 if foo is present on current list of options and to 0 otherwise.

Macros below work in “almost expand-only” mode i.e. expression is analyzed only by expansion but we have to define some macros on the way (e.g., \Expr and

\t@foo).

The first parameter of each of these macros is “continuation” (in the sense similar to the language Scheme). Continuation is a function of at least one argument (parameter) being the value of previous steps of computation. For example macro \Primary constructs translation of ⟨Primary⟩ expression. When it decides that expression is completed it calls its continuation (its first argument) passing to it whole constructed translation. Continuation may expect more arguments if it wants to see what comes next on the input.

We will perform recursive descent parse, but definitions will be presented in bottom-up order.

\Terminal ⟨Terminal⟩s are recognized by macro \Terminal. The proper way of calling it is \Terminal{⟨current continuation⟩}{}. Parameters are: continuation, ⟨Terminal⟩ so far and next character from the input. Macro checks if #3 is one of terminalending characters and then takes appropriate actions. Since there are 7 ending chars and probably one \csname costs less than 7 nested \ifs we construct a name and check if it is defined.

We must expand \ifx completely before taking next actions so we use

\afterfi.
261 \def\Terminal#1#2#3{%
262 \expandafter\ifx\csname eT@#3\endcsname\relax

If condition is true #3 belongs to current ⟨Terminal⟩ so we append it to ⟨Terminal⟩- so-far and call \Terminal again.

263  \afterfi{\Terminal{#1}{#2#3}}\else

When condition is false it’s time to end the ⟨Terminal⟩ so we call macro \TerminalX. Next character is reinserted to the input.

In both cases continuation is passed unchanged.

264  \afterfi{\TerminalX{#1}{#2}#3}\fi

265 }

\eT@ Here we define macros marking characters that cannot appear inside terminal. The value is not important as long as it is different from \relax.

266 \Name\let{eT@>}=1
267 \Name\let{eT@&}=1 \Name\let{eT@!}=1
268 \Name\let{eT@|}=1 \Name\let{eT@,}=1
269 \Name\let{eT@(}=1 \Name\let{eT@)}=1

\TerminalX This macro should end scanning of ⟨Terminal⟩. Parameters are continuation and

gathered tokens of ⟨Terminal⟩.

Macro starts by issuing an error message if ⟨Terminal⟩ is empty.

270 \def\TerminalX#1#2{%
271 \ifx>#2> \errmessage{Error in expression: empty terminal}\fi

Then a macro is constructed for checking presence of ⟨Terminal⟩ in options list.

272 \Name\def{t@#2}##1,#2,##2\qStop{\ifx>##2>0\else1\fi}%

And then current continuation is called with translation of ⟨Terminal⟩ according to formula

          τ(⟨Terminal⟩) = \t@<Terminal>,#1,<Terminal>,\qStop
273 #1{\Name\noexpand{t@#2},##1,#2,\noexpand\qStop}%

274 }

\Primary Parameters are continuation and next character from the input.

According to the syntax ⟨Primari⟩es can have three forms. This makes us use even more dirty tricks than usual. Note the \space after a series of \ifxs. This series produces an one digit number of case to be executed. The number is given to \ifcase and \space stops TEX scanning for a ⟨number⟩. Use of \ifcase gives possibility to have one of three actions selected without placing them in nested \ifs and so to use \afterfi.

275 \def\Primary#1#2{%
276 \ifcase \ifx!#20\else\ifx(#21\else2\fi\fi\space

First case is for ! i.e. negated ⟨Primary⟩. In this case we call \Primary recursively but we create new continuation: macro \NPrimary that will negate result passed by \Primary and pass it to current continuation (#1).

277 \afterfi{\Primary{\NPrimary{#1}}}\or

When next character is ( we call \Expression giving it as continuation macro \PExpression which will just pass the result up but ensuring first that a ) comes next.

278 \afterfi{\Expression{\PExpression{#1}}}\or

Otherwise we start a ⟨Terminal⟩. #2 is not passed as ⟨Terminal⟩-so-far but reinserted to input since we didn’t check if it can appear in a ⟨Terminal⟩.

279 \afterfi{\Terminal{#1}{}#2}\fi

280 }

\NPrimary Parameters are continuation and previously computed ⟨Primary⟩. This macro negates result of previous computations according to the rule

τ(!⟨Primary⟩) = \if1 τ(⟨Primary⟩) 0\else1\fi

281 \def\NPrimary#1#2{%
282 #1{\noexpand\if1#20\noexpand\else1\noexpand\fi}%

283 }

\PExpression Parameters: continuation, ⟨Expression⟩, next character from input. We are checking if character is ) and then pass unchanged result to our continuation.

284 \def\PExpression#1#2#3{%
285 \ifx)#3\else
286  \errmessage{Error in expression: expected right parenthesis}\fi
287 #1{#2}}

\Secondary Each ⟨Secondary⟩ expression starts with ⟨Primary⟩. Next checks will be performed

by \SecondaryX.
288 \def\Secondary#1{%
289 \Primary{\SecondaryX{#1}}}

\SecondaryX Parameters: continuation, translation of ⟨Primary⟩, next character. We start by checking if next character is &.

290 \bgroup\catcode`\&=12
291 \gdef\SecondaryX#1#2#3{%
292 \ifx&#3%

If it is we should parse next ⟨Secondary⟩ and then combine it with results so far. Note that \SecondaryXX will have 3 parameters.

293 \afterfi{\Secondary{\SecondaryXX{#1}{#2}}}\else

Otherwise ⟨Secondary⟩ turned out to be just ⟨Primary⟩. We call continuation passing to it translation of that ⟨Primary⟩ not forgetting to reinsert #3 to the input as it does not belong here.

294 \afterfi{#1{#2}#3}\fi

295 }

296 \egroup

\SecondaryXX Parameters: continuation, translation of ⟨Primary⟩, translation of ⟨Secondary⟩. We construct translation of whole construction according to the rule:

τ(⟨Primary⟩&⟨Secondary⟩) = \if0 τ(⟨Primary⟩) 0\else τ(⟨Secondary⟩) \fi

and pass it to our continuation.

297 \def\SecondaryXX#1#2#3{%
298 #1{\noexpand\if0#20\noexpand\else#3\noexpand\fi}}

\Expression Every ⟨Expression⟩ starts with ⟨Secondary⟩. We construct new continuation and

pass it to \Secondary.
299 \def\Expression#1{%
300 \Secondary{\ExpressionX{#1}}}

\ExpressionX Parameters: continuation, translation of ⟨Secondary⟩, next character. We perform check if character is | or ,.

301 \def\ExpressionX#1#2#3{%
302 \if0\ifx|#31\else\ifx,#31\fi\fi0

If it is not ⟨Expression⟩ is just a ⟨Secondary⟩. We pass its translation to continuation and reinsert #3.

303 \afterfi{#1{#2}#3}\else

If we are dealing with complex ⟨Expression⟩ we should parse another \Expression now.

304 \afterfi{\Expression{\ExpressionXX{#1}{#2}}}\fi

305 }

\ExpressionXX Parameters: continuation, translation of ⟨Secondary⟩, translation of ⟨Expression⟩. We finish up translating of ⟨Expression⟩ according to the formula:

τ(⟨Secondary⟩|⟨Expression⟩) = \if1 τ(⟨Secondary⟩) 1\else τ(⟨Expression⟩) \fi

306 \def\ExpressionXX#1#2#3{%
307 #1{\noexpand\if1#21\noexpand\else#3\noexpand\fi}}

\StopParse Here is initial continuation for whole parse process. It will be used by \Evaluate. Note that we assume that expression has > on its end. This macro eventually defines \Expr. Parameters: translation of whole ⟨Expression⟩ and next character from input.

308 \def\StopParse#1#2{%
309 \ifx>#2 \else\errmessage{Error in expression: spurious #2}\fi
310 \edef\Expr##1{#1}}

\Evaluate This macro is used to start parsing. We call \Expression with continuation defined above. On end of expression we append a >.

311 \def\Evaluate#1{%
312 \Expression\StopParse#1>}

8.5 Processing the input lines

\normalLine The macro \normalLine writes its argument (which has to be delimited with \endLine) on all active output files i.e. those with off-counters equal to zero. If statistics are included, the counter \codeLinesPassed is incremented by 1.

313 \def\normalLine#1\endLine{%

314 ⟨∗stats⟩

315 \advance\codeLinesPassed\@ne

316 ⟨/stats⟩

317 \maybeMsg{.}%
318 \def\inLine{#1}%
319 \let\do\putline@do
320 \activefiles

321 }

\putline@do This is a value for \do when copying line to output files.

322 \def\putline@do#1#2#3{%
323 \StreamPut#1{\inLine}}

\removeComment The macro \removeComment throws its argument (which has to be delimited with \endLine) away. When statistics are included in the program the removed comment is counted.

324 %

325 \def\removeComment#1\endLine{%

326 ⟨∗stats⟩

327  \advance\commentsRemoved\@ne

328 ⟨/stats⟩

329  \maybeMsg{\perCent}}

\putMetaComment If a line starts with two consecutive percent signs, it is considered to be a Meta-Comment. Such a comment line is passed on to the output file unmodified.

330 \bgroup\catcode`\%=12
331 \iden{\egroup
332 \def\putMetaComment%}#1\endLine{%

If statistics are included the line is counted.

333 ⟨∗stats⟩

334 \advance\commentsPassed\@ne

335 ⟨/stats⟩

The macro \putMetaComment has one argument, delimited with \endLine. It brings the source line with %% stripped. We prepend to it \MetaPrefix (which can be different from %%) and send the line to all active files.

336 \edef\inLine{\MetaPrefix#1}%
337 \let\do\putline@do
338 \activefiles

339 }

\processLine Each line that is read from the input stream has to be processed to see if it has to be written on the output stream. This task is performed by calling the macro \processLine. In order to do that, it needs to check whether the line starts with a ‘%’. Therefore the macro is globally defined within a group. Within this group the category code of ‘%’ is changed to 12 (other). Because a comment character is needed, the category code of ‘*’ is changed to 14 (comment character).

The macro increments counter \processedLines by 1 if statistics are included. We cannot include this line with %<*stats> since the category of % is changed and the file must be loadable unstripped. So the whole definition is repeated embedded in guards.

The next token from the input stream is passed in #1. If it is a ‘%’ further processing has to be done by \processLineX; otherwise this is normal (not commented out) line.

In either case the character read is reinserted to the input as it may have to be written out.

340 ⟨∗!stats⟩

341 \begingroup
342 \catcode`\%=12 \catcode`\*=14
343 \gdef\processLine#1{*
344 \ifx%#1
345  \expandafter\processLineX
346 \else
347  \expandafter\normalLine
348 \fi
349 #1}
350 \endgroup

351 ⟨/!stats⟩ 352 ⟨∗stats⟩

353 \begingroup
354 \catcode`\%=12 \catcode`\*=14
355 \gdef\processLine#1{*
356 \advance\processedLines\@ne
357 \ifx%#1
358  \expandafter\processLineX
359 \else
360  \expandafter\normalLine
361 \fi
362 #1}
363 \endgroup

364 ⟨/stats⟩

\processLineX This macro is also defined within a group, because it also has to check if the next

token in the input stream is a ‘%’ character.

If the second token in the current line happens to be a ‘%’, a ⟨MetaComment⟩ has been found. This has to be copied in its entirety to the output. Another possible second character is ‘<’, which introduces a guard expression. The processing of such an expression is started by calling \checkOption.

When the token was neither a ‘%’ nor a ‘<’, the line contains a normal comment that has to be removed.

We express conditions in such a way that all actions appear on first nesting level of \ifs. In such conditions just one expandafter pushes us outside whole construction. A thing to watch here is \relax. It stops search for numeric constant. If it wasn’t here TEX would expand the first case of \ifcase before knowing the value.

365 \begingroup
366 \catcode`\%=12 \catcode`\*=14
367 \gdef\processLineX%#1{*
368 \ifcase\ifx%#10\else
369  \ifx<#11\else 2\fi\fi\relax
370  \expandafter\putMetaComment\or
371  \expandafter\checkOption\or
372  \expandafter\removeComment\fi
373 #1}
374 \endgroup

8.6 The handling of options

\checkOption When the macros that process a line have found that the line starts with ‘%<’, a guard line has been encountered. The first character of a guard can be an asterisk (*), a slash (/) a plus (+), a minus (-), a less-than sign (<) starting verbatim mode or any other character that can be found in an option name. This means that we have to peek at the next token and decide what kind of guard we have.

We reinsert #1 as it may be needed by \doOption.

375 \def\checkOption<#1{%
376 \ifcase
377  \ifx*#10\else \ifx/#11\else
378  \ifx+#12\else \ifx-#13\else
379  \ifx<#14\else 5\fi\fi\fi\fi\fi\relax
380 \expandafter\starOption\or
381 \expandafter\slashOption\or
382 \expandafter\plusOption\or
383 \expandafter\minusOption\or
384 \expandafter\verbOption\or
385 \expandafter\doOption\fi
386 #1}

\doOption When no guard modifier is found by \checkOptions, the macro \doOption is called. It evaluates a boolean expression. The result of this evaluation is stored in \Expr. The guard only affects the current line, so \do is defined in such a way that depending on the result of the test \if1\Expr{⟨options⟩}, the current line is either copied to the output stream or removed. Then the test is computed for all active output files.

387 \def\doOption#1>#2\endLine{%
388 \maybeMsg{<#1 . >}%
389 \Evaluate{#1}%
390 \def\do##1##2##3{%

391  \if1\Expr{##2}\StreamPut##1{#2}\fi

392 }%

393 \activefiles

394 }

\plusOption When a ‘+’ is found as a guard modifier, \plusOption is called. This macro is very similar to \doOption, the only difference being that displayed message now contains ‘+’.

395 \def\plusOption+#1>#2\endLine{%
396 \maybeMsg{<+#1 . >}%
397 \Evaluate{#1}%
398 \def\do##1##2##3{%
399  \if1\Expr{##2}\StreamPut##1{#2}\fi

400 }%

401 \activefiles

402 }

\minusOption When a ‘-’ is found as a guard modifier, \minusOption is called. This macro is very similar to \plusOption, the difference is that condition is negated.

403 \def\minusOption-#1>#2\endLine{%
404 \maybeMsg{<-#1 . >}%
405 \Evaluate{#1}%
406 \def\do##1##2##3{%
407  \if1\Expr{##2}\else \StreamPut##1{#2}\fi

408 }%

409 \activefiles

410 }

\starOption When a ‘*’ is found as a guard modifier, \starOption is called. In this case a block of code will be included in the output on the condition that the guard expression evaluates to ⟨true⟩.

The current line is gobbled as #2, because it only contains the guard and possibly a comment.

411 \def\starOption*#1>#2\endLine{%

First we optionally write a message to the terminal to indicate that a new option starts here.

412 \maybeMsg{<*#1}%

Then we push the current contents of \blockHead on the stack of blocks, \guardStack and increment the counter \blockLevel to indicate that we are now one level of nesting deeper.

413 \expandafter\push\expandafter\guardStack\expandafter{\blockHead}%
414 \advance\blockLevel\@ne

The guard for this block of code is now stored in \blockHead.

415 \def\blockHead{#1}%

Now we evaluate guard expression for all output files updating off-counters. Then we create new list of active output files. Only files that were active in the outer block can remain active now.

416 \Evaluate{#1}%
417 \let\do\checkguard@do
418 \outputfiles
419 \let\do\findactive@do
420 \edef\activefiles{\activefiles}

421 }

\checkguard@do This form of \do updates off-counts according to the value of guard expression.

422 \def\checkguard@do#1#2#3{%

If this block of code occurs inside another block of code that is not included in the output, we increment the off counter. In that case the guard expression will not be evaluated, because a block inside another block that is excluded from the output will also be excluded, regardless of the evaluation of its guard.

423 \ifnum#3>0
424  \advance#3\@ne

When the off count has value 0, we have to evaluate the guard expression. If the result is ⟨false⟩ we increase the off-counter.

425 \else
426  \if1\Expr{#2}\else
427  \advance#3\@ne\fi
428 \fi}

\findactive@do This form of \do picks elements of output files list which have off-counters equal to zero.

429 \def\findactive@do#1#2#3{%
430 \ifnum#3=0
431  \noexpand\do#1{#2}#3\fi}

\slashOption The macro \slashOption is the counterpart to \starOption. It indicates the end of a block of conditionally included code. We store the argument in the temporary control sequence \tmp.

432 \def\slashOption/#1>#2\endLine{%
433 \def\tmp{#1}%

When the counter \blockLevel has a value less than 1, this ‘end-of-block’ line has no corresponding ‘start-of-block’. Therefore we signal an error and ignore this end of block.

434 \ifnum\blockLevel<\@ne
435  \errmessage{Spurious end block </\tmp> ignored}%

Next we compare the contents of \tmp with the contents of \blockHead. The latter macro contains the last guard for a block of code that was encountered. If the contents match, we pop the previous guard from the stack.

436 \else
437  \ifx\tmp\blockHead
438  \pop\guardStack\blockHead

When the contents of the two macros don’t match something is amiss. We signal

Is this the desired be- this to the user, but accept the ‘end-of-block’. haviour??

439  \else
440  \errmessage{Found </\tmp> instead of </\blockHead>}%
441  \fi

When the end of a block of optionally included code is encountered we optionally signal this on the terminal and decrement the counter \blockLevel.

442  \maybeMsg{>}%
443  \advance\blockLevel\m@ne

The last thing that has to be done is to decrement off-counters and make new list of active files. Now whole list of output files has to be searched since some inactive files could have been reactivated.

444 \let\do\closeguard@do
445 \outputfiles
446 \let\do\findactive@do
447 \edef\activefiles{\outputfiles}
448 \fi

449 }

\closeguard@do This macro decrements non-zero off-counters.

450 \def\closeguard@do#1#2#3{%
451 \ifnum#3>0
452  \advance#3\m@ne
453 \fi}

\verbOption This macro is called when a line starts with %<<. It reads a bunch of lines in verbatim mode: the lines are passed unchanged to the output without even checking for starting %. This way of processing ends when a line containing only a percent sign followed by stop mark given on the %<< line is found.

454 \def\verbOption<#1\endLine{{%
455 \edef\verbStop{\perCent#1}\maybeMsg{<<<}%
456 \let\do\putline@do
457 \loop
458  \ifeof\inFile\errmessage{Source file ended while in verbatim
459  mode!}\fi
460  \read\inFile to \inLine
461 \if 1\ifx\inLine\verbStop 0\fi 1% if not inLine==verbStop
462  \activefiles
463  \maybeMsg{.}%
464 \repeat
465 \maybeMsg{>}%

466 }}

8.7 Batchfile commands

DocStrip keeps information needed to control inclusion of sources in several list structures. Lists are macros expanding to a series of calls to macro \do with two or three parameters. Subsequently \do is redefined in various ways and list macros sometimes are executed to perform some action on every element, and sometimes are used inside an \edef to make new list of elements having some properties. For every input file ⟨infile⟩ the following lists are kept:

\b@⟨infile⟩ the “open list”—names of all output files such that their generation should start with reading of ⟨infile⟩,

\o@⟨infile⟩ the “output list”—names of all output files generated from that source together with suitable sets of options (guards),

\e@⟨infile⟩ the “close list”—names of all output files that should be closed when this source is read.

For every output file name ⟨outfile⟩ DocStrip keeps following information:

\pth@⟨outfile⟩ full pathname (including file name),

\ref@⟨outfile⟩ reference lines for the file,

\in@⟨outfile⟩ names of all source files separated with spaces (needed by \InFileName),

\pre@⟨outfile⟩ preamble template (as defined with \declarepreamble),

\post@⟨outfile⟩ postamble template.

\generate This macro executes its argument in a group. \inputfiles is a list of files to be read, \filestogenerate list of names of output files (needed for the message below). \files contained in #1 define \inputfiles in such a way that all that has to be done when the parameter is executed is to call this macro. \inputfiles command is called over and over again until no output files had to be postponed.

467 \def\generate#1{\begingroup
468 \let\inputfiles\empty \let\filestogenerate\empty
469 \let\file\@file

470 #1

471 \ifx\filestogenerate\empty\else
472 \Msg{^^JGenerating file(s) \filestogenerate}\fi
473 \def\inFileName{\csname in@\outFileName\endcsname}%
474 \def\ReferenceLines{\csname ref@\outFileName\endcsname}%
475 \processinputfiles
476 \endgroup}

\processinputfiles This is a recurrent function which processes input files until they are all gone.

477 \def\processinputfiles{%
478 \let\newinputfiles\empty
479 \inputfiles
480 \let\inputfiles\newinputfiles
481 \ifx\inputfiles\empty\else
482  \expandafter\processinputfiles
483 \fi

484 }

\file The first argument is the file to produce, the second argument contains the list of

input files. Each entry should have the format \from{⟨filename.ext⟩}{⟨options⟩}.

The switch \ifGenerate is initially set to ⟨true⟩.

485 \def\file#1#2{\errmessage{Command `\string\file' only allowed in
486  argument to `\string\generate'}}
487 \def\@file#1{%
488 \Generatetrue

Next we construct full path name for output file and check if we have to be careful about overwriting existing files. If the user specified \askforoverwritetrue we will ask him if he wants to overwrite an existing file. Otherwise we simply go ahead.

489 \makepathname{#1}%
490 \ifaskforoverwrite

We try to open a file with the name of the output file for reading. If this succeeds the file exists and we ask the user if he wants to overwrite the file.

491  \immediate\openin\inFile\@pathname\relax
492  \ifeof\inFile\else
493  \Ask\answer{File \@pathname\space already exists
494  \ifx\empty\destdir somewhere \fi
495  on the system.^^J%
496  Overwrite it%
497  \ifx\empty\destdir\space if necessary\fi
498  ? [y/n]}%

We set the switch \ifGenerate according to his answer. We allow for both “y” and “yes”.

499  \ifx\y  \answer \else
500  \ifx\yes\answer \else
501  \Generatefalse\fi\fi\fi

Don’t forget to close the file just opened as we want to write to it.

502  \closein\inFile
503 \fi

If file is to be generated we save its destination pathname and pass control to macro \@fileX. Note that file name is turned into control sequence and \else branch is skipped before calling \@fileX.

504 \ifGenerate
505 \Name\let{pth@#1}\@pathname
506 \@addto\filestogenerate{\@pathname\space}%
507 \Name\@fileX{#1\expandafter}%
508 \else

In case we were not allowed to overwrite an existing file we inform the user that we are not generating his file and we gobble \from specifications.

509  \Msg{Not generating file \@pathname^^J}%
510 \expandafter\@gobble
511 \fi

512 }

\@fileX We put name of current output file in \curout and initialize \curinfiles (the list of source files for this output file) to empty—these will be needed by \from. Then we start defining preamble for the current file.

513 \def\@fileX#1#2{%
514 \chardef#1=\stream@closed
515 \def\curout{#1}%
516 \let\curinfiles\empty
517 \let\curinnames\empty
518 \def\curref{\MetaPrefix ^^J%
519  \MetaPrefix\space The original source files were:^^J%
520  \MetaPrefix ^^J}%

Next we execute second parameter. \froms will add reference lines to the preamble.

521 \let\from\@from \let\needed\@needed
522 #2%
523 \let\from\err@from \let\needed\err@needed

We check order of input files.

524 \checkorder

Each \from clause defines \curin to be its first parameter. So now \curin holds name of last input file for current output file. This means that current output file should be closed after processing \curin. We add #1 to proper ‘close list’.

525 \Name\@addto{e@\curin}{\noexpand\closeoutput{#1}}%

Last we save all the interesting information about current file.

526 \Name\let{pre@\@stripstring#1\expandafter}\currentpreamble
527 \Name\let{post@\@stripstring#1\expandafter}\currentpostamble
528 \Name\edef{in@\@stripstring#1}{\expandafter\iden\curinnames}
529 \Name\edef{ref@\@stripstring#1}{\curref}

530 }

\checkorder This macro checks if the order of files in \curinfiles agrees with that of \inputfiles. The coding is somewhat clumsy.

531 \def\checkorder{%
532 \expandafter\expandafter\expandafter
533 \checkorderX\expandafter\curinfiles
534 \expandafter\qStop\inputfiles\qStop

535 }

536 \def\checkorderX(#1)#2\qStop#3\qStop{%
537 \def\tmp##1\readsource(#1)##2\qStop{%
538  \ifx!##2! \order@error
539  \else\ifx!#2!\else
540  \checkorderXX##2%
541  \fi\fi}%
542 \def\checkorderXX##1\readsource(#1)\fi\fi{\fi\fi
543  \checkorderX#2\qStop##1\qStop}%
544 \tmp#3\readsource(#1)\qStop

545 }

546 \def\order@error#1\fi\fi{\fi
547 \errmessage{DOCSTRIP error: Incompatible order of input
548  files specified for file
549  `\iden{\expandafter\uptospace\curin} \qStop'.^^J
550  Read DOCSTRIP documentation for explanation.^^J
551  This is a serious problem, I'm exiting}\end

552 }

\needed \@needed This macro uniquizes name of an input file passed as a parameter and marks it as needed to be input. It is used internally by \from, but can also be issued in argument to \file to influence the order in which files are read.

553 \def\needed#1{\errmessage{\string\needed\space can only be used in
554  argument to \string\file}}
555 \let\err@needed\needed
556 \def\@needed#1{%
557 \edef\reserved@a{#1}%
558 \expandafter\@need@d\expandafter{\reserved@a}}
559 \def\@need@d#1{%
560 \@ifpresent{(#1)}\curinfiles

If #1 is present on list of input files for current output file we add a space on end of its name and try again. The idea is to construct a name that will look different for TEX but will lead to the same file when seen by operating system.

561  {\@need@d{#1 }}%

When it is not we check if #1 is present in the list of files to be processed. If not we add it and initialize list of output files for that input and list of output files that should be closed when this file closes. We also add constructed name to \curinfiles and define \curin to be able to access constructed name from

 \@from.
562  {\@ifpresent{\readsource(#1)}\inputfiles
563  {}{\@addto\inputfiles{\noexpand\readsource(#1)}%
564  \Name\let{b@#1}\empty
565  \Name\let{o@#1}\empty
566  \Name\let{e@#1}\empty}%
567  \@addto\curinfiles{(#1)}%
568  \def\curin{#1}}%

569 }

\from \from starts by adding a line to preamble for output file.

570 \def\from#1#2{\errmessage{Command `\string\from' only allowed in
571  argument to `\string\file'}}
572 \let\err@from\from
573 \def\@from#1#2{%
574 \@addto\curref{\MetaPrefix\space #1 \if>#2>\else
575  \space (with options: `#2')\fi^^J}%

Then we mark the file as needed input file.

576 \needed{#1}%

If this is the first \from in current \file (i.e. if the \curinnames so far is empty) the file name is added to the “open list” for the current input file. And \do⟨current output⟩{⟨options⟩} is appended to the list of output files for current input file.

577 \ifx\curinnames\empty
578  \Name\@addto{b@\curin}{\noexpand\openoutput\curout}%
579 \fi
580 \@addto\curinnames{ #1}%
581 \Name\@addto{o@\curin}{\noexpand\do\curout{#2}}%

582 }

\readsource This macro is called for each input file that is to be processed.

583 \def\readsource(#1){%

We try to open the input file. If this doesn’t succeed, we tell the user so and nothing else happens.

584 \immediate\openin\inFile\uptospace#1 \qStop\relax
585 \ifeof\inFile
586  \errmessage{Cannot find file \uptospace#1 \qStop}%
587 \else

If statistics are included we nullify line counters

588 ⟨∗stats⟩

589  \processedLines\z@
590  \commentsRemoved\z@
591  \commentsPassed\z@
592  \codeLinesPassed\z@

593 ⟨/stats⟩

When the input file was successfully opened, we try to open all needed output files by executing the “open list”. If any of files couldn’t be opened because of number of streams limits, their names are put into \refusedfiles list. This list subsequently becomes the open list for the next pass.

594  \let\refusedfiles\empty
595  \csname b@#1\endcsname
596  \Name\let{b@#1}\refusedfiles

Now all output files that could be opened are open. So we go through the “output list” and for every open file we display a message and zero the off-counter, while closed files are appended to \refusedfiles.

597  \Msg{} \def\@msg{Processing file \uptospace#1 \qStop}
598  \def\change@msg{%
599  \edef\@msg{\@spaces\@spaces\@spaces\space
600  \expandafter\tospaces\uptospace#1 \qStop\secapsot}
601  \let\change@msg\relax}
602  \let\do\showfiles@do
603  \let\refusedfiles\empty
604  \csname o@#1\endcsname

If \refusedfiles is nonempty current source file needs reread, so we append it

to \newinputfiles.

605  \ifx\refusedfiles\empty\else
606  \@addto\newinputfiles{\noexpand\readsource(#1)}
607  \fi

Finally we define \outputfiles and construct off-counters names. Now \dos will have 3 parameters! All output files become active.

608  \let\do\makeoutlist@do
609  \edef\outputfiles{\csname o@#1\endcsname}%
610  \let\activefiles\outputfiles
611  \Name\let{o@#1}\refusedfiles

Now we change the category code of a lot of characters to ⟨other⟩ and make sure that no extra spaces appear in the lines read by setting the \endlinechar to −1.

612  \makeOther\ \makeOther\\\makeOther\$%
613  \makeOther\#\makeOther\^\makeOther\^^K%
614  \makeOther\_\makeOther\^^A\makeOther\%%
615  \makeOther\~\makeOther\{\makeOther\}\makeOther\&%
616  \endlinechar-1\relax

Then we start a loop to process the lines in the file one by one.

617  \loop
618  \read\inFile to\inLine

The first thing we check is whether the current line contains an \endinput. To allow also real \endinput commands in the source file, \endinput is only recognized when it occurs directly at the beginning of a line.

619  \ifx\inLine\Endinput

In this case we output a message to inform the programmer (in case this was a mistake) and end the loop immediately by setting Continue to ⟨false⟩. Note that \endinput is not placed into the output file. This is important in cases where the output file is generated from several doc files.

620  \Msg{File #1 ended by \string\endinput.}%
621  \Continuefalse
622  \else

When the end of the file is found we have to interrupt the loop.

623  \ifeof\inFile
624  \Continuefalse

If the file did not end we check if the input line is empty. If it is, the counter \emptyLines is incremented.

625  \else
626  \Continuetrue
627  \ifx\inLine\empty
628  \advance\emptyLines\@ne
629  \else
630  \emptyLines\z@
631  \fi

When the number of empty lines seen so far exceeds 1, we skip them. If it doesn’t, the expansion of \inLine is fed to \processLine with \endLine appended to indicate the end of the line.

632  \ifnum \emptyLines<2
633  \expandafter\processLine\inLine\endLine
634  \else
635  \maybeMsg{/}%
636  \fi
637  \fi
638  \fi

When the processing of the line is finished, we check if there is more to do, in which case we repeat the loop.

639  \ifContinue
640  \repeat

The input file is closed.

641  \closein\inFile

We close output files for which this was the last input file.

642 \csname e@#1\endcsname

If the user was interested in statistics, we inform him of the number of lines processed, the number of comments that were either removed or passed and the number of codelines that were written to the output file. Also the totals are updated.

643 ⟨∗stats⟩

644  \Msg{Lines \space processed: \the\processedLines^^J%
645  Comments removed: \the\commentsRemoved^^J%
646  Comments \space passed: \the\commentsPassed^^J%
647  Codelines passed: \the\codeLinesPassed^^J}%
648  \global\advance\TotalprocessedLines  by \processedLines
649  \global\advance\TotalcommentsRemoved by \commentsRemoved
650  \global\advance\TotalcommentsPassed  by \commentsPassed
651  \global\advance\TotalcodeLinesPassed by \codeLinesPassed

652 ⟨/stats⟩

The \NumberOfFiles need to be known even if no statistics are gathered so we update it always.

653  \global\advance\NumberOfFiles by \@ne
654  \fi}

\showfiles@do A message is displayed on the terminal telling the user what we are about to do. For each open output file we display one line saying what options it is generated with and the off-counter associated with the file is zeroed. First line contains also name of input file. Names of output files that are closed are appended to

 \refusedfiles.
655 \def\showfiles@do#1#2{%
656 \ifnum#1=\stream@closed
657  \@addto\refusedfiles{\noexpand\do#1{#2}}%
658 \else
659  \Msg{\@msg
660  \ifx>#2>\else\space(#2)\fi
661  \space -> \@stripstring#1}

662  \change@msg
663 \csname off@\number#1\endcsname=\z@
664 \fi

665 }

\makeoutlist@do This macro selects only open output files and constructs names for off-counters.

666 \def\makeoutlist@do#1#2{%
667 \ifnum#1=\stream@closed\else
668  \noexpand\do#1{#2}\csname off@\number#1\endcsname
669 \fi}

\openoutput This macro opens output streams if possible.

670 \def\openoutput#1{%

If both maxfile counters are non-zero…

671 \if 1\ifnum\@maxfiles=\z@ 0\fi
672  \ifnum\@maxoutfiles=\z@ 0\fi1%

… the stream may be opened and counters decremented. But if that cannot be done…

673  \advance\@maxfiles\m@ne
674  \advance\@maxoutfiles\m@ne
675  \StreamOpen#1%
676  \WritePreamble#1%
677 \else

… the file is added to the “refuse list”.

678  \@addto\refusedfiles{\noexpand\openoutput#1}%
679 \fi

680 }

\closeoutput This macro closes open output stream when it is no longer needed and increments maxfiles counters.

681 \def\closeoutput#1{%
682 \ifnum#1=\stream@closed\else
683  \WritePostamble#1%
684  \StreamClose#1%
685  \advance\@maxfiles\@ne
686  \advance\@maxoutfiles\@ne
687 \fi}

8.7.1 Preamble and postamble

\ds@heading This is a couple of lines, stating what file is being written and how it was created.

688 \def\ds@heading{%
689 \MetaPrefix ^^J%
690 \MetaPrefix\space This is file `\outFileName',^^J%
691 \MetaPrefix\space  generated with the docstrip utility.^^J%

692 }

\AddGenerationDate Older versions of DocStrip added the date that any file was generated and the version number of DocStrip. This confused some people as they mistook this for the version/date of the file that was being written. So now this information is not normally written, but a batch file may call this to get an old style header.

693 \def\AddGenerationDate{%
694 \def\ds@heading{%
695  \MetaPrefix ^^J%
696  \MetaPrefix\space This is file `\outFileName', generated %
697  on <\the\year/\the\month/\the\day> ^^J%
698  \MetaPrefix\space with the docstrip utility (\fileversion).^^J%

699 }}

\declarepreamble When a batch file is used the user can specify a preamble of his own that will be written to each file that is created. This can be useful to include an extra copyright notice in the stripped version of a file. Also a warning that both versions of a file should always be distributed together could be written to a stripped file by including it in such a preamble.

Every line that is written to \outFile that belongs to the preamble is preceded by two percent characters. This will prevent DocStrip from stripping these lines off the file.

The preamble should be started with the macro \declarepreamble; it is ended by \endpreamble. All processing is done within a group in order to be able to locally change some values.

\ReferenceLines is let equal \relax to be unexpandable.

700 \let\inFileName\relax
701 \let\outFileName\relax
702 \let\ReferenceLines\relax
703 \def\declarepreamble{\begingroup
704 \catcode`\^^M=13 \catcode`\ =12 %
705 \declarepreambleX}
706 {\catcode`\^^M=13 %
707 \gdef\declarepreambleX#1#2
708 \endpreamble{\endgroup%
709 \def^^M{^^J\MetaPrefix\space}%
710 \edef#1{\ds@heading%
711  \ReferenceLines%
712  \MetaPrefix\space\checkeoln#2\empty}}%
713 \gdef\checkeoln#1{\ifx^^M#1\else\expandafter#1\fi}%

714 }

\declarepostamble Just as a preamble can be specified in a batch file, the same can be done for a

postamble.

The definition of \declarepostamble is very much like the definition above of

\declarepreamble.
715 \def\declarepostamble{\begingroup
716 \catcode`\ =12 \catcode`\^^M=13
717 \declarepostambleX}
718 {\catcode`\^^M=13 %

719 \gdef\declarepostambleX#1#2
720 \endpostamble{\endgroup%
721 \def^^M{^^J\MetaPrefix\space}%
722 \edef#1{\MetaPrefix\space\checkeoln#2\empty^^J%
723  \MetaPrefix ^^J%
724  \MetaPrefix\space End of file `\outFileName'.%
725 }}%

726 }

\usepreamble \usepostamble Macros for selecting [pre/post]amble to be used.

727 \def\usepreamble#1{\def\currentpreamble{#1}}
728 \def\usepostamble#1{\def\currentpostamble{#1}}

\preamble \postamble For backward compatibility we provide these macros defining default preamble and postamble.

729 \def\preamble{\usepreamble\defaultpreamble
730 \declarepreamble\defaultpreamble}
731 \def\postamble{\usepostamble\defaultpostamble
732 \declarepostamble\defaultpostamble}

\org@preamble \org@postamble Default values to use if nothing different is provided.

733 \declarepreamble\org@preamble

734

735 IMPORTANT NOTICE:

736

737 For the copyright see the source file.

738

739 You are *not* allowed to modify this file.

740

741 You are *not* allowed to distribute this file.
742 For distribution of the original source see the terms
743 for copying and modification in the file \inFileName.

744

745 \endpreamble
746 \edef\org@postamble{\string\endinput^^J%
747 \MetaPrefix ^^J%
748 \MetaPrefix\space End of file `\outFileName'.%

749 }

750

751 \let\defaultpreamble\org@preamble
752 \let\defaultpostamble\org@postamble
753 \usepreamble\defaultpreamble
754 \usepostamble\defaultpostamble
\WritePreamble
755 \def\WritePreamble#1{%
756  \edef\outFileName{\@stripstring#1}%

Then the reference lines that tell from what source file(s) the stripped file was created and user supplied preamble.

757  \StreamPut#1{\csname pre@\@stripstring#1\endcsname}}

\WritePostamble Postamble attributed to #1 is written out. The last line written identifies the file again.

758 \def\WritePostamble#1{%
759  \edef\outFileName{\@stripstring#1}%
760  \StreamPut#1{\csname post@\@stripstring#1\endcsname}}

8.8 Support for writing to specified directories

As we’ve seen before every output file is written to directory specifed by the value of \destdir current at the moment of this file’s \file declaration.

\usedir This macro when called should translate its one argument into a directory name and define \destdir to that value. The default for \usedir is to ignore its argument and return name of current directory (if known). This can be changed by commands from docstrip.cfg file.

\showdirectory is used just to display directory name for user’s information.

761 \def\usedir#1{\edef\destdir{\WriteToDir}}
762 \def\showdirectory#1{\WriteToDir}

\BaseDirectory This is config file command for specifing root directory of the TEX hierarchy. It enables the whole directory selecting mechanism by redefining \usedir. First make sure that the directory syntax commands have been set up by calling \@setwritedir, so that the value of \dirsep used by the \edef is (hopefully) correct.

763 \def\BaseDirectory#1{%
764 \@setwritetodir
765 \let\usedir\alt@usedir
766 \let\showdirectory\showalt@directory
767 \edef\basedir{#1\dirsep}}

\convsep This macro loops through slashes in its argument replacing them with current

\dirsep. It should be called \convsep some/directory/name/\qStop (with

slash on the end).

768 \def\convsep#1/#2\qStop{%
769 #1\ifx\qStop#2\qStop \pesvnoc\fi\convsep\dirsep#2\qStop}
770 \def\pesvnoc#1\qStop{\fi}

\alt@usedir Directory name construction macro enabling writing to various directories.

771 \def\alt@usedir#1{%
772 \Name\ifx{dir@#1}\relax
773  \undefined@directory{#1}%
774 \else
775  \edef\destdir{\csname dir@#1\endcsname}%
776 \fi}
777 \def\showalt@directory#1{%
778 \Name\ifx{dir@#1}\relax

779  \showundef@directory{#1}%
780 \else\csname dir@#1\endcsname\fi}

\undefined@directory This macro comes into action when undefined label is spotted. The action is to raise an error and define \destdir to point to the current directory.

781 \def\undefined@directory#1{%
782 \errhelp{docstrip.cfg should specify a target directory for^^J%
783 #1 using \DeclareDir or \UseTDS.}%
784 \errmessage{You haven't defined output directory for `#1'.^^J%
785  Subsequent files will be written to the current directory.}%
786 \let\destdir\WriteToDir

787 }

788 \def\showundef@directory#1{UNDEFINED (label is #1)}

\undefined@TDSdirectory This happens when label is undefined while using TDS. The label is converted to use proper separators and appended to base directory name.

789 \def\undefined@TDSdirectory#1{%
790 \edef\destdir{%
791  \basedir\convsep#1/\qStop

792 }}

793 \def\showundef@TDSdirectory#1{\basedir\convsep#1/\qStop}

\UseTDS Change of behaviour for undefined labels is done simply:

794 \def\UseTDS{%
795 \@setwritetodir
796 \let\undefined@directory\undefined@TDSdirectory
797 \let\showundef@directory\showundef@TDSdirectory

798 }

\DeclareDir This macro remaps some directory name to another.

799 \def\DeclareDir{\@ifnextchar*{\DeclareDirX}{\DeclareDirX\basedir*}}
800 \def\DeclareDirX#1*#2#3{%
801 \@setwritetodir
802 \Name\edef{dir@#2}{#1#3}}

8.8.1 Compatibility with older versions

\generateFile Main macro of previous versions of DocStrip.

803 \def\generateFile#1#2#3{{%
804 \ifx t#2\askforoverwritetrue
805 \else\askforoverwritefalse\fi
806 \generate{\file{#1}{#3}}%

807 }}

To support command files that were written for the first version of DocStrip the commands \include and \processFile are defined here. The use of this interface is not recommended as it may be removed in a future release of DocStrip.

\include To provide the DocStrip program with a list of options that should be included in the output the command \include{⟨Options⟩} can be used. This macro is meant to be used in conjunction with the \processFile command.

808 \def\include#1{\def\Options{#1}}

\processFile The macro \processFile{⟨filename⟩}{⟨inext⟩}{⟨outext⟩}{⟨t|f ⟩} can be used when a single input file is used to produce a single output file. The macro is also used in the interactive mode of the DocStrip program.

The arguments ⟨inext⟩ and ⟨outext⟩ denote the extensions of the input and output files respectively. The fourth argument can be used to specify if an existing file should be overwritten without asking. If ⟨t⟩ is specified the program will ask for permission before overwriting an existing file.

This macro is defined using the more generic macro \generateFile.

809 \def\processFile#1#2#3#4{%
810 \generateFile{#1.#3}{#4}{\from{#1.#2}{\Options}}}
\processfile \generatefile Early versions of DocStrip defined \processfile and \generatefile instead of

the commands as they are defined in this version. To remain upwards compatible, we still provide these commands, but issue a warning when they are used.

811 \def\processfile{\Msg{%
812  ^^Jplease use \string\processFile\space instead of
813  \string\processfile!^^J}%
814  \processFile}
815 \def\generatefile{\Msg{%
816  ^^Jplease use \string\generateFile\space instead of
817  \string\generatefile!^^J}%
818  \generateFile}

8.9 Limiting open file streams

(This section was written by Mark Wooding)

\maxfiles Some operating systems with duff libraries or other restrictions can’t cope with all the files which DocStrip tries to output at once. A configuration file can say \maxfiles{⟨number⟩} to describe the maximum limit for the environment.

I’ll need a counter for this value, so I’d better allocate one.

819 \newcount\@maxfiles

The configuration command \maxfiles is just slightly prettier than an assignment, for L^{A}TEX people. It also gives me an opportunity to check that the limit is vaguely sensible. I need at least 4 streams:

1. A batch file.

2. A sub batch file, which L^{A}TEX’s installation utility uses.

3. An input stream for reading an unstripped file.

4. An output stream for writing a stripped file.

820 \def\maxfiles#1{%
821 \@maxfiles#1\relax
822 \ifnum\@maxfiles<4
823  \errhelp{I'm not a magician.  I need at least four^^J%
824  streams to be able to work properly, but^^J%
825  you've only let me use \the\@maxfiles.}%
826  \errmessage{\noexpand\maxfiles limit is too strict.}%
827  \@maxfiles4
828 \fi

829 }

Since batchfiles are now \inputed there should be no default limit here. I’ll just use some abstract large number.

830 \maxfiles{1972} % year of my birth (MW)

\maxoutfiles Maybe there’s a restriction on just output streams. (Well, there is: I know, because

TEX only allows 16.) I may as well allow the configuration to set this up. Again, I need a counter.

831 \newcount\@maxoutfiles

And now the macro. I need at least one output stream which I think is reasonable.

832 \def\maxoutfiles#1{%
833 \@maxoutfiles=#1\relax
834 \ifnum\@maxoutfiles<1
835  \@maxoutfiles1
836  \errhelp{I'm not a magician.  I need at least one output^^J%
837  stream to be able to do anything useful at all.^^J%
838  Please be reasonable.}%
839  \errmessage{\noexpand\maxoutfiles limit is insane}%
840 \fi

841 }

The default limit is 16, because that’s what TEX says.

842 \maxoutfiles{16}

\checkfilelimit This checks the file limit when a new batch file is started. If there’s fewer than two files left here, we’re not going to be able to strip any files. The file limit counter is local to the group which is set up around \batchinput, so that’s all pretty cool.

843 \def\checkfilelimit{%
844 \advance\@maxfiles\m@ne
845 \ifnum\@maxfiles<2 %
846  \errhelp{There aren't enough streams left to do any unpacking.^^J%
847  I can't do anything about this, so complain at the^^J%
848  person who made such a complicated installation.}%
849  \errmessage{Too few streams left.}%
850  \end
851 \fi

852 }

8.10 Interaction with the user

\strip@meaning Throw away the first part of \meaning output.

853 \def\strip@meaning#1>{}

\processbatchFile When DocStrip is run it always tries to use a batch file. For this purpose it calls the macro \processbatchFile. The first thing is to check if there are any input streams left.

854 \def\processbatchFile{%
855 \checkfilelimit
856 \let\next\relax

Now we try to open the batch file for reading.

857 \openin\inputcheck \batchfile\relax
858 \ifeof\inputcheck

If we didn’t succeed in opening the file, we assume that it does not exist. If we tried the default filename, we silently continue; the DocStrip program will switch to interactive mode in this case.

859  \ifDefault
860  \else

If we failed to open the user-supplied file, something is wrong and we warn him about it. This will also result in a switch to interactive mode.

861  \errhelp
862  {A batchfile specified in \batchinput could not be found.}%
863  \errmessage{^^J%
864  **************************************************^^J%
865  * Could not find your \string\batchfile=\batchfile.^^J%
866  **************************************************}%
867  \fi
868 \else

When we were successful in opening a file, we again have to check whether it was the default file. In that case we tell the user we found that file and ask him if he wants to use it.

869  \ifDefault
870  \Msg{**************************************************^^J%
871  * Batchfile \DefaultbatchFile\space found Use it? (y/n)?}%
872  \Ask\answer{%
873  **************************************************}%
874  \else

When it was the user-supplied file we can safely assume he wants to use it so we

set \answer to y.
875  \let\answer\y
876  \fi

If the macro \answer contains a y we can read in the batchfile. We do it in an indirect way—after completing \ifs.

877  \ifx\answer\y

878  \closein\inputcheck
879  \def\next{\@@input\batchfile\relax}%
880  \fi
881 \fi
882 \next}

\ReportTotals The macro \ReportTotals can be used to report total statistics for all files processed. This code is only included in the program if the option stats is included.

883 ⟨∗stats⟩

884 \def\ReportTotals{%
885 \ifnum\NumberOfFiles>\@ne
886  \Msg{Overall statistics:^^J%
887  Files \space processed: \the\NumberOfFiles^^J%
888  Lines \space processed: \the\TotalprocessedLines^^J%
889  Comments removed: \the\TotalcommentsRemoved^^J%
890  Comments \space passed: \the\TotalcommentsPassed^^J%
891  Codelines passed: \the\TotalcodeLinesPassed}%
892 \fi}

893 ⟨/stats⟩

\SetFileNames The macro \SetFileNames is used when the program runs in interactive mode and the user was asked to supply extensions and a list of filenames.

894 \def\SetFileNames{%
895  \edef\sourceFileName{\MainFileName.\infileext}%
896  \edef\destFileName{\MainFileName.\outfileext}}

\CheckFileNames In interactive mode, the user gets asked for the extensions for the input and output files. Also the name or names of the input files (without extension) is asked for. Then the names of the input and output files are constructed from this information by \SetFileNames. This assumes that the name of the input file is the same as the name of the output file. But we should not write to the same file we’re reading from so the extensions should differ.

The macro \CheckFileNames makes sure that the output goes to a different file to the one where the input comes from.

897 \def\CheckFileNames{%
898  \ifx\sourceFileName\destFileName

If input and output files are the same we signal an error and stop processing.

899  \Msg{^^J%
900  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J%
901  ! It is not possible to read from and write to the same file !^^J%
902  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J}%
903  \Continuefalse
904  \else

If they are not the same we check if the input file exists by trying to open it for reading.

905  \Continuetrue
906  \immediate\openin\inFile \sourceFileName\relax
907  \ifeof\inFile

If an end of file was found, the file couldn’t be opened, so we signal an error and stop processing.

908  \Msg{^^J%
909  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J%
910  ! Your input file `\sourceFileName' was not found !^^J%
911  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J}%
912  \Continuefalse
913  \else

The last check we have to make is if the output file already exists. Therefore we try to open it for reading. As a precaution we first close the input stream.

914  \immediate\closein\inFile
915  \immediate\openin\inFile\destdir \destFileName\relax
916  \ifeof\inFile

If this fails, it didn’t exist and all is well.

917  \Continuetrue
918  \else

If opening of the output file for reading succeeded we have to ask the user if he wants to overwrite it. We assume he doesn’t want to overwrite it, so the switch \ifContinue is initially set to ⟨false⟩. Only if he answers the question positively with ‘y’ or ‘yes’ we set the switch back to ⟨true⟩.

919  \Continuefalse
920  \Ask\answer{File \destdir\destFileName\space already
921  exists
922  \ifx\empty\destdir somewhere \fi
923  on the system.^^J%
924  Overwrite it%
925  \ifx\empty\destdir\space if necessary\fi
926  ? [y/n]}%
927  \ifx\y  \answer \Continuetrue \else
928  \ifx\yes\answer \Continuetrue \else
929  \fi\fi
930  \fi

All checks have been performed now, so we can close any file that was opened just for this purpose.

931  \fi
932  \fi
933  \closein\inFile}

\interactive The macro \interactive implements the interactive mode of the DocStrip program. The macro is implemented using the ⟨while⟩ construction. While the switch \ifMoreFiles remains true, we continue processing.

934 \def\interactive{%
935 \whileswitch\ifMoreFiles\fi%

To keep macro redefinitions local we start a group and ask the user some questions about what he wants us to do.

936 {\begingroup
937  \AskQuestions

The names of the files that have to be processed are stored as a comma-separated list in the macro \filelist by \AskQuestions. We use a ⟨for⟩ loop to process the files one by one.

938  \forlist\MainFileName:=\filelist
939  \do

First the names of the input and output files are constructed and a check is made if all filename information is correct.

940  \SetFileNames
941  \CheckFileNames
942  \ifContinue

If everything was well, produce output file.

943  \generateFile{\destFileName}{f}%
944  {\from{\sourceFileName}{\Options}}
945  \fi%

This process is repeated until \filelist is exhausted.

946  \od
947  \endgroup

Maybe the user wants more files to be processed, possibly with another set of options, so we give him the opportunity.

948  \Ask\answer{More files to process (y/n)?}%
949  \ifx\y  \answer\MoreFilestrue \else
950  \ifx\yes\answer\MoreFilestrue \else

If he didn’t want to process any more files, the switch \ifMoreFiles is set to ⟨false⟩ in order to interrupt the ⟨while⟩ loop.

951  \MoreFilesfalse\fi\fi

952 }}

\AskQuestions The macro \AskQuestions is called by \interactive to get some information

from the user concerning the files that need to be processed.

953 \def\AskQuestions{%
954  \Msg{^^J%
955  ****************************************************}%

We want to know the extension of the input files,

956  \Ask\infileext{%
957  * First type the extension of your input file(s): \space  *}%
958  \Msg{****************************************************^^J^^J%
959  ****************************************************}%

the extension of the output files,

960  \Ask\outfileext{%
961  * Now type the extension of your output file(s) \space: *}%
962  \Msg{****************************************************^^J^^J%
963  ****************************************************}%

if options are to be included and

964  \Ask\Options{%
965  * Now type the name(s) of option(s) to include \space\space: *}%
966  \Msg{****************************************************^^J^^J%
967  ****************************************************^^J%
968  * Finally give the list of input file(s) without \space\space*}%

the name of the input file or a list of names, separated by commas.

969  \Ask\filelist{%
970  * extension seperated by commas if necessary %
971  \space\space\space\space: *}%
972  \Msg{****************************************************^^J}}%

8.11 The main program

When TEX processes the DocStrip program it displays a message about the version of the program and its function on the terminal.

973 \Msg{Utility: `docstrip' \fileversion\space <\filedate>^^J%
974  English documentation \space\space\space <\docdate>}%
975 \Msg{^^J%
976  **********************************************************^^J%
977  * This program converts documented macro-files into fast *^^J%
978  * loadable files by stripping off (nearly) all comments! *^^J%
979  **********************************************************^^J}%

\WriteToDir Macro \WriteToDir is either empty or holds the prefix necessary to read a file from the current directory. Under UNIX this is ./ but a lot of other systems addopted this concept. This macro is a default value for \destdir.

The definition of this macro is now delayed until \@setwritedir is called.

\makepathname This macro should define \@pathname to full path name made by combining current value of \destdir with its one argument being a file name. Its default value defined here is suitable for unix, ms-dos and Macintosh, but for some systems it may be needed to redefine this in docstrip.cfg file. We provide such redefinition for VMS here.

Macro \dirsep holds directory separator specific for a system. Default value suitable for UNIX and DOS is slash. It comes in action when \usedir labels are used directly.

The definition of this macro is now delayed until \@setwritedir is called.

\@setwritedir The following tests try to automatically set \WriteToDir, \dirname and \makepathname

in Unix, Mac, or VMS style. The tests are not run at the top level but held in this macro so that a configuration file has a chance to define \WriteToDir which allows the other two to be set automatically. The tests could more simply be run after the configuration file is read, but the configuration commands like \BaseDirectory need (at least at present) to have \dirsep correctly defined. It does not define any command that is already defined, so by defining these commands a configuration file can produce different effects for special needs. So this command is called by BaseDirectory, \UseTDS, \DeclareDir and finally at the top level after the cfg is run. It begins by redefining itself to be a no-op so it effectively is only called once.

980 \def\@setwritetodir{%
981 \let\setwritetodir\relax
982 \ifx\WriteToDir\@undefined
983  \ifx\@currdir\@undefined
984  \def\WriteToDir{}%
985  \else
986  \let\WriteToDir\@currdir
987  \fi
988 \fi
989 \let\destdir\WriteToDir

VMS Style.

990 \def\tmp{[]}%
991 \ifx\tmp\WriteToDir
992  \ifx\dirsep\@undefined
993  \def\dirsep{.}%
994  \fi
995  \ifx\makepathname\@undefined
996  \def\makepathname##1{%
997  \edef\@pathname{\ifx\WriteToDir\destdir
998  \WriteToDir\else[\destdir]\fi##1}}%
999  \fi

1000 \fi

Unix and Mac styles.

1001 \ifx\dirsep\@undefined
1002  \def\dirsep{/}%
1003  \def\tmp{:}%
1004  \ifx\tmp\WriteToDir
1005  \def\dirsep{:}%

1006 \fi 1007 \fi

1008 \ifx\makepathname\@undefined
1009  \def\makepathname##1{%
1010  \edef\@pathname{\destdir\ifx\empty\destdir\else
1011  \ifx\WriteToDir\destdir\else\dirsep\fi\fi##1}}%
1012 \fi}

If the user has a docstrip.cfg file, use it now. This macro tries to read docstrip.cfg file. If this succeeds executes its first argument, otherwise the second.

1013 \immediate\openin\inputcheck=docstrip.cfg\relax
1014 \ifeof\inputcheck
1015 \Msg{%
1016  ********************************************************^^J%

1017  * No Configuration file found, using default settings. *^^J%
1018  ********************************************************^^J}%
1019 \else
1020 \Msg{%
1021  ******************************************^^J%
1022  * Using Configuration file docstrip.cfg. *^^J%
1023  ******************************************^^J}%
1024 \closein\inputcheck
1025 \afterfi{\@@input docstrip.cfg\relax}

1026 \fi

Now run \@setwritedir in case it has not already been run by a command in a configuration file.

1027 \@setwritetodir

\process@first@batchfile Process the batch file, and then terminate cleanly. This may be set to \relax for ‘new style’ batch files that do not start with \def\batchfile{…

1028 \def\process@first@batchfile{%
1029 \processbatchFile
1030 \ifnum\NumberOfFiles=\z@
1031  \interactive

1032 \fi

1033 \endbatchfile}

\endbatchfile User level command to end batch file processing. At the top level, returns totals and then stops TEX. At nested levels just does \endinput.

1034 \def\endbatchfile{%
1035 \iftopbatchfile

1036 ⟨∗stats⟩

1037  \ReportTotals

1038 ⟨/stats⟩

1039  \expandafter\end
1040 \else
1041  \endinput
1042 \fi}

Now we see whether to process a batch file.

\@jobname Jobname (catcode 12)

1043 \edef\@jobname{\lowercase{\def\noexpand\@jobname{\jobname}}}%
1044 \@jobname

\@docstrip docstrip (catcode 12)

1045 \def\@docstrip{docstrip}%
1046 \edef\@docstrip{\expandafter\strip@meaning\meaning\@docstrip}

First check whether the user has defined the control sequence \batchfile. If he did, it should contain the name of the file to process. If he didn’t, try the current file, unless that is docstrip.tex in which case a default name is tried.

Whether or not the default batch file is used is remembered by setting the switch \ifDefault to ⟨true⟩ or ⟨false⟩.

1047 \Defaultfalse
1048 \ifx\undefined\batchfile

\@jobname is lowercase jobname (catcode 12) \@docstrip is docstrip (catcode 12)

1049 \ifx\@jobname\@docstrip

Set the batchfile to the default

1050  \let\batchfile\DefaultbatchFile
1051  \Defaulttrue

Else don’t process a new batchfile, just carry on with past the end of this file. In this case processing will move to the initial batchfile which must then be terminated by \endbatchfile or TEX will fall to the star prompt.

1052 \else
1053  \let\process@first@batchfile\relax

1054 \fi 1055 \fi

1056 \process@first@batchfile

1057 ⟨/program⟩

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

\@@end . . . . . . . . . . . 233 \@@input . \underline{105}, 879, 1025 \@addto … \underline{234}, 506,

525, 563, 567, 574, 578, 580, 581, 606, 657, 678

\@currdir …. 983, 986 \@defpar . . . . . 213, 215

\@docstrip . \underline{1045}, 1049

\@file . . . . . . . 469, 487 \@fileX . . . . . . 507, \underline{513}

\@firstoftwo . . 249, 257

\@from . . . . . . . 521, 573 \@gobble . . . . . 104,

132, 205, 212, 217, \underline{230}, 231, 510

\@gobblethree . . . . . 59
\@gobbletwo . . 54, 55, 58

\@if . . . . . . . . 50, 51, 53 \@ifnch … 252, 254, 260

                          \@ifnextchar . . \underline{248}, 799
                          \@ifpresent \underline{238}, 560, 562

\@jobname . . \underline{1043}, 1049

                          \@maxfiles . . . . . . .

. 671, 673, 685, 819, 821, 822, 825, 827, 844, 845

                          \@maxoutfiles . . . . .

…. 672, 674, 686, 831, 833–835

\@msg . . . . . 597, 599, 659 \@need@d . . 558, 559, 561 \@needed . . . . . 521, \underline{553}

                          \@nostreamerror 176, \underline{178}
                          \@outputstreams . . .

…. 167, 192, 200

                                                   \@pathname . . . . . . .

. 491, 493, 505, 506, 509, 997, 1010

                                                   \@secondoftwo . 250, 258
                                                   \@setwritedir . . . . . \underline{980}
                                                   \@setwritetodir 764,

795, 801, 980, 1027 \@spaces . . . . . 245, 599 \@sptoken …. 254, 259

                                                   \@streamfound . . . . .

…. \underline{178}, 190, 198 \@stripstr 181, 187, 196

                                                   \@stripstring . . . . .

…. 132, 189, 526–529, 661, 756, 757, 759, 760

                                                   \@tempcnta . . . 158,

159, 161, 163–165

\@temptokena . . . . . .

…. 234, 236, 237

\@undefined 982, 983,

992, 995, 1001, 1008 \@xifnch . . . . . 254, 260

A

\activefiles 320, 338,

393, 401, 409, 420, 447, 462, 610

\AddGenerationDate . \underline{693}

\afterfi \underline{247}, 263, 264, 277–279, 293, 294, 303, 304, 1025

\aftergroup . . . 249, 250

\alloc@ . . . . . 42, 44, 45

\alt@usedir . . . 765, \underline{771}

\answer … \underline{133}, 493, 499, 500, 872, 875, 877, 920, 927, 928, 948–950

\Ask \underline{211}, 218, 220, 222, 223, 229, 493, 872, 920, 948, 956, 960, 964, 969

\askforoverwritefalse

. . . . . . . . . 8, 805

\askforoverwritetrue

. . . . . . . 8, 84, 804

\askonceonly . . . . 8, \underline{219}
\AskQuestions . 937, \underline{953}

B

\basedir . . . . . . . . .

. 767, 791, 793, 799

\BaseDirectory . . 4, \underline{763}
\batchfile . . . . . . .

. 108, \underline{133}, 857, 865, 879, 1048, 1050

\batchinput . 9, \underline{105}, 862

\begin . . . . . . . . . . . 15 \bgroup . . 30, 73, 74,

180, 248, 290, 330

\blockHead   \underline{120}, 413,

415, 437, 438, 440

\blockLevel . . . . . . .

. \underline{85}, 414, 434, 443 \body . . . . . . . . . . 61, 62

C

\change@msg 598, 601, 662

\chardef . . . . . . 32, 45, 99, 100, 161, 183, 185, 187, 188, 197, 201, 514

\checkeoln 712, 713, 722

\checkfilelimit  \underline{843}, 855
\CheckFileNames  \underline{897}, 941
\checkguard@do 417, \underline{422}
\checkOption . . 371, \underline{375}
\checkorder . . . 524, \underline{531}
\checkorderX . . . . . .

…. 533, 536, 543

\checkorderXX . 540, 542
\closeguard@do 444, \underline{450}
\closeoutput . . 525, \underline{681}
\codeLinesPassed  \underline{87},

315, 592, 647, 651

\commentsPassed   \underline{87},

334, 591, 646, 650

\commentsRemoved  \underline{87},

327, 590, 645, 649

\Continuefalse 621,

624, 903, 912, 919

\Continuetrue . 626,

905, 917, 927, 928 \convsep . . \underline{768}, 791, 793 \count . . . . . . 37–40, 42 \count@ . . . . . 33, 48, 52 \countdef … 32, 33, 44 \csname 5, 54, 131, 162,

163, 189, 234, 262, 473, 474, 595, 604, 609, 642, 663, 668, 757, 760, 775, 780

\curin . . . . . . . 525,

549, 568, 578, 581

\curinfiles . . . . . . .

. 516, 533, 560, 567

\curinnames . . . . . . .

. 517, 528, 577, 580 \curout … 515, 578, 581 \curref … 518, 529, 574

\currentpostamble .

. . . . . . . . 527, 728

\currentpreamble . .

. . . . . . . . 526, 727

D

\DeclareDir . 4, 783, \underline{799}

                          \DeclareDirX . . 799, 800
                          \declarepostamble .

. . . . . . 9, \underline{715}, 732

                          \declarepostambleX .

. . . . . . . . 717, 719

                          \declarepreamble . .

. . 9, \underline{700}, 730, 733

                          \declarepreambleX .

. . . . . . . . 705, 707

                          \DefaultbatchFile .

… 124, 871, 1050

                          \Defaultbatchile . . \underline{124}
                          \Defaultfalse 110, 1047
                          \defaultpostamble .

. 731, 732, 752, 754

                          \defaultpreamble . .

. 729, 730, 751, 753

                          \Defaulttrue . . . . . 1051

\destdir 113, 494, 497, 761, 775, 786, 790, 915, 920, 922, 925, 989, 997, 998, 1010, 1011

                          \destFileName . 896,

898, 915, 920, 943 \dimendef . . . . . . . . 32 \dirsep … 767, 769,

992, 993, 1001, 1002, 1005, 1011

                          \DisableCrossrefs 9, 10

\do . . . . . . 146, 319, 337, 390, 398, 406, 417, 419, 431, 444, 446, 456, 581, 602, 608, 657, 668, 939

\docdate . . . . . . . . . 974 \DocInput . . . . . . . . 16

                          \documentclass . . 3, 4, 7

\doOption …. 385, \underline{387}

                          \DoubleperCent . . . . \underline{125}
                          \ds@heading \underline{688}, 694, 710

E \egroup . . 24, 30, 74,

180, 250, 296, 331 \eltEnd … \underline{133}, 143, 144 \eltStart . \underline{133}, 143, 144

                          \emptyLines . . . . . . .

. \underline{86}, 628, 630, 632

\EnableCrossrefs . . . 8

\end . . . . . . . . . . 17,

\underline{233}, 551, 850, 1039

\endbatchfile . . . . .

…. 6, 1033, \underline{1034}

\endcsname . . . . . . .

5, 55, 131, 162, 163, 189, 234, 262, 473, 474, 595, 604, 609, 642, 663, 668, 757, 760, 775, 780

\Endinput …. \underline{231}, 619 \endinput 620, 746, 1041 \endLine 313, 325, 332,

387, 395, 403, 411, 432, 454, 633

\endlinechar . . . . . . 616
\endpostamble . . . 8, 720
\endpreamble 8, 708, 745

\err@from …. 523, 572

\err@needed . . . 523, 555

\errhelp . . . . . 782,

823, 836, 846, 861

\errorcontextlines . 71
\errorstopmode . . . . 70
\escapechar . . . . . 48, 52

\eT@ . . . . . . . . . . . . . \underline{266}

\Evaluate . . . . \underline{311},

389, 397, 405, 416 \Expr . . . . . . . . 310,

391, 399, 407, 426

\Expression . . . . . . .

. 278, \underline{299}, 304, 312

\ExpressionX . . 300, \underline{301}
\ExpressionXX . 304, \underline{306}

F

\file . . . . . . . 6, 469,

\underline{485}, 554, 571, 806 \filedate . . . . . . . . 973 \filelist …. 938, 969

\filestogenerate . .

. 468, 471, 472, 506

\fileversion . . 698, 973
\findactive@do . . . .

…. 419, \underline{429}, 446 \FirstElt …. 150, \underline{155} \forlist . . . . . \underline{146}, 938

\Forlistfalse . . . . . 152

                          \Forlisttrue . . . . . . 148

\from . . . . . . . 6, 521, 523, \underline{570}, 810, 944

G \generate 6, \underline{467}, 486, 806

                          \Generatefalse . . . . 501
                          \generateFile 10, \underline{803},

810, 816, 818, 943

                          \generatefile . . . . . \underline{811}
                          \Generatetrue . . . . . 488
                          \guardStack \underline{119}, 413, 438

I \iden . . . . . . . . 104,

211, 216, 259, 260, 331, 528, 549

                          \ifaskforoverwrite .

. . . . . . . . \underline{84}, 490 \ifcase … 276, 368, 376

                          \ifContinue  \underline{80}, 639, 942
                          \ifDefault   \underline{82}, 859, 869

\iffalse . . . . . . . 49, 51

                          \ifForlist . . . . \underline{81}, 153
                          \ifGenerate . . . . \underline{79}, 504
                          \ifMoreFiles . . . \underline{83}, 935

\ifnum . 24, 165, 186, 196, 423, 430, 434, 451, 632, 656, 667, 671, 672, 682, 822, 834, 845, 885, 1030

                          \iftopbatchfile . . .

… 102, 103, 1035

                          \ifToplevel . . . . . 9, \underline{102}

\iftrue . . . . . . . . . . 50 \include . . . . . . 10, \underline{808} \inFile \underline{98}, 458, 460,

491, 492, 502, 584, 585, 618, 623, 641, 906, 907, 914–916, 933

                          \infileext . . . 895, 956
                          \inFileName 473, 700, 743

\inLine \underline{133}, 318, 323, 336, 460, 461, 618, 619, 627, 633

\input . . . . . 6, 105, 118

                                                   \inputcheck . . . \underline{101},

857, 858, 878, 1013, 1014, 1024

                                                   \inputfiles 468, 479–

481, 534, 562, 563

                                                   \interactive 6, \underline{934}, 1031

\iterate . . . . . . . 61, 62

J \jobname . . . . . . 3, 1043

K

                                                   \keepsilent . . . . . 9, \underline{204}

L

                                                   \ListCondition . . . .

…. 147, 150, 151

                                                   \lowercase . . . . . . 1043

M

                                                   \MainFileName . . . . .

…. 895, 896, 938 \makeOther \underline{232}, 612–615

                                                   \makeoutlist@do 608, \underline{666}
                                                   \makepathname . . . . .

…. 489, \underline{980}, 995, 996, 1008, 1009

\maxfiles . . . . . . 5, \underline{819}

                                                   \maxoutfiles . . . . 5, \underline{831}

                                                   \maybeMsg . \underline{204}, 317,

329, 388, 396, 404, 412, 442, 455, 463, 465, 635

\meaning . . . . . . . . 1046

                                                   \MetaPrefix . . . . . . .

. \underline{125}, 336, 518– 520, 574, 689– 691, 695, 696, 698, 709, 712, 721–724, 747, 748

                                                   \minusOption . . 383, \underline{403}
                                                   \MoreFilesfalse . . . 951
                                                   \MoreFilestrue . . . .

. . . . . 83, 949, 950 \Msg 138, \underline{210}, 472, 509,

597, 620, 644, 659, 811, 815, 870, 886, 899, 908, 954, 958, 962, 966, 972, 973, 975, 1015, 1020

N

\n . . . . . . . . . . . . . . \underline{123} \Name . . . . . 131, 161,

168–175, 266– 269, 272, 273, 505, 507, 525– 529, 564–566, 578, 581, 596, 611, 772, 778, 802

\needed 521, 523, \underline{553}, 576

\newinputfiles . . . .

…. 478, 480, 606 \next . . 62, 856, 879, 882 \noprompt . 223, 228, 229

\normalLine \underline{313}, 347, 360

\NPrimary …. 277, \underline{281} \number 161, 163, 663, 668

\NumberOfFiles . \underline{97},

653, 885, 887, 1030

O

\od . . . . . . . . . 146, 946

\OnlyDescription . . 13
\openoutput . . . 578, \underline{670}

\Options . . . . . . . . .

. 808, 810, 944, 964 \or . . . . . . 277, 278,

370, 371, 380–384

\order@error . . 538, 546
\org@postamble 112, \underline{733}
\org@preamble . 111, \underline{733}
\OriginalAsk . . . . . .

…. \underline{218}, 221, 222

\OtherElts . . . 151, \underline{156}
\outfileext . . . 896, 960
\outFileName 473, 474,

690, 696, 701, 724, 748, 756, 759

\outputfiles . . 418,

445, 447, 609, 610

P

\perCent . . \underline{125}, 329, 455 \pesvnoc . . . . . 769, 770

\PExpression . . 278, \underline{284}
\plusOption . . . 382, \underline{395}

\pop . . . . . . . . . \underline{136}, 438 \popX . . . . . . . . 141, \underline{143}

\postamble . . . . . 8, \underline{729}

\preamble . . . . . . 8, \underline{729} \Primary . . . . . \underline{275}, 289

                          \process@first@batchfile

. . \underline{1028}, 1053, 1056

                          \processbatchFile .

. 6, 114, \underline{854}, 1029

                          \processedLines   \underline{87},

356, 589, 644, 648

                          \processFile . . . . . .

. 10, \underline{809}, 812, 814

                          \processfile . . . . . . \underline{811}
                          \processinputfiles .

. . . . . . . . 475, \underline{477}

                          \processLine . . \underline{340}, 633
                          \processLineX . . . . .

…. 345, 358, \underline{365} \push . . . . . . . . \underline{144}, 413 \pushX . . . . . . . 144, \underline{145}

                          \putline@do . . . . . . .

. 319, \underline{322}, 337, 456

                          \putMetaComment  \underline{330}, 370

Q \qStop . . . . . . . \underline{135},

141, 143–145, 239, 240, 246, 272, 273, 534, 536, 537, 543, 544, 549, 584, 586, 597, 600, 768–770, 791, 793

R

                          \readsource 537, 542,

544, 562, 563, \underline{583}

                          \RecordChanges . . . . 12
                          \ReferenceLines . . .

…. 474, 702, 711

                          \refusedfiles . . . . .

. 594, 596, 603, 605, 611, 657, 678

                          \removeComment   \underline{324}, 372
                          \ReportTotals . . . . .

. . . . . 6, \underline{883}, 1037

                          \reserved@a . . . . . . .

. 249, 255, 557, 558

                          \reserved@c . . . . . . .

. 249, 252, 254, 260

S \s@ . . . . . . . . . . . . . 181 \s@do . . . . . . . . 166,

168–175, 186, 196 \secapsot . 243, 244, 600 \Secondary \underline{288}, 293, 300

                                                   \SecondaryX . . . 289, \underline{290}
                                                   \SecondaryXX . . 293, \underline{297}
                                                   \SetFileNames . \underline{894}, 940
                                                   \setwritetodir . . . . 981
                                                   \showalt@directory .

. . . . . . . . 766, 777

                                                   \showboxbreadth . . . 70
                                                   \showboxdepth . . . . . 70
                                                   \showdirectory . . . .

. . . . . . 4, 762, 766

                                                   \showfiles@do . 602, \underline{655}
                                                   \showprogress . . . 9, \underline{204}
                                                   \showundef@directory

…. 779, 788, 797

                                                   \showundef@TDSdirectory

. . . . . . . . 793, 797

                                                   \skip@input . . . . . . . \underline{117}
                                                   \slashOption . . 381, \underline{432}
                                                   \sourceFileName . . .

…. \underline{133}, 895, 898, 906, 910, 944

                                                   \starOption . . . 380, \underline{411}
                                                   \StopParse . . . \underline{308}, 312
                                                   \stream@closed . . . .

. 183, 185, 201, 514, 656, 667, 682

                                                   \StreamClose . . \underline{183}, 684
                                                   \StreamOpen . . . \underline{183}, 675
                                                   \StreamPut . . . . . . .

. \underline{183}, 323, 391, 399, 407, 757, 760

\string . . . . . . . . . .

54, 55, 132, 181, 187, 196, 231, 485, 486, 553, 554, 570, 571, 620, 746, 812, 813, 816, 817, 865

\strip . . . . . . . 212, 216

                                                   \strip@meaning  \underline{853}, 1046

T \Terminal …. \underline{261}, 279

                                                   \TerminalX . . . 264, \underline{270}

\tmp . . . . . . \underline{133}, 141,

142, 239, 240, 433, 435, 437, 440, 537, 544, 990, 991, 1003, 1004

\toks . . . . . . . . . . . . 38 \toksdef . . . . . . . . . 44

\topbatchfilefalse . 109
\topbatchfiletrue . 102

\tospaces …. \underline{242}, 600

\TotalcodeLinesPassed

. . . . . \underline{92}, 651, 891

\TotalcommentsPassed

. . . . . \underline{92}, 650, 890

\TotalcommentsRemoved

. . . . . \underline{92}, 649, 889

\TotalprocessedLines

. . . . . \underline{92}, 648, 888

\tracingall . . . . . . . 67
\tracingcommands . . 67
\tracinglostchars . 68
\tracingmacros . . . . 69
\tracingonline . . . . 71
\tracingoutput . . . . 68
\tracingpages . . . . . 68

                          \tracingparagraphs . 69
                          \tracingrestores . . 69
                          \tracingstats . . . . . 67

\ttyin . . . . . . . . \underline{99}, 215 \ttyout . . . . . . . \underline{99}, 210 \typeout . . . . . . . . . 14

U

                          \undefined@directory

…. 773, \underline{781}, 796

                          \undefined@TDSdirectory

. . . . . . . . \underline{789}, 796

                          \uptospace   \underline{246}, 549,

584, 586, 597, 600 \usedir …. 3, \underline{761}, 765

                          \usepostamble . . . 9,

112, \underline{727}, 731, 754

                          \usepreamble . . . . 9,

111, \underline{727}, 729, 753 \UseTDS …. 4, 783, \underline{794}

V

                          \verbOption . . . 384, \underline{454}

\verbStop …. 455, 461

W

                                                   \whileswitch . . \underline{157}, 935

\wlog . . . . . . . . . . . . 35

                                                   \WritePostamble 683, \underline{758}
                                                   \WritePreamble 676, \underline{755}
                                                   \WriteToDir . . . 113,

761, 762, 786, \underline{980}, 982, 984, 986, 989, 991, 997, 998, 1004, 1011

X \x . . . . . . . . . . 180, 182

Y \y … \underline{121}, 228, 499,

875, 877, 927, 949 \yes . . . . . . \underline{121}, 228,

229, 500, 928, 950

Z \Z . . . . . . . . . 23, 25, 73

Change History

2.0a

\@gobble: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2.0b

General: Added bugfix from Denys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2.0c

General: Allow almost all characters in guard (DD) . . . . . . . . . . . . . . . . . . . . . 1 2.0d

General: Started merging in some of Franks code . . . . . . . . . . . . . . . . . . . . . . 1 2.0e

General: Added counter allocation for the processing of multiple files . . . . . . . 16 \AskQuestions: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 \declarepostamble: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 \declarepreamble: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 \WritePostamble: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 \WritePreamble: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

2.0f \Defaultbatchile: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 \Endinput: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 \ifDefault: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 \include: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 \processbatchFile: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

   \processFile: Supply \generateFile with \Options . . . . . . . . . . . . . . . . . . 48

\readsource: Added check for lines with \endinput . . . . . . . . . . . . . . . . . . . 40 2.0g

\FirstElt: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 \forlist: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 \ifForlist: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 \OtherElts: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 \ReportTotals: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

2.0h \end: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 \ifMoreFiles: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 \whileswitch: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

2.0i \Ask: Added check for just ⟨ ⟩CR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 \emptyLines: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 \readsource: Added check for consecutive empty lines . . . . . . . . . . . . . . . . . 41

2.0j General: Wrote introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 \readsource: First check for end of file before check for empty lines . . . . . . . . 41 \skip@input: Added macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

2.0k \eltEnd: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 \eltStart: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 \guardStack: Renamed from \blockStack . . . . . . . . . . . . . . . . . . . . . . . . . . 18 \pop: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 \popX: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 \push: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 \pushX: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 \qStop: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 \slashOption: Use new stack mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 \starOption: The macro that holds the guard needs to be expanded . . . . . . . 33

Use new stack mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 2.0m

General: Added some missing percents; corrected some typos . . . . . . . . . . . . . . 1 Removed dependency from ltugboat, incorporated driver file into source. … 1 Renamed all macros that deal with the parsing of boolean expressions . . . . . 1

\generatefile: Now issue a warning when \processfile or \generatefile are

used . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 2.0m-DL

General: Various small corrections to English and typos . . . . . . . . . . . . . . . . . . 1 2.0n

\batchinput: Added macro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 \skip@input: Argument delimited by space not \relax . . . . . . . . . . . . . . . . . 18

Macro renamed from \skipinput . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.0p

\CheckFileNames: Added \WriteToDir (FMi). . . . . . . . . . . . . . . . . . . . . . . . 52

Changed question about overwriting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 \file: Added \WriteToDir (FMi). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 \WriteToDir: Macro added (FMi). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

2.0q General: Changed all dates to yy/mm/dd for better sorting . . . . . . . . . . . . . . . 1

\interactive: Preceded filename by \WriteToDir . . . . . . . . . . . . . . . . . . . . . 53 2.0r

\CheckFileNames: Moved \closein statements . . . . . . . . . . . . . . . . . . . . . . . 52

Use \inFile for reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 2.1a

\@@input: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 \batchinput: Completely redefined (so that it works) . . . . . . . . . . . . . . . . . . 17

2.1b

General: Added fontdefinitions for doc to the driver file, in order to get the layout of the code right; also added the layout definitions that are in effect in doc.drv 13 modified mailaddress of Johannes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

2.1c

General: Added a setting for StandardModuleDepth . . . . . . . . . . . . . . . . . . . . 1

Remove definitions for fonts again . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.1e

\n: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.2a

General: Update for LaTeX2e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 \WriteToDir: check texsys file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

2.2c

General: Renamed texsys.tex to texsys.cfg. . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2.2d

\WriteToDir: do not read dircheck/texsys file . . . . . . . . . . . . . . . . . . . . . . . . 54 2.2f

General: Allow direct processing of source . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.2j

\org@postamble: Updated default preamble . . . . . . . . . . . . . . . . . . . . . . . . . 45 2.3a

General: Changed driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 New mechanism: output streams allocation . . . . . . . . . . . . . . . . . . . . . . . . 21 No allocated streams for console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 Swapped Primary with Secondary since expressions are generally described bottom-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

\checkOption: Adapted to concurrent version . . . . . . . . . . . . . . . . . . . . . . . . 32

Trying to avoid assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 \declarepreamble: renamed from \preamble; interface changed . . . . . . . . . . . 44 \file: Changed \@empty (which was undefined) to \empty . . . . . . . . . . . . . . 37

Messages changed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 \generate: Messages changed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 \org@postamble: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 \org@preamble: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 \processLine: Adaptation for concurrent version . . . . . . . . . . . . . . . . . . . . . 30

Trying to avoid assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 \processLineX: Trying to avoid assignments . . . . . . . . . . . . . . . . . . . . . . . . . 31 \readsource: Renamed to \readsource; adaptation for concurrent version … 40 \slashOption: Adapted for concurrent version . . . . . . . . . . . . . . . . . . . . . . . 34 \starOption: Adapted to concurrent version . . . . . . . . . . . . . . . . . . . . . . . . . 33

2.3b General: Completely changed expressions parser . . . . . . . . . . . . . . . . . . . . . . . 1 Removed mechanism for checking if previous one-line guard is same as current (\testOption, \closeOption)—this is not a common case and testing complicates things unnecessarily . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

\checkguard@do: Change for pre-constructed off-counters’ names . . . . . . . . . . 34 \closeguard@do: Change for pre-constructed off-counters’ names . . . . . . . . . . 35 \findactive@do: Change for pre-constructed off-counters’ names . . . . . . . . . . 34 \makeoutlist@do: Macro added — pre-constructed off-counters’ names . . . . . 43 \putline@do: Change for pre-constructed off-counters’ names . . . . . . . . . . . . 30 \readsource: Change for pre-constructed off-counters’ names . . . . . . . . . . . . 40

2.3c

General: Changed some dirty tricks to be less/more dirty—all uses of \afterfi 1

When file is multiply listed in \file clause it is multiply read . . . . . . . . . . . 1 \afterfi: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 \from: part of code moved to \needed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 \needed: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 \org@preamble: With \inFileName again . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 \postamble: As for \preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 \preamble: Bug fixed: default preamble is now selected not only defined …. 45 \uptospace: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

\WritePostamble: Added defs of \inFileName and \outFileName . . . . . . . . . 46
\WritePreamble: Added definitions of \inFileName and \outFileName . . . . . . 45

2.3d \AddGenerationDate: (DPC) Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . 44 \WritePreamble: (DPC) Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

2.3e \@ifnextchar: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 General: added \makepathname to support systems with bizzare pathnames … 1

Added doc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Added documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 batch files work by \input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Directories support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Introduced “open lists” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

\alt@usedir: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 \BaseDirectory: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 \checkOption: Verbatim mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 \convsep: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 \DeclareDir: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 \declarepostamble: Change for batchfiles working by \input . . . . . . . . . . . . 44 \declarepreamble: Change for batchfiles working by \input . . . . . . . . . . . . . 44

Change to allow customization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 \ds@heading: Macro added. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 \file: Changed \WriteToDir to \destdir . . . . . . . . . . . . . . . . . . . . . . . . . . 37

Destination directory handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 \from: Introduced “open list” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 \makepathname: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 \needed: Forced expansion of argument to fix a bug with filenames containing

macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 \openoutput: Change for “open lists” – renamed from \ensureopen@do . . . . . 43 \processbatchFile: Batch file is \inputed not \read . . . . . . . . . . . . . . . . . . 50 \putMetaComment: Introduced \MetaPrefix . . . . . . . . . . . . . . . . . . . . . . . . . . 30 \readsource: Introduced “open list” . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 \usedir: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 \verbOption: Macro added . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

2.4a General: Add stream limits (MDW) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 \closeoutput: Don’t close the file if it’s not open (MDW) . . . . . . . . . . . . . . . 43 \generate: Repeat processing of files until all done (MDW) . . . . . . . . . . . . . . 36 \maxfiles: Macro added (MDW) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

No default limit since batchfiles are now \input (MW) . . . . . . . . . . . . . . . 49 \maxoutfiles: Macro added (MDW) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 \openoutput: Check whether there are streams left (MDW) . . . . . . . . . . . . . . 43 \processbatchFile: Added check for file limits (MDW) . . . . . . . . . . . . . . . . 50 \processinputfiles: Macro added (MW) . . . . . . . . . . . . . . . . . . . . . . . . . . 36 \readsource: Extensively hacked to honour stream limits (MDW) . . . . . . . . . 40 \showfiles@do: Macro added (MW) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 \undefined@directory: Macro added (MW) . . . . . . . . . . . . . . . . . . . . . . . . . 47 \undefined@TDSdirectory: Macro added (MW) . . . . . . . . . . . . . . . . . . . . . . 47 \UseTDS: Macro added (MW) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

2.4c General: Add initex support (DPC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 \processbatchFile: Add \jobname checks (DPC) . . . . . . . . . . . . . . . . . . . . . 50 \strip@meaning: Macro added (DPC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

2.4d \@docstrip: Macro added (DPC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 \@jobname: Macro added (DPC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 General: Move config file test to outer level (DPC) . . . . . . . . . . . . . . . . . . . . 55

Move default batchfile check to outer level (DPC) . . . . . . . . . . . . . . . . . . . 56 \endbatchfile: Macro added (DPC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 \process@first@batchfile: Macro added (DPC) . . . . . . . . . . . . . . . . . . . . . 56 \processbatchFile: Missing batchfile an error (DPC) . . . . . . . . . . . . . . . . . . 50

Move \jobname checks to top level (DPC) . . . . . . . . . . . . . . . . . . . . . . . . . 50 2.4e

\@setwritedir: macro added (DPC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 \askonceonly: macro added (essentially from unpack.ins) (DPC) . . . . . . . . . . 24 \BaseDirectory: \@setwritetodir added (DPC) . . . . . . . . . . . . . . . . . . . . . 46 \DeclareDir: \@setwritetodir added (DPC) . . . . . . . . . . . . . . . . . . . . . . . . 47 \makepathname: set in \@setwritedir (DPC) . . . . . . . . . . . . . . . . . . . . . . . . 54 \OriginalAsk: macro added (was in unpack.ins) (DPC) . . . . . . . . . . . . . . . . 24 \undefined@directory: Help text added (DPC) . . . . . . . . . . . . . . . . . . . . . . 47 \UseTDS: \@setwritetodir added (DPC) . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 \WriteToDir: set in \@setwritedir (DPC) . . . . . . . . . . . . . . . . . . . . . . . . . . 54

2.4g

\verbOption: Reset \putline@do for /2340 . . . . . . . . . . . . . . . . . . . . . . . . . . 35 2.4h

\NumberOfFiles: Declare counter always pr/2429 . . . . . . . . . . . . . . . . . . . . . 16 \readsource: update \NumberOfFiles even if stats are not gathered pr/2429 . 42