| 1 |
%% |
| 2 |
%% This is file `docstrip.tex', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% docstrip.dtx (with options: `initex,program,stats') |
| 8 |
%% |
| 9 |
%% This is a generated file. |
| 10 |
%% |
| 11 |
%% The source is maintained by the LaTeX Project team and bug |
| 12 |
%% reports for it can be opened at https://latex-project.org/bugs.html |
| 13 |
%% (but please observe conditions on bug reports sent to that address!) |
| 14 |
%% |
| 15 |
%% |
| 16 |
%% Copyright (C) 1993-2025 |
| 17 |
%% The LaTeX Project and any individual authors listed elsewhere |
| 18 |
%% in this file. |
| 19 |
%% |
| 20 |
%% This file was generated from file(s) of the LaTeX base system. |
| 21 |
%% -------------------------------------------------------------- |
| 22 |
%% |
| 23 |
%% It may be distributed and/or modified under the |
| 24 |
%% conditions of the LaTeX Project Public License, either version 1.3c |
| 25 |
%% of this license or (at your option) any later version. |
| 26 |
%% The latest version of this license is in |
| 27 |
%% https://www.latex-project.org/lppl.txt |
| 28 |
%% and version 1.3c or later is part of all distributions of LaTeX |
| 29 |
%% version 2008 or later. |
| 30 |
%% |
| 31 |
%% This file has the LPPL maintenance status "maintained". |
| 32 |
%% |
| 33 |
%% This file may only be distributed together with a copy of the LaTeX |
| 34 |
%% base system. You may however distribute the LaTeX base system without |
| 35 |
%% such generated files. |
| 36 |
%% |
| 37 |
%% The list of all files belonging to the LaTeX base distribution is |
| 38 |
%% given in the file `manifest.txt'. See also `legal.txt' for additional |
| 39 |
%% information. |
| 40 |
%% |
| 41 |
%% The list of derived (unpacked) files belonging to the distribution |
| 42 |
%% and covered by LPPL is defined by the unpacking scripts (with |
| 43 |
%% extension .ins) which are part of the distribution. |
| 44 |
\catcode`\{=1 |
| 45 |
\catcode`\}=2 |
| 46 |
\def\filename{docstrip.dtx} |
| 47 |
\def\fileversion{v2.6c} |
| 48 |
\def\filedate{2024-12-23} |
| 49 |
\def\docdate {2025-09-23} |
| 50 |
%% |
| 51 |
%% The docstrip program for use with TeX. |
| 52 |
%% Copyright (C) 1989-1991 Frank Mittelbach |
| 53 |
%% Copyright (C) 1992-1995 Johannes Braams, Denys Duchier, |
| 54 |
%% Frank Mittelbach |
| 55 |
%% Copyright (C) 1995 Marcin Woli\'nski |
| 56 |
%% Copyright (C) 1996-1997 Mark Wooding, Marcin Woli\'nski |
| 57 |
%% Copyright (C) 1998-2022 LaTeX Project and the above authors. |
| 58 |
%% All rights are reserved. |
| 59 |
%% |
| 60 |
\catcode`\Z=\catcode`\% |
| 61 |
\ifnum13=\catcode`\~{\egroup\else |
| 62 |
\catcode`\Z=9 |
| 63 |
Z |
| 64 |
Z \catcode`\{=1 \catcode`\}=2 |
| 65 |
Z \catcode`\#=6 \catcode`\^=7 |
| 66 |
Z \catcode`\@=11 \catcode`\^^L=13 |
| 67 |
Z \let\bgroup={ \let\egroup=} |
| 68 |
Z |
| 69 |
Z \dimendef\z@=10 \z@=0pt \chardef\@ne=1 \countdef\m@ne=22 \m@ne=-1 |
| 70 |
Z \countdef\count@=255 |
| 71 |
Z |
| 72 |
Z \def\wlog{\immediate\write\m@ne} \def\space{ } |
| 73 |
Z |
| 74 |
Z \count10=22 % allocates \count registers 23, 24, ... |
| 75 |
Z \count15=9 % allocates \toks registers 10, 11, ... |
| 76 |
Z \count16=-1 % allocates input streams 0, 1, ... |
| 77 |
Z \count17=-1 % allocates output streams 0, 1, ... |
| 78 |
Z |
| 79 |
Z \def\alloc@#1#2#3{\advance\count1#1\@ne#2#3\count1#1\relax} |
| 80 |
Z |
| 81 |
Z \def\newcount{\alloc@0\countdef} \def\newtoks{\alloc@5\toksdef} |
| 82 |
Z \def\newread{\alloc@6\chardef} \def\newwrite{\alloc@7\chardef} |
| 83 |
Z |
| 84 |
Z \def\newif#1{% |
| 85 |
Z \count@\escapechar \escapechar\m@ne |
| 86 |
Z \let#1\iffalse |
| 87 |
Z \@if#1\iftrue |
| 88 |
Z \@if#1\iffalse |
| 89 |
Z \escapechar\count@} |
| 90 |
Z \def\@if#1#2{% |
| 91 |
Z \expandafter\def\csname\expandafter\@gobbletwo\string#1% |
| 92 |
Z \expandafter\@gobbletwo\string#2\endcsname |
| 93 |
Z {\let#1#2}} |
| 94 |
Z |
| 95 |
Z \def\@gobbletwo#1#2{} |
| 96 |
Z \def\@gobblethree#1#2#3{} |
| 97 |
Z |
| 98 |
Z \def\loop#1\repeat{\def\body{#1}\iterate} |
| 99 |
Z \def\iterate{\body \let\next\iterate \else\let\next\relax\fi \next} |
| 100 |
Z \let\repeat\fi |
| 101 |
Z |
| 102 |
Z \def\empty{} |
| 103 |
Z |
| 104 |
Z \def\tracingall{\tracingcommands2 \tracingstats2 |
| 105 |
Z \tracingpages1 \tracingoutput1 \tracinglostchars1 |
| 106 |
Z \tracingmacros2 \tracingparagraphs1 \tracingrestores1 |
| 107 |
Z \showboxbreadth 10000 \showboxdepth 10000 \errorstopmode |
| 108 |
Z \errorcontextlines 10000 \tracingonline1 } |
| 109 |
Z |
| 110 |
\bgroup}\fi\catcode`\Z=11 |
| 111 |
\let\bgroup={ \let\egroup=} |
| 112 |
\catcode`\@=11 |
| 113 |
\newlinechar=`\^^J |
| 114 |
\count@=128\relax |
| 115 |
\loop |
| 116 |
\catcode\count@ 12\relax |
| 117 |
\ifnum\count@ <255\relax |
| 118 |
\advance\count@\@ne |
| 119 |
\repeat |
| 120 |
\newif\ifGenerate |
| 121 |
\newif\ifContinue |
| 122 |
\newif\ifForlist |
| 123 |
\newif\ifDefault |
| 124 |
\newif\ifMoreFiles \MoreFilestrue |
| 125 |
\newif\ifaskforoverwrite \askforoverwritetrue |
| 126 |
\newcount\blockLevel \blockLevel\z@ |
| 127 |
\newcount\emptyLines \emptyLines \z@ |
| 128 |
\newcount\processedLines \processedLines \z@ |
| 129 |
\newcount\commentsRemoved \commentsRemoved \z@ |
| 130 |
\newcount\commentsPassed \commentsPassed \z@ |
| 131 |
\newcount\codeLinesPassed \codeLinesPassed \z@ |
| 132 |
\newcount\TotalprocessedLines \TotalprocessedLines \z@ |
| 133 |
\newcount\TotalcommentsRemoved \TotalcommentsRemoved \z@ |
| 134 |
\newcount\TotalcommentsPassed \TotalcommentsPassed \z@ |
| 135 |
\newcount\TotalcodeLinesPassed \TotalcodeLinesPassed \z@ |
| 136 |
\newcount\NumberOfFiles \NumberOfFiles\z@ |
| 137 |
\newread\inFile |
| 138 |
\chardef\ttyin16 |
| 139 |
\chardef\ttyout16 |
| 140 |
\newread\inputcheck |
| 141 |
\newif\iftopbatchfile \topbatchfiletrue |
| 142 |
\def\ifToplevel{\relax\iftopbatchfile |
| 143 |
\expandafter\iden \else \expandafter\@gobble\fi} |
| 144 |
\ifx\undefined\@@input \let\@@input\input\fi |
| 145 |
\def\batchinput#1{% |
| 146 |
\begingroup |
| 147 |
\def\batchfile{#1}% |
| 148 |
\topbatchfilefalse |
| 149 |
\Defaultfalse |
| 150 |
\usepreamble\org@preamble |
| 151 |
\usepostamble\org@postamble |
| 152 |
\let\destdir\WriteToDir |
| 153 |
\processbatchFile |
| 154 |
\endgroup |
| 155 |
} |
| 156 |
\def\skip@input#1 {} |
| 157 |
\let\input\skip@input |
| 158 |
\def\guardStack{} |
| 159 |
\def\blockHead{} |
| 160 |
\def\yes{yes} |
| 161 |
\def\y{y} |
| 162 |
\def\n{n} |
| 163 |
\def\DefaultbatchFile{docstrip.cmd} |
| 164 |
{\catcode`\%=12 |
| 165 |
\gdef\perCent{%} |
| 166 |
\gdef\DoubleperCent{%%} |
| 167 |
} |
| 168 |
\let\MetaPrefix\DoubleperCent |
| 169 |
\def^^L{ } |
| 170 |
\def\Name#1#2{\expandafter#1\csname#2\endcsname} |
| 171 |
\def\@stripstring{\expandafter\@gobble\string} |
| 172 |
\def\eltStart{} |
| 173 |
\def\eltEnd{} |
| 174 |
\def\qStop{\qStop} |
| 175 |
\def\pop#1#2{% |
| 176 |
\ifx#1\empty |
| 177 |
\Msg{Warning: Found end guard without matching begin}% |
| 178 |
\let#2\empty |
| 179 |
\else |
| 180 |
\def\tmp{\expandafter\popX #1\qStop #1#2}% |
| 181 |
\expandafter\tmp\fi} |
| 182 |
\def\popX\eltStart #1\eltEnd #2\qStop #3#4{\def#3{#2}\def#4{#1}} |
| 183 |
\def\push#1#2{\expandafter\pushX #1\qStop #1{\eltStart #2\eltEnd}} |
| 184 |
\def\pushX #1\qStop #2#3{\def #2{#3#1}} |
| 185 |
\def\forlist#1:=#2\do#3\od{% |
| 186 |
\edef\ListCondition{#2}% |
| 187 |
\Forlisttrue |
| 188 |
\loop |
| 189 |
\edef#1{\expandafter\FirstElt\ListCondition,\empty.}% |
| 190 |
\edef\ListCondition{\expandafter\OtherElts\ListCondition,\empty.}% |
| 191 |
\ifx#1\empty \Forlistfalse \else#3\fi |
| 192 |
\ifForlist |
| 193 |
\repeat} |
| 194 |
\def\FirstElt#1,#2.{#1} |
| 195 |
\def\OtherElts#1,#2.{#2} |
| 196 |
\def\whileswitch#1\fi#2{#1\loop#2#1\repeat\fi} |
| 197 |
\ifx\@tempcnta\undefined \newcount\@tempcnta \fi |
| 198 |
\@tempcnta=0 |
| 199 |
\loop |
| 200 |
\Name\chardef{s@\number\@tempcnta}=0 |
| 201 |
\csname newcount\expandafter\endcsname% |
| 202 |
\csname off@\number\@tempcnta\endcsname |
| 203 |
\advance\@tempcnta1 |
| 204 |
\ifnum\@tempcnta<16\repeat |
| 205 |
\let\s@do\relax |
| 206 |
\edef\@outputstreams{% |
| 207 |
\s@do\Name\noexpand{s@0}\s@do\Name\noexpand{s@1}% |
| 208 |
\s@do\Name\noexpand{s@2}\s@do\Name\noexpand{s@3}% |
| 209 |
\s@do\Name\noexpand{s@4}\s@do\Name\noexpand{s@5}% |
| 210 |
\s@do\Name\noexpand{s@6}\s@do\Name\noexpand{s@7}% |
| 211 |
\s@do\Name\noexpand{s@8}\s@do\Name\noexpand{s@9}% |
| 212 |
\s@do\Name\noexpand{s@10}\s@do\Name\noexpand{s@11}% |
| 213 |
\s@do\Name\noexpand{s@12}\s@do\Name\noexpand{s@13}% |
| 214 |
\s@do\Name\noexpand{s@14}\s@do\Name\noexpand{s@15}% |
| 215 |
\noexpand\@nostreamerror |
| 216 |
} |
| 217 |
\def\@nostreamerror{\errmessage{No more output streams!}} |
| 218 |
\def\@streamfound#1\@nostreamerror{\fi} |
| 219 |
\bgroup\edef\x{\egroup |
| 220 |
\def\noexpand\@stripstr\string\s@{}} |
| 221 |
\x |
| 222 |
\def\quote@name#1{"\quote@@name#1\@gobble""} |
| 223 |
\def\quote@@name#1"{#1\quote@@name} |
| 224 |
\chardef\stream@closed=16 |
| 225 |
\def\StreamOpen#1{% |
| 226 |
\chardef#1=\stream@closed |
| 227 |
\def\s@do##1{\ifnum##1=0 |
| 228 |
\chardef#1=\expandafter\@stripstr\string##1 % |
| 229 |
\global\chardef##1=1 % |
| 230 |
\edef\q@curr@file{% |
| 231 |
\expandafter\expandafter\expandafter\quote@name |
| 232 |
\expandafter\expandafter\expandafter{\csname pth@\@stripstring#1\endcsname}} |
| 233 |
\immediate\openout#1=\q@curr@file\relax |
| 234 |
\@streamfound |
| 235 |
\fi} |
| 236 |
\@outputstreams |
| 237 |
} |
| 238 |
\def\StreamClose#1{% |
| 239 |
\immediate\closeout#1% |
| 240 |
\def\s@do##1{\ifnum#1=\expandafter\@stripstr\string##1 % |
| 241 |
\global\chardef##1=0 % |
| 242 |
\@streamfound |
| 243 |
\fi} |
| 244 |
\@outputstreams |
| 245 |
\chardef#1=\stream@closed |
| 246 |
} |
| 247 |
\def\StreamPut{\immediate\write} |
| 248 |
\def\showprogress{\let\maybeMsg\message} |
| 249 |
\def\keepsilent{\let\maybeMsg\@gobble} |
| 250 |
\showprogress |
| 251 |
\def\Msg{\immediate\write\ttyout} |
| 252 |
\def\iden#1{#1} |
| 253 |
\def\strip#1#2 \@gobble{\def #1{#2}} |
| 254 |
\def\@defpar{\par} |
| 255 |
\def\Ask#1#2{% |
| 256 |
\message{#2}\read\ttyin to #1\ifx#1\@defpar\def#1{}\else |
| 257 |
\iden{\expandafter\strip |
| 258 |
\expandafter#1#1\@gobble\@gobble} \@gobble\fi} |
| 259 |
\let\OriginalAsk=\Ask |
| 260 |
\def\askonceonly{% |
| 261 |
\def\Ask##1##2{% |
| 262 |
\OriginalAsk{##1}{##2}% |
| 263 |
\global\let\Ask\OriginalAsk |
| 264 |
\Ask\noprompt{% |
| 265 |
By default you will be asked this question for every file.^^J% |
| 266 |
If you enter `y' now,^^J% |
| 267 |
I will assume `y' for all future questions^^J% |
| 268 |
without prompting.}% |
| 269 |
\ifx\y\noprompt\let\noprompt\yes\fi |
| 270 |
\ifx\yes\noprompt\gdef\Ask####1####2{\def####1{y}}\fi}} |
| 271 |
\def\@gobble#1{} |
| 272 |
\edef\Endinput{\expandafter\@gobble\string\\endinput} |
| 273 |
\def\makeOther#1{\catcode`#1=12\relax} |
| 274 |
\ifx\undefined\@@end\else\let\end\@@end\fi |
| 275 |
\ifx\@temptokena\undefined \csname newtoks\endcsname\@temptokena\fi |
| 276 |
\def\@addto#1#2{% |
| 277 |
\@temptokena\expandafter{#1}% |
| 278 |
\edef#1{\the\@temptokena#2}} |
| 279 |
\def\@ifpresent#1#2#3#4{% |
| 280 |
\def\tmp##1#1##2\qStop{\ifx!##2!}% |
| 281 |
\expandafter\tmp#2#1\qStop #4\else #3\fi |
| 282 |
} |
| 283 |
\def\tospaces#1{% |
| 284 |
\ifx#1\secapsot\secapsot\fi\space\tospaces} |
| 285 |
\def\secapsot\fi\space\tospaces{\fi} |
| 286 |
\def\@spaces{\space\space\space\space\space} |
| 287 |
\def\uptospace#1 #2\qStop{#1} |
| 288 |
\def\afterfi#1#2\fi{\fi#1} |
| 289 |
\def\@ifnextchar#1#2#3{\bgroup |
| 290 |
\def\reserved@a{\ifx\reserved@c #1 \aftergroup\@firstoftwo |
| 291 |
\else \aftergroup\@secondoftwo\fi\egroup |
| 292 |
{#2}{#3}}% |
| 293 |
\futurelet\reserved@c\@ifnch |
| 294 |
} |
| 295 |
\def\@ifnch{\ifx \reserved@c \@sptoken \expandafter\@xifnch |
| 296 |
\else \expandafter\reserved@a |
| 297 |
\fi} |
| 298 |
\def\@firstoftwo#1#2{#1} |
| 299 |
\def\@secondoftwo#1#2{#2} |
| 300 |
\iden{\let\@sptoken= } % |
| 301 |
\iden{\def\@xifnch} {\futurelet\reserved@c\@ifnch} |
| 302 |
\let\kernel@ifnextchar\@ifnextchar |
| 303 |
\def\Terminal#1#2#3{% |
| 304 |
\expandafter\ifx\csname eT@#3\endcsname\relax |
| 305 |
\afterfi{\Terminal{#1}{#2#3}}\else |
| 306 |
\afterfi{\TerminalX{#1}{#2}#3}\fi |
| 307 |
} |
| 308 |
\Name\let{eT@>}=1 |
| 309 |
\Name\let{eT@&}=1 \Name\let{eT@!}=1 |
| 310 |
\Name\let{eT@|}=1 \Name\let{eT@,}=1 |
| 311 |
\Name\let{eT@(}=1 \Name\let{eT@)}=1 |
| 312 |
\def\TerminalX#1#2{% |
| 313 |
\ifx>#2> \errmessage{Error in expression: empty terminal}\fi |
| 314 |
\Name\def{t@#2}##1,#2,##2\qStop{\ifx>##2>0\else1\fi}% |
| 315 |
#1{\Name\noexpand{t@#2},##1,#2,\noexpand\qStop}% |
| 316 |
} |
| 317 |
\def\Primary#1#2{% |
| 318 |
\ifcase \ifx!#20\else\ifx(#21\else2\fi\fi\space |
| 319 |
\afterfi{\Primary{\NPrimary{#1}}}\or |
| 320 |
\afterfi{\Expression{\PExpression{#1}}}\or |
| 321 |
\afterfi{\Terminal{#1}{}#2}\fi |
| 322 |
} |
| 323 |
\def\NPrimary#1#2{% |
| 324 |
#1{\noexpand\if1#20\noexpand\else1\noexpand\fi}% |
| 325 |
} |
| 326 |
\def\PExpression#1#2#3{% |
| 327 |
\ifx)#3\else |
| 328 |
\errmessage{Error in expression: expected right parenthesis}\fi |
| 329 |
#1{#2}} |
| 330 |
\def\Secondary#1{% |
| 331 |
\Primary{\SecondaryX{#1}}} |
| 332 |
\bgroup\catcode`\&=12 |
| 333 |
\gdef\SecondaryX#1#2#3{% |
| 334 |
\ifx% |
| 335 |
\afterfi{\Secondary{\SecondaryXX{#1}{#2}}}\else |
| 336 |
\afterfi{#1{#2}#3}\fi |
| 337 |
} |
| 338 |
\egroup |
| 339 |
\def\SecondaryXX#1#2#3{% |
| 340 |
#1{\noexpand\if0#20\noexpand\else#3\noexpand\fi}} |
| 341 |
\def\Expression#1{% |
| 342 |
\Secondary{\ExpressionX{#1}}} |
| 343 |
\def\ExpressionX#1#2#3{% |
| 344 |
\if0\ifx|#31\else\ifx,#31\fi\fi0 |
| 345 |
\afterfi{#1{#2}#3}\else |
| 346 |
\afterfi{\Expression{\ExpressionXX{#1}{#2}}}\fi |
| 347 |
} |
| 348 |
\def\ExpressionXX#1#2#3{% |
| 349 |
#1{\noexpand\if1#21\noexpand\else#3\noexpand\fi}} |
| 350 |
\def\StopParse#1#2{% |
| 351 |
\ifx>#2 \else\errmessage{Error in expression: spurious #2}\fi |
| 352 |
\edef\Expr##1{#1}} |
| 353 |
\def\Evaluate#1{% |
| 354 |
\Expression\StopParse#1>} |
| 355 |
\def\normalLine#1\endLine{% |
| 356 |
\advance\codeLinesPassed\@ne |
| 357 |
\maybeMsg{.}% |
| 358 |
\def\inLine{#1}% |
| 359 |
\replaceModuleInLine |
| 360 |
\let\do\putline@do |
| 361 |
\activefiles |
| 362 |
} |
| 363 |
\def\putline@do#1#2#3{% |
| 364 |
\StreamPut#1{\inLine}} |
| 365 |
\def\removeComment#1\endLine{% |
| 366 |
\advance\commentsRemoved\@ne |
| 367 |
\maybeMsg{\perCent}} |
| 368 |
\bgroup\catcode`\%=12 |
| 369 |
\iden{\egroup |
| 370 |
\def\putMetaComment%}#1\endLine{% |
| 371 |
\advance\commentsPassed\@ne |
| 372 |
\edef\inLine{\MetaPrefix#1}% |
| 373 |
\let\do\putline@do |
| 374 |
\activefiles |
| 375 |
} |
| 376 |
\begingroup |
| 377 |
\catcode`\%=12 \catcode`\*=14 |
| 378 |
\gdef\processLine#1{* |
| 379 |
\advance\processedLines\@ne |
| 380 |
\ifx%#1 |
| 381 |
\expandafter\processLineX |
| 382 |
\else |
| 383 |
\expandafter\normalLine |
| 384 |
\fi |
| 385 |
#1} |
| 386 |
\endgroup |
| 387 |
\begingroup |
| 388 |
\catcode`\%=12 \catcode`\*=14 |
| 389 |
\gdef\processLineX%#1{* |
| 390 |
\ifcase\ifx%#10\else |
| 391 |
\ifx<#11\else 2\fi\fi\relax |
| 392 |
\expandafter\putMetaComment\or |
| 393 |
\expandafter\checkOption\or |
| 394 |
\expandafter\removeComment\fi |
| 395 |
#1} |
| 396 |
\endgroup |
| 397 |
\def\checkOption<#1{% |
| 398 |
\ifcase |
| 399 |
\ifx*#10\else \ifx/#11\else |
| 400 |
\ifx+#12\else \ifx-#13\else |
| 401 |
\ifx<#14\else \ifx @#15\else 6\fi\fi\fi\fi\fi\fi\relax |
| 402 |
\expandafter\starOption\or |
| 403 |
\expandafter\slashOption\or |
| 404 |
\expandafter\plusOption\or |
| 405 |
\expandafter\minusOption\or |
| 406 |
\expandafter\verbOption\or |
| 407 |
\expandafter\moduleOption\or |
| 408 |
\expandafter\doOption\fi |
| 409 |
#1} |
| 410 |
\def\doOption#1>#2\endLine{% |
| 411 |
\maybeMsg{<#1 . >}% |
| 412 |
\Evaluate{#1}% |
| 413 |
\def\do##1##2##3{% |
| 414 |
\if1\Expr{##2}% |
| 415 |
\def\inLine{#2}% |
| 416 |
\replaceModuleInLine |
| 417 |
\StreamPut##1{\inLine}\fi |
| 418 |
}% |
| 419 |
\activefiles |
| 420 |
} |
| 421 |
\def\plusOption+#1>#2\endLine{% |
| 422 |
\maybeMsg{<+#1 . >}% |
| 423 |
\Evaluate{#1}% |
| 424 |
\def\do##1##2##3{% |
| 425 |
\if1\Expr{##2}% |
| 426 |
\def\inLine{#2}\replaceModuleInLine |
| 427 |
\StreamPut##1{\inLine}\fi |
| 428 |
}% |
| 429 |
\activefiles |
| 430 |
} |
| 431 |
\def\minusOption-#1>#2\endLine{% |
| 432 |
\maybeMsg{<-#1 . >}% |
| 433 |
\Evaluate{#1}% |
| 434 |
\def\do##1##2##3{% |
| 435 |
\if1\Expr{##2}\else |
| 436 |
\def\inLine{#2}\replaceModuleInLine |
| 437 |
\StreamPut##1{\inLine}\fi |
| 438 |
}% |
| 439 |
\activefiles |
| 440 |
} |
| 441 |
\def\starOption*#1>#2\endLine{% |
| 442 |
\maybeMsg{<*#1}% |
| 443 |
\expandafter\push\expandafter\guardStack\expandafter{\blockHead}% |
| 444 |
\advance\blockLevel\@ne |
| 445 |
\def\blockHead{#1}% |
| 446 |
\Evaluate{#1}% |
| 447 |
\let\do\checkguard@do |
| 448 |
\outputfiles |
| 449 |
\let\do\findactive@do |
| 450 |
\edef\activefiles{\activefiles} |
| 451 |
} |
| 452 |
\def\checkguard@do#1#2#3{% |
| 453 |
\ifnum#3>0 |
| 454 |
\advance#3\@ne |
| 455 |
\else |
| 456 |
\if1\Expr{#2}\else |
| 457 |
\advance#3\@ne\fi |
| 458 |
\fi} |
| 459 |
\def\findactive@do#1#2#3{% |
| 460 |
\ifnum#3=0 |
| 461 |
\noexpand\do#1{#2}#3\fi} |
| 462 |
\def\slashOption/#1>#2\endLine{% |
| 463 |
\def\tmp{#1}% |
| 464 |
\ifnum\blockLevel<\@ne |
| 465 |
\errmessage{Spurious end block </\tmp> ignored}% |
| 466 |
\else |
| 467 |
\ifx\tmp\blockHead |
| 468 |
\pop\guardStack\blockHead |
| 469 |
\else |
| 470 |
\errmessage{Found </\tmp> instead of </\blockHead>}% |
| 471 |
\fi |
| 472 |
\maybeMsg{>}% |
| 473 |
\advance\blockLevel\m@ne |
| 474 |
\let\do\closeguard@do |
| 475 |
\outputfiles |
| 476 |
\let\do\findactive@do |
| 477 |
\edef\activefiles{\outputfiles} |
| 478 |
\fi |
| 479 |
} |
| 480 |
\def\closeguard@do#1#2#3{% |
| 481 |
\ifnum#3>0 |
| 482 |
\advance#3\m@ne |
| 483 |
\fi} |
| 484 |
\def\verbOption<#1\endLine{{% |
| 485 |
\edef\verbStop{\perCent#1}\maybeMsg{<<<}% |
| 486 |
\let\do\putline@do |
| 487 |
\loop |
| 488 |
\ifeof\inFile\errmessage{Source file ended while in verbatim |
| 489 |
mode!}\fi |
| 490 |
\read\inFile to \inLine |
| 491 |
\if 1\ifx\inLine\verbStop 0\fi 1% if not inLine==verbStop |
| 492 |
\activefiles |
| 493 |
\maybeMsg{.}% |
| 494 |
\repeat |
| 495 |
\maybeMsg{>}% |
| 496 |
}} |
| 497 |
\def\moduleOption @@=#1>#2\endLine{% |
| 498 |
\maybeMsg{<@@=#1>}% |
| 499 |
\prepareActiveModule{#1}% |
| 500 |
} |
| 501 |
\begingroup |
| 502 |
\catcode`\_ = 12 % |
| 503 |
\long\gdef\prepareActiveModule#1{% |
| 504 |
\ifx\relax#1\relax |
| 505 |
\let\replaceModuleInLine\empty |
| 506 |
\else |
| 507 |
\edef\replaceModuleInLine{% |
| 508 |
\noexpand\replaceAllIn\noexpand\inLine{@@@@}{\string aa}% |
| 509 |
\noexpand\replaceAllIn\noexpand\inLine{__@@}{__#1}% |
| 510 |
\noexpand\replaceAllIn\noexpand\inLine{_@@}{__#1}% |
| 511 |
\noexpand\replaceAllIn\noexpand\inLine{@@}{__#1}% |
| 512 |
\noexpand\replaceAllIn\noexpand\inLine{\string aa}{@@}% |
| 513 |
}% |
| 514 |
\fi |
| 515 |
} |
| 516 |
\endgroup |
| 517 |
\let\replaceModuleInLine\empty |
| 518 |
\long\def\replaceAllIn#1#2#3{% |
| 519 |
\long\def\tempa##1##2#2{% |
| 520 |
##2\qMark\replaceAllInAuxIII#3##1% |
| 521 |
}% |
| 522 |
\edef#1{\expandafter\replaceAllInAuxI#1\qMark#2\qStop}% |
| 523 |
} |
| 524 |
\def\replaceAllInAuxI{% |
| 525 |
\expandafter\replaceAllInAuxII\tempa\replaceAllInAuxI\empty |
| 526 |
} |
| 527 |
\long\def\replaceAllInAuxII#1\qMark#2{#1} |
| 528 |
\long\def\replaceAllInAuxIII#1\qStop{} |
| 529 |
\def\generate#1{\begingroup |
| 530 |
\let\inputfiles\empty \let\filestogenerate\empty |
| 531 |
\let\file\@file |
| 532 |
#1 |
| 533 |
\ifx\filestogenerate\empty\else |
| 534 |
\Msg{^^JGenerating file(s) \filestogenerate}\fi |
| 535 |
\def\inFileName{\csname in@\outFileName\endcsname}% |
| 536 |
\def\ReferenceLines{\csname ref@\outFileName\endcsname}% |
| 537 |
\processinputfiles |
| 538 |
\endgroup} |
| 539 |
\def\processinputfiles{% |
| 540 |
\let\newinputfiles\empty |
| 541 |
\inputfiles |
| 542 |
\let\inputfiles\newinputfiles |
| 543 |
\ifx\inputfiles\empty\else |
| 544 |
\expandafter\processinputfiles |
| 545 |
\fi |
| 546 |
} |
| 547 |
\def\file#1#2{\errmessage{Command `\string\file' only allowed in |
| 548 |
argument to `\string\generate'}} |
| 549 |
\def\@file#1{% |
| 550 |
\Generatetrue |
| 551 |
\makepathname{#1}% |
| 552 |
\ifaskforoverwrite |
| 553 |
\immediate\openin\inFile\@pathname\relax |
| 554 |
\ifeof\inFile\else |
| 555 |
\Ask\answer{File \@pathname\space already exists |
| 556 |
\ifx\empty\destdir somewhere \fi |
| 557 |
on the system.^^J% |
| 558 |
Overwrite it% |
| 559 |
\ifx\empty\destdir\space if necessary\fi |
| 560 |
? [y/n]}% |
| 561 |
\ifx\y \answer \else |
| 562 |
\ifx\yes\answer \else |
| 563 |
\Generatefalse\fi\fi\fi |
| 564 |
\closein\inFile |
| 565 |
\fi |
| 566 |
\ifGenerate |
| 567 |
\Name\let{pth@#1}\@pathname |
| 568 |
\@addto\filestogenerate{\@pathname\space}% |
| 569 |
\Name\@fileX{#1\expandafter}% |
| 570 |
\else |
| 571 |
\Msg{Not generating file \@pathname^^J}% |
| 572 |
\expandafter\@gobble |
| 573 |
\fi |
| 574 |
} |
| 575 |
\def\@fileX#1#2{% |
| 576 |
\ifx#1\relax \else |
| 577 |
\errmessage{Command \string#1 for denoting the output \noexpand |
| 578 |
\file stream already defined!^^J |
| 579 |
\space Current meaning is:^^J^^J\meaning#1^^J^^J |
| 580 |
\space Extraction will probably fail - check result}% |
| 581 |
\fi |
| 582 |
\chardef#1=\stream@closed |
| 583 |
\def\curout{#1}% |
| 584 |
\ifx\curout\currentpreamble |
| 585 |
\errmessage{Declared preamble name \string#1 not allowed if |
| 586 |
\string\file{\@stripstring#1} is used}% |
| 587 |
\fi |
| 588 |
\ifx\curout\currentpostamble |
| 589 |
\errmessage{Declared postamble name \string#1 not allowed if |
| 590 |
\string\file{\@stripstring#1} is used}% |
| 591 |
\fi |
| 592 |
\let\curinfiles\empty |
| 593 |
\let\curinnames\empty |
| 594 |
\def\curref{\MetaPrefix ^^J% |
| 595 |
\MetaPrefix\space The original source files were:^^J% |
| 596 |
\MetaPrefix ^^J}% |
| 597 |
\let\from\@from \let\needed\@needed |
| 598 |
#2% |
| 599 |
\let\from\err@from \let\needed\err@needed |
| 600 |
\checkorder |
| 601 |
\Name\@addto{e@\curin}{\noexpand\closeoutput{#1}}% |
| 602 |
\Name\let{pre@\@stripstring#1\expandafter}\currentpreamble |
| 603 |
\Name\let{post@\@stripstring#1\expandafter}\currentpostamble |
| 604 |
\Name\edef{in@\@stripstring#1}{\expandafter\iden\curinnames} |
| 605 |
\Name\edef{ref@\@stripstring#1}{\curref} |
| 606 |
} |
| 607 |
\def\checkorder{% |
| 608 |
\expandafter\expandafter\expandafter |
| 609 |
\checkorderX\expandafter\curinfiles |
| 610 |
\expandafter\qStop\inputfiles\qStop |
| 611 |
} |
| 612 |
\def\checkorderX(#1)#2\qStop#3\qStop{% |
| 613 |
\def\tmp##1\readsource(#1)##2\qStop{% |
| 614 |
\ifx!##2! \order@error |
| 615 |
\else\ifx!#2!\else |
| 616 |
\checkorderXX##2% |
| 617 |
\fi\fi}% |
| 618 |
\def\checkorderXX##1\readsource(#1)\fi\fi{\fi\fi |
| 619 |
\checkorderX#2\qStop##1\qStop}% |
| 620 |
\tmp#3\readsource(#1)\qStop |
| 621 |
} |
| 622 |
\def\order@error#1\fi\fi{\fi |
| 623 |
\errmessage{DOCSTRIP error: Incompatible order of input |
| 624 |
files specified for file |
| 625 |
`\iden{\expandafter\uptospace\curin} \qStop'.^^J |
| 626 |
Read DOCSTRIP documentation for explanation.^^J |
| 627 |
This is a serious problem, I'm exiting}\end |
| 628 |
} |
| 629 |
\def\needed#1{\errmessage{\string\needed\space can only be used in |
| 630 |
argument to \string\file}} |
| 631 |
\let\err@needed\needed |
| 632 |
\def\@needed#1{% |
| 633 |
\edef\reserved@a{#1}% |
| 634 |
\expandafter\@need@d\expandafter{\reserved@a}} |
| 635 |
\def\@need@d#1{% |
| 636 |
\@ifpresent{(#1)}\curinfiles |
| 637 |
{\@need@d{#1 }}% |
| 638 |
{\@ifpresent{\readsource(#1)}\inputfiles |
| 639 |
{}{\@addto\inputfiles{\noexpand\readsource(#1)}% |
| 640 |
\Name\let{b@#1}\empty |
| 641 |
\Name\let{o@#1}\empty |
| 642 |
\Name\let{e@#1}\empty}% |
| 643 |
\@addto\curinfiles{(#1)}% |
| 644 |
\def\curin{#1}}% |
| 645 |
} |
| 646 |
\def\from#1#2{\errmessage{Command `\string\from' only allowed in |
| 647 |
argument to `\string\file'}} |
| 648 |
\let\err@from\from |
| 649 |
\def\@from#1#2{% |
| 650 |
\@addto\curref{\MetaPrefix\space #1 \if>#2>\else |
| 651 |
\space (with options: `#2')\fi^^J}% |
| 652 |
\needed{#1}% |
| 653 |
\ifx\curinnames\empty |
| 654 |
\Name\@addto{b@\curin}{\noexpand\openoutput\curout}% |
| 655 |
\fi |
| 656 |
\@addto\curinnames{ #1}% |
| 657 |
\Name\@addto{o@\curin}{\noexpand\do\curout{#2}}% |
| 658 |
} |
| 659 |
\def\readsource(#1){% |
| 660 |
\immediate\openin\inFile\uptospace#1 \qStop\relax |
| 661 |
\ifeof\inFile |
| 662 |
\errmessage{Cannot find file \uptospace#1 \qStop}% |
| 663 |
\else |
| 664 |
\processedLines\z@ |
| 665 |
\commentsRemoved\z@ |
| 666 |
\commentsPassed\z@ |
| 667 |
\codeLinesPassed\z@ |
| 668 |
\let\refusedfiles\empty |
| 669 |
\csname b@#1\endcsname |
| 670 |
\Name\let{b@#1}\refusedfiles |
| 671 |
\Msg{} \def\@msg{Processing file \uptospace#1 \qStop} |
| 672 |
\def\change@msg{% |
| 673 |
\edef\@msg{\@spaces\@spaces\@spaces\space |
| 674 |
\expandafter\tospaces\uptospace#1 \qStop\secapsot} |
| 675 |
\let\change@msg\relax} |
| 676 |
\let\do\showfiles@do |
| 677 |
\let\refusedfiles\empty |
| 678 |
\csname o@#1\endcsname |
| 679 |
\ifx\refusedfiles\empty\else |
| 680 |
\@addto\newinputfiles{\noexpand\readsource(#1)} |
| 681 |
\fi |
| 682 |
\let\do\makeoutlist@do |
| 683 |
\edef\outputfiles{\csname o@#1\endcsname}% |
| 684 |
\let\activefiles\outputfiles |
| 685 |
\Name\let{o@#1}\refusedfiles |
| 686 |
\makeOther\ \makeOther\\\makeOther\$% |
| 687 |
\makeOther\#\makeOther\^\makeOther\^^K% |
| 688 |
\makeOther\_\makeOther\^^A\makeOther\%% |
| 689 |
\makeOther\~\makeOther\{\makeOther\}\makeOther\&% |
| 690 |
\endlinechar-1\relax |
| 691 |
\@tempcnta=128\relax |
| 692 |
\loop |
| 693 |
\catcode\@tempcnta 12\relax |
| 694 |
\ifnum\@tempcnta <255\relax |
| 695 |
\advance\@tempcnta\@ne |
| 696 |
\repeat |
| 697 |
\loop |
| 698 |
\read\inFile to\inLine |
| 699 |
\ifx\inLine\Endinput |
| 700 |
\Msg{File #1 ended by \string\endinput.}% |
| 701 |
\Continuefalse |
| 702 |
\else |
| 703 |
\ifeof\inFile |
| 704 |
\Continuefalse |
| 705 |
\else |
| 706 |
\Continuetrue |
| 707 |
\ifx\inLine\empty |
| 708 |
\advance\emptyLines\@ne |
| 709 |
\else |
| 710 |
\emptyLines\z@ |
| 711 |
\fi |
| 712 |
\ifnum \emptyLines<2 |
| 713 |
\expandafter\processLine\inLine\endLine |
| 714 |
\else |
| 715 |
\maybeMsg{/}% |
| 716 |
\fi |
| 717 |
\fi |
| 718 |
\fi |
| 719 |
\ifContinue |
| 720 |
\repeat |
| 721 |
\closein\inFile |
| 722 |
\csname e@#1\endcsname |
| 723 |
\Msg{Lines \space processed: \the\processedLines^^J% |
| 724 |
Comments removed: \the\commentsRemoved^^J% |
| 725 |
Comments \space passed: \the\commentsPassed^^J% |
| 726 |
Codelines passed: \the\codeLinesPassed^^J}% |
| 727 |
\global\advance\TotalprocessedLines by \processedLines |
| 728 |
\global\advance\TotalcommentsRemoved by \commentsRemoved |
| 729 |
\global\advance\TotalcommentsPassed by \commentsPassed |
| 730 |
\global\advance\TotalcodeLinesPassed by \codeLinesPassed |
| 731 |
\global\advance\NumberOfFiles by \@ne |
| 732 |
\fi} |
| 733 |
\def\showfiles@do#1#2{% |
| 734 |
\ifnum#1=\stream@closed |
| 735 |
\@addto\refusedfiles{\noexpand\do#1{#2}}% |
| 736 |
\else |
| 737 |
\Msg{\@msg |
| 738 |
\ifx>#2>\else\space(#2)\fi |
| 739 |
\space -> \@stripstring#1} |
| 740 |
\change@msg |
| 741 |
\csname off@\number#1\endcsname=\z@ |
| 742 |
\fi |
| 743 |
} |
| 744 |
\def\makeoutlist@do#1#2{% |
| 745 |
\ifnum#1=\stream@closed\else |
| 746 |
\noexpand\do#1{#2}\csname off@\number#1\endcsname |
| 747 |
\fi} |
| 748 |
\def\openoutput#1{% |
| 749 |
\if 1\ifnum\@maxfiles=\z@ 0\fi |
| 750 |
\ifnum\@maxoutfiles=\z@ 0\fi1% |
| 751 |
\advance\@maxfiles\m@ne |
| 752 |
\advance\@maxoutfiles\m@ne |
| 753 |
\StreamOpen#1% |
| 754 |
\WritePreamble#1% |
| 755 |
\else |
| 756 |
\@addto\refusedfiles{\noexpand\openoutput#1}% |
| 757 |
\fi |
| 758 |
} |
| 759 |
\def\closeoutput#1{% |
| 760 |
\ifnum#1=\stream@closed\else |
| 761 |
\WritePostamble#1% |
| 762 |
\StreamClose#1% |
| 763 |
\advance\@maxfiles\@ne |
| 764 |
\advance\@maxoutfiles\@ne |
| 765 |
\fi} |
| 766 |
\def\ds@heading{% |
| 767 |
\MetaPrefix ^^J% |
| 768 |
\MetaPrefix\space This is file `\outFileName',^^J% |
| 769 |
\MetaPrefix\space generated with the docstrip utility.^^J% |
| 770 |
} |
| 771 |
\def\AddGenerationDate{% |
| 772 |
\def\ds@heading{% |
| 773 |
\MetaPrefix ^^J% |
| 774 |
\MetaPrefix\space This is file `\outFileName', generated % |
| 775 |
on <\the\year/\the\month/\the\day> ^^J% |
| 776 |
\MetaPrefix\space with the docstrip utility (\fileversion).^^J% |
| 777 |
}} |
| 778 |
\let\inFileName\relax |
| 779 |
\let\outFileName\relax |
| 780 |
\let\ReferenceLines\relax |
| 781 |
\def\declarepreamble{\begingroup |
| 782 |
\catcode`\^^M=13 \catcode`\ =12 % |
| 783 |
\declarepreambleX} |
| 784 |
{\catcode`\^^M=13 % |
| 785 |
\gdef\declarepreambleX#1#2 |
| 786 |
\endpreamble{\endgroup% |
| 787 |
\def^^M{^^J\MetaPrefix\space}% |
| 788 |
\edef#1{\ds@heading% |
| 789 |
\ReferenceLines% |
| 790 |
\MetaPrefix\space\checkeoln#2\empty}}% |
| 791 |
\gdef\checkeoln#1{\ifx^^M#1\else\expandafter#1\fi}% |
| 792 |
} |
| 793 |
\def\declarepostamble{\begingroup |
| 794 |
\catcode`\ =12 \catcode`\^^M=13 |
| 795 |
\declarepostambleX} |
| 796 |
{\catcode`\^^M=13 % |
| 797 |
\gdef\declarepostambleX#1#2 |
| 798 |
\endpostamble{\endgroup% |
| 799 |
\def^^M{^^J\MetaPrefix\space}% |
| 800 |
\edef#1{\MetaPrefix\space\checkeoln#2\empty^^J% |
| 801 |
\MetaPrefix ^^J% |
| 802 |
\MetaPrefix\space End of file `\outFileName'.% |
| 803 |
}}% |
| 804 |
} |
| 805 |
\def\usepreamble#1{\def\currentpreamble{#1}} |
| 806 |
\def\usepostamble#1{\def\currentpostamble{#1}} |
| 807 |
\def\nopreamble{\usepreamble\empty} |
| 808 |
\def\nopostamble{\usepostamble\empty} |
| 809 |
\def\preamble{\usepreamble\defaultpreamble |
| 810 |
\declarepreamble\defaultpreamble} |
| 811 |
\def\postamble{\usepostamble\defaultpostamble |
| 812 |
\declarepostamble\defaultpostamble} |
| 813 |
\declarepreamble\org@preamble |
| 814 |
|
| 815 |
IMPORTANT NOTICE: |
| 816 |
|
| 817 |
For the copyright see the source file. |
| 818 |
|
| 819 |
Any modified versions of this file must be renamed |
| 820 |
with new filenames distinct from \outFileName. |
| 821 |
|
| 822 |
For distribution of the original source see the terms |
| 823 |
for copying and modification in the file \inFileName. |
| 824 |
|
| 825 |
This generated file may be distributed as long as the |
| 826 |
original source files, as listed above, are part of the |
| 827 |
same distribution. (The sources need not necessarily be |
| 828 |
in the same archive or directory.) |
| 829 |
\endpreamble |
| 830 |
\edef\org@postamble{\string\endinput^^J% |
| 831 |
\MetaPrefix ^^J% |
| 832 |
\MetaPrefix\space End of file `\outFileName'.% |
| 833 |
} |
| 834 |
\let\defaultpreamble\org@preamble |
| 835 |
\let\defaultpostamble\org@postamble |
| 836 |
\usepreamble\defaultpreamble |
| 837 |
\usepostamble\defaultpostamble |
| 838 |
\declarepreamble\originaldefault |
| 839 |
|
| 840 |
IMPORTANT NOTICE: |
| 841 |
|
| 842 |
For the copyright see the source file. |
| 843 |
|
| 844 |
You are *not* allowed to modify this file. |
| 845 |
|
| 846 |
You are *not* allowed to distribute this file. |
| 847 |
For distribution of the original source see the terms |
| 848 |
for copying and modification in the file \inFileName. |
| 849 |
|
| 850 |
\endpreamble |
| 851 |
\def\WritePreamble#1{% |
| 852 |
\expandafter\ifx\csname pre@\@stripstring#1\endcsname\empty |
| 853 |
\else |
| 854 |
\edef\outFileName{\@stripstring#1}% |
| 855 |
\StreamPut#1{\csname pre@\@stripstring#1\endcsname}% |
| 856 |
\fi} |
| 857 |
\def\WritePostamble#1{% |
| 858 |
\expandafter\ifx\csname post@\@stripstring#1\endcsname\empty |
| 859 |
\else |
| 860 |
\edef\outFileName{\@stripstring#1}% |
| 861 |
\StreamPut#1{\csname post@\@stripstring#1\endcsname}% |
| 862 |
\fi} |
| 863 |
\def\usedir#1{\edef\destdir{\WriteToDir}} |
| 864 |
\def\showdirectory#1{\WriteToDir} |
| 865 |
\def\BaseDirectory#1{% |
| 866 |
\@setwritetodir |
| 867 |
\let\usedir\alt@usedir |
| 868 |
\let\showdirectory\showalt@directory |
| 869 |
\edef\basedir{#1\dirsep}} |
| 870 |
\def\convsep#1/#2\qStop{% |
| 871 |
#1\ifx\qStop#2\qStop \pesvnoc\fi\convsep\dirsep#2\qStop} |
| 872 |
\def\pesvnoc#1\qStop{\fi} |
| 873 |
\def\alt@usedir#1{% |
| 874 |
\Name\ifx{dir@#1}\relax |
| 875 |
\undefined@directory{#1}% |
| 876 |
\else |
| 877 |
\edef\destdir{\csname dir@#1\endcsname}% |
| 878 |
\fi} |
| 879 |
\def\showalt@directory#1{% |
| 880 |
\Name\ifx{dir@#1}\relax |
| 881 |
\showundef@directory{#1}% |
| 882 |
\else\csname dir@#1\endcsname\fi} |
| 883 |
\def\undefined@directory#1{% |
| 884 |
\errhelp{docstrip.cfg should specify a target directory for^^J% |
| 885 |
#1 using \DeclareDir or \UseTDS.}% |
| 886 |
\errmessage{You haven't defined the output directory for `#1'.^^J% |
| 887 |
Subsequent files will be written to the current directory}% |
| 888 |
\let\destdir\WriteToDir |
| 889 |
} |
| 890 |
\def\showundef@directory#1{UNDEFINED (label is #1)} |
| 891 |
\def\undefined@TDSdirectory#1{% |
| 892 |
\edef\destdir{% |
| 893 |
\basedir\convsep#1/\qStop |
| 894 |
}} |
| 895 |
\def\showundef@TDSdirectory#1{\basedir\convsep#1/\qStop} |
| 896 |
\def\UseTDS{% |
| 897 |
\@setwritetodir |
| 898 |
\let\undefined@directory\undefined@TDSdirectory |
| 899 |
\let\showundef@directory\showundef@TDSdirectory |
| 900 |
} |
| 901 |
\def\DeclareDir{\@ifnextchar*{\DeclareDirX}{\DeclareDirX\basedir*}} |
| 902 |
\def\DeclareDirX#1*#2#3{% |
| 903 |
\@setwritetodir |
| 904 |
\Name\edef{dir@#2}{#1#3}} |
| 905 |
\def\generateFile#1#2#3{{% |
| 906 |
\ifx t#2\askforoverwritetrue |
| 907 |
\else\askforoverwritefalse\fi |
| 908 |
\generate{\file{#1}{#3}}% |
| 909 |
}} |
| 910 |
\def\include#1{\def\Options{#1}} |
| 911 |
\def\processFile#1#2#3#4{% |
| 912 |
\generateFile{#1.#3}{#4}{\from{#1.#2}{\Options}}} |
| 913 |
\def\processfile{\Msg{% |
| 914 |
^^Jplease use \string\processFile\space instead of |
| 915 |
\string\processfile!^^J}% |
| 916 |
\processFile} |
| 917 |
\def\generatefile{\Msg{% |
| 918 |
^^Jplease use \string\generateFile\space instead of |
| 919 |
\string\generatefile!^^J}% |
| 920 |
\generateFile} |
| 921 |
\newcount\@maxfiles |
| 922 |
\def\maxfiles#1{% |
| 923 |
\@maxfiles#1\relax |
| 924 |
\ifnum\@maxfiles<4 |
| 925 |
\errhelp{I'm not a magician. I need at least four^^J% |
| 926 |
streams to be able to work properly, but^^J% |
| 927 |
you've only let me use \the\@maxfiles.}% |
| 928 |
\errmessage{\noexpand\maxfiles limit is too strict.}% |
| 929 |
\@maxfiles4 |
| 930 |
\fi |
| 931 |
} |
| 932 |
\maxfiles{1972} % year of my birth (MW) |
| 933 |
\newcount\@maxoutfiles |
| 934 |
\def\maxoutfiles#1{% |
| 935 |
\@maxoutfiles=#1\relax |
| 936 |
\ifnum\@maxoutfiles<1 |
| 937 |
\@maxoutfiles1 |
| 938 |
\errhelp{I'm not a magician. I need at least one output^^J% |
| 939 |
stream to be able to do anything useful at all.^^J% |
| 940 |
Please be reasonable.}% |
| 941 |
\errmessage{\noexpand\maxoutfiles limit is insane}% |
| 942 |
\fi |
| 943 |
} |
| 944 |
\maxoutfiles{16} |
| 945 |
\def\checkfilelimit{% |
| 946 |
\advance\@maxfiles\m@ne |
| 947 |
\ifnum\@maxfiles<2 % |
| 948 |
\errhelp{There aren't enough streams left to do any unpacking.^^J% |
| 949 |
I can't do anything about this, so complain at the^^J% |
| 950 |
person who made such a complicated installation.}% |
| 951 |
\errmessage{Too few streams left.}% |
| 952 |
\end |
| 953 |
\fi |
| 954 |
} |
| 955 |
\def\strip@meaning#1>{} |
| 956 |
\def\processbatchFile{% |
| 957 |
\checkfilelimit |
| 958 |
\let\next\relax |
| 959 |
\openin\inputcheck \batchfile\relax |
| 960 |
\ifeof\inputcheck |
| 961 |
\ifDefault |
| 962 |
\else |
| 963 |
\errhelp |
| 964 |
{A batchfile specified in \batchinput could not be found.}% |
| 965 |
\errmessage{^^J% |
| 966 |
**************************************************^^J% |
| 967 |
* Could not find your \string\batchfile=\batchfile.^^J% |
| 968 |
**************************************************}% |
| 969 |
\fi |
| 970 |
\else |
| 971 |
\ifDefault |
| 972 |
\Msg{**************************************************^^J% |
| 973 |
* Batchfile \DefaultbatchFile\space found Use it? (y/n)?}% |
| 974 |
\Ask\answer{% |
| 975 |
**************************************************}% |
| 976 |
\else |
| 977 |
\let\answer\y |
| 978 |
\fi |
| 979 |
\ifx\answer\y |
| 980 |
\closein\inputcheck |
| 981 |
\def\next{\@@input\batchfile\relax}% |
| 982 |
\fi |
| 983 |
\fi |
| 984 |
\next} |
| 985 |
\def\ReportTotals{% |
| 986 |
\ifnum\NumberOfFiles>\@ne |
| 987 |
\Msg{Overall statistics:^^J% |
| 988 |
Files \space processed: \the\NumberOfFiles^^J% |
| 989 |
Lines \space processed: \the\TotalprocessedLines^^J% |
| 990 |
Comments removed: \the\TotalcommentsRemoved^^J% |
| 991 |
Comments \space passed: \the\TotalcommentsPassed^^J% |
| 992 |
Codelines passed: \the\TotalcodeLinesPassed}% |
| 993 |
\fi} |
| 994 |
\def\SetFileNames{% |
| 995 |
\edef\sourceFileName{\MainFileName.\infileext}% |
| 996 |
\edef\destFileName{\MainFileName.\outfileext}} |
| 997 |
\def\CheckFileNames{% |
| 998 |
\ifx\sourceFileName\destFileName |
| 999 |
\Msg{^^J% |
| 1000 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J% |
| 1001 |
! It is not possible to read from and write to the same file !^^J% |
| 1002 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J}% |
| 1003 |
\Continuefalse |
| 1004 |
\else |
| 1005 |
\Continuetrue |
| 1006 |
\immediate\openin\inFile \sourceFileName\relax |
| 1007 |
\ifeof\inFile |
| 1008 |
\Msg{^^J% |
| 1009 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J% |
| 1010 |
! Your input file `\sourceFileName' was not found !^^J% |
| 1011 |
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!^^J}% |
| 1012 |
\Continuefalse |
| 1013 |
\else |
| 1014 |
\immediate\closein\inFile |
| 1015 |
\immediate\openin\inFile\destdir \destFileName\relax |
| 1016 |
\ifeof\inFile |
| 1017 |
\Continuetrue |
| 1018 |
\else |
| 1019 |
\Continuefalse |
| 1020 |
\Ask\answer{File \destdir\destFileName\space already |
| 1021 |
exists |
| 1022 |
\ifx\empty\destdir somewhere \fi |
| 1023 |
on the system.^^J% |
| 1024 |
Overwrite it% |
| 1025 |
\ifx\empty\destdir\space if necessary\fi |
| 1026 |
? [y/n]}% |
| 1027 |
\ifx\y \answer \Continuetrue \else |
| 1028 |
\ifx\yes\answer \Continuetrue \else |
| 1029 |
\fi\fi |
| 1030 |
\fi |
| 1031 |
\fi |
| 1032 |
\fi |
| 1033 |
\closein\inFile} |
| 1034 |
\def\interactive{% |
| 1035 |
\whileswitch\ifMoreFiles\fi% |
| 1036 |
{\begingroup |
| 1037 |
\AskQuestions |
| 1038 |
\forlist\MainFileName:=\filelist |
| 1039 |
\do |
| 1040 |
\SetFileNames |
| 1041 |
\CheckFileNames |
| 1042 |
\ifContinue |
| 1043 |
\generateFile{\destFileName}{f}% |
| 1044 |
{\from{\sourceFileName}{\Options}} |
| 1045 |
\fi% |
| 1046 |
\od |
| 1047 |
\endgroup |
| 1048 |
\Ask\answer{More files to process (y/n)?}% |
| 1049 |
\ifx\y \answer\MoreFilestrue \else |
| 1050 |
\ifx\yes\answer\MoreFilestrue \else |
| 1051 |
\MoreFilesfalse\fi\fi |
| 1052 |
}} |
| 1053 |
\def\AskQuestions{% |
| 1054 |
\Msg{^^J% |
| 1055 |
****************************************************}% |
| 1056 |
\Ask\infileext{% |
| 1057 |
* First type the extension of your input file(s): \space *}% |
| 1058 |
\Msg{****************************************************^^J^^J% |
| 1059 |
****************************************************}% |
| 1060 |
\Ask\outfileext{% |
| 1061 |
* Now type the extension of your output file(s) \space: *}% |
| 1062 |
\Msg{****************************************************^^J^^J% |
| 1063 |
****************************************************}% |
| 1064 |
\Ask\Options{% |
| 1065 |
* Now type the name(s) of option(s) to include \space\space: *}% |
| 1066 |
\Msg{****************************************************^^J^^J% |
| 1067 |
****************************************************^^J% |
| 1068 |
* Finally give the list of input file(s) without \space\space*}% |
| 1069 |
\Ask\filelist{% |
| 1070 |
* extension separated by commas if necessary % |
| 1071 |
\space\space\space\space: *}% |
| 1072 |
\Msg{****************************************************^^J}}% |
| 1073 |
\Msg{Utility: `docstrip' \fileversion\space <\filedate>^^J% |
| 1074 |
English documentation \space\space\space <\docdate>}% |
| 1075 |
\Msg{^^J% |
| 1076 |
**********************************************************^^J% |
| 1077 |
* This program converts documented macro-files into fast *^^J% |
| 1078 |
* loadable files by stripping off (nearly) all comments! *^^J% |
| 1079 |
**********************************************************^^J}% |
| 1080 |
\def\@setwritetodir{% |
| 1081 |
\let\setwritetodir\relax |
| 1082 |
\ifx\WriteToDir\@undefined |
| 1083 |
\ifx\@currdir\@undefined |
| 1084 |
\def\WriteToDir{}% |
| 1085 |
\else |
| 1086 |
\let\WriteToDir\@currdir |
| 1087 |
\fi |
| 1088 |
\fi |
| 1089 |
\let\destdir\WriteToDir |
| 1090 |
\def\tmp{[]}% |
| 1091 |
\ifx\tmp\WriteToDir |
| 1092 |
\ifx\dirsep\@undefined |
| 1093 |
\def\dirsep{.}% |
| 1094 |
\fi |
| 1095 |
\ifx\makepathname\@undefined |
| 1096 |
\def\makepathname##1{% |
| 1097 |
\edef\@pathname{\ifx\WriteToDir\destdir |
| 1098 |
\WriteToDir\else[\destdir]\fi##1}}% |
| 1099 |
\fi |
| 1100 |
\fi |
| 1101 |
\ifx\dirsep\@undefined |
| 1102 |
\def\dirsep{/}% |
| 1103 |
\def\tmp{:}% |
| 1104 |
\ifx\tmp\WriteToDir |
| 1105 |
\def\dirsep{:}% |
| 1106 |
\fi |
| 1107 |
\fi |
| 1108 |
\ifx\makepathname\@undefined |
| 1109 |
\def\makepathname##1{% |
| 1110 |
\edef\@pathname{\destdir\ifx\empty\destdir\else |
| 1111 |
\ifx\WriteToDir\destdir\else\dirsep\fi\fi##1}}% |
| 1112 |
\fi} |
| 1113 |
\immediate\openin\inputcheck=docstrip.cfg\relax |
| 1114 |
\ifeof\inputcheck |
| 1115 |
\Msg{% |
| 1116 |
********************************************************^^J% |
| 1117 |
* No Configuration file found, using default settings. *^^J% |
| 1118 |
********************************************************^^J}% |
| 1119 |
\else |
| 1120 |
\Msg{% |
| 1121 |
******************************************^^J% |
| 1122 |
* Using Configuration file docstrip.cfg. *^^J% |
| 1123 |
******************************************^^J}% |
| 1124 |
\closein\inputcheck |
| 1125 |
\afterfi{\@@input docstrip.cfg\relax} |
| 1126 |
\fi |
| 1127 |
\@setwritetodir |
| 1128 |
\def\process@first@batchfile{% |
| 1129 |
\processbatchFile |
| 1130 |
\ifnum\NumberOfFiles=\z@ |
| 1131 |
\interactive |
| 1132 |
\fi |
| 1133 |
\endbatchfile} |
| 1134 |
\def\endbatchfile{% |
| 1135 |
\iftopbatchfile |
| 1136 |
\ReportTotals |
| 1137 |
\expandafter\end |
| 1138 |
\else |
| 1139 |
\endinput |
| 1140 |
\fi} |
| 1141 |
\edef\@jobname{\lowercase{\def\noexpand\@jobname{\jobname}}}% |
| 1142 |
\@jobname |
| 1143 |
\def\@docstrip{docstrip}% |
| 1144 |
\edef\@docstrip{\expandafter\strip@meaning\meaning\@docstrip} |
| 1145 |
\Defaultfalse |
| 1146 |
\ifx\undefined\batchfile |
| 1147 |
\ifx\@jobname\@docstrip |
| 1148 |
\let\batchfile\DefaultbatchFile |
| 1149 |
\Defaulttrue |
| 1150 |
\else |
| 1151 |
\let\process@first@batchfile\relax |
| 1152 |
\fi |
| 1153 |
\fi |
| 1154 |
\process@first@batchfile |
| 1155 |
\endinput |
| 1156 |
%% |
| 1157 |
%% End of file `docstrip.tex'. |