home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 3 / Meeting_Pearls_III.iso / Pearls / texmf / inputs / latex / unpacked / docstrip.tex < prev    next >
Text File  |  1995-06-21  |  24KB  |  737 lines

  1. %% 
  2. %% This is file `docstrip.tex', generated 
  3. %% on <1995/6/21> with the docstrip utility (2.2i).
  4. %% 
  5. %% The original source files were:
  6. %% 
  7. %% docstrip.dtx  (with options: `program,stats')
  8. %% 
  9. %% 
  10. %% This is a generated file. 
  11. %% 
  12. %% Copyright 1993-1995 the LaTeX3 project and any individual authors 
  13. %% listed elsewhere in this file. All rights reserved. 
  14. %% 
  15. %% For further copyright information see the file legal.txt, and any 
  16. %% other copyright notices in this file. 
  17. %% 
  18. %% This file is part of the LaTeX2e system. 
  19. %% ---------------------------------------- 
  20. %% This system is distributed in the hope that it will be useful, 
  21. %% but WITHOUT ANY WARRANTY; without even the implied warranty of 
  22. %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
  23. %% 
  24. %% For error reports concerning UNCHANGED versions of this file no more 
  25. %% than one year old, see bugs.txt. 
  26. %% 
  27. %% Please do not request updates from us directly. Primary 
  28. %% distribution is through the CTAN archives. 
  29. %% 
  30. %% 
  31. %% IMPORTANT COPYRIGHT NOTICE: 
  32. %% 
  33. %% You are NOT ALLOWED to distribute this file alone. 
  34. %% 
  35. %% You are allowed to distribute this file under the condition that it is 
  36. %% distributed together with all the files listed in manifest.txt. 
  37. %% 
  38. %% If you receive only some of these files from someone, complain! 
  39. %% 
  40. %% Permission is granted to copy this file to another file with a clearly 
  41. %% different name and to customize the declarations in that copy to serve 
  42. %% the needs of your installation, provided that you comply with 
  43. %% the conditions in the file legal.txt. 
  44. %% 
  45. %% However, NO PERMISSION is granted to generate or to distribute a 
  46. %% modified version of this file under its original name. 
  47. %% 
  48. %% You are NOT ALLOWED to change this file. 
  49. %% 
  50. %% 
  51. %% MODIFICATION ADVICE: 
  52. %% 
  53. %% If you want to customize this file, it is best to make a copy of the 
  54. %% source file(s) from which it was produced. Use a different name for 
  55. %% your copy(ies) and modify the copy(ies); this will ensure that your 
  56. %% modifications do not get overwritten when you install a new release of 
  57. %% the standard system. You should also ensure that your modified source 
  58. %% file does not generate any modified file with the same name as a 
  59. %% standard file. You can then easily distribute your modifications by 
  60. %% distributing the modified and renamed copy of the source file, taking 
  61. %% care to observe the conditions in legal.txt; this will ensure that 
  62. %% other users can safely use your modifications. 
  63. %% 
  64. %% You will also need to produce your own, suitably named, .ins file to 
  65. %% control the generation of files from your source file; this file 
  66. %% should contain your own preambles for the files it generates, not 
  67. %% those in the standard .ins files. 
  68. %% 
  69. %% The names of the source files used are shown above. 
  70. %% 
  71. %% 
  72. %% 
  73.  
  74. \def\filename{docstrip.dtx}
  75. \def\fileversion{2.2i}
  76. \def\filedate{1994/12/15}
  77. \def\docdate {1994/06/09}
  78.  
  79. %% \CharacterTable
  80. %%  {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
  81. %%   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
  82. %%   Digits        \0\1\2\3\4\5\6\7\8\9
  83. %%   Exclamation   \!     Double quote  \"     Hash (number) \#
  84. %%   Dollar        \$     Percent       \%     Ampersand     \&
  85. %%   Acute accent  \'     Left paren    \(     Right paren   \)
  86. %%   Asterisk      \*     Plus          \+     Comma         \,
  87. %%   Minus         \-     Point         \.     Solidus       \/
  88. %%   Colon         \:     Semicolon     \;     Less than     \<
  89. %%   Equals        \=     Greater than  \>     Question mark \?
  90. %%   Commercial at \@     Left bracket  \[     Backslash     \\
  91. %%   Right bracket \]     Circumflex    \^     Underscore    \_
  92. %%   Grave accent  \`     Left brace    \{     Vertical bar  \|
  93. %%   Right brace   \}     Tilde         \~}
  94. %%
  95. %% The docstrip program for use with TeX.
  96. %% Copyright (C) 1989-1991 Frank Mittelbach
  97. %% Copyright (C) 1992-1994 Johannes Braams, Denys Duchier,
  98. %%                         Frank Mittelbach
  99. %% All rights are reserved.
  100. %%
  101. \catcode`\@=11
  102. \newlinechar=`\^^J
  103. \newtoks\TerminalString
  104. \newif\ifOff
  105. \newif\ifGenerate
  106. \newif\ifContinue
  107. \newif\ifTerminal
  108. \newif\ifForlist
  109. \newif\ifDefault
  110. \newif\ifMoreFiles \MoreFilestrue
  111. \newcount\blockLevel \blockLevel\z@
  112. \newcount\offLevel \offLevel \z@
  113. \newcount\emptyLines \emptyLines \z@
  114. \newcount\processedLines   \processedLines  \z@
  115. \newcount\commentsRemoved  \commentsRemoved \z@
  116. \newcount\commentsPassed   \commentsPassed  \z@
  117. \newcount\codeLinesPassed  \codeLinesPassed \z@
  118. \newcount\NumberOfFiles \NumberOfFiles\z@
  119. \newcount\TotalprocessedLines   \TotalprocessedLines  \z@
  120. \newcount\TotalcommentsRemoved  \TotalcommentsRemoved \z@
  121. \newcount\TotalcommentsPassed   \TotalcommentsPassed  \z@
  122. \newcount\TotalcodeLinesPassed  \TotalcodeLinesPassed \z@
  123. \newread\inFile
  124. \newwrite\outFile
  125. \newread\ttyin
  126. \newwrite\ttyout
  127. \newread\@tempa
  128. \let\lowestbatchFile\@tempa
  129. \newread\@tempa \newread\@tempa \newread\@tempa \newread\@tempa
  130. \newread\@tempa \newread\@tempa \newread\@tempa \newread\@tempa
  131. \newread\@tempa
  132. \let\highestbatchFile\@tempa
  133. \newcount\currbatchFile
  134. \currbatchFile=\highestbatchFile
  135. \advance\currbatchFile by -9
  136. \def\ifToplevel{\relax\ifnum\currbatchFile=\lowestbatchFile
  137.    \expandafter\iden \else \expandafter\gobble\fi}
  138. \ifx\undefined\@@input \let\@@input\input\fi
  139. \def\batchinput#1{%
  140.    \begingroup
  141.      \def\batchfile{#1}%
  142.      \advance\currbatchFile\@ne
  143.      \ifnum\currbatchFile>\highestbatchFile
  144.         \errhelp{Only up to ten levels of nesting for
  145.                  \noexpand\batchinput commands are supported}%
  146.         \errmessage{Batchfiles too deeply nested}%
  147.      \fi
  148.      \processbatchFile
  149.    \endgroup
  150. }
  151. \def\skip@input#1 {}
  152. \let\input\skip@input
  153. \def\guardStack{}
  154. \def\blockHead{}
  155. \def\Options{}
  156. \def\lastOption{}
  157. \def\TrueExpression{TT}
  158. \def\FalseExpression{TF}
  159. \def\yes{yes}
  160. \def\y{y}
  161. \def\n{n}
  162. \def\DefaultbatchFile{docstrip.cmd}
  163. {\catcode`\%=12
  164.  \gdef\perCent{%}
  165.  \gdef\DoubleperCent{%% }
  166. }
  167. \def^^L{ }
  168. \def\eltStart{}
  169. \def\eltEnd{}
  170. \def\qStop{\qStop}
  171. \def\pop#1#2{%
  172.   \ifx#1\empty
  173.     \Msg{Warning: Found end guard without matching begin}%
  174.     \let#2\empty
  175.   \else
  176.     \def\tmp{\expandafter\popX #1\qStop #1#2}%
  177.     \expandafter\tmp\fi}
  178. \def\popX\eltStart #1\eltEnd #2\qStop #3#4{\def#3{#2}\def#4{#1}}
  179. \def\push#1#2{\expandafter\pushX #1\qStop #1{\eltStart #2\eltEnd}}
  180. \def\pushX #1\qStop #2#3{\def #2{#3#1}}
  181. \def\forlist#1:=#2\do#3\od{%
  182.     \edef\ListCondition{#2}%
  183.     \Forlisttrue
  184.     \loop
  185.       \edef#1{\expandafter\FirstElt\ListCondition,\empty.}%
  186.       \edef\ListCondition{\expandafter\OtherElts\ListCondition,\empty.}%
  187.       \ifx#1\empty \Forlistfalse \else#3\fi
  188.       \ifForlist
  189.     \repeat}
  190. \def\FirstElt#1,#2.{#1}
  191. \def\OtherElts#1,#2.{#2}
  192. \def\whileswitch#1\fi#2{#1\loop#2#1\repeat\fi}
  193. \def\showprogress{\let\maybeMsg\message}
  194. \def\keepsilent{\let\maybeMsg\gobble}
  195. \showprogress
  196. \def\Msg{\immediate\write\ttyout}
  197. \def\iden#1{#1}
  198. \def\strip#1#2 \gobble{\def #1{#2}}
  199. \def\@defpar{\par}
  200. \def\Ask#1#2{%
  201.     \message{#2}\read\ttyin to #1\ifx#1\@defpar\def#1{}\else
  202.     \iden{\expandafter\strip\expandafter#1#1\gobble\gobble} \gobble\fi}
  203. \def\WriteOut#1{\maybeMsg{.}\immediate\write\outFile{#1}}
  204. \def\OffStart{\Offtrue\advance\offLevel\@ne}
  205. \def\OffEnd{%
  206.     \advance\offLevel\m@ne
  207.     \ifnum\offLevel=\z@
  208.       \Offfalse
  209.     \fi}
  210. \def\gobble#1{}
  211. \edef\Endinput{\expandafter\gobble\string\\endinput}
  212. \def\makeOther#1{\catcode`#1=12\relax}
  213. \ifx\undefined\@@end\else\let\end\@@end\fi
  214. \def\PropagateValue#1\qStop{%
  215.   \edef\ExpressionValue{#1}}
  216. \def\ContinueExpression#1{%
  217.   \if\ExpressionValue
  218.   \else
  219.     \def\ExpressionValue{#1}%
  220.   \fi
  221.   \futurelet\nextToken\ContinueExpressionX}
  222. \def\ContinueExpressionX{%
  223.   \ifx|\nextToken
  224.     \def\doNext|{\Primary}%
  225.   \else
  226.     \ifx,\nextToken
  227.       \def\doNext,{\Primary}%
  228.     \else
  229.       \edef\doNext){\endgroup\noexpand\PropagateValue{\ExpressionValue}}
  230.     \fi
  231.   \fi
  232.   \doNext}
  233. \def\ContinuePrimary#1{%
  234.   \if\ExpressionValue
  235.     \def\ExpressionValue{#1}%
  236.   \fi
  237.   \futurelet\nextToken\ContinuePrimaryX}
  238. {\catcode`\&=12
  239. \gdef\ContinuePrimaryX{%
  240.   \ifx&\nextToken
  241.     \def\doNext&{\Secondary}%
  242.   \else
  243.     \edef\doNext{\endgroup\noexpand\PropagateValue{\ExpressionValue}}%
  244.   \fi
  245.   \doNext}}
  246. \def\PropagateNegatedValue#1{%
  247.   \edef\doNext{\endgroup
  248.     \noexpand\PropagateValue
  249.     {\if#1%
  250.        \noexpand\FalseExpression
  251.      \else
  252.        \noexpand\TrueExpression
  253.      \fi}}%
  254.   \doNext}
  255. \def\Evaluate#1{%
  256.   \Expression(#1)\qStop}
  257. \def\Expression({%
  258.   \begingroup
  259.     \let\ExpressionValue\FalseExpression
  260.     \let\PropagateValue\ContinueExpression
  261.     \Primary}
  262. \def\Primary{%
  263.   \begingroup
  264.     \let\ExpressionValue\TrueExpression
  265.     \let\PropagateValue\ContinuePrimary
  266.     \Secondary}
  267. \def\Secondary{%
  268.   \futurelet\nextToken\SecondaryX}
  269. \def\SecondaryX{%
  270.   \ifx\nextToken(\let\doNext\Expression\else
  271.   \ifx\nextToken!\let\doNext\Negate\else
  272.                  \let\doNext\Terminal\fi\fi
  273.   \doNext}
  274. \def\Negate!{%
  275.   \begingroup
  276.     \let\PropagateValue\PropagateNegatedValue
  277.     \Secondary}
  278. \def\Terminal{%
  279.   \global\TerminalString{}\TerminalX}
  280. \def\TerminalX#1{%
  281.   \global\TerminalString\expandafter{\the\TerminalString#1}%
  282.   \futurelet\nextToken\TerminalXX}
  283. {\catcode`\&=12
  284. \gdef\TerminalXX{%
  285.   \Terminalfalse
  286.   \ifx &\nextToken \else
  287.   \ifx |\nextToken \else
  288.   \ifx ,\nextToken \else
  289.   \ifx !\nextToken \else
  290.   \ifx (\nextToken \else
  291.   \ifx )\nextToken \else
  292.     \Terminaltrue
  293.   \fi\fi\fi\fi\fi\fi
  294.   \ifTerminal
  295.     \let\doNext\TerminalX
  296.   \else
  297.     \edef\doNext{\noexpand\SetValue{\the\TerminalString}}%
  298.     \global\TerminalString{}%
  299.   \fi
  300.   \doNext}
  301. }
  302. \def\SetValue#1{%
  303.   \def\tmp##1,#1,##2\qStop{%
  304.     \def\tmp{##2}%
  305.     \edef\doNext{\noexpand\PropagateValue
  306.       {\ifx\tmp\empty\FalseExpression\else\TrueExpression\fi}}%
  307.     \doNext}%
  308.   \expandafter\tmp\expandafter,\Options,#1,\qStop}
  309. \def\copyLine#1\endLine{%
  310.   \advance\codeLinesPassed\@ne
  311.   \WriteOut{#1}}
  312. \def\removeLine#1\endLine{%
  313.     \maybeMsg{\perCent}}
  314. \def\removeComment#1\endLine{%
  315.     \advance\commentsRemoved\@ne
  316.     \maybeMsg{\perCent}}
  317. \def\putMetaComment#1\endLine{%
  318.   \closeOption%
  319.   \advance\commentsPassed\@ne
  320.   \WriteOut{\inLine}}
  321. \def\processLine{%
  322.   \advance\processedLines\@ne
  323.   \futurelet\nextToken\processLineX}
  324. \begingroup
  325. \catcode`\%=12 \catcode`\#=14
  326. \gdef\processLineX{#
  327.   \ifx%\nextToken
  328.     \let\doNext\processLineXX
  329.   \else
  330.     \closeOption
  331.     \ifOff
  332.       \let\doNext\removeLine
  333.     \else
  334.       \let\doNext\copyLine
  335.     \fi
  336.   \fi
  337.   \doNext}
  338. \endgroup
  339. \def\processLineXX#1{%
  340.   \futurelet\nextToken\processLineXXX}
  341. \begingroup
  342. \catcode`\%=12 \catcode`\#=14
  343. \gdef\processLineXXX{#
  344.   \ifx%\nextToken \let\doNext\putMetaComment \else
  345.   \ifx<\nextToken \let\doNext\checkOption    \else
  346.              \closeOption
  347.              \let\doNext\removeComment  \fi\fi
  348.   \doNext}
  349. \endgroup
  350. \def\checkOption<{%
  351.   \futurelet\nextToken\checkOptionsX}
  352. \def\checkOptionsX{%
  353.   \ifx*\nextToken \let\doNext\starOption  \else
  354.   \ifx/\nextToken \let\doNext\slashOption \else
  355.   \ifOff          \let\doNext\removeLine  \else
  356.   \ifx+\nextToken \let\doNext\plusOption  \else
  357.   \ifx-\nextToken \let\doNext\minusOption \else
  358.                   \let\doNext\doOption    \fi\fi\fi\fi\fi
  359.   \doNext}
  360. \def\closeOption{%
  361.   \ifx\lastOption\empty\else
  362.     \maybeMsg{>}\let\lastOption\empty\fi}
  363. \def\doOption#1>{%
  364.   \testOption{}{#1}%
  365.   \if\ExpressionValue \expandafter\copyLine
  366.   \else         \expandafter\removeLine \fi}
  367. \def\plusOption+#1>{%
  368.   \testOption+{#1}%
  369.   \if\ExpressionValue \expandafter\copyLine
  370.   \else         \expandafter\removeLine \fi}
  371. \def\minusOption-#1>{%
  372.   \testOption-{#1}%
  373.   \if\ExpressionValue \expandafter\removeLine
  374.   \else         \expandafter\copyLine \fi}
  375. \def\starOption*#1>{%
  376.   \closeOption
  377.   \maybeMsg{<*#1}%
  378.   \expandafter\push\expandafter\guardStack\expandafter{\blockHead}%
  379.   \advance\blockLevel\@ne
  380.   \def\blockHead{#1}%
  381.   \ifOff
  382.     \advance\offLevel\@ne
  383.   \else
  384.     \Evaluate{#1}%
  385.     \if\ExpressionValue\else\OffStart\fi
  386.   \fi
  387.   \removeLine}
  388. \def\slashOption/#1>{%
  389.   \def\tmp{#1}%
  390.   \ifnum\blockLevel<\@ne
  391.     \errmessage{Spurious end block </\tmp> ignored}%
  392.   \else
  393.     \ifx\tmp\blockHead
  394.       \pop\guardStack\blockHead
  395.     \else
  396.       \errmessage{Found </\tmp> instead of <*\blockHead>}%
  397.     \fi
  398.     \maybeMsg{>}%
  399.     \advance\blockLevel\m@ne
  400.     \ifOff\OffEnd\fi
  401.   \fi
  402.   \removeLine}
  403. \def\testOption#1#2{%
  404.   \def\tmp{#2}%
  405.   \ifx\tmp\empty
  406.     \errmessage{Missing option expression!}%
  407.     \def\tmp{MISSING OPTION}%
  408.   \else
  409.     \def\tmp{<#1#2}%
  410.   \fi
  411.   \ifx\tmp\lastOption
  412.   \else
  413.     \closeOption
  414.     \let\lastOption\tmp
  415.     \maybeMsg{\lastOption}%
  416.     \Evaluate{#2}%
  417.   \fi}
  418. \def\generateFile#1#2#3{{%
  419.   \Msg{^^JGenerating file \WriteToDir#1^^J}%
  420.   \Generatetrue
  421.   \def\tmp{#2}\def\t{t}%
  422.   \ifx\tmp\t
  423.     \immediate\openin\inFile\WriteToDir#1\relax
  424.     \ifeof\inFile\else
  425.       \Ask\answer{File \WriteToDir#1 already exists
  426.                   \ifx\@empty\WriteToDir somewhere \fi
  427.                   on the system.^^J%
  428.                   Overwrite it%
  429.                   \ifx\@empty\WriteToDir\space if necessary\fi
  430.                   ? [y/n]}%
  431.       \ifx\y  \answer \Generatetrue \else
  432.       \ifx\yes\answer \Generatetrue \else
  433.                       \Generatefalse\fi\fi\fi
  434.     \immediate\closein\inFile
  435.   \fi
  436.   \ifGenerate
  437.     \def\outFileName{#1}%
  438.     \def\from##1##2{\WriteOut{\DoubleperCent ##1 \if>##2>\else
  439.                               \space (with options: `##2')\fi}}%
  440.     \edef\ReferenceLines{%
  441.         \WriteOut{\DoubleperCent ^^J%
  442.                   \DoubleperCent The original source files were:^^J%
  443.                   \DoubleperCent }%
  444.         #3}%
  445.     \def\from##1##2{\edef\inFileName{\inFileName##1\space}}
  446.     \def\inFileName{}#3
  447.     \def\from##1##2{\def\inFileName{##1}%
  448.                     \edef\Options{##2}%
  449.                     \generateFileX}%
  450.     \immediate\openout\outFile\WriteToDir#1\relax
  451.     \WritePreamble
  452.     #3%
  453.     \WritePostamble
  454.     \immediate\closeout\outFile
  455.     \let\ReferenceLines\OriginalRefs
  456.   \else
  457.     \Msg{Not generating file #1^^J}%
  458.   \fi}}
  459. \ifx\@currdir\@undefined
  460.   \def\WriteToDir{}
  461. \else
  462.   \let\WriteToDir\@currdir
  463. \fi
  464. \def\include#1{\def\Options{#1}}
  465. \def\processFile#1#2#3#4{%
  466.   \generateFile{#1.#3}{#4}{\from{#1.#2}{\Options}}}
  467. \def\processfile{\Msg{%
  468.     ^^Jplease use \string\processFile\space instead of
  469.        \string\processfile!^^J}%
  470.     \processFile}
  471. \def\generatefile{\Msg{%
  472.     ^^Jplease use \string\generateFile\space instead of
  473.       \string\generatefile!^^J}%
  474.     \generateFile}
  475. \def\generateFileX{{%
  476.   \Msg{Processing File \inFileName
  477.        \ifx\Options\empty\else\space(\Options)\fi
  478.        \space -> \outFileName^^J}%
  479.   \immediate\openin\inFile\inFileName\relax
  480.   \ifeof\inFile
  481.     \errmessage{Cannot find file \inFileName}%
  482.   \else
  483.     \makeOther\ \makeOther\\\makeOther\$%
  484.     \makeOther\#\makeOther\^\makeOther\^^K%
  485.     \makeOther\_\makeOther\^^A\makeOther\%%
  486.     \makeOther\~\makeOther\{\makeOther\}\makeOther\&%
  487.     \endlinechar-1\relax
  488.     \loop
  489.       \read\inFile to\inLine
  490.       \ifx\inLine\Endinput
  491.         \Msg{File \inFileName\space ended by \string\endinput.}%
  492.         \Continuefalse
  493.       \else
  494.        \ifeof\inFile
  495.          \Continuefalse
  496.        \else
  497.          \Continuetrue
  498.          \ifx\inLine\empty
  499.             \advance\emptyLines\@ne
  500.           \else
  501.             \emptyLines\z@
  502.           \fi
  503.           \ifnum \emptyLines<2
  504.             \expandafter\processLine\inLine\endLine
  505.           \else
  506.             \maybeMsg{/}%
  507.           \fi
  508.        \fi
  509.       \fi
  510.     \ifContinue
  511.     \repeat
  512.     \closeOption
  513.     \immediate\closein\inFile
  514.     \Msg{Lines \space processed: \the\processedLines^^J%
  515.          Comments removed: \the\commentsRemoved^^J%
  516.          Comments \space passed: \the\commentsPassed^^J%
  517.          Codelines passed: \the\codeLinesPassed^^J}%
  518.       \global\advance\TotalprocessedLines  by \processedLines
  519.       \global\advance\TotalcommentsRemoved by \commentsRemoved
  520.       \global\advance\TotalcommentsPassed  by \commentsPassed
  521.       \global\advance\TotalcodeLinesPassed by \codeLinesPassed
  522.       \global\advance\NumberOfFiles by \@ne
  523.     \fi}}
  524. \def\WritePreamble{%
  525.     \WriteOut{%
  526.         \DoubleperCent ^^J%
  527.         \DoubleperCent This is file `\outFileName', generated %
  528.                         on <\the\year/\the\month/\the\day> ^^J%
  529.         \DoubleperCent with the docstrip utility (\fileversion).%
  530.              }%
  531.     \ReferenceLines
  532.     \WriteOut{%
  533.         \DoubleperCent ^^J%
  534.         \DoubleperCent IMPORTANT NOTICE:^^J%
  535.         \DoubleperCent You are not allowed to distribute this file.^^J%
  536.         \DoubleperCent For distribution of the original source see^^J%
  537.         \DoubleperCent the copyright notice in the file \inFileName.^^J%
  538.         \DoubleperCent }}
  539. \def\OriginalRefs{%
  540.     \WriteOut{\DoubleperCent }%
  541.     \WriteOut{\DoubleperCent The original source file was
  542.               `\inFileName'.}%
  543.     \ifx\Options\empty\else
  544.         \WriteOut{\DoubleperCent Included options: `\Options'.}\fi
  545.     \WriteOut{\DoubleperCent }}
  546. \let\ReferenceLines\OriginalRefs
  547. \def\WritePostamble{%
  548.     \WriteOut{\string\endinput}%
  549.     \WriteOut{\DoubleperCent ^^J%
  550.               \DoubleperCent End of file `\outFileName'.}}
  551. \def\preamble{\begingroup
  552.     \def\tmp{\par}%
  553.     \def\Endpreamble{\endpreamble}%
  554.     \Continuetrue
  555.     \let\inFileName\relax
  556.     \let\outFileName\relax
  557.     \let\ReferenceLines\relax
  558.     \gdef\WritePreamble{%
  559.         \WriteOut{\DoubleperCent ^^J%
  560.                   \DoubleperCent This is file `\outFileName',
  561.                                  generated ^^J%
  562.                   \DoubleperCent on <\the\year/\the\month/\the\day> with
  563.                                  the docstrip utility (\fileversion).}%
  564.         \ReferenceLines}%
  565.     \loop
  566.         \read\currbatchFile to \batchLine
  567.         \ifx\batchLine\Endpreamble \Continuefalse
  568.         \else
  569.             \xdef\WritePreamble{%
  570.                 \WritePreamble
  571.                 \WriteOut{\DoubleperCent
  572.                           \ifx\batchLine\tmp\else\batchLine\fi}}%
  573.         \fi
  574.     \ifContinue\repeat
  575.     \endgroup}
  576. \def\postamble{\begingroup
  577.     \Continuetrue
  578.     \def\Endpostamble{\endpostamble}%
  579.     \def\tmp{\par}%
  580.     \gdef\WritePostamble{}%
  581.     \loop
  582.         \read\currbatchFile to \batchLine
  583.         \ifx\batchLine\Endpostamble \Continuefalse
  584.         \else
  585.             \xdef\WritePostamble{%
  586.                \WritePostamble
  587.                \WriteOut{\DoubleperCent
  588.                          \ifx\batchLine\tmp\else\batchLine\fi}}%
  589.         \fi
  590.     \ifContinue\repeat
  591.     \endgroup}
  592. \def\processbatchFile{%
  593.     \ifx\undefined\batchfile
  594.       \let\batchfile\DefaultbatchFile
  595.       \Defaulttrue
  596.     \else
  597.       \Defaultfalse
  598.     \fi
  599.     \openin\currbatchFile \batchfile\relax
  600.     \ifeof\currbatchFile
  601.       \ifDefault
  602.       \else
  603.         \Msg{**************************************************^^J%
  604.              * Could not find your \string\batchfile=\batchfile^^J%
  605.              * Try to continue without it^^J%
  606.              **************************************************}%
  607.       \fi
  608.     \else
  609.       \ifDefault
  610.         \Msg{**************************************************^^J%
  611.              * Batchfile \DefaultbatchFile\space found Use it? (y/n)?}%
  612.         \Ask\answer{%
  613.              **************************************************}%
  614.       \else
  615.         \let\answer\y
  616.       \fi
  617.       \ifx\answer\y
  618.         \Continuetrue
  619.         \let\endinput\Continuefalse
  620.         \loop
  621.           \ifeof\currbatchFile
  622.             \Continuefalse
  623.           \else
  624.             \read\currbatchFile to \batchLine
  625.             \batchLine
  626.           \fi
  627.         \ifContinue \repeat
  628.       \fi
  629.     \fi}
  630. \def\ReportTotals{%
  631.   \ifnum\NumberOfFiles>\@ne
  632.     \Msg{Overall statistics:^^J%
  633.          Files \space processed: \the\NumberOfFiles^^J%
  634.          Lines \space processed: \the\TotalprocessedLines^^J%
  635.          Comments removed: \the\TotalcommentsRemoved^^J%
  636.          Comments \space passed: \the\TotalcommentsPassed^^J%
  637.          Codelines passed: \the\TotalcodeLinesPassed}%
  638.   \fi}
  639. \def\SetFileNames{%
  640.     \edef\inFileName{\MainFileName.\infileext}%
  641.     \edef\outFileName{\MainFileName.\outfileext}}
  642. \def\CheckFileNames{%
  643.     \ifx\inFileName\outFileName
  644.       \Msg{^^J%
  645.      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J%
  646.      ! It is not possible to read from and write to the same file !^^J%
  647.      !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J}%
  648.       \Continuefalse
  649.     \else
  650.       \Continuetrue
  651.       \immediate\openin\inFile \inFileName\relax
  652.       \ifeof\inFile
  653.         \Msg{^^J%
  654.               !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J%
  655.               ! Your input file `\inFileName' was not found !^^J%
  656.               !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J}%
  657.         \Continuefalse
  658.       \else
  659.         \immediate\closein\inFile
  660.         \immediate\openin\inFile\WriteToDir \outFileName\relax
  661.         \ifeof\inFile
  662.           \Continuetrue
  663.         \else
  664.           \Continuefalse
  665.           \Ask\answer{File \WriteToDir\outFileName\space already
  666.                       exists
  667.                       \ifx\@empty\WriteToDir somewhere \fi
  668.                       on the system.^^J%
  669.                       Overwrite it%
  670.                       \ifx\@empty\WriteToDir\space if necessary\fi
  671.                       ? [y/n]}%
  672.           \ifx\y  \answer \Continuetrue \else
  673.           \ifx\yes\answer \Continuetrue \else
  674.           \fi\fi
  675.         \fi
  676.       \fi
  677.     \fi
  678.     \immediate\closein\inFile}
  679. \def\interactive{%
  680.   \whileswitch\ifMoreFiles\fi%
  681.    {\begingroup
  682.       \AskQuestions
  683.       \forlist\MainFileName:=\filelist
  684.       \do
  685.         \SetFileNames
  686.         \CheckFileNames
  687.         \ifContinue
  688.           \immediate\openout\outFile\WriteToDir\outFileName\relax
  689.           \WritePreamble
  690.           \generateFileX
  691.           \WritePostamble
  692.           \immediate\closeout\outFile
  693.         \fi%
  694.       \od
  695.     \endgroup
  696.     \Ask\answer{More files to process (y/n)?}%
  697.     \ifx\y  \answer\MoreFilestrue \else
  698.     \ifx\yes\answer\MoreFilestrue \else
  699.                    \MoreFilesfalse\fi\fi
  700.    }}
  701. \def\AskQuestions{%
  702.     \Msg{^^J%
  703.          ****************************************************}%
  704.     \Ask\infileext{%
  705.          * First type the extension of your input file(s): \space  *}%
  706.     \Msg{****************************************************^^J^^J%
  707.          ****************************************************}%
  708.     \Ask\outfileext{%
  709.          * Now type the extension of your output file(s) \space: *}%
  710.     \Msg{****************************************************^^J^^J%
  711.          ****************************************************}%
  712.     \Ask\Options{%
  713.        * Now type the name(s) of option(s) to include \space\space: *}%
  714.     \Msg{****************************************************^^J^^J%
  715.          ****************************************************^^J%
  716.        * Finally give the list of input file(s) without \space\space*}%
  717.     \Ask\filelist{%
  718.          * extension seperated by commas if necessary %
  719.                                   \space\space\space\space: *}%
  720.     \Msg{****************************************************^^J}}%
  721. \Msg{Utility: `docstrip' \fileversion\space <\filedate>^^J%
  722.      English documentation \space\space\space <\docdate>}%
  723. \Msg{^^J%
  724.      **********************************************************^^J%
  725.      * This program converts documented macro-files into fast *^^J%
  726.      * loadable files by stripping off (nearly) all comments! *^^J%
  727.      **********************************************************^^J}%
  728. \processbatchFile
  729.   \ifnum\NumberOfFiles=\z@
  730.     \interactive
  731.   \fi
  732. \ReportTotals
  733. \end
  734. \endinput
  735. %% 
  736. %% End of file `docstrip.tex'.
  737.