home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / unix / volume26 / funnlweb / part07 < prev    next >
Encoding:
Text File  |  1993-04-10  |  116.3 KB  |  2,834 lines

  1. Newsgroups: comp.sources.unix
  2. From: ross@spam.adelaide.edu.au (Ross Williams)
  3. Subject: v26i127: funnelweb - a tool for literate programming in C, Part07/20
  4. Sender: unix-sources-moderator@vix.com
  5. Approved: paul@vix.com
  6.  
  7. Submitted-By: ross@spam.adelaide.edu.au (Ross Williams)
  8. Posting-Number: Volume 26, Issue 127
  9. Archive-Name: funnelweb/part07
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line, then unpack
  13. # it by saving it into a file and typing "sh file".  To overwrite existing
  14. # files, type "sh file -c".  You can also feed this as standard input via
  15. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  16. # will see the following message at the end:
  17. #        "End of archive 7 (of 20)."
  18. # Contents:  answers/ex11.tex answers/ex12.tex answers/ex14.tex
  19. #   answers/ex15.tex sources/option.c sources/table.c
  20. #   sources/texhead.ctx
  21. # Wrapped by vixie@gw.home.vix.com on Sun Apr 11 11:00:19 1993
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. if test -f 'answers/ex11.tex' -a "${1}" != "-c" ; then 
  24.   echo shar: Will not clobber existing file \"'answers/ex11.tex'\"
  25. else
  26. echo shar: Extracting \"'answers/ex11.tex'\" \(16100 characters\)
  27. sed "s/^X//" >'answers/ex11.tex' <<'END_OF_FILE'
  28. X
  29. X%*******************************************************************************
  30. X%*                    START OF AUTOMATICALLY GENERATED TEX FILE                *
  31. X%*******************************************************************************
  32. X%*                                                                             *
  33. X%* This TeX file was automatically generated by the FunnelWeb preprocessor.    *
  34. X%* You can typeset this file to produce printed documentation by running it    *
  35. X%* through the TeX typesetter using a command such as:                         *
  36. X%*    tex thisfilename                                                         *
  37. X%* The resultant file thisfilename.dvi can be printed using a command such as: *
  38. X%*    lpr -Pcslw -d thisfilename.dvi                                           *
  39. X%*                                                                             *
  40. X%* FunnelWeb is a preprocessor that allows programmers to weave programs and   *
  41. X%* their documentation together in a single document. The FunnelWeb program    *
  42. X%* analyses such documents producing both program files and typeset            *
  43. X%* documentation such as this TeX file.                                        *
  44. X%* FunnelWeb was created by Ross Williams.                                     *
  45. X%*                                                                             *
  46. X%* For more information on FunnelWeb look in the following FTP archive:        *
  47. X%*    Machine  : sirius.itd.adelaide.edu.au [IP=129.127.40.3].                 *
  48. X%*    Directory: ~pub/funnelweb/                                               *
  49. X%*               (or some other appropriately named directory).                *
  50. X%* or email Ross Williams at ross@spam.adelaide.edu.au                         *
  51. X%*                                                                             *
  52. X%*******************************************************************************
  53. X
  54. X
  55. X%===================== Start of FunnelWeb TeX Definitions ======================
  56. X
  57. X
  58. X% Version
  59. X% -------
  60. X% This is FunnelWeb TeX Macro Library Version 1.0.
  61. X
  62. X
  63. X% Copyright
  64. X% ---------
  65. X% This set of FunnelWeb TeX definitions was written by Ross Williams and was
  66. X% originally Copyright (C) 1992 Ross N. Williams.  However, I, Ross Williams,
  67. X% hereby forego any claim to Copyright in this set of FunnelWeb TeX definitions
  68. X% and hereby authorize that the set of TeX definitions pass into the public
  69. X% domain. -- Ross N. Williams, 3:41pm 07-May-1992, Adelaide, Australia.
  70. X
  71. X
  72. X% Modification
  73. X% ------------
  74. X% Please record all modifications to these TeX definitions here. Unless
  75. X% otherwise specified, all modified definitions fall in the public domain too.
  76. X%
  77. X% Programmers:
  78. X%    RNW  Ross N. Williams  ross@spam.adelaide.edu.au
  79. X%
  80. X% Changes:
  81. X%    07-May-1992  RNW  Prepared this work for public domain release.
  82. X%
  83. X
  84. X
  85. X% General Comments
  86. X% ----------------
  87. X% This set of TeX definitions exists for two reasons:
  88. X%
  89. X%    1. To shorten and neaten the FunnelWeb TeX output.
  90. X%    2. To allow users to fiddle with the output format in their input files
  91. X%       (by inserting redefining "\def"s) without having to resort to
  92. X%       modifying the FunnelWeb code.
  93. X%
  94. X% The user is warned that these definitions may be changed from time to time
  95. X% (but probably not much). The user should not be too sneaky. In particular,
  96. X% users wishing to redefine some of these macros should do so in an explicitly
  97. X% defined section at the top of their input file. This will mean that in the
  98. X% event of problems, that section can simply be deleted or commented out to
  99. X% allow the document to at least be typeset in the default format. Users should
  100. X% limit themselves to redefining these macros in such a section and should
  101. X% refrain from using the macros throughout their documents.
  102. X
  103. X
  104. X% Environment Parameters
  105. X% ----------------------
  106. X% \tolerance tells TeX how tolerant it should be about making bad line and
  107. X% page breaks. Here we set it to it's maximum, as
  108. X%   1) Computer programs are likely to cause lots of bad breaks.
  109. X%   2) In most cases the user would probably rather get the TeX file through
  110. X%      TeX without any errors than fiddle with spacings for perfection.
  111. X\tolerance=10000
  112. X
  113. X% I don't like indentation as it makes the page look more busy. Instead,
  114. X% paragraphs are separated by a little space (see next).
  115. X\parindent=0pt
  116. X
  117. X% In many cases, users will produce documents with long runs of paragraphs.
  118. X% In order to space out these paragraphs, it is convenient to maintain a
  119. X% prevailing non-zero \parskip (end-of-paragaph skip). The only trouble is
  120. X% that the skip becomes a problem in macro definitions which require no skip
  121. X% and so we have to turn the skip on and off. The following two macros
  122. X% simplify this process.
  123. X\def\fwparskipon{\parskip=\medskipamount}
  124. X\def\fwparskipoff{\parskip=0pt}
  125. X\fwparskipon
  126. X
  127. X% Setting raggedbottom allows TeX to leave a bit of space at the bottom of the
  128. X% page in order to better vertically align the rest of the page (e.g. skips
  129. X% won't stretch as much). It also means that headings are less likely to be
  130. X% isolated at the bottom of the page without any following text.
  131. X\raggedbottom
  132. X
  133. X
  134. X% Fonts
  135. X% -----
  136. X% Most of the typeset output is set in 10pt roman and 10pt tt font.
  137. X% The major extra font needs spring from titles and headings.
  138. X% For portability's sake we use only the following fonts:
  139. X%    cmr10
  140. X%    cmbx10
  141. X%    cmtt10
  142. X% and some enlargements of them. These fonts are all "standard" fonts
  143. X% in Plain TeX. See The TeXbook p.350.
  144. X\font\fwfontnote=cmr7
  145. X
  146. X\font\fwfontnorm=cmr10
  147. X\font\fwfontnorma=cmr10 scaled \magstep1
  148. X\font\fwfontnormb=cmr10 scaled \magstep2
  149. X
  150. X\font\fwfontbold=cmbx10
  151. X\font\fwfontbolda=cmbx10 scaled \magstep1
  152. X\font\fwfontboldb=cmbx10 scaled \magstep2
  153. X\font\fwfontboldc=cmbx10 scaled \magstep3
  154. X\font\fwfontboldd=cmbx10 scaled \magstep4
  155. X
  156. X
  157. X% Macros for Stylistic Details
  158. X% ----------------------------
  159. X% This section contains all the fiddly little macros for setting the details
  160. X% of each macro definition.
  161. X
  162. X% Macro definitions are sandwiched by calls to these macros which can be used
  163. X% to sort out the spacing before and after the macro definition.
  164. X\def\fwbeginmacro{\fwparskipoff\bigskip}
  165. X\def\fwendmacro{\fwparskipon\par}
  166. X
  167. X% These macros deal with the macro name and definition line.
  168. X\def\fwmacroname#1#2{{\sl #1\/}$\lbrack$#2$\rbrack$}
  169. X\def\fwfilename#1#2{{\bf #1}$\lbrack$#2$\rbrack$}
  170. X\def\fwzero#1{{\bf Z}}
  171. X\def\fwmany#1{{\bf M}}
  172. X\def\fwequals{ $\equiv$}
  173. X\def\fwplusequals{ $+\equiv$}
  174. X
  175. X% Now for the actual body of the definition. It looks nice to have the tt
  176. X% code indented a little. Again, we use macros instead of writing direct TeX,
  177. X% so as to allow the user to fiddle this stuff to taste without having to
  178. X% modify the FunnelWeb C code.
  179. X\def\fwodef{\parindent=15pt\vskip0pt$\lbrace$\parindent=20pt}
  180. X\def\fwcdef{$\rbrace$\vskip0pt\parindent=0pt}
  181. X\def\fwoquote{`}
  182. X\def\fwcquote{'}
  183. X\def\fwoparen{$($}
  184. X\def\fwcomma{$,$}
  185. X\def\fwcparen{$)$}
  186. X\def\fwparam#1{$\diamond #1$}
  187. X\def\fwparams#1{$(\diamond #1)$}
  188. X
  189. X% These macros deal with the notes that are appended at the end of each
  190. X% macro definition. Note that even though \fwisafile,\fwusedin, and \fwseealso
  191. X% have the same definition, they are given different names so as to allow the
  192. X% user to redefine these macros to typeset each kind of information differently
  193. X% if desired.
  194. X\def\fwbeginmacronotes{\begingroup\baselineskip=9pt\smallskip}
  195. X\def\fwnote#1{{\fwfontnote #1}\par}
  196. X\def\fwisafile#1{\fwnote{#1}}
  197. X\def\fwusedin#1{\fwnote{#1}}
  198. X\def\fwseealso#1{\fwnote{#1}}
  199. X\def\fwendmacronotes{\endgroup}
  200. X
  201. X
  202. X% Macros to Typeset Program Code Verbatim
  203. X% ---------------------------------------
  204. X% This is by far the hairiest and most difficult part of the typesetting task
  205. X% because we have to turn off most of TeX's natural instincts in order to
  206. X% typeset the program text exactly as it appears in the input file.
  207. X% Two macros are defined to pull this off: \fwbtx and \fwverbatimgobble.
  208. X% Their code was inspired by the following sections of "The TeXbook":
  209. X%    Appendix D: Dirty Tricks, 3.Verbatim listing, p.380-382.
  210. X%    Appendix E: Example Formats, p.421.
  211. X% The \fwbtx[ (for "FunnelWeb Begin TeXt") macro does most of the hard work.
  212. X% The liberal use of "%" is because I don't understand TeX well enough to
  213. X% understand when an end of line will cause trouble, and I am playing it safe.
  214. X
  215. X% Before defining the main \fwbtx macro, we have to stash away some definitions
  216. X% in the hidden part of TeX's environment. Let's hope that these "hidden"
  217. X% definitions don't affect anything except what is desired to be affected.
  218. X
  219. X% The tt font in which we wish to set the text has two Latin lurking ligatures!
  220. X% These are ?` and !`. To disable them, we define the left quote when ACTIVE
  221. X% to be defined in such a way as to prevent ligatures. The main TeX text will
  222. X% normally not be exposed to this definition because normally the leftquote
  223. X% character is not active. The \fwbtx macro temporarily makes the left quote
  224. X% character active thus activating the deactivation of left quote ligatures.
  225. X% See The TeXbook p.381.
  226. X{\catcode`\`=\active \gdef`{\relax\lq}}
  227. X
  228. X% TeX is fairly carefree about spaces and so we have to make it more serious.
  229. X% To do so we pull the same trick as above, setting up a definition for active
  230. X% space, but only making space active during the span of the verbatim text.
  231. X% In Plain TeX the active space is defined to be simply a space, but here we
  232. X% define it to be a control space. This ensures that the space cannot
  233. X% be gobbled up by one of TeX's mysterious mechanisms when activated.
  234. X% See The TeXbook, p.381 and p.352.
  235. X{\obeyspaces\global\let =\ }
  236. X
  237. X% Here is the main \fwbtx verbatim text macro.
  238. X% Note: The order in which all these pieces of business have to be done is
  239. X% still a partial mystery to me. Don't fiddle with this stuff unless you
  240. X% think you know what you are doing.
  241. X\def\fwbtx[{%
  242. X%
  243. X% The funnies involved in getting verbatim output are safely housed inside
  244. X% this \begingroup, and the \endgroup in \fwverbatimgobble. Groups are used
  245. X% instead of curly braces because we have to be able to signal the end of
  246. X% this macro with a curly brace.
  247. X\begingroup%
  248. X%
  249. X% \pars at the end of empty lines in the verbatim text won't come out normally
  250. X% because TeX is in vertical mode and they get gobbled up. To prevent this,
  251. X% we force \par to exit vertical mode first. See The TeXbook p.381.
  252. X\def\par{\leavevmode\endgraf}%
  253. X%
  254. X% Activate the leftquote character so as to avoid ligatures (see above).
  255. X\catcode`\`=\active%
  256. X%
  257. X% The \obeylines macro simply defines end of line (^M) to be \par. This ensures
  258. X% that TeX will treat each verbatim line as a new paragraph.
  259. X\obeylines%
  260. X%
  261. X% To get verbatim output, we have to desex all the special characters. This
  262. X% is explained in detail in The TeXbook p.380.
  263. X\def\do##1{\catcode`##1=12 }\dospecials%
  264. X%
  265. X% Activate the space character so as to make TeX treat blanks seriously.
  266. X% This activation invokes an eralier definition (see above).
  267. X\obeyspaces
  268. X%
  269. X% Interparagraph skips do not help the cause.
  270. X% Note: We have to preserve the indentation though, as the code is actually
  271. X% indented in the final output. See \fwodef in an earlier section.
  272. X\parskip=0pt%
  273. X%
  274. X% We typeset the verbatim text in tt font (courier on the Macintosh) for a
  275. X% number of reasons:
  276. X%    - tt font has the same horizontal spacing for each character.
  277. X%    - tt font covers the ASCII character set.
  278. X%    - tt font doesn't have many surprises (e.g. ligatures).
  279. X%    - tt font looks much what you might see on a computer terminal screen.
  280. X\tt%
  281. X%
  282. X% Having set up an environment for verbatim, we are ready to use it.
  283. X% By invoking \fwverbatimgobble, this \fwbtx macro gobbles up text verbatim (as
  284. X% part of the parameter of \fwverbatimgobble) until it sees the termination
  285. X% string "]fwetx=" (the "=" was thrown in to add obscurity as this sequence
  286. X% must never occur in the verbatim text).
  287. X\fwverbatimgobble}
  288. X
  289. X% The \fwverbatimgobble macro exists to allow \fwbtx to bracket verbatim text.
  290. X\def\fwverbatimgobble#1]fwetx={#1\endgroup}
  291. X
  292. X
  293. X% Table of Contents
  294. X% -----------------
  295. X% The five levels of table of contents that FunnelWeb supports are identified
  296. X% by the five letters [A..E]. These are used throughout the following macros.
  297. X
  298. X% The following macros are utilities to the TOC macros to follow.
  299. X\def\fwrule{\medskip\hrule\medskip}
  300. X\def\fwqh{\hskip1.5em\relax}
  301. X\def\fwbeforesec{\penalty-200\bigskip\medskip\par}
  302. X
  303. X% The following macros are used to typeset the table of contents.
  304. X\def\fwtocstart#1{\fwrule\leftline{\fwfontbolda Table of Contents}\fwrule}
  305. X\def\fwtoca#1#2{\leftline{{\bf #1 #2}}}
  306. X\def\fwtocb#1#2{\leftline{\fwqh #1 #2}}
  307. X\def\fwtocc#1#2{\leftline{\fwqh\fwqh #1 #2}}
  308. X\def\fwtocd#1#2{\leftline{\fwqh\fwqh\fwqh #1 #2}}
  309. X\def\fwtoce#1#2{\leftline{\fwqh\fwqh\fwqh\fwqh #1 #2}}
  310. X\def\fwtocfinish#1{\fwrule}
  311. X
  312. X% The following "library" macros define five different strengths of headings
  313. X% which can be used later in the section macros.
  314. X\def\fwliba#1#2{\vfill\eject{\fwfontboldc #1 #2}\penalty200\smallskip}
  315. X\def\fwlibb#1#2{\fwbeforesec{\fwfontboldb #1 #2}\penalty200\smallskip}
  316. X\def\fwlibc#1#2{\fwbeforesec{\fwfontnormb #1 #2}\penalty200\smallskip}
  317. X\def\fwlibd#1#2{\fwbeforesec{\bf          #1 #2}\penalty200}
  318. X\def\fwlibe#1#2{\fwbeforesec{\bf          #1 #2}}
  319. X
  320. X% Here are the macros that actually typeset the section headings throughout
  321. X% the document. The fwlib system has been employed so as to easily allow the
  322. X% user to redefine the strengths of headings to taste. For example, the
  323. X% user could insert in the input document a similar set of definitions to these
  324. X% but with the b..e headings set to \fwlibc. This would tone down the output.
  325. X\def\fwseca#1#2{\fwliba{#1}{#2}}
  326. X\def\fwsecb#1#2{\fwlibb{#1}{#2}}
  327. X\def\fwsecc#1#2{\fwlibc{#1}{#2}}
  328. X\def\fwsecd#1#2{\fwlibd{#1}{#2}}
  329. X\def\fwsece#1#2{\fwlibe{#1}{#2}}
  330. X
  331. X
  332. X% Support for Explicit Typesetting
  333. X% --------------------------------
  334. X% FunnelWeb supports pragmas and other constructs that allow
  335. X% typesetter-independent typesetting commands to be given. The
  336. X% following macros support these features.
  337. X
  338. X% The in-text literal @{sloth@} and emphasise @[walrus@] features.
  339. X\def\fwlit#1{{\tt #1}}
  340. X\def\fwemp#1{{\it #1}}
  341. X
  342. X% The "@p new_page" pragma.
  343. X\def\fwnewpage{\vfill\eject}
  344. X
  345. X% The "@p vskip Nmm" pragma.
  346. X\def\fwvskip#1{\null\vskip #1mm}
  347. X
  348. X% The "@p title <font> <align> <text>" pragma.
  349. X\def\fwfontnormal#1{{\fwfontnorm {#1}}}
  350. X\def\fwfonttitle#1{{\fwfontboldd {#1}}}
  351. X\def\fwfontsmalltitle#1{{\fwfontboldb {#1}}}
  352. X\def\fwleftline#1{\leftline{#1}}
  353. X\def\fwcenterline#1{\centerline{#1}}
  354. X\def\fwrightline#1{\rightline{#1}}
  355. X
  356. X
  357. X% Support for Old FunnelWeb
  358. X% -------------------------
  359. X% The following macros were used extensively in the first version of
  360. X% FunnelWeb and are retained so that these older input files will still
  361. X% typeset cleanly.
  362. X\def\p#1{{\tt #1}}  % P for Program text.
  363. X\def\flagpage#1#2{
  364. X   \null
  365. X   \vfill
  366. X   \centerline{\fwfontboldd #1}
  367. X   \vskip 1cm
  368. X   \centerline{\fwfontboldd #2}
  369. X   \vfill
  370. X   \null
  371. X   \vfill
  372. X}
  373. X
  374. X%====================== End of FunnelWeb TeX Definitions =======================
  375. XEX11: This example shows how FunnelWeb typesets macros, typesetter commands
  376. X      and free text.
  377. X
  378. You are reading some free text before the macro. Free text can consist
  379. of any text (not containing the FunnelWeb special character) including
  380. typesetter commands
  381. such as \$, \%, \#, and $\backslash$TeX$\{$$\}$ which
  382. will be typeset to appear exactly as they do in the input file!
  383. Look out! Here comes a macro!
  384. X
  385. X\fwbeginmacro
  386. X\fwfilename{ex11.out}{1}\fwequals \fwodef \fwbtx[This text is part of
  387. a macro definition.
  388. X]fwetx=%
  389. X\fwcdef 
  390. X\fwbeginmacronotes
  391. X\fwisafile{This macro is attached to an output file.}
  392. X\fwendmacronotes
  393. X\fwendmacro
  394. X
  395. X
  396. This is free text following the macro. This sentence contains
  397. two \fwlit{inline} typesetter \fwemp{directives}.
  398. Now here is a non-inline typesetting directive.
  399. X
  400. X
  401. X\fwnewpage
  402. X
  403. X
  404. This sentence will appear on the next page.
  405. X\bye
  406. X
  407. X
  408. X%*******************************************************************************
  409. X%*                    END OF AUTOMATICALLY GENERATED TEX FILE                  *
  410. X%*******************************************************************************
  411. X
  412. END_OF_FILE
  413. if test 16100 -ne `wc -c <'answers/ex11.tex'`; then
  414.     echo shar: \"'answers/ex11.tex'\" unpacked with wrong size!
  415. fi
  416. # end of 'answers/ex11.tex'
  417. fi
  418. if test -f 'answers/ex12.tex' -a "${1}" != "-c" ; then 
  419.   echo shar: Will not clobber existing file \"'answers/ex12.tex'\"
  420. else
  421. echo shar: Extracting \"'answers/ex12.tex'\" \(16184 characters\)
  422. sed "s/^X//" >'answers/ex12.tex' <<'END_OF_FILE'
  423. X
  424. X%*******************************************************************************
  425. X%*                    START OF AUTOMATICALLY GENERATED TEX FILE                *
  426. X%*******************************************************************************
  427. X%*                                                                             *
  428. X%* This TeX file was automatically generated by the FunnelWeb preprocessor.    *
  429. X%* You can typeset this file to produce printed documentation by running it    *
  430. X%* through the TeX typesetter using a command such as:                         *
  431. X%*    tex thisfilename                                                         *
  432. X%* The resultant file thisfilename.dvi can be printed using a command such as: *
  433. X%*    lpr -Pcslw -d thisfilename.dvi                                           *
  434. X%*                                                                             *
  435. X%* FunnelWeb is a preprocessor that allows programmers to weave programs and   *
  436. X%* their documentation together in a single document. The FunnelWeb program    *
  437. X%* analyses such documents producing both program files and typeset            *
  438. X%* documentation such as this TeX file.                                        *
  439. X%* FunnelWeb was created by Ross Williams.                                     *
  440. X%*                                                                             *
  441. X%* For more information on FunnelWeb look in the following FTP archive:        *
  442. X%*    Machine  : sirius.itd.adelaide.edu.au [IP=129.127.40.3].                 *
  443. X%*    Directory: ~pub/funnelweb/                                               *
  444. X%*               (or some other appropriately named directory).                *
  445. X%* or email Ross Williams at ross@spam.adelaide.edu.au                         *
  446. X%*                                                                             *
  447. X%*******************************************************************************
  448. X
  449. X
  450. X%===================== Start of FunnelWeb TeX Definitions ======================
  451. X
  452. X
  453. X% Version
  454. X% -------
  455. X% This is FunnelWeb TeX Macro Library Version 1.0.
  456. X
  457. X
  458. X% Copyright
  459. X% ---------
  460. X% This set of FunnelWeb TeX definitions was written by Ross Williams and was
  461. X% originally Copyright (C) 1992 Ross N. Williams.  However, I, Ross Williams,
  462. X% hereby forego any claim to Copyright in this set of FunnelWeb TeX definitions
  463. X% and hereby authorize that the set of TeX definitions pass into the public
  464. X% domain. -- Ross N. Williams, 3:41pm 07-May-1992, Adelaide, Australia.
  465. X
  466. X
  467. X% Modification
  468. X% ------------
  469. X% Please record all modifications to these TeX definitions here. Unless
  470. X% otherwise specified, all modified definitions fall in the public domain too.
  471. X%
  472. X% Programmers:
  473. X%    RNW  Ross N. Williams  ross@spam.adelaide.edu.au
  474. X%
  475. X% Changes:
  476. X%    07-May-1992  RNW  Prepared this work for public domain release.
  477. X%
  478. X
  479. X
  480. X% General Comments
  481. X% ----------------
  482. X% This set of TeX definitions exists for two reasons:
  483. X%
  484. X%    1. To shorten and neaten the FunnelWeb TeX output.
  485. X%    2. To allow users to fiddle with the output format in their input files
  486. X%       (by inserting redefining "\def"s) without having to resort to
  487. X%       modifying the FunnelWeb code.
  488. X%
  489. X% The user is warned that these definitions may be changed from time to time
  490. X% (but probably not much). The user should not be too sneaky. In particular,
  491. X% users wishing to redefine some of these macros should do so in an explicitly
  492. X% defined section at the top of their input file. This will mean that in the
  493. X% event of problems, that section can simply be deleted or commented out to
  494. X% allow the document to at least be typeset in the default format. Users should
  495. X% limit themselves to redefining these macros in such a section and should
  496. X% refrain from using the macros throughout their documents.
  497. X
  498. X
  499. X% Environment Parameters
  500. X% ----------------------
  501. X% \tolerance tells TeX how tolerant it should be about making bad line and
  502. X% page breaks. Here we set it to it's maximum, as
  503. X%   1) Computer programs are likely to cause lots of bad breaks.
  504. X%   2) In most cases the user would probably rather get the TeX file through
  505. X%      TeX without any errors than fiddle with spacings for perfection.
  506. X\tolerance=10000
  507. X
  508. X% I don't like indentation as it makes the page look more busy. Instead,
  509. X% paragraphs are separated by a little space (see next).
  510. X\parindent=0pt
  511. X
  512. X% In many cases, users will produce documents with long runs of paragraphs.
  513. X% In order to space out these paragraphs, it is convenient to maintain a
  514. X% prevailing non-zero \parskip (end-of-paragaph skip). The only trouble is
  515. X% that the skip becomes a problem in macro definitions which require no skip
  516. X% and so we have to turn the skip on and off. The following two macros
  517. X% simplify this process.
  518. X\def\fwparskipon{\parskip=\medskipamount}
  519. X\def\fwparskipoff{\parskip=0pt}
  520. X\fwparskipon
  521. X
  522. X% Setting raggedbottom allows TeX to leave a bit of space at the bottom of the
  523. X% page in order to better vertically align the rest of the page (e.g. skips
  524. X% won't stretch as much). It also means that headings are less likely to be
  525. X% isolated at the bottom of the page without any following text.
  526. X\raggedbottom
  527. X
  528. X
  529. X% Fonts
  530. X% -----
  531. X% Most of the typeset output is set in 10pt roman and 10pt tt font.
  532. X% The major extra font needs spring from titles and headings.
  533. X% For portability's sake we use only the following fonts:
  534. X%    cmr10
  535. X%    cmbx10
  536. X%    cmtt10
  537. X% and some enlargements of them. These fonts are all "standard" fonts
  538. X% in Plain TeX. See The TeXbook p.350.
  539. X\font\fwfontnote=cmr7
  540. X
  541. X\font\fwfontnorm=cmr10
  542. X\font\fwfontnorma=cmr10 scaled \magstep1
  543. X\font\fwfontnormb=cmr10 scaled \magstep2
  544. X
  545. X\font\fwfontbold=cmbx10
  546. X\font\fwfontbolda=cmbx10 scaled \magstep1
  547. X\font\fwfontboldb=cmbx10 scaled \magstep2
  548. X\font\fwfontboldc=cmbx10 scaled \magstep3
  549. X\font\fwfontboldd=cmbx10 scaled \magstep4
  550. X
  551. X
  552. X% Macros for Stylistic Details
  553. X% ----------------------------
  554. X% This section contains all the fiddly little macros for setting the details
  555. X% of each macro definition.
  556. X
  557. X% Macro definitions are sandwiched by calls to these macros which can be used
  558. X% to sort out the spacing before and after the macro definition.
  559. X\def\fwbeginmacro{\fwparskipoff\bigskip}
  560. X\def\fwendmacro{\fwparskipon\par}
  561. X
  562. X% These macros deal with the macro name and definition line.
  563. X\def\fwmacroname#1#2{{\sl #1\/}$\lbrack$#2$\rbrack$}
  564. X\def\fwfilename#1#2{{\bf #1}$\lbrack$#2$\rbrack$}
  565. X\def\fwzero#1{{\bf Z}}
  566. X\def\fwmany#1{{\bf M}}
  567. X\def\fwequals{ $\equiv$}
  568. X\def\fwplusequals{ $+\equiv$}
  569. X
  570. X% Now for the actual body of the definition. It looks nice to have the tt
  571. X% code indented a little. Again, we use macros instead of writing direct TeX,
  572. X% so as to allow the user to fiddle this stuff to taste without having to
  573. X% modify the FunnelWeb C code.
  574. X\def\fwodef{\parindent=15pt\vskip0pt$\lbrace$\parindent=20pt}
  575. X\def\fwcdef{$\rbrace$\vskip0pt\parindent=0pt}
  576. X\def\fwoquote{`}
  577. X\def\fwcquote{'}
  578. X\def\fwoparen{$($}
  579. X\def\fwcomma{$,$}
  580. X\def\fwcparen{$)$}
  581. X\def\fwparam#1{$\diamond #1$}
  582. X\def\fwparams#1{$(\diamond #1)$}
  583. X
  584. X% These macros deal with the notes that are appended at the end of each
  585. X% macro definition. Note that even though \fwisafile,\fwusedin, and \fwseealso
  586. X% have the same definition, they are given different names so as to allow the
  587. X% user to redefine these macros to typeset each kind of information differently
  588. X% if desired.
  589. X\def\fwbeginmacronotes{\begingroup\baselineskip=9pt\smallskip}
  590. X\def\fwnote#1{{\fwfontnote #1}\par}
  591. X\def\fwisafile#1{\fwnote{#1}}
  592. X\def\fwusedin#1{\fwnote{#1}}
  593. X\def\fwseealso#1{\fwnote{#1}}
  594. X\def\fwendmacronotes{\endgroup}
  595. X
  596. X
  597. X% Macros to Typeset Program Code Verbatim
  598. X% ---------------------------------------
  599. X% This is by far the hairiest and most difficult part of the typesetting task
  600. X% because we have to turn off most of TeX's natural instincts in order to
  601. X% typeset the program text exactly as it appears in the input file.
  602. X% Two macros are defined to pull this off: \fwbtx and \fwverbatimgobble.
  603. X% Their code was inspired by the following sections of "The TeXbook":
  604. X%    Appendix D: Dirty Tricks, 3.Verbatim listing, p.380-382.
  605. X%    Appendix E: Example Formats, p.421.
  606. X% The \fwbtx[ (for "FunnelWeb Begin TeXt") macro does most of the hard work.
  607. X% The liberal use of "%" is because I don't understand TeX well enough to
  608. X% understand when an end of line will cause trouble, and I am playing it safe.
  609. X
  610. X% Before defining the main \fwbtx macro, we have to stash away some definitions
  611. X% in the hidden part of TeX's environment. Let's hope that these "hidden"
  612. X% definitions don't affect anything except what is desired to be affected.
  613. X
  614. X% The tt font in which we wish to set the text has two Latin lurking ligatures!
  615. X% These are ?` and !`. To disable them, we define the left quote when ACTIVE
  616. X% to be defined in such a way as to prevent ligatures. The main TeX text will
  617. X% normally not be exposed to this definition because normally the leftquote
  618. X% character is not active. The \fwbtx macro temporarily makes the left quote
  619. X% character active thus activating the deactivation of left quote ligatures.
  620. X% See The TeXbook p.381.
  621. X{\catcode`\`=\active \gdef`{\relax\lq}}
  622. X
  623. X% TeX is fairly carefree about spaces and so we have to make it more serious.
  624. X% To do so we pull the same trick as above, setting up a definition for active
  625. X% space, but only making space active during the span of the verbatim text.
  626. X% In Plain TeX the active space is defined to be simply a space, but here we
  627. X% define it to be a control space. This ensures that the space cannot
  628. X% be gobbled up by one of TeX's mysterious mechanisms when activated.
  629. X% See The TeXbook, p.381 and p.352.
  630. X{\obeyspaces\global\let =\ }
  631. X
  632. X% Here is the main \fwbtx verbatim text macro.
  633. X% Note: The order in which all these pieces of business have to be done is
  634. X% still a partial mystery to me. Don't fiddle with this stuff unless you
  635. X% think you know what you are doing.
  636. X\def\fwbtx[{%
  637. X%
  638. X% The funnies involved in getting verbatim output are safely housed inside
  639. X% this \begingroup, and the \endgroup in \fwverbatimgobble. Groups are used
  640. X% instead of curly braces because we have to be able to signal the end of
  641. X% this macro with a curly brace.
  642. X\begingroup%
  643. X%
  644. X% \pars at the end of empty lines in the verbatim text won't come out normally
  645. X% because TeX is in vertical mode and they get gobbled up. To prevent this,
  646. X% we force \par to exit vertical mode first. See The TeXbook p.381.
  647. X\def\par{\leavevmode\endgraf}%
  648. X%
  649. X% Activate the leftquote character so as to avoid ligatures (see above).
  650. X\catcode`\`=\active%
  651. X%
  652. X% The \obeylines macro simply defines end of line (^M) to be \par. This ensures
  653. X% that TeX will treat each verbatim line as a new paragraph.
  654. X\obeylines%
  655. X%
  656. X% To get verbatim output, we have to desex all the special characters. This
  657. X% is explained in detail in The TeXbook p.380.
  658. X\def\do##1{\catcode`##1=12 }\dospecials%
  659. X%
  660. X% Activate the space character so as to make TeX treat blanks seriously.
  661. X% This activation invokes an eralier definition (see above).
  662. X\obeyspaces
  663. X%
  664. X% Interparagraph skips do not help the cause.
  665. X% Note: We have to preserve the indentation though, as the code is actually
  666. X% indented in the final output. See \fwodef in an earlier section.
  667. X\parskip=0pt%
  668. X%
  669. X% We typeset the verbatim text in tt font (courier on the Macintosh) for a
  670. X% number of reasons:
  671. X%    - tt font has the same horizontal spacing for each character.
  672. X%    - tt font covers the ASCII character set.
  673. X%    - tt font doesn't have many surprises (e.g. ligatures).
  674. X%    - tt font looks much what you might see on a computer terminal screen.
  675. X\tt%
  676. X%
  677. X% Having set up an environment for verbatim, we are ready to use it.
  678. X% By invoking \fwverbatimgobble, this \fwbtx macro gobbles up text verbatim (as
  679. X% part of the parameter of \fwverbatimgobble) until it sees the termination
  680. X% string "]fwetx=" (the "=" was thrown in to add obscurity as this sequence
  681. X% must never occur in the verbatim text).
  682. X\fwverbatimgobble}
  683. X
  684. X% The \fwverbatimgobble macro exists to allow \fwbtx to bracket verbatim text.
  685. X\def\fwverbatimgobble#1]fwetx={#1\endgroup}
  686. X
  687. X
  688. X% Table of Contents
  689. X% -----------------
  690. X% The five levels of table of contents that FunnelWeb supports are identified
  691. X% by the five letters [A..E]. These are used throughout the following macros.
  692. X
  693. X% The following macros are utilities to the TOC macros to follow.
  694. X\def\fwrule{\medskip\hrule\medskip}
  695. X\def\fwqh{\hskip1.5em\relax}
  696. X\def\fwbeforesec{\penalty-200\bigskip\medskip\par}
  697. X
  698. X% The following macros are used to typeset the table of contents.
  699. X\def\fwtocstart#1{\fwrule\leftline{\fwfontbolda Table of Contents}\fwrule}
  700. X\def\fwtoca#1#2{\leftline{{\bf #1 #2}}}
  701. X\def\fwtocb#1#2{\leftline{\fwqh #1 #2}}
  702. X\def\fwtocc#1#2{\leftline{\fwqh\fwqh #1 #2}}
  703. X\def\fwtocd#1#2{\leftline{\fwqh\fwqh\fwqh #1 #2}}
  704. X\def\fwtoce#1#2{\leftline{\fwqh\fwqh\fwqh\fwqh #1 #2}}
  705. X\def\fwtocfinish#1{\fwrule}
  706. X
  707. X% The following "library" macros define five different strengths of headings
  708. X% which can be used later in the section macros.
  709. X\def\fwliba#1#2{\vfill\eject{\fwfontboldc #1 #2}\penalty200\smallskip}
  710. X\def\fwlibb#1#2{\fwbeforesec{\fwfontboldb #1 #2}\penalty200\smallskip}
  711. X\def\fwlibc#1#2{\fwbeforesec{\fwfontnormb #1 #2}\penalty200\smallskip}
  712. X\def\fwlibd#1#2{\fwbeforesec{\bf          #1 #2}\penalty200}
  713. X\def\fwlibe#1#2{\fwbeforesec{\bf          #1 #2}}
  714. X
  715. X% Here are the macros that actually typeset the section headings throughout
  716. X% the document. The fwlib system has been employed so as to easily allow the
  717. X% user to redefine the strengths of headings to taste. For example, the
  718. X% user could insert in the input document a similar set of definitions to these
  719. X% but with the b..e headings set to \fwlibc. This would tone down the output.
  720. X\def\fwseca#1#2{\fwliba{#1}{#2}}
  721. X\def\fwsecb#1#2{\fwlibb{#1}{#2}}
  722. X\def\fwsecc#1#2{\fwlibc{#1}{#2}}
  723. X\def\fwsecd#1#2{\fwlibd{#1}{#2}}
  724. X\def\fwsece#1#2{\fwlibe{#1}{#2}}
  725. X
  726. X
  727. X% Support for Explicit Typesetting
  728. X% --------------------------------
  729. X% FunnelWeb supports pragmas and other constructs that allow
  730. X% typesetter-independent typesetting commands to be given. The
  731. X% following macros support these features.
  732. X
  733. X% The in-text literal @{sloth@} and emphasise @[walrus@] features.
  734. X\def\fwlit#1{{\tt #1}}
  735. X\def\fwemp#1{{\it #1}}
  736. X
  737. X% The "@p new_page" pragma.
  738. X\def\fwnewpage{\vfill\eject}
  739. X
  740. X% The "@p vskip Nmm" pragma.
  741. X\def\fwvskip#1{\null\vskip #1mm}
  742. X
  743. X% The "@p title <font> <align> <text>" pragma.
  744. X\def\fwfontnormal#1{{\fwfontnorm {#1}}}
  745. X\def\fwfonttitle#1{{\fwfontboldd {#1}}}
  746. X\def\fwfontsmalltitle#1{{\fwfontboldb {#1}}}
  747. X\def\fwleftline#1{\leftline{#1}}
  748. X\def\fwcenterline#1{\centerline{#1}}
  749. X\def\fwrightline#1{\rightline{#1}}
  750. X
  751. X
  752. X% Support for Old FunnelWeb
  753. X% -------------------------
  754. X% The following macros were used extensively in the first version of
  755. X% FunnelWeb and are retained so that these older input files will still
  756. X% typeset cleanly.
  757. X\def\p#1{{\tt #1}}  % P for Program text.
  758. X\def\flagpage#1#2{
  759. X   \null
  760. X   \vfill
  761. X   \centerline{\fwfontboldd #1}
  762. X   \vskip 1cm
  763. X   \centerline{\fwfontboldd #2}
  764. X   \vfill
  765. X   \null
  766. X   \vfill
  767. X}
  768. X
  769. X%====================== End of FunnelWeb TeX Definitions =======================
  770. XEX12: This example gives some simple headings and demonstrates heading name
  771. X      inheritance.
  772. X
  773. X\fwbeginmacro
  774. X\fwfilename{ex12.out}{1}\fwequals \fwodef \fwbtx[dummy text]fwetx=%
  775. X\fwcdef 
  776. X\fwbeginmacronotes
  777. X\fwisafile{This macro is attached to an output file.}
  778. X\fwendmacronotes
  779. X\fwendmacro
  780. X
  781. X
  782. X\fwseca{1}{Feed the Penguins and Save the World}
  783. X\fwsecb{1.1}{Feed the Penguins}
  784. X\fwsecc{1.1.1}{Feed the little penguins}
  785. X\fwsecc{1.1.2}{Feed the big penguins}
  786. X\fwsecb{1.2}{Save the World}
  787. X\fwsecc{1.2.1}{Save Europe}
  788. X\fwsecc{1.2.2}{Save Africa}
  789. X
  790. X\fwsecc{1.2.3}{Save the rest of the world} This heading hasn't been given an explicit name, but will inherit the
  791. name $\backslash$p$\{$Save the rest of the world$\}$ from the macro definition below.
  792. X
  793. X\fwbeginmacro
  794. X\fwmacroname{Save the rest of the world}{2}\fwzero{}\fwequals \fwodef \fwbtx[...]fwetx=%
  795. X\fwcdef 
  796. X\fwbeginmacronotes
  797. X\fwusedin{This macro is NEVER invoked.}
  798. X\fwendmacronotes
  799. X\fwendmacro
  800. X
  801. X\bye
  802. X
  803. X
  804. X%*******************************************************************************
  805. X%*                    END OF AUTOMATICALLY GENERATED TEX FILE                  *
  806. X%*******************************************************************************
  807. X
  808. END_OF_FILE
  809. if test 16184 -ne `wc -c <'answers/ex12.tex'`; then
  810.     echo shar: \"'answers/ex12.tex'\" unpacked with wrong size!
  811. fi
  812. # end of 'answers/ex12.tex'
  813. fi
  814. if test -f 'answers/ex14.tex' -a "${1}" != "-c" ; then 
  815.   echo shar: Will not clobber existing file \"'answers/ex14.tex'\"
  816. else
  817. echo shar: Extracting \"'answers/ex14.tex'\" \(15714 characters\)
  818. sed "s/^X//" >'answers/ex14.tex' <<'END_OF_FILE'
  819. X
  820. X%*******************************************************************************
  821. X%*                    START OF AUTOMATICALLY GENERATED TEX FILE                *
  822. X%*******************************************************************************
  823. X%*                                                                             *
  824. X%* This TeX file was automatically generated by the FunnelWeb preprocessor.    *
  825. X%* You can typeset this file to produce printed documentation by running it    *
  826. X%* through the TeX typesetter using a command such as:                         *
  827. X%*    tex thisfilename                                                         *
  828. X%* The resultant file thisfilename.dvi can be printed using a command such as: *
  829. X%*    lpr -Pcslw -d thisfilename.dvi                                           *
  830. X%*                                                                             *
  831. X%* FunnelWeb is a preprocessor that allows programmers to weave programs and   *
  832. X%* their documentation together in a single document. The FunnelWeb program    *
  833. X%* analyses such documents producing both program files and typeset            *
  834. X%* documentation such as this TeX file.                                        *
  835. X%* FunnelWeb was created by Ross Williams.                                     *
  836. X%*                                                                             *
  837. X%* For more information on FunnelWeb look in the following FTP archive:        *
  838. X%*    Machine  : sirius.itd.adelaide.edu.au [IP=129.127.40.3].                 *
  839. X%*    Directory: ~pub/funnelweb/                                               *
  840. X%*               (or some other appropriately named directory).                *
  841. X%* or email Ross Williams at ross@spam.adelaide.edu.au                         *
  842. X%*                                                                             *
  843. X%*******************************************************************************
  844. X
  845. X
  846. X%===================== Start of FunnelWeb TeX Definitions ======================
  847. X
  848. X
  849. X% Version
  850. X% -------
  851. X% This is FunnelWeb TeX Macro Library Version 1.0.
  852. X
  853. X
  854. X% Copyright
  855. X% ---------
  856. X% This set of FunnelWeb TeX definitions was written by Ross Williams and was
  857. X% originally Copyright (C) 1992 Ross N. Williams.  However, I, Ross Williams,
  858. X% hereby forego any claim to Copyright in this set of FunnelWeb TeX definitions
  859. X% and hereby authorize that the set of TeX definitions pass into the public
  860. X% domain. -- Ross N. Williams, 3:41pm 07-May-1992, Adelaide, Australia.
  861. X
  862. X
  863. X% Modification
  864. X% ------------
  865. X% Please record all modifications to these TeX definitions here. Unless
  866. X% otherwise specified, all modified definitions fall in the public domain too.
  867. X%
  868. X% Programmers:
  869. X%    RNW  Ross N. Williams  ross@spam.adelaide.edu.au
  870. X%
  871. X% Changes:
  872. X%    07-May-1992  RNW  Prepared this work for public domain release.
  873. X%
  874. X
  875. X
  876. X% General Comments
  877. X% ----------------
  878. X% This set of TeX definitions exists for two reasons:
  879. X%
  880. X%    1. To shorten and neaten the FunnelWeb TeX output.
  881. X%    2. To allow users to fiddle with the output format in their input files
  882. X%       (by inserting redefining "\def"s) without having to resort to
  883. X%       modifying the FunnelWeb code.
  884. X%
  885. X% The user is warned that these definitions may be changed from time to time
  886. X% (but probably not much). The user should not be too sneaky. In particular,
  887. X% users wishing to redefine some of these macros should do so in an explicitly
  888. X% defined section at the top of their input file. This will mean that in the
  889. X% event of problems, that section can simply be deleted or commented out to
  890. X% allow the document to at least be typeset in the default format. Users should
  891. X% limit themselves to redefining these macros in such a section and should
  892. X% refrain from using the macros throughout their documents.
  893. X
  894. X
  895. X% Environment Parameters
  896. X% ----------------------
  897. X% \tolerance tells TeX how tolerant it should be about making bad line and
  898. X% page breaks. Here we set it to it's maximum, as
  899. X%   1) Computer programs are likely to cause lots of bad breaks.
  900. X%   2) In most cases the user would probably rather get the TeX file through
  901. X%      TeX without any errors than fiddle with spacings for perfection.
  902. X\tolerance=10000
  903. X
  904. X% I don't like indentation as it makes the page look more busy. Instead,
  905. X% paragraphs are separated by a little space (see next).
  906. X\parindent=0pt
  907. X
  908. X% In many cases, users will produce documents with long runs of paragraphs.
  909. X% In order to space out these paragraphs, it is convenient to maintain a
  910. X% prevailing non-zero \parskip (end-of-paragaph skip). The only trouble is
  911. X% that the skip becomes a problem in macro definitions which require no skip
  912. X% and so we have to turn the skip on and off. The following two macros
  913. X% simplify this process.
  914. X\def\fwparskipon{\parskip=\medskipamount}
  915. X\def\fwparskipoff{\parskip=0pt}
  916. X\fwparskipon
  917. X
  918. X% Setting raggedbottom allows TeX to leave a bit of space at the bottom of the
  919. X% page in order to better vertically align the rest of the page (e.g. skips
  920. X% won't stretch as much). It also means that headings are less likely to be
  921. X% isolated at the bottom of the page without any following text.
  922. X\raggedbottom
  923. X
  924. X
  925. X% Fonts
  926. X% -----
  927. X% Most of the typeset output is set in 10pt roman and 10pt tt font.
  928. X% The major extra font needs spring from titles and headings.
  929. X% For portability's sake we use only the following fonts:
  930. X%    cmr10
  931. X%    cmbx10
  932. X%    cmtt10
  933. X% and some enlargements of them. These fonts are all "standard" fonts
  934. X% in Plain TeX. See The TeXbook p.350.
  935. X\font\fwfontnote=cmr7
  936. X
  937. X\font\fwfontnorm=cmr10
  938. X\font\fwfontnorma=cmr10 scaled \magstep1
  939. X\font\fwfontnormb=cmr10 scaled \magstep2
  940. X
  941. X\font\fwfontbold=cmbx10
  942. X\font\fwfontbolda=cmbx10 scaled \magstep1
  943. X\font\fwfontboldb=cmbx10 scaled \magstep2
  944. X\font\fwfontboldc=cmbx10 scaled \magstep3
  945. X\font\fwfontboldd=cmbx10 scaled \magstep4
  946. X
  947. X
  948. X% Macros for Stylistic Details
  949. X% ----------------------------
  950. X% This section contains all the fiddly little macros for setting the details
  951. X% of each macro definition.
  952. X
  953. X% Macro definitions are sandwiched by calls to these macros which can be used
  954. X% to sort out the spacing before and after the macro definition.
  955. X\def\fwbeginmacro{\fwparskipoff\bigskip}
  956. X\def\fwendmacro{\fwparskipon\par}
  957. X
  958. X% These macros deal with the macro name and definition line.
  959. X\def\fwmacroname#1#2{{\sl #1\/}$\lbrack$#2$\rbrack$}
  960. X\def\fwfilename#1#2{{\bf #1}$\lbrack$#2$\rbrack$}
  961. X\def\fwzero#1{{\bf Z}}
  962. X\def\fwmany#1{{\bf M}}
  963. X\def\fwequals{ $\equiv$}
  964. X\def\fwplusequals{ $+\equiv$}
  965. X
  966. X% Now for the actual body of the definition. It looks nice to have the tt
  967. X% code indented a little. Again, we use macros instead of writing direct TeX,
  968. X% so as to allow the user to fiddle this stuff to taste without having to
  969. X% modify the FunnelWeb C code.
  970. X\def\fwodef{\parindent=15pt\vskip0pt$\lbrace$\parindent=20pt}
  971. X\def\fwcdef{$\rbrace$\vskip0pt\parindent=0pt}
  972. X\def\fwoquote{`}
  973. X\def\fwcquote{'}
  974. X\def\fwoparen{$($}
  975. X\def\fwcomma{$,$}
  976. X\def\fwcparen{$)$}
  977. X\def\fwparam#1{$\diamond #1$}
  978. X\def\fwparams#1{$(\diamond #1)$}
  979. X
  980. X% These macros deal with the notes that are appended at the end of each
  981. X% macro definition. Note that even though \fwisafile,\fwusedin, and \fwseealso
  982. X% have the same definition, they are given different names so as to allow the
  983. X% user to redefine these macros to typeset each kind of information differently
  984. X% if desired.
  985. X\def\fwbeginmacronotes{\begingroup\baselineskip=9pt\smallskip}
  986. X\def\fwnote#1{{\fwfontnote #1}\par}
  987. X\def\fwisafile#1{\fwnote{#1}}
  988. X\def\fwusedin#1{\fwnote{#1}}
  989. X\def\fwseealso#1{\fwnote{#1}}
  990. X\def\fwendmacronotes{\endgroup}
  991. X
  992. X
  993. X% Macros to Typeset Program Code Verbatim
  994. X% ---------------------------------------
  995. X% This is by far the hairiest and most difficult part of the typesetting task
  996. X% because we have to turn off most of TeX's natural instincts in order to
  997. X% typeset the program text exactly as it appears in the input file.
  998. X% Two macros are defined to pull this off: \fwbtx and \fwverbatimgobble.
  999. X% Their code was inspired by the following sections of "The TeXbook":
  1000. X%    Appendix D: Dirty Tricks, 3.Verbatim listing, p.380-382.
  1001. X%    Appendix E: Example Formats, p.421.
  1002. X% The \fwbtx[ (for "FunnelWeb Begin TeXt") macro does most of the hard work.
  1003. X% The liberal use of "%" is because I don't understand TeX well enough to
  1004. X% understand when an end of line will cause trouble, and I am playing it safe.
  1005. X
  1006. X% Before defining the main \fwbtx macro, we have to stash away some definitions
  1007. X% in the hidden part of TeX's environment. Let's hope that these "hidden"
  1008. X% definitions don't affect anything except what is desired to be affected.
  1009. X
  1010. X% The tt font in which we wish to set the text has two Latin lurking ligatures!
  1011. X% These are ?` and !`. To disable them, we define the left quote when ACTIVE
  1012. X% to be defined in such a way as to prevent ligatures. The main TeX text will
  1013. X% normally not be exposed to this definition because normally the leftquote
  1014. X% character is not active. The \fwbtx macro temporarily makes the left quote
  1015. X% character active thus activating the deactivation of left quote ligatures.
  1016. X% See The TeXbook p.381.
  1017. X{\catcode`\`=\active \gdef`{\relax\lq}}
  1018. X
  1019. X% TeX is fairly carefree about spaces and so we have to make it more serious.
  1020. X% To do so we pull the same trick as above, setting up a definition for active
  1021. X% space, but only making space active during the span of the verbatim text.
  1022. X% In Plain TeX the active space is defined to be simply a space, but here we
  1023. X% define it to be a control space. This ensures that the space cannot
  1024. X% be gobbled up by one of TeX's mysterious mechanisms when activated.
  1025. X% See The TeXbook, p.381 and p.352.
  1026. X{\obeyspaces\global\let =\ }
  1027. X
  1028. X% Here is the main \fwbtx verbatim text macro.
  1029. X% Note: The order in which all these pieces of business have to be done is
  1030. X% still a partial mystery to me. Don't fiddle with this stuff unless you
  1031. X% think you know what you are doing.
  1032. X\def\fwbtx[{%
  1033. X%
  1034. X% The funnies involved in getting verbatim output are safely housed inside
  1035. X% this \begingroup, and the \endgroup in \fwverbatimgobble. Groups are used
  1036. X% instead of curly braces because we have to be able to signal the end of
  1037. X% this macro with a curly brace.
  1038. X\begingroup%
  1039. X%
  1040. X% \pars at the end of empty lines in the verbatim text won't come out normally
  1041. X% because TeX is in vertical mode and they get gobbled up. To prevent this,
  1042. X% we force \par to exit vertical mode first. See The TeXbook p.381.
  1043. X\def\par{\leavevmode\endgraf}%
  1044. X%
  1045. X% Activate the leftquote character so as to avoid ligatures (see above).
  1046. X\catcode`\`=\active%
  1047. X%
  1048. X% The \obeylines macro simply defines end of line (^M) to be \par. This ensures
  1049. X% that TeX will treat each verbatim line as a new paragraph.
  1050. X\obeylines%
  1051. X%
  1052. X% To get verbatim output, we have to desex all the special characters. This
  1053. X% is explained in detail in The TeXbook p.380.
  1054. X\def\do##1{\catcode`##1=12 }\dospecials%
  1055. X%
  1056. X% Activate the space character so as to make TeX treat blanks seriously.
  1057. X% This activation invokes an eralier definition (see above).
  1058. X\obeyspaces
  1059. X%
  1060. X% Interparagraph skips do not help the cause.
  1061. X% Note: We have to preserve the indentation though, as the code is actually
  1062. X% indented in the final output. See \fwodef in an earlier section.
  1063. X\parskip=0pt%
  1064. X%
  1065. X% We typeset the verbatim text in tt font (courier on the Macintosh) for a
  1066. X% number of reasons:
  1067. X%    - tt font has the same horizontal spacing for each character.
  1068. X%    - tt font covers the ASCII character set.
  1069. X%    - tt font doesn't have many surprises (e.g. ligatures).
  1070. X%    - tt font looks much what you might see on a computer terminal screen.
  1071. X\tt%
  1072. X%
  1073. X% Having set up an environment for verbatim, we are ready to use it.
  1074. X% By invoking \fwverbatimgobble, this \fwbtx macro gobbles up text verbatim (as
  1075. X% part of the parameter of \fwverbatimgobble) until it sees the termination
  1076. X% string "]fwetx=" (the "=" was thrown in to add obscurity as this sequence
  1077. X% must never occur in the verbatim text).
  1078. X\fwverbatimgobble}
  1079. X
  1080. X% The \fwverbatimgobble macro exists to allow \fwbtx to bracket verbatim text.
  1081. X\def\fwverbatimgobble#1]fwetx={#1\endgroup}
  1082. X
  1083. X
  1084. X% Table of Contents
  1085. X% -----------------
  1086. X% The five levels of table of contents that FunnelWeb supports are identified
  1087. X% by the five letters [A..E]. These are used throughout the following macros.
  1088. X
  1089. X% The following macros are utilities to the TOC macros to follow.
  1090. X\def\fwrule{\medskip\hrule\medskip}
  1091. X\def\fwqh{\hskip1.5em\relax}
  1092. X\def\fwbeforesec{\penalty-200\bigskip\medskip\par}
  1093. X
  1094. X% The following macros are used to typeset the table of contents.
  1095. X\def\fwtocstart#1{\fwrule\leftline{\fwfontbolda Table of Contents}\fwrule}
  1096. X\def\fwtoca#1#2{\leftline{{\bf #1 #2}}}
  1097. X\def\fwtocb#1#2{\leftline{\fwqh #1 #2}}
  1098. X\def\fwtocc#1#2{\leftline{\fwqh\fwqh #1 #2}}
  1099. X\def\fwtocd#1#2{\leftline{\fwqh\fwqh\fwqh #1 #2}}
  1100. X\def\fwtoce#1#2{\leftline{\fwqh\fwqh\fwqh\fwqh #1 #2}}
  1101. X\def\fwtocfinish#1{\fwrule}
  1102. X
  1103. X% The following "library" macros define five different strengths of headings
  1104. X% which can be used later in the section macros.
  1105. X\def\fwliba#1#2{\vfill\eject{\fwfontboldc #1 #2}\penalty200\smallskip}
  1106. X\def\fwlibb#1#2{\fwbeforesec{\fwfontboldb #1 #2}\penalty200\smallskip}
  1107. X\def\fwlibc#1#2{\fwbeforesec{\fwfontnormb #1 #2}\penalty200\smallskip}
  1108. X\def\fwlibd#1#2{\fwbeforesec{\bf          #1 #2}\penalty200}
  1109. X\def\fwlibe#1#2{\fwbeforesec{\bf          #1 #2}}
  1110. X
  1111. X% Here are the macros that actually typeset the section headings throughout
  1112. X% the document. The fwlib system has been employed so as to easily allow the
  1113. X% user to redefine the strengths of headings to taste. For example, the
  1114. X% user could insert in the input document a similar set of definitions to these
  1115. X% but with the b..e headings set to \fwlibc. This would tone down the output.
  1116. X\def\fwseca#1#2{\fwliba{#1}{#2}}
  1117. X\def\fwsecb#1#2{\fwlibb{#1}{#2}}
  1118. X\def\fwsecc#1#2{\fwlibc{#1}{#2}}
  1119. X\def\fwsecd#1#2{\fwlibd{#1}{#2}}
  1120. X\def\fwsece#1#2{\fwlibe{#1}{#2}}
  1121. X
  1122. X
  1123. X% Support for Explicit Typesetting
  1124. X% --------------------------------
  1125. X% FunnelWeb supports pragmas and other constructs that allow
  1126. X% typesetter-independent typesetting commands to be given. The
  1127. X% following macros support these features.
  1128. X
  1129. X% The in-text literal @{sloth@} and emphasise @[walrus@] features.
  1130. X\def\fwlit#1{{\tt #1}}
  1131. X\def\fwemp#1{{\it #1}}
  1132. X
  1133. X% The "@p new_page" pragma.
  1134. X\def\fwnewpage{\vfill\eject}
  1135. X
  1136. X% The "@p vskip Nmm" pragma.
  1137. X\def\fwvskip#1{\null\vskip #1mm}
  1138. X
  1139. X% The "@p title <font> <align> <text>" pragma.
  1140. X\def\fwfontnormal#1{{\fwfontnorm {#1}}}
  1141. X\def\fwfonttitle#1{{\fwfontboldd {#1}}}
  1142. X\def\fwfontsmalltitle#1{{\fwfontboldb {#1}}}
  1143. X\def\fwleftline#1{\leftline{#1}}
  1144. X\def\fwcenterline#1{\centerline{#1}}
  1145. X\def\fwrightline#1{\rightline{#1}}
  1146. X
  1147. X
  1148. X% Support for Old FunnelWeb
  1149. X% -------------------------
  1150. X% The following macros were used extensively in the first version of
  1151. X% FunnelWeb and are retained so that these older input files will still
  1152. X% typeset cleanly.
  1153. X\def\p#1{{\tt #1}}  % P for Program text.
  1154. X\def\flagpage#1#2{
  1155. X   \null
  1156. X   \vfill
  1157. X   \centerline{\fwfontboldd #1}
  1158. X   \vskip 1cm
  1159. X   \centerline{\fwfontboldd #2}
  1160. X   \vfill
  1161. X   \null
  1162. X   \vfill
  1163. X}
  1164. X
  1165. X%====================== End of FunnelWeb TeX Definitions =======================
  1166. XEX14: This example demonstrates the literal and emphasis typesetting constructs.
  1167. X
  1168. The following procedure \fwlit{put\_sloth} writes the \fwlit{sloth} variable to
  1169. the output file. Note: \fwemp{The output file must be opened for writing
  1170. at this point or the program will crash!}
  1171. X
  1172. X\fwbeginmacro
  1173. X\fwfilename{ex14.out}{1}\fwequals \fwodef \fwbtx[dummy
  1174. X]fwetx=%
  1175. X\fwcdef 
  1176. X\fwbeginmacronotes
  1177. X\fwisafile{This macro is attached to an output file.}
  1178. X\fwendmacronotes
  1179. X\fwendmacro
  1180. X
  1181. X\bye
  1182. X
  1183. X
  1184. X%*******************************************************************************
  1185. X%*                    END OF AUTOMATICALLY GENERATED TEX FILE                  *
  1186. X%*******************************************************************************
  1187. X
  1188. END_OF_FILE
  1189. if test 15714 -ne `wc -c <'answers/ex14.tex'`; then
  1190.     echo shar: \"'answers/ex14.tex'\" unpacked with wrong size!
  1191. fi
  1192. # end of 'answers/ex14.tex'
  1193. fi
  1194. if test -f 'answers/ex15.tex' -a "${1}" != "-c" ; then 
  1195.   echo shar: Will not clobber existing file \"'answers/ex15.tex'\"
  1196. else
  1197. echo shar: Extracting \"'answers/ex15.tex'\" \(16000 characters\)
  1198. sed "s/^X//" >'answers/ex15.tex' <<'END_OF_FILE'
  1199. X
  1200. X%*******************************************************************************
  1201. X%*                    START OF AUTOMATICALLY GENERATED TEX FILE                *
  1202. X%*******************************************************************************
  1203. X%*                                                                             *
  1204. X%* This TeX file was automatically generated by the FunnelWeb preprocessor.    *
  1205. X%* You can typeset this file to produce printed documentation by running it    *
  1206. X%* through the TeX typesetter using a command such as:                         *
  1207. X%*    tex thisfilename                                                         *
  1208. X%* The resultant file thisfilename.dvi can be printed using a command such as: *
  1209. X%*    lpr -Pcslw -d thisfilename.dvi                                           *
  1210. X%*                                                                             *
  1211. X%* FunnelWeb is a preprocessor that allows programmers to weave programs and   *
  1212. X%* their documentation together in a single document. The FunnelWeb program    *
  1213. X%* analyses such documents producing both program files and typeset            *
  1214. X%* documentation such as this TeX file.                                        *
  1215. X%* FunnelWeb was created by Ross Williams.                                     *
  1216. X%*                                                                             *
  1217. X%* For more information on FunnelWeb look in the following FTP archive:        *
  1218. X%*    Machine  : sirius.itd.adelaide.edu.au [IP=129.127.40.3].                 *
  1219. X%*    Directory: ~pub/funnelweb/                                               *
  1220. X%*               (or some other appropriately named directory).                *
  1221. X%* or email Ross Williams at ross@spam.adelaide.edu.au                         *
  1222. X%*                                                                             *
  1223. X%*******************************************************************************
  1224. X
  1225. X
  1226. X%===================== Start of FunnelWeb TeX Definitions ======================
  1227. X
  1228. X
  1229. X% Version
  1230. X% -------
  1231. X% This is FunnelWeb TeX Macro Library Version 1.0.
  1232. X
  1233. X
  1234. X% Copyright
  1235. X% ---------
  1236. X% This set of FunnelWeb TeX definitions was written by Ross Williams and was
  1237. X% originally Copyright (C) 1992 Ross N. Williams.  However, I, Ross Williams,
  1238. X% hereby forego any claim to Copyright in this set of FunnelWeb TeX definitions
  1239. X% and hereby authorize that the set of TeX definitions pass into the public
  1240. X% domain. -- Ross N. Williams, 3:41pm 07-May-1992, Adelaide, Australia.
  1241. X
  1242. X
  1243. X% Modification
  1244. X% ------------
  1245. X% Please record all modifications to these TeX definitions here. Unless
  1246. X% otherwise specified, all modified definitions fall in the public domain too.
  1247. X%
  1248. X% Programmers:
  1249. X%    RNW  Ross N. Williams  ross@spam.adelaide.edu.au
  1250. X%
  1251. X% Changes:
  1252. X%    07-May-1992  RNW  Prepared this work for public domain release.
  1253. X%
  1254. X
  1255. X
  1256. X% General Comments
  1257. X% ----------------
  1258. X% This set of TeX definitions exists for two reasons:
  1259. X%
  1260. X%    1. To shorten and neaten the FunnelWeb TeX output.
  1261. X%    2. To allow users to fiddle with the output format in their input files
  1262. X%       (by inserting redefining "\def"s) without having to resort to
  1263. X%       modifying the FunnelWeb code.
  1264. X%
  1265. X% The user is warned that these definitions may be changed from time to time
  1266. X% (but probably not much). The user should not be too sneaky. In particular,
  1267. X% users wishing to redefine some of these macros should do so in an explicitly
  1268. X% defined section at the top of their input file. This will mean that in the
  1269. X% event of problems, that section can simply be deleted or commented out to
  1270. X% allow the document to at least be typeset in the default format. Users should
  1271. X% limit themselves to redefining these macros in such a section and should
  1272. X% refrain from using the macros throughout their documents.
  1273. X
  1274. X
  1275. X% Environment Parameters
  1276. X% ----------------------
  1277. X% \tolerance tells TeX how tolerant it should be about making bad line and
  1278. X% page breaks. Here we set it to it's maximum, as
  1279. X%   1) Computer programs are likely to cause lots of bad breaks.
  1280. X%   2) In most cases the user would probably rather get the TeX file through
  1281. X%      TeX without any errors than fiddle with spacings for perfection.
  1282. X\tolerance=10000
  1283. X
  1284. X% I don't like indentation as it makes the page look more busy. Instead,
  1285. X% paragraphs are separated by a little space (see next).
  1286. X\parindent=0pt
  1287. X
  1288. X% In many cases, users will produce documents with long runs of paragraphs.
  1289. X% In order to space out these paragraphs, it is convenient to maintain a
  1290. X% prevailing non-zero \parskip (end-of-paragaph skip). The only trouble is
  1291. X% that the skip becomes a problem in macro definitions which require no skip
  1292. X% and so we have to turn the skip on and off. The following two macros
  1293. X% simplify this process.
  1294. X\def\fwparskipon{\parskip=\medskipamount}
  1295. X\def\fwparskipoff{\parskip=0pt}
  1296. X\fwparskipon
  1297. X
  1298. X% Setting raggedbottom allows TeX to leave a bit of space at the bottom of the
  1299. X% page in order to better vertically align the rest of the page (e.g. skips
  1300. X% won't stretch as much). It also means that headings are less likely to be
  1301. X% isolated at the bottom of the page without any following text.
  1302. X\raggedbottom
  1303. X
  1304. X
  1305. X% Fonts
  1306. X% -----
  1307. X% Most of the typeset output is set in 10pt roman and 10pt tt font.
  1308. X% The major extra font needs spring from titles and headings.
  1309. X% For portability's sake we use only the following fonts:
  1310. X%    cmr10
  1311. X%    cmbx10
  1312. X%    cmtt10
  1313. X% and some enlargements of them. These fonts are all "standard" fonts
  1314. X% in Plain TeX. See The TeXbook p.350.
  1315. X\font\fwfontnote=cmr7
  1316. X
  1317. X\font\fwfontnorm=cmr10
  1318. X\font\fwfontnorma=cmr10 scaled \magstep1
  1319. X\font\fwfontnormb=cmr10 scaled \magstep2
  1320. X
  1321. X\font\fwfontbold=cmbx10
  1322. X\font\fwfontbolda=cmbx10 scaled \magstep1
  1323. X\font\fwfontboldb=cmbx10 scaled \magstep2
  1324. X\font\fwfontboldc=cmbx10 scaled \magstep3
  1325. X\font\fwfontboldd=cmbx10 scaled \magstep4
  1326. X
  1327. X
  1328. X% Macros for Stylistic Details
  1329. X% ----------------------------
  1330. X% This section contains all the fiddly little macros for setting the details
  1331. X% of each macro definition.
  1332. X
  1333. X% Macro definitions are sandwiched by calls to these macros which can be used
  1334. X% to sort out the spacing before and after the macro definition.
  1335. X\def\fwbeginmacro{\fwparskipoff\bigskip}
  1336. X\def\fwendmacro{\fwparskipon\par}
  1337. X
  1338. X% These macros deal with the macro name and definition line.
  1339. X\def\fwmacroname#1#2{{\sl #1\/}$\lbrack$#2$\rbrack$}
  1340. X\def\fwfilename#1#2{{\bf #1}$\lbrack$#2$\rbrack$}
  1341. X\def\fwzero#1{{\bf Z}}
  1342. X\def\fwmany#1{{\bf M}}
  1343. X\def\fwequals{ $\equiv$}
  1344. X\def\fwplusequals{ $+\equiv$}
  1345. X
  1346. X% Now for the actual body of the definition. It looks nice to have the tt
  1347. X% code indented a little. Again, we use macros instead of writing direct TeX,
  1348. X% so as to allow the user to fiddle this stuff to taste without having to
  1349. X% modify the FunnelWeb C code.
  1350. X\def\fwodef{\parindent=15pt\vskip0pt$\lbrace$\parindent=20pt}
  1351. X\def\fwcdef{$\rbrace$\vskip0pt\parindent=0pt}
  1352. X\def\fwoquote{`}
  1353. X\def\fwcquote{'}
  1354. X\def\fwoparen{$($}
  1355. X\def\fwcomma{$,$}
  1356. X\def\fwcparen{$)$}
  1357. X\def\fwparam#1{$\diamond #1$}
  1358. X\def\fwparams#1{$(\diamond #1)$}
  1359. X
  1360. X% These macros deal with the notes that are appended at the end of each
  1361. X% macro definition. Note that even though \fwisafile,\fwusedin, and \fwseealso
  1362. X% have the same definition, they are given different names so as to allow the
  1363. X% user to redefine these macros to typeset each kind of information differently
  1364. X% if desired.
  1365. X\def\fwbeginmacronotes{\begingroup\baselineskip=9pt\smallskip}
  1366. X\def\fwnote#1{{\fwfontnote #1}\par}
  1367. X\def\fwisafile#1{\fwnote{#1}}
  1368. X\def\fwusedin#1{\fwnote{#1}}
  1369. X\def\fwseealso#1{\fwnote{#1}}
  1370. X\def\fwendmacronotes{\endgroup}
  1371. X
  1372. X
  1373. X% Macros to Typeset Program Code Verbatim
  1374. X% ---------------------------------------
  1375. X% This is by far the hairiest and most difficult part of the typesetting task
  1376. X% because we have to turn off most of TeX's natural instincts in order to
  1377. X% typeset the program text exactly as it appears in the input file.
  1378. X% Two macros are defined to pull this off: \fwbtx and \fwverbatimgobble.
  1379. X% Their code was inspired by the following sections of "The TeXbook":
  1380. X%    Appendix D: Dirty Tricks, 3.Verbatim listing, p.380-382.
  1381. X%    Appendix E: Example Formats, p.421.
  1382. X% The \fwbtx[ (for "FunnelWeb Begin TeXt") macro does most of the hard work.
  1383. X% The liberal use of "%" is because I don't understand TeX well enough to
  1384. X% understand when an end of line will cause trouble, and I am playing it safe.
  1385. X
  1386. X% Before defining the main \fwbtx macro, we have to stash away some definitions
  1387. X% in the hidden part of TeX's environment. Let's hope that these "hidden"
  1388. X% definitions don't affect anything except what is desired to be affected.
  1389. X
  1390. X% The tt font in which we wish to set the text has two Latin lurking ligatures!
  1391. X% These are ?` and !`. To disable them, we define the left quote when ACTIVE
  1392. X% to be defined in such a way as to prevent ligatures. The main TeX text will
  1393. X% normally not be exposed to this definition because normally the leftquote
  1394. X% character is not active. The \fwbtx macro temporarily makes the left quote
  1395. X% character active thus activating the deactivation of left quote ligatures.
  1396. X% See The TeXbook p.381.
  1397. X{\catcode`\`=\active \gdef`{\relax\lq}}
  1398. X
  1399. X% TeX is fairly carefree about spaces and so we have to make it more serious.
  1400. X% To do so we pull the same trick as above, setting up a definition for active
  1401. X% space, but only making space active during the span of the verbatim text.
  1402. X% In Plain TeX the active space is defined to be simply a space, but here we
  1403. X% define it to be a control space. This ensures that the space cannot
  1404. X% be gobbled up by one of TeX's mysterious mechanisms when activated.
  1405. X% See The TeXbook, p.381 and p.352.
  1406. X{\obeyspaces\global\let =\ }
  1407. X
  1408. X% Here is the main \fwbtx verbatim text macro.
  1409. X% Note: The order in which all these pieces of business have to be done is
  1410. X% still a partial mystery to me. Don't fiddle with this stuff unless you
  1411. X% think you know what you are doing.
  1412. X\def\fwbtx[{%
  1413. X%
  1414. X% The funnies involved in getting verbatim output are safely housed inside
  1415. X% this \begingroup, and the \endgroup in \fwverbatimgobble. Groups are used
  1416. X% instead of curly braces because we have to be able to signal the end of
  1417. X% this macro with a curly brace.
  1418. X\begingroup%
  1419. X%
  1420. X% \pars at the end of empty lines in the verbatim text won't come out normally
  1421. X% because TeX is in vertical mode and they get gobbled up. To prevent this,
  1422. X% we force \par to exit vertical mode first. See The TeXbook p.381.
  1423. X\def\par{\leavevmode\endgraf}%
  1424. X%
  1425. X% Activate the leftquote character so as to avoid ligatures (see above).
  1426. X\catcode`\`=\active%
  1427. X%
  1428. X% The \obeylines macro simply defines end of line (^M) to be \par. This ensures
  1429. X% that TeX will treat each verbatim line as a new paragraph.
  1430. X\obeylines%
  1431. X%
  1432. X% To get verbatim output, we have to desex all the special characters. This
  1433. X% is explained in detail in The TeXbook p.380.
  1434. X\def\do##1{\catcode`##1=12 }\dospecials%
  1435. X%
  1436. X% Activate the space character so as to make TeX treat blanks seriously.
  1437. X% This activation invokes an eralier definition (see above).
  1438. X\obeyspaces
  1439. X%
  1440. X% Interparagraph skips do not help the cause.
  1441. X% Note: We have to preserve the indentation though, as the code is actually
  1442. X% indented in the final output. See \fwodef in an earlier section.
  1443. X\parskip=0pt%
  1444. X%
  1445. X% We typeset the verbatim text in tt font (courier on the Macintosh) for a
  1446. X% number of reasons:
  1447. X%    - tt font has the same horizontal spacing for each character.
  1448. X%    - tt font covers the ASCII character set.
  1449. X%    - tt font doesn't have many surprises (e.g. ligatures).
  1450. X%    - tt font looks much what you might see on a computer terminal screen.
  1451. X\tt%
  1452. X%
  1453. X% Having set up an environment for verbatim, we are ready to use it.
  1454. X% By invoking \fwverbatimgobble, this \fwbtx macro gobbles up text verbatim (as
  1455. X% part of the parameter of \fwverbatimgobble) until it sees the termination
  1456. X% string "]fwetx=" (the "=" was thrown in to add obscurity as this sequence
  1457. X% must never occur in the verbatim text).
  1458. X\fwverbatimgobble}
  1459. X
  1460. X% The \fwverbatimgobble macro exists to allow \fwbtx to bracket verbatim text.
  1461. X\def\fwverbatimgobble#1]fwetx={#1\endgroup}
  1462. X
  1463. X
  1464. X% Table of Contents
  1465. X% -----------------
  1466. X% The five levels of table of contents that FunnelWeb supports are identified
  1467. X% by the five letters [A..E]. These are used throughout the following macros.
  1468. X
  1469. X% The following macros are utilities to the TOC macros to follow.
  1470. X\def\fwrule{\medskip\hrule\medskip}
  1471. X\def\fwqh{\hskip1.5em\relax}
  1472. X\def\fwbeforesec{\penalty-200\bigskip\medskip\par}
  1473. X
  1474. X% The following macros are used to typeset the table of contents.
  1475. X\def\fwtocstart#1{\fwrule\leftline{\fwfontbolda Table of Contents}\fwrule}
  1476. X\def\fwtoca#1#2{\leftline{{\bf #1 #2}}}
  1477. X\def\fwtocb#1#2{\leftline{\fwqh #1 #2}}
  1478. X\def\fwtocc#1#2{\leftline{\fwqh\fwqh #1 #2}}
  1479. X\def\fwtocd#1#2{\leftline{\fwqh\fwqh\fwqh #1 #2}}
  1480. X\def\fwtoce#1#2{\leftline{\fwqh\fwqh\fwqh\fwqh #1 #2}}
  1481. X\def\fwtocfinish#1{\fwrule}
  1482. X
  1483. X% The following "library" macros define five different strengths of headings
  1484. X% which can be used later in the section macros.
  1485. X\def\fwliba#1#2{\vfill\eject{\fwfontboldc #1 #2}\penalty200\smallskip}
  1486. X\def\fwlibb#1#2{\fwbeforesec{\fwfontboldb #1 #2}\penalty200\smallskip}
  1487. X\def\fwlibc#1#2{\fwbeforesec{\fwfontnormb #1 #2}\penalty200\smallskip}
  1488. X\def\fwlibd#1#2{\fwbeforesec{\bf          #1 #2}\penalty200}
  1489. X\def\fwlibe#1#2{\fwbeforesec{\bf          #1 #2}}
  1490. X
  1491. X% Here are the macros that actually typeset the section headings throughout
  1492. X% the document. The fwlib system has been employed so as to easily allow the
  1493. X% user to redefine the strengths of headings to taste. For example, the
  1494. X% user could insert in the input document a similar set of definitions to these
  1495. X% but with the b..e headings set to \fwlibc. This would tone down the output.
  1496. X\def\fwseca#1#2{\fwliba{#1}{#2}}
  1497. X\def\fwsecb#1#2{\fwlibb{#1}{#2}}
  1498. X\def\fwsecc#1#2{\fwlibc{#1}{#2}}
  1499. X\def\fwsecd#1#2{\fwlibd{#1}{#2}}
  1500. X\def\fwsece#1#2{\fwlibe{#1}{#2}}
  1501. X
  1502. X
  1503. X% Support for Explicit Typesetting
  1504. X% --------------------------------
  1505. X% FunnelWeb supports pragmas and other constructs that allow
  1506. X% typesetter-independent typesetting commands to be given. The
  1507. X% following macros support these features.
  1508. X
  1509. X% The in-text literal @{sloth@} and emphasise @[walrus@] features.
  1510. X\def\fwlit#1{{\tt #1}}
  1511. X\def\fwemp#1{{\it #1}}
  1512. X
  1513. X% The "@p new_page" pragma.
  1514. X\def\fwnewpage{\vfill\eject}
  1515. X
  1516. X% The "@p vskip Nmm" pragma.
  1517. X\def\fwvskip#1{\null\vskip #1mm}
  1518. X
  1519. X% The "@p title <font> <align> <text>" pragma.
  1520. X\def\fwfontnormal#1{{\fwfontnorm {#1}}}
  1521. X\def\fwfonttitle#1{{\fwfontboldd {#1}}}
  1522. X\def\fwfontsmalltitle#1{{\fwfontboldb {#1}}}
  1523. X\def\fwleftline#1{\leftline{#1}}
  1524. X\def\fwcenterline#1{\centerline{#1}}
  1525. X\def\fwrightline#1{\rightline{#1}}
  1526. X
  1527. X
  1528. X% Support for Old FunnelWeb
  1529. X% -------------------------
  1530. X% The following macros were used extensively in the first version of
  1531. X% FunnelWeb and are retained so that these older input files will still
  1532. X% typeset cleanly.
  1533. X\def\p#1{{\tt #1}}  % P for Program text.
  1534. X\def\flagpage#1#2{
  1535. X   \null
  1536. X   \vfill
  1537. X   \centerline{\fwfontboldd #1}
  1538. X   \vskip 1cm
  1539. X   \centerline{\fwfontboldd #2}
  1540. X   \vfill
  1541. X   \null
  1542. X   \vfill
  1543. X}
  1544. X
  1545. X%====================== End of FunnelWeb TeX Definitions =======================
  1546. XEX15: This example demonstrates some of FunnelWeb's generic typesetting
  1547. X      constructs.
  1548. X
  1549. X\fwvskip{40}
  1550. X\fwcenterline{\fwfonttitle{Hairy Wombat}}
  1551. X\fwcenterline{\fwfonttitle{Simulation}}
  1552. X\fwvskip{10}
  1553. X\fwcenterline{\fwfontsmalltitle{A Program in Six Parts}}
  1554. X\fwcenterline{\fwfontsmalltitle{Simulating the Life of Some Hairy Wombats}}
  1555. X\fwvskip{20}
  1556. X\fwleftline{\fwfontnormal{By Zqitzypbuswapzra Ypongtatoslrtzz}}
  1557. X
  1558. X\fwnewpage
  1559. X
  1560. X
  1561. X\fwtocstart{}
  1562. X\fwtoca{1}{Section One}
  1563. X\fwtoca{2}{Section Two}
  1564. X\fwtocfinish{}
  1565. X
  1566. X
  1567. X\fwnewpage
  1568. X
  1569. X
  1570. X\fwseca{1}{Section One}
  1571. X\fwseca{2}{Section Two}
  1572. X
  1573. X\fwbeginmacro
  1574. X\fwfilename{ex15.out}{1}\fwequals \fwodef \fwbtx[Dummy
  1575. X]fwetx=%
  1576. X\fwcdef 
  1577. X\fwbeginmacronotes
  1578. X\fwisafile{This macro is attached to an output file.}
  1579. X\fwendmacronotes
  1580. X\fwendmacro
  1581. X
  1582. X\bye
  1583. X
  1584. X
  1585. X%*******************************************************************************
  1586. X%*                    END OF AUTOMATICALLY GENERATED TEX FILE                  *
  1587. X%*******************************************************************************
  1588. X
  1589. END_OF_FILE
  1590. if test 16000 -ne `wc -c <'answers/ex15.tex'`; then
  1591.     echo shar: \"'answers/ex15.tex'\" unpacked with wrong size!
  1592. fi
  1593. # end of 'answers/ex15.tex'
  1594. fi
  1595. if test -f 'sources/option.c' -a "${1}" != "-c" ; then 
  1596.   echo shar: Will not clobber existing file \"'sources/option.c'\"
  1597. else
  1598. echo shar: Extracting \"'sources/option.c'\" \(16334 characters\)
  1599. sed "s/^X//" >'sources/option.c' <<'END_OF_FILE'
  1600. X/*##############################################################################
  1601. X
  1602. XFUNNNELWEB COPYRIGHT
  1603. X====================
  1604. XFunnelWeb is a literate-programming macro preprocessor.
  1605. X
  1606. Copyright (C) 1992 Ross N. Williams.
  1607. X
  1608. X   Ross N. Williams
  1609. X   ross@spam.adelaide.edu.au
  1610. X   16 Lerwick Avenue, Hazelwood Park 5066, Australia.
  1611. X
  1612. This program is free software; you can redistribute it and/or modify
  1613. it under the terms of Version 2 of the GNU General Public License as
  1614. published by the Free Software Foundation.
  1615. X
  1616. This program is distributed WITHOUT ANY WARRANTY; without even the implied
  1617. warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  1618. See Version 2 of the GNU General Public License for more details.
  1619. X
  1620. You should have received a copy of Version 2 of the GNU General Public
  1621. License along with this program. If not, you can FTP the license from
  1622. prep.ai.mit.edu/pub/gnu/COPYING-2 or write to the Free Software
  1623. XFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1624. X
  1625. Section 2a of the license requires that all changes to this file be
  1626. recorded prominently in this file. Please record all changes here.
  1627. X
  1628. Programmers:
  1629. X   RNW  Ross N. Williams  ross@spam.adelaide.edu.au
  1630. X
  1631. Changes:
  1632. X   07-May-1992  RNW  Program prepared for release under GNU GPL V2.
  1633. X
  1634. X##############################################################################*/
  1635. X
  1636. X
  1637. X/******************************************************************************/
  1638. X/*                                  OPTION.C                                  */
  1639. X/******************************************************************************/
  1640. X
  1641. X#include <ctype.h>
  1642. X#include "style.h"
  1643. X
  1644. X#include "as.h"
  1645. X#include "data.h"
  1646. X#include "machin.h"
  1647. X#include "misc.h"
  1648. X#include "option.h"
  1649. X
  1650. X/******************************************************************************/
  1651. X
  1652. LOCAL void wl_caret P_((ulong,void (*)(char *)));
  1653. LOCAL void wl_caret(n,p_outf)
  1654. X/* Writes a caret at position n of an otherwise blank line. */
  1655. ulong n;
  1656. void  (*p_outf) P_((char *));
  1657. X{
  1658. X as_cold(n<1000,"wl_caret: Argument is out of range.");
  1659. X while (--n > 0)
  1660. X    (*p_outf)(" ");
  1661. X (*p_outf)("^\n");
  1662. X}
  1663. X
  1664. X/******************************************************************************/
  1665. X
  1666. XEXPORT void op_ini(p_op)
  1667. p_op_t p_op;
  1668. X{
  1669. X p_op->op_f_b=FALSE;
  1670. X strcpy(&p_op->op_f_s[0],"");
  1671. X
  1672. X p_op->op_j_b=FALSE;
  1673. X strcpy(&p_op->op_j_s[0],"");
  1674. X
  1675. X strcpy(&p_op->op_i_s[0],"");
  1676. X
  1677. X p_op->op_o_b=TRUE;
  1678. X strcpy(&p_op->op_o_s[0],"");
  1679. X
  1680. X p_op->op_t_b=FALSE;
  1681. X strcpy(&p_op->op_t_s[0],"");
  1682. X
  1683. X p_op->op_l_b=TRUE;
  1684. X strcpy(&p_op->op_l_s[0],"");
  1685. X
  1686. X p_op->op_d_b=FALSE;
  1687. X
  1688. X p_op->op_c_i=2;
  1689. X
  1690. X p_op->op_q_b=FALSE;
  1691. X
  1692. X p_op->op_s_b=FALSE;
  1693. X p_op->op_s_i=1;
  1694. X
  1695. X p_op->op_w_b=FALSE;
  1696. X p_op->op_w_i=80;
  1697. X
  1698. X p_op->op_x_b=FALSE;
  1699. X strcpy(&p_op->op_x_s[0],"");
  1700. X
  1701. X p_op->op_k_b=FALSE;
  1702. X
  1703. X p_op->op_b1_b=FALSE;
  1704. X p_op->op_b2_b=FALSE;
  1705. X p_op->op_b3_b=FALSE;
  1706. X p_op->op_b4_b=FALSE;
  1707. X p_op->op_b5_b=FALSE;
  1708. X p_op->op_b6_b=FALSE;
  1709. X p_op->op_b7_b=FALSE;
  1710. X p_op->op_h_b=FALSE;
  1711. X strcpy(&p_op->op_h_s[0],"menu");
  1712. X}
  1713. X
  1714. X/******************************************************************************/
  1715. X
  1716. XEXPORT bool op_add(p_op,p_cl,p_outf)
  1717. p_op_t p_op;
  1718. p_cl_t p_cl;
  1719. void   (*p_outf) P_((char *));
  1720. X{
  1721. X op_t  op_save;                  /* Saves *p_op so it can be restored later.  */
  1722. X char *comline = (char *) p_cl;  /* Pointer to the command line to be parsed. */
  1723. X char *p;                        /* Handy parsing pointer.                    */
  1724. X bool seen_error = FALSE;        /* TRUE iff one or more errors seen.         */
  1725. X
  1726. X#define ECHO_CL {if (!seen_error)\
  1727. X                   {(*p_outf)(comline);(*p_outf)("\n"); seen_error=TRUE;}}
  1728. X
  1729. X /* Save the parameter option structure so that we can restore it */
  1730. X /* if an error occurs later on.                                  */
  1731. X ASSIGN(op_save,*p_op);
  1732. X
  1733. X /* Check to make sure that the command line is not too long. */
  1734. X /* This error should really never occur.                     */
  1735. X p=comline;
  1736. X while (*p++ != EOS)
  1737. X    if ((p-comline) > COMLINE_MAX)
  1738. X      {
  1739. X       (*p_outf)("FunnelWeb command line syntax error.\n");
  1740. X       (*p_outf)("The entire command line is too long.\n");
  1741. X       sprintf(linet1,"The maximum command line length is %u characters.\n",
  1742. X              (unsigned) COMLINE_MAX);
  1743. X       (*p_outf)(linet1);
  1744. X       goto failure;
  1745. X      }
  1746. X
  1747. X /* Check that the command line contains only printables. */
  1748. X p=comline;
  1749. X while (*p != EOS)
  1750. X   {
  1751. X    if (!isascprn(*p))
  1752. X      {
  1753. X       (*p_outf)("FunnelWeb command line syntax error.\n");
  1754. X       (*p_outf)("Command line contains one or more non-printables.\n");
  1755. X       sprintf(linet1,"The first is at column %u.\n",(unsigned) (1+p-comline));
  1756. X       (*p_outf)(linet1);
  1757. X       goto failure;
  1758. X      }
  1759. X    p++;
  1760. X   }
  1761. X
  1762. X /* Now parse each option. */
  1763. X p=comline;
  1764. X while (TRUE)
  1765. X   {/* This loop processes one command line parameter (option) per iteration. */
  1766. X    char *p_startopt;    /* Points to the start of the parameter.             */
  1767. X    bool opsign;           /* The sign of the current option (+=TRUE).          */
  1768. X    bool opsign_active;    /* TRUE => (+ or -). FALSE => (=).                   */
  1769. X    char letter;         /* Letter of current option.                         */
  1770. X    cl_t cl_temp;        /* Parameter string of the current option.           */
  1771. X    fn_t fn_temp;        /* Parameter string of the current option.           */
  1772. X    int  i;              /* Handy int used to feed sscanf.                    */
  1773. X
  1774. X    /* Skip first parameter or rest of previous parameter after syntax error. */
  1775. X    while ((*p!=' ') && (*p!=EOS)) p++;
  1776. X
  1777. X    /* Skip blanks between parameters. */
  1778. X    while (*p==' ') p++;
  1779. X
  1780. X    /* At this point we are either at the start of a parameter or at EOS.     */
  1781. X    /* Finish if we are at the EOS.                                           */
  1782. X    if (*p==EOS) break;
  1783. X
  1784. X    /* p now points to the next parameter (option). Make a note of its start. */
  1785. X    p_startopt=p;
  1786. X
  1787. X    /* This switch statement parses the sign and letter characters.           */
  1788. X    switch (*p)
  1789. X      {
  1790. X       case '-': opsign=FALSE; opsign_active=TRUE;  p++; goto parse_letter;
  1791. X       case '+': opsign=TRUE;  opsign_active=TRUE;  p++; goto parse_letter;
  1792. X       case '=':             opsign_active=FALSE; p++; goto parse_letter;
  1793. X          parse_letter:
  1794. X          /* We have seen a sign. There should be a following letter. */
  1795. X          letter = *p;
  1796. X          if (!isalpha(letter))
  1797. X            {
  1798. X     ECHO_CL; wl_caret(p-comline,p_outf);
  1799. X             (*p_outf)("FunnelWeb command line syntax error.\n");
  1800. X             (*p_outf)("Option letter expected here.\n");
  1801. X             continue; /* Skip to the next parameter. */
  1802. X            }
  1803. X          p++;
  1804. X          break;
  1805. X       default: /* If no sign the option is a NAME option and defaults to +F. */
  1806. X          opsign=TRUE; opsign_active=TRUE; letter='F'; break;
  1807. X      } /* End switch */
  1808. X
  1809. X    /* Assert: p points to the parameter string of the option.      */
  1810. X    /* Copy the parameter string into the holding variable cl_temp. */
  1811. X    {char *q;
  1812. X     q = &cl_temp[0];
  1813. X     while ((*p!=EOS) && (*p!=' '))
  1814. X        *q++ = *p++;
  1815. X     *q=EOS;
  1816. X    }
  1817. X
  1818. X    /* As COMLINE_MAX can be greater than FILENAME_MAX, we have to be careful */
  1819. X    /* that the user is not about to blow our filename buffer.                */
  1820. X    if (strlen(cl_temp) > FILENAME_MAX)
  1821. X      {
  1822. X       ECHO_CL; wl_caret(p_startopt-comline,p_outf);
  1823. X       (*p_outf)("FunnelWeb command line syntax error.\n");
  1824. X       (*p_outf)("Option parameter string is too long.\n");
  1825. X       sprintf(linet1,"The maximum option parameter length is %u characters.\n",
  1826. X              (unsigned) FILENAME_MAX);
  1827. X       (*p_outf)(linet1);
  1828. X       continue; /* Skip to next parameter. */
  1829. X      }
  1830. X
  1831. X    /* Now that we know that the parameter is not too big, we can copy it     */
  1832. X    /* into a temporary variable of filename type.                            */
  1833. X    strcpy(&fn_temp[0],&cl_temp[0]);
  1834. X
  1835. X    /* At this point p points to the character following the option that      */
  1836. X    /* we have just scanned. This is either a blank or an EOS.                */
  1837. X    /* The current option is held in (opsign,opsign_active,letter,fn_temp).       */
  1838. X    /* Now we apply the option to the option record.                          */
  1839. X    switch (toupper(letter))
  1840. X      {
  1841. X       case 'F':
  1842. X          if (opsign_active) p_op->op_f_b=opsign;
  1843. X          strcpy(&p_op->op_f_s[0],&fn_temp[0]);
  1844. X          break;
  1845. X       case 'J':
  1846. X          if (opsign_active) p_op->op_j_b=opsign;
  1847. X          strcpy(&p_op->op_j_s[0],&fn_temp[0]);
  1848. X          break;
  1849. X       case 'I':
  1850. X          strcpy(&p_op->op_i_s[0],&fn_temp[0]);
  1851. X          break;
  1852. X       case 'O':
  1853. X          if (opsign_active) p_op->op_o_b=opsign;
  1854. X          strcpy(&p_op->op_o_s[0],&fn_temp[0]);
  1855. X          break;
  1856. X       case 'T':
  1857. X          if (opsign_active) p_op->op_t_b=opsign;
  1858. X          strcpy(&p_op->op_t_s[0],&fn_temp[0]);
  1859. X          break;
  1860. X       case 'L':
  1861. X          if (opsign_active) p_op->op_l_b=opsign;
  1862. X          strcpy(&p_op->op_l_s[0],&fn_temp[0]);
  1863. X          break;
  1864. X       case 'D':
  1865. X          if (opsign_active) p_op->op_d_b=opsign;
  1866. X          if (strlen(fn_temp)>0)
  1867. X            {
  1868. X     ECHO_CL; wl_caret(3+p_startopt-comline,p_outf);
  1869. X             (*p_outf)("FunnelWeb command line syntax error.\n");
  1870. X             (*p_outf)("The D option does not take an argument.\n");
  1871. X            }
  1872. X          break;
  1873. X       case 'C':
  1874. X          if ((sscanf(&fn_temp[0],"%d",&i) != 1) || (i<0) || (100<i))
  1875. X            {
  1876. X     ECHO_CL; wl_caret(3+p_startopt-comline,p_outf);
  1877. X             (*p_outf)("FunnelWeb command line syntax error.\n");
  1878. X             (*p_outf)("Numeric argument to C option invalid. It must\n");
  1879. X             (*p_outf)("be an unsigned decimal integer in the range [0,100].\n");
  1880. X            }
  1881. X          else
  1882. X             p_op->op_c_i=i;
  1883. X          break;
  1884. X       case 'Q':
  1885. X          if (opsign_active) p_op->op_q_b=opsign;
  1886. X          if (strlen(fn_temp)>0)
  1887. X            {
  1888. X     ECHO_CL; wl_caret(3+p_startopt-comline,p_outf);
  1889. X             (*p_outf)("FunnelWeb command line syntax error.\n");
  1890. X             (*p_outf)("The Q option does not take an argument.\n");
  1891. X            }
  1892. X          break;
  1893. X       case 'S':
  1894. X          if (opsign_active) p_op->op_s_b=opsign;
  1895. X          if (strlen(fn_temp)==0) break;
  1896. X          if ((sscanf(&fn_temp[0],"%d",&i) != 1) || (i<0) || (100<i))
  1897. X            {
  1898. X     ECHO_CL; wl_caret(2+p_startopt-comline,p_outf);
  1899. X             (*p_outf)("FunnelWeb command line syntax error.\n");
  1900. X             (*p_outf)("Numeric argument to S option invalid. It must\n");
  1901. X             (*p_outf)("be an unsigned decimal integer in the range [0,100].\n");
  1902. X            }
  1903. X          else
  1904. X             p_op->op_s_i=i;
  1905. X          break;
  1906. X       case 'W':
  1907. X          if (opsign_active) p_op->op_w_b=opsign;
  1908. X          if (strlen(fn_temp)==0) break;
  1909. X          if ((sscanf(&fn_temp[0],"%d",&i) != 1) || (i<0) || (1000<i))
  1910. X            {
  1911. X     ECHO_CL; wl_caret(2+p_startopt-comline,p_outf);
  1912. X             (*p_outf)("FunnelWeb command line syntax error.\n");
  1913. X             (*p_outf)("Error: Numeric argument to W option invalid. It must\n");
  1914. X             (*p_outf)("be an unsigned decimal integer in the range [0,1000].\n");
  1915. X            }
  1916. X          else
  1917. X             p_op->op_w_i=i;
  1918. X          break;
  1919. X       case 'X':
  1920. X          if (opsign_active) p_op->op_x_b=opsign;
  1921. X          strcpy(&p_op->op_x_s[0],&fn_temp[0]);
  1922. X          break;
  1923. X       case 'K':
  1924. X          if (opsign_active) p_op->op_k_b=opsign;
  1925. X          if (strlen(fn_temp)>0)
  1926. X            {
  1927. X     ECHO_CL; wl_caret(3+p_startopt-comline,p_outf);
  1928. X             (*p_outf)("FunnelWeb command line syntax error.\n");
  1929. X             (*p_outf)("The K option does not take an argument.\n");
  1930. X            }
  1931. X          break;
  1932. X       case 'H':
  1933. X          if (opsign_active) p_op->op_h_b=opsign;
  1934. X          if (strlen(&fn_temp[0])>0)
  1935. X          if (strlen(&fn_temp[0]) > HL_NMLEN)
  1936. X            {
  1937. X     ECHO_CL; wl_caret(3+p_startopt-comline,p_outf);
  1938. X             (*p_outf)("FunnelWeb command line syntax error.\n");
  1939. X             (*p_outf)("The H option string argument is too long.\n");
  1940. X             (*p_outf)("Try +Hmenu for a list of help message names.\n");
  1941. X            }
  1942. X          else
  1943. X             if (hel_num(&fn_temp[0]) == HL_ERR)
  1944. X            {
  1945. X     ECHO_CL; wl_caret(3+p_startopt-comline,p_outf);
  1946. X             (*p_outf)("FunnelWeb command line syntax error.\n");
  1947. X             (*p_outf)("Unrecognised message name in argument to H option.\n");
  1948. X             (*p_outf)("Try +Hmenu for a list of help message names.\n");
  1949. X            }
  1950. X          else
  1951. X             strcpy(&p_op->op_h_s[0],&fn_temp[0]);
  1952. X          break;
  1953. X       case 'B':
  1954. X         {
  1955. X          uword i;
  1956. X          if (strlen(fn_temp)==0)
  1957. X            {
  1958. X     ECHO_CL; wl_caret(3+p_startopt-comline,p_outf);
  1959. X             (*p_outf)("FunnelWeb command line syntax error.\n");
  1960. X             (*p_outf)("The B option must be followed by one or more digits.\n");
  1961. X             (*p_outf)("The digits must be in the range 1..7.\n");
  1962. X             break;
  1963. X            }
  1964. X          for (i=0;i<strlen(fn_temp);i++)
  1965. X             if (fn_temp[i]<'1' || fn_temp[i]>'7')
  1966. X               {
  1967. X
  1968. XECHO_CL; wl_caret(2+p_startopt-comline+(1+i),p_outf);
  1969. X                (*p_outf)("FunnelWeb command line syntax error.\n");
  1970. X                (*p_outf)("Error: Characters in B argument must be '1'..'7'.\n");
  1971. X                goto endbop;
  1972. X               }
  1973. X          if (opsign_active)
  1974. X             for (i=0;i<strlen(fn_temp);i++)
  1975. X                switch (fn_temp[i])
  1976. X                  {
  1977. X                   case '1': p_op->op_b1_b=opsign; break;
  1978. X                   case '2': p_op->op_b2_b=opsign; break;
  1979. X                   case '3': p_op->op_b3_b=opsign; break;
  1980. X                   case '4': p_op->op_b4_b=opsign; break;
  1981. X                   case '5': p_op->op_b5_b=opsign; break;
  1982. X                   case '6': p_op->op_b6_b=opsign; break;
  1983. X                   case '7': p_op->op_b7_b=opsign; break;
  1984. X                   default: as_bomb("op_add: b option case defaulted.");
  1985. X                  }
  1986. X          endbop:
  1987. X          break;
  1988. X         }
  1989. X       default:
  1990. X  ECHO_CL; wl_caret(2+p_startopt-comline,p_outf);
  1991. X          (*p_outf)("FunnelWeb command line syntax error.\n");
  1992. X          (*p_outf)("Error: Unknown option letter.\n");
  1993. X          (*p_outf)("Legal option letters are FIOTLCSWPXZ.\n");
  1994. X          (*p_outf)("(Note: But P is not yet implemented!)\n");
  1995. X          break;
  1996. X      }
  1997. X   } /* End while. */
  1998. X if (seen_error) goto failure;
  1999. X return TRUE;
  2000. X
  2001. X failure: ASSIGN(*p_op,op_save); return FALSE;
  2002. X}
  2003. X
  2004. X/******************************************************************************/
  2005. X
  2006. XEXPORT void op_wri(p_op,p_outf)
  2007. p_op_t p_op;
  2008. void   (*p_outf) P_((char *));
  2009. X{
  2010. X#define STC(BOOLV) ((BOOLV)?'+':'-')
  2011. X sprintf(linet1,"   %cB1 %cB2 %cB3 %cB4 %cB5 %cB6 %cB7\n",
  2012. X STC(p_op->op_b1_b),
  2013. X STC(p_op->op_b2_b),
  2014. X STC(p_op->op_b3_b),
  2015. X STC(p_op->op_b4_b),
  2016. X STC(p_op->op_b5_b),
  2017. X STC(p_op->op_b6_b),
  2018. X STC(p_op->op_b7_b));(*p_outf)(linet1);
  2019. X sprintf(linet1,"   +C%u\n" ,                    (unsigned) p_op->op_c_i );(*p_outf)(linet1);
  2020. X sprintf(linet1,"   %cD\n"  , STC(p_op->op_d_b)                          );(*p_outf)(linet1);
  2021. X sprintf(linet1,"   %cF%s\n", STC(p_op->op_f_b),            p_op->op_f_s );(*p_outf)(linet1);
  2022. X sprintf(linet1,"   %cH%s\n", STC(p_op->op_h_b),            p_op->op_h_s );(*p_outf)(linet1);
  2023. X sprintf(linet1,"   +I%s\n" ,                               p_op->op_i_s );(*p_outf)(linet1);
  2024. X sprintf(linet1,"   %cJ%s\n", STC(p_op->op_j_b),            p_op->op_j_s );(*p_outf)(linet1);
  2025. X sprintf(linet1,"   %cK\n"  , STC(p_op->op_k_b)                          );(*p_outf)(linet1);
  2026. X sprintf(linet1,"   %cL%s\n", STC(p_op->op_l_b),            p_op->op_l_s );(*p_outf)(linet1);
  2027. X sprintf(linet1,"   %cO%s\n", STC(p_op->op_o_b),            p_op->op_o_s );(*p_outf)(linet1);
  2028. X sprintf(linet1,"   %cQ\n"  , STC(p_op->op_q_b)                          );(*p_outf)(linet1);
  2029. X sprintf(linet1,"   %cS%u\n", STC(p_op->op_s_b), (unsigned) p_op->op_s_i );(*p_outf)(linet1);
  2030. X sprintf(linet1,"   %cT%s\n", STC(p_op->op_t_b),            p_op->op_t_s );(*p_outf)(linet1);
  2031. X sprintf(linet1,"   %cW%u\n", STC(p_op->op_w_b), (unsigned) p_op->op_w_i );(*p_outf)(linet1);
  2032. X sprintf(linet1,"   %cX%s\n", STC(p_op->op_x_b),            p_op->op_x_s );(*p_outf)(linet1);
  2033. X}
  2034. X
  2035. X/******************************************************************************/
  2036. X/*                              End of OPTION.C                               */
  2037. X/******************************************************************************/
  2038. X
  2039. END_OF_FILE
  2040. if test 16334 -ne `wc -c <'sources/option.c'`; then
  2041.     echo shar: \"'sources/option.c'\" unpacked with wrong size!
  2042. fi
  2043. # end of 'sources/option.c'
  2044. fi
  2045. if test -f 'sources/table.c' -a "${1}" != "-c" ; then 
  2046.   echo shar: Will not clobber existing file \"'sources/table.c'\"
  2047. else
  2048. echo shar: Extracting \"'sources/table.c'\" \(15854 characters\)
  2049. sed "s/^X//" >'sources/table.c' <<'END_OF_FILE'
  2050. X/*##############################################################################
  2051. X
  2052. XFUNNNELWEB COPYRIGHT
  2053. X====================
  2054. XFunnelWeb is a literate-programming macro preprocessor.
  2055. X
  2056. Copyright (C) 1992 Ross N. Williams.
  2057. X
  2058. X   Ross N. Williams
  2059. X   ross@spam.adelaide.edu.au
  2060. X   16 Lerwick Avenue, Hazelwood Park 5066, Australia.
  2061. X
  2062. This program is free software; you can redistribute it and/or modify
  2063. it under the terms of Version 2 of the GNU General Public License as
  2064. published by the Free Software Foundation.
  2065. X
  2066. This program is distributed WITHOUT ANY WARRANTY; without even the implied
  2067. warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  2068. See Version 2 of the GNU General Public License for more details.
  2069. X
  2070. You should have received a copy of Version 2 of the GNU General Public
  2071. License along with this program. If not, you can FTP the license from
  2072. prep.ai.mit.edu/pub/gnu/COPYING-2 or write to the Free Software
  2073. XFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  2074. X
  2075. Section 2a of the license requires that all changes to this file be
  2076. recorded prominently in this file. Please record all changes here.
  2077. X
  2078. Programmers:
  2079. X   RNW  Ross N. Williams  ross@spam.adelaide.edu.au
  2080. X
  2081. Changes:
  2082. X   07-May-1992  RNW  Program prepared for release under GNU GPL V2.
  2083. X
  2084. X##############################################################################*/
  2085. X
  2086. X
  2087. X/******************************************************************************/
  2088. X/*                                   TABLE.C                                  */
  2089. X/******************************************************************************/
  2090. X/*                                                                            */
  2091. X/* Notes                                                                      */
  2092. X/* -----                                                                      */
  2093. X/* - There are few comments at the start of each function. As definitions     */
  2094. X/*   appear in the .H file, and it is dangerous to duplicate definitions, I   */
  2095. X/*   have simply omitted them here.                                           */
  2096. X/*                                                                            */
  2097. X/* About The Cache                                                            */
  2098. X/* ---------------                                                            */
  2099. X/* A typical usage sequence for tables is for the user to first call tb_itb   */
  2100. X/* to see if a key is in the table and then call either tb_loo or tb_ins      */
  2101. X/* to lookup the value or to add a new (key,value) pair to the table.         */
  2102. X/* In order to avoid performing TWO searches down the binary tree in such     */
  2103. X/* cases, a CACHE is maintained in the table data structure between calls.    */
  2104. X/*                                                                            */
  2105. X/* ca_valid stores whether the cache contents are valid. If TRUE then:        */
  2106. X/* ca_p_key points to a key.                                                  */
  2107. X/* ca_p_node points to the node in the tree containing the key, or contains   */
  2108. X/*    NULL if no such node exists.                                            */
  2109. X/* ca_p_parent points to the node in the tree that is the parent of the node  */
  2110. X/*    ca_p_node in the tree, or (if ca_p_node==NULL) WOULD BE the parent if a */
  2111. X/*    node containing the key were inserted in the tree. If the tree is       */
  2112. X/*    currently empty, ca_p_parent will be NULL.                              */
  2113. X/*                                                                            */
  2114. X/******************************************************************************/
  2115. X
  2116. X#include "style.h"
  2117. X
  2118. X#include "as.h"
  2119. X#include "machin.h"
  2120. X#include "memory.h"
  2121. X
  2122. X/******************************************************************************/
  2123. X
  2124. X/* In order to catch uninitialized and corrupted tables, the first and last   */
  2125. X/* fields of legitimate table objects contain magic numbers. The following    */
  2126. X/* #defines give the values of these numbers. The first thing that each       */
  2127. X/* function of this package does is to check the two magic number fields of   */
  2128. X/* the table it has just been passed, and bomb the package if the fields have */
  2129. X/* the wrong values. This technique is likely to pick uninitialized tables,   */
  2130. X/* as well as tables that have been partially overwritten.                    */
  2131. X#define MAGIC_HEAD_VALUE  (53456839L)
  2132. X#define MAGIC_TAIL_VALUE  (28434290L)
  2133. X
  2134. X/* Comparing keys is messy and so we define a macro to help us out.           */
  2135. X#define key_compare(a,b) ((*(p_tb->p_kycm))((a),(b)))
  2136. X
  2137. X/******************************************************************************/
  2138. X
  2139. X/* The functions of the table abstraction pass keys and values exclusively    */
  2140. X/* using pointers. These two definitions define types for these pointers.     */
  2141. X/* Although the two types are both 'p_void', the different types are useful   */
  2142. X/* to indicate what is expected in each position of the parameter lists.      */
  2143. typedef p_void p_tbky_t;
  2144. typedef p_void p_tbvl_t;
  2145. X
  2146. X/* Define a type for a function to compare two keys. Such functions are       */
  2147. X/* needed to organize the storage of (key,value) pairs inside the table.      */
  2148. X/* Given the arguments are (a,b), the function should return:                 */
  2149. X/*    -1 if a<b                                                               */
  2150. X/*     0 if a==b                                                              */
  2151. X/*     1 if a>b                                                               */
  2152. X/* The user must create such a function and hand it to the 'tb_create'        */
  2153. X/* function when creating new a new table.                                    */
  2154. typedef sign (*p_kycm_t) P_((p_tbky_t,p_tbky_t));
  2155. X
  2156. X/* The (key,value) pairs in the table are stored in a binary tree. The tree   */
  2157. X/* is ordered by the key ordering function passed in at table creation.       */
  2158. typedef struct node_t_
  2159. X  {
  2160. X   struct node_t_ *p_left;
  2161. X   struct node_t_ *p_right;
  2162. X   struct node_t_ *p_parent;
  2163. X   p_tbky_t        p_key;
  2164. X   p_tbvl_t        p_value;
  2165. X  }
  2166. X  node_t;
  2167. typedef node_t *p_node_t;
  2168. X
  2169. X/* The type tb_t (table type) defines the root table data record. This      */
  2170. X/* record stores attributes of the table along with the main binary tree of */
  2171. X/* (key,value) pairs.                                                       */
  2172. typedef struct
  2173. X  {
  2174. X   ulong     magic_head;       /* Magic number to allow corruption checks.  */
  2175. X   size_t    key_bytes;        /* Number of bytes in a key.                 */
  2176. X   size_t    value_bytes;      /* Number of bytes in a value.               */
  2177. X   p_kycm_t  p_kycm;           /* Pointer to function to compare keys.      */
  2178. X   p_node_t  tree;             /* Ptr to root of (key,value) binary tree.   */
  2179. X   ulong     num_keys;         /* Number of (k,v) pairs in the table.       */
  2180. X   bool      ca_valid;         /* Cache: TRUE iff cache contents are valid. */
  2181. X   p_tbky_t  ca_p_key;         /* Cache: Key value cache contents refer to. */
  2182. X   p_node_t  ca_p_node;        /* Cache: Pointer to node in binary tree.    */
  2183. X   p_node_t  ca_p_parent;      /* Cache: Pointer to parent of ca_p_node.    */
  2184. X   p_node_t  p_read_next;      /* Pointer to next node to be read.          */
  2185. X   ulong     magic_tail;       /* Magic number to allow corruption checks.  */
  2186. X  } tb_t;
  2187. X
  2188. typedef tb_t *p_tb_t;           /* Pointer to main table record.            */
  2189. X
  2190. X/* Defining INTABLEC hides the abstract definition. */
  2191. X#define INTABLEC
  2192. X#include "table.h"
  2193. X
  2194. X/******************************************************************************/
  2195. X/*                              PRIVATE FUNCTIONS                             */
  2196. X/******************************************************************************/
  2197. X
  2198. LOCAL p_node_t new_node P_((p_tb_t,p_tbky_t,p_tbvl_t));
  2199. LOCAL p_node_t new_node(p_tb,p_tbky,p_tbvl)
  2200. X/* Creates a new tree node and returns a pointer to it.                       */
  2201. X/* p_tb is the table for which the new node is to be created.                 */
  2202. X/* p_tbky and p_tbvl point to the key and value to go in the new node.        */
  2203. X/* Assumes that a tb_check(p_tb) has already been performed by the caller.    */
  2204. p_tb_t   p_tb;
  2205. p_tbky_t p_tbky;
  2206. p_tbvl_t p_tbvl;
  2207. X{
  2208. X p_node_t p_node;
  2209. X
  2210. X p_node=(p_node_t) mm_temp(sizeof(node_t));
  2211. X
  2212. X p_node->p_left   = NULL;
  2213. X p_node->p_right  = NULL;
  2214. X p_node->p_parent = NULL;
  2215. X p_node->p_key    = mm_temp(p_tb->key_bytes  );
  2216. X p_node->p_value  = mm_temp(p_tb->value_bytes);
  2217. X
  2218. X memcpy(p_node->p_key  ,p_tbky,p_tb->key_bytes  );
  2219. X memcpy(p_node->p_value,p_tbvl,p_tb->value_bytes);
  2220. X
  2221. X return p_node;
  2222. X}
  2223. X
  2224. X/******************************************************************************/
  2225. X
  2226. LOCAL void tb_check P_((p_tb_t));
  2227. LOCAL void tb_check(p_tb)
  2228. X/* Accepts a pointer to a table and performs a series of checks to make sure  */
  2229. X/* that the table has not been corrupted in some way.                         */
  2230. p_tb_t p_tb;
  2231. X{
  2232. X as_cold(p_tb!=NULL,"tb_check: Table pointer is NULL.");
  2233. X as_cold(p_tb->magic_head==MAGIC_HEAD_VALUE,
  2234. X         "tb_check: Magic number at head of record is incorrect.");
  2235. X as_cold(p_tb->magic_tail==MAGIC_TAIL_VALUE,
  2236. X         "tb_check: Magic number at tail of record is incorrect.");
  2237. X}
  2238. X
  2239. X/******************************************************************************/
  2240. X
  2241. LOCAL p_node_t min_leaf P_((p_node_t));
  2242. LOCAL p_node_t min_leaf(p_node)
  2243. X/* Returns a pointer to the node that is leftmost (has the smallest value     */
  2244. X/* according to the ordering function) in the specified node's subtree.       */
  2245. p_node_t p_node;
  2246. X{
  2247. X if (p_node==NULL)
  2248. X    return NULL;
  2249. X while (p_node->p_left != NULL)
  2250. X    p_node=p_node->p_left;
  2251. X return p_node;
  2252. X}
  2253. X
  2254. X/******************************************************************************/
  2255. X
  2256. LOCAL p_node_t next_node P_((p_node_t));
  2257. LOCAL p_node_t next_node(p_node)
  2258. X/* Give a pointer to a node in the binary tree, returns a pointer to the next */
  2259. X/* node (in sequence defined by the order function) or NULL if the given node */
  2260. X/* is the last node in the ordered sequence.                                  */
  2261. p_node_t p_node;
  2262. X{
  2263. X /* If there is a right subtree, we need the minimum node of that subtree.    */
  2264. X if (p_node->p_right != NULL)
  2265. X    return min_leaf(p_node->p_right);
  2266. X
  2267. X /* Otherwise go up as far as possible through right arcs. */
  2268. X while (p_node->p_parent!=NULL && p_node->p_parent->p_right==p_node)
  2269. X    p_node=p_node->p_parent;
  2270. X return p_node->p_parent;
  2271. X}
  2272. X
  2273. X/******************************************************************************/
  2274. X
  2275. LOCAL void tb_search P_((p_tb_t,p_tbky_t));
  2276. LOCAL void tb_search(p_tb,p_tbky)
  2277. X/* Calling this function with a particular key value results in the cache     */
  2278. X/* becoming valid and containing the specified key.                           */
  2279. p_tb_t   p_tb;
  2280. p_tbky_t p_tbky;
  2281. X{
  2282. X p_node_t p,p_parent;
  2283. X
  2284. X tb_check(p_tb);
  2285. X
  2286. X /* Return if the cache is already up to date. */
  2287. X if (p_tb->ca_valid)
  2288. X   if (key_compare(p_tbky,p_tb->ca_p_key) == 0)
  2289. X      return;
  2290. X
  2291. X  p_parent=NULL;
  2292. X  p=p_tb->tree;
  2293. X  while (p != NULL)
  2294. X     switch(key_compare(p_tbky,p->p_key))
  2295. X       {
  2296. X        case -1: p_parent=p; p=p->p_left;  break;
  2297. X        case  1: p_parent=p; p=p->p_right; break;
  2298. X        case  0: goto found;
  2299. X        default:
  2300. X           as_bomb("tb_search: Key comparison function returned bad value.");
  2301. X       }
  2302. X  found:
  2303. X  p_tb->ca_valid    = TRUE;
  2304. X  memcpy(p_tb->ca_p_key,p_tbky,p_tb->key_bytes);
  2305. X  p_tb->ca_p_node   = p;
  2306. X  p_tb->ca_p_parent = p_parent;
  2307. X}
  2308. X
  2309. X/******************************************************************************/
  2310. X
  2311. LOCAL void des_tree P_((p_node_t));
  2312. LOCAL void des_tree(p_root)
  2313. p_node_t p_root;
  2314. X{
  2315. X if (p_root==NULL)
  2316. X    return;
  2317. X des_tree(p_root->p_left);
  2318. X des_tree(p_root->p_right);
  2319. X
  2320. X /* This is what we would need if it wasn't for the MM watermark system.      */
  2321. X /* DEALLOCATE(PV p_root); */
  2322. X}
  2323. X
  2324. X/******************************************************************************/
  2325. X/*                              EXPORTED FUNCTIONS                            */
  2326. X/******************************************************************************/
  2327. X
  2328. XEXPORT p_tb_t tb_cre(key_bytes,value_bytes,p_kycm)
  2329. size_t   key_bytes;
  2330. size_t   value_bytes;
  2331. p_kycm_t p_kycm;
  2332. X{
  2333. X p_tb_t p_tb;
  2334. X
  2335. X p_tb              = (p_tb_t) mm_temp(sizeof(tb_t));
  2336. X p_tb->magic_head  = MAGIC_HEAD_VALUE;
  2337. X p_tb->key_bytes   = key_bytes;
  2338. X p_tb->value_bytes = value_bytes;
  2339. X p_tb->p_kycm      = p_kycm;
  2340. X p_tb->tree        = NULL;
  2341. X p_tb->num_keys    = 0;
  2342. X p_tb->ca_valid    = FALSE;
  2343. X p_tb->ca_p_key    = (p_tbky_t) mm_temp(key_bytes);
  2344. X p_tb->ca_p_node   = NULL; /* This initialization not strictly necessary. */
  2345. X p_tb->ca_p_parent = NULL; /* This initialization not strictly necessary. */
  2346. X p_tb->p_read_next = NULL;
  2347. X p_tb->magic_tail  = MAGIC_TAIL_VALUE;
  2348. X
  2349. X return p_tb;
  2350. X}
  2351. X
  2352. X/******************************************************************************/
  2353. X
  2354. XEXPORT bool tb_itb(p_tb,p_tbky)
  2355. p_tb_t   p_tb;
  2356. p_tbky_t p_tbky;
  2357. X{
  2358. X tb_check(p_tb);
  2359. X
  2360. X tb_search(p_tb,p_tbky);
  2361. X return p_tb->ca_p_node != NULL;
  2362. X}
  2363. X
  2364. X/******************************************************************************/
  2365. X
  2366. XEXPORT void tb_loo(p_tb,p_tbky,p_tbvl)
  2367. p_tb_t   p_tb;
  2368. p_tbky_t p_tbky;
  2369. p_tbvl_t p_tbvl;
  2370. X{
  2371. X tb_check(p_tb);
  2372. X
  2373. X tb_search(p_tb,p_tbky);
  2374. X as_cold(p_tb->ca_p_node!=NULL,"tb_loo: Requested key is absent.");
  2375. X memcpy(p_tbvl,p_tb->ca_p_node->p_value,p_tb->value_bytes);
  2376. X}
  2377. X
  2378. X/******************************************************************************/
  2379. X
  2380. XEXPORT void tb_ins(p_tb,p_tbky,p_tbvl)
  2381. p_tb_t   p_tb;
  2382. p_tbky_t p_tbky;
  2383. p_tbvl_t p_tbvl;
  2384. X{
  2385. X p_node_t p_new;
  2386. X
  2387. X tb_check(p_tb);
  2388. X
  2389. X /* Validate the cache. Note: tb_search does it's own cache check. */
  2390. X tb_search(p_tb,p_tbky);
  2391. X
  2392. X /* Ensure that the table does not already contain the key. */
  2393. X as_cold(p_tb->ca_p_node==NULL,"tb_ins: Key is already present in the p_tb.");
  2394. X
  2395. X /* Create the new node. */
  2396. X p_new=new_node(p_tb,p_tbky,p_tbvl);
  2397. X
  2398. X /* Insert the new node into the tree. */
  2399. X if (p_tb->ca_p_parent==NULL)
  2400. X    p_tb->tree=p_new;
  2401. X else
  2402. X    switch(key_compare(p_tbky,p_tb->ca_p_parent->p_key))
  2403. X      {
  2404. X       case -1: p_tb->ca_p_parent->p_left =p_new; break;
  2405. X       case  1: p_tb->ca_p_parent->p_right=p_new; break;
  2406. X       default: as_bomb("tb_ins: Key comparison function is inconsistent.");
  2407. X      }
  2408. X p_new->p_parent=p_tb->ca_p_parent;
  2409. X
  2410. X /* Need to fiddle cache to make it correct, and inc num_keys. */
  2411. X p_tb->ca_p_node=p_new;
  2412. X p_tb->num_keys++;
  2413. X}
  2414. X
  2415. X/******************************************************************************/
  2416. X
  2417. XEXPORT ulong tb_len(p_tb)
  2418. p_tb_t p_tb;
  2419. X{
  2420. X tb_check(p_tb);
  2421. X return p_tb->num_keys;
  2422. X}
  2423. X
  2424. X/******************************************************************************/
  2425. X
  2426. XEXPORT void tb_fir(p_tb)
  2427. p_tb_t p_tb;
  2428. X{
  2429. X tb_check(p_tb);
  2430. X
  2431. X p_tb->p_read_next=min_leaf(p_tb->tree);
  2432. X}
  2433. X
  2434. X/******************************************************************************/
  2435. X
  2436. XEXPORT bool tb_rea(p_tb,p_tbky,p_tbvl)
  2437. p_tb_t    p_tb;
  2438. p_tbky_t  p_tbky;
  2439. p_tbvl_t  p_tbvl;
  2440. X{
  2441. X tb_check(p_tb);
  2442. X
  2443. X if (p_tb->p_read_next == NULL)
  2444. X    return FALSE;
  2445. X
  2446. X memcpy(p_tbky,p_tb->p_read_next->p_key  ,p_tb->key_bytes  );
  2447. X memcpy(p_tbvl,p_tb->p_read_next->p_value,p_tb->value_bytes);
  2448. X
  2449. X p_tb->p_read_next=next_node(p_tb->p_read_next);
  2450. X
  2451. X return TRUE;
  2452. X}
  2453. X
  2454. X/******************************************************************************/
  2455. X
  2456. X#if FALSE
  2457. XEXPORT void tb_des(p_tb)
  2458. p_tb_t p_tb;
  2459. X{
  2460. X /* This routine now unused because of the watermark system. */
  2461. X return;
  2462. X
  2463. X /* tb_check(p_tb); */
  2464. X
  2465. X /* Zap the magic numbers in case the memory is re-used in same alignment. */
  2466. X /* p_tb->magic_head=0; */
  2467. X /* p_tb->magic_tail=0; */
  2468. X
  2469. X /* This is what we would need if it wasn't for the MM watermark system.      */
  2470. X /* des_tree(p_tb->tree); */  /* Zap the binary tree. */
  2471. X /* DEALLOCATE(PV p_tb);  */  /* Zap the node itself. */
  2472. X}
  2473. X#endif
  2474. X
  2475. X/******************************************************************************/
  2476. X/*                                   TABLE.C                                  */
  2477. X/******************************************************************************/
  2478. X
  2479. END_OF_FILE
  2480. if test 15854 -ne `wc -c <'sources/table.c'`; then
  2481.     echo shar: \"'sources/table.c'\" unpacked with wrong size!
  2482. fi
  2483. # end of 'sources/table.c'
  2484. fi
  2485. if test -f 'sources/texhead.ctx' -a "${1}" != "-c" ; then 
  2486.   echo shar: Will not clobber existing file \"'sources/texhead.ctx'\"
  2487. else
  2488. echo shar: Extracting \"'sources/texhead.ctx'\" \(15944 characters\)
  2489. sed "s/^X//" >'sources/texhead.ctx' <<'END_OF_FILE'
  2490. X WX("%===================== Start of FunnelWeb TeX Definitions ======================");
  2491. X WX("");
  2492. X WX("");
  2493. X WX("% Version");
  2494. X WX("% -------");
  2495. X WX("% This is FunnelWeb TeX Macro Library Version 1.0.");
  2496. X WX("");
  2497. X WX("");
  2498. X WX("% Copyright");
  2499. X WX("% ---------");
  2500. X WX("% This set of FunnelWeb TeX definitions was written by Ross Williams and was");
  2501. X WX("% originally Copyright (C) 1992 Ross N. Williams.  However, I, Ross Williams,");
  2502. X WX("% hereby forego any claim to Copyright in this set of FunnelWeb TeX definitions");
  2503. X WX("% and hereby authorize that the set of TeX definitions pass into the public");
  2504. X WX("% domain. -- Ross N. Williams, 3:41pm 07-May-1992, Adelaide, Australia.");
  2505. X WX("");
  2506. X WX("");
  2507. X WX("% Modification");
  2508. X WX("% ------------");
  2509. X WX("% Please record all modifications to these TeX definitions here. Unless");
  2510. X WX("% otherwise specified, all modified definitions fall in the public domain too.");
  2511. X WX("%");
  2512. X WX("% Programmers:");
  2513. X WX("%    RNW  Ross N. Williams  ross@spam.adelaide.edu.au");
  2514. X WX("%");
  2515. X WX("% Changes:");
  2516. X WX("%    07-May-1992  RNW  Prepared this work for public domain release.");
  2517. X WX("%");
  2518. X WX("");
  2519. X WX("");
  2520. X WX("% General Comments");
  2521. X WX("% ----------------");
  2522. X WX("% This set of TeX definitions exists for two reasons:");
  2523. X WX("%");
  2524. X WX("%    1. To shorten and neaten the FunnelWeb TeX output.");
  2525. X WX("%    2. To allow users to fiddle with the output format in their input files");
  2526. X WX("%       (by inserting redefining \"\\def\"s) without having to resort to");
  2527. X WX("%       modifying the FunnelWeb code.");
  2528. X WX("%");
  2529. X WX("% The user is warned that these definitions may be changed from time to time");
  2530. X WX("% (but probably not much). The user should not be too sneaky. In particular,");
  2531. X WX("% users wishing to redefine some of these macros should do so in an explicitly");
  2532. X WX("% defined section at the top of their input file. This will mean that in the");
  2533. X WX("% event of problems, that section can simply be deleted or commented out to");
  2534. X WX("% allow the document to at least be typeset in the default format. Users should");
  2535. X WX("% limit themselves to redefining these macros in such a section and should");
  2536. X WX("% refrain from using the macros throughout their documents.");
  2537. X WX("");
  2538. X WX("");
  2539. X WX("% Environment Parameters");
  2540. X WX("% ----------------------");
  2541. X WX("% \\tolerance tells TeX how tolerant it should be about making bad line and");
  2542. X WX("% page breaks. Here we set it to it's maximum, as");
  2543. X WX("%   1) Computer programs are likely to cause lots of bad breaks.");
  2544. X WX("%   2) In most cases the user would probably rather get the TeX file through");
  2545. X WX("%      TeX without any errors than fiddle with spacings for perfection.");
  2546. X WX("\\tolerance=10000");
  2547. X WX("");
  2548. X WX("% I don't like indentation as it makes the page look more busy. Instead,");
  2549. X WX("% paragraphs are separated by a little space (see next).");
  2550. X WX("\\parindent=0pt");
  2551. X WX("");
  2552. X WX("% In many cases, users will produce documents with long runs of paragraphs.");
  2553. X WX("% In order to space out these paragraphs, it is convenient to maintain a");
  2554. X WX("% prevailing non-zero \\parskip (end-of-paragaph skip). The only trouble is");
  2555. X WX("% that the skip becomes a problem in macro definitions which require no skip");
  2556. X WX("% and so we have to turn the skip on and off. The following two macros");
  2557. X WX("% simplify this process.");
  2558. X WX("\\def\\fwparskipon{\\parskip=\\medskipamount}");
  2559. X WX("\\def\\fwparskipoff{\\parskip=0pt}");
  2560. X WX("\\fwparskipon");
  2561. X WX("");
  2562. X WX("% Setting raggedbottom allows TeX to leave a bit of space at the bottom of the");
  2563. X WX("% page in order to better vertically align the rest of the page (e.g. skips");
  2564. X WX("% won't stretch as much). It also means that headings are less likely to be");
  2565. X WX("% isolated at the bottom of the page without any following text.");
  2566. X WX("\\raggedbottom");
  2567. X WX("");
  2568. X WX("");
  2569. X WX("% Fonts");
  2570. X WX("% -----");
  2571. X WX("% Most of the typeset output is set in 10pt roman and 10pt tt font.");
  2572. X WX("% The major extra font needs spring from titles and headings.");
  2573. X WX("% For portability's sake we use only the following fonts:");
  2574. X WX("%    cmr10");
  2575. X WX("%    cmbx10");
  2576. X WX("%    cmtt10");
  2577. X WX("% and some enlargements of them. These fonts are all \"standard\" fonts");
  2578. X WX("% in Plain TeX. See The TeXbook p.350.");
  2579. X WX("\\font\\fwfontnote=cmr7");
  2580. X WX("");
  2581. X WX("\\font\\fwfontnorm=cmr10");
  2582. X WX("\\font\\fwfontnorma=cmr10 scaled \\magstep1");
  2583. X WX("\\font\\fwfontnormb=cmr10 scaled \\magstep2");
  2584. X WX("");
  2585. X WX("\\font\\fwfontbold=cmbx10");
  2586. X WX("\\font\\fwfontbolda=cmbx10 scaled \\magstep1");
  2587. X WX("\\font\\fwfontboldb=cmbx10 scaled \\magstep2");
  2588. X WX("\\font\\fwfontboldc=cmbx10 scaled \\magstep3");
  2589. X WX("\\font\\fwfontboldd=cmbx10 scaled \\magstep4");
  2590. X WX("");
  2591. X WX("");
  2592. X WX("% Macros for Stylistic Details");
  2593. X WX("% ----------------------------");
  2594. X WX("% This section contains all the fiddly little macros for setting the details");
  2595. X WX("% of each macro definition.");
  2596. X WX("");
  2597. X WX("% Macro definitions are sandwiched by calls to these macros which can be used");
  2598. X WX("% to sort out the spacing before and after the macro definition.");
  2599. X WX("\\def\\fwbeginmacro{\\fwparskipoff\\bigskip}");
  2600. X WX("\\def\\fwendmacro{\\fwparskipon\\par}");
  2601. X WX("");
  2602. X WX("% These macros deal with the macro name and definition line.");
  2603. X WX("\\def\\fwmacroname#1#2{{\\sl #1\\/}$\\lbrack$#2$\\rbrack$}");
  2604. X WX("\\def\\fwfilename#1#2{{\\bf #1}$\\lbrack$#2$\\rbrack$}");
  2605. X WX("\\def\\fwzero#1{{\\bf Z}}");
  2606. X WX("\\def\\fwmany#1{{\\bf M}}");
  2607. X WX("\\def\\fwequals{ $\\equiv$}");
  2608. X WX("\\def\\fwplusequals{ $+\\equiv$}");
  2609. X WX("");
  2610. X WX("% Now for the actual body of the definition. It looks nice to have the tt");
  2611. X WX("% code indented a little. Again, we use macros instead of writing direct TeX,");
  2612. X WX("% so as to allow the user to fiddle this stuff to taste without having to");
  2613. X WX("% modify the FunnelWeb C code.");
  2614. X WX("\\def\\fwodef{\\parindent=15pt\\vskip0pt$\\lbrace$\\parindent=20pt}");
  2615. X WX("\\def\\fwcdef{$\\rbrace$\\vskip0pt\\parindent=0pt}");
  2616. X WX("\\def\\fwoquote{`}");
  2617. X WX("\\def\\fwcquote{'}");
  2618. X WX("\\def\\fwoparen{$($}");
  2619. X WX("\\def\\fwcomma{$,$}");
  2620. X WX("\\def\\fwcparen{$)$}");
  2621. X WX("\\def\\fwparam#1{$\\diamond #1$}");
  2622. X WX("\\def\\fwparams#1{$(\\diamond #1)$}");
  2623. X WX("");
  2624. X WX("% These macros deal with the notes that are appended at the end of each");
  2625. X WX("% macro definition. Note that even though \\fwisafile,\\fwusedin, and \\fwseealso");
  2626. X WX("% have the same definition, they are given different names so as to allow the");
  2627. X WX("% user to redefine these macros to typeset each kind of information differently");
  2628. X WX("% if desired.");
  2629. X WX("\\def\\fwbeginmacronotes{\\begingroup\\baselineskip=9pt\\smallskip}");
  2630. X WX("\\def\\fwnote#1{{\\fwfontnote #1}\\par}");
  2631. X WX("\\def\\fwisafile#1{\\fwnote{#1}}");
  2632. X WX("\\def\\fwusedin#1{\\fwnote{#1}}");
  2633. X WX("\\def\\fwseealso#1{\\fwnote{#1}}");
  2634. X WX("\\def\\fwendmacronotes{\\endgroup}");
  2635. X WX("");
  2636. X WX("");
  2637. X WX("% Macros to Typeset Program Code Verbatim");
  2638. X WX("% ---------------------------------------");
  2639. X WX("% This is by far the hairiest and most difficult part of the typesetting task");
  2640. X WX("% because we have to turn off most of TeX's natural instincts in order to");
  2641. X WX("% typeset the program text exactly as it appears in the input file.");
  2642. X WX("% Two macros are defined to pull this off: \\fwbtx and \\fwverbatimgobble.");
  2643. X WX("% Their code was inspired by the following sections of \"The TeXbook\":");
  2644. X WX("%    Appendix D: Dirty Tricks, 3.Verbatim listing, p.380-382.");
  2645. X WX("%    Appendix E: Example Formats, p.421.");
  2646. X WX("% The \\fwbtx[ (for \"FunnelWeb Begin TeXt\") macro does most of the hard work.");
  2647. X WX("% The liberal use of \"%\" is because I don't understand TeX well enough to");
  2648. X WX("% understand when an end of line will cause trouble, and I am playing it safe.");
  2649. X WX("");
  2650. X WX("% Before defining the main \\fwbtx macro, we have to stash away some definitions");
  2651. X WX("% in the hidden part of TeX's environment. Let's hope that these \"hidden\"");
  2652. X WX("% definitions don't affect anything except what is desired to be affected.");
  2653. X WX("");
  2654. X WX("% The tt font in which we wish to set the text has two Latin lurking ligatures!");
  2655. X WX("% These are ?` and !`. To disable them, we define the left quote when ACTIVE");
  2656. X WX("% to be defined in such a way as to prevent ligatures. The main TeX text will");
  2657. X WX("% normally not be exposed to this definition because normally the leftquote");
  2658. X WX("% character is not active. The \\fwbtx macro temporarily makes the left quote");
  2659. X WX("% character active thus activating the deactivation of left quote ligatures.");
  2660. X WX("% See The TeXbook p.381.");
  2661. X WX("{\\catcode`\\`=\\active \\gdef`{\\relax\\lq}}");
  2662. X WX("");
  2663. X WX("% TeX is fairly carefree about spaces and so we have to make it more serious.");
  2664. X WX("% To do so we pull the same trick as above, setting up a definition for active");
  2665. X WX("% space, but only making space active during the span of the verbatim text.");
  2666. X WX("% In Plain TeX the active space is defined to be simply a space, but here we");
  2667. X WX("% define it to be a control space. This ensures that the space cannot");
  2668. X WX("% be gobbled up by one of TeX's mysterious mechanisms when activated.");
  2669. X WX("% See The TeXbook, p.381 and p.352.");
  2670. X WX("{\\obeyspaces\\global\\let =\\ }");
  2671. X WX("");
  2672. X WX("% Here is the main \\fwbtx verbatim text macro.");
  2673. X WX("% Note: The order in which all these pieces of business have to be done is");
  2674. X WX("% still a partial mystery to me. Don't fiddle with this stuff unless you");
  2675. X WX("% think you know what you are doing.");
  2676. X WX("\\def\\fwbtx[{%");
  2677. X WX("%");
  2678. X WX("% The funnies involved in getting verbatim output are safely housed inside");
  2679. X WX("% this \\begingroup, and the \\endgroup in \\fwverbatimgobble. Groups are used");
  2680. X WX("% instead of curly braces because we have to be able to signal the end of");
  2681. X WX("% this macro with a curly brace.");
  2682. X WX("\\begingroup%");
  2683. X WX("%");
  2684. X WX("% \\pars at the end of empty lines in the verbatim text won't come out normally");
  2685. X WX("% because TeX is in vertical mode and they get gobbled up. To prevent this,");
  2686. X WX("% we force \\par to exit vertical mode first. See The TeXbook p.381.");
  2687. X WX("\\def\\par{\\leavevmode\\endgraf}%");
  2688. X WX("%");
  2689. X WX("% Activate the leftquote character so as to avoid ligatures (see above).");
  2690. X WX("\\catcode`\\`=\\active%");
  2691. X WX("%");
  2692. X WX("% The \\obeylines macro simply defines end of line (^M) to be \\par. This ensures");
  2693. X WX("% that TeX will treat each verbatim line as a new paragraph.");
  2694. X WX("\\obeylines%");
  2695. X WX("%");
  2696. X WX("% To get verbatim output, we have to desex all the special characters. This");
  2697. X WX("% is explained in detail in The TeXbook p.380.");
  2698. X WX("\\def\\do##1{\\catcode`##1=12 }\\dospecials%");
  2699. X WX("%");
  2700. X WX("% Activate the space character so as to make TeX treat blanks seriously.");
  2701. X WX("% This activation invokes an eralier definition (see above).");
  2702. X WX("\\obeyspaces");
  2703. X WX("%");
  2704. X WX("% Interparagraph skips do not help the cause.");
  2705. X WX("% Note: We have to preserve the indentation though, as the code is actually");
  2706. X WX("% indented in the final output. See \\fwodef in an earlier section.");
  2707. X WX("\\parskip=0pt%");
  2708. X WX("%");
  2709. X WX("% We typeset the verbatim text in tt font (courier on the Macintosh) for a");
  2710. X WX("% number of reasons:");
  2711. X WX("%    - tt font has the same horizontal spacing for each character.");
  2712. X WX("%    - tt font covers the ASCII character set.");
  2713. X WX("%    - tt font doesn't have many surprises (e.g. ligatures).");
  2714. X WX("%    - tt font looks much what you might see on a computer terminal screen.");
  2715. X WX("\\tt%");
  2716. X WX("%");
  2717. X WX("% Having set up an environment for verbatim, we are ready to use it.");
  2718. X WX("% By invoking \\fwverbatimgobble, this \\fwbtx macro gobbles up text verbatim (as");
  2719. X WX("% part of the parameter of \\fwverbatimgobble) until it sees the termination");
  2720. X WX("% string \"]fwetx=\" (the \"=\" was thrown in to add obscurity as this sequence");
  2721. X WX("% must never occur in the verbatim text).");
  2722. X WX("\\fwverbatimgobble}");
  2723. X WX("");
  2724. X WX("% The \\fwverbatimgobble macro exists to allow \\fwbtx to bracket verbatim text.");
  2725. X WX("\\def\\fwverbatimgobble#1]fwetx={#1\\endgroup}");
  2726. X WX("");
  2727. X WX("");
  2728. X WX("% Table of Contents");
  2729. X WX("% -----------------");
  2730. X WX("% The five levels of table of contents that FunnelWeb supports are identified");
  2731. X WX("% by the five letters [A..E]. These are used throughout the following macros.");
  2732. X WX("");
  2733. X WX("% The following macros are utilities to the TOC macros to follow.");
  2734. X WX("\\def\\fwrule{\\medskip\\hrule\\medskip}");
  2735. X WX("\\def\\fwqh{\\hskip1.5em\\relax}");
  2736. X WX("\\def\\fwbeforesec{\\penalty-200\\bigskip\\medskip\\par}");
  2737. X WX("");
  2738. X WX("% The following macros are used to typeset the table of contents.");
  2739. X WX("\\def\\fwtocstart#1{\\fwrule\\leftline{\\fwfontbolda Table of Contents}\\fwrule}");
  2740. X WX("\\def\\fwtoca#1#2{\\leftline{{\\bf #1 #2}}}");
  2741. X WX("\\def\\fwtocb#1#2{\\leftline{\\fwqh #1 #2}}");
  2742. X WX("\\def\\fwtocc#1#2{\\leftline{\\fwqh\\fwqh #1 #2}}");
  2743. X WX("\\def\\fwtocd#1#2{\\leftline{\\fwqh\\fwqh\\fwqh #1 #2}}");
  2744. X WX("\\def\\fwtoce#1#2{\\leftline{\\fwqh\\fwqh\\fwqh\\fwqh #1 #2}}");
  2745. X WX("\\def\\fwtocfinish#1{\\fwrule}");
  2746. X WX("");
  2747. X WX("% The following \"library\" macros define five different strengths of headings");
  2748. X WX("% which can be used later in the section macros.");
  2749. X WX("\\def\\fwliba#1#2{\\vfill\\eject{\\fwfontboldc #1 #2}\\penalty200\\smallskip}");
  2750. X WX("\\def\\fwlibb#1#2{\\fwbeforesec{\\fwfontboldb #1 #2}\\penalty200\\smallskip}");
  2751. X WX("\\def\\fwlibc#1#2{\\fwbeforesec{\\fwfontnormb #1 #2}\\penalty200\\smallskip}");
  2752. X WX("\\def\\fwlibd#1#2{\\fwbeforesec{\\bf          #1 #2}\\penalty200}");
  2753. X WX("\\def\\fwlibe#1#2{\\fwbeforesec{\\bf          #1 #2}}");
  2754. X WX("");
  2755. X WX("% Here are the macros that actually typeset the section headings throughout");
  2756. X WX("% the document. The fwlib system has been employed so as to easily allow the");
  2757. X WX("% user to redefine the strengths of headings to taste. For example, the");
  2758. X WX("% user could insert in the input document a similar set of definitions to these");
  2759. X WX("% but with the b..e headings set to \\fwlibc. This would tone down the output.");
  2760. X WX("\\def\\fwseca#1#2{\\fwliba{#1}{#2}}");
  2761. X WX("\\def\\fwsecb#1#2{\\fwlibb{#1}{#2}}");
  2762. X WX("\\def\\fwsecc#1#2{\\fwlibc{#1}{#2}}");
  2763. X WX("\\def\\fwsecd#1#2{\\fwlibd{#1}{#2}}");
  2764. X WX("\\def\\fwsece#1#2{\\fwlibe{#1}{#2}}");
  2765. X WX("");
  2766. X WX("");
  2767. X WX("% Support for Explicit Typesetting");
  2768. X WX("% --------------------------------");
  2769. X WX("% FunnelWeb supports pragmas and other constructs that allow");
  2770. X WX("% typesetter-independent typesetting commands to be given. The");
  2771. X WX("% following macros support these features.");
  2772. X WX("");
  2773. X WX("% The in-text literal @{sloth@} and emphasise @[walrus@] features.");
  2774. X WX("\\def\\fwlit#1{{\\tt #1}}");
  2775. X WX("\\def\\fwemp#1{{\\it #1}}");
  2776. X WX("");
  2777. X WX("% The \"@p new_page\" pragma.");
  2778. X WX("\\def\\fwnewpage{\\vfill\\eject}");
  2779. X WX("");
  2780. X WX("% The \"@p vskip Nmm\" pragma.");
  2781. X WX("\\def\\fwvskip#1{\\null\\vskip #1mm}");
  2782. X WX("");
  2783. X WX("% The \"@p title <font> <align> <text>\" pragma.");
  2784. X WX("\\def\\fwfontnormal#1{{\\fwfontnorm {#1}}}");
  2785. X WX("\\def\\fwfonttitle#1{{\\fwfontboldd {#1}}}");
  2786. X WX("\\def\\fwfontsmalltitle#1{{\\fwfontboldb {#1}}}");
  2787. X WX("\\def\\fwleftline#1{\\leftline{#1}}");
  2788. X WX("\\def\\fwcenterline#1{\\centerline{#1}}");
  2789. X WX("\\def\\fwrightline#1{\\rightline{#1}}");
  2790. X WX("");
  2791. X WX("");
  2792. X WX("% Support for Old FunnelWeb");
  2793. X WX("% -------------------------");
  2794. X WX("% The following macros were used extensively in the first version of");
  2795. X WX("% FunnelWeb and are retained so that these older input files will still");
  2796. X WX("% typeset cleanly.");
  2797. X WX("\\def\\p#1{{\\tt #1}}  % P for Program text.");
  2798. X WX("\\def\\flagpage#1#2{");
  2799. X WX("   \\null");
  2800. X WX("   \\vfill");
  2801. X WX("   \\centerline{\\fwfontboldd #1}");
  2802. X WX("   \\vskip 1cm");
  2803. X WX("   \\centerline{\\fwfontboldd #2}");
  2804. X WX("   \\vfill");
  2805. X WX("   \\null");
  2806. X WX("   \\vfill");
  2807. X WX("}");
  2808. X WX("");
  2809. X WX("%====================== End of FunnelWeb TeX Definitions =======================");
  2810. END_OF_FILE
  2811. if test 15944 -ne `wc -c <'sources/texhead.ctx'`; then
  2812.     echo shar: \"'sources/texhead.ctx'\" unpacked with wrong size!
  2813. fi
  2814. # end of 'sources/texhead.ctx'
  2815. fi
  2816. echo shar: End of archive 7 \(of 20\).
  2817. cp /dev/null ark7isdone
  2818. MISSING=""
  2819. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do
  2820.     if test ! -f ark${I}isdone ; then
  2821.     MISSING="${MISSING} ${I}"
  2822.     fi
  2823. done
  2824. if test "${MISSING}" = "" ; then
  2825.     echo You have unpacked all 20 archives.
  2826.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2827. else
  2828.     echo You still need to unpack the following archives:
  2829.     echo "        " ${MISSING}
  2830. fi
  2831. ##  End of shell archive.
  2832. exit 0
  2833.