%% 
%% This is file `docstrip.tex',
%% generated with the docstrip utility.
%% 
%% The original source files were:
%% 
%% docstrip.dtx  (with options: `program,stats')
%% 
%% 
%% This is a generated file. 
%% 
%% Copyright 1993 1994 1995 The LaTeX3 Project and any individual 
%% authors listed elsewhere in this file. 
%% 
%% For further copyright information, and conditions for modification 
%% and distribution, see the file legal.txt, and any other copyright 
%% notices in this file. 
%% 
%% This file is part of the LaTeX2e system. 
%% ---------------------------------------- 
%% This system is distributed in the hope that it will be useful, 
%% but WITHOUT ANY WARRANTY; without even the implied warranty of 
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
%% 
%% For error reports concerning UNCHANGED versions of this file no 
%% more than one year old, see bugs.txt. 
%% 
%% Please do not request updates from us directly. Primary 
%% distribution is through the CTAN archives. 
%% 
%% 
%% IMPORTANT COPYRIGHT NOTICE: 
%% 
%% You are NOT ALLOWED to distribute this file alone. 
%% 
%% You are allowed to distribute this file under the condition that it 
%% is distributed together with all the files listed in manifest.txt. 
%% 
%% If you receive only some of these files from someone, complain! 
%% 
%% 
%% Permission is granted to copy this file to another file with a 
%% clearly different name and to customize the declarations in that 
%% copy to serve the needs of your installation, provided that you 
%% comply with the conditions in the file legal.txt. 
%% 
%% However, NO PERMISSION is granted to generate or to distribute a 
%% modified version of this file under its original name. 
%% 
%% You are NOT ALLOWED to change this file. 
%% 
%% 
%% MODIFICATION ADVICE: 
%% 
%% If you want to customize this file, it is best to make a copy of 
%% the source file(s) from which it was produced. Use a different 
%% name for your copy(ies) and modify the copy(ies); this will ensure 
%% that your modifications do not get overwritten when you install a 
%% new release of the standard system. You should also ensure that 
%% your modified source file does not generate any modified file with 
%% the same name as a standard file. 
%% 
%% You can then easily distribute your modifications by distributing 
%% the modified and renamed copy of the source file, taking care to 
%% observe the conditions in legal.txt; this will ensure that other 
%% users can safely use your modifications. 
%% 
%% You will also need to produce your own, suitably named, .ins file to 
%% control the generation of files from your source file; this file 
%% should contain your own preambles for the files it generates, not 
%% those in the standard .ins files. 
%% 
%% The names of the source files used are shown above. 
%% 
%% 
%% 
\def\filename{docstrip.dtx}
\def\fileversion{2.3d}
\def\filedate{1995/11/17}
\def\docdate {1995/11/18}
%% \CharacterTable
%%  {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
%%   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
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
%% The docstrip program for use with TeX.
%% Copyright (C) 1989-1991 Frank Mittelbach
%% Copyright (C) 1992-1995 Johannes Braams, Denys Duchier,
%%                         Frank Mittelbach
%% Copyright (C) 1995 Marcin Woli\'nski
%% All rights are reserved.
%%
\catcode`\@=11
\newlinechar=`\^^J
\newif\ifGenerate
\newif\ifContinue
\newif\ifForlist
\newif\ifDefault
\newif\ifMoreFiles \MoreFilestrue
\newif\ifaskforoverwrite \askforoverwritetrue
\newcount\blockLevel \blockLevel\z@
\newcount\emptyLines \emptyLines \z@
\newcount\processedLines   \processedLines  \z@
\newcount\commentsRemoved  \commentsRemoved \z@
\newcount\commentsPassed   \commentsPassed  \z@
\newcount\codeLinesPassed  \codeLinesPassed \z@
\newcount\NumberOfFiles \NumberOfFiles\z@
\newcount\TotalprocessedLines   \TotalprocessedLines  \z@
\newcount\TotalcommentsRemoved  \TotalcommentsRemoved \z@
\newcount\TotalcommentsPassed   \TotalcommentsPassed  \z@
\newcount\TotalcodeLinesPassed  \TotalcodeLinesPassed \z@
\newread\inFile
\chardef\ttyin16
\chardef\ttyout16
\newread\@tempa
\let\lowestbatchFile\@tempa
\newread\@tempa \newread\@tempa \newread\@tempa \newread\@tempa
\newread\@tempa \newread\@tempa \newread\@tempa \newread\@tempa
\newread\@tempa
\let\highestbatchFile\@tempa
\newcount\currbatchFile
\currbatchFile=\highestbatchFile
\advance\currbatchFile by -9
\def\ifToplevel{\relax\ifnum\currbatchFile=\lowestbatchFile
   \expandafter\iden \else \expandafter\@gobble\fi}
\ifx\undefined\@@input \let\@@input\input\fi
\def\batchinput#1{%
   \begingroup
     \def\batchfile{#1}%
     \advance\currbatchFile\@ne
     \ifnum\currbatchFile>\highestbatchFile
        \errhelp{Only up to ten levels of nesting for
                 \noexpand\batchinput commands are supported}%
        \errmessage{Batchfiles too deeply nested}%
     \fi
     \processbatchFile
   \endgroup
}
\def\skip@input#1 {}
\let\input\skip@input
\def\guardStack{}
\def\blockHead{}
\def\yes{yes}
\def\y{y}
\def\n{n}
\def\DefaultbatchFile{docstrip.cmd}
{\catcode`\%=12
 \gdef\perCent{%}
 \gdef\DoubleperCent{%% }
}
\def^^L{ }
\def\Name#1#2{\expandafter#1\csname#2\endcsname}
\def\@stripstring{\expandafter\@gobble\string}
\def\eltStart{}
\def\eltEnd{}
\def\qStop{\qStop}
\def\pop#1#2{%
  \ifx#1\empty
    \Msg{Warning: Found end guard without matching begin}%
    \let#2\empty
  \else
    \def\tmp{\expandafter\popX #1\qStop #1#2}%
    \expandafter\tmp\fi}
\def\popX\eltStart #1\eltEnd #2\qStop #3#4{\def#3{#2}\def#4{#1}}
\def\push#1#2{\expandafter\pushX #1\qStop #1{\eltStart #2\eltEnd}}
\def\pushX #1\qStop #2#3{\def #2{#3#1}}
\def\forlist#1:=#2\do#3\od{%
    \edef\ListCondition{#2}%
    \Forlisttrue
    \loop
      \edef#1{\expandafter\FirstElt\ListCondition,\empty.}%
      \edef\ListCondition{\expandafter\OtherElts\ListCondition,\empty.}%
      \ifx#1\empty \Forlistfalse \else#3\fi
      \ifForlist
    \repeat}
\def\FirstElt#1,#2.{#1}
\def\OtherElts#1,#2.{#2}
\def\whileswitch#1\fi#2{#1\loop#2#1\repeat\fi}
\ifx\@tempcnta\undefined \newcount\@tempcnta \fi
\@tempcnta=0
\loop
\Name\chardef{s@\number\@tempcnta}=0
\csname newcount\expandafter\endcsname%
  \csname off@\number\@tempcnta\endcsname
\advance\@tempcnta1
\ifnum\@tempcnta<16\repeat
\let\s@do\relax
\edef\@outputstreams{%
  \s@do\Name\noexpand{s@0}\s@do\Name\noexpand{s@1}
  \s@do\Name\noexpand{s@2}\s@do\Name\noexpand{s@3}
  \s@do\Name\noexpand{s@4}\s@do\Name\noexpand{s@5}
  \s@do\Name\noexpand{s@6}\s@do\Name\noexpand{s@7}
  \s@do\Name\noexpand{s@8}\s@do\Name\noexpand{s@9}
  \s@do\Name\noexpand{s@10}\s@do\Name\noexpand{s@11}
  \s@do\Name\noexpand{s@12}\s@do\Name\noexpand{s@13}
  \s@do\Name\noexpand{s@14}\s@do\Name\noexpand{s@15}
  \noexpand\@nostreamerror
  }
\def\@nostreamerror{\errmessage{No more output streams!}}
\def\@streamfound#1\@nostreamerror{\fi}
\bgroup\edef\x{\egroup
 \def\noexpand\@stripstr\string\s@{}}
\x
\def\StreamOpen#1{%
  \chardef#1=16
  \def\s@do##1{\ifnum##1=0
    \chardef#1=\expandafter\@stripstr\string##1 %
    \global\chardef##1=1 %
    \immediate\openout#1=\WriteToDir\@stripstring#1 %
    \@streamfound
    \fi}
  \@outputstreams
  }
\def\StreamClose#1{
  \immediate\closeout#1%
  \def\s@do##1{\ifnum#1=\expandafter\@stripstr\string##1 %
    \global\chardef##1=0 %
    \@streamfound
    \fi}
  \@outputstreams
  \chardef#1=16
  }
\def\StreamPut{\immediate\write}
\def\showprogress{\let\maybeMsg\message}
\def\keepsilent{\let\maybeMsg\@gobble}
\showprogress
\def\Msg{\immediate\write\ttyout}
\def\iden#1{#1}
\def\strip#1#2 \@gobble{\def #1{#2}}
\def\@defpar{\par}
\def\Ask#1#2{%
    \message{#2}\read\ttyin to #1\ifx#1\@defpar\def#1{}\else
    \iden{\expandafter\strip
       \expandafter#1#1\@gobble\@gobble} \@gobble\fi}
\def\@gobble#1{}
\edef\Endinput{\expandafter\@gobble\string\\endinput}
\def\makeOther#1{\catcode`#1=12\relax}
\ifx\undefined\@@end\else\let\end\@@end\fi
\ifx\@temptokena\undefined \csname newtoks\endcsname\@temptokena\fi

\def\@addto#1#2{%
  \@temptokena=\expandafter{#1}
  \edef#1{\the\@temptokena#2}}
\def\@ifpresent#1#2#3#4{%
  \def\tmp##1#1##2\qStop{\ifx!##2!}%
  \expandafter\tmp#2#1\qStop #4\else #3\fi
  }
\def\tospaces#1{%
  \ifx#1\secapsot\secapsot\fi\space\tospaces}
\def\secapsot\fi\space\tospaces{\fi}
\def\@spaces{\space\space\space\space\space}
\def\uptospace#1 #2\qStop{#1}
\def\@firstoftwo#1#2{#1}
\def\@secondoftwo#1#2{#2}
\def\@firstofthree#1#2#3{#1}
\def\@secondofthree#1#2#3{#2}
\def\@thirdofthree#1#2#3{#3}
\def\Terminal#1#2#3{%
  \expandafter\ifx\csname eT@#3\endcsname\relax
    \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
  {\Terminal{#1}{#2#3}}%
  {\TerminalX{#1}{#2}#3}%
  }
\Name\let{eT@>}=1
\Name\let{eT@&}=1 \Name\let{eT@!}=1
\Name\let{eT@|}=1 \Name\let{eT@,}=1
\Name\let{eT@(}=1 \Name\let{eT@)}=1
\def\TerminalX#1#2{%
  \ifx>#2> \errmessage{Error in expression: empty terminal}\fi
  \Name\def{t@#2}##1,#2,##2\qStop{\ifx>##2>0\else1\fi}%
  #1{\Name\noexpand{t@#2},##1,#2,\noexpand\qStop}%
  }
\def\Primary#1#2{%
  \ifcase \ifx!#20\else\ifx(#21\else2\fi\fi\space
    \expandafter\@firstofthree\or
    \expandafter\@secondofthree\or
    \expandafter\@thirdofthree\fi
  {\Primary{\NPrimary{#1}}}%
  {\Expression{\PExpression{#1}}}%
  {\Terminal{#1}{}#2}%
  }
\def\NPrimary#1#2{%
  #1{\noexpand\if1#20\noexpand\else1\noexpand\fi}%
  }
\def\PExpression#1#2#3{%
  \ifx)#3\else
    \errmessage{Error in expression: expected right parenthesis}\fi
  #1{#2}}
\def\Secondary#1{%
  \Primary{\SecondaryX{#1}}}
\bgroup\catcode`\&=12
\gdef\SecondaryX#1#2#3{%
  \ifx&#3%
    \expandafter\@firstoftwo\else
    \expandafter\@secondoftwo\fi
  {\Secondary{\SecondaryXX{#1}{#2}}}%
  {#1{#2}#3}%
  }
\egroup
\def\SecondaryXX#1#2#3{%
  #1{\noexpand\if0#20\noexpand\else#3\noexpand\fi}}
\def\Expression#1{%
  \Secondary{\ExpressionX{#1}}}
\def\ExpressionX#1#2#3{%
  \if0\ifx|#31\else\ifx,#31\fi\fi0
    \expandafter\@firstoftwo\else
    \expandafter\@secondoftwo\fi
  {#1{#2}#3}%
  {\Expression{\ExpressionXX{#1}{#2}}}%
  }
\def\ExpressionXX#1#2#3{%
  #1{\noexpand\if1#21\noexpand\else#3\noexpand\fi}}
\def\StopParse#1#2{%
  \ifx>#2 \else\errmessage{Error in expression: spurious #2}\fi
  \edef\Expr##1{#1}}
\def\Evaluate#1{%
  \Expression\StopParse#1>}
\def\normalLine#1\endLine{%
  \advance\codeLinesPassed\@ne
  \maybeMsg{.}%
  \def\inLine{#1}%
  \let\do\putline@do
  \activefiles
  }
\def\putline@do#1#2#3{%
  \StreamPut#1{\inLine}}
\def\removeComment#1\endLine{%
    \advance\commentsRemoved\@ne
    \maybeMsg{\perCent}}
\def\putMetaComment#1\endLine{%
  \advance\commentsPassed\@ne
  \let\do\putline@do
  \outputfiles
  }
\begingroup
\catcode`\%=12 \catcode`\*=14
\gdef\processLine#1{*
  \advance\processedLines\@ne
  \ifx%#1
    \expandafter\processLineX
  \else
    \expandafter\normalLine
  \fi
  #1}
\endgroup
\begingroup
\catcode`\%=12 \catcode`\*=14
\gdef\processLineX%#1{*
  \ifcase\ifx%#10\else
         \ifx<#11\else 2\fi\fi\relax
    \expandafter\putMetaComment\or
    \expandafter\checkOption\or
    \expandafter\removeComment\fi
  #1}
\endgroup
\def\checkOption<#1{%
  \ifcase
    \ifx*#10\else \ifx/#11\else
    \ifx+#12\else \ifx-#13\else 4\fi\fi\fi\fi\relax
  \expandafter\starOption\or
  \expandafter\slashOption\or
  \expandafter\plusOption\or
  \expandafter\minusOption\or
  \expandafter\doOption\fi
  #1}
\def\doOption#1>#2\endLine{%
  \maybeMsg{<#1 . >}%
  \Evaluate{#1}%
  \def\do##1##2##3{%
    \if1\Expr{##2}\StreamPut##1{#2}\fi
    }%
  \activefiles
  }
\def\plusOption+#1>#2\endLine{%
  \maybeMsg{<+#1 . >}%
  \Evaluate{#1}%
  \def\do##1##2##3{%
    \if1\Expr{##2}\StreamPut##1{#2}\fi
    }%
  \activefiles
  }
\def\minusOption-#1>#2\endLine{%
  \maybeMsg{<-#1 . >}%
  \Evaluate{#1}%
  \def\do##1##2##3{%
    \if1\Expr{##2}\else \StreamPut##1{#2}\fi
    }%
  \activefiles
  }
\def\starOption*#1>#2\endLine{%
  \maybeMsg{<*#1}%
  \expandafter\push\expandafter\guardStack\expandafter{\blockHead}%
  \advance\blockLevel\@ne
  \def\blockHead{#1}%
  \Evaluate{#1}%
  \let\do\checkguard@do
  \outputfiles
  \let\do\findactive@do
  \edef\activefiles{\activefiles}
  }
\def\checkguard@do#1#2#3{%
  \ifnum#3>0
    \advance#3\@ne
  \else
    \if1\Expr{#2}\else
      \advance#3\@ne\fi
  \fi}
\def\findactive@do#1#2#3{%
  \ifnum#3=0
    \noexpand\do#1{#2}#3\fi}
\def\slashOption/#1>#2\endLine{%
  \def\tmp{#1}%
  \ifnum\blockLevel<\@ne
    \errmessage{Spurious end block </\tmp> ignored}%
  \else
    \ifx\tmp\blockHead
      \pop\guardStack\blockHead
    \else
      \errmessage{Found </\tmp> instead of </\blockHead>}%
    \fi
    \maybeMsg{>}%
    \advance\blockLevel\m@ne
  \let\do\closeguard@do
  \outputfiles
  \let\do\findactive@do
  \edef\activefiles{\outputfiles}
  \fi
  }
\def\closeguard@do#1#2#3{%
  \ifnum#3>0
    \advance#3\m@ne
  \fi}
\def\generate#1{\begingroup
  \let\inputfiles\empty \let\filestogenerate\empty
  \let\file\@file
  #1
  \Msg{^^JGenerating file(s) \filestogenerate}%
  \inputfiles
  \endgroup}
\def\file#1#2{\errmessage{Command `\string\file' only allowed in
                          argument to `\string\generate'}}
\def\@file#1{%
  \Generatetrue
  \ifaskforoverwrite
    \immediate\openin\inFile\WriteToDir#1\relax
    \ifeof\inFile\else
      \Ask\answer{File \WriteToDir#1 already exists
                  \ifx\empty\WriteToDir somewhere \fi
                  on the system.^^J%
                  Overwrite it%
                  \ifx\empty\WriteToDir\space if necessary\fi
                  ? [y/n]}%
      \ifx\y  \answer \else
      \ifx\yes\answer \else
                      \Generatefalse\fi\fi\fi
    \immediate\closein\inFile
  \fi
  \ifGenerate
  \@addto\filestogenerate{\WriteToDir#1 }%
  \Name\@fileX{#1\expandafter}%
  \else
    \Msg{Not generating file #1^^J}%
  \expandafter\@gobble
  \fi
  }
\ifx\@currdir\@undefined
  \def\WriteToDir{}
\else
  \let\WriteToDir\@currdir
\fi
\def\@fileX#1#2{%
  \chardef#1=16
  \def\curout{#1}\let\curinfiles\empty
  \edef\curpre{\Name\noexpand{pre@\@stripstring#1}}
  \edef\curinnames{\Name\noexpand{in@\@stripstring#1}}
  \expandafter\def\curpre{\DoubleperCent ^^J%
                  \DoubleperCent The original source files were:^^J%
                  \DoubleperCent ^^J}%
  \expandafter\def\curinnames{}
  \let\from\@from \let\needed\@needed
  #2%
  \let\from\err@from \let\needed\err@needed
  \checkorder
  \Name\@addto{e@\curin}{\noexpand\closeoutput{#1}}%
  \expandafter\@addto\curpre{\expandafter\noexpand\currentpreamble}
  \Name\let{post@\@stripstring#1\expandafter}\currentpostamble
  }
\def\checkorder{%
  \expandafter\expandafter\expandafter
  \checkorderX\expandafter\curinfiles
  \expandafter\qStop\inputfiles\qStop
  }
\def\checkorderX(#1)#2\qStop#3\qStop{%
  \def\tmp##1\readsource(#1)##2\qStop{%
    \ifx!##2! \order@error
    \else\ifx!#2!\else
       \checkorderXX##2%
    \fi\fi}%
  \def\checkorderXX##1\readsource(#1)\fi\fi{\fi\fi
    \checkorderX#2\qStop##1\qStop}%
  \tmp#3\readsource(#1)\qStop
  }
\def\order@error#1\fi\fi{\fi
  \errmessage{DOCSTRIP error: Incompatible order of input
              files specified for file
              `\iden{\expandafter\uptospace\curin} \qStop'.^^J
              Read DOCSTRIP documentation for explanation.^^J
              This is a serious problem, I'm exiting}\end
  }
\def\needed#1{\errmessage{\string\needed\space can only be used in
               argument to \string\file}}
\let\err@needed\needed
\def\@needed#1{%
  \@ifpresent{(#1)}\curinfiles
    {\@needed{#1 }}%
    {\@ifpresent{\readsource(#1)}\inputfiles
       {}{\@addto\inputfiles{\noexpand\readsource(#1)}%
       \Name\let{o@#1}\empty\Name\let{e@#1}\empty}%
     \@addto\curinfiles{(#1)}%
     \def\curin{#1}}%
  }
\def\from#1#2{\errmessage{Command `\string\from' only allowed in
                          argument to `\string\file'}}
\let\err@from\from
\def\@from#1#2{%
  \expandafter\@addto\curpre{\DoubleperCent #1 \if>#2>\else
                              \space (with options: `#2')\fi^^J}%
  \expandafter\@addto\curinnames{ #1}%
  \needed{#1}%
  \Name\@addto{o@\curin}{\noexpand\do\curout{#2}}
  }
\def\readsource(#1){%
  \expandafter\let\expandafter\outputfiles\csname o@#1\endcsname
  \Msg{} \def\@msg{Processing file \uptospace#1 \qStop}
  \def\change@msg{%
    \edef\@msg{\@spaces\@spaces\@spaces\space
      \expandafter\tospaces\uptospace#1 \qStop\secapsot}
    \let\change@msg\relax}
  \def\do##1##2{%
    \Msg{\@msg
         \ifx>##2>\else\space(##2)\fi
         \space -> \@stripstring##1}
    \change@msg}%
  \outputfiles
  \immediate\openin\inFile\uptospace#1 \qStop\relax
  \ifeof\inFile
    \errmessage{Cannot find file \uptospace#1 \qStop}%
  \else
    \processedLines\z@
    \commentsRemoved\z@
    \commentsPassed\z@
    \codeLinesPassed\z@
    \let\do\ensureopen@do
    \outputfiles
    \let\do\makeoutlist@do
    \edef\outputfiles{\outputfiles}%
    \let\activefiles\outputfiles
    \makeOther\ \makeOther\\\makeOther\$%
    \makeOther\#\makeOther\^\makeOther\^^K%
    \makeOther\_\makeOther\^^A\makeOther\%%
    \makeOther\~\makeOther\{\makeOther\}\makeOther\&%
    \endlinechar-1\relax
    \loop
      \read\inFile to\inLine
      \ifx\inLine\Endinput
        \Msg{File #1 ended by \string\endinput.}%
        \Continuefalse
      \else
       \ifeof\inFile
         \Continuefalse
       \else
         \Continuetrue
         \ifx\inLine\empty
            \advance\emptyLines\@ne
          \else
            \emptyLines\z@
          \fi
          \ifnum \emptyLines<2
            \expandafter\processLine\inLine\endLine
          \else
            \maybeMsg{/}%
          \fi
       \fi
      \fi
    \ifContinue
    \repeat
    \immediate\closein\inFile
  \csname e@#1\endcsname
    \Msg{Lines \space processed: \the\processedLines^^J%
         Comments removed: \the\commentsRemoved^^J%
         Comments \space passed: \the\commentsPassed^^J%
         Codelines passed: \the\codeLinesPassed^^J}%
      \global\advance\TotalprocessedLines  by \processedLines
      \global\advance\TotalcommentsRemoved by \commentsRemoved
      \global\advance\TotalcommentsPassed  by \commentsPassed
      \global\advance\TotalcodeLinesPassed by \codeLinesPassed
      \global\advance\NumberOfFiles by \@ne
    \fi}
\def\ensureopen@do#1#2{%
  \ifnum#1=16
    \StreamOpen#1%
    \WritePreamble#1%
    \fi
  \csname off@\number#1\endcsname=0
  }
\def\makeoutlist@do#1#2{%
  \noexpand\do#1{#2}\csname off@\number#1\endcsname}
\def\closeoutput#1{%
  \WritePostamble#1%
  \StreamClose#1%
  }
\def\declarepreamble#1{\begingroup
    \def\tmp{\par}%
    \def\Endpreamble{\endpreamble}%
    \let\inFileName\relax \let\outFileName\relax
    \Continuetrue
    \global\let#1\empty
    \loop
        \read\currbatchFile to \batchLine
        \ifx\batchLine\Endpreamble \Continuefalse
        \else
              {\globaldefs1
              \@addto#1{%
                \ifx#1\empty\else^^J\fi
                \DoubleperCent
                \ifx\batchLine\tmp\else\batchLine\fi}}%
        \fi
    \ifContinue\repeat
    \endgroup}
\def\declarepostamble#1{\begingroup
    \Continuetrue
    \def\Endpostamble{\endpostamble}%
    \def\tmp{\par}%
    \let\inFileName\relax \let\outFileName\relax
    \global\let#1\empty
    \loop
        \read\currbatchFile to \batchLine
        \ifx\batchLine\Endpostamble \Continuefalse
        \else
            {\globaldefs1
            \@addto#1{%
               \ifx#1\empty\else^^J\fi
               \DoubleperCent
               \ifx\batchLine\tmp\else\batchLine\fi}}%
        \fi
    \ifContinue\repeat
    \endgroup}
\def\usepreamble#1{\def\currentpreamble{#1}}
\def\usepostamble#1{\def\currentpostamble{#1}}
\def\preamble{\usepreamble\defaultpreamble
  \declarepreamble\defaultpreamble}
\def\postamble{\usepostamble\defaultpostamble
  \declarepostamble\defaultpostamble}
\def\defaultpreamble{%
     \DoubleperCent ^^J%
     \DoubleperCent IMPORTANT NOTICE:^^J%
     \DoubleperCent ^^J%
     \DoubleperCent For the copyright see the source file.^^J%
     \DoubleperCent ^^J%
     \DoubleperCent You are *not* allowed to modify this file.^^J%
     \DoubleperCent ^^J%
     \DoubleperCent You are *not* allowed to distribute this file.^^J%
     \DoubleperCent For distribution of the original source see^^J%
     \DoubleperCent the terms for copying and modification
                       in the file \inFileName.^^J%
     \DoubleperCent}
\def\defaultpostamble{\string\endinput}
\usepreamble\defaultpreamble
\usepostamble\defaultpostamble
\def\WritePreamble#1{%
    \edef\outFileName{\@stripstring#1}%
    \edef\inFileName{\csname in@\outFileName\endcsname}%
    \StreamPut#1{%
        \DoubleperCent ^^J%
        \DoubleperCent This is file `\outFileName',^^J%
        \DoubleperCent  generated with the docstrip utility.%
             }%
    \StreamPut#1{\csname pre@\@stripstring#1\endcsname}}
\def\AddGenerationDate{%
\def\WritePreamble##1{%
    \edef\outFileName{\@stripstring##1}%
    \edef\inFileName{\csname in@\outFileName\endcsname}%
    \StreamPut##1{%
        \DoubleperCent ^^J%
        \DoubleperCent This is file `\outFileName', generated %
                        on <\the\year/\the\month/\the\day> ^^J%
        \DoubleperCent with the docstrip utility (\fileversion).%
             }%
    \StreamPut##1{\csname pre@\@stripstring##1\endcsname}}}
\def\WritePostamble#1{%
    \edef\outFileName{\@stripstring#1}%
    \edef\inFileName{\csname in@\outFileName\endcsname}%
    \StreamPut#1{\csname post@\@stripstring#1\endcsname}%
    \StreamPut#1{\DoubleperCent ^^J%
              \DoubleperCent End of file `\outFileName'.}}
\def\generateFile#1#2#3{{
  \ifx t#2\askforoverwritetrue
  \else\askforoverwritefalse\fi
  \generate{\file{#1}{#3}}%
  }}
\def\include#1{\def\Options{#1}}
\def\processFile#1#2#3#4{%
  \generateFile{#1.#3}{#4}{\from{#1.#2}{\Options}}}
\def\processfile{\Msg{%
    ^^Jplease use \string\processFile\space instead of
       \string\processfile!^^J}%
    \processFile}
\def\generatefile{\Msg{%
    ^^Jplease use \string\generateFile\space instead of
      \string\generatefile!^^J}%
    \generateFile}
\def\processbatchFile{%
    \ifx\undefined\batchfile
      \let\batchfile\DefaultbatchFile
      \Defaulttrue
    \else
      \Defaultfalse
    \fi
    \openin\currbatchFile \batchfile\relax
    \ifeof\currbatchFile
      \ifDefault
      \else
        \Msg{**************************************************^^J%
             * Could not find your \string\batchfile=\batchfile^^J%
             * Try to continue without it^^J%
             **************************************************}%
      \fi
    \else
      \ifDefault
        \Msg{**************************************************^^J%
             * Batchfile \DefaultbatchFile\space found Use it? (y/n)?}%
        \Ask\answer{%
             **************************************************}%
      \else
        \let\answer\y
      \fi
      \ifx\answer\y
        \Continuetrue
        \let\endinput\Continuefalse
        \loop
          \ifeof\currbatchFile
            \Continuefalse
          \else
            \read\currbatchFile to \batchLine
            \batchLine
          \fi
        \ifContinue \repeat
      \fi
    \fi}
\def\ReportTotals{%
  \ifnum\NumberOfFiles>\@ne
    \Msg{Overall statistics:^^J%
         Files \space processed: \the\NumberOfFiles^^J%
         Lines \space processed: \the\TotalprocessedLines^^J%
         Comments removed: \the\TotalcommentsRemoved^^J%
         Comments \space passed: \the\TotalcommentsPassed^^J%
         Codelines passed: \the\TotalcodeLinesPassed}%
  \fi}
\def\SetFileNames{%
    \edef\sourceFileName{\MainFileName.\infileext}%
    \edef\destFileName{\MainFileName.\outfileext}}
\def\CheckFileNames{%
    \ifx\sourceFileName\destFileName
      \Msg{^^J%
     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J%
     ! It is not possible to read from and write to the same file !^^J%
     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J}%
      \Continuefalse
    \else
      \Continuetrue
      \immediate\openin\inFile \sourceFileName\relax
      \ifeof\inFile
        \Msg{^^J%
              !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J%
              ! Your input file `\sourceFileName' was not found !^^J%
              !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J}%
        \Continuefalse
      \else
        \immediate\closein\inFile
        \immediate\openin\inFile\WriteToDir \destFileName\relax
        \ifeof\inFile
          \Continuetrue
        \else
          \Continuefalse
          \Ask\answer{File \WriteToDir\destFileName\space already
                      exists
                      \ifx\empty\WriteToDir somewhere \fi
                      on the system.^^J%
                      Overwrite it%
                      \ifx\empty\WriteToDir\space if necessary\fi
                      ? [y/n]}%
          \ifx\y  \answer \Continuetrue \else
          \ifx\yes\answer \Continuetrue \else
          \fi\fi
        \fi
      \fi
    \fi
    \immediate\closein\inFile}
\def\interactive{%
  \whileswitch\ifMoreFiles\fi%
   {\begingroup
      \AskQuestions
      \forlist\MainFileName:=\filelist
      \do
        \SetFileNames
        \CheckFileNames
        \ifContinue
        \generateFile{\destFileName}{f}%
                     {\from{\sourceFileName}{\Options}}
        \fi%
      \od
    \endgroup
    \Ask\answer{More files to process (y/n)?}%
    \ifx\y  \answer\MoreFilestrue \else
    \ifx\yes\answer\MoreFilestrue \else
                   \MoreFilesfalse\fi\fi
   }}
\def\AskQuestions{%
    \Msg{^^J%
         ****************************************************}%
    \Ask\infileext{%
         * First type the extension of your input file(s): \space  *}%
    \Msg{****************************************************^^J^^J%
         ****************************************************}%
    \Ask\outfileext{%
         * Now type the extension of your output file(s) \space: *}%
    \Msg{****************************************************^^J^^J%
         ****************************************************}%
    \Ask\Options{%
       * Now type the name(s) of option(s) to include \space\space: *}%
    \Msg{****************************************************^^J^^J%
         ****************************************************^^J%
       * Finally give the list of input file(s) without \space\space*}%
    \Ask\filelist{%
         * extension seperated by commas if necessary %
                                  \space\space\space\space: *}%
    \Msg{****************************************************^^J}}%
\Msg{Utility: `docstrip' \fileversion\space <\filedate>^^J%
     English documentation \space\space\space <\docdate>}%
\Msg{^^J%
     **********************************************************^^J%
     * This program converts documented macro-files into fast *^^J%
     * loadable files by stripping off (nearly) all comments! *^^J%
     **********************************************************^^J}%
\processbatchFile
  \ifnum\NumberOfFiles=\z@
    \interactive
  \fi
\ReportTotals
\end
\endinput
%% 
%% End of file `docstrip.tex'.
