1 % \iffalse meta-comment
4 % The LaTeX3 Project and any individual authors listed elsewhere
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
10 % It may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either version 1.3c
12 % of this license or (at your option) any later version.
13 % The latest version of this license is in
14 % http://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2005/12/01 or later.
18 % This file has the LPPL maintenance status "maintained".
20 % The list of all files belonging to the LaTeX base distribution is
21 % given in the file `manifest.txt'. See also `legal.txt' for additional
24 % The list of derived (unpacked) files belonging to the distribution
25 % and covered by LPPL is defined by the unpacking scripts (with
26 % extension .ins) which are part of the distribution.
31 \def\filename{docstrip.dtx}
32 \def\fileversion{2.5e}
33 \def\filedate{2014/09/29}
34 \def\docdate {2014/09/29}
37 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
38 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
39 %% Digits \0\1\2\3\4\5\6\7\8\9
40 %% Exclamation \! Double quote \" Hash (number) \#
41 %% Dollar \$ Percent \% Ampersand \&
42 %% Acute accent \' Left paren \( Right paren \)
43 %% Asterisk \* Plus \+ Comma \,
44 %% Minus \- Point \. Solidus \/
45 %% Colon \: Semicolon \; Less than \<
46 %% Equals \= Greater than \> Question mark \?
47 %% Commercial at \@ Left bracket \[ Backslash \\
48 %% Right bracket \] Circumflex \^ Underscore \_
49 %% Grave accent \` Left brace \{ Vertical bar \|
50 %% Right brace \} Tilde \~}
55 %% The docstrip program for use with TeX.
56 %% Copyright (C) 1989-1991 Frank Mittelbach
57 %% Copyright (C) 1992-1995 Johannes Braams, Denys Duchier,
59 %% Copyright (C) 1995 Marcin Woli\'nski
60 %% Copyright (C) 1996-1997 Mark Wooding, Marcin Woli\'nski
61 %% Copyright (C) 1998-2003 LaTeX3 project and the above authors
62 %% All rights are reserved.
67 % \changes{2.0b}{1991/05/29}{Added bugfix from Denys}
68 % \changes{2.0c}{1991/05/29}{Allow almost all characters in guard (DD)}
69 % \changes{2.0d}{1991/05/31}{Started merging in some of Franks code}
70 % \changes{2.0j}{1992/03/05}{Wrote introduction}
71 % \changes{2.0m}{1992/04/21}{Renamed all macros that deal with the
72 % parsing of boolean expressions}
73 % \changes{2.0m}{1992/04/25}{Removed dependency from ltugboat,
74 % incorporated driver file into source.}
75 % \changes{2.0m}{1992/04/25}{Added some missing percents; corrected some
77 % \changes{2.0m-DL}{1992/05/08}{Various small corrections to English and
79 % \changes{2.0q}{1992/07/01}{Changed all dates to yy/mm/dd for better
81 % \changes{2.2a}{1993/12/02}{Update for LaTeX2e}
82 % \changes{2.2c}{1993/12/17}{Renamed texsys.tex to texsys.cfg.}
83 % \changes{2.3a}{1995/08/17}{Swapped Primary with Secondary since
84 % expressions are generally described bottom-up}
85 % \changes{2.3b}{1995/08/22}{Completely changed expressions parser}
86 % \changes{2.3b}{1995/08/23}{Removed mechanism for checking if previous
87 % one-line guard is same as current (\cs{testOption},
88 % \cs{closeOption})---this is not a common
89 % case and testing complicates things unnecessarily}
90 % \changes{2.3c}{1995/08/24}{When file is multiply listed in \cs{file}
91 % clause it \emph{is} multiply read}
92 % \changes{2.3c}{1995/09/04}{Changed some dirty tricks to be
93 % less/more dirty---all uses of \cs{afterfi}}
94 % \changes{2.3e}{1995/09/25}{Directories support}
95 % \changes{2.3e}{1995/10/24}{added \cs{makepathname} to support
96 % systems with bizzare pathnames}
97 % \changes{2.3e}{1995/10/25}{batch files work by \cs{input}}
98 % \changes{2.3e}{1996/10/02}{Introduced ``open lists''}
99 % \changes{2.4a}{1996/06/06}{Add stream limits (MDW)}
100 % \changes{2.4c}{1996/06/11}{Add initex support (DPC)}
102 % \DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ }
104 % \DoNotIndex{\advance,\begingroup,\catcode,\closein,\closeout}
105 % \DoNotIndex{\day,\def,\edef,\else,\empty,\endgroup,\errmessage}
106 % \DoNotIndex{\expandafter,\fi,\futurelet,\gdef,\global,\if,\ifeof}
107 % \DoNotIndex{\ifx,\immediate,\let,\loop,\m@ne,\message,\month}
108 % \DoNotIndex{\newcount}
109 % \DoNotIndex{\newif,\newlinechar,\newread,\newtoks,\newwrite}
110 % \DoNotIndex{\noexpand,\openin,\openout,\par,\read,\relax,\repeat}
111 % \DoNotIndex{\space,\the,\undefined,\write,\xdef,\year,\z@}
113 % ^^A some definitions for this documentation
115 % \newcommand{\ds}{\textsf{DocStrip}} ^^A maybe?
116 % \newcommand{\bsl}{\protect\bslash}
117 % \newcommand{\note}[1]{\marginpar{\textbf{#1}}}
118 % \newcommand{\netaddress}[1]{\texttt{#1}}
120 % ^^A override the default in doc.sty
122 % \renewenvironment{theglossary}{%
123 % \glossary@prologue%
124 % \GlossaryParms \let\item\@idxitem \ignorespaces}%
129 % \changes{2.1c}{1993/02/25}{Added a setting for StandardModuleDepth}
130 % \setcounter{StandardModuleDepth}{1}
132 % \title{The \ds{} program%
133 % \thanks{This file has version number \fileversion,
134 % last revised \filedate,
135 % documentation dated \docdate.}}
137 % \changes{2.1b}{1993/02/23}{modified mailaddress of Johannes}
138 % \changes{2.4i}{1998/01/18}{removed mail addresses as it is hopeless
139 % to keep them uptodate}
152 % \date{Printed \today}
154 % \MaintainedByLaTeXTeam{latex}
158 % This document describes the implementation of the \ds{} program.
159 % The original version of this program was developed by Frank
160 % Mittelbach to accompany his \texttt{doc.sty} which enables literate
161 % programming in \LaTeX\@. Denys Duchier rewrote it to run either
162 % with \TeX\ or with \LaTeX, and to allow full boolean expressions in
163 % conditional guards instead of just comma-separated lists.
164 % Johannes Braams re-united the two implementations, documented and
167 % In September 1995 Marcin Woli\'nski changed many parts of the
168 % program to make use of \TeX's ability to write to multiple files
169 % at the same time to avoid re-reading sources. The performance
170 % improvement of version~2.3 came at a price of compatibility with
171 % some more obscure operating systems which limit the number of
172 % files a process can keep open. This was corrected in September
173 % 1996 by Mark Wooding and his changes were ``creatively merged''
174 % by Marcin Woli\'nski who made at the same time changes in batch
175 % files processing, handling of preambles and introduced ``verbatim
176 % mode''. After all that, David Carlisle merged the new version into
177 % the \LaTeX\ sources, and made a few other changes, principally
178 % making \ds{} work under initex, and removing the need for
179 % batch files to say \verb|\def\batchfile{...}|.
182 % \section{Introduction}
184 % \subsection{Why the \ds{} program?} When Frank Mittelbach created
185 % the \texttt{doc} package, he invented a way to combine \TeX\ code
186 % and its documentation. From then on it was more or less possible
187 % to do literate programming in \TeX.
189 % This way of writing \TeX\ programs obviously has great
190 % advantages, especially when the program becomes larger than a
191 % couple of macros. There is one drawback however, and that is
192 % that such programs may take longer than expected to run because
193 % \TeX\ is an interpreter and has to decide for each line of the
194 % program file what it has to do with it. Therefore, \TeX\ programs
195 % may be sped up by removing all comments from them.
197 % By removing the comments from a \TeX\ program a new problem is
198 % introduced. We now have two versions of the program and both of
199 % them {\em have\/} to be maintained. Therefore it would be nice to
200 % have a possibility to remove the comments automatically, instead
201 % of doing it by hand. So we need a program to remove comments from
202 % \TeX\ programs. This could be programmed in any high level
203 % language, but maybe not everybody has the right compiler to
204 % compile the program. Everybody who wants to remove comments from
205 % \TeX\ programs has \TeX\@. Therefore the \ds{} program is
206 % implemented entirely in \TeX.
208 % \subsection{Functions of the \ds{} program}
210 % Having created the \ds{} program to remove comment lines from
211 % \TeX\ programs\footnote{Note that only comment lines, that is
212 % lines that start with a single \texttt{\%} character, are removed;
213 % all other comments stay in the code.} it became feasible to do more
214 % than just strip comments.\\ Wouldn't it be nice to have a way to
215 % include parts of the code only when some condition is set true?
216 % Wouldn't it be as nice to have the possibility to split the
217 % source of a \TeX\ program into several smaller files and combine
218 % them later into one `executable'?\\ Both these wishes have been
219 % implemented in the \ds{} program.
221 % \section{How to use the \ds{} program}
222 % A number of ways exist to use the \ds{} program:
224 % \item The usual way to use \ds{} is to write a \emph{batch file}
225 % in such a way that it can be directly processed by \TeX{}.
226 % The batch file should contain the commands described below for
227 % controlling the \ds{} program.
228 % This allows you to set up a distribution where you can instruct
229 % the user to simply run
231 % \texttt{TEX} \meta{batch file}
233 % to generate the executable versions of your files from the
234 % distribution sources.
235 % Most of the \LaTeX\ distribution is packaged this way.
236 % To produce such a batch file include a statement in your
238 % instructs \TeX\ to read \texttt{docstrip.tex}.
239 % The beginning of such a file would look like:
244 % By convention the batch file should have extension |.ins|. But
245 % these days \ds{} in fact work with any extension.
247 % \item Alternatively you can instruct \TeX\ to read the file
248 % \texttt{docstrip.tex} and to see what happens. \TeX\ will ask
249 % you a few questions about the file you would like to be
250 % processed. When you have answered these questions it does
251 % its job and strips the comments from your \TeX\ code.
254 % \section{Configuring \ds}
255 % \subsection{Selecting output directories}
256 % \changes{2.3e}{1996/09/19}{Added documentation}
257 % Inspired by a desire to simplify reinstallations of \LaTeXe{} and
258 % to support operating systems which have an upper limit on the
259 % number of files allowed in a directory, \ds\ now allows
260 % installation scripts to specify output directories for files it
261 % creates. We suggest using TDS (\TeX\ directory structure) names
262 % of directories relative to \texttt{texmf} here. However these
263 % names should be thought of as a labels rather than actual names
264 % of directories. They get translated to actual system-dependent
265 % pathnames according to commands contained in a configuration file
266 % named \texttt{docstrip.cfg}.
268 % The configuration file is read by \ds{} just before it starts to
269 % process any batch file commands.
271 % If this file is not present \ds{} uses some default settings which
272 % ensure that files are only written to the current directory.
273 % However by use of this configuration file, a site maintainer can
274 % `enable' features of \ds{} that allow files to be written to
275 % alternative directories.
277 % \DescribeMacro{\usedir}
278 % Using this macro package author can tell where a file should be
279 % installed. All |\file|s generated in the scope of that
280 % declaration are written to a directory specified by its one
281 % argument. For example in \LaTeXe{} installation following
282 % declarations are used:
284 % \usedir{tex/latex/base}
287 % And standard packages use
289 % \usedir{tex/latex/tools}
290 % \usedir{tex/latex/babel}
294 % \DescribeMacro{\showdirectory}
295 % Used to display directory names in messages. If some label is not
296 % defined it expands to |UNDEFINED (label is ...)| otherwise to a
297 % directory name. It is probably a good idea for every installation
298 % script to display at startup list of all directories that would
299 % be used and asking user to confirm that.
301 % The above macros are used by package/installation script
302 % author. The following macros are used in a configuration file,
303 % |docstrip.cfg|, by a system administrator to
304 % describe her/his local directory structure.
306 % \DescribeMacro{\BaseDirectory} This macro is administrator's way of
307 % saying ``yes, I want to use that directories support of
308 % yours''. \ds{} will write only to current directory unless your
309 % config has a call to this macro. (This means \ds{} won't write to
310 % random directories unless you tell it to, which is nice.) Using
311 % this macro you can specify a base directory for \TeX-related
312 % stuff. E.g., for many Unix systems that would be
314 % \BaseDirectory{/usr/local/lib/texmf}
316 % and for standard em\TeX{} installation
318 % \BaseDirectory{c:/emtex}
321 % \DescribeMacro{\DeclareDir}
322 % Having specified the base directory you should tell \ds{} how to
323 % interpret labels used in |\usedir| commands. This is done with
324 % |\DeclareDir| with two arguments. The first is the label and the
325 % second is actual name of directory relative to base
326 % directory. For example to teach \ds{} using standard em\TeX{}
327 % directories one would say:
329 % \BaseDirectory{c:/emtex}
330 % \DeclareDir{tex/latex/base}{texinput/latex2e}
331 % \DeclareDir{tex/latex/tools}{texinput/tools}
332 % \DeclareDir{makeindex}{idxstyle}
334 % This will cause base latex files and font descriptions to be
335 % written to directory |c:\emtex\texinput\latex2e|, files of the
336 % \texttt{tools} package to be written to |c:\emtex\texinput\tools|
337 % and makeindex files to |c:\emtex\idxstyle|.
339 % Sometimes it is desirable to put some files outside of the base
340 % directory. For that reason |\DeclareDir| has a star form
341 % specifying absolute pathname. For example one could say
343 % \DeclareDir*{makeindex}{d:/tools/texindex/styles}
346 % \DescribeMacro{\UseTDS}
347 % Users of systems conforming to TDS may well ask here ``do I
348 % really need to put a dozen of lines like
350 % \DeclareDir{tex/latex/base}{tex/latex/base}
352 % in my config file''. The answer is |\UseTDS|. This macro causes
353 % \ds{} to use labels themselves for any directory you haven't
354 % overridden with |\DeclareDir|. The default behaviour is to raise
355 % an error on undefined labels because some users may want to know
356 % exactly where files go and not to allow \ds{} to write to random
357 % places. However I (MW) think this is pretty cool and my
358 % config says just (I'm running te\TeX{} under Linux)
360 % \BaseDirectory{/usr/local/teTeX/texmf}
364 % The important thing to note here is that it is impossible to create
365 % a new directory from inside \TeX{}. So however you configure
366 % \ds, you need to create all needed directories before running
367 % the installation. Authors may want to begin
368 % every installation script by displaying a list of directories
369 % that will be used and asking user if he's sure all of them
372 % Since file name syntax is OS specific \ds{} tries to guess it
373 % from the current directory syntax. It should succeed for Unix,
374 % MSDOS, Macintosh and VMS. However \ds{} will only initially
375 % know the current directory syntax if it is used with \LaTeX.
376 % If used with plain\TeX\ or initex it will not have this
377 % information\footnote{Except when processing the main
378 % \texttt{unpack.ins} batch file for the \LaTeX\ distribution, which
379 % takes special measures so that initex can learn the directory
381 % If you often use \ds{} with formats other than \LaTeX\ you should
382 % \emph{start} the file |docstrip.cfg| with a definition of
383 % |\WriteToDir|. E.g.,
384 % |\def\WriteToDir{./}| on MSDOS/Unix,
385 % |\def\WriteToDir{:}| on Macintosh,
386 % |\def\WriteToDir{[]}| on VMS.
388 % If your system requires something
389 % completely different you can define in |docstrip.cfg| macros
390 % |\dirsep| and |\makepathname|. Check for their definition in the
391 % implementation part. If you want some substantially different
392 % scheme of translating |\usedir| labels into directory names try
393 % redefining macro |\usedir|.
395 % \subsection{Setting maximum numbers of streams}
397 % \DescribeMacro{\maxfiles}
398 % In support of some of the more obscure operating systems, there's
399 % a limit on the number of files a program can have open. This can
400 % be expressed to \ds\ through the |\maxfiles| macro. If the number
401 % of streams \ds\ is allowed to open is $n$, your configuration file
402 % can say |\maxfiles{|$n$|}|, and \ds\ won't try to open more files
403 % than this. Note that this limit won't include files which are
404 % already open. There'll usually be two of these: the installation
405 % script which you started, and the file |docstrip.tex| which it
406 % included; you must bear these in mind yourself. \ds\ assumes
407 % that it can open at least four files before it hits some kind of
408 % maximum: if this isn't the case, you have real problems.
410 % \DescribeMacro{\maxoutfiles}
411 % Maybe instead of having a limit on the number of files \TeX\ can
412 % have open, there's a limit on the number of files it can write
413 % to (e.g., \TeX\ itself imposes a limit of 16~files being written
414 % at a time). This can be expressed by saying |\maxoutfiles{|$m$|}|
415 % in a configuration file. You must be able to have at least one
416 % output file open at a time; otherwise \ds\ can't do anything at
419 % Both these options would typically be put in the |docstrip.cfg|
423 % \section{The user interface}
425 % \subsection{The main program}
426 % \DescribeMacro{\processbatchFile} The `main program' starts with
427 % trying to process a batch file, this is accomplished by calling
428 % the macro |\processbatchFile|. It counts the number of batch
429 % files it processes, so that when the number of files processed is
430 % still zero after the call to |\processbatchFile| appropriate
431 % action can be taken.
433 % \DescribeMacro{\interactive} When no batch files have been processed
434 % the macro |\interactive| is called. It prompts the user for
435 % information. First the extensions of the input and output files
436 % is determined. Then a question about optional code is asked and
437 % finally the user can give a list of files that have to be
440 % \DescribeMacro{\ReportTotals} When the \texttt{stats} option is
441 % included in the \ds{}-program it keeps a record of the number of
442 % files and lines that are processed. Also the number of comments
443 % removed and passed as well as the number of code lines that were
444 % passed to the output are accounted. The macro |\ReportTotals|
445 % shows a summary of this information.
447 % \subsection{Batchfile commands}
449 % The commands described in this section are available to build a
450 % batch file for \TeX.
452 % \DescribeMacro{\input}
453 % All \ds{} batch files should start with the line: |\input docstrip|
455 % Do not use the \LaTeX\ syntax |\input{docstrip}| as batch files may
456 % be used with plain~\TeX\ or ini\TeX.
457 % You may that old batch files always have a line
458 % |\def\batchfile{|\meta{filename}|}|
459 % just before the input.
460 % Such usage is still supported but is now discouraged, as it causes
461 % \TeX\ to re-input the same file, using up one of its limited number
464 % \DescribeMacro{\endbatchfile}
465 % All batch files should end with this command. Any lines after this
466 % in the file are ignored. In old files that start
467 % |\def\batchfile{|\ldots\ this command is optional, but is a good
468 % idea anyway. If this command is omitted from a batchfile then
469 % normally \TeX\ will go to its interactive |*| prompt, so you may
470 % stop \ds{} by typing |\endbatchfile| to this prompt.
472 % \DescribeMacro{\generate}
473 % \DescribeMacro{\file}
474 % \DescribeMacro{\from}
475 % The main reason for constructing a \ds{} command file is to
476 % describe what files should be generated, from what sources and
477 % what optional (`guarded') pieces of code should be included. The
478 % macro |\generate| is used to give \TeX\ this information. Its
481 % |\generate{|[|\file{|\meta{output}|}{|[|\from{|^^A
482 % \meta{input}|}{|\meta{optionlist}|}|]*|}|]*|}|
484 % The \meta{output} and \meta{input} are normal file specifications
485 % as are appropriate for your computer system. The
486 % \meta{optionlist} is a comma separated list of `options' that
487 % specify which optional code fragments in \meta{input} should be
488 % included in \meta{output}. Argument to |\generate| may contain
489 % some local declarations (e.g., the |\use...| commands described
490 % below) that will apply to all |\file|s after them. Argument to
491 % |\generate| is executed inside a group, so all local declarations
492 % are undone when |\generate| concludes.
494 % It is possible to specify multiple input files, each with its own
495 % \meta{optionlist}. This is indicated by the notation [\ldots]*.
496 % Moreover there can be many |\file| specifications in one
497 % |\generate| clause. This means that all these \meta{output} files
498 % should be generated while reading each of \meta{input} files
499 % once. Input files are read in order of first appearance in this
502 % \generate{\file{p1.sty}{\from{s1.dtx}{foo,bar}}
503 % \file{p2.sty}{\from{s2.dtx}{baz}
504 % \from{s3.dtx}{baz}}
505 % \file{p3.sty}{\from{s1.dtx}{zip}
506 % \from{s2.dtx}{zip}}
509 % will cause \ds{} to read files \texttt{s1.dtx}, \texttt{s2.dtx},
510 % \texttt{s3.dtx} (in that order) and produce files
511 % \texttt{p1.sty}, \texttt{p2.sty}, \texttt{p3.sty}.
513 % The restriction to at most 16 output streams open in a while
514 % does not mean that you can produce at most 16 files with one
515 % |\generate|. In the example above only 2 streams are needed,
516 % since while \texttt{s1.dtx} is processed only \texttt{p1.sty} and
517 % \texttt{p3.sty} are being generated; while reading
518 % \texttt{s2.dtx} only \texttt{p2.sty} and \texttt{p3.sty}; and
519 % while reading \texttt{s3.dtx} file \texttt{p2.sty} . However
520 % example below needs 3 streams:
522 % \generate{\file{p1.sty}{\from{s1.dtx}{foo,bar}}
523 % \file{p2.sty}{\from{s2.dtx}{baz}
524 % \from{s3.dtx}{baz}}
525 % \file{p3.sty}{\from{s1.dtx}{zip}
526 % \from{s3.dtx}{zip}}
529 % Although while reading \texttt{s2.dtx} file \texttt{p3.sty} is
530 % not written it must remain open since some parts of
531 % \texttt{s3.dtx} will go to it later.
533 % Sometimes it is not possible to create a file by reading all
534 % sources once. Consider the following example:
536 % \generate{\file{p1.sty}{\from{s1.dtx}{head}
538 % \from{s1.dtx}{tail}}
539 % \file{s1.drv}{\from{s1.dtx}{driver}}
542 % To generate \texttt{p1.sty} file \texttt{s1.dtx} must be read
543 % twice: first time with option \texttt{head}, then file
544 % \texttt{s2.dtx} is read and then \texttt{s1.dtx} again this time
545 % with option \texttt{tail}. \ds{} handles this case correctly: if
546 % inside one |\file| declaration there are multiple |\from|es with
547 % the same input file this file \emph{is} read multiple times.
549 % If the order of |\from|s specified in one of your |\file|
550 % specifications does not match the order of input files
551 % established by previous |\file|s, \ds{} will raise an error and
552 % abort. Then you may either read one of next sections or give up
553 % and put that file in separate |\generate| (but then sources will
554 % be read again just for that file).
556 % \paragraph{For impatient.} Try following algorithm: Find
557 % file that is generated from largest number of sources, start
558 % writing |\generate| clause with this file and its sources in
559 % proper order. Take other files that are to be generated and add
560 % them checking if they don't contradict order of sources for the
561 % first one. If this doesn't work read next sections.
563 % \paragraph{For mathematicians.} Relation ``file $A$ must be
564 % read before file $B$'' is a partial order on the set of all your
565 % source files. Each |\from| clause adds a chain to this order.
566 % What you have to do is to perform a topological sort i.e. to
567 % extend partial order to linear one. When you have done it just
568 % list your source files in |\generate| in such a way that order of
569 % their first appearance in the clause matches linear order. If
570 % this cannot be achieved read next paragraph. (Maybe future
571 % versions of \ds{} will perform this sort automatically, so all
572 % these troubles will disappear.)
574 % \paragraph{For that who must know that all.} There is a
575 % diverse case when it's not possible to achieve proper order of
576 % reading source files. Suppose you have to generate two files,
577 % first from \texttt{s1.dtx} and \texttt{s3.dtx} (in that order)
578 % and second from \texttt{s2.dtx} and \texttt{s3.dtx}. Whatever
579 % way you specify this the files will be read in either as
580 % \texttt{s1 s3 s2} or \texttt{s2 s3 s1}. The key to solution is
581 % magical macro |\needed| that marks a file as needed to be input
582 % but not directing any output from it to current |\file|. In our
583 % example proper specification is:
585 % \generate{\file{p1.sty}{\from{s1.dtx}{foo}
587 % \from{s3.dtx}{bar}}
588 % \file{p2.sty}{\from{s2.dtx}{zip}
589 % \from{s3.dtx}{zap}}
594 % \DescribeMacro{\askforoverwritetrue}
595 % \DescribeMacro{\askforoverwritefalse}
596 % These macros specify what should happen if a file that is to be
597 % generated already exists. If |\askforoverwritetrue| is active
598 % (the default) the user is asked whether the file should be
599 % overwritten. If however |\askforoverwritefalse| was issued
600 % existing files will be overwritten silently. These switches are
601 % local and can be issued in any place in the file even inside
602 % |\generate| clause (between |\file|s however).
604 % \DescribeMacro{\askonceonly}
605 % You might not want to set |\askforoverwritefalse| in a batch file
606 % as that says that it us always all right to overwrite other people's
607 % files. However for large installations, such as the base \LaTeX\
608 % distribution, being asked individually about hundreds of files
609 % is not very helpful either. A batchfile may therefore specify
610 % |\askonceonly|. This means that after the first time the batchfile
611 % asks the user a question, the user is given an option of to change
612 % the behaviour so that `yes' will be automatically assumed for all
613 % future questions. This applies to any use of the \ds{} command
614 % |\Ask| including, but not restricted to, the file overwrite
615 % questions controlled by |\askforoverwritetrue|.
617 % \DescribeMacro{\preamble}
618 % \DescribeMacro{\endpreamble}
619 % \DescribeMacro{\postamble}
620 % \DescribeMacro{\endpostamble}
621 % It is possible to add a number of lines to the output of the
622 % \ds{} program. The information you want to add to the start of
623 % the output file should be listed between the |\preamble| and
624 % |\endpreamble| commands; the lines you want to add to the end of
625 % the output file should be listed between the |\postamble| and
626 % |\endpostamble| commands. Everything that \ds{} finds for both
627 % the pre- and postamble it writes to the output file, but preceded
628 % with value of |\MetaPrefix| (default is two \%-characters). If
629 % you include a |^^J| character in one of these lines, everything
630 % that follows it on the same line is written to a new line in the
631 % output file. This `feature' can be used to add a |\typeout| or
632 % |\message| to the stripped file.
634 % \DescribeMacro{\declarepreamble}
635 % \DescribeMacro{\declarepostamble}
636 % \DescribeMacro{\usepreamble}
637 % \DescribeMacro{\usepostamble}
638 % \DescribeMacro{\nopreamble}
639 % \DescribeMacro{\nopostamble}
640 % Sometimes it is desirable to have different preambles for different
641 % files of a larger package (e.g., because some of them are
642 % customisable configuration files and they should be marked as
643 % such). In such a case one can say |\declarepreamble\somename|,
644 % then type in his/her preamble, end it with |\endpreamble|,
645 % and later on |\usepreamble\somename| to switch to this
647 % If no preamble should be used you can deploy the |\nopreamble|
648 % command. This command is equivalent to saying |\usepreamble\empty|.
649 % The same mechanism works for postambles, |\use...|
650 % declarations are local and can appear inside |\generate|.
652 % Commands |\preamble| and |\postamble| define and activate
653 % pre(post)ambles named |\defaultpreamble| and |\defaultpostamble|.
655 % \DescribeMacro{\batchinput}
656 % The batch file commands can be put into several batch files which
657 % are then executed from a master batch file. This is, for example,
658 % useful if a distribution consists of several distinct parts. You
659 % can then write individual batch files for every part and in
660 % addition a master file that simply calls the batch files for the
661 % parts. For this, call the individual batch files from the master
662 % file with the command |\batchinput{|\meta{file}|}|. Don't use
663 % |\input| for this purpose, this command
664 % should be used only for calling the \ds{} program as explained
665 % above and is ignored when used for any other purpose.
667 % \DescribeMacro{\ifToplevel}
668 % When batch files are nested you may want to suppress certain
669 % commands in the lower-level batch files such as terminal
670 % messages. For this purpose you can use the |\ifToplevel| command
671 % which executes its argument only if the current batch file is the
672 % outermost one. Make sure that you put the opening brace of the
673 % argument into the same line as the command itself, otherwise the
674 % \ds{} program will get confused.
676 % \DescribeMacro{\showprogress}
677 % \DescribeMacro{\keepsilent}
678 % When the option \texttt{stats} is included in \ds{} it can
679 % write message to the terminal as each line of the input file(s) is
680 % processed. This message consists of a single character, indicating
681 % kind of that particular line. We use the
682 % following characters:
684 % \item[\texttt{\%}] Whenever an input line is a comment
685 % \texttt{\%}-character is written to the terminal.
686 % \item[\texttt{.}] Whenever a code line is encountered
687 % a \texttt{.}-character is written on the terminal.
688 % \item[\texttt{/}] When a number of empty lines appear in a row in the
689 % input file, at most one of them is retained. The \ds{}
690 % program signals the removal of an empty line with the
691 % \texttt{/}-character.
692 % \item[\texttt{<}] When a `guard line' is found in the input and it
693 % starts a block of optionally included code, this is signalled
694 % on the terminal by showing the \texttt{<}-character, together
695 % with the boolean expression of the guard.
696 % \item[\texttt{>}] The end of a conditionally included block of code is
697 % indicated by showing the \texttt{>}-character.
699 % This feature is turned on by default when the option
700 % \texttt{stats} is included, otherwise it is turned off. The
701 % feature can be toggled with the commands |\showprogress| and
705 % \subsubsection{Supporting old interface}
707 % \DescribeMacro{\generateFile}
708 % Here is the old syntax for specifying what files are to be
709 % generated. It allows specification of just one output file.
711 % |\generateFile{|\meta{output}|}{|\meta{ask}|}{|[|\from{|^^A
712 % \meta{input}|}{|\meta{optionlist}|}|]*|}|
714 % The meaning of \meta{output}, \meta{input} and
715 % \meta{optionslist} is just as for |\generate|. With
716 % \meta{ask} you can instruct \TeX\ to either silently overwrite a
717 % previously existing file (|f|) or to issue a warning and ask you
718 % if it should overwrite the existing file (|t|) (it overrides the
719 % |\askforoverwrite| setting).
721 % \DescribeMacro{\include}
722 % \DescribeMacro{\processFile}
723 % The earlier version of the \ds{} program supported a
724 % different kind of command to tell \TeX\ what to do. This command
725 % is less powerful than |\generateFile|; it can be used when
726 % \meta{output} is created from one \meta{input}. The syntax is:
728 % |\include{|\meta{optionlist}|}|
730 % |\processFile{|\meta{name}|}{|\meta{inext}^^A
731 % |}{|\meta{outext}^^A
734 % This command is based on environments where filenames are
735 % constructed of two parts, the name and the extension, separated
736 % with a dot. The syntax of this command assumes that the
737 % \meta{input} and \meta{output} share the same name and only
738 % differ in their extension. This command is retained to be
739 % backwards compatible with the older version of \ds{}, but its use
742 % \section{Conditional inclusion of code}
744 % When you use the \ds{} program to strip comments out of
745 % \TeX\ macro files you have the possibility to make more than one
746 % stripped macro file from one documented file. This is achieved by
747 % the support for optional code. The optional code is marked
748 % in the documented file with a `guard'.
750 % A guard is a boolean expression that is enclosed in |<| and |>|.
751 % It also {\em has\/} to follow the |%| at the beginning of the line.
758 % In this example the line of code will be included in \meta{output}
759 % if the option \texttt{bool} is present in the \meta{optionlist} of
760 % the |\generateFile| command.
762 % The syntax for the boolean expressions is:
765 % \begin{tabular}{lcl}
766 % \meta{Expression} & $::=$ & \meta{Secondary}
767 % [\{\texttt{|}, \texttt{,}\}
768 % \meta{Secondary}]*\\
769 % \meta{Secondary} & $::=$ &
770 % \meta{Primary} [\texttt{\&}
772 % \meta{Primary} & $::=$ &
773 % \meta{Terminal} $|$ \texttt{!}\meta{Primary}
774 % $|$ \texttt{(}\meta{Expression}\texttt{)}\\
777 % The \texttt{|} stands for disjunction, the \texttt{\&} stands for
778 % conjunction and the \texttt{!}\ stands for negation. The
779 % \meta{Terminal} is any sequence of letters and evaluates to
780 % \meta{true} iff\footnote{iff stands for `if and only if'} it
781 % occurs in the list of options that have to be included.
784 % Two kinds of optional code are supported: one can either have
785 % optional code that `fits' on one line of text, like the example
786 % above, or one can have blocks of optional code.
788 % To distinguish both kinds of optional code the `guard modifier'
789 % has been introduced. The `guard modifier' is one character that
790 % immediately follows the |<| of the guard. It can be either |*|
791 % for the beginning of a block of code, or |/| for the end of a
792 % block of code\footnote{To be compatible with the earlier version
793 % of \ds{} also \texttt{+} and \texttt{-} are supported as `guard
794 % modifiers'. However, there is an incompatibility with the
795 % earlier version since a line with a \texttt{+}-modified guard is
796 % not included inside a block with a guard that evaluates to false,
797 % in contrast to the previous behaviour.}. The beginning and
798 % ending guards for a block of code have to be on a line by
801 % When a block of code is {\em not\/} included, any guards that occur
802 % within that block are {\em not\/} evaluated.
804 % \section{Those other languages}
805 % Since \TeX\ is an open system some of \TeX\ packages include
806 % non-\TeX\ files. Some authors use \ds\ to generate PostScript
807 % headers, shell scripts or programs in other languages. For them
808 % the comments-stripping activity of \ds\ may cause some
809 % trouble. This section describes how to produce non-\TeX\ files
810 % with \ds\ effectively.
812 % \subsection{Stuff \ds\ puts in every file}
813 % First problem when producing files in ``other'' languages is that
814 % \ds\ adds some bits to the beginning and end of every generated
815 % file that may not fit with the syntax of the language in
816 % question. So we'll study carefully what exactly goes where.
818 % The whole text put on beginning of file is kept in a macro defined
819 % by |\declarepreamble|. Every line of input presented to
820 % |\declarepreamble| is prepended with current value of
821 % |\MetaPrefix|. Standard \ds\ header is inserted before your text,
822 % and macros |\inFileName|, |\outFileName| and |\ReferenceLines|
823 % are used as placeholders for information which will be filled in
824 % later (specifically for each output file). Don't try to redefine
825 % these macros. After
827 % \declarepreamble\foo
828 % ____________________________
829 % Package FOO for use with TeX
832 % macro |\foo| is defined as
835 % %% This is file `\outFileName ',^^J
836 % %% generated with the docstrip utility.^^J
838 % %% ____________________________^^J
839 % %% Package FOO for use with TeX.
841 % You can play with it freely or even define it from scratch. To
842 % embed the preamble in Adobe structured comments just use |\edef|:
844 % \edef\foo{\perCent!PS-Adobe-3.0^^J%
845 % \DoubleperCent\space Title: \outFileName^^J%
847 % \DoubleperCent\space EndComments}
849 % After that use |\usepreamble\foo| to select your new preamble.
850 % Everything above works as well for postambles.
852 % You may also prevent \ds\ from adding anything to your file, and
853 % put any language specific invocations directly in your code:
855 % \generate{\usepreamble\empty
856 % \usepostamble\empty
857 % \file{foo.ps}{\from{mypackage.dtx}{ps}}}
859 % or alternatively |\nopreamble| and |\nopostamble|.
861 % \subsection{Meta comments}
862 % You can change the prefix used for putting meta comments to
863 % output files by redefining |\MetaPrefix|. Its default value is
864 % |\DoubleperCent|. The preamble uses value of |\MetaPrefix|
865 % current at time of |\declarepreamble| while meta comments in the
866 % source file use value current at time of |\generate|. Note that
867 % this means that you cannot produce concurrently two files using
868 % different |\MetaPrefix|es.
870 % \subsection{Verbatim mode}
871 % If your programming language uses some construct that can
872 % interferes badly with \ds\ (e.g., percent in column one) you may
873 % need a way for preventing it from being stripped off. For that
874 % purpose \ds\ features `verbatim mode'.
876 % A `Guard expression' of the form |%<<|\meta{END-TAG} marks
877 % the start of a section that will be copied verbatim upto a line
878 % containing only a percent in column 1 followed by \meta{END-TAG}.
879 % You can select any \meta{END-TAG} you want, but note that spaces
880 % count here. Example:
886 % % These two lines are copied verbatim (including percents
887 % %% even if \MetaPrefix is something different than %%).
889 % using*strange@programming<language>
892 % And the output is (when stripped with \texttt{myblock} defined):
896 % % These two lines are copied verbatim (including percents
897 % %% even if \MetaPrefix is something different than %%).
898 % using*strange@programming<language>
902 %^^A \section{Conclusion}
908 % \section{Producing the documentation}
910 % We provide a short driver file that can be extracted by the
911 % \ds{} program using the conditional `\textsf{driver}'. To
912 % allow the use of \texttt{docstrip.dtx} as a program at Ini\TeX{}
913 % time (e.g., to strip
914 % off its own comments) we need to add a bit of primitive code.
915 % With this extra checking it is still possible to process this
916 % file with \LaTeXe{} to typeset the documentation.
917 % \changes{2.1b}{1993/02/23}{Added fontdefinitions for doc to the driver
918 % file, in order to get the layout of the code
919 % right; also added the layout definitions
920 % that are in effect in \texttt{doc.drv}}
921 % \changes{2.1c}{1993/02/23}{Remove definitions for fonts again}
922 % \changes{2.2f}{1994/02/26}{Allow direct processing of source}
926 % If |\documentclass| is undefined, e.g., if Ini\TeX{} or plain
927 % \TeX{} is used for formatting, we bypass the driver file.
929 % \changes{2.3a}{1995/08/20}{Changed driver}
930 % We use some trickery to avoid issuing |\end{document}| when
931 % the |\ifx| construction is unfinished. If condition below is
932 % true a |\fi| is constructed on the fly, the |\ifx| is completed,
933 % and the real |\fi| will never be seen as it comes after
934 % |\end{document}|. On the other hand if condition is false
935 % \TeX\ skips over |\csname fi\endcsname| having no idea that
936 % this could stand for |\fi|, driver is skipped and only then
937 % the condition completed.
939 % Additional guard |gobble| prevents \ds\ from extracting
940 % these tricks to real driver file.
943 \ifx\jobname\relax\let\documentclass\undefined\fi
944 \ifx\documentclass\undefined
945 \else \csname fi\endcsname
948 % Otherwise we process the following lines which will result in
949 % formatting the documentation.
951 \documentclass{ltxdoc}
954 % use \DisableCrossrefs if the
958 \typeout{Expect some Under- and overfull boxes}
960 \DocInput{docstrip.dtx}
969 % \section{The implementation}
971 % \subsection{Initex initializations}
972 % Allow this program to run with |initex|.
973 % The |Z| trickery saves the need to worry about |\outer| stuff in
977 \catcode`\Z=\catcode`\%
978 \ifnum13=\catcode`\~{\egroup\else
981 Z \catcode`\{=1 \catcode`\}=2
982 Z \catcode`\#=6 \catcode`\^=7
983 Z \catcode`\@=11 \catcode`\^^L=13
984 Z \let\bgroup={ \let\egroup=}
986 Z \dimendef\z@=10 \z@=0pt \chardef\@ne=1 \countdef\m@ne=22 \m@ne=-1
987 Z \countdef\count@=255
989 Z \def\wlog{\immediate\write\m@ne} \def\space{ }
991 Z \count10=22 % allocates \count registers 23, 24, ...
992 Z \count15=9 % allocates \toks registers 10, 11, ...
993 Z \count16=-1 % allocates input streams 0, 1, ...
994 Z \count17=-1 % allocates output streams 0, 1, ...
996 Z \def\alloc@#1#2#3{\advance\count1#1\@ne#2#3\count1#1\relax}
998 Z \def\newcount{\alloc@0\countdef} \def\newtoks{\alloc@5\toksdef}
999 Z \def\newread{\alloc@6\chardef} \def\newwrite{\alloc@7\chardef}
1002 Z \count@\escapechar \escapechar\m@ne
1006 Z \escapechar\count@}
1008 Z \expandafter\def\csname\expandafter\@gobbletwo\string#1%
1009 Z \expandafter\@gobbletwo\string#2\endcsname
1012 Z \def\@gobbletwo#1#2{}
1013 Z \def\@gobblethree#1#2#3{}
1015 Z \def\loop#1\repeat{\def\body{#1}\iterate}
1016 Z \def\iterate{\body \let\next\iterate \else\let\next\relax\fi \next}
1021 Z \def\tracingall{\tracingcommands2 \tracingstats2
1022 Z \tracingpages1 \tracingoutput1 \tracinglostchars1
1023 Z \tracingmacros2 \tracingparagraphs1 \tracingrestores1
1024 Z \showboxbreadth 10000 \showboxdepth 10000 \errorstopmode
1025 Z \errorcontextlines 10000 \tracingonline1 }
1027 \bgroup}\fi\catcode`\Z=11
1028 \let\bgroup={ \let\egroup=}
1032 % \subsection{Declarations and initializations}
1034 % In order to be able to include the \texttt{@}-sign in control
1035 % sequences its category code is changed to \meta{letter}. The
1036 % `program' guard here allows most of the code to be excluded when
1037 % extracting the driver file.
1043 % When we want to write multiple lines to the terminal with one
1044 % statement, we need a character that tells \TeX\ to break the lines.
1045 % We use \verb=^^J= for this purpose.
1050 % \subsubsection{Switches}
1051 % \begin{macro}{\ifGenerate}
1052 % The program will check if a
1053 % file of the same name as the file it would be creating already
1054 % exists. The switch |\ifGenerate| is used to indicate if the
1055 % stripped file has to be generated.
1061 % \begin{macro}{\ifContinue}
1062 % The switch |\ifContinue| is used in various places in the
1063 % program to indicate if a |\loop| has to end.
1069 % \begin{macro}{\ifForlist}
1070 % \changes{2.0g}{1991/06/05}{Macro added.}
1071 % The program contains an implementation of a for-loop, based on
1072 % plain \TeX{}'s |\loop| macros. The implementation needs a
1073 % switch to terminate the loop.
1079 % \begin{macro}{\ifDefault}
1080 % The switch |\ifDefault| is used to indicate whether the
1081 % default batch file has to be used.
1082 % \changes{2.0f}{1991/06/04}{Macro added.}
1088 % \begin{macro}{\ifMoreFiles}
1089 % The switch |\ifMoreFiles| is used to decide if the user
1090 % wants more files to be processed. It is used only in interactive
1091 % mode; initially it evaluates to \meta{true}.
1092 % \changes{2.0h}{1991/06/19}{Macro added.}
1094 \newif\ifMoreFiles \MoreFilestrue
1097 % \begin{macro}{\ifaskforoverwrite}
1098 % The switch |\askforoverwrite| is used to decide if the user
1099 % should be asked when a file is to be overwritten.
1101 \newif\ifaskforoverwrite \askforoverwritetrue
1105 % \subsubsection{Count registers}
1106 % \begin{macro}{\blockLevel}
1107 % Optionally included blocks of code can be nested. The counter
1108 % |\blockLevel| will be used to keep track of the level of
1109 % nesting. Its initial value is zero.
1111 \newcount\blockLevel \blockLevel\z@
1115 % \begin{macro}{\emptyLines}
1116 % The count register |\emptyLines| is used to count the number
1117 % of consecutive empty input lines. Only the first will be copied
1118 % to the output file.
1119 % \changes{2.0i}{1990/06/27}{Macro added}
1121 \newcount\emptyLines \emptyLines \z@
1125 % \begin{macro}{\processedLines}
1126 % \begin{macro}{\commentsRemoved}
1127 % \begin{macro}{\commentsPassed}
1128 % \begin{macro}{\codeLinesPassed}
1129 % To be able to provide the user with some statistics about the
1130 % stripping process four counters are allocated if the statistics
1131 % have been included when this program was \ds{}ped. The number of
1132 % lines processed is stored in the counter |\processedLines|.
1133 % The number of lines containing comments that are not written on
1134 % the output file is stored in the counter |\commentsRemoved|;
1135 % the number of comments copied to the output file is stored in the
1136 % counter |\commentsPassed|. The number of lines containing
1137 % macro code that are copied to the output file is stored in the
1138 % counter |\codeLinesPassed|.
1141 \newcount\processedLines \processedLines \z@
1142 \newcount\commentsRemoved \commentsRemoved \z@
1143 \newcount\commentsPassed \commentsPassed \z@
1144 \newcount\codeLinesPassed \codeLinesPassed \z@
1151 % \changes{2.0e}{1991/05/31}{Added counter allocation for the processing
1152 % of multiple files}
1153 % \begin{macro}{\TotalprocessedLines}
1154 % \begin{macro}{\TotalcommentsRemoved}
1155 % \begin{macro}{\TotalcommentsPassed}
1156 % \begin{macro}{\TotalcodeLinesPassed}
1157 % When more than one file is processed and when statistics have
1158 % been included we provide the user also with information about the
1159 % total amount of lines processed. For this purpose four more count
1160 % registers are allocated here.
1162 \newcount\TotalprocessedLines \TotalprocessedLines \z@
1163 \newcount\TotalcommentsRemoved \TotalcommentsRemoved \z@
1164 \newcount\TotalcommentsPassed \TotalcommentsPassed \z@
1165 \newcount\TotalcodeLinesPassed \TotalcodeLinesPassed \z@
1173 % \begin{macro}{\NumberOfFiles}
1174 % When more than one file is processed, the number of files is
1175 % stored in the count register |\NumberOfFiles|.
1176 % \changes{2.4h}{1997/07/07}{Declare counter always pr/2429}
1178 \newcount\NumberOfFiles \NumberOfFiles\z@
1182 % \subsubsection{I/O streams}
1183 % \begin{macro}{\inFile}
1184 % For reading the file with documented \TeX-code, an input stream
1185 % |\inFile| is allocated.
1191 % \changes{2.3a}{1995/08/18}{No allocated streams for console}
1192 % \begin{macro}{\ttyin}
1193 % \begin{macro}{\ttyout}
1194 % Communication with the user goes through (nonexistent) stream 16.
1202 % \begin{macro}{\inputcheck}
1203 % This stream is only used for checking for existence of files.
1209 % \begin{macro}{\ifToplevel}
1210 % Execute the argument if current batch file is the outermost one.
1211 % Otherwise suppress it.
1213 \newif\iftopbatchfile \topbatchfiletrue
1214 \def\ifToplevel{\relax\iftopbatchfile
1215 \expandafter\iden \else \expandafter\@gobble\fi}
1219 % \begin{macro}{\batchinput}
1220 % \changes{2.0n}{1992/04/26}{Added macro}
1221 % \changes{2.1a}{1993/02/22}{Completely redefined (so that it works)}
1223 % When the file \texttt{docstrip.tex} is read because of an
1224 % |\input| statement in a batch file we have to prevent an
1225 % endless loop (well, limited by \TeX's stack). Therefore we save
1226 % the original primitive |\input| and define a new macro with
1227 % an argument delimited by \verb*= = (i.e.\ a space) that just
1228 % gobbles the argument. Since the end-of-line character is
1229 % converted by \TeX{} to a space. This means that |\input| is not
1230 % available as a command within batch files.
1232 % \begin{macro}{\@@input}
1233 % \changes{2.1a}{1993/02/22}{Macro added}
1234 % We therefore keep a copy of the original under the name
1235 % |\@@input| for internal use. If \ds{} runs under \LaTeX{} this
1236 % command is already defined, so we make a quick test.
1238 \ifx\undefined\@@input \let\@@input\input\fi
1242 % To allow the nesting of batch files the |\batchinput| command is
1243 % provided it takes one argument, the name of the batch file to
1248 % We start a new group and locally redefine |\batchFile| to hold
1249 % the new batch file name. We toggle the |\iftopbatchfile| switch
1250 % since this definitely is not top batch file.
1256 \usepreamble\org@preamble
1257 \usepostamble\org@postamble
1258 \let\destdir\WriteToDir
1260 % After this we can simply call |\processbatchFile| which will
1261 % open the new batch file and read it until it
1262 % is exhausted. Note that if the batch file is not available, or
1263 % misspelled this routine will produce a warning and return.
1267 % The value of |\batchfile| as well as local definitions of
1268 % preambles, directories etc. will be restored
1269 % at this closing |\endgroup|, so that further processing
1270 % continues in the calling batch file.
1275 % \begin{macro}{\skip@input}
1276 % \changes{2.0j}{1992/03/03}{Added macro}
1277 % \changes{2.0n}{1992/04/26}{Argument delimited by space not \cs{relax}}
1278 % \changes{2.0n}{1992/04/26}{Macro renamed from \cs{skipinput}}
1279 % And here is the promised redefinition of |\input|:
1281 \def\skip@input#1 {}
1282 \let\input\skip@input
1287 % \subsubsection{Empty macros and macros that expand to a string}
1288 % \begin{macro}{\guardStack}
1289 % \changes{2.0k}{1992/04/06}{Renamed from \texttt{\bsl blockStack}}
1290 % Because blocks of code that will conditionally be included in the
1291 % output can be nested, a stack is maintained to keep track of
1292 % these blocks. The main reason for this is that we want to be able
1293 % to check if the blocks are properly nested. The stack itself is
1294 % stored in |\guardStack|.
1300 % \begin{macro}{\blockHead}
1301 % The macro |\blockHead| is used for storing and retrieving
1302 % the boolean expression that starts a block.
1308 % \begin{macro}{\yes}
1310 % When the user is asked a question that he has to answer with either
1311 % \meta{yes} or \meta{no}, his response has to be evaluated. For this
1312 % reason the macros |\yes| and |\y| are defined.
1318 % We also define |\n| for use in \ds{} command files.
1319 % \changes{2.1e}{1993/03/09}{Macro added}
1327 % \begin{macro}{\Defaultbatchile}
1328 % \changes{2.0f}{1991/06/04}{Macro added.}
1329 % When the \ds{} program has to process a batch file it
1330 % can look for a batch file with a default name. This name
1331 % is stored in |\DefaultbatchFile|.
1333 \def\DefaultbatchFile{docstrip.cmd}
1337 % \begin{macro}{\perCent}
1338 % \begin{macro}{\DoubleperCent}
1339 % \begin{macro}{\MetaPrefix}
1340 % To be able to display percent-signs on the terminal, a
1341 % \texttt{\%} with category code 12 is stored in |\perCent| and
1342 % |\DoubleperCent|. The macro |\MetaPrefix| is put on beginning of
1343 % every meta-comment line. It is defined indirect way since some
1344 % applications need redefining it.
1348 \gdef\DoubleperCent{%%}
1350 \let\MetaPrefix\DoubleperCent
1355 % In order to allow formfeeds in the input we define a one-character
1356 % control sequence \verb=^^L=.
1361 % The only result of using |\Name| is slowing down execution since
1362 % its typical use (e.g., |\Name\def{foo bar}...|) has exactly the
1363 % same number of tokens as its expansion. However I think that it's
1364 % easier to read. The meaning of |\Name| as a black box is:
1365 % ``construct a name from second parameter and then pass it to your
1366 % first parameter as a parameter''.
1368 % |\@stripstring| is used to get tokens building name of a macro
1369 % without leading backslash.
1371 \def\Name#1#2{\expandafter#1\csname#2\endcsname}
1372 \def\@stripstring{\expandafter\@gobble\string}
1375 % \subsubsection{Miscellaneous variables}
1376 % \begin{macro}{\sourceFileName}
1377 % The macro |\sourceFileName| is used to store the name of the
1378 % current input file.
1380 % \begin{macro}{\batchfile}
1381 % The macro |\batchfile| is used to store the name of the
1384 % \begin{macro}{\inLine}
1385 % The macro |\inLine| is used to store the lines, read from
1386 % the input file, before further processing.
1388 % \begin{macro}{\answer}
1389 % When some interaction with the user is needed the macro
1390 % |\answer| is used to store his response.
1392 % \begin{macro}{\tmp}
1393 % Sometimes something has to be temporarily stored in a control
1394 % sequence. For these purposes the control sequence |\tmp| is
1398 % \subsection{Support macros}
1399 % \subsubsection{The stack mechanism}
1401 % It is possible to have `nested guards'. This means that within a
1402 % block of optionally included code a subgroup is only included
1403 % when an additional option is specified. To keep track of the
1404 % nesting of the guards the currently `open' guard can be pushed on
1405 % the stack |\guardStack| and later popped off the stack again. The
1406 % macros that implement this stack mechanism are loosely based on
1407 % code that is developed in the context of the \LaTeX3 project.
1409 % To be able to implement a stack mechanism we need a couple of
1411 % \begin{macro}{\eltStart}
1412 % \changes{2.0k}{1992/04/06}{Macro added}
1413 % \begin{macro}{\eltEnd}
1414 % \changes{2.0k}{1992/04/06}{Macro added}
1415 % The macros |\eltStart| and |\eltEnd| are used to delimit a stack
1416 % element. They are both empty.
1424 % \begin{macro}{\qStop}
1425 % \changes{2.0k}{1992/04/06}{Macro added}
1426 % The macro |\qStop| is a so-called `quark', a macro that expands to
1427 % itself\footnote{The concept of `quarks' is developed for the
1428 % \LaTeX3 project.}.
1434 % \begin{macro}{\pop}
1435 % \changes{2.0k}{1992/04/06}{Macro added} The macro
1436 % |\pop|\meta{stack}\meta{cs} `pops' the top element from the
1437 % stack. It assigns the value of the top element to \meta{cs} and
1438 % removes it from \meta{stack}. When \meta{stack} is empty a
1439 % warning is issued and \meta{cs} is assigned an empty value.
1443 \Msg{Warning: Found end guard without matching begin}%
1447 % To be able to `peel' off the first guard we use an extra macro
1448 % |\popX| that receives both the expanded and the unexpanded stack
1449 % in its arguments. The expanded stack is delimited with the quark
1452 \def\tmp{\expandafter\popX #1\qStop #1#2}%
1453 \expandafter\tmp\fi}
1455 % \begin{macro}{\popX}
1456 % \changes{2.0k}{1992/04/06}{Macro added} When the stack is expanded
1457 % the elements are surrounded with |\eltStart| and |\eltEnd|. The
1458 % first element of the stack is assigned to |#4|.
1460 \def\popX\eltStart #1\eltEnd #2\qStop #3#4{\def#3{#2}\def#4{#1}}
1465 % \begin{macro}{\push}
1466 % \changes{2.0k}{1992/04/06}{Macro added}
1467 % Guards can be pushed on the stack using the macro
1468 % |\push|\meta{stack}\meta{guard}. Again we need a secondary macro
1469 % (|\pushX|) that has both the expanded and the unexpanded stack as
1472 \def\push#1#2{\expandafter\pushX #1\qStop #1{\eltStart #2\eltEnd}}
1474 % \begin{macro}{\pushX}
1475 % \changes{2.0k}{1992/04/06}{Macro added}
1476 % The macro |\pushX| picks up the complete expansion of the stack as
1477 % its first argument and places the guard in |#3| on the `top'.
1479 \def\pushX #1\qStop #2#3{\def #2{#3#1}}
1484 % \subsubsection{Programming structures}
1486 % \begin{macro}{\forlist}
1487 % \changes{2.0g}{1991/06/05}{Macro added.}
1488 % When the program is used in interactive mode the
1489 % user can supply a list of files that have to be processed.
1490 % In order to process this list a for-loop is needed. This
1491 % implementation of such a programming construct is based on the
1492 % use of the \verb=\loop{=\meta{body}\verb=}\repeat= macro that
1493 % is defined in plain \TeX\@. The syntax for this loop is:
1495 % |\for|\meta{control sequence} |:=| \meta{list}
1500 % The \meta{list} should be a comma separated list.
1502 % The first actions that have to be taken are to set the switch
1503 % |\ifForlist| to \meta{true} and to store the loop condition
1504 % in the macro |\ListCondition|. This is done using an
1505 % |\edef| to allow for a control sequence that contains a
1508 \def\forlist#1:=#2\do#3\od{%
1509 \edef\ListCondition{#2}%
1512 % Then we start the loop.
1513 % We store the first element from the |\ListCondition| in the
1514 % macro that was supplied as the first argument to |\forlist|.
1515 % This element is then removed from the |\ListCondition|.
1518 \edef#1{\expandafter\FirstElt\ListCondition,\empty.}%
1519 \edef\ListCondition{\expandafter\OtherElts\ListCondition,\empty.}%
1521 % When the first element from the \meta{list} is empty, we are done
1522 % processing, so we switch |\ifForlist| to \meta{false}.
1523 % When it is not empty we execute the third argument that should
1524 % contain \TeX\ commands to execute.
1526 \ifx#1\empty \Forlistfalse \else#3\fi
1528 % Finally we test the switch |\ifForlist| to decide whether the
1529 % loop has to be continued.
1534 % \begin{macro}{\FirstElt}
1535 % \changes{2.0g}{1991/06/05}{Macro added.}
1536 % The macro |\FirstElt| is used to get the first element from a
1537 % comma-separated list.
1539 \def\FirstElt#1,#2.{#1}
1542 % \begin{macro}{\OtherElts}
1543 % \changes{2.0g}{1991/06/05}{Macro added.}
1544 % The macro |\OtherElts| is used to get all elements {\em but\/}
1545 % the first element from a comma-separated list.
1547 \def\OtherElts#1,#2.{#2}
1552 % \begin{macro}{\whileswitch}
1553 % \changes{2.0h}{1991/06/19}{Macro added.} When the program is used in
1554 % interactive mode the user might want to process several files
1555 % with different options or extensions. This goal could be reached
1556 % by running the program several times, but it is more
1557 % user-friendly to ask if he would like to process more files when
1558 % we are done processing his last request. To accomplish this we
1559 % need the implementation of a \texttt{while}-loop. Again plain
1560 % \TeX's \verb=\loop{=\meta{body}\verb=}\repeat= is used to
1561 % implement this programming structure.
1563 % The syntax for this loop is:
1565 % |\whileswitch|\meta{switch} \verb|\fi| \meta{list}
1566 % \verb={=\meta{body}\verb=}=\\
1568 % The first argument to this macro has to be a switch, defined
1569 % using |\newif|; the second argument contains the statements
1570 % to execute while the switch evaluates to \meta{true}.
1572 \def\whileswitch#1\fi#2{#1\loop#2#1\repeat\fi}
1576 % \changes{2.3a}{1995/08/18}{New mechanism: output streams allocation}
1578 % \subsubsection{Output streams allocator}
1580 % For each of sixteen output streams available we have a macro
1581 % named |\s@0| through |\s@15| saying if the stream is assigned to a
1582 % file~(1) or not~(0). Initially all streams are not assigned.
1584 % We also declare 16 counters which will be needed by the conditional
1585 % code inclusion algorithm.
1588 \ifx\@tempcnta\undefined \newcount\@tempcnta \fi
1591 \Name\chardef{s@\number\@tempcnta}=0
1592 \csname newcount\expandafter\endcsname%
1593 \csname off@\number\@tempcnta\endcsname
1595 \ifnum\@tempcnta<16\repeat
1598 % We will use \emph{The \TeX book} style list to search through streams.
1602 \edef\@outputstreams{%
1603 \s@do\Name\noexpand{s@0}\s@do\Name\noexpand{s@1}%
1604 \s@do\Name\noexpand{s@2}\s@do\Name\noexpand{s@3}%
1605 \s@do\Name\noexpand{s@4}\s@do\Name\noexpand{s@5}%
1606 \s@do\Name\noexpand{s@6}\s@do\Name\noexpand{s@7}%
1607 \s@do\Name\noexpand{s@8}\s@do\Name\noexpand{s@9}%
1608 \s@do\Name\noexpand{s@10}\s@do\Name\noexpand{s@11}%
1609 \s@do\Name\noexpand{s@12}\s@do\Name\noexpand{s@13}%
1610 \s@do\Name\noexpand{s@14}\s@do\Name\noexpand{s@15}%
1611 \noexpand\@nostreamerror
1615 % \begin{macro}{\@nostreamerror}\begin{macro}{\@streamfound}
1616 % When |\@outputstreams| is executed |\s@do| is defined to do
1617 % something on condition of some test. If condition
1618 % always fails macro |\@nostreamerror| on the end of the list
1619 % causes an error. When condition succeeds |\@streamfound| is
1620 % called, which gobbles rest of the list including the ending
1621 % |\@nostreamerror|. It also gobbles |\fi| ending the condition, so
1622 % the |\fi| is reinserted.
1625 \def\@nostreamerror{\errmessage{No more output streams!}}
1626 \def\@streamfound#1\@nostreamerror{\fi}
1628 % \end{macro}\end{macro}
1630 % |\@stripstr| is auxiliary macro eating characters |\s@|
1631 % (backslash,s,@). It is defined in somewhat strange way since |\s@|
1632 % must have all category code 12 (other). This macro is used to
1633 % extract stream numbers from stream names.
1636 \bgroup\edef\x{\egroup
1637 \def\noexpand\@stripstr\string\s@{}}
1641 % \begin{macro}{\StreamOpen}\begin{macro}{\StreamPut}
1642 % \begin{macro}{\StreamClose}
1643 % Here is stream opening operator. Its parameter should be a macro
1644 % named the same as the external file being opened. E.g., to
1645 % write to file |foo.tex| use |\StreamOpen\foo|, then
1646 % |\StreamPut\foo| and |\StreamClose\foo|.
1649 \chardef\stream@closed=16
1651 \chardef#1=\stream@closed
1652 \def\s@do##1{\ifnum##1=0
1653 \chardef#1=\expandafter\@stripstr\string##1 %
1654 \global\chardef##1=1 %
1655 \immediate\openout#1=\csname pth@\@stripstring#1\endcsname %
1660 \def\StreamClose#1{%
1661 \immediate\closeout#1%
1662 \def\s@do##1{\ifnum#1=\expandafter\@stripstr\string##1 %
1663 \global\chardef##1=0 %
1667 \chardef#1=\stream@closed
1669 \def\StreamPut{\immediate\write}
1671 % \end{macro}\end{macro}\end{macro}
1673 % \subsubsection{Input and Output}
1675 % \begin{macro}{\maybeMsg}
1676 % \begin{macro}{\showprogress}
1677 % \begin{macro}{\keepsilent}
1678 % When this program is used it can optionally show its progress on
1679 % the terminal. In that case it will write a special character to
1680 % the terminal (and the transcript file) for each input line. This
1681 % option is on by default when statistics are included in
1682 % \texttt{docstrip.tex}. It is off when statistics are excluded. The
1683 % commands |\showprogress| and |\keepsilent| can be used
1684 % to choose otherwise.
1686 \def\showprogress{\let\maybeMsg\message}
1687 \def\keepsilent{\let\maybeMsg\@gobble}
1691 %<-stats>\keepsilent
1697 % \begin{macro}{\Msg}
1698 % For displaying messages on the terminal the macro |\Msg| is
1699 % defined to write {\em immediately\/} to |\ttyout|.
1701 \def\Msg{\immediate\write\ttyout}
1705 % \begin{macro}{\Ask}
1707 % \verb=\Ask{=\meta{cs}\verb=}{=\meta{string}\verb=}= is a
1708 % slightly modified copy of the \LaTeX\ macro |\typein|. It is
1709 % used to ask the user a question. The \meta{string} will be
1710 % displayed on his terminal and the response will be stored in the
1711 % \meta{cs}. The trailing space left over from the carriage return
1712 % is stripped off by the macro |\strip|. If the user just
1713 % types a carriage return, the result will be an empty macro.
1714 % \changes{2.0i}{1991/06/27}{Added check for just \protect\meta{CR}}
1717 \def\strip#1#2 \@gobble{\def #1{#2}}
1720 \message{#2}\read\ttyin to #1\ifx#1\@defpar\def#1{}\else
1721 \iden{\expandafter\strip
1722 \expandafter#1#1\@gobble\@gobble} \@gobble\fi}
1726 % \begin{macro}{\OriginalAsk}
1727 % \changes{2.4e}{1996/10/24}{macro added (was in unpack.ins) (DPC)}
1729 \let\OriginalAsk=\Ask
1734 % \begin{macro}{\askonceonly}
1735 % \changes{2.4e}{1996/10/22}
1736 % {macro added (essentially from unpack.ins) (DPC)}
1740 \OriginalAsk{##1}{##2}%
1741 \global\let\Ask\OriginalAsk
1743 By default you will be asked this question for every file.^^J%
1744 If you enter `y' now,^^J%
1745 I will assume `y' for all future questions^^J%
1746 without prompting.}%
1747 \ifx\y\noprompt\let\noprompt\yes\fi
1748 \ifx\yes\noprompt\gdef\Ask####1####2{\def####1{y}}\fi}}
1752 % \subsubsection{Miscellaneous}
1754 % \begin{macro}{\@gobble}
1755 % \changes{2.0a}{1991/05/25}{Macro added.}
1756 % A macro that has an argument and puts it in the bitbucket.
1762 % \begin{macro}{\Endinput}
1763 % \changes{2.0f}{1991/06/04}{Macro added.} When a \texttt{doc} file
1764 % contains a \verb+\endinput+ on a line by itself this normally
1765 % means that anything following in this file should be ignored.
1766 % Therefore we need a macro containing |\endinput| as its
1767 % replacement text to check this against |\inLine| (the
1768 % current line from the current input file). Of course the
1769 % backslash has to have the correct |\catcode|. One way of
1770 % doing this is feeding \verb=\\= to the |\string| operation
1771 % and afterwards removing one of the |\| characters.
1773 \edef\Endinput{\expandafter\@gobble\string\\endinput}
1777 % \begin{macro}{\makeOther}
1778 % During the process of reading a file with \TeX\ code the category
1779 % code of all special characters has to be changed to \meta{other}.
1780 % The macro |\makeOther| serves this purpose.
1782 \def\makeOther#1{\catcode`#1=12\relax}
1786 % \begin{macro}{\end}
1787 % \changes{2.0h}{1991/06/19}{Macro added.} For now we want the \ds{}
1788 % program to be compatible with both plain \TeX\ and \LaTeX\@.
1789 % \LaTeX\ hides plain \TeX{}'s |\end| command and
1790 % calls it |\@@end|. We unhide it here.
1792 \ifx\undefined\@@end\else\let\end\@@end\fi
1796 % \begin{macro}{\@addto}
1797 % A macro extending macro's definition. The trick with |\csname|
1798 % is necessary to get around |\newtoks| being outer in plain \TeX{}
1799 % and \LaTeX\ version 2.09.
1801 \ifx\@temptokena\undefined \csname newtoks\endcsname\@temptokena\fi
1806 \@temptokena\expandafter{#1}%
1807 \edef#1{\the\@temptokena#2}}
1811 % \begin{macro}{\@ifpresent}
1812 % This macro checks if its first argument is present on a
1813 % list passed as the second argument. Depending on the result
1814 % it executes either its third or fourth argument.
1817 \def\@ifpresent#1#2#3#4{%
1818 \def\tmp##1#1##2\qStop{\ifx!##2!}%
1819 \expandafter\tmp#2#1\qStop #4\else #3\fi
1824 % \begin{macro}{\tospaces}
1825 % This macro converts its argument delimited with |\secapsot| to
1826 % appropriate number of spaces. We need this for smart displaying
1827 % messages on the screen.
1829 % |\@spaces| are used when we need many spaces in a row.
1832 \ifx#1\secapsot\secapsot\fi\space\tospaces}
1833 \def\secapsot\fi\space\tospaces{\fi}
1834 \def\@spaces{\space\space\space\space\space}
1838 % \begin{macro}{\uptospace}
1839 % \changes{2.3c}{1995/08/24}{Macro added}
1840 % This macro extracts from its argument delimited with |\qStop|
1841 % part up to first occurrence of space.
1843 \def\uptospace#1 #2\qStop{#1}
1847 % \begin{macro}{\afterfi}
1848 % \changes{2.3c}{1995/09/04}{Macro added}
1849 % This macro can be used in conditionals to perform some actions
1850 % (its first parameter) after the condition is completed (i.e.
1851 % after reading the matching |\fi|. Second parameter is used to
1852 % gobble the rest of |\if ... \fi| construction (some |\else|
1853 % maybe). Note that this won't work in nested |\if|s!
1855 \def\afterfi#1#2\fi{\fi#1}
1858 % \begin{macro}{\@ifnextchar}
1859 % \changes{2.3e}{1995/09/25}{Macro added}
1860 % This is one of \LaTeX's macros not defined by plain. My
1861 % devious definition differs from the standard one but
1862 % functionality is the same.
1864 \def\@ifnextchar#1#2#3{\bgroup
1865 \def\reserved@a{\ifx\reserved@c #1 \aftergroup\@firstoftwo
1866 \else \aftergroup\@secondoftwo\fi\egroup
1868 \futurelet\reserved@c\@ifnch
1870 \def\@ifnch{\ifx \reserved@c \@sptoken \expandafter\@xifnch
1871 \else \expandafter\reserved@a
1873 \def\@firstoftwo#1#2{#1}
1874 \def\@secondoftwo#1#2{#2}
1875 \iden{\let\@sptoken= } %
1876 \iden{\def\@xifnch} {\futurelet\reserved@c\@ifnch}
1879 % \begin{macro}{\kernel@ifnextchar}
1880 % \changes{v2.5d}{2005/07/29}{Added macro}
1881 % The 2003/12/01 release of \LaTeX\ incorporated this macro to avoid
1882 % problems with \texttt{amsmath} but this also means that we have to
1883 % perform the same trick here when people use \LaTeX\ on a
1884 % installation file containing |\ProvidesFile|.
1886 \let\kernel@ifnextchar\@ifnextchar
1891 % \subsection{The evaluation of boolean expressions}
1893 % For clarity we repeat here the syntax for the boolean expressions
1894 % in a somewhat changed but equivalent way:
1896 % \DeleteShortVerb\|
1897 % \begin{tabular}{lcl}
1898 % \meta{Expression} & $::=$ & \meta{Secondary} $|$
1899 % \meta{Secondary} \{\texttt{|}, \texttt{,}\}
1900 % \meta{Expression}\\
1901 % \meta{Secondary} & $::=$ & \meta{Primary} $|$
1902 % \meta{Primary} \texttt{\&}
1903 % \meta{Secondary}\\
1904 % \meta{Primary} & $::=$ &
1905 % \meta{Terminal} $|$ \texttt{!}\meta{Primary}
1907 % \texttt{(}\meta{Expression}\texttt{)}\\
1910 % The \texttt{|} stands for disjunction, the \texttt{\&} stands for
1911 % conjunction and the \texttt{!}\ stands for negation. The
1912 % \meta{Terminal} is any sequence of letters and evaluates to
1913 % \meta{true} iff it occurs in the list of options that have to be
1917 % Since we can generate multiple output files from one input,
1918 % same guard expressions can be computed several times with
1919 % different options. For that reason we first ``compile'' the
1920 % expression to the form of one parameter macro |\Expr|
1921 % expanding to nested |\if|s that when given current list of
1922 % options produces 1 or 0 as a result. The idea is to say
1923 % |\if1\Expr{|\meta{current set of options}|}...\fi| for all
1926 % Here is a table recursively defining translations for right
1927 % sides of the grammar. $\tau(X)$ denotes translation of~$X$.
1929 % \DeleteShortVerb\|
1932 % \addtolength\arraycolsep{-2.1pt}
1934 % \tau(\meta{Terminal})&=&"\t@<Terminal>,#1,<Terminal>,\qStop"\\
1935 % \tau(!\meta{Primary})&=&"\if1"\,\tau(\meta{Primary})\,"0\else1\fi"\\
1936 % \tau(\mbox{\texttt{(}\meta{Expression}\texttt{)}})
1937 % &=&\tau(\meta{Expression})\\
1938 % \tau(\mbox{\meta{Primary}\texttt{\&}\meta{Secondary}})
1939 % &=&"\if0"\,\tau(\meta{Primary})\,"0\else"
1940 % \,\tau(\meta{Secondary})\,"\fi"\\
1941 % \tau(\mbox{\meta{Secondary}\texttt{|}\meta{Expression}})
1942 % &=&"\if1"\,\tau(\meta{Secondary})\,"1\else"
1943 % \,\tau(\meta{Expression})\,"\fi"
1946 % \DeleteShortVerb\"
1948 % |\t@<Terminal>| denotes macro with name constructed from |t@|
1949 % with appended tokens of terminal. E.g., for terminal |foo| the
1950 % translation would be
1952 % \t@foo,#1,foo,\qStop
1954 % This will end up in definition of |\Expr|, so |#1| here will
1955 % be substituted by current list of options when |\Expr| is
1956 % called. Macro |\t@foo| would be defined as
1958 % \def\t@foo#1,foo,#2\qStop{\ifx>#2>0\else1\fi}
1960 % When called as above this will expand to |1| if |foo| is
1961 % present on current list of options and to |0| otherwise.
1963 % Macros below work in ``almost expand-only'' mode i.e.
1964 % expression is analyzed only by expansion but we have to define
1965 % some macros on the way (e.g., |\Expr| and |\t@foo|).
1967 % The first parameter of each of these macros is
1968 % ``continuation'' (in the sense similar to the language
1969 % \textsc{Scheme}). Continuation is a function of at least one
1970 % argument (parameter) being the value of previous steps of
1971 % computation. For example macro |\Primary| constructs
1972 % translation of \meta{Primary} expression. When it decides that
1973 % expression is completed it calls its continuation (its first
1974 % argument) passing to it whole constructed translation.
1975 % Continuation may expect more arguments if it wants to see what
1976 % comes next on the input.
1978 % We will perform recursive descent parse, but definitions will
1979 % be presented in bottom-up order.
1981 % \begin{macro}{\Terminal}
1983 % \meta{Terminal}s are recognized by macro |\Terminal|. The
1984 % proper way of calling it is |\Terminal{|\meta{current
1985 % continuation}|}{}|. Parameters are: continuation,
1986 % \meta{Terminal} so far and next character from the input.
1987 % Macro checks if |#3| is one of terminal-ending characters and
1988 % then takes appropriate actions. Since there are 7 ending
1989 % chars and probably one |\csname| costs less than 7 nested
1990 % |\if|s we construct a name and check if it is defined.
1992 % We must expand |\ifx| completely before taking next actions so
1993 % we use |\afterfi|.
1995 \def\Terminal#1#2#3{%
1996 \expandafter\ifx\csname eT@#3\endcsname\relax
1998 % If condition is true |#3| belongs to current \meta{Terminal}
1999 % so we append it to \meta{Terminal}-so-far and call |\Terminal|
2002 \afterfi{\Terminal{#1}{#2#3}}\else
2004 % When condition is false it's time to end the \meta{Terminal}
2005 % so we call macro |\TerminalX|. Next character is reinserted to
2008 % In both cases continuation is passed unchanged.
2010 \afterfi{\TerminalX{#1}{#2}#3}\fi
2015 % \begin{macro}{\eT@}
2016 % Here we define macros marking characters that cannot appear
2017 % inside terminal. The value is not important as long as it is
2018 % different from |\relax|.
2021 \Name\let{eT@&}=1 \Name\let{eT@!}=1
2022 \Name\let{eT@|}=1 \Name\let{eT@,}=1
2023 \Name\let{eT@(}=1 \Name\let{eT@)}=1
2027 % \begin{macro}{\TerminalX}
2028 % This macro should end scanning of \meta{Terminal}. Parameters
2029 % are continuation and gathered tokens of \meta{Terminal}.
2031 % Macro starts by issuing an error message if \meta{Terminal} is
2034 \def\TerminalX#1#2{%
2035 \ifx>#2> \errmessage{Error in expression: empty terminal}\fi
2037 % Then a macro is constructed for checking presence of
2038 % \meta{Terminal} in options list.
2040 \Name\def{t@#2}##1,#2,##2\qStop{\ifx>##2>0\else1\fi}%
2042 % And then current continuation is called with translation of
2043 % \meta{Terminal} according to formula
2044 % $$\tau(\meta{Terminal})=|\t@<Terminal>,#1,<Terminal>,\qStop|$$
2046 #1{\Name\noexpand{t@#2},##1,#2,\noexpand\qStop}%
2051 % \begin{macro}{\Primary}
2052 % Parameters are continuation and next character from the input.
2054 % According to the syntax \meta{Primari}es can have three forms.
2055 % This makes us use even more dirty tricks than usual. Note the
2056 % |\space| after a series of |\ifx|s. This series produces an
2057 % one digit number of case to be executed. The number is given
2058 % to |\ifcase| and |\space| stops \TeX{} scanning for a
2059 % \meta{number}. Use of |\ifcase| gives possibility to have one
2060 % of three actions selected without placing them in nested
2061 % |\if|s and so to use |\afterfi|.
2064 \ifcase \ifx!#20\else\ifx(#21\else2\fi\fi\space
2066 % First case is for |!| i.e. negated \meta{Primary}. In this
2067 % case we call |\Primary| recursively but we create new
2068 % continuation: macro |\NPrimary| that will negate result
2069 % passed by |\Primary| and pass it to current continuation
2072 \afterfi{\Primary{\NPrimary{#1}}}\or
2074 % When next character is |(| we call |\Expression| giving it as
2075 % continuation macro |\PExpression| which will just pass the
2076 % result up but ensuring first that a |)| comes next.
2078 \afterfi{\Expression{\PExpression{#1}}}\or
2080 % Otherwise we start a \meta{Terminal}. |#2| is not passed as
2081 % \meta{Terminal}-so-far but reinserted to input since we didn't
2082 % check if it can appear in a \meta{Terminal}.
2084 \afterfi{\Terminal{#1}{}#2}\fi
2089 % \begin{macro}{\NPrimary}
2090 % Parameters are continuation and previously computed
2093 % This macro negates result of previous computations according
2095 % $$\tau(!\meta{Primary})
2096 % =|\if1|\,\tau(\meta{Primary})\,|0\else1\fi|$$
2099 #1{\noexpand\if1#20\noexpand\else1\noexpand\fi}%
2104 % \begin{macro}{\PExpression}
2105 % Parameters: continuation, \meta{Expression}, next character
2106 % from input. We are checking if character is |)| and then pass
2107 % unchanged result to our continuation.
2109 \def\PExpression#1#2#3{%
2111 \errmessage{Error in expression: expected right parenthesis}\fi
2116 % \begin{macro}{\Secondary}
2117 % Each \meta{Secondary} expression starts with \meta{Primary}.
2118 % Next checks will be performed by |\SecondaryX|.
2121 \Primary{\SecondaryX{#1}}}
2125 % \begin{macro}{\SecondaryX}
2126 % Parameters: continuation, translation of \meta{Primary}, next
2127 % character. We start by checking if next character is |&|.
2129 \bgroup\catcode`\&=12
2130 \gdef\SecondaryX#1#2#3{%
2133 % If it is we should parse next \meta{Secondary} and then
2134 % combine it with results so far. Note that |\SecondaryXX| will
2135 % have 3 parameters.
2137 \afterfi{\Secondary{\SecondaryXX{#1}{#2}}}\else
2139 % Otherwise \meta{Secondary} turned out to be just
2140 % \meta{Primary}. We call continuation passing to it translation
2141 % of that \meta{Primary} not forgetting to reinsert |#3| to the
2142 % input as it does not belong here.
2144 \afterfi{#1{#2}#3}\fi
2150 % \begin{macro}{\SecondaryXX}
2151 % Parameters: continuation, translation of \meta{Primary},
2152 % translation of \meta{Secondary}. We construct translation of
2153 % whole construction according to the rule:
2154 % $$\tau(\mbox{\meta{Primary}\texttt{\&}\meta{Secondary}})
2155 % =|\if0|\,\tau(\meta{Primary})\,|0\else|
2156 % \,\tau(\meta{Secondary})\,|\fi| $$
2157 % and pass it to our continuation.
2159 \def\SecondaryXX#1#2#3{%
2160 #1{\noexpand\if0#20\noexpand\else#3\noexpand\fi}}
2164 % \begin{macro}{\Expression}
2165 % Every \meta{Expression} starts with \meta{Secondary}. We
2166 % construct new continuation and pass it to |\Secondary|.
2169 \Secondary{\ExpressionX{#1}}}
2173 % \begin{macro}{\ExpressionX}
2174 % Parameters: continuation, translation of \meta{Secondary},
2175 % next character. We perform check if character is
2176 % \texttt{\char`\|} or |,|.
2178 \def\ExpressionX#1#2#3{%
2179 \if0\ifx|#31\else\ifx,#31\fi\fi0
2181 % If it is not \meta{Expression} is just a \meta{Secondary}. We
2182 % pass its translation to continuation and reinsert |#3|.
2184 \afterfi{#1{#2}#3}\else
2186 % If we are dealing with complex \meta{Expression} we should
2187 % parse another |\Expression| now.
2189 \afterfi{\Expression{\ExpressionXX{#1}{#2}}}\fi
2194 % \begin{macro}{\ExpressionXX}
2195 % Parameters: continuation, translation of \meta{Secondary},
2196 % translation of \meta{Expression}.
2197 % We finish up translating of \meta{Expression} according to
2199 % $$\tau(\mbox{\meta{Secondary}\texttt{\char`\|}\meta{Expression}})
2200 % =|\if1|\,\tau(\meta{Secondary})\,|1\else|
2201 % \,\tau(\meta{Expression})\,|\fi|$$
2203 \def\ExpressionXX#1#2#3{%
2204 #1{\noexpand\if1#21\noexpand\else#3\noexpand\fi}}
2208 % \begin{macro}{\StopParse}
2209 % Here is initial continuation for whole parse process. It will
2210 % be used by |\Evaluate|. Note that we assume that expression
2211 % has |>| on its end. This macro eventually defines |\Expr|.
2212 % Parameters: translation of whole \meta{Expression} and next
2213 % character from input.
2215 \def\StopParse#1#2{%
2216 \ifx>#2 \else\errmessage{Error in expression: spurious #2}\fi
2221 % \begin{macro}{\Evaluate}
2222 % This macro is used to start parsing. We call |\Expression|
2223 % with continuation defined above. On end of expression we
2227 \Expression\StopParse#1>}
2231 % \subsection{Processing the input lines}
2233 % \begin{macro}{\normalLine}
2234 % The macro |\normalLine| writes its argument (which has to be
2235 % delimited with |\endLine|) on all active output files i.e.
2236 % those with off-counters equal to zero.
2237 % If statistics are included, the counter
2238 % |\codeLinesPassed| is incremented by $1$.
2240 \def\normalLine#1\endLine{%
2242 \advance\codeLinesPassed\@ne
2252 % \begin{macro}{\putline@do}
2253 % \changes{2.3b}{1995/08/22}{Change for pre-constructed
2254 % off-counters' names}
2255 % This is a value for |\do| when copying line to output files.
2257 \def\putline@do#1#2#3{%
2258 \StreamPut#1{\inLine}}
2262 % \begin{macro}{\removeComment}
2263 % The macro |\removeComment| throws its argument (which has to be
2264 % delimited with |\endLine|) away. When statistics are included
2265 % in the program the removed comment is counted.
2268 \def\removeComment#1\endLine{%
2270 \advance\commentsRemoved\@ne
2272 \maybeMsg{\perCent}}
2276 % \begin{macro}{\putMetaComment}
2277 % \changes{2.3e}{1996/09/16}{Introduced \cs{MetaPrefix}}
2278 % If a line starts with two consecutive percent signs, it is
2279 % considered to be a {\em MetaComment\/}. Such a comment line is
2280 % passed on to the output file unmodified.
2282 \bgroup\catcode`\%=12
2284 \def\putMetaComment%}#1\endLine{%
2286 % If statistics are included the line is counted.
2289 \advance\commentsPassed\@ne
2292 % The macro |\putMetaComment| has one argument, delimited with
2293 % |\endLine|. It brings the source line with |%%| stripped. We
2294 % prepend to it |\MetaPrefix| (which can be different from |%%|)
2295 % and send the line to all active files.
2297 \edef\inLine{\MetaPrefix#1}%
2305 % \begin{macro}{\processLine}
2306 % \changes{2.3a}{1995/08/18}{Adaptation for concurrent version}
2307 % \changes{2.3a}{1995/08/20}{Trying to avoid assignments}
2308 % Each line that is read from the input stream has to be processed
2309 % to see if it has to be written on the output stream. This task
2310 % is performed by calling the macro |\processLine|.
2312 % that, it needs to check whether the line starts with a
2313 % `\texttt{\%}'. Therefore the macro is globally defined within a
2314 % group. Within this group the category code of `\texttt{\%}' is
2315 % changed to 12 (other). Because a comment character is needed,
2316 % the category code of `\texttt{*}' is changed to 14 (comment
2319 % The macro increments counter |\processedLines| by $1$ if
2320 % statistics are included. We cannot include this line with
2321 % |%<*stats>| since the category of \texttt{\%} is changed and the
2322 % file must be loadable unstripped. So the whole definition is
2323 % repeated embedded in guards.
2325 % The next token from the input stream is passed in |#1|. If it is
2326 % a `\texttt{\%}' further processing has to be done by
2327 % |\processLineX|; otherwise this is normal (not commented out)
2330 % In either case the character read is reinserted to the input
2331 % as it may have to be written out.
2336 \catcode`\%=12 \catcode`\*=14
2337 \gdef\processLine#1{*
2339 \expandafter\processLineX
2341 \expandafter\normalLine
2348 \catcode`\%=12 \catcode`\*=14
2349 \gdef\processLine#1{*
2350 \advance\processedLines\@ne
2352 \expandafter\processLineX
2354 \expandafter\normalLine
2363 % \begin{macro}{\processLineX}
2364 % \changes{2.3a}{1995/08/20}{Trying to avoid assignments}
2365 % This macro is also defined within a group,
2366 % because it also has to check if the next
2367 % token in the input stream is a `\texttt{\%}' character.
2369 % If the second token in the current line happens to be a
2370 % `\texttt{\%}', a \meta{MetaComment} has been found. This has to
2371 % be copied in its entirety to the output. Another possible second
2372 % character is `\texttt{<}', which introduces a guard expression.
2373 % The processing of such an expression is started by calling
2376 % When the token was neither a `\texttt{\%}' nor a `\texttt{<}',
2377 % the line contains a normal comment that has to be removed.
2379 % We express conditions in such a way that all actions appear
2380 % on first nesting level of |\if|s. In such conditions just one
2381 % expandafter pushes us outside whole construction. A thing to
2382 % watch here is |\relax|. It stops search for numeric constant.
2383 % If it wasn't here \TeX\ would expand the first case of |\ifcase|
2384 % before knowing the value.
2388 \catcode`\%=12 \catcode`\*=14
2389 \gdef\processLineX%#1{*
2390 \ifcase\ifx%#10\else
2391 \ifx<#11\else 2\fi\fi\relax
2392 \expandafter\putMetaComment\or
2393 \expandafter\checkOption\or
2394 \expandafter\removeComment\fi
2400 % \subsection{The handling of options}
2402 % \begin{macro}{\checkOption}
2403 % \changes{2.3a}{1995/08/18}{Adapted to concurrent version}
2404 % \changes{2.3a}{1995/08/20}{Trying to avoid assignments}
2405 % \changes{2.3e}{1996/09/16}{Verbatim mode}
2406 % When the macros that process a line have found that the line
2407 % starts with `\texttt{\%<}', a guard line has been encountered.
2408 % The first character of a guard can be an asterisk (\texttt{*}), a
2409 % slash (\texttt{/}) a plus (\texttt{+}), a minus (\texttt{-}), a
2410 % less-than sign (\texttt{<}) starting verbatim mode or
2411 % any other character that can be found in an option name. This
2412 % means that we have to peek at the next token and
2413 % decide what kind of guard we have.
2415 % We reinsert |#1| as it may be needed by |\doOption|.
2417 \def\checkOption<#1{%
2419 \ifx*#10\else \ifx/#11\else
2420 \ifx+#12\else \ifx-#13\else
2421 \ifx<#14\else 5\fi\fi\fi\fi\fi\relax
2422 \expandafter\starOption\or
2423 \expandafter\slashOption\or
2424 \expandafter\plusOption\or
2425 \expandafter\minusOption\or
2426 \expandafter\verbOption\or
2427 \expandafter\doOption\fi
2432 % \begin{macro}{\doOption}
2433 % When no guard modifier is found by |\checkOptions|, the
2434 % macro |\doOption| is called. It evaluates a boolean
2435 % expression. The result of this evaluation is stored in
2436 % |\Expr|. The guard only affects the current
2437 % line, so |\do| is defined in such a way that depending on the
2438 % result of the test |\if1\Expr{|\meta{options}|}|, the current
2439 % line is either copied to the output stream or removed. Then
2440 % the test is computed for all active output files.
2442 \def\doOption#1>#2\endLine{%
2446 \if1\Expr{##2}\StreamPut##1{#2}\fi
2453 % \begin{macro}{\plusOption}
2454 % When a `\texttt{+}' is found as a guard modifier,
2455 % |\plusOption| is called. This macro is very similar to
2456 % |\doOption|, the only difference being that displayed
2457 % message now contains `\texttt{+}'.
2459 \def\plusOption+#1>#2\endLine{%
2460 \maybeMsg{<+#1 . >}%
2463 \if1\Expr{##2}\StreamPut##1{#2}\fi
2470 % \begin{macro}{\minusOption}
2471 % When a `\texttt{-}' is found as a guard modifier,
2472 % |\minusOption| is called. This macro is very similar to
2473 % |\plusOption|, the difference is that condition is negated.
2475 \def\minusOption-#1>#2\endLine{%
2476 \maybeMsg{<-#1 . >}%
2479 \if1\Expr{##2}\else \StreamPut##1{#2}\fi
2486 % \begin{macro}{\starOption}
2487 % \changes{2.3a}{1995/08/18}{Adapted to concurrent version}
2488 % When a `\texttt{*}' is found as a guard modifier,
2489 % |\starOption| is called. In this case a block of code will
2490 % be included in the output on the condition that the guard
2491 % expression evaluates to \meta{true}.
2493 % The current line is gobbled as |#2|, because it only contains
2494 % the guard and possibly a comment.
2497 \def\starOption*#1>#2\endLine{%
2499 % First we optionally write
2500 % a message to the terminal to indicate that a new option starts
2505 % Then we push the current contents of |\blockHead| on the
2506 % stack of blocks, |\guardStack| and increment the counter
2507 % |\blockLevel| to indicate that we are now one level of
2509 % \changes{2.0k}{1992/04/06}{Use new stack mechanism}
2510 % \changes{2.0k}{1992/04/09}{The macro that holds the guard needs to be
2513 \expandafter\push\expandafter\guardStack\expandafter{\blockHead}%
2514 \advance\blockLevel\@ne
2516 % The guard for this block of code is now stored in
2521 % Now we evaluate guard expression for all output files
2522 % updating off-counters. Then we create new list of active
2523 % output files. Only files that were active in the outer block
2524 % can remain active now.
2527 \let\do\checkguard@do
2529 \let\do\findactive@do
2530 \edef\activefiles{\activefiles}
2535 % \begin{macro}{\checkguard@do}
2536 % \changes{2.3b}{1995/08/22}{Change for pre-constructed
2537 % off-counters' names}
2538 % This form of |\do| updates off-counts according to the value of
2541 \def\checkguard@do#1#2#3{%
2543 % If this block of code occurs inside another block of code that is
2544 % {\em not\/} included in the output, we increment the off counter.
2545 % In that case the guard expression will not be
2546 % evaluated, because a block inside another block that is excluded
2547 % from the output will also be excluded, regardless of the
2548 % evaluation of its guard.
2553 % When the off count has value 0, we have
2554 % to evaluate the guard expression. If the result is \meta{false}
2555 % we increase the off-counter.
2564 % \begin{macro}{\findactive@do}
2565 % \changes{2.3b}{1995/08/22}{Change for pre-constructed
2566 % off-counters' names}
2567 % This form of |\do| picks elements of output files list which
2568 % have off-counters equal to zero.
2570 \def\findactive@do#1#2#3{%
2572 \noexpand\do#1{#2}#3\fi}
2576 % \begin{macro}{\slashOption}
2577 % \changes{2.3a}{1995/08/18}{Adapted for concurrent version}
2578 % The macro |\slashOption| is the counterpart to
2579 % |\starOption|. It indicates the end of a block of
2580 % conditionally included code. We store the argument in the
2581 % temporary control sequence |\tmp|.
2583 \def\slashOption/#1>#2\endLine{%
2586 % When the counter |\blockLevel| has a value less than $1$,
2587 % this `end-of-block' line has no corresponding `start-of-block'.
2588 % Therefore we signal an error and ignore this end of block.
2590 \ifnum\blockLevel<\@ne
2591 \errmessage{Spurious end block </\tmp> ignored}%
2593 % Next we compare the contents of |\tmp| with the contents
2594 % of |\blockHead|. The latter macro contains the last guard for
2595 % a block of code that was encountered. If the contents match, we
2596 % pop the previous guard from the stack.
2597 % \changes{2.0k}{1992/04/06}{Use new stack mechanism}
2601 \pop\guardStack\blockHead
2603 % When the contents of the two macros don't match something is
2604 % amiss. We signal this to the user, but accept the `end-of-block'.
2605 %\note{Is this the desired behaviour??}
2608 \errmessage{Found </\tmp> instead of </\blockHead>}%
2611 % When the end of a block of optionally included code is encountered
2612 % we optionally signal this on the terminal and decrement the counter
2616 \advance\blockLevel\m@ne
2618 % The last thing that has to be done is to decrement off-counters and
2619 % make new list of active files. Now whole list of output files has
2620 % to be searched since some inactive files could have been
2623 \let\do\closeguard@do
2625 \let\do\findactive@do
2626 \edef\activefiles{\outputfiles}
2632 % \begin{macro}{\closeguard@do}
2633 % \changes{2.3b}{1995/08/22}{Change for pre-constructed
2634 % off-counters' names}
2635 % This macro decrements non-zero off-counters.
2637 \def\closeguard@do#1#2#3{%
2645 % \begin{macro}{\verbOption}
2646 % \changes{2.3e}{1996/09/16}{Macro added}
2647 % \changes{2.4g}{1996/12/13}{Reset \cs{putline@do} for /2340}
2648 % This macro is called when a line starts with |%<<|. It reads a
2649 % bunch of lines in verbatim mode: the lines are passed unchanged
2650 % to the output without even checking for starting |%|. This way of
2651 % processing ends when a line containing only a percent sign
2652 % followed by stop mark given on the |%<<| line is found.
2654 \def\verbOption<#1\endLine{{%
2655 \edef\verbStop{\perCent#1}\maybeMsg{<<<}%
2658 \ifeof\inFile\errmessage{Source file ended while in verbatim
2660 \read\inFile to \inLine
2661 \if 1\ifx\inLine\verbStop 0\fi 1% if not inLine==verbStop
2670 % \subsection{Batchfile commands}
2671 % \changes{2.3e}{1996/10/02}{Added doc}
2672 % \ds{} keeps information needed to control inclusion of sources in
2673 % several list structures. Lists are macros expanding to a series
2674 % of calls to macro |\do| with two or three parameters.
2675 % Subsequently |\do| is redefined in various ways and list
2676 % macros sometimes are executed to perform some action on every
2677 % element, and sometimes are used inside an |\edef| to make new
2678 % list of elements having some properties. For every input file
2679 % \meta{infile} the following lists are kept:
2681 % \item[\cs{b@}\meta{infile}] the ``open list''---names of all output
2682 % files such that their generation should start with
2683 % reading of \meta{infile},
2684 % \item[\cs{o@}\meta{infile}] the ``output list''---names of all
2685 % output files generated from that source together with
2686 % suitable sets of options (guards),
2687 % \item[\cs{e@}\meta{infile}] the ``close list''---names of all
2688 % output files that should be closed when this source is
2692 % For every output file name \meta{outfile} \ds{} keeps following
2695 % \item[\cs{pth@}\meta{outfile}] full pathname (including file name),
2696 % \item[\cs{ref@}\meta{outfile}] reference lines for the file,
2697 % \item[\cs{in@}\meta{outfile}] names of all source files separated
2698 % with spaces (needed by \cs{InFileName}),
2699 % \item[\cs{pre@}\meta{outfile}] preamble template (as defined with
2700 % |\declarepreamble|),
2701 % \item[\cs{post@}\meta{outfile}] postamble template.
2704 % \begin{macro}{\generate}
2705 % \changes{2.3a}{1995/08/20}{Messages changed}
2706 % \changes{2.4a}{1996/06/06}{Repeat processing of files until all
2708 % This macro executes its argument in a group. |\inputfiles| is
2709 % a list of files to be read, |\filestogenerate| list of names
2710 % of output files (needed for the message below). |\file|s
2711 % contained in |#1| define |\inputfiles| in such a way that all
2712 % that has to be done when the parameter is executed is to call
2713 % this macro. |\inputfiles| command is called over and over again
2714 % until no output files had to be postponed.
2716 \def\generate#1{\begingroup
2717 \let\inputfiles\empty \let\filestogenerate\empty
2720 \ifx\filestogenerate\empty\else
2721 \Msg{^^JGenerating file(s) \filestogenerate}\fi
2722 \def\inFileName{\csname in@\outFileName\endcsname}%
2723 \def\ReferenceLines{\csname ref@\outFileName\endcsname}%
2729 % \begin{macro}{\processinputfiles}
2730 % \changes{2.4a}{1996/10/02}{Macro added (MW)}
2731 % This is a recurrent function which processes input files until
2732 % they are all gone.
2734 \def\processinputfiles{%
2735 \let\newinputfiles\empty
2737 \let\inputfiles\newinputfiles
2738 \ifx\inputfiles\empty\else
2739 \expandafter\processinputfiles
2745 % \begin{macro}{\file}
2746 % The first argument is the file to produce, the second
2747 % argument contains the list of input files. Each entry should have
2749 % \verb=\from{=\meta{filename.ext}\verb=}{=\meta{options}\verb=}=.
2751 % \changes{2.3a}{1995/08/20}{Messages changed}
2752 % ^^A The macro starts by displaying a message on the terminal to
2753 % ^^A indicate which file is going to be made.
2754 % The switch |\ifGenerate| is initially set to \meta{true}.
2756 \def\file#1#2{\errmessage{Command `\string\file' only allowed in
2757 argument to `\string\generate'}}
2761 % Next we construct full path name for output file and check if we
2762 % have to be careful about overwriting existing files. If the user
2763 % specified |\askforoverwritetrue| we will ask him if he wants to
2764 % overwrite an existing file. Otherwise we simply go ahead.
2769 % We try to open a file with the name of the output file for
2770 % reading. If this succeeds the file exists and we ask the user if
2771 % he wants to overwrite the file.
2772 % \changes{2.0p}{1992/06/26}{Added \cs{WriteToDir} (FMi).}
2773 % \changes{2.3a}{1995/08/18}{Changed \cs{@empty} (which was undefined)
2775 % \changes{2.3e}{1995/09/25}{Changed \cs{WriteToDir} to \cs{destdir}}
2777 \immediate\openin\inFile\@pathname\relax
2779 \Ask\answer{File \@pathname\space already exists
2780 \ifx\empty\destdir somewhere \fi
2783 \ifx\empty\destdir\space if necessary\fi
2786 % We set the switch |\ifGenerate| according to his answer. We
2787 % allow for both ``\texttt{y}'' and ``\texttt{yes}''.
2789 \ifx\y \answer \else
2790 \ifx\yes\answer \else
2791 \Generatefalse\fi\fi\fi
2793 % Don't forget to close the file just opened as we want to write
2799 % \changes{2.3e}{1995/09/25}{Destination directory handling}
2800 % If file is to be generated we save its destination pathname and
2801 % pass control to macro |\@fileX|.
2802 % Note that file name is turned into control sequence and |\else|
2803 % branch is skipped before calling |\@fileX|.
2806 \Name\let{pth@#1}\@pathname
2807 \@addto\filestogenerate{\@pathname\space}%
2808 \Name\@fileX{#1\expandafter}%
2811 % In case we were not allowed to overwrite an existing file
2812 % we inform the user that we are {\em not\/} generating his file
2813 % and we gobble |\from| specifications.
2815 \Msg{Not generating file \@pathname^^J}%
2816 \expandafter\@gobble
2822 % \begin{macro}{\@fileX}
2823 % We put name of current output file in |\curout| and initialize
2824 % |\curinfiles| (the list of source files for this output file)
2825 % to empty---these will be needed by |\from|. Then we start
2826 % defining preamble for the current file.
2829 \chardef#1=\stream@closed
2831 \let\curinfiles\empty
2832 \let\curinnames\empty
2833 \def\curref{\MetaPrefix ^^J%
2834 \MetaPrefix\space The original source files were:^^J%
2837 % Next we execute second parameter. |\from|s will add reference
2838 % lines to the preamble.
2840 \let\from\@from \let\needed\@needed
2842 \let\from\err@from \let\needed\err@needed
2844 % We check order of input files.
2848 % Each |\from| clause defines |\curin| to be its first parameter.
2849 % So now |\curin| holds name of last input file for current output
2850 % file. This means that current output file should be closed after
2851 % processing |\curin|. We add |#1| to proper `close list'.
2853 \Name\@addto{e@\curin}{\noexpand\closeoutput{#1}}%
2855 % Last we save all the interesting information about current file.
2857 \Name\let{pre@\@stripstring#1\expandafter}\currentpreamble
2858 \Name\let{post@\@stripstring#1\expandafter}\currentpostamble
2859 \Name\edef{in@\@stripstring#1}{\expandafter\iden\curinnames}
2860 \Name\edef{ref@\@stripstring#1}{\curref}
2865 % \begin{macro}{\checkorder}
2866 % This macro checks if the order of files in |\curinfiles|
2867 % agrees with that of |\inputfiles|. The coding is somewhat
2871 \expandafter\expandafter\expandafter
2872 \checkorderX\expandafter\curinfiles
2873 \expandafter\qStop\inputfiles\qStop
2875 \def\checkorderX(#1)#2\qStop#3\qStop{%
2876 \def\tmp##1\readsource(#1)##2\qStop{%
2877 \ifx!##2! \order@error
2881 \def\checkorderXX##1\readsource(#1)\fi\fi{\fi\fi
2882 \checkorderX#2\qStop##1\qStop}%
2883 \tmp#3\readsource(#1)\qStop
2885 \def\order@error#1\fi\fi{\fi
2886 \errmessage{DOCSTRIP error: Incompatible order of input
2887 files specified for file
2888 `\iden{\expandafter\uptospace\curin} \qStop'.^^J
2889 Read DOCSTRIP documentation for explanation.^^J
2890 This is a serious problem, I'm exiting}\end
2895 % \begin{macro}{\needed}
2896 % \changes{2.3c}{1995/08/24}{Macro added}
2897 % \changes{2.3e}{1996/09/12}{Forced expansion of argument to fix a bug
2898 % with filenames containing macros}
2899 % \begin{macro}{\@needed}
2900 % This macro uniquizes name of an input file passed as a
2901 % parameter and marks it as needed to be input. It is used
2902 % internally by |\from|, but can also be issued in argument to
2903 % |\file| to influence the order in which files are read.
2905 \def\needed#1{\errmessage{\string\needed\space can only be used in
2906 argument to \string\file}}
2907 \let\err@needed\needed
2909 \edef\reserved@a{#1}%
2910 \expandafter\@need@d\expandafter{\reserved@a}}
2912 \@ifpresent{(#1)}\curinfiles
2914 % If |#1| is present on list of input files for current output
2915 % file we add a space on end of its name and try again. The idea
2916 % is to construct a name that will look different for \TeX\ but
2917 % will lead to the same file when seen by operating system.
2921 % When it is not we check if |#1| is present in the list of
2922 % files to be processed. If not we add it and initialize list of
2923 % output files for that input and list of output files that
2924 % should be closed when this file closes. We also add
2925 % constructed name to |\curinfiles| and define |\curin| to be
2926 % able to access constructed name from |\@from|.
2928 {\@ifpresent{\readsource(#1)}\inputfiles
2929 {}{\@addto\inputfiles{\noexpand\readsource(#1)}%
2930 \Name\let{b@#1}\empty
2931 \Name\let{o@#1}\empty
2932 \Name\let{e@#1}\empty}%
2933 \@addto\curinfiles{(#1)}%
2940 % \begin{macro}{\from}
2941 % \changes{2.3c}{1995/08/24}{part of code moved to \cs{needed}}
2942 % |\from| starts by adding a line to preamble for output file.
2944 \def\from#1#2{\errmessage{Command `\string\from' only allowed in
2945 argument to `\string\file'}}
2948 \@addto\curref{\MetaPrefix\space #1 \if>#2>\else
2949 \space (with options: `#2')\fi^^J}%
2951 % Then we mark the file as needed input file.
2955 % \changes{2.3e}{1996/10/02}{Introduced ``open list''}
2956 % If this is the first |\from| in current |\file| (i.e. if the
2957 % |\curinnames| so far is empty) the file name is added to the
2958 % ``open list'' for the current input file.
2959 % And |\do|\meta{current output}|{|\meta{options}|}| is appended
2960 % to the list of output files for current input file.
2962 \ifx\curinnames\empty
2963 \Name\@addto{b@\curin}{\noexpand\openoutput\curout}%
2965 \@addto\curinnames{ #1}%
2966 \Name\@addto{o@\curin}{\noexpand\do\curout{#2}}%
2971 % \begin{macro}{\readsource}
2972 % \changes{2.4a}{1996/06/06}{Extensively hacked to honour stream
2974 % \changes{2.3a}{1995/08/18}{Renamed to \cs{readsource}; adaptation for
2975 % concurrent version}
2976 % \changes{2.0f}{1991/06/04}{Added check for lines with \texttt{\bsl
2977 % endinput}} This macro is called for each input file that
2978 % is to be processed.
2981 \def\readsource(#1){%
2983 % We try to open the input file. If this doesn't succeed, we
2984 % tell the user so and nothing else happens.
2986 \immediate\openin\inFile\uptospace#1 \qStop\relax
2988 \errmessage{Cannot find file \uptospace#1 \qStop}%
2991 % If statistics are included we nullify line counters
3000 % \changes{2.3b}{1995/08/22}{Change for pre-constructed
3001 % off-counters' names}
3002 % \changes{2.3e}{1996/10/02}{Introduced ``open list''}
3003 % When the input file was successfully opened, we try to open all
3004 % needed output files by executing the ``open list''.
3005 % If any of files couldn't be opened because of number of streams
3006 % limits, their names are put into |\refusedfiles| list. This list
3007 % subsequently becomes the open list for the next pass.
3009 \let\refusedfiles\empty
3010 \csname b@#1\endcsname
3011 \Name\let{b@#1}\refusedfiles
3013 % Now all output files that could be opened are open. So we go
3014 % through the ``output list'' and for every open file we display a
3015 % message and zero the off-counter, while closed files are appended
3016 % to |\refusedfiles|.
3018 \Msg{} \def\@msg{Processing file \uptospace#1 \qStop}
3020 \edef\@msg{\@spaces\@spaces\@spaces\space
3021 \expandafter\tospaces\uptospace#1 \qStop\secapsot}
3022 \let\change@msg\relax}
3023 \let\do\showfiles@do
3024 \let\refusedfiles\empty
3025 \csname o@#1\endcsname
3027 % If |\refusedfiles| is nonempty current source file needs reread,
3028 % so we append it to |\newinputfiles|.
3030 \ifx\refusedfiles\empty\else
3031 \@addto\newinputfiles{\noexpand\readsource(#1)}
3034 % Finally we define |\outputfiles| and construct off-counters
3035 % names. Now |\do|s will have 3 parameters! All output files become
3038 \let\do\makeoutlist@do
3039 \edef\outputfiles{\csname o@#1\endcsname}%
3040 \let\activefiles\outputfiles
3041 \Name\let{o@#1}\refusedfiles
3043 % Now we change the category code of a lot of characters to
3044 % \meta{other} and make sure that no extra spaces appear in the
3045 % lines read by setting the |\endlinechar| to $-1$.
3047 \makeOther\ \makeOther\\\makeOther\$%
3048 \makeOther\#\makeOther\^\makeOther\^^K%
3049 \makeOther\_\makeOther\^^A\makeOther\%%
3050 \makeOther\~\makeOther\{\makeOther\}\makeOther\&%
3051 \endlinechar-1\relax
3053 % Then we start a loop to process the lines in the file one by one.
3056 \read\inFile to\inLine
3058 % The first thing we check is whether the current line
3059 % contains an |\endinput|. To allow also real |\endinput|
3060 % commands in the source file, |\endinput| is only recognized
3061 % when it occurs directly at the beginning of a line.
3063 \ifx\inLine\Endinput
3065 % In this case we output a message to inform the programmer (in
3066 % case this was a mistake) and end the loop immediately by setting
3067 % \verb=Continue= to \meta{false}. Note that |\endinput| is
3068 % not placed into the output file. This is important in cases where
3069 % the output file is generated from several \texttt{doc} files.
3071 \Msg{File #1 ended by \string\endinput.}%
3075 % \changes{2.0j}{1992/03/03}{First check for end of file before check
3076 % for empty lines} When the end of the file is found we have to
3077 % interrupt the loop.
3082 % \changes{2.0i}{1991/06/27}{Added check for consecutive empty lines}
3083 % If the file did not end we check if the input line is empty.
3084 % If it is, the counter |\emptyLines| is incremented.
3089 \advance\emptyLines\@ne
3094 % When the number of empty lines seen so far exceeds 1, we skip them.
3095 % If it doesn't, the expansion of |\inLine| is fed to |\processLine|
3096 % with |\endLine| appended to indicate the end of the line.
3098 \ifnum \emptyLines<2
3099 \expandafter\processLine\inLine\endLine
3106 % When the processing of the line is finished, we check if there is
3107 % more to do, in which case we repeat the loop.
3112 % The input file is closed.
3116 % We close output files for which this was the last input file.
3118 \csname e@#1\endcsname
3120 % If the user was interested in statistics, we inform him of the
3121 % number of lines processed, the number of comments that were
3122 % either removed or passed and the number of codelines that were
3123 % written to the output file. Also the totals are updated.
3126 \Msg{Lines \space processed: \the\processedLines^^J%
3127 Comments removed: \the\commentsRemoved^^J%
3128 Comments \space passed: \the\commentsPassed^^J%
3129 Codelines passed: \the\codeLinesPassed^^J}%
3130 \global\advance\TotalprocessedLines by \processedLines
3131 \global\advance\TotalcommentsRemoved by \commentsRemoved
3132 \global\advance\TotalcommentsPassed by \commentsPassed
3133 \global\advance\TotalcodeLinesPassed by \codeLinesPassed
3136 % The |\NumberOfFiles| need to be known even if no statistics are
3137 % gathered so we update it always.
3138 % \changes{2.4h}{1997/07/07}{update \cs{NumberOfFiles} even if stats are
3139 % not gathered pr/2429}
3141 \global\advance\NumberOfFiles by \@ne
3146 % \begin{macro}{\showfiles@do}
3147 % \changes{2.4a}{1996/10/02}{Macro added (MW)}
3148 % A message is displayed on the terminal telling the user what we
3149 % are about to do. For each open output file we display one line
3150 % saying what options it is generated with and the off-counter
3151 % associated with the file is zeroed. First line contains also name
3153 % Names of output files that are closed are appended to
3156 \def\showfiles@do#1#2{%
3157 \ifnum#1=\stream@closed
3158 \@addto\refusedfiles{\noexpand\do#1{#2}}%
3161 \ifx>#2>\else\space(#2)\fi
3162 \space -> \@stripstring#1}
3164 \csname off@\number#1\endcsname=\z@
3170 % \begin{macro}{\makeoutlist@do}
3171 % \changes{2.3b}{1995/08/22}{Macro added --- pre-constructed
3172 % off-counters' names}
3173 % This macro selects only open output files and constructs names for
3176 \def\makeoutlist@do#1#2{%
3177 \ifnum#1=\stream@closed\else
3178 \noexpand\do#1{#2}\csname off@\number#1\endcsname
3183 % \begin{macro}{\openoutput}
3184 % \changes{2.3e}{1996/10/02}{Change for ``open lists'' -- renamed from
3185 % \cs{ensureopen@do}}
3186 % \changes{2.4a}{1996/06/06}{Check whether there are streams left (MDW)}
3187 % This macro opens output streams if possible.
3191 % If both maxfile counters are non-zero\dots
3193 \if 1\ifnum\@maxfiles=\z@ 0\fi
3194 \ifnum\@maxoutfiles=\z@ 0\fi1%
3196 % \dots the stream may be opened and counters decremented. But if
3197 % that cannot be done\dots
3199 \advance\@maxfiles\m@ne
3200 \advance\@maxoutfiles\m@ne
3205 % \dots the file is added to the ``refuse list''.
3207 \@addto\refusedfiles{\noexpand\openoutput#1}%
3213 % \begin{macro}{\closeoutput}
3214 % \changes{2.4a}{1996/06/06}
3215 % {Don't close the file if it's not open (MDW)}
3216 % This macro closes open output stream when it is no longer
3217 % needed and increments maxfiles counters.
3219 \def\closeoutput#1{%
3220 \ifnum#1=\stream@closed\else
3223 \advance\@maxfiles\@ne
3224 \advance\@maxoutfiles\@ne
3229 % \subsubsection{Preamble and postamble}
3231 % \begin{macro}{\ds@heading}
3232 % \changes{2.3e}{1996/09/16}{Macro added.}
3233 % This is a couple of lines, stating what file is being written and
3234 % how it was created.
3238 \MetaPrefix\space This is file `\outFileName',^^J%
3239 \MetaPrefix\space generated with the docstrip utility.^^J%
3244 % \begin{macro}{\AddGenerationDate}
3245 % \changes{2.3d}{1995/11/17}{(DPC) Macro added.}
3246 % Older versions of \ds{} added the date that any file was generated
3247 % and the version number of \ds{}. This confused some people as they
3248 % mistook this for the version/date of the file that was being
3249 % written. So now this information is not normally written, but
3250 % a batch file may call this to get an old style header.
3252 \def\AddGenerationDate{%
3255 \MetaPrefix\space This is file `\outFileName', generated %
3256 on <\the\year/\the\month/\the\day> ^^J%
3257 \MetaPrefix\space with the docstrip utility (\fileversion).^^J%
3262 % \begin{macro}{\declarepreamble}
3263 % \changes{2.3a}{1995/08/18}{renamed from \cs{preamble};
3264 % interface changed}
3265 % \changes{2.0e}{1991/06/01}{Macro added.}
3266 % \changes{2.3e}{1995/09/25}
3267 % {Change for batchfiles working by \cs{input}}
3268 % \changes{2.3e}{1996/09/16}{Change to allow customization.}
3269 % When a batch file is used the
3270 % user can specify a preamble of his own that will be written to
3271 % each file that is created. This can be useful to include an extra
3272 % copyright notice in the stripped version of a file. Also a
3273 % warning that both versions of a file should {\em always\/} be
3274 % distributed together could be written to a stripped file by
3275 % including it in such a preamble.
3277 % Every line that is written to |\outFile| that belongs to the
3278 % preamble is preceded by two percent characters. This will prevent
3279 % \ds{} from stripping these lines off the file.
3281 % The preamble should be started with the macro
3282 % |\declarepreamble|; it is ended by |\endpreamble|. All
3283 % processing is done within a group in order to be able to locally
3284 % change some values.
3286 % |\ReferenceLines| is let equal |\relax| to be unexpandable.
3288 \let\inFileName\relax
3289 \let\outFileName\relax
3290 \let\ReferenceLines\relax
3291 \def\declarepreamble{\begingroup
3292 \catcode`\^^M=13 \catcode`\ =12 %
3295 \gdef\declarepreambleX#1#2
3296 \endpreamble{\endgroup%
3297 \def^^M{^^J\MetaPrefix\space}%
3298 \edef#1{\ds@heading%
3300 \MetaPrefix\space\checkeoln#2\empty}}%
3301 \gdef\checkeoln#1{\ifx^^M#1\else\expandafter#1\fi}%
3306 % \begin{macro}{\declarepostamble}
3307 % \changes{2.0e}{1991/06/01}{Macro added.}
3308 % \changes{2.3e}{1995/09/25}
3309 % {Change for batchfiles working by \cs{input}}
3310 % Just as a preamble can be
3311 % specified in a batch file, the same can be done for a {\em
3314 % The definition of |\declarepostamble| is very much like the
3315 % definition above of |\declarepreamble|.
3317 \def\declarepostamble{\begingroup
3318 \catcode`\ =12 \catcode`\^^M=13
3321 \gdef\declarepostambleX#1#2
3322 \endpostamble{\endgroup%
3323 \def^^M{^^J\MetaPrefix\space}%
3324 \edef#1{\MetaPrefix\space\checkeoln#2\empty^^J%
3326 \MetaPrefix\space End of file `\outFileName'.%
3332 % \begin{macro}{\usepreamble}
3333 % \begin{macro}{\usepostamble}
3334 % Macros for selecting [pre/post]amble to be used.
3336 \def\usepreamble#1{\def\currentpreamble{#1}}
3337 \def\usepostamble#1{\def\currentpostamble{#1}}
3342 % \begin{macro}{\nopreamble}
3343 % \changes{2.4i}{1998/01/18}{Macro added. pr/2726}
3344 % \begin{macro}{\nopostamble}
3345 % \changes{2.4i}{1998/01/18}{Macro added. pr/2726}
3346 % Shortcuts for disabling the writing of [pre/post]ambles.
3347 % This is not done by disabling |\WritePreamble| or |\WritePostamble|
3348 % since that wouldn't
3349 % revertable afterwards. Instead the empty [pre/post]ambles are handled
3350 % specially in those macros.
3352 \def\nopreamble{\usepreamble\empty}
3353 \def\nopostamble{\usepostamble\empty}
3358 % \begin{macro}{\preamble}
3359 % \changes{2.3c}{1995/08/28}{Bug fixed: default preamble is now selected
3361 % \begin{macro}{\postamble}
3362 % \changes{2.3c}{1995/08/28}{As for \cs{preamble}}
3363 % For backward compatibility we provide these macros defining
3364 % default preamble and postamble.
3366 \def\preamble{\usepreamble\defaultpreamble
3367 \declarepreamble\defaultpreamble}
3368 \def\postamble{\usepostamble\defaultpostamble
3369 \declarepostamble\defaultpostamble}
3373 % \begin{macro}{\org@preamble}
3374 % \changes{2.3a}{1995/08/18}{Macro added}
3375 % \changes{2.3c}{1995/11/16}{With \cs{inFileName} again}
3376 % \begin{macro}{\org@postamble}
3377 % \changes{2.3a}{1995/08/18}{Macro added}
3378 % Default values to use if nothing different is provided.
3379 % \changes{2.2j}{1995/08/06}{Updated default preamble}
3380 % \changes{2.5a}{1998/04/03}{Updated default preamble}
3382 \declarepreamble\org@preamble
3386 For the copyright see the source file.
3388 Any modified versions of this file must be renamed
3389 with new filenames distinct from \outFileName.
3391 For distribution of the original source see the terms
3392 for copying and modification in the file \inFileName.
3394 This generated file may be distributed as long as the
3395 original source files, as listed above, are part of the
3396 same distribution. (The sources need not necessarily be
3397 in the same archive or directory.)
3402 \edef\org@postamble{\string\endinput^^J%
3404 \MetaPrefix\space End of file `\outFileName'.%
3409 \let\defaultpreamble\org@preamble
3410 \let\defaultpostamble\org@postamble
3414 \usepreamble\defaultpreamble
3415 \usepostamble\defaultpostamble
3420 % \begin{macro}{\originaldefault}
3421 % \changes{2.5a}{1998/04/03}{Macro added}
3422 % \changes{2.5b}{1998/04/28}{Macro renamed from \cs{orginaldefault}
3423 % to \cs{originaldefault}}
3424 % The default preamble header changed in v2.5 to allow distribution
3425 % of generated files as long as source also distributed. If you need
3426 % the original default, not allowing distribution of generated files
3427 % add |\usepreamble\originaldefault| to your .ins files.
3428 % Note then that your file can not be included in most TeX distributions
3429 % on CD which are distributed `pre-installed' with all \LaTeX\ files
3430 % extracted form the documented sources and moved to a suitable
3431 % directory in \TeX's search path.
3433 \declarepreamble\originaldefault
3437 For the copyright see the source file.
3439 You are *not* allowed to modify this file.
3441 You are *not* allowed to distribute this file.
3442 For distribution of the original source see the terms
3443 for copying and modification in the file \inFileName.
3449 % \begin{macro}{\WritePreamble}
3450 % \changes{2.0e}{1991/06/01}{Macro added.}
3451 % \changes{2.3c}{1995/11/16}{Added definitions of \cs{inFileName} and
3453 % \changes{2.3d}{1995/11/17}{(DPC) Macro added.}
3454 % \changes{2.4i}{1998/01/18}{Test for \cs{empty} postamble and
3455 % don't write it out. pr/2726}
3457 \def\WritePreamble#1{%
3459 % We write out only non-empty preambles.
3461 \expandafter\ifx\csname pre@\@stripstring#1\endcsname\empty
3463 \edef\outFileName{\@stripstring#1}%
3465 % Then the reference lines that tell from what source file(s) the
3466 % stripped file was created and user supplied preamble.
3468 \StreamPut#1{\csname pre@\@stripstring#1\endcsname}%
3473 % \begin{macro}{\WritePostamble}
3474 % \changes{2.0e}{1991/06/01}{Macro added.}
3475 % \changes{2.3c}{1995/11/16}{Added defs of \cs{inFileName} and
3477 % \changes{2.4i}{1998/01/18}{Test for \cs{empty} postamble and
3478 % don't write it out. pr/2726}
3479 % Postamble attributed to |#1| is written out. The
3480 % last line written identifies the file again.
3482 \def\WritePostamble#1{%
3484 % We write out only non-empty postambles.
3486 \expandafter\ifx\csname post@\@stripstring#1\endcsname\empty
3488 \edef\outFileName{\@stripstring#1}%
3489 \StreamPut#1{\csname post@\@stripstring#1\endcsname}%
3494 % \subsection{Support for writing to specified directories}
3496 % As we've seen before every output file is written to directory
3497 % specified by the value of |\destdir| current at the moment of
3498 % this file's |\file| declaration.
3500 % \begin{macro}{\usedir}
3501 % \changes{2.3e}{1995/09/15}{Macro added}
3502 % This macro when called should translate its one argument into a
3503 % directory name and define |\destdir| to that value. The default
3504 % for |\usedir| is to ignore its argument and return name of
3505 % current directory (if known). This can be changed by commands
3506 % from |docstrip.cfg| file.
3508 % |\showdirectory| is used just to display directory name for
3509 % user's information.
3511 \def\usedir#1{\edef\destdir{\WriteToDir}}
3512 \def\showdirectory#1{\WriteToDir}
3516 % \begin{macro}{\BaseDirectory}
3517 % \changes{2.3e}{1995/09/15}{Macro added}
3518 % \changes{2.4e}{1996/10/22}{\cs{@setwritetodir} added (DPC)}
3519 % This is config file command for specifying root directory of the
3520 % \TeX{} hierarchy. It enables the whole directory
3521 % selecting mechanism by redefining |\usedir|.
3522 % First make sure that the directory syntax commands have been set
3523 % up by calling |\@setwritedir|, so that the value of |\dirsep|
3524 % used by the |\edef| is (hopefully) correct.
3526 \def\BaseDirectory#1{%
3528 \let\usedir\alt@usedir
3529 \let\showdirectory\showalt@directory
3530 \edef\basedir{#1\dirsep}}
3534 % \begin{macro}{\convsep}
3535 % \changes{2.3e}{1995/09/15}{Macro added}
3536 % This macro loops through slashes in its argument replacing them
3537 % with current |\dirsep|. It should be called
3538 % |\convsep some/directory/name/\qStop| (with slash on the end).
3540 \def\convsep#1/#2\qStop{%
3541 #1\ifx\qStop#2\qStop \pesvnoc\fi\convsep\dirsep#2\qStop}
3542 \def\pesvnoc#1\qStop{\fi}
3546 % \begin{macro}{\alt@usedir}
3547 % \changes{2.3e}{1995/09/15}{Macro added}
3548 % Directory name construction macro enabling writing to various
3552 \Name\ifx{dir@#1}\relax
3553 \undefined@directory{#1}%
3555 \edef\destdir{\csname dir@#1\endcsname}%
3557 \def\showalt@directory#1{%
3558 \Name\ifx{dir@#1}\relax
3559 \showundef@directory{#1}%
3560 \else\csname dir@#1\endcsname\fi}
3564 % \begin{macro}{\undefined@directory}
3565 % \changes{2.4a}{1996/10/04}{Macro added (MW)}
3566 % \changes{2.4e}{1996/10/22}{Help text added (DPC)}
3567 % This macro comes into action when undefined label is spotted. The
3568 % action is to raise an error and define |\destdir| to point to the
3569 % current directory.
3571 \def\undefined@directory#1{%
3572 \errhelp{docstrip.cfg should specify a target directory for^^J%
3573 #1 using \DeclareDir or \UseTDS.}%
3574 \errmessage{You haven't defined the output directory for `#1'.^^J%
3575 Subsequent files will be written to the current directory}%
3576 \let\destdir\WriteToDir
3578 \def\showundef@directory#1{UNDEFINED (label is #1)}
3582 % \begin{macro}{\undefined@TDSdirectory}
3583 % \changes{2.4a}{1996/10/04}{Macro added (MW)}
3584 % This happens when label is undefined while using TDS. The label
3585 % is converted to use proper separators and appended to base
3588 \def\undefined@TDSdirectory#1{%
3590 \basedir\convsep#1/\qStop
3592 \def\showundef@TDSdirectory#1{\basedir\convsep#1/\qStop}
3596 % \begin{macro}{\UseTDS}
3597 % \changes{2.4a}{1996/10/04}{Macro added (MW)}
3598 % \changes{2.4e}{1996/10/22}{\cs{@setwritetodir} added (DPC)}
3599 % Change of behaviour for undefined labels is done simply:
3603 \let\undefined@directory\undefined@TDSdirectory
3604 \let\showundef@directory\showundef@TDSdirectory
3609 % \begin{macro}{\DeclareDir}
3610 % \changes{2.3e}{1995/09/15}{Macro added}
3611 % \changes{2.4e}{1996/10/22}{\cs{@setwritetodir} added (DPC)}
3612 % This macro remaps some directory name to another.
3614 \def\DeclareDir{\@ifnextchar*{\DeclareDirX}{\DeclareDirX\basedir*}}
3615 \def\DeclareDirX#1*#2#3{%
3617 \Name\edef{dir@#2}{#1#3}}
3622 % \subsubsection{Compatibility with older versions}
3624 % \begin{macro}{\generateFile}
3625 % Main macro of previous versions of \ds.
3627 \def\generateFile#1#2#3{{%
3628 \ifx t#2\askforoverwritetrue
3629 \else\askforoverwritefalse\fi
3630 \generate{\file{#1}{#3}}%
3635 % To support command files that were written for the first version
3636 % of \ds{} the commands |\include| and |\processFile|
3637 % are defined here. The use of this interface is not recommended
3638 % as it may be removed in a future release of \ds{}.
3640 % \begin{macro}{\include}
3641 % \changes{2.0f}{1991/06/04}{Macro added} To provide the \ds{} program
3642 % with a list of options that should be included in the output the
3643 % command \verb=\include{=\meta{Options}\verb=}= can be used. This
3644 % macro is meant to be used in conjunction with the
3645 % |\processFile| command.
3647 \def\include#1{\def\Options{#1}}
3651 % \begin{macro}{\processFile}
3652 % \changes{2.0f}{1991/06/04}{Supply \texttt{\bsl generateFile} with
3653 % \texttt{\bsl Options}}
3656 % \verb=\processFile{=\meta{filename}\verb=}{=\meta{inext}\verb=}{=%
3657 %\unskip\meta{outext}\verb=}{=\meta{t{\fontshape{n}\ttfamily|}f}\verb=}=
3658 % can be used when a single input file is used to produce
3659 % a single output file. The macro is also used in the interactive
3660 % mode of the \ds{} program.
3663 % The arguments \meta{inext} and \meta{outext} denote the
3664 % extensions of the input and output files respectively. The fourth
3665 % argument can be used to specify if an existing file should be
3666 % overwritten without asking. If \meta{t} is specified the program
3667 % will ask for permission before overwriting an existing file.
3669 % This macro is defined using the more generic macro |\generateFile|.
3671 \def\processFile#1#2#3#4{%
3672 \generateFile{#1.#3}{#4}{\from{#1.#2}{\Options}}}
3676 % \begin{macro}{\processfile}
3677 % \begin{macro}{\generatefile}
3678 % \changes{2.0m}{1991/04/23}{Now issue a warning when \cs{processfile}
3679 % or \cs{generatefile} are used}
3681 % versions of \ds{} defined |\processfile| and
3682 % |\generatefile| instead of the commands as they are defined in
3683 % this version. To remain upwards compatible, we still provide
3684 % these commands, but issue a warning when they are used.
3686 \def\processfile{\Msg{%
3687 ^^Jplease use \string\processFile\space instead of
3688 \string\processfile!^^J}%
3690 \def\generatefile{\Msg{%
3691 ^^Jplease use \string\generateFile\space instead of
3692 \string\generatefile!^^J}%
3699 % \subsection{Limiting open file streams}
3701 % (This section was written by Mark Wooding)
3703 % \begin{macro}{\maxfiles}
3704 % \changes{2.4a}{1996/06/06}{Macro added (MDW)}
3705 % Some operating systems with duff libraries or other restrictions
3706 % can't cope with all the files which \ds\ tries to output at once.
3707 % A configuration file can say |\maxfiles{|\meta{number}|}| to
3708 % describe the maximum limit for the environment.
3710 % I'll need a counter for this value, so I'd better allocate one.
3716 % The configuration command |\maxfiles| is just slightly prettier than
3717 % an assignment, for \LaTeX\ people. It also gives me an opportunity
3718 % to check that the limit is vaguely sensible. I need at least 4
3721 % \item A batch file.
3722 % \item A sub batch file, which \LaTeX's installation utility uses.
3723 % \item An input stream for reading an unstripped file.
3724 % \item An output stream for writing a stripped file.
3731 \errhelp{I'm not a magician. I need at least four^^J%
3732 streams to be able to work properly, but^^J%
3733 you've only let me use \the\@maxfiles.}%
3734 \errmessage{\noexpand\maxfiles limit is too strict.}%
3740 % \changes{2.4a}{1996/10/03}{No default limit since batchfiles are now
3742 % Since batchfiles are now |\input|ed there should be no default limit
3743 % here. I'll just use some abstract large number.
3745 \maxfiles{1972} % year of my birth (MW)
3750 % \begin{macro}{\maxoutfiles}
3751 % \changes{2.4a}{1996/06/06}{Macro added (MDW)}
3753 % Maybe there's a restriction on just output streams. (Well, there is:
3754 % I know, because \TeX\ only allows 16.) I may as well allow the
3755 % configuration to set this up.
3757 % Again, I need a counter.
3760 \newcount\@maxoutfiles
3763 % And now the macro. I need at least one output stream which I think is
3767 \def\maxoutfiles#1{%
3768 \@maxoutfiles=#1\relax
3769 \ifnum\@maxoutfiles<1
3771 \errhelp{I'm not a magician. I need at least one output^^J%
3772 stream to be able to do anything useful at all.^^J%
3773 Please be reasonable.}%
3774 \errmessage{\noexpand\maxoutfiles limit is insane}%
3779 % The default limit is 16, because that's what \TeX\ says.
3787 % \begin{macro}{\checkfilelimit}
3789 % This checks the file limit when a new batch file is started. If
3790 % there's fewer than two files left here, we're not going to be able
3791 % to strip any files. The file limit counter is local to the group
3792 % which is set up around |\batchinput|, so that's all pretty cool.
3795 \def\checkfilelimit{%
3796 \advance\@maxfiles\m@ne
3797 \ifnum\@maxfiles<2 %
3798 \errhelp{There aren't enough streams left to do any unpacking.^^J%
3799 I can't do anything about this, so complain at the^^J%
3800 person who made such a complicated installation.}%
3801 \errmessage{Too few streams left.}%
3809 % \subsection{Interaction with the user}
3811 % \begin{macro}{\strip@meaning}
3812 % Throw away the first part of |\meaning| output.
3813 % \changes{2.4c}{1996/06/11}{Macro added (DPC)}
3815 \def\strip@meaning#1>{}
3819 % \begin{macro}{\processbatchFile}
3820 % \changes{2.0f}{1991/06/04}{Macro added.}
3821 % \changes{2.3e}{1995/09/25}{Batch file is \cs{input}ed not \cs{read}}
3822 % When \ds{} is run it always tries to use a batch file.
3824 % For this purpose it calls the macro |\processbatchFile|.
3826 % \changes{2.4a}{1996/06/06}
3827 % {Added check for file limits (MDW)}
3828 % \changes{2.4c}{1996/06/11}
3829 % {Add \cs{jobname} checks (DPC)}
3830 % \changes{2.4d}{1996/06/17}
3831 % {Move \cs{jobname} checks to top level (DPC)}
3832 % The first thing is to check if there are any input streams left.
3834 \def\processbatchFile{%
3838 % Now we try to open the batch file for reading.
3840 \openin\inputcheck \batchfile\relax
3843 % If we didn't succeed in opening the file, we assume that it does
3844 % not exist. If we tried the default filename, we silently
3845 % continue; the \ds{} program will switch to interactive mode in
3851 % \changes{2.4d}{1996/10/17}{Missing batchfile an error (DPC)}
3852 % If we failed to open the user-supplied file, something is wrong
3853 % and we warn him about it. This will also result in a switch to
3857 {A batchfile specified in \batchinput could not be found.}%
3859 **************************************************^^J%
3860 * Could not find your \string\batchfile=\batchfile.^^J%
3861 **************************************************}%
3865 % When we were successful in opening a file, we again have to check
3866 % whether it was the default file. In that case we tell the user
3867 % we found that file and ask him if he wants to use it.
3870 \Msg{**************************************************^^J%
3871 * Batchfile \DefaultbatchFile\space found Use it? (y/n)?}%
3873 **************************************************}%
3876 % When it was the user-supplied file we can safely assume he wants
3877 % to use it so we set |\answer| to \texttt{y}.
3882 % If the macro |\answer| contains a \texttt{y} we can read in the
3883 % batchfile. We do it in an indirect way---after completing |\if|s.
3887 \def\next{\@@input\batchfile\relax}%
3894 % \begin{macro}{\ReportTotals}
3895 % \changes{2.0g}{1991/06/05}{Macro added.} The macro
3896 % |\ReportTotals| can be used to report total statistics for
3897 % all files processed. This code is only included in the program if
3898 % the option \texttt{stats} is included.
3902 \ifnum\NumberOfFiles>\@ne
3903 \Msg{Overall statistics:^^J%
3904 Files \space processed: \the\NumberOfFiles^^J%
3905 Lines \space processed: \the\TotalprocessedLines^^J%
3906 Comments removed: \the\TotalcommentsRemoved^^J%
3907 Comments \space passed: \the\TotalcommentsPassed^^J%
3908 Codelines passed: \the\TotalcodeLinesPassed}%
3914 % \begin{macro}{\SetFileNames}
3915 % The macro |\SetFileNames| is used when the program runs in
3916 % interactive mode and the user was asked to supply extensions and
3917 % a list of filenames.
3920 \edef\sourceFileName{\MainFileName.\infileext}%
3921 \edef\destFileName{\MainFileName.\outfileext}}
3925 % \begin{macro}{\CheckFileNames}
3926 % In interactive mode, the user gets asked for the extensions for
3927 % the input and output files. Also the name or names of the input
3928 % files (without extension) is asked for. Then the names of the
3929 % input and output files are constructed from this information by
3930 % |\SetFileNames|. This assumes that the name of the input file is
3931 % the same as the name of the output file. But we should not write
3932 % to the same file we're reading from so the extensions should
3935 % The macro |\CheckFileNames| makes sure that the output goes to a
3936 % different file to the one where the input comes from.
3938 \def\CheckFileNames{%
3939 \ifx\sourceFileName\destFileName
3941 % If input and output files are the same we signal an error and stop
3945 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J%
3946 ! It is not possible to read from and write to the same file !^^J%
3947 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J}%
3951 % If they are not the same we check if the input file exists by
3952 % trying to open it for reading.
3955 \immediate\openin\inFile \sourceFileName\relax
3958 % If an end of file was found, the file couldn't be opened, so we
3959 % signal an error and stop processing.
3962 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J%
3963 ! Your input file `\sourceFileName' was not found !^^J%
3964 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J}%
3968 % The last check we have to make is if the output file already
3969 % exists. Therefore we try to open it for reading.
3970 % As a precaution we first close the input stream.
3971 % \changes{2.0p}{1992/06/26}{Added \cs{WriteToDir} (FMi).}
3972 % \changes{2.0r}{1992/08/17}{Use \cs{inFile} for reading}
3973 % \changes{2.0r}{1992/08/17}{Moved \cs{closein} statements}
3975 \immediate\closein\inFile
3976 \immediate\openin\inFile\destdir \destFileName\relax
3979 % If this fails, it didn't exist and all is well.
3984 % If opening of the output file for reading succeeded we have to
3985 % ask the user if he wants to overwrite it. We assume he doesn't
3986 % want to overwrite it, so the switch |\ifContinue| is initially
3987 % set to \meta{false}. Only if he answers the question positively
3988 % with `\texttt{y}' or `\texttt{yes}' we set the switch back to
3990 % \changes{2.0p}{1992/06/26}{Changed question about overwriting.}
3993 \Ask\answer{File \destdir\destFileName\space already
3995 \ifx\empty\destdir somewhere \fi
3998 \ifx\empty\destdir\space if necessary\fi
4000 \ifx\y \answer \Continuetrue \else
4001 \ifx\yes\answer \Continuetrue \else
4005 % All checks have been performed now, so we can close any file that
4006 % was opened just for this purpose.
4014 % \begin{macro}{\interactive}
4015 % The macro |\interactive| implements the interactive mode of the
4016 % \ds{} program. The macro is implemented using the
4017 % \meta{while} construction. While the switch |\ifMoreFiles| remains
4018 % true, we continue processing.
4021 \whileswitch\ifMoreFiles\fi%
4023 % To keep macro redefinitions local we start a group and ask the
4024 % user some questions about what he wants us to do.
4029 % The names of the files that have to be processed are stored as a
4030 % comma-separated list in the macro |\filelist| by |\AskQuestions|.
4031 % We use a \meta{for} loop to process the files one by one.
4033 \forlist\MainFileName:=\filelist
4036 % First the names of the input and output files are constructed
4037 % and a check is made if all filename information is correct.
4043 % If everything was well, produce output file.
4044 % \changes{2.0q}{1992/07/01}{Preceded filename by \cs{WriteToDir}}
4046 \generateFile{\destFileName}{f}%
4047 {\from{\sourceFileName}{\Options}}
4050 % This process is repeated until |\filelist| is exhausted.
4055 % Maybe the user wants more files to be processed, possibly with
4056 % another set of options, so we give him the opportunity.
4058 \Ask\answer{More files to process (y/n)?}%
4059 \ifx\y \answer\MoreFilestrue \else
4060 \ifx\yes\answer\MoreFilestrue \else
4062 % If he didn't want to process any more files, the switch
4063 % |\ifMoreFiles| is set to \meta{false} in order to interrupt the
4064 % \meta{while} loop.
4066 \MoreFilesfalse\fi\fi
4071 % \begin{macro}{\AskQuestions}
4072 % \changes{2.0e}{1991/06/01}{Macro added.}
4073 % The macro |\AskQuestions| is called by |\interactive| to get
4074 % some information from the user concerning the files that need
4079 ****************************************************}%
4081 % We want to know the extension of the input files,
4084 * First type the extension of your input file(s): \space *}%
4085 \Msg{****************************************************^^J^^J%
4086 ****************************************************}%
4088 % the extension of the output files,
4091 * Now type the extension of your output file(s) \space: *}%
4092 \Msg{****************************************************^^J^^J%
4093 ****************************************************}%
4095 % if options are to be included and
4098 * Now type the name(s) of option(s) to include \space\space: *}%
4099 \Msg{****************************************************^^J^^J%
4100 ****************************************************^^J%
4101 * Finally give the list of input file(s) without \space\space*}%
4103 % the name of the input file or a list of names, separated by commas.
4104 % \changes{2.5e}{2014/09/29}{Typo in \cs{Ask} argument fixed}
4107 * extension separated by commas if necessary %
4108 \space\space\space\space: *}%
4109 \Msg{****************************************************^^J}}%
4113 % \subsection{The main program}
4114 % When \TeX\ processes the \ds{} program it displays
4115 % a message about the version of the program and its function
4118 \Msg{Utility: `docstrip' \fileversion\space <\filedate>^^J%
4119 English documentation \space\space\space <\docdate>}%
4121 **********************************************************^^J%
4122 * This program converts documented macro-files into fast *^^J%
4123 * loadable files by stripping off (nearly) all comments! *^^J%
4124 **********************************************************^^J}%
4128 % \begin{macro}{\WriteToDir}
4129 % Macro |\WriteToDir| is either empty or holds the prefix
4130 % necessary to read a file from the current directory. Under UNIX
4131 % this is |./| but a lot of other systems addopted this concept.
4132 % This macro is a default value for |\destdir|.
4134 % The definition of this macro is now delayed until |\@setwritedir|
4136 % \changes{2.0p}{1992/06/26}{Macro added (FMi).}
4137 % \changes{2.2a}{1993/12/02}{check texsys file}
4138 % \changes{2.2d}{1994/01/20}{do not read dircheck/texsys file}
4139 % \changes{2.4e}{1996/10/22}{set in \cs{@setwritedir} (DPC)}
4142 % \begin{macro}{\makepathname}
4143 % \changes{2.3e}{1995/10/24}{Macro added}
4144 % \changes{2.4e}{1996/10/22}{set in \cs{@setwritedir} (DPC)}
4145 % This macro should define |\@pathname| to full path name made by
4146 % combining current value of |\destdir| with its one argument being
4147 % a file name. Its default value defined here is suitable for
4148 % \textsc{unix, ms-dos} and Macintosh, but for some systems it may
4149 % be needed to redefine this in \texttt{docstrip.cfg} file. We
4150 % provide such redefinition for VMS here.
4152 % Macro |\dirsep| holds directory separator specific for a
4153 % system. Default value suitable for UNIX and DOS is slash. It
4154 % comes in action when |\usedir| labels are used directly.
4156 % The definition of this macro is now delayed until |\@setwritedir|
4160 % \begin{macro}{\@setwritedir}
4161 % \changes{2.4e}{1996/10/22}{macro added (DPC)}
4162 % The following tests try to automatically set the macros |\WriteToDir|,
4163 % |\dirname| and |\makepathname| in Unix, Mac, or VMS style.
4164 % The tests are not run at the top level but held in this macro
4165 % so that a configuration file has a chance to define |\WriteToDir|
4166 % which allows the other two to be set automatically. The tests could
4167 % more simply be run after the configuration file is read, but the
4168 % configuration commands like |\BaseDirectory| need (at least at
4169 % present) to have |\dirsep| correctly defined. It does not define
4170 % any command that is already defined, so by defining these commands
4171 % a configuration file can produce different effects for special needs.
4172 % So this command is called by |BaseDirectory|, |\UseTDS|,
4173 % |\DeclareDir| and finally at the top level after the cfg is run.
4174 % It begins by redefining itself to be a no-op so it effectively is
4177 \def\@setwritetodir{%
4178 \let\setwritetodir\relax
4182 \ifx\WriteToDir\@undefined
4183 \ifx\@currdir\@undefined
4186 \let\WriteToDir\@currdir
4192 \let\destdir\WriteToDir
4199 \ifx\dirsep\@undefined
4202 \ifx\makepathname\@undefined
4203 \def\makepathname##1{%
4204 \edef\@pathname{\ifx\WriteToDir\destdir
4205 \WriteToDir\else[\destdir]\fi##1}}%
4210 % Unix and Mac styles.
4212 \ifx\dirsep\@undefined
4222 \ifx\makepathname\@undefined
4223 \def\makepathname##1{%
4224 \edef\@pathname{\destdir\ifx\empty\destdir\else
4225 \ifx\WriteToDir\destdir\else\dirsep\fi\fi##1}}%
4231 % If the user has a |docstrip.cfg| file, use it now.
4232 % \changes{2.4d}{1995/10/17}{Move config file test to outer level (DPC)}
4233 % This macro tries to read \texttt{docstrip.cfg} file. If this
4234 % succeeds executes its first argument, otherwise the second.
4236 \immediate\openin\inputcheck=docstrip.cfg\relax
4239 ********************************************************^^J%
4240 * No Configuration file found, using default settings. *^^J%
4241 ********************************************************^^J}%
4244 ******************************************^^J%
4245 * Using Configuration file docstrip.cfg. *^^J%
4246 ******************************************^^J}%
4248 \afterfi{\@@input docstrip.cfg\relax}
4252 % Now run |\@setwritedir| in case it has not already been run
4253 % by a command in a configuration file.
4258 % \begin{macro}{\process@first@batchfile}
4259 % \changes{2.4d}{1996/10/17}
4260 % {Macro added (DPC)}
4261 % Process the batch file, and then terminate cleanly.
4262 % This may be set to |\relax| for `new style' batch files that
4263 % do not start with |\def\batchfile{|\ldots
4265 \def\process@first@batchfile{%
4267 \ifnum\NumberOfFiles=\z@
4274 % \begin{macro}{\endbatchfile}
4275 % \changes{2.4d}{1996/10/17}
4276 % {Macro added (DPC)}
4277 % User level command to end batch file processing.
4278 % At the top level, returns totals and then stops \TeX.
4279 % At nested levels just does |\endinput|.
4293 % Now we see whether to process a batch file.
4294 % \changes{2.4d}{1996/10/17}
4295 % {Move default batchfile check to outer level (DPC)}
4298 % \begin{macro}{\@jobname}
4299 % \changes{2.4d}{1996/10/17}
4300 % {Macro added (DPC)}
4301 % Jobname (catcode 12)
4303 \edef\@jobname{\lowercase{\def\noexpand\@jobname{\jobname}}}%
4309 % \begin{macro}{\@docstrip}
4310 % \changes{2.4d}{1996/10/17}
4311 % {Macro added (DPC)}
4312 % docstrip (catcode 12)
4314 \def\@docstrip{docstrip}%
4315 \edef\@docstrip{\expandafter\strip@meaning\meaning\@docstrip}
4319 % First check whether the user has
4320 % defined the control sequence |\batchfile|. If he did, it should
4321 % contain the name of the file to process.
4322 % If he didn't, try the current file, unless that is |docstrip.tex|
4323 % in which case a default name is tried.
4324 % Whether or not the default batch file is used is
4325 % remembered by setting the switch |\ifDefault| to \meta{true} or
4332 \ifx\undefined\batchfile
4334 % |\@jobname| is lowercase jobname (catcode 12)\\
4335 % |\@docstrip| is docstrip (catcode 12)
4337 \ifx\@jobname\@docstrip
4339 % Set the batchfile to the default
4341 \let\batchfile\DefaultbatchFile
4344 % Else don't process a new batchfile, just carry on with past the end
4345 % of this file. In this case processing will move to the initial
4346 % batchfile which \emph{must} then be terminated by |\endbatchfile| or
4347 % \TeX\ will fall to the star prompt.
4350 \let\process@first@batchfile\relax
4353 \process@first@batchfile