home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-04-10 | 116.3 KB | 2,834 lines |
- Newsgroups: comp.sources.unix
- From: ross@spam.adelaide.edu.au (Ross Williams)
- Subject: v26i127: funnelweb - a tool for literate programming in C, Part07/20
- Sender: unix-sources-moderator@vix.com
- Approved: paul@vix.com
-
- Submitted-By: ross@spam.adelaide.edu.au (Ross Williams)
- Posting-Number: Volume 26, Issue 127
- Archive-Name: funnelweb/part07
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 7 (of 20)."
- # Contents: answers/ex11.tex answers/ex12.tex answers/ex14.tex
- # answers/ex15.tex sources/option.c sources/table.c
- # sources/texhead.ctx
- # Wrapped by vixie@gw.home.vix.com on Sun Apr 11 11:00:19 1993
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'answers/ex11.tex' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'answers/ex11.tex'\"
- else
- echo shar: Extracting \"'answers/ex11.tex'\" \(16100 characters\)
- sed "s/^X//" >'answers/ex11.tex' <<'END_OF_FILE'
- X
- X%*******************************************************************************
- X%* START OF AUTOMATICALLY GENERATED TEX FILE *
- X%*******************************************************************************
- X%* *
- X%* This TeX file was automatically generated by the FunnelWeb preprocessor. *
- X%* You can typeset this file to produce printed documentation by running it *
- X%* through the TeX typesetter using a command such as: *
- X%* tex thisfilename *
- X%* The resultant file thisfilename.dvi can be printed using a command such as: *
- X%* lpr -Pcslw -d thisfilename.dvi *
- X%* *
- X%* FunnelWeb is a preprocessor that allows programmers to weave programs and *
- X%* their documentation together in a single document. The FunnelWeb program *
- X%* analyses such documents producing both program files and typeset *
- X%* documentation such as this TeX file. *
- X%* FunnelWeb was created by Ross Williams. *
- X%* *
- X%* For more information on FunnelWeb look in the following FTP archive: *
- X%* Machine : sirius.itd.adelaide.edu.au [IP=129.127.40.3]. *
- X%* Directory: ~pub/funnelweb/ *
- X%* (or some other appropriately named directory). *
- X%* or email Ross Williams at ross@spam.adelaide.edu.au *
- X%* *
- X%*******************************************************************************
- X
- X
- X%===================== Start of FunnelWeb TeX Definitions ======================
- X
- X
- X% Version
- X% -------
- X% This is FunnelWeb TeX Macro Library Version 1.0.
- X
- X
- X% Copyright
- X% ---------
- X% This set of FunnelWeb TeX definitions was written by Ross Williams and was
- X% originally Copyright (C) 1992 Ross N. Williams. However, I, Ross Williams,
- X% hereby forego any claim to Copyright in this set of FunnelWeb TeX definitions
- X% and hereby authorize that the set of TeX definitions pass into the public
- X% domain. -- Ross N. Williams, 3:41pm 07-May-1992, Adelaide, Australia.
- X
- X
- X% Modification
- X% ------------
- X% Please record all modifications to these TeX definitions here. Unless
- X% otherwise specified, all modified definitions fall in the public domain too.
- X%
- X% Programmers:
- X% RNW Ross N. Williams ross@spam.adelaide.edu.au
- X%
- X% Changes:
- X% 07-May-1992 RNW Prepared this work for public domain release.
- X%
- X
- X
- X% General Comments
- X% ----------------
- X% This set of TeX definitions exists for two reasons:
- X%
- X% 1. To shorten and neaten the FunnelWeb TeX output.
- X% 2. To allow users to fiddle with the output format in their input files
- X% (by inserting redefining "\def"s) without having to resort to
- X% modifying the FunnelWeb code.
- X%
- X% The user is warned that these definitions may be changed from time to time
- X% (but probably not much). The user should not be too sneaky. In particular,
- X% users wishing to redefine some of these macros should do so in an explicitly
- X% defined section at the top of their input file. This will mean that in the
- X% event of problems, that section can simply be deleted or commented out to
- X% allow the document to at least be typeset in the default format. Users should
- X% limit themselves to redefining these macros in such a section and should
- X% refrain from using the macros throughout their documents.
- X
- X
- X% Environment Parameters
- X% ----------------------
- X% \tolerance tells TeX how tolerant it should be about making bad line and
- X% page breaks. Here we set it to it's maximum, as
- X% 1) Computer programs are likely to cause lots of bad breaks.
- X% 2) In most cases the user would probably rather get the TeX file through
- X% TeX without any errors than fiddle with spacings for perfection.
- X\tolerance=10000
- X
- X% I don't like indentation as it makes the page look more busy. Instead,
- X% paragraphs are separated by a little space (see next).
- X\parindent=0pt
- X
- X% In many cases, users will produce documents with long runs of paragraphs.
- X% In order to space out these paragraphs, it is convenient to maintain a
- X% prevailing non-zero \parskip (end-of-paragaph skip). The only trouble is
- X% that the skip becomes a problem in macro definitions which require no skip
- X% and so we have to turn the skip on and off. The following two macros
- X% simplify this process.
- X\def\fwparskipon{\parskip=\medskipamount}
- X\def\fwparskipoff{\parskip=0pt}
- X\fwparskipon
- X
- X% Setting raggedbottom allows TeX to leave a bit of space at the bottom of the
- X% page in order to better vertically align the rest of the page (e.g. skips
- X% won't stretch as much). It also means that headings are less likely to be
- X% isolated at the bottom of the page without any following text.
- X\raggedbottom
- X
- X
- X% Fonts
- X% -----
- X% Most of the typeset output is set in 10pt roman and 10pt tt font.
- X% The major extra font needs spring from titles and headings.
- X% For portability's sake we use only the following fonts:
- X% cmr10
- X% cmbx10
- X% cmtt10
- X% and some enlargements of them. These fonts are all "standard" fonts
- X% in Plain TeX. See The TeXbook p.350.
- X\font\fwfontnote=cmr7
- X
- X\font\fwfontnorm=cmr10
- X\font\fwfontnorma=cmr10 scaled \magstep1
- X\font\fwfontnormb=cmr10 scaled \magstep2
- X
- X\font\fwfontbold=cmbx10
- X\font\fwfontbolda=cmbx10 scaled \magstep1
- X\font\fwfontboldb=cmbx10 scaled \magstep2
- X\font\fwfontboldc=cmbx10 scaled \magstep3
- X\font\fwfontboldd=cmbx10 scaled \magstep4
- X
- X
- X% Macros for Stylistic Details
- X% ----------------------------
- X% This section contains all the fiddly little macros for setting the details
- X% of each macro definition.
- X
- X% Macro definitions are sandwiched by calls to these macros which can be used
- X% to sort out the spacing before and after the macro definition.
- X\def\fwbeginmacro{\fwparskipoff\bigskip}
- X\def\fwendmacro{\fwparskipon\par}
- X
- X% These macros deal with the macro name and definition line.
- X\def\fwmacroname#1#2{{\sl #1\/}$\lbrack$#2$\rbrack$}
- X\def\fwfilename#1#2{{\bf #1}$\lbrack$#2$\rbrack$}
- X\def\fwzero#1{{\bf Z}}
- X\def\fwmany#1{{\bf M}}
- X\def\fwequals{ $\equiv$}
- X\def\fwplusequals{ $+\equiv$}
- X
- X% Now for the actual body of the definition. It looks nice to have the tt
- X% code indented a little. Again, we use macros instead of writing direct TeX,
- X% so as to allow the user to fiddle this stuff to taste without having to
- X% modify the FunnelWeb C code.
- X\def\fwodef{\parindent=15pt\vskip0pt$\lbrace$\parindent=20pt}
- X\def\fwcdef{$\rbrace$\vskip0pt\parindent=0pt}
- X\def\fwoquote{`}
- X\def\fwcquote{'}
- X\def\fwoparen{$($}
- X\def\fwcomma{$,$}
- X\def\fwcparen{$)$}
- X\def\fwparam#1{$\diamond #1$}
- X\def\fwparams#1{$(\diamond #1)$}
- X
- X% These macros deal with the notes that are appended at the end of each
- X% macro definition. Note that even though \fwisafile,\fwusedin, and \fwseealso
- X% have the same definition, they are given different names so as to allow the
- X% user to redefine these macros to typeset each kind of information differently
- X% if desired.
- X\def\fwbeginmacronotes{\begingroup\baselineskip=9pt\smallskip}
- X\def\fwnote#1{{\fwfontnote #1}\par}
- X\def\fwisafile#1{\fwnote{#1}}
- X\def\fwusedin#1{\fwnote{#1}}
- X\def\fwseealso#1{\fwnote{#1}}
- X\def\fwendmacronotes{\endgroup}
- X
- X
- X% Macros to Typeset Program Code Verbatim
- X% ---------------------------------------
- X% This is by far the hairiest and most difficult part of the typesetting task
- X% because we have to turn off most of TeX's natural instincts in order to
- X% typeset the program text exactly as it appears in the input file.
- X% Two macros are defined to pull this off: \fwbtx and \fwverbatimgobble.
- X% Their code was inspired by the following sections of "The TeXbook":
- X% Appendix D: Dirty Tricks, 3.Verbatim listing, p.380-382.
- X% Appendix E: Example Formats, p.421.
- X% The \fwbtx[ (for "FunnelWeb Begin TeXt") macro does most of the hard work.
- X% The liberal use of "%" is because I don't understand TeX well enough to
- X% understand when an end of line will cause trouble, and I am playing it safe.
- X
- X% Before defining the main \fwbtx macro, we have to stash away some definitions
- X% in the hidden part of TeX's environment. Let's hope that these "hidden"
- X% definitions don't affect anything except what is desired to be affected.
- X
- X% The tt font in which we wish to set the text has two Latin lurking ligatures!
- X% These are ?` and !`. To disable them, we define the left quote when ACTIVE
- X% to be defined in such a way as to prevent ligatures. The main TeX text will
- X% normally not be exposed to this definition because normally the leftquote
- X% character is not active. The \fwbtx macro temporarily makes the left quote
- X% character active thus activating the deactivation of left quote ligatures.
- X% See The TeXbook p.381.
- X{\catcode`\`=\active \gdef`{\relax\lq}}
- X
- X% TeX is fairly carefree about spaces and so we have to make it more serious.
- X% To do so we pull the same trick as above, setting up a definition for active
- X% space, but only making space active during the span of the verbatim text.
- X% In Plain TeX the active space is defined to be simply a space, but here we
- X% define it to be a control space. This ensures that the space cannot
- X% be gobbled up by one of TeX's mysterious mechanisms when activated.
- X% See The TeXbook, p.381 and p.352.
- X{\obeyspaces\global\let =\ }
- X
- X% Here is the main \fwbtx verbatim text macro.
- X% Note: The order in which all these pieces of business have to be done is
- X% still a partial mystery to me. Don't fiddle with this stuff unless you
- X% think you know what you are doing.
- X\def\fwbtx[{%
- X%
- X% The funnies involved in getting verbatim output are safely housed inside
- X% this \begingroup, and the \endgroup in \fwverbatimgobble. Groups are used
- X% instead of curly braces because we have to be able to signal the end of
- X% this macro with a curly brace.
- X\begingroup%
- X%
- X% \pars at the end of empty lines in the verbatim text won't come out normally
- X% because TeX is in vertical mode and they get gobbled up. To prevent this,
- X% we force \par to exit vertical mode first. See The TeXbook p.381.
- X\def\par{\leavevmode\endgraf}%
- X%
- X% Activate the leftquote character so as to avoid ligatures (see above).
- X\catcode`\`=\active%
- X%
- X% The \obeylines macro simply defines end of line (^M) to be \par. This ensures
- X% that TeX will treat each verbatim line as a new paragraph.
- X\obeylines%
- X%
- X% To get verbatim output, we have to desex all the special characters. This
- X% is explained in detail in The TeXbook p.380.
- X\def\do##1{\catcode`##1=12 }\dospecials%
- X%
- X% Activate the space character so as to make TeX treat blanks seriously.
- X% This activation invokes an eralier definition (see above).
- X\obeyspaces
- X%
- X% Interparagraph skips do not help the cause.
- X% Note: We have to preserve the indentation though, as the code is actually
- X% indented in the final output. See \fwodef in an earlier section.
- X\parskip=0pt%
- X%
- X% We typeset the verbatim text in tt font (courier on the Macintosh) for a
- X% number of reasons:
- X% - tt font has the same horizontal spacing for each character.
- X% - tt font covers the ASCII character set.
- X% - tt font doesn't have many surprises (e.g. ligatures).
- X% - tt font looks much what you might see on a computer terminal screen.
- X\tt%
- X%
- X% Having set up an environment for verbatim, we are ready to use it.
- X% By invoking \fwverbatimgobble, this \fwbtx macro gobbles up text verbatim (as
- X% part of the parameter of \fwverbatimgobble) until it sees the termination
- X% string "]fwetx=" (the "=" was thrown in to add obscurity as this sequence
- X% must never occur in the verbatim text).
- X\fwverbatimgobble}
- X
- X% The \fwverbatimgobble macro exists to allow \fwbtx to bracket verbatim text.
- X\def\fwverbatimgobble#1]fwetx={#1\endgroup}
- X
- X
- X% Table of Contents
- X% -----------------
- X% The five levels of table of contents that FunnelWeb supports are identified
- X% by the five letters [A..E]. These are used throughout the following macros.
- X
- X% The following macros are utilities to the TOC macros to follow.
- X\def\fwrule{\medskip\hrule\medskip}
- X\def\fwqh{\hskip1.5em\relax}
- X\def\fwbeforesec{\penalty-200\bigskip\medskip\par}
- X
- X% The following macros are used to typeset the table of contents.
- X\def\fwtocstart#1{\fwrule\leftline{\fwfontbolda Table of Contents}\fwrule}
- X\def\fwtoca#1#2{\leftline{{\bf #1 #2}}}
- X\def\fwtocb#1#2{\leftline{\fwqh #1 #2}}
- X\def\fwtocc#1#2{\leftline{\fwqh\fwqh #1 #2}}
- X\def\fwtocd#1#2{\leftline{\fwqh\fwqh\fwqh #1 #2}}
- X\def\fwtoce#1#2{\leftline{\fwqh\fwqh\fwqh\fwqh #1 #2}}
- X\def\fwtocfinish#1{\fwrule}
- X
- X% The following "library" macros define five different strengths of headings
- X% which can be used later in the section macros.
- X\def\fwliba#1#2{\vfill\eject{\fwfontboldc #1 #2}\penalty200\smallskip}
- X\def\fwlibb#1#2{\fwbeforesec{\fwfontboldb #1 #2}\penalty200\smallskip}
- X\def\fwlibc#1#2{\fwbeforesec{\fwfontnormb #1 #2}\penalty200\smallskip}
- X\def\fwlibd#1#2{\fwbeforesec{\bf #1 #2}\penalty200}
- X\def\fwlibe#1#2{\fwbeforesec{\bf #1 #2}}
- X
- X% Here are the macros that actually typeset the section headings throughout
- X% the document. The fwlib system has been employed so as to easily allow the
- X% user to redefine the strengths of headings to taste. For example, the
- X% user could insert in the input document a similar set of definitions to these
- X% but with the b..e headings set to \fwlibc. This would tone down the output.
- X\def\fwseca#1#2{\fwliba{#1}{#2}}
- X\def\fwsecb#1#2{\fwlibb{#1}{#2}}
- X\def\fwsecc#1#2{\fwlibc{#1}{#2}}
- X\def\fwsecd#1#2{\fwlibd{#1}{#2}}
- X\def\fwsece#1#2{\fwlibe{#1}{#2}}
- X
- X
- X% Support for Explicit Typesetting
- X% --------------------------------
- X% FunnelWeb supports pragmas and other constructs that allow
- X% typesetter-independent typesetting commands to be given. The
- X% following macros support these features.
- X
- X% The in-text literal @{sloth@} and emphasise @[walrus@] features.
- X\def\fwlit#1{{\tt #1}}
- X\def\fwemp#1{{\it #1}}
- X
- X% The "@p new_page" pragma.
- X\def\fwnewpage{\vfill\eject}
- X
- X% The "@p vskip Nmm" pragma.
- X\def\fwvskip#1{\null\vskip #1mm}
- X
- X% The "@p title <font> <align> <text>" pragma.
- X\def\fwfontnormal#1{{\fwfontnorm {#1}}}
- X\def\fwfonttitle#1{{\fwfontboldd {#1}}}
- X\def\fwfontsmalltitle#1{{\fwfontboldb {#1}}}
- X\def\fwleftline#1{\leftline{#1}}
- X\def\fwcenterline#1{\centerline{#1}}
- X\def\fwrightline#1{\rightline{#1}}
- X
- X
- X% Support for Old FunnelWeb
- X% -------------------------
- X% The following macros were used extensively in the first version of
- X% FunnelWeb and are retained so that these older input files will still
- X% typeset cleanly.
- X\def\p#1{{\tt #1}} % P for Program text.
- X\def\flagpage#1#2{
- X \null
- X \vfill
- X \centerline{\fwfontboldd #1}
- X \vskip 1cm
- X \centerline{\fwfontboldd #2}
- X \vfill
- X \null
- X \vfill
- X}
- X
- X%====================== End of FunnelWeb TeX Definitions =======================
- XEX11: This example shows how FunnelWeb typesets macros, typesetter commands
- X and free text.
- X
- You are reading some free text before the macro. Free text can consist
- of any text (not containing the FunnelWeb special character) including
- typesetter commands
- such as \$, \%, \#, and $\backslash$TeX$\{$$\}$ which
- will be typeset to appear exactly as they do in the input file!
- Look out! Here comes a macro!
- X
- X\fwbeginmacro
- X\fwfilename{ex11.out}{1}\fwequals \fwodef \fwbtx[This text is part of
- a macro definition.
- X]fwetx=%
- X\fwcdef
- X\fwbeginmacronotes
- X\fwisafile{This macro is attached to an output file.}
- X\fwendmacronotes
- X\fwendmacro
- X
- X
- This is free text following the macro. This sentence contains
- two \fwlit{inline} typesetter \fwemp{directives}.
- Now here is a non-inline typesetting directive.
- X
- X
- X\fwnewpage
- X
- X
- This sentence will appear on the next page.
- X\bye
- X
- X
- X%*******************************************************************************
- X%* END OF AUTOMATICALLY GENERATED TEX FILE *
- X%*******************************************************************************
- X
- END_OF_FILE
- if test 16100 -ne `wc -c <'answers/ex11.tex'`; then
- echo shar: \"'answers/ex11.tex'\" unpacked with wrong size!
- fi
- # end of 'answers/ex11.tex'
- fi
- if test -f 'answers/ex12.tex' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'answers/ex12.tex'\"
- else
- echo shar: Extracting \"'answers/ex12.tex'\" \(16184 characters\)
- sed "s/^X//" >'answers/ex12.tex' <<'END_OF_FILE'
- X
- X%*******************************************************************************
- X%* START OF AUTOMATICALLY GENERATED TEX FILE *
- X%*******************************************************************************
- X%* *
- X%* This TeX file was automatically generated by the FunnelWeb preprocessor. *
- X%* You can typeset this file to produce printed documentation by running it *
- X%* through the TeX typesetter using a command such as: *
- X%* tex thisfilename *
- X%* The resultant file thisfilename.dvi can be printed using a command such as: *
- X%* lpr -Pcslw -d thisfilename.dvi *
- X%* *
- X%* FunnelWeb is a preprocessor that allows programmers to weave programs and *
- X%* their documentation together in a single document. The FunnelWeb program *
- X%* analyses such documents producing both program files and typeset *
- X%* documentation such as this TeX file. *
- X%* FunnelWeb was created by Ross Williams. *
- X%* *
- X%* For more information on FunnelWeb look in the following FTP archive: *
- X%* Machine : sirius.itd.adelaide.edu.au [IP=129.127.40.3]. *
- X%* Directory: ~pub/funnelweb/ *
- X%* (or some other appropriately named directory). *
- X%* or email Ross Williams at ross@spam.adelaide.edu.au *
- X%* *
- X%*******************************************************************************
- X
- X
- X%===================== Start of FunnelWeb TeX Definitions ======================
- X
- X
- X% Version
- X% -------
- X% This is FunnelWeb TeX Macro Library Version 1.0.
- X
- X
- X% Copyright
- X% ---------
- X% This set of FunnelWeb TeX definitions was written by Ross Williams and was
- X% originally Copyright (C) 1992 Ross N. Williams. However, I, Ross Williams,
- X% hereby forego any claim to Copyright in this set of FunnelWeb TeX definitions
- X% and hereby authorize that the set of TeX definitions pass into the public
- X% domain. -- Ross N. Williams, 3:41pm 07-May-1992, Adelaide, Australia.
- X
- X
- X% Modification
- X% ------------
- X% Please record all modifications to these TeX definitions here. Unless
- X% otherwise specified, all modified definitions fall in the public domain too.
- X%
- X% Programmers:
- X% RNW Ross N. Williams ross@spam.adelaide.edu.au
- X%
- X% Changes:
- X% 07-May-1992 RNW Prepared this work for public domain release.
- X%
- X
- X
- X% General Comments
- X% ----------------
- X% This set of TeX definitions exists for two reasons:
- X%
- X% 1. To shorten and neaten the FunnelWeb TeX output.
- X% 2. To allow users to fiddle with the output format in their input files
- X% (by inserting redefining "\def"s) without having to resort to
- X% modifying the FunnelWeb code.
- X%
- X% The user is warned that these definitions may be changed from time to time
- X% (but probably not much). The user should not be too sneaky. In particular,
- X% users wishing to redefine some of these macros should do so in an explicitly
- X% defined section at the top of their input file. This will mean that in the
- X% event of problems, that section can simply be deleted or commented out to
- X% allow the document to at least be typeset in the default format. Users should
- X% limit themselves to redefining these macros in such a section and should
- X% refrain from using the macros throughout their documents.
- X
- X
- X% Environment Parameters
- X% ----------------------
- X% \tolerance tells TeX how tolerant it should be about making bad line and
- X% page breaks. Here we set it to it's maximum, as
- X% 1) Computer programs are likely to cause lots of bad breaks.
- X% 2) In most cases the user would probably rather get the TeX file through
- X% TeX without any errors than fiddle with spacings for perfection.
- X\tolerance=10000
- X
- X% I don't like indentation as it makes the page look more busy. Instead,
- X% paragraphs are separated by a little space (see next).
- X\parindent=0pt
- X
- X% In many cases, users will produce documents with long runs of paragraphs.
- X% In order to space out these paragraphs, it is convenient to maintain a
- X% prevailing non-zero \parskip (end-of-paragaph skip). The only trouble is
- X% that the skip becomes a problem in macro definitions which require no skip
- X% and so we have to turn the skip on and off. The following two macros
- X% simplify this process.
- X\def\fwparskipon{\parskip=\medskipamount}
- X\def\fwparskipoff{\parskip=0pt}
- X\fwparskipon
- X
- X% Setting raggedbottom allows TeX to leave a bit of space at the bottom of the
- X% page in order to better vertically align the rest of the page (e.g. skips
- X% won't stretch as much). It also means that headings are less likely to be
- X% isolated at the bottom of the page without any following text.
- X\raggedbottom
- X
- X
- X% Fonts
- X% -----
- X% Most of the typeset output is set in 10pt roman and 10pt tt font.
- X% The major extra font needs spring from titles and headings.
- X% For portability's sake we use only the following fonts:
- X% cmr10
- X% cmbx10
- X% cmtt10
- X% and some enlargements of them. These fonts are all "standard" fonts
- X% in Plain TeX. See The TeXbook p.350.
- X\font\fwfontnote=cmr7
- X
- X\font\fwfontnorm=cmr10
- X\font\fwfontnorma=cmr10 scaled \magstep1
- X\font\fwfontnormb=cmr10 scaled \magstep2
- X
- X\font\fwfontbold=cmbx10
- X\font\fwfontbolda=cmbx10 scaled \magstep1
- X\font\fwfontboldb=cmbx10 scaled \magstep2
- X\font\fwfontboldc=cmbx10 scaled \magstep3
- X\font\fwfontboldd=cmbx10 scaled \magstep4
- X
- X
- X% Macros for Stylistic Details
- X% ----------------------------
- X% This section contains all the fiddly little macros for setting the details
- X% of each macro definition.
- X
- X% Macro definitions are sandwiched by calls to these macros which can be used
- X% to sort out the spacing before and after the macro definition.
- X\def\fwbeginmacro{\fwparskipoff\bigskip}
- X\def\fwendmacro{\fwparskipon\par}
- X
- X% These macros deal with the macro name and definition line.
- X\def\fwmacroname#1#2{{\sl #1\/}$\lbrack$#2$\rbrack$}
- X\def\fwfilename#1#2{{\bf #1}$\lbrack$#2$\rbrack$}
- X\def\fwzero#1{{\bf Z}}
- X\def\fwmany#1{{\bf M}}
- X\def\fwequals{ $\equiv$}
- X\def\fwplusequals{ $+\equiv$}
- X
- X% Now for the actual body of the definition. It looks nice to have the tt
- X% code indented a little. Again, we use macros instead of writing direct TeX,
- X% so as to allow the user to fiddle this stuff to taste without having to
- X% modify the FunnelWeb C code.
- X\def\fwodef{\parindent=15pt\vskip0pt$\lbrace$\parindent=20pt}
- X\def\fwcdef{$\rbrace$\vskip0pt\parindent=0pt}
- X\def\fwoquote{`}
- X\def\fwcquote{'}
- X\def\fwoparen{$($}
- X\def\fwcomma{$,$}
- X\def\fwcparen{$)$}
- X\def\fwparam#1{$\diamond #1$}
- X\def\fwparams#1{$(\diamond #1)$}
- X
- X% These macros deal with the notes that are appended at the end of each
- X% macro definition. Note that even though \fwisafile,\fwusedin, and \fwseealso
- X% have the same definition, they are given different names so as to allow the
- X% user to redefine these macros to typeset each kind of information differently
- X% if desired.
- X\def\fwbeginmacronotes{\begingroup\baselineskip=9pt\smallskip}
- X\def\fwnote#1{{\fwfontnote #1}\par}
- X\def\fwisafile#1{\fwnote{#1}}
- X\def\fwusedin#1{\fwnote{#1}}
- X\def\fwseealso#1{\fwnote{#1}}
- X\def\fwendmacronotes{\endgroup}
- X
- X
- X% Macros to Typeset Program Code Verbatim
- X% ---------------------------------------
- X% This is by far the hairiest and most difficult part of the typesetting task
- X% because we have to turn off most of TeX's natural instincts in order to
- X% typeset the program text exactly as it appears in the input file.
- X% Two macros are defined to pull this off: \fwbtx and \fwverbatimgobble.
- X% Their code was inspired by the following sections of "The TeXbook":
- X% Appendix D: Dirty Tricks, 3.Verbatim listing, p.380-382.
- X% Appendix E: Example Formats, p.421.
- X% The \fwbtx[ (for "FunnelWeb Begin TeXt") macro does most of the hard work.
- X% The liberal use of "%" is because I don't understand TeX well enough to
- X% understand when an end of line will cause trouble, and I am playing it safe.
- X
- X% Before defining the main \fwbtx macro, we have to stash away some definitions
- X% in the hidden part of TeX's environment. Let's hope that these "hidden"
- X% definitions don't affect anything except what is desired to be affected.
- X
- X% The tt font in which we wish to set the text has two Latin lurking ligatures!
- X% These are ?` and !`. To disable them, we define the left quote when ACTIVE
- X% to be defined in such a way as to prevent ligatures. The main TeX text will
- X% normally not be exposed to this definition because normally the leftquote
- X% character is not active. The \fwbtx macro temporarily makes the left quote
- X% character active thus activating the deactivation of left quote ligatures.
- X% See The TeXbook p.381.
- X{\catcode`\`=\active \gdef`{\relax\lq}}
- X
- X% TeX is fairly carefree about spaces and so we have to make it more serious.
- X% To do so we pull the same trick as above, setting up a definition for active
- X% space, but only making space active during the span of the verbatim text.
- X% In Plain TeX the active space is defined to be simply a space, but here we
- X% define it to be a control space. This ensures that the space cannot
- X% be gobbled up by one of TeX's mysterious mechanisms when activated.
- X% See The TeXbook, p.381 and p.352.
- X{\obeyspaces\global\let =\ }
- X
- X% Here is the main \fwbtx verbatim text macro.
- X% Note: The order in which all these pieces of business have to be done is
- X% still a partial mystery to me. Don't fiddle with this stuff unless you
- X% think you know what you are doing.
- X\def\fwbtx[{%
- X%
- X% The funnies involved in getting verbatim output are safely housed inside
- X% this \begingroup, and the \endgroup in \fwverbatimgobble. Groups are used
- X% instead of curly braces because we have to be able to signal the end of
- X% this macro with a curly brace.
- X\begingroup%
- X%
- X% \pars at the end of empty lines in the verbatim text won't come out normally
- X% because TeX is in vertical mode and they get gobbled up. To prevent this,
- X% we force \par to exit vertical mode first. See The TeXbook p.381.
- X\def\par{\leavevmode\endgraf}%
- X%
- X% Activate the leftquote character so as to avoid ligatures (see above).
- X\catcode`\`=\active%
- X%
- X% The \obeylines macro simply defines end of line (^M) to be \par. This ensures
- X% that TeX will treat each verbatim line as a new paragraph.
- X\obeylines%
- X%
- X% To get verbatim output, we have to desex all the special characters. This
- X% is explained in detail in The TeXbook p.380.
- X\def\do##1{\catcode`##1=12 }\dospecials%
- X%
- X% Activate the space character so as to make TeX treat blanks seriously.
- X% This activation invokes an eralier definition (see above).
- X\obeyspaces
- X%
- X% Interparagraph skips do not help the cause.
- X% Note: We have to preserve the indentation though, as the code is actually
- X% indented in the final output. See \fwodef in an earlier section.
- X\parskip=0pt%
- X%
- X% We typeset the verbatim text in tt font (courier on the Macintosh) for a
- X% number of reasons:
- X% - tt font has the same horizontal spacing for each character.
- X% - tt font covers the ASCII character set.
- X% - tt font doesn't have many surprises (e.g. ligatures).
- X% - tt font looks much what you might see on a computer terminal screen.
- X\tt%
- X%
- X% Having set up an environment for verbatim, we are ready to use it.
- X% By invoking \fwverbatimgobble, this \fwbtx macro gobbles up text verbatim (as
- X% part of the parameter of \fwverbatimgobble) until it sees the termination
- X% string "]fwetx=" (the "=" was thrown in to add obscurity as this sequence
- X% must never occur in the verbatim text).
- X\fwverbatimgobble}
- X
- X% The \fwverbatimgobble macro exists to allow \fwbtx to bracket verbatim text.
- X\def\fwverbatimgobble#1]fwetx={#1\endgroup}
- X
- X
- X% Table of Contents
- X% -----------------
- X% The five levels of table of contents that FunnelWeb supports are identified
- X% by the five letters [A..E]. These are used throughout the following macros.
- X
- X% The following macros are utilities to the TOC macros to follow.
- X\def\fwrule{\medskip\hrule\medskip}
- X\def\fwqh{\hskip1.5em\relax}
- X\def\fwbeforesec{\penalty-200\bigskip\medskip\par}
- X
- X% The following macros are used to typeset the table of contents.
- X\def\fwtocstart#1{\fwrule\leftline{\fwfontbolda Table of Contents}\fwrule}
- X\def\fwtoca#1#2{\leftline{{\bf #1 #2}}}
- X\def\fwtocb#1#2{\leftline{\fwqh #1 #2}}
- X\def\fwtocc#1#2{\leftline{\fwqh\fwqh #1 #2}}
- X\def\fwtocd#1#2{\leftline{\fwqh\fwqh\fwqh #1 #2}}
- X\def\fwtoce#1#2{\leftline{\fwqh\fwqh\fwqh\fwqh #1 #2}}
- X\def\fwtocfinish#1{\fwrule}
- X
- X% The following "library" macros define five different strengths of headings
- X% which can be used later in the section macros.
- X\def\fwliba#1#2{\vfill\eject{\fwfontboldc #1 #2}\penalty200\smallskip}
- X\def\fwlibb#1#2{\fwbeforesec{\fwfontboldb #1 #2}\penalty200\smallskip}
- X\def\fwlibc#1#2{\fwbeforesec{\fwfontnormb #1 #2}\penalty200\smallskip}
- X\def\fwlibd#1#2{\fwbeforesec{\bf #1 #2}\penalty200}
- X\def\fwlibe#1#2{\fwbeforesec{\bf #1 #2}}
- X
- X% Here are the macros that actually typeset the section headings throughout
- X% the document. The fwlib system has been employed so as to easily allow the
- X% user to redefine the strengths of headings to taste. For example, the
- X% user could insert in the input document a similar set of definitions to these
- X% but with the b..e headings set to \fwlibc. This would tone down the output.
- X\def\fwseca#1#2{\fwliba{#1}{#2}}
- X\def\fwsecb#1#2{\fwlibb{#1}{#2}}
- X\def\fwsecc#1#2{\fwlibc{#1}{#2}}
- X\def\fwsecd#1#2{\fwlibd{#1}{#2}}
- X\def\fwsece#1#2{\fwlibe{#1}{#2}}
- X
- X
- X% Support for Explicit Typesetting
- X% --------------------------------
- X% FunnelWeb supports pragmas and other constructs that allow
- X% typesetter-independent typesetting commands to be given. The
- X% following macros support these features.
- X
- X% The in-text literal @{sloth@} and emphasise @[walrus@] features.
- X\def\fwlit#1{{\tt #1}}
- X\def\fwemp#1{{\it #1}}
- X
- X% The "@p new_page" pragma.
- X\def\fwnewpage{\vfill\eject}
- X
- X% The "@p vskip Nmm" pragma.
- X\def\fwvskip#1{\null\vskip #1mm}
- X
- X% The "@p title <font> <align> <text>" pragma.
- X\def\fwfontnormal#1{{\fwfontnorm {#1}}}
- X\def\fwfonttitle#1{{\fwfontboldd {#1}}}
- X\def\fwfontsmalltitle#1{{\fwfontboldb {#1}}}
- X\def\fwleftline#1{\leftline{#1}}
- X\def\fwcenterline#1{\centerline{#1}}
- X\def\fwrightline#1{\rightline{#1}}
- X
- X
- X% Support for Old FunnelWeb
- X% -------------------------
- X% The following macros were used extensively in the first version of
- X% FunnelWeb and are retained so that these older input files will still
- X% typeset cleanly.
- X\def\p#1{{\tt #1}} % P for Program text.
- X\def\flagpage#1#2{
- X \null
- X \vfill
- X \centerline{\fwfontboldd #1}
- X \vskip 1cm
- X \centerline{\fwfontboldd #2}
- X \vfill
- X \null
- X \vfill
- X}
- X
- X%====================== End of FunnelWeb TeX Definitions =======================
- XEX12: This example gives some simple headings and demonstrates heading name
- X inheritance.
- X
- X\fwbeginmacro
- X\fwfilename{ex12.out}{1}\fwequals \fwodef \fwbtx[dummy text]fwetx=%
- X\fwcdef
- X\fwbeginmacronotes
- X\fwisafile{This macro is attached to an output file.}
- X\fwendmacronotes
- X\fwendmacro
- X
- X
- X\fwseca{1}{Feed the Penguins and Save the World}
- X\fwsecb{1.1}{Feed the Penguins}
- X\fwsecc{1.1.1}{Feed the little penguins}
- X\fwsecc{1.1.2}{Feed the big penguins}
- X\fwsecb{1.2}{Save the World}
- X\fwsecc{1.2.1}{Save Europe}
- X\fwsecc{1.2.2}{Save Africa}
- X
- X\fwsecc{1.2.3}{Save the rest of the world} This heading hasn't been given an explicit name, but will inherit the
- name $\backslash$p$\{$Save the rest of the world$\}$ from the macro definition below.
- X
- X\fwbeginmacro
- X\fwmacroname{Save the rest of the world}{2}\fwzero{}\fwequals \fwodef \fwbtx[...]fwetx=%
- X\fwcdef
- X\fwbeginmacronotes
- X\fwusedin{This macro is NEVER invoked.}
- X\fwendmacronotes
- X\fwendmacro
- X
- X\bye
- X
- X
- X%*******************************************************************************
- X%* END OF AUTOMATICALLY GENERATED TEX FILE *
- X%*******************************************************************************
- X
- END_OF_FILE
- if test 16184 -ne `wc -c <'answers/ex12.tex'`; then
- echo shar: \"'answers/ex12.tex'\" unpacked with wrong size!
- fi
- # end of 'answers/ex12.tex'
- fi
- if test -f 'answers/ex14.tex' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'answers/ex14.tex'\"
- else
- echo shar: Extracting \"'answers/ex14.tex'\" \(15714 characters\)
- sed "s/^X//" >'answers/ex14.tex' <<'END_OF_FILE'
- X
- X%*******************************************************************************
- X%* START OF AUTOMATICALLY GENERATED TEX FILE *
- X%*******************************************************************************
- X%* *
- X%* This TeX file was automatically generated by the FunnelWeb preprocessor. *
- X%* You can typeset this file to produce printed documentation by running it *
- X%* through the TeX typesetter using a command such as: *
- X%* tex thisfilename *
- X%* The resultant file thisfilename.dvi can be printed using a command such as: *
- X%* lpr -Pcslw -d thisfilename.dvi *
- X%* *
- X%* FunnelWeb is a preprocessor that allows programmers to weave programs and *
- X%* their documentation together in a single document. The FunnelWeb program *
- X%* analyses such documents producing both program files and typeset *
- X%* documentation such as this TeX file. *
- X%* FunnelWeb was created by Ross Williams. *
- X%* *
- X%* For more information on FunnelWeb look in the following FTP archive: *
- X%* Machine : sirius.itd.adelaide.edu.au [IP=129.127.40.3]. *
- X%* Directory: ~pub/funnelweb/ *
- X%* (or some other appropriately named directory). *
- X%* or email Ross Williams at ross@spam.adelaide.edu.au *
- X%* *
- X%*******************************************************************************
- X
- X
- X%===================== Start of FunnelWeb TeX Definitions ======================
- X
- X
- X% Version
- X% -------
- X% This is FunnelWeb TeX Macro Library Version 1.0.
- X
- X
- X% Copyright
- X% ---------
- X% This set of FunnelWeb TeX definitions was written by Ross Williams and was
- X% originally Copyright (C) 1992 Ross N. Williams. However, I, Ross Williams,
- X% hereby forego any claim to Copyright in this set of FunnelWeb TeX definitions
- X% and hereby authorize that the set of TeX definitions pass into the public
- X% domain. -- Ross N. Williams, 3:41pm 07-May-1992, Adelaide, Australia.
- X
- X
- X% Modification
- X% ------------
- X% Please record all modifications to these TeX definitions here. Unless
- X% otherwise specified, all modified definitions fall in the public domain too.
- X%
- X% Programmers:
- X% RNW Ross N. Williams ross@spam.adelaide.edu.au
- X%
- X% Changes:
- X% 07-May-1992 RNW Prepared this work for public domain release.
- X%
- X
- X
- X% General Comments
- X% ----------------
- X% This set of TeX definitions exists for two reasons:
- X%
- X% 1. To shorten and neaten the FunnelWeb TeX output.
- X% 2. To allow users to fiddle with the output format in their input files
- X% (by inserting redefining "\def"s) without having to resort to
- X% modifying the FunnelWeb code.
- X%
- X% The user is warned that these definitions may be changed from time to time
- X% (but probably not much). The user should not be too sneaky. In particular,
- X% users wishing to redefine some of these macros should do so in an explicitly
- X% defined section at the top of their input file. This will mean that in the
- X% event of problems, that section can simply be deleted or commented out to
- X% allow the document to at least be typeset in the default format. Users should
- X% limit themselves to redefining these macros in such a section and should
- X% refrain from using the macros throughout their documents.
- X
- X
- X% Environment Parameters
- X% ----------------------
- X% \tolerance tells TeX how tolerant it should be about making bad line and
- X% page breaks. Here we set it to it's maximum, as
- X% 1) Computer programs are likely to cause lots of bad breaks.
- X% 2) In most cases the user would probably rather get the TeX file through
- X% TeX without any errors than fiddle with spacings for perfection.
- X\tolerance=10000
- X
- X% I don't like indentation as it makes the page look more busy. Instead,
- X% paragraphs are separated by a little space (see next).
- X\parindent=0pt
- X
- X% In many cases, users will produce documents with long runs of paragraphs.
- X% In order to space out these paragraphs, it is convenient to maintain a
- X% prevailing non-zero \parskip (end-of-paragaph skip). The only trouble is
- X% that the skip becomes a problem in macro definitions which require no skip
- X% and so we have to turn the skip on and off. The following two macros
- X% simplify this process.
- X\def\fwparskipon{\parskip=\medskipamount}
- X\def\fwparskipoff{\parskip=0pt}
- X\fwparskipon
- X
- X% Setting raggedbottom allows TeX to leave a bit of space at the bottom of the
- X% page in order to better vertically align the rest of the page (e.g. skips
- X% won't stretch as much). It also means that headings are less likely to be
- X% isolated at the bottom of the page without any following text.
- X\raggedbottom
- X
- X
- X% Fonts
- X% -----
- X% Most of the typeset output is set in 10pt roman and 10pt tt font.
- X% The major extra font needs spring from titles and headings.
- X% For portability's sake we use only the following fonts:
- X% cmr10
- X% cmbx10
- X% cmtt10
- X% and some enlargements of them. These fonts are all "standard" fonts
- X% in Plain TeX. See The TeXbook p.350.
- X\font\fwfontnote=cmr7
- X
- X\font\fwfontnorm=cmr10
- X\font\fwfontnorma=cmr10 scaled \magstep1
- X\font\fwfontnormb=cmr10 scaled \magstep2
- X
- X\font\fwfontbold=cmbx10
- X\font\fwfontbolda=cmbx10 scaled \magstep1
- X\font\fwfontboldb=cmbx10 scaled \magstep2
- X\font\fwfontboldc=cmbx10 scaled \magstep3
- X\font\fwfontboldd=cmbx10 scaled \magstep4
- X
- X
- X% Macros for Stylistic Details
- X% ----------------------------
- X% This section contains all the fiddly little macros for setting the details
- X% of each macro definition.
- X
- X% Macro definitions are sandwiched by calls to these macros which can be used
- X% to sort out the spacing before and after the macro definition.
- X\def\fwbeginmacro{\fwparskipoff\bigskip}
- X\def\fwendmacro{\fwparskipon\par}
- X
- X% These macros deal with the macro name and definition line.
- X\def\fwmacroname#1#2{{\sl #1\/}$\lbrack$#2$\rbrack$}
- X\def\fwfilename#1#2{{\bf #1}$\lbrack$#2$\rbrack$}
- X\def\fwzero#1{{\bf Z}}
- X\def\fwmany#1{{\bf M}}
- X\def\fwequals{ $\equiv$}
- X\def\fwplusequals{ $+\equiv$}
- X
- X% Now for the actual body of the definition. It looks nice to have the tt
- X% code indented a little. Again, we use macros instead of writing direct TeX,
- X% so as to allow the user to fiddle this stuff to taste without having to
- X% modify the FunnelWeb C code.
- X\def\fwodef{\parindent=15pt\vskip0pt$\lbrace$\parindent=20pt}
- X\def\fwcdef{$\rbrace$\vskip0pt\parindent=0pt}
- X\def\fwoquote{`}
- X\def\fwcquote{'}
- X\def\fwoparen{$($}
- X\def\fwcomma{$,$}
- X\def\fwcparen{$)$}
- X\def\fwparam#1{$\diamond #1$}
- X\def\fwparams#1{$(\diamond #1)$}
- X
- X% These macros deal with the notes that are appended at the end of each
- X% macro definition. Note that even though \fwisafile,\fwusedin, and \fwseealso
- X% have the same definition, they are given different names so as to allow the
- X% user to redefine these macros to typeset each kind of information differently
- X% if desired.
- X\def\fwbeginmacronotes{\begingroup\baselineskip=9pt\smallskip}
- X\def\fwnote#1{{\fwfontnote #1}\par}
- X\def\fwisafile#1{\fwnote{#1}}
- X\def\fwusedin#1{\fwnote{#1}}
- X\def\fwseealso#1{\fwnote{#1}}
- X\def\fwendmacronotes{\endgroup}
- X
- X
- X% Macros to Typeset Program Code Verbatim
- X% ---------------------------------------
- X% This is by far the hairiest and most difficult part of the typesetting task
- X% because we have to turn off most of TeX's natural instincts in order to
- X% typeset the program text exactly as it appears in the input file.
- X% Two macros are defined to pull this off: \fwbtx and \fwverbatimgobble.
- X% Their code was inspired by the following sections of "The TeXbook":
- X% Appendix D: Dirty Tricks, 3.Verbatim listing, p.380-382.
- X% Appendix E: Example Formats, p.421.
- X% The \fwbtx[ (for "FunnelWeb Begin TeXt") macro does most of the hard work.
- X% The liberal use of "%" is because I don't understand TeX well enough to
- X% understand when an end of line will cause trouble, and I am playing it safe.
- X
- X% Before defining the main \fwbtx macro, we have to stash away some definitions
- X% in the hidden part of TeX's environment. Let's hope that these "hidden"
- X% definitions don't affect anything except what is desired to be affected.
- X
- X% The tt font in which we wish to set the text has two Latin lurking ligatures!
- X% These are ?` and !`. To disable them, we define the left quote when ACTIVE
- X% to be defined in such a way as to prevent ligatures. The main TeX text will
- X% normally not be exposed to this definition because normally the leftquote
- X% character is not active. The \fwbtx macro temporarily makes the left quote
- X% character active thus activating the deactivation of left quote ligatures.
- X% See The TeXbook p.381.
- X{\catcode`\`=\active \gdef`{\relax\lq}}
- X
- X% TeX is fairly carefree about spaces and so we have to make it more serious.
- X% To do so we pull the same trick as above, setting up a definition for active
- X% space, but only making space active during the span of the verbatim text.
- X% In Plain TeX the active space is defined to be simply a space, but here we
- X% define it to be a control space. This ensures that the space cannot
- X% be gobbled up by one of TeX's mysterious mechanisms when activated.
- X% See The TeXbook, p.381 and p.352.
- X{\obeyspaces\global\let =\ }
- X
- X% Here is the main \fwbtx verbatim text macro.
- X% Note: The order in which all these pieces of business have to be done is
- X% still a partial mystery to me. Don't fiddle with this stuff unless you
- X% think you know what you are doing.
- X\def\fwbtx[{%
- X%
- X% The funnies involved in getting verbatim output are safely housed inside
- X% this \begingroup, and the \endgroup in \fwverbatimgobble. Groups are used
- X% instead of curly braces because we have to be able to signal the end of
- X% this macro with a curly brace.
- X\begingroup%
- X%
- X% \pars at the end of empty lines in the verbatim text won't come out normally
- X% because TeX is in vertical mode and they get gobbled up. To prevent this,
- X% we force \par to exit vertical mode first. See The TeXbook p.381.
- X\def\par{\leavevmode\endgraf}%
- X%
- X% Activate the leftquote character so as to avoid ligatures (see above).
- X\catcode`\`=\active%
- X%
- X% The \obeylines macro simply defines end of line (^M) to be \par. This ensures
- X% that TeX will treat each verbatim line as a new paragraph.
- X\obeylines%
- X%
- X% To get verbatim output, we have to desex all the special characters. This
- X% is explained in detail in The TeXbook p.380.
- X\def\do##1{\catcode`##1=12 }\dospecials%
- X%
- X% Activate the space character so as to make TeX treat blanks seriously.
- X% This activation invokes an eralier definition (see above).
- X\obeyspaces
- X%
- X% Interparagraph skips do not help the cause.
- X% Note: We have to preserve the indentation though, as the code is actually
- X% indented in the final output. See \fwodef in an earlier section.
- X\parskip=0pt%
- X%
- X% We typeset the verbatim text in tt font (courier on the Macintosh) for a
- X% number of reasons:
- X% - tt font has the same horizontal spacing for each character.
- X% - tt font covers the ASCII character set.
- X% - tt font doesn't have many surprises (e.g. ligatures).
- X% - tt font looks much what you might see on a computer terminal screen.
- X\tt%
- X%
- X% Having set up an environment for verbatim, we are ready to use it.
- X% By invoking \fwverbatimgobble, this \fwbtx macro gobbles up text verbatim (as
- X% part of the parameter of \fwverbatimgobble) until it sees the termination
- X% string "]fwetx=" (the "=" was thrown in to add obscurity as this sequence
- X% must never occur in the verbatim text).
- X\fwverbatimgobble}
- X
- X% The \fwverbatimgobble macro exists to allow \fwbtx to bracket verbatim text.
- X\def\fwverbatimgobble#1]fwetx={#1\endgroup}
- X
- X
- X% Table of Contents
- X% -----------------
- X% The five levels of table of contents that FunnelWeb supports are identified
- X% by the five letters [A..E]. These are used throughout the following macros.
- X
- X% The following macros are utilities to the TOC macros to follow.
- X\def\fwrule{\medskip\hrule\medskip}
- X\def\fwqh{\hskip1.5em\relax}
- X\def\fwbeforesec{\penalty-200\bigskip\medskip\par}
- X
- X% The following macros are used to typeset the table of contents.
- X\def\fwtocstart#1{\fwrule\leftline{\fwfontbolda Table of Contents}\fwrule}
- X\def\fwtoca#1#2{\leftline{{\bf #1 #2}}}
- X\def\fwtocb#1#2{\leftline{\fwqh #1 #2}}
- X\def\fwtocc#1#2{\leftline{\fwqh\fwqh #1 #2}}
- X\def\fwtocd#1#2{\leftline{\fwqh\fwqh\fwqh #1 #2}}
- X\def\fwtoce#1#2{\leftline{\fwqh\fwqh\fwqh\fwqh #1 #2}}
- X\def\fwtocfinish#1{\fwrule}
- X
- X% The following "library" macros define five different strengths of headings
- X% which can be used later in the section macros.
- X\def\fwliba#1#2{\vfill\eject{\fwfontboldc #1 #2}\penalty200\smallskip}
- X\def\fwlibb#1#2{\fwbeforesec{\fwfontboldb #1 #2}\penalty200\smallskip}
- X\def\fwlibc#1#2{\fwbeforesec{\fwfontnormb #1 #2}\penalty200\smallskip}
- X\def\fwlibd#1#2{\fwbeforesec{\bf #1 #2}\penalty200}
- X\def\fwlibe#1#2{\fwbeforesec{\bf #1 #2}}
- X
- X% Here are the macros that actually typeset the section headings throughout
- X% the document. The fwlib system has been employed so as to easily allow the
- X% user to redefine the strengths of headings to taste. For example, the
- X% user could insert in the input document a similar set of definitions to these
- X% but with the b..e headings set to \fwlibc. This would tone down the output.
- X\def\fwseca#1#2{\fwliba{#1}{#2}}
- X\def\fwsecb#1#2{\fwlibb{#1}{#2}}
- X\def\fwsecc#1#2{\fwlibc{#1}{#2}}
- X\def\fwsecd#1#2{\fwlibd{#1}{#2}}
- X\def\fwsece#1#2{\fwlibe{#1}{#2}}
- X
- X
- X% Support for Explicit Typesetting
- X% --------------------------------
- X% FunnelWeb supports pragmas and other constructs that allow
- X% typesetter-independent typesetting commands to be given. The
- X% following macros support these features.
- X
- X% The in-text literal @{sloth@} and emphasise @[walrus@] features.
- X\def\fwlit#1{{\tt #1}}
- X\def\fwemp#1{{\it #1}}
- X
- X% The "@p new_page" pragma.
- X\def\fwnewpage{\vfill\eject}
- X
- X% The "@p vskip Nmm" pragma.
- X\def\fwvskip#1{\null\vskip #1mm}
- X
- X% The "@p title <font> <align> <text>" pragma.
- X\def\fwfontnormal#1{{\fwfontnorm {#1}}}
- X\def\fwfonttitle#1{{\fwfontboldd {#1}}}
- X\def\fwfontsmalltitle#1{{\fwfontboldb {#1}}}
- X\def\fwleftline#1{\leftline{#1}}
- X\def\fwcenterline#1{\centerline{#1}}
- X\def\fwrightline#1{\rightline{#1}}
- X
- X
- X% Support for Old FunnelWeb
- X% -------------------------
- X% The following macros were used extensively in the first version of
- X% FunnelWeb and are retained so that these older input files will still
- X% typeset cleanly.
- X\def\p#1{{\tt #1}} % P for Program text.
- X\def\flagpage#1#2{
- X \null
- X \vfill
- X \centerline{\fwfontboldd #1}
- X \vskip 1cm
- X \centerline{\fwfontboldd #2}
- X \vfill
- X \null
- X \vfill
- X}
- X
- X%====================== End of FunnelWeb TeX Definitions =======================
- XEX14: This example demonstrates the literal and emphasis typesetting constructs.
- X
- The following procedure \fwlit{put\_sloth} writes the \fwlit{sloth} variable to
- the output file. Note: \fwemp{The output file must be opened for writing
- at this point or the program will crash!}
- X
- X\fwbeginmacro
- X\fwfilename{ex14.out}{1}\fwequals \fwodef \fwbtx[dummy
- X]fwetx=%
- X\fwcdef
- X\fwbeginmacronotes
- X\fwisafile{This macro is attached to an output file.}
- X\fwendmacronotes
- X\fwendmacro
- X
- X\bye
- X
- X
- X%*******************************************************************************
- X%* END OF AUTOMATICALLY GENERATED TEX FILE *
- X%*******************************************************************************
- X
- END_OF_FILE
- if test 15714 -ne `wc -c <'answers/ex14.tex'`; then
- echo shar: \"'answers/ex14.tex'\" unpacked with wrong size!
- fi
- # end of 'answers/ex14.tex'
- fi
- if test -f 'answers/ex15.tex' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'answers/ex15.tex'\"
- else
- echo shar: Extracting \"'answers/ex15.tex'\" \(16000 characters\)
- sed "s/^X//" >'answers/ex15.tex' <<'END_OF_FILE'
- X
- X%*******************************************************************************
- X%* START OF AUTOMATICALLY GENERATED TEX FILE *
- X%*******************************************************************************
- X%* *
- X%* This TeX file was automatically generated by the FunnelWeb preprocessor. *
- X%* You can typeset this file to produce printed documentation by running it *
- X%* through the TeX typesetter using a command such as: *
- X%* tex thisfilename *
- X%* The resultant file thisfilename.dvi can be printed using a command such as: *
- X%* lpr -Pcslw -d thisfilename.dvi *
- X%* *
- X%* FunnelWeb is a preprocessor that allows programmers to weave programs and *
- X%* their documentation together in a single document. The FunnelWeb program *
- X%* analyses such documents producing both program files and typeset *
- X%* documentation such as this TeX file. *
- X%* FunnelWeb was created by Ross Williams. *
- X%* *
- X%* For more information on FunnelWeb look in the following FTP archive: *
- X%* Machine : sirius.itd.adelaide.edu.au [IP=129.127.40.3]. *
- X%* Directory: ~pub/funnelweb/ *
- X%* (or some other appropriately named directory). *
- X%* or email Ross Williams at ross@spam.adelaide.edu.au *
- X%* *
- X%*******************************************************************************
- X
- X
- X%===================== Start of FunnelWeb TeX Definitions ======================
- X
- X
- X% Version
- X% -------
- X% This is FunnelWeb TeX Macro Library Version 1.0.
- X
- X
- X% Copyright
- X% ---------
- X% This set of FunnelWeb TeX definitions was written by Ross Williams and was
- X% originally Copyright (C) 1992 Ross N. Williams. However, I, Ross Williams,
- X% hereby forego any claim to Copyright in this set of FunnelWeb TeX definitions
- X% and hereby authorize that the set of TeX definitions pass into the public
- X% domain. -- Ross N. Williams, 3:41pm 07-May-1992, Adelaide, Australia.
- X
- X
- X% Modification
- X% ------------
- X% Please record all modifications to these TeX definitions here. Unless
- X% otherwise specified, all modified definitions fall in the public domain too.
- X%
- X% Programmers:
- X% RNW Ross N. Williams ross@spam.adelaide.edu.au
- X%
- X% Changes:
- X% 07-May-1992 RNW Prepared this work for public domain release.
- X%
- X
- X
- X% General Comments
- X% ----------------
- X% This set of TeX definitions exists for two reasons:
- X%
- X% 1. To shorten and neaten the FunnelWeb TeX output.
- X% 2. To allow users to fiddle with the output format in their input files
- X% (by inserting redefining "\def"s) without having to resort to
- X% modifying the FunnelWeb code.
- X%
- X% The user is warned that these definitions may be changed from time to time
- X% (but probably not much). The user should not be too sneaky. In particular,
- X% users wishing to redefine some of these macros should do so in an explicitly
- X% defined section at the top of their input file. This will mean that in the
- X% event of problems, that section can simply be deleted or commented out to
- X% allow the document to at least be typeset in the default format. Users should
- X% limit themselves to redefining these macros in such a section and should
- X% refrain from using the macros throughout their documents.
- X
- X
- X% Environment Parameters
- X% ----------------------
- X% \tolerance tells TeX how tolerant it should be about making bad line and
- X% page breaks. Here we set it to it's maximum, as
- X% 1) Computer programs are likely to cause lots of bad breaks.
- X% 2) In most cases the user would probably rather get the TeX file through
- X% TeX without any errors than fiddle with spacings for perfection.
- X\tolerance=10000
- X
- X% I don't like indentation as it makes the page look more busy. Instead,
- X% paragraphs are separated by a little space (see next).
- X\parindent=0pt
- X
- X% In many cases, users will produce documents with long runs of paragraphs.
- X% In order to space out these paragraphs, it is convenient to maintain a
- X% prevailing non-zero \parskip (end-of-paragaph skip). The only trouble is
- X% that the skip becomes a problem in macro definitions which require no skip
- X% and so we have to turn the skip on and off. The following two macros
- X% simplify this process.
- X\def\fwparskipon{\parskip=\medskipamount}
- X\def\fwparskipoff{\parskip=0pt}
- X\fwparskipon
- X
- X% Setting raggedbottom allows TeX to leave a bit of space at the bottom of the
- X% page in order to better vertically align the rest of the page (e.g. skips
- X% won't stretch as much). It also means that headings are less likely to be
- X% isolated at the bottom of the page without any following text.
- X\raggedbottom
- X
- X
- X% Fonts
- X% -----
- X% Most of the typeset output is set in 10pt roman and 10pt tt font.
- X% The major extra font needs spring from titles and headings.
- X% For portability's sake we use only the following fonts:
- X% cmr10
- X% cmbx10
- X% cmtt10
- X% and some enlargements of them. These fonts are all "standard" fonts
- X% in Plain TeX. See The TeXbook p.350.
- X\font\fwfontnote=cmr7
- X
- X\font\fwfontnorm=cmr10
- X\font\fwfontnorma=cmr10 scaled \magstep1
- X\font\fwfontnormb=cmr10 scaled \magstep2
- X
- X\font\fwfontbold=cmbx10
- X\font\fwfontbolda=cmbx10 scaled \magstep1
- X\font\fwfontboldb=cmbx10 scaled \magstep2
- X\font\fwfontboldc=cmbx10 scaled \magstep3
- X\font\fwfontboldd=cmbx10 scaled \magstep4
- X
- X
- X% Macros for Stylistic Details
- X% ----------------------------
- X% This section contains all the fiddly little macros for setting the details
- X% of each macro definition.
- X
- X% Macro definitions are sandwiched by calls to these macros which can be used
- X% to sort out the spacing before and after the macro definition.
- X\def\fwbeginmacro{\fwparskipoff\bigskip}
- X\def\fwendmacro{\fwparskipon\par}
- X
- X% These macros deal with the macro name and definition line.
- X\def\fwmacroname#1#2{{\sl #1\/}$\lbrack$#2$\rbrack$}
- X\def\fwfilename#1#2{{\bf #1}$\lbrack$#2$\rbrack$}
- X\def\fwzero#1{{\bf Z}}
- X\def\fwmany#1{{\bf M}}
- X\def\fwequals{ $\equiv$}
- X\def\fwplusequals{ $+\equiv$}
- X
- X% Now for the actual body of the definition. It looks nice to have the tt
- X% code indented a little. Again, we use macros instead of writing direct TeX,
- X% so as to allow the user to fiddle this stuff to taste without having to
- X% modify the FunnelWeb C code.
- X\def\fwodef{\parindent=15pt\vskip0pt$\lbrace$\parindent=20pt}
- X\def\fwcdef{$\rbrace$\vskip0pt\parindent=0pt}
- X\def\fwoquote{`}
- X\def\fwcquote{'}
- X\def\fwoparen{$($}
- X\def\fwcomma{$,$}
- X\def\fwcparen{$)$}
- X\def\fwparam#1{$\diamond #1$}
- X\def\fwparams#1{$(\diamond #1)$}
- X
- X% These macros deal with the notes that are appended at the end of each
- X% macro definition. Note that even though \fwisafile,\fwusedin, and \fwseealso
- X% have the same definition, they are given different names so as to allow the
- X% user to redefine these macros to typeset each kind of information differently
- X% if desired.
- X\def\fwbeginmacronotes{\begingroup\baselineskip=9pt\smallskip}
- X\def\fwnote#1{{\fwfontnote #1}\par}
- X\def\fwisafile#1{\fwnote{#1}}
- X\def\fwusedin#1{\fwnote{#1}}
- X\def\fwseealso#1{\fwnote{#1}}
- X\def\fwendmacronotes{\endgroup}
- X
- X
- X% Macros to Typeset Program Code Verbatim
- X% ---------------------------------------
- X% This is by far the hairiest and most difficult part of the typesetting task
- X% because we have to turn off most of TeX's natural instincts in order to
- X% typeset the program text exactly as it appears in the input file.
- X% Two macros are defined to pull this off: \fwbtx and \fwverbatimgobble.
- X% Their code was inspired by the following sections of "The TeXbook":
- X% Appendix D: Dirty Tricks, 3.Verbatim listing, p.380-382.
- X% Appendix E: Example Formats, p.421.
- X% The \fwbtx[ (for "FunnelWeb Begin TeXt") macro does most of the hard work.
- X% The liberal use of "%" is because I don't understand TeX well enough to
- X% understand when an end of line will cause trouble, and I am playing it safe.
- X
- X% Before defining the main \fwbtx macro, we have to stash away some definitions
- X% in the hidden part of TeX's environment. Let's hope that these "hidden"
- X% definitions don't affect anything except what is desired to be affected.
- X
- X% The tt font in which we wish to set the text has two Latin lurking ligatures!
- X% These are ?` and !`. To disable them, we define the left quote when ACTIVE
- X% to be defined in such a way as to prevent ligatures. The main TeX text will
- X% normally not be exposed to this definition because normally the leftquote
- X% character is not active. The \fwbtx macro temporarily makes the left quote
- X% character active thus activating the deactivation of left quote ligatures.
- X% See The TeXbook p.381.
- X{\catcode`\`=\active \gdef`{\relax\lq}}
- X
- X% TeX is fairly carefree about spaces and so we have to make it more serious.
- X% To do so we pull the same trick as above, setting up a definition for active
- X% space, but only making space active during the span of the verbatim text.
- X% In Plain TeX the active space is defined to be simply a space, but here we
- X% define it to be a control space. This ensures that the space cannot
- X% be gobbled up by one of TeX's mysterious mechanisms when activated.
- X% See The TeXbook, p.381 and p.352.
- X{\obeyspaces\global\let =\ }
- X
- X% Here is the main \fwbtx verbatim text macro.
- X% Note: The order in which all these pieces of business have to be done is
- X% still a partial mystery to me. Don't fiddle with this stuff unless you
- X% think you know what you are doing.
- X\def\fwbtx[{%
- X%
- X% The funnies involved in getting verbatim output are safely housed inside
- X% this \begingroup, and the \endgroup in \fwverbatimgobble. Groups are used
- X% instead of curly braces because we have to be able to signal the end of
- X% this macro with a curly brace.
- X\begingroup%
- X%
- X% \pars at the end of empty lines in the verbatim text won't come out normally
- X% because TeX is in vertical mode and they get gobbled up. To prevent this,
- X% we force \par to exit vertical mode first. See The TeXbook p.381.
- X\def\par{\leavevmode\endgraf}%
- X%
- X% Activate the leftquote character so as to avoid ligatures (see above).
- X\catcode`\`=\active%
- X%
- X% The \obeylines macro simply defines end of line (^M) to be \par. This ensures
- X% that TeX will treat each verbatim line as a new paragraph.
- X\obeylines%
- X%
- X% To get verbatim output, we have to desex all the special characters. This
- X% is explained in detail in The TeXbook p.380.
- X\def\do##1{\catcode`##1=12 }\dospecials%
- X%
- X% Activate the space character so as to make TeX treat blanks seriously.
- X% This activation invokes an eralier definition (see above).
- X\obeyspaces
- X%
- X% Interparagraph skips do not help the cause.
- X% Note: We have to preserve the indentation though, as the code is actually
- X% indented in the final output. See \fwodef in an earlier section.
- X\parskip=0pt%
- X%
- X% We typeset the verbatim text in tt font (courier on the Macintosh) for a
- X% number of reasons:
- X% - tt font has the same horizontal spacing for each character.
- X% - tt font covers the ASCII character set.
- X% - tt font doesn't have many surprises (e.g. ligatures).
- X% - tt font looks much what you might see on a computer terminal screen.
- X\tt%
- X%
- X% Having set up an environment for verbatim, we are ready to use it.
- X% By invoking \fwverbatimgobble, this \fwbtx macro gobbles up text verbatim (as
- X% part of the parameter of \fwverbatimgobble) until it sees the termination
- X% string "]fwetx=" (the "=" was thrown in to add obscurity as this sequence
- X% must never occur in the verbatim text).
- X\fwverbatimgobble}
- X
- X% The \fwverbatimgobble macro exists to allow \fwbtx to bracket verbatim text.
- X\def\fwverbatimgobble#1]fwetx={#1\endgroup}
- X
- X
- X% Table of Contents
- X% -----------------
- X% The five levels of table of contents that FunnelWeb supports are identified
- X% by the five letters [A..E]. These are used throughout the following macros.
- X
- X% The following macros are utilities to the TOC macros to follow.
- X\def\fwrule{\medskip\hrule\medskip}
- X\def\fwqh{\hskip1.5em\relax}
- X\def\fwbeforesec{\penalty-200\bigskip\medskip\par}
- X
- X% The following macros are used to typeset the table of contents.
- X\def\fwtocstart#1{\fwrule\leftline{\fwfontbolda Table of Contents}\fwrule}
- X\def\fwtoca#1#2{\leftline{{\bf #1 #2}}}
- X\def\fwtocb#1#2{\leftline{\fwqh #1 #2}}
- X\def\fwtocc#1#2{\leftline{\fwqh\fwqh #1 #2}}
- X\def\fwtocd#1#2{\leftline{\fwqh\fwqh\fwqh #1 #2}}
- X\def\fwtoce#1#2{\leftline{\fwqh\fwqh\fwqh\fwqh #1 #2}}
- X\def\fwtocfinish#1{\fwrule}
- X
- X% The following "library" macros define five different strengths of headings
- X% which can be used later in the section macros.
- X\def\fwliba#1#2{\vfill\eject{\fwfontboldc #1 #2}\penalty200\smallskip}
- X\def\fwlibb#1#2{\fwbeforesec{\fwfontboldb #1 #2}\penalty200\smallskip}
- X\def\fwlibc#1#2{\fwbeforesec{\fwfontnormb #1 #2}\penalty200\smallskip}
- X\def\fwlibd#1#2{\fwbeforesec{\bf #1 #2}\penalty200}
- X\def\fwlibe#1#2{\fwbeforesec{\bf #1 #2}}
- X
- X% Here are the macros that actually typeset the section headings throughout
- X% the document. The fwlib system has been employed so as to easily allow the
- X% user to redefine the strengths of headings to taste. For example, the
- X% user could insert in the input document a similar set of definitions to these
- X% but with the b..e headings set to \fwlibc. This would tone down the output.
- X\def\fwseca#1#2{\fwliba{#1}{#2}}
- X\def\fwsecb#1#2{\fwlibb{#1}{#2}}
- X\def\fwsecc#1#2{\fwlibc{#1}{#2}}
- X\def\fwsecd#1#2{\fwlibd{#1}{#2}}
- X\def\fwsece#1#2{\fwlibe{#1}{#2}}
- X
- X
- X% Support for Explicit Typesetting
- X% --------------------------------
- X% FunnelWeb supports pragmas and other constructs that allow
- X% typesetter-independent typesetting commands to be given. The
- X% following macros support these features.
- X
- X% The in-text literal @{sloth@} and emphasise @[walrus@] features.
- X\def\fwlit#1{{\tt #1}}
- X\def\fwemp#1{{\it #1}}
- X
- X% The "@p new_page" pragma.
- X\def\fwnewpage{\vfill\eject}
- X
- X% The "@p vskip Nmm" pragma.
- X\def\fwvskip#1{\null\vskip #1mm}
- X
- X% The "@p title <font> <align> <text>" pragma.
- X\def\fwfontnormal#1{{\fwfontnorm {#1}}}
- X\def\fwfonttitle#1{{\fwfontboldd {#1}}}
- X\def\fwfontsmalltitle#1{{\fwfontboldb {#1}}}
- X\def\fwleftline#1{\leftline{#1}}
- X\def\fwcenterline#1{\centerline{#1}}
- X\def\fwrightline#1{\rightline{#1}}
- X
- X
- X% Support for Old FunnelWeb
- X% -------------------------
- X% The following macros were used extensively in the first version of
- X% FunnelWeb and are retained so that these older input files will still
- X% typeset cleanly.
- X\def\p#1{{\tt #1}} % P for Program text.
- X\def\flagpage#1#2{
- X \null
- X \vfill
- X \centerline{\fwfontboldd #1}
- X \vskip 1cm
- X \centerline{\fwfontboldd #2}
- X \vfill
- X \null
- X \vfill
- X}
- X
- X%====================== End of FunnelWeb TeX Definitions =======================
- XEX15: This example demonstrates some of FunnelWeb's generic typesetting
- X constructs.
- X
- X\fwvskip{40}
- X\fwcenterline{\fwfonttitle{Hairy Wombat}}
- X\fwcenterline{\fwfonttitle{Simulation}}
- X\fwvskip{10}
- X\fwcenterline{\fwfontsmalltitle{A Program in Six Parts}}
- X\fwcenterline{\fwfontsmalltitle{Simulating the Life of Some Hairy Wombats}}
- X\fwvskip{20}
- X\fwleftline{\fwfontnormal{By Zqitzypbuswapzra Ypongtatoslrtzz}}
- X
- X\fwnewpage
- X
- X
- X\fwtocstart{}
- X\fwtoca{1}{Section One}
- X\fwtoca{2}{Section Two}
- X\fwtocfinish{}
- X
- X
- X\fwnewpage
- X
- X
- X\fwseca{1}{Section One}
- X\fwseca{2}{Section Two}
- X
- X\fwbeginmacro
- X\fwfilename{ex15.out}{1}\fwequals \fwodef \fwbtx[Dummy
- X]fwetx=%
- X\fwcdef
- X\fwbeginmacronotes
- X\fwisafile{This macro is attached to an output file.}
- X\fwendmacronotes
- X\fwendmacro
- X
- X\bye
- X
- X
- X%*******************************************************************************
- X%* END OF AUTOMATICALLY GENERATED TEX FILE *
- X%*******************************************************************************
- X
- END_OF_FILE
- if test 16000 -ne `wc -c <'answers/ex15.tex'`; then
- echo shar: \"'answers/ex15.tex'\" unpacked with wrong size!
- fi
- # end of 'answers/ex15.tex'
- fi
- if test -f 'sources/option.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'sources/option.c'\"
- else
- echo shar: Extracting \"'sources/option.c'\" \(16334 characters\)
- sed "s/^X//" >'sources/option.c' <<'END_OF_FILE'
- X/*##############################################################################
- X
- XFUNNNELWEB COPYRIGHT
- X====================
- XFunnelWeb is a literate-programming macro preprocessor.
- X
- Copyright (C) 1992 Ross N. Williams.
- X
- X Ross N. Williams
- X ross@spam.adelaide.edu.au
- X 16 Lerwick Avenue, Hazelwood Park 5066, Australia.
- X
- This program is free software; you can redistribute it and/or modify
- it under the terms of Version 2 of the GNU General Public License as
- published by the Free Software Foundation.
- X
- This program is distributed WITHOUT ANY WARRANTY; without even the implied
- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See Version 2 of the GNU General Public License for more details.
- X
- You should have received a copy of Version 2 of the GNU General Public
- License along with this program. If not, you can FTP the license from
- prep.ai.mit.edu/pub/gnu/COPYING-2 or write to the Free Software
- XFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- Section 2a of the license requires that all changes to this file be
- recorded prominently in this file. Please record all changes here.
- X
- Programmers:
- X RNW Ross N. Williams ross@spam.adelaide.edu.au
- X
- Changes:
- X 07-May-1992 RNW Program prepared for release under GNU GPL V2.
- X
- X##############################################################################*/
- X
- X
- X/******************************************************************************/
- X/* OPTION.C */
- X/******************************************************************************/
- X
- X#include <ctype.h>
- X#include "style.h"
- X
- X#include "as.h"
- X#include "data.h"
- X#include "machin.h"
- X#include "misc.h"
- X#include "option.h"
- X
- X/******************************************************************************/
- X
- LOCAL void wl_caret P_((ulong,void (*)(char *)));
- LOCAL void wl_caret(n,p_outf)
- X/* Writes a caret at position n of an otherwise blank line. */
- ulong n;
- void (*p_outf) P_((char *));
- X{
- X as_cold(n<1000,"wl_caret: Argument is out of range.");
- X while (--n > 0)
- X (*p_outf)(" ");
- X (*p_outf)("^\n");
- X}
- X
- X/******************************************************************************/
- X
- XEXPORT void op_ini(p_op)
- p_op_t p_op;
- X{
- X p_op->op_f_b=FALSE;
- X strcpy(&p_op->op_f_s[0],"");
- X
- X p_op->op_j_b=FALSE;
- X strcpy(&p_op->op_j_s[0],"");
- X
- X strcpy(&p_op->op_i_s[0],"");
- X
- X p_op->op_o_b=TRUE;
- X strcpy(&p_op->op_o_s[0],"");
- X
- X p_op->op_t_b=FALSE;
- X strcpy(&p_op->op_t_s[0],"");
- X
- X p_op->op_l_b=TRUE;
- X strcpy(&p_op->op_l_s[0],"");
- X
- X p_op->op_d_b=FALSE;
- X
- X p_op->op_c_i=2;
- X
- X p_op->op_q_b=FALSE;
- X
- X p_op->op_s_b=FALSE;
- X p_op->op_s_i=1;
- X
- X p_op->op_w_b=FALSE;
- X p_op->op_w_i=80;
- X
- X p_op->op_x_b=FALSE;
- X strcpy(&p_op->op_x_s[0],"");
- X
- X p_op->op_k_b=FALSE;
- X
- X p_op->op_b1_b=FALSE;
- X p_op->op_b2_b=FALSE;
- X p_op->op_b3_b=FALSE;
- X p_op->op_b4_b=FALSE;
- X p_op->op_b5_b=FALSE;
- X p_op->op_b6_b=FALSE;
- X p_op->op_b7_b=FALSE;
- X
- X p_op->op_h_b=FALSE;
- X strcpy(&p_op->op_h_s[0],"menu");
- X}
- X
- X/******************************************************************************/
- X
- XEXPORT bool op_add(p_op,p_cl,p_outf)
- p_op_t p_op;
- p_cl_t p_cl;
- void (*p_outf) P_((char *));
- X{
- X op_t op_save; /* Saves *p_op so it can be restored later. */
- X char *comline = (char *) p_cl; /* Pointer to the command line to be parsed. */
- X char *p; /* Handy parsing pointer. */
- X bool seen_error = FALSE; /* TRUE iff one or more errors seen. */
- X
- X#define ECHO_CL {if (!seen_error)\
- X {(*p_outf)(comline);(*p_outf)("\n"); seen_error=TRUE;}}
- X
- X /* Save the parameter option structure so that we can restore it */
- X /* if an error occurs later on. */
- X ASSIGN(op_save,*p_op);
- X
- X /* Check to make sure that the command line is not too long. */
- X /* This error should really never occur. */
- X p=comline;
- X while (*p++ != EOS)
- X if ((p-comline) > COMLINE_MAX)
- X {
- X (*p_outf)("FunnelWeb command line syntax error.\n");
- X (*p_outf)("The entire command line is too long.\n");
- X sprintf(linet1,"The maximum command line length is %u characters.\n",
- X (unsigned) COMLINE_MAX);
- X (*p_outf)(linet1);
- X goto failure;
- X }
- X
- X /* Check that the command line contains only printables. */
- X p=comline;
- X while (*p != EOS)
- X {
- X if (!isascprn(*p))
- X {
- X (*p_outf)("FunnelWeb command line syntax error.\n");
- X (*p_outf)("Command line contains one or more non-printables.\n");
- X sprintf(linet1,"The first is at column %u.\n",(unsigned) (1+p-comline));
- X (*p_outf)(linet1);
- X goto failure;
- X }
- X p++;
- X }
- X
- X /* Now parse each option. */
- X p=comline;
- X while (TRUE)
- X {/* This loop processes one command line parameter (option) per iteration. */
- X char *p_startopt; /* Points to the start of the parameter. */
- X bool opsign; /* The sign of the current option (+=TRUE). */
- X bool opsign_active; /* TRUE => (+ or -). FALSE => (=). */
- X char letter; /* Letter of current option. */
- X cl_t cl_temp; /* Parameter string of the current option. */
- X fn_t fn_temp; /* Parameter string of the current option. */
- X int i; /* Handy int used to feed sscanf. */
- X
- X /* Skip first parameter or rest of previous parameter after syntax error. */
- X while ((*p!=' ') && (*p!=EOS)) p++;
- X
- X /* Skip blanks between parameters. */
- X while (*p==' ') p++;
- X
- X /* At this point we are either at the start of a parameter or at EOS. */
- X /* Finish if we are at the EOS. */
- X if (*p==EOS) break;
- X
- X /* p now points to the next parameter (option). Make a note of its start. */
- X p_startopt=p;
- X
- X /* This switch statement parses the sign and letter characters. */
- X switch (*p)
- X {
- X case '-': opsign=FALSE; opsign_active=TRUE; p++; goto parse_letter;
- X case '+': opsign=TRUE; opsign_active=TRUE; p++; goto parse_letter;
- X case '=': opsign_active=FALSE; p++; goto parse_letter;
- X parse_letter:
- X /* We have seen a sign. There should be a following letter. */
- X letter = *p;
- X if (!isalpha(letter))
- X {
- X ECHO_CL; wl_caret(p-comline,p_outf);
- X (*p_outf)("FunnelWeb command line syntax error.\n");
- X (*p_outf)("Option letter expected here.\n");
- X continue; /* Skip to the next parameter. */
- X }
- X p++;
- X break;
- X default: /* If no sign the option is a NAME option and defaults to +F. */
- X opsign=TRUE; opsign_active=TRUE; letter='F'; break;
- X } /* End switch */
- X
- X /* Assert: p points to the parameter string of the option. */
- X /* Copy the parameter string into the holding variable cl_temp. */
- X {char *q;
- X q = &cl_temp[0];
- X while ((*p!=EOS) && (*p!=' '))
- X *q++ = *p++;
- X *q=EOS;
- X }
- X
- X /* As COMLINE_MAX can be greater than FILENAME_MAX, we have to be careful */
- X /* that the user is not about to blow our filename buffer. */
- X if (strlen(cl_temp) > FILENAME_MAX)
- X {
- X ECHO_CL; wl_caret(p_startopt-comline,p_outf);
- X (*p_outf)("FunnelWeb command line syntax error.\n");
- X (*p_outf)("Option parameter string is too long.\n");
- X sprintf(linet1,"The maximum option parameter length is %u characters.\n",
- X (unsigned) FILENAME_MAX);
- X (*p_outf)(linet1);
- X continue; /* Skip to next parameter. */
- X }
- X
- X /* Now that we know that the parameter is not too big, we can copy it */
- X /* into a temporary variable of filename type. */
- X strcpy(&fn_temp[0],&cl_temp[0]);
- X
- X /* At this point p points to the character following the option that */
- X /* we have just scanned. This is either a blank or an EOS. */
- X /* The current option is held in (opsign,opsign_active,letter,fn_temp). */
- X /* Now we apply the option to the option record. */
- X switch (toupper(letter))
- X {
- X case 'F':
- X if (opsign_active) p_op->op_f_b=opsign;
- X strcpy(&p_op->op_f_s[0],&fn_temp[0]);
- X break;
- X case 'J':
- X if (opsign_active) p_op->op_j_b=opsign;
- X strcpy(&p_op->op_j_s[0],&fn_temp[0]);
- X break;
- X case 'I':
- X strcpy(&p_op->op_i_s[0],&fn_temp[0]);
- X break;
- X case 'O':
- X if (opsign_active) p_op->op_o_b=opsign;
- X strcpy(&p_op->op_o_s[0],&fn_temp[0]);
- X break;
- X case 'T':
- X if (opsign_active) p_op->op_t_b=opsign;
- X strcpy(&p_op->op_t_s[0],&fn_temp[0]);
- X break;
- X case 'L':
- X if (opsign_active) p_op->op_l_b=opsign;
- X strcpy(&p_op->op_l_s[0],&fn_temp[0]);
- X break;
- X case 'D':
- X if (opsign_active) p_op->op_d_b=opsign;
- X if (strlen(fn_temp)>0)
- X {
- X ECHO_CL; wl_caret(3+p_startopt-comline,p_outf);
- X (*p_outf)("FunnelWeb command line syntax error.\n");
- X (*p_outf)("The D option does not take an argument.\n");
- X }
- X break;
- X case 'C':
- X if ((sscanf(&fn_temp[0],"%d",&i) != 1) || (i<0) || (100<i))
- X {
- X ECHO_CL; wl_caret(3+p_startopt-comline,p_outf);
- X (*p_outf)("FunnelWeb command line syntax error.\n");
- X (*p_outf)("Numeric argument to C option invalid. It must\n");
- X (*p_outf)("be an unsigned decimal integer in the range [0,100].\n");
- X }
- X else
- X p_op->op_c_i=i;
- X break;
- X case 'Q':
- X if (opsign_active) p_op->op_q_b=opsign;
- X if (strlen(fn_temp)>0)
- X {
- X ECHO_CL; wl_caret(3+p_startopt-comline,p_outf);
- X (*p_outf)("FunnelWeb command line syntax error.\n");
- X (*p_outf)("The Q option does not take an argument.\n");
- X }
- X break;
- X case 'S':
- X if (opsign_active) p_op->op_s_b=opsign;
- X if (strlen(fn_temp)==0) break;
- X if ((sscanf(&fn_temp[0],"%d",&i) != 1) || (i<0) || (100<i))
- X {
- X ECHO_CL; wl_caret(2+p_startopt-comline,p_outf);
- X (*p_outf)("FunnelWeb command line syntax error.\n");
- X (*p_outf)("Numeric argument to S option invalid. It must\n");
- X (*p_outf)("be an unsigned decimal integer in the range [0,100].\n");
- X }
- X else
- X p_op->op_s_i=i;
- X break;
- X case 'W':
- X if (opsign_active) p_op->op_w_b=opsign;
- X if (strlen(fn_temp)==0) break;
- X if ((sscanf(&fn_temp[0],"%d",&i) != 1) || (i<0) || (1000<i))
- X {
- X ECHO_CL; wl_caret(2+p_startopt-comline,p_outf);
- X (*p_outf)("FunnelWeb command line syntax error.\n");
- X (*p_outf)("Error: Numeric argument to W option invalid. It must\n");
- X (*p_outf)("be an unsigned decimal integer in the range [0,1000].\n");
- X }
- X else
- X p_op->op_w_i=i;
- X break;
- X case 'X':
- X if (opsign_active) p_op->op_x_b=opsign;
- X strcpy(&p_op->op_x_s[0],&fn_temp[0]);
- X break;
- X case 'K':
- X if (opsign_active) p_op->op_k_b=opsign;
- X if (strlen(fn_temp)>0)
- X {
- X ECHO_CL; wl_caret(3+p_startopt-comline,p_outf);
- X (*p_outf)("FunnelWeb command line syntax error.\n");
- X (*p_outf)("The K option does not take an argument.\n");
- X }
- X break;
- X case 'H':
- X if (opsign_active) p_op->op_h_b=opsign;
- X if (strlen(&fn_temp[0])>0)
- X if (strlen(&fn_temp[0]) > HL_NMLEN)
- X {
- X ECHO_CL; wl_caret(3+p_startopt-comline,p_outf);
- X (*p_outf)("FunnelWeb command line syntax error.\n");
- X (*p_outf)("The H option string argument is too long.\n");
- X (*p_outf)("Try +Hmenu for a list of help message names.\n");
- X }
- X else
- X if (hel_num(&fn_temp[0]) == HL_ERR)
- X {
- X ECHO_CL; wl_caret(3+p_startopt-comline,p_outf);
- X (*p_outf)("FunnelWeb command line syntax error.\n");
- X (*p_outf)("Unrecognised message name in argument to H option.\n");
- X (*p_outf)("Try +Hmenu for a list of help message names.\n");
- X }
- X else
- X strcpy(&p_op->op_h_s[0],&fn_temp[0]);
- X break;
- X case 'B':
- X {
- X uword i;
- X if (strlen(fn_temp)==0)
- X {
- X ECHO_CL; wl_caret(3+p_startopt-comline,p_outf);
- X (*p_outf)("FunnelWeb command line syntax error.\n");
- X (*p_outf)("The B option must be followed by one or more digits.\n");
- X (*p_outf)("The digits must be in the range 1..7.\n");
- X break;
- X }
- X for (i=0;i<strlen(fn_temp);i++)
- X if (fn_temp[i]<'1' || fn_temp[i]>'7')
- X {
- X
- XECHO_CL; wl_caret(2+p_startopt-comline+(1+i),p_outf);
- X (*p_outf)("FunnelWeb command line syntax error.\n");
- X (*p_outf)("Error: Characters in B argument must be '1'..'7'.\n");
- X goto endbop;
- X }
- X if (opsign_active)
- X for (i=0;i<strlen(fn_temp);i++)
- X switch (fn_temp[i])
- X {
- X case '1': p_op->op_b1_b=opsign; break;
- X case '2': p_op->op_b2_b=opsign; break;
- X case '3': p_op->op_b3_b=opsign; break;
- X case '4': p_op->op_b4_b=opsign; break;
- X case '5': p_op->op_b5_b=opsign; break;
- X case '6': p_op->op_b6_b=opsign; break;
- X case '7': p_op->op_b7_b=opsign; break;
- X default: as_bomb("op_add: b option case defaulted.");
- X }
- X endbop:
- X break;
- X }
- X default:
- X ECHO_CL; wl_caret(2+p_startopt-comline,p_outf);
- X (*p_outf)("FunnelWeb command line syntax error.\n");
- X (*p_outf)("Error: Unknown option letter.\n");
- X (*p_outf)("Legal option letters are FIOTLCSWPXZ.\n");
- X (*p_outf)("(Note: But P is not yet implemented!)\n");
- X break;
- X }
- X } /* End while. */
- X if (seen_error) goto failure;
- X return TRUE;
- X
- X failure: ASSIGN(*p_op,op_save); return FALSE;
- X}
- X
- X/******************************************************************************/
- X
- XEXPORT void op_wri(p_op,p_outf)
- p_op_t p_op;
- void (*p_outf) P_((char *));
- X{
- X#define STC(BOOLV) ((BOOLV)?'+':'-')
- X sprintf(linet1," %cB1 %cB2 %cB3 %cB4 %cB5 %cB6 %cB7\n",
- X STC(p_op->op_b1_b),
- X STC(p_op->op_b2_b),
- X STC(p_op->op_b3_b),
- X STC(p_op->op_b4_b),
- X STC(p_op->op_b5_b),
- X STC(p_op->op_b6_b),
- X STC(p_op->op_b7_b));(*p_outf)(linet1);
- X sprintf(linet1," +C%u\n" , (unsigned) p_op->op_c_i );(*p_outf)(linet1);
- X sprintf(linet1," %cD\n" , STC(p_op->op_d_b) );(*p_outf)(linet1);
- X sprintf(linet1," %cF%s\n", STC(p_op->op_f_b), p_op->op_f_s );(*p_outf)(linet1);
- X sprintf(linet1," %cH%s\n", STC(p_op->op_h_b), p_op->op_h_s );(*p_outf)(linet1);
- X sprintf(linet1," +I%s\n" , p_op->op_i_s );(*p_outf)(linet1);
- X sprintf(linet1," %cJ%s\n", STC(p_op->op_j_b), p_op->op_j_s );(*p_outf)(linet1);
- X sprintf(linet1," %cK\n" , STC(p_op->op_k_b) );(*p_outf)(linet1);
- X sprintf(linet1," %cL%s\n", STC(p_op->op_l_b), p_op->op_l_s );(*p_outf)(linet1);
- X sprintf(linet1," %cO%s\n", STC(p_op->op_o_b), p_op->op_o_s );(*p_outf)(linet1);
- X sprintf(linet1," %cQ\n" , STC(p_op->op_q_b) );(*p_outf)(linet1);
- X sprintf(linet1," %cS%u\n", STC(p_op->op_s_b), (unsigned) p_op->op_s_i );(*p_outf)(linet1);
- X sprintf(linet1," %cT%s\n", STC(p_op->op_t_b), p_op->op_t_s );(*p_outf)(linet1);
- X sprintf(linet1," %cW%u\n", STC(p_op->op_w_b), (unsigned) p_op->op_w_i );(*p_outf)(linet1);
- X sprintf(linet1," %cX%s\n", STC(p_op->op_x_b), p_op->op_x_s );(*p_outf)(linet1);
- X}
- X
- X/******************************************************************************/
- X/* End of OPTION.C */
- X/******************************************************************************/
- X
- END_OF_FILE
- if test 16334 -ne `wc -c <'sources/option.c'`; then
- echo shar: \"'sources/option.c'\" unpacked with wrong size!
- fi
- # end of 'sources/option.c'
- fi
- if test -f 'sources/table.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'sources/table.c'\"
- else
- echo shar: Extracting \"'sources/table.c'\" \(15854 characters\)
- sed "s/^X//" >'sources/table.c' <<'END_OF_FILE'
- X/*##############################################################################
- X
- XFUNNNELWEB COPYRIGHT
- X====================
- XFunnelWeb is a literate-programming macro preprocessor.
- X
- Copyright (C) 1992 Ross N. Williams.
- X
- X Ross N. Williams
- X ross@spam.adelaide.edu.au
- X 16 Lerwick Avenue, Hazelwood Park 5066, Australia.
- X
- This program is free software; you can redistribute it and/or modify
- it under the terms of Version 2 of the GNU General Public License as
- published by the Free Software Foundation.
- X
- This program is distributed WITHOUT ANY WARRANTY; without even the implied
- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See Version 2 of the GNU General Public License for more details.
- X
- You should have received a copy of Version 2 of the GNU General Public
- License along with this program. If not, you can FTP the license from
- prep.ai.mit.edu/pub/gnu/COPYING-2 or write to the Free Software
- XFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- X
- Section 2a of the license requires that all changes to this file be
- recorded prominently in this file. Please record all changes here.
- X
- Programmers:
- X RNW Ross N. Williams ross@spam.adelaide.edu.au
- X
- Changes:
- X 07-May-1992 RNW Program prepared for release under GNU GPL V2.
- X
- X##############################################################################*/
- X
- X
- X/******************************************************************************/
- X/* TABLE.C */
- X/******************************************************************************/
- X/* */
- X/* Notes */
- X/* ----- */
- X/* - There are few comments at the start of each function. As definitions */
- X/* appear in the .H file, and it is dangerous to duplicate definitions, I */
- X/* have simply omitted them here. */
- X/* */
- X/* About The Cache */
- X/* --------------- */
- X/* A typical usage sequence for tables is for the user to first call tb_itb */
- X/* to see if a key is in the table and then call either tb_loo or tb_ins */
- X/* to lookup the value or to add a new (key,value) pair to the table. */
- X/* In order to avoid performing TWO searches down the binary tree in such */
- X/* cases, a CACHE is maintained in the table data structure between calls. */
- X/* */
- X/* ca_valid stores whether the cache contents are valid. If TRUE then: */
- X/* ca_p_key points to a key. */
- X/* ca_p_node points to the node in the tree containing the key, or contains */
- X/* NULL if no such node exists. */
- X/* ca_p_parent points to the node in the tree that is the parent of the node */
- X/* ca_p_node in the tree, or (if ca_p_node==NULL) WOULD BE the parent if a */
- X/* node containing the key were inserted in the tree. If the tree is */
- X/* currently empty, ca_p_parent will be NULL. */
- X/* */
- X/******************************************************************************/
- X
- X#include "style.h"
- X
- X#include "as.h"
- X#include "machin.h"
- X#include "memory.h"
- X
- X/******************************************************************************/
- X
- X/* In order to catch uninitialized and corrupted tables, the first and last */
- X/* fields of legitimate table objects contain magic numbers. The following */
- X/* #defines give the values of these numbers. The first thing that each */
- X/* function of this package does is to check the two magic number fields of */
- X/* the table it has just been passed, and bomb the package if the fields have */
- X/* the wrong values. This technique is likely to pick uninitialized tables, */
- X/* as well as tables that have been partially overwritten. */
- X#define MAGIC_HEAD_VALUE (53456839L)
- X#define MAGIC_TAIL_VALUE (28434290L)
- X
- X/* Comparing keys is messy and so we define a macro to help us out. */
- X#define key_compare(a,b) ((*(p_tb->p_kycm))((a),(b)))
- X
- X/******************************************************************************/
- X
- X/* The functions of the table abstraction pass keys and values exclusively */
- X/* using pointers. These two definitions define types for these pointers. */
- X/* Although the two types are both 'p_void', the different types are useful */
- X/* to indicate what is expected in each position of the parameter lists. */
- typedef p_void p_tbky_t;
- typedef p_void p_tbvl_t;
- X
- X/* Define a type for a function to compare two keys. Such functions are */
- X/* needed to organize the storage of (key,value) pairs inside the table. */
- X/* Given the arguments are (a,b), the function should return: */
- X/* -1 if a<b */
- X/* 0 if a==b */
- X/* 1 if a>b */
- X/* The user must create such a function and hand it to the 'tb_create' */
- X/* function when creating new a new table. */
- typedef sign (*p_kycm_t) P_((p_tbky_t,p_tbky_t));
- X
- X/* The (key,value) pairs in the table are stored in a binary tree. The tree */
- X/* is ordered by the key ordering function passed in at table creation. */
- typedef struct node_t_
- X {
- X struct node_t_ *p_left;
- X struct node_t_ *p_right;
- X struct node_t_ *p_parent;
- X p_tbky_t p_key;
- X p_tbvl_t p_value;
- X }
- X node_t;
- typedef node_t *p_node_t;
- X
- X/* The type tb_t (table type) defines the root table data record. This */
- X/* record stores attributes of the table along with the main binary tree of */
- X/* (key,value) pairs. */
- typedef struct
- X {
- X ulong magic_head; /* Magic number to allow corruption checks. */
- X size_t key_bytes; /* Number of bytes in a key. */
- X size_t value_bytes; /* Number of bytes in a value. */
- X p_kycm_t p_kycm; /* Pointer to function to compare keys. */
- X p_node_t tree; /* Ptr to root of (key,value) binary tree. */
- X ulong num_keys; /* Number of (k,v) pairs in the table. */
- X bool ca_valid; /* Cache: TRUE iff cache contents are valid. */
- X p_tbky_t ca_p_key; /* Cache: Key value cache contents refer to. */
- X p_node_t ca_p_node; /* Cache: Pointer to node in binary tree. */
- X p_node_t ca_p_parent; /* Cache: Pointer to parent of ca_p_node. */
- X p_node_t p_read_next; /* Pointer to next node to be read. */
- X ulong magic_tail; /* Magic number to allow corruption checks. */
- X } tb_t;
- X
- typedef tb_t *p_tb_t; /* Pointer to main table record. */
- X
- X/* Defining INTABLEC hides the abstract definition. */
- X#define INTABLEC
- X#include "table.h"
- X
- X/******************************************************************************/
- X/* PRIVATE FUNCTIONS */
- X/******************************************************************************/
- X
- LOCAL p_node_t new_node P_((p_tb_t,p_tbky_t,p_tbvl_t));
- LOCAL p_node_t new_node(p_tb,p_tbky,p_tbvl)
- X/* Creates a new tree node and returns a pointer to it. */
- X/* p_tb is the table for which the new node is to be created. */
- X/* p_tbky and p_tbvl point to the key and value to go in the new node. */
- X/* Assumes that a tb_check(p_tb) has already been performed by the caller. */
- p_tb_t p_tb;
- p_tbky_t p_tbky;
- p_tbvl_t p_tbvl;
- X{
- X p_node_t p_node;
- X
- X p_node=(p_node_t) mm_temp(sizeof(node_t));
- X
- X p_node->p_left = NULL;
- X p_node->p_right = NULL;
- X p_node->p_parent = NULL;
- X p_node->p_key = mm_temp(p_tb->key_bytes );
- X p_node->p_value = mm_temp(p_tb->value_bytes);
- X
- X memcpy(p_node->p_key ,p_tbky,p_tb->key_bytes );
- X memcpy(p_node->p_value,p_tbvl,p_tb->value_bytes);
- X
- X return p_node;
- X}
- X
- X/******************************************************************************/
- X
- LOCAL void tb_check P_((p_tb_t));
- LOCAL void tb_check(p_tb)
- X/* Accepts a pointer to a table and performs a series of checks to make sure */
- X/* that the table has not been corrupted in some way. */
- p_tb_t p_tb;
- X{
- X as_cold(p_tb!=NULL,"tb_check: Table pointer is NULL.");
- X as_cold(p_tb->magic_head==MAGIC_HEAD_VALUE,
- X "tb_check: Magic number at head of record is incorrect.");
- X as_cold(p_tb->magic_tail==MAGIC_TAIL_VALUE,
- X "tb_check: Magic number at tail of record is incorrect.");
- X}
- X
- X/******************************************************************************/
- X
- LOCAL p_node_t min_leaf P_((p_node_t));
- LOCAL p_node_t min_leaf(p_node)
- X/* Returns a pointer to the node that is leftmost (has the smallest value */
- X/* according to the ordering function) in the specified node's subtree. */
- p_node_t p_node;
- X{
- X if (p_node==NULL)
- X return NULL;
- X while (p_node->p_left != NULL)
- X p_node=p_node->p_left;
- X return p_node;
- X}
- X
- X/******************************************************************************/
- X
- LOCAL p_node_t next_node P_((p_node_t));
- LOCAL p_node_t next_node(p_node)
- X/* Give a pointer to a node in the binary tree, returns a pointer to the next */
- X/* node (in sequence defined by the order function) or NULL if the given node */
- X/* is the last node in the ordered sequence. */
- p_node_t p_node;
- X{
- X /* If there is a right subtree, we need the minimum node of that subtree. */
- X if (p_node->p_right != NULL)
- X return min_leaf(p_node->p_right);
- X
- X /* Otherwise go up as far as possible through right arcs. */
- X while (p_node->p_parent!=NULL && p_node->p_parent->p_right==p_node)
- X p_node=p_node->p_parent;
- X return p_node->p_parent;
- X}
- X
- X/******************************************************************************/
- X
- LOCAL void tb_search P_((p_tb_t,p_tbky_t));
- LOCAL void tb_search(p_tb,p_tbky)
- X/* Calling this function with a particular key value results in the cache */
- X/* becoming valid and containing the specified key. */
- p_tb_t p_tb;
- p_tbky_t p_tbky;
- X{
- X p_node_t p,p_parent;
- X
- X tb_check(p_tb);
- X
- X /* Return if the cache is already up to date. */
- X if (p_tb->ca_valid)
- X if (key_compare(p_tbky,p_tb->ca_p_key) == 0)
- X return;
- X
- X p_parent=NULL;
- X p=p_tb->tree;
- X while (p != NULL)
- X switch(key_compare(p_tbky,p->p_key))
- X {
- X case -1: p_parent=p; p=p->p_left; break;
- X case 1: p_parent=p; p=p->p_right; break;
- X case 0: goto found;
- X default:
- X as_bomb("tb_search: Key comparison function returned bad value.");
- X }
- X found:
- X p_tb->ca_valid = TRUE;
- X memcpy(p_tb->ca_p_key,p_tbky,p_tb->key_bytes);
- X p_tb->ca_p_node = p;
- X p_tb->ca_p_parent = p_parent;
- X}
- X
- X/******************************************************************************/
- X
- LOCAL void des_tree P_((p_node_t));
- LOCAL void des_tree(p_root)
- p_node_t p_root;
- X{
- X if (p_root==NULL)
- X return;
- X des_tree(p_root->p_left);
- X des_tree(p_root->p_right);
- X
- X /* This is what we would need if it wasn't for the MM watermark system. */
- X /* DEALLOCATE(PV p_root); */
- X}
- X
- X/******************************************************************************/
- X/* EXPORTED FUNCTIONS */
- X/******************************************************************************/
- X
- XEXPORT p_tb_t tb_cre(key_bytes,value_bytes,p_kycm)
- size_t key_bytes;
- size_t value_bytes;
- p_kycm_t p_kycm;
- X{
- X p_tb_t p_tb;
- X
- X p_tb = (p_tb_t) mm_temp(sizeof(tb_t));
- X p_tb->magic_head = MAGIC_HEAD_VALUE;
- X p_tb->key_bytes = key_bytes;
- X p_tb->value_bytes = value_bytes;
- X p_tb->p_kycm = p_kycm;
- X p_tb->tree = NULL;
- X p_tb->num_keys = 0;
- X p_tb->ca_valid = FALSE;
- X p_tb->ca_p_key = (p_tbky_t) mm_temp(key_bytes);
- X p_tb->ca_p_node = NULL; /* This initialization not strictly necessary. */
- X p_tb->ca_p_parent = NULL; /* This initialization not strictly necessary. */
- X p_tb->p_read_next = NULL;
- X p_tb->magic_tail = MAGIC_TAIL_VALUE;
- X
- X return p_tb;
- X}
- X
- X/******************************************************************************/
- X
- XEXPORT bool tb_itb(p_tb,p_tbky)
- p_tb_t p_tb;
- p_tbky_t p_tbky;
- X{
- X tb_check(p_tb);
- X
- X tb_search(p_tb,p_tbky);
- X return p_tb->ca_p_node != NULL;
- X}
- X
- X/******************************************************************************/
- X
- XEXPORT void tb_loo(p_tb,p_tbky,p_tbvl)
- p_tb_t p_tb;
- p_tbky_t p_tbky;
- p_tbvl_t p_tbvl;
- X{
- X tb_check(p_tb);
- X
- X tb_search(p_tb,p_tbky);
- X as_cold(p_tb->ca_p_node!=NULL,"tb_loo: Requested key is absent.");
- X memcpy(p_tbvl,p_tb->ca_p_node->p_value,p_tb->value_bytes);
- X}
- X
- X/******************************************************************************/
- X
- XEXPORT void tb_ins(p_tb,p_tbky,p_tbvl)
- p_tb_t p_tb;
- p_tbky_t p_tbky;
- p_tbvl_t p_tbvl;
- X{
- X p_node_t p_new;
- X
- X tb_check(p_tb);
- X
- X /* Validate the cache. Note: tb_search does it's own cache check. */
- X tb_search(p_tb,p_tbky);
- X
- X /* Ensure that the table does not already contain the key. */
- X as_cold(p_tb->ca_p_node==NULL,"tb_ins: Key is already present in the p_tb.");
- X
- X /* Create the new node. */
- X p_new=new_node(p_tb,p_tbky,p_tbvl);
- X
- X /* Insert the new node into the tree. */
- X if (p_tb->ca_p_parent==NULL)
- X p_tb->tree=p_new;
- X else
- X switch(key_compare(p_tbky,p_tb->ca_p_parent->p_key))
- X {
- X case -1: p_tb->ca_p_parent->p_left =p_new; break;
- X case 1: p_tb->ca_p_parent->p_right=p_new; break;
- X default: as_bomb("tb_ins: Key comparison function is inconsistent.");
- X }
- X p_new->p_parent=p_tb->ca_p_parent;
- X
- X /* Need to fiddle cache to make it correct, and inc num_keys. */
- X p_tb->ca_p_node=p_new;
- X p_tb->num_keys++;
- X}
- X
- X/******************************************************************************/
- X
- XEXPORT ulong tb_len(p_tb)
- p_tb_t p_tb;
- X{
- X tb_check(p_tb);
- X return p_tb->num_keys;
- X}
- X
- X/******************************************************************************/
- X
- XEXPORT void tb_fir(p_tb)
- p_tb_t p_tb;
- X{
- X tb_check(p_tb);
- X
- X p_tb->p_read_next=min_leaf(p_tb->tree);
- X}
- X
- X/******************************************************************************/
- X
- XEXPORT bool tb_rea(p_tb,p_tbky,p_tbvl)
- p_tb_t p_tb;
- p_tbky_t p_tbky;
- p_tbvl_t p_tbvl;
- X{
- X tb_check(p_tb);
- X
- X if (p_tb->p_read_next == NULL)
- X return FALSE;
- X
- X memcpy(p_tbky,p_tb->p_read_next->p_key ,p_tb->key_bytes );
- X memcpy(p_tbvl,p_tb->p_read_next->p_value,p_tb->value_bytes);
- X
- X p_tb->p_read_next=next_node(p_tb->p_read_next);
- X
- X return TRUE;
- X}
- X
- X/******************************************************************************/
- X
- X#if FALSE
- XEXPORT void tb_des(p_tb)
- p_tb_t p_tb;
- X{
- X /* This routine now unused because of the watermark system. */
- X return;
- X
- X /* tb_check(p_tb); */
- X
- X /* Zap the magic numbers in case the memory is re-used in same alignment. */
- X /* p_tb->magic_head=0; */
- X /* p_tb->magic_tail=0; */
- X
- X /* This is what we would need if it wasn't for the MM watermark system. */
- X /* des_tree(p_tb->tree); */ /* Zap the binary tree. */
- X /* DEALLOCATE(PV p_tb); */ /* Zap the node itself. */
- X}
- X#endif
- X
- X/******************************************************************************/
- X/* TABLE.C */
- X/******************************************************************************/
- X
- END_OF_FILE
- if test 15854 -ne `wc -c <'sources/table.c'`; then
- echo shar: \"'sources/table.c'\" unpacked with wrong size!
- fi
- # end of 'sources/table.c'
- fi
- if test -f 'sources/texhead.ctx' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'sources/texhead.ctx'\"
- else
- echo shar: Extracting \"'sources/texhead.ctx'\" \(15944 characters\)
- sed "s/^X//" >'sources/texhead.ctx' <<'END_OF_FILE'
- X WX("%===================== Start of FunnelWeb TeX Definitions ======================");
- X WX("");
- X WX("");
- X WX("% Version");
- X WX("% -------");
- X WX("% This is FunnelWeb TeX Macro Library Version 1.0.");
- X WX("");
- X WX("");
- X WX("% Copyright");
- X WX("% ---------");
- X WX("% This set of FunnelWeb TeX definitions was written by Ross Williams and was");
- X WX("% originally Copyright (C) 1992 Ross N. Williams. However, I, Ross Williams,");
- X WX("% hereby forego any claim to Copyright in this set of FunnelWeb TeX definitions");
- X WX("% and hereby authorize that the set of TeX definitions pass into the public");
- X WX("% domain. -- Ross N. Williams, 3:41pm 07-May-1992, Adelaide, Australia.");
- X WX("");
- X WX("");
- X WX("% Modification");
- X WX("% ------------");
- X WX("% Please record all modifications to these TeX definitions here. Unless");
- X WX("% otherwise specified, all modified definitions fall in the public domain too.");
- X WX("%");
- X WX("% Programmers:");
- X WX("% RNW Ross N. Williams ross@spam.adelaide.edu.au");
- X WX("%");
- X WX("% Changes:");
- X WX("% 07-May-1992 RNW Prepared this work for public domain release.");
- X WX("%");
- X WX("");
- X WX("");
- X WX("% General Comments");
- X WX("% ----------------");
- X WX("% This set of TeX definitions exists for two reasons:");
- X WX("%");
- X WX("% 1. To shorten and neaten the FunnelWeb TeX output.");
- X WX("% 2. To allow users to fiddle with the output format in their input files");
- X WX("% (by inserting redefining \"\\def\"s) without having to resort to");
- X WX("% modifying the FunnelWeb code.");
- X WX("%");
- X WX("% The user is warned that these definitions may be changed from time to time");
- X WX("% (but probably not much). The user should not be too sneaky. In particular,");
- X WX("% users wishing to redefine some of these macros should do so in an explicitly");
- X WX("% defined section at the top of their input file. This will mean that in the");
- X WX("% event of problems, that section can simply be deleted or commented out to");
- X WX("% allow the document to at least be typeset in the default format. Users should");
- X WX("% limit themselves to redefining these macros in such a section and should");
- X WX("% refrain from using the macros throughout their documents.");
- X WX("");
- X WX("");
- X WX("% Environment Parameters");
- X WX("% ----------------------");
- X WX("% \\tolerance tells TeX how tolerant it should be about making bad line and");
- X WX("% page breaks. Here we set it to it's maximum, as");
- X WX("% 1) Computer programs are likely to cause lots of bad breaks.");
- X WX("% 2) In most cases the user would probably rather get the TeX file through");
- X WX("% TeX without any errors than fiddle with spacings for perfection.");
- X WX("\\tolerance=10000");
- X WX("");
- X WX("% I don't like indentation as it makes the page look more busy. Instead,");
- X WX("% paragraphs are separated by a little space (see next).");
- X WX("\\parindent=0pt");
- X WX("");
- X WX("% In many cases, users will produce documents with long runs of paragraphs.");
- X WX("% In order to space out these paragraphs, it is convenient to maintain a");
- X WX("% prevailing non-zero \\parskip (end-of-paragaph skip). The only trouble is");
- X WX("% that the skip becomes a problem in macro definitions which require no skip");
- X WX("% and so we have to turn the skip on and off. The following two macros");
- X WX("% simplify this process.");
- X WX("\\def\\fwparskipon{\\parskip=\\medskipamount}");
- X WX("\\def\\fwparskipoff{\\parskip=0pt}");
- X WX("\\fwparskipon");
- X WX("");
- X WX("% Setting raggedbottom allows TeX to leave a bit of space at the bottom of the");
- X WX("% page in order to better vertically align the rest of the page (e.g. skips");
- X WX("% won't stretch as much). It also means that headings are less likely to be");
- X WX("% isolated at the bottom of the page without any following text.");
- X WX("\\raggedbottom");
- X WX("");
- X WX("");
- X WX("% Fonts");
- X WX("% -----");
- X WX("% Most of the typeset output is set in 10pt roman and 10pt tt font.");
- X WX("% The major extra font needs spring from titles and headings.");
- X WX("% For portability's sake we use only the following fonts:");
- X WX("% cmr10");
- X WX("% cmbx10");
- X WX("% cmtt10");
- X WX("% and some enlargements of them. These fonts are all \"standard\" fonts");
- X WX("% in Plain TeX. See The TeXbook p.350.");
- X WX("\\font\\fwfontnote=cmr7");
- X WX("");
- X WX("\\font\\fwfontnorm=cmr10");
- X WX("\\font\\fwfontnorma=cmr10 scaled \\magstep1");
- X WX("\\font\\fwfontnormb=cmr10 scaled \\magstep2");
- X WX("");
- X WX("\\font\\fwfontbold=cmbx10");
- X WX("\\font\\fwfontbolda=cmbx10 scaled \\magstep1");
- X WX("\\font\\fwfontboldb=cmbx10 scaled \\magstep2");
- X WX("\\font\\fwfontboldc=cmbx10 scaled \\magstep3");
- X WX("\\font\\fwfontboldd=cmbx10 scaled \\magstep4");
- X WX("");
- X WX("");
- X WX("% Macros for Stylistic Details");
- X WX("% ----------------------------");
- X WX("% This section contains all the fiddly little macros for setting the details");
- X WX("% of each macro definition.");
- X WX("");
- X WX("% Macro definitions are sandwiched by calls to these macros which can be used");
- X WX("% to sort out the spacing before and after the macro definition.");
- X WX("\\def\\fwbeginmacro{\\fwparskipoff\\bigskip}");
- X WX("\\def\\fwendmacro{\\fwparskipon\\par}");
- X WX("");
- X WX("% These macros deal with the macro name and definition line.");
- X WX("\\def\\fwmacroname#1#2{{\\sl #1\\/}$\\lbrack$#2$\\rbrack$}");
- X WX("\\def\\fwfilename#1#2{{\\bf #1}$\\lbrack$#2$\\rbrack$}");
- X WX("\\def\\fwzero#1{{\\bf Z}}");
- X WX("\\def\\fwmany#1{{\\bf M}}");
- X WX("\\def\\fwequals{ $\\equiv$}");
- X WX("\\def\\fwplusequals{ $+\\equiv$}");
- X WX("");
- X WX("% Now for the actual body of the definition. It looks nice to have the tt");
- X WX("% code indented a little. Again, we use macros instead of writing direct TeX,");
- X WX("% so as to allow the user to fiddle this stuff to taste without having to");
- X WX("% modify the FunnelWeb C code.");
- X WX("\\def\\fwodef{\\parindent=15pt\\vskip0pt$\\lbrace$\\parindent=20pt}");
- X WX("\\def\\fwcdef{$\\rbrace$\\vskip0pt\\parindent=0pt}");
- X WX("\\def\\fwoquote{`}");
- X WX("\\def\\fwcquote{'}");
- X WX("\\def\\fwoparen{$($}");
- X WX("\\def\\fwcomma{$,$}");
- X WX("\\def\\fwcparen{$)$}");
- X WX("\\def\\fwparam#1{$\\diamond #1$}");
- X WX("\\def\\fwparams#1{$(\\diamond #1)$}");
- X WX("");
- X WX("% These macros deal with the notes that are appended at the end of each");
- X WX("% macro definition. Note that even though \\fwisafile,\\fwusedin, and \\fwseealso");
- X WX("% have the same definition, they are given different names so as to allow the");
- X WX("% user to redefine these macros to typeset each kind of information differently");
- X WX("% if desired.");
- X WX("\\def\\fwbeginmacronotes{\\begingroup\\baselineskip=9pt\\smallskip}");
- X WX("\\def\\fwnote#1{{\\fwfontnote #1}\\par}");
- X WX("\\def\\fwisafile#1{\\fwnote{#1}}");
- X WX("\\def\\fwusedin#1{\\fwnote{#1}}");
- X WX("\\def\\fwseealso#1{\\fwnote{#1}}");
- X WX("\\def\\fwendmacronotes{\\endgroup}");
- X WX("");
- X WX("");
- X WX("% Macros to Typeset Program Code Verbatim");
- X WX("% ---------------------------------------");
- X WX("% This is by far the hairiest and most difficult part of the typesetting task");
- X WX("% because we have to turn off most of TeX's natural instincts in order to");
- X WX("% typeset the program text exactly as it appears in the input file.");
- X WX("% Two macros are defined to pull this off: \\fwbtx and \\fwverbatimgobble.");
- X WX("% Their code was inspired by the following sections of \"The TeXbook\":");
- X WX("% Appendix D: Dirty Tricks, 3.Verbatim listing, p.380-382.");
- X WX("% Appendix E: Example Formats, p.421.");
- X WX("% The \\fwbtx[ (for \"FunnelWeb Begin TeXt\") macro does most of the hard work.");
- X WX("% The liberal use of \"%\" is because I don't understand TeX well enough to");
- X WX("% understand when an end of line will cause trouble, and I am playing it safe.");
- X WX("");
- X WX("% Before defining the main \\fwbtx macro, we have to stash away some definitions");
- X WX("% in the hidden part of TeX's environment. Let's hope that these \"hidden\"");
- X WX("% definitions don't affect anything except what is desired to be affected.");
- X WX("");
- X WX("% The tt font in which we wish to set the text has two Latin lurking ligatures!");
- X WX("% These are ?` and !`. To disable them, we define the left quote when ACTIVE");
- X WX("% to be defined in such a way as to prevent ligatures. The main TeX text will");
- X WX("% normally not be exposed to this definition because normally the leftquote");
- X WX("% character is not active. The \\fwbtx macro temporarily makes the left quote");
- X WX("% character active thus activating the deactivation of left quote ligatures.");
- X WX("% See The TeXbook p.381.");
- X WX("{\\catcode`\\`=\\active \\gdef`{\\relax\\lq}}");
- X WX("");
- X WX("% TeX is fairly carefree about spaces and so we have to make it more serious.");
- X WX("% To do so we pull the same trick as above, setting up a definition for active");
- X WX("% space, but only making space active during the span of the verbatim text.");
- X WX("% In Plain TeX the active space is defined to be simply a space, but here we");
- X WX("% define it to be a control space. This ensures that the space cannot");
- X WX("% be gobbled up by one of TeX's mysterious mechanisms when activated.");
- X WX("% See The TeXbook, p.381 and p.352.");
- X WX("{\\obeyspaces\\global\\let =\\ }");
- X WX("");
- X WX("% Here is the main \\fwbtx verbatim text macro.");
- X WX("% Note: The order in which all these pieces of business have to be done is");
- X WX("% still a partial mystery to me. Don't fiddle with this stuff unless you");
- X WX("% think you know what you are doing.");
- X WX("\\def\\fwbtx[{%");
- X WX("%");
- X WX("% The funnies involved in getting verbatim output are safely housed inside");
- X WX("% this \\begingroup, and the \\endgroup in \\fwverbatimgobble. Groups are used");
- X WX("% instead of curly braces because we have to be able to signal the end of");
- X WX("% this macro with a curly brace.");
- X WX("\\begingroup%");
- X WX("%");
- X WX("% \\pars at the end of empty lines in the verbatim text won't come out normally");
- X WX("% because TeX is in vertical mode and they get gobbled up. To prevent this,");
- X WX("% we force \\par to exit vertical mode first. See The TeXbook p.381.");
- X WX("\\def\\par{\\leavevmode\\endgraf}%");
- X WX("%");
- X WX("% Activate the leftquote character so as to avoid ligatures (see above).");
- X WX("\\catcode`\\`=\\active%");
- X WX("%");
- X WX("% The \\obeylines macro simply defines end of line (^M) to be \\par. This ensures");
- X WX("% that TeX will treat each verbatim line as a new paragraph.");
- X WX("\\obeylines%");
- X WX("%");
- X WX("% To get verbatim output, we have to desex all the special characters. This");
- X WX("% is explained in detail in The TeXbook p.380.");
- X WX("\\def\\do##1{\\catcode`##1=12 }\\dospecials%");
- X WX("%");
- X WX("% Activate the space character so as to make TeX treat blanks seriously.");
- X WX("% This activation invokes an eralier definition (see above).");
- X WX("\\obeyspaces");
- X WX("%");
- X WX("% Interparagraph skips do not help the cause.");
- X WX("% Note: We have to preserve the indentation though, as the code is actually");
- X WX("% indented in the final output. See \\fwodef in an earlier section.");
- X WX("\\parskip=0pt%");
- X WX("%");
- X WX("% We typeset the verbatim text in tt font (courier on the Macintosh) for a");
- X WX("% number of reasons:");
- X WX("% - tt font has the same horizontal spacing for each character.");
- X WX("% - tt font covers the ASCII character set.");
- X WX("% - tt font doesn't have many surprises (e.g. ligatures).");
- X WX("% - tt font looks much what you might see on a computer terminal screen.");
- X WX("\\tt%");
- X WX("%");
- X WX("% Having set up an environment for verbatim, we are ready to use it.");
- X WX("% By invoking \\fwverbatimgobble, this \\fwbtx macro gobbles up text verbatim (as");
- X WX("% part of the parameter of \\fwverbatimgobble) until it sees the termination");
- X WX("% string \"]fwetx=\" (the \"=\" was thrown in to add obscurity as this sequence");
- X WX("% must never occur in the verbatim text).");
- X WX("\\fwverbatimgobble}");
- X WX("");
- X WX("% The \\fwverbatimgobble macro exists to allow \\fwbtx to bracket verbatim text.");
- X WX("\\def\\fwverbatimgobble#1]fwetx={#1\\endgroup}");
- X WX("");
- X WX("");
- X WX("% Table of Contents");
- X WX("% -----------------");
- X WX("% The five levels of table of contents that FunnelWeb supports are identified");
- X WX("% by the five letters [A..E]. These are used throughout the following macros.");
- X WX("");
- X WX("% The following macros are utilities to the TOC macros to follow.");
- X WX("\\def\\fwrule{\\medskip\\hrule\\medskip}");
- X WX("\\def\\fwqh{\\hskip1.5em\\relax}");
- X WX("\\def\\fwbeforesec{\\penalty-200\\bigskip\\medskip\\par}");
- X WX("");
- X WX("% The following macros are used to typeset the table of contents.");
- X WX("\\def\\fwtocstart#1{\\fwrule\\leftline{\\fwfontbolda Table of Contents}\\fwrule}");
- X WX("\\def\\fwtoca#1#2{\\leftline{{\\bf #1 #2}}}");
- X WX("\\def\\fwtocb#1#2{\\leftline{\\fwqh #1 #2}}");
- X WX("\\def\\fwtocc#1#2{\\leftline{\\fwqh\\fwqh #1 #2}}");
- X WX("\\def\\fwtocd#1#2{\\leftline{\\fwqh\\fwqh\\fwqh #1 #2}}");
- X WX("\\def\\fwtoce#1#2{\\leftline{\\fwqh\\fwqh\\fwqh\\fwqh #1 #2}}");
- X WX("\\def\\fwtocfinish#1{\\fwrule}");
- X WX("");
- X WX("% The following \"library\" macros define five different strengths of headings");
- X WX("% which can be used later in the section macros.");
- X WX("\\def\\fwliba#1#2{\\vfill\\eject{\\fwfontboldc #1 #2}\\penalty200\\smallskip}");
- X WX("\\def\\fwlibb#1#2{\\fwbeforesec{\\fwfontboldb #1 #2}\\penalty200\\smallskip}");
- X WX("\\def\\fwlibc#1#2{\\fwbeforesec{\\fwfontnormb #1 #2}\\penalty200\\smallskip}");
- X WX("\\def\\fwlibd#1#2{\\fwbeforesec{\\bf #1 #2}\\penalty200}");
- X WX("\\def\\fwlibe#1#2{\\fwbeforesec{\\bf #1 #2}}");
- X WX("");
- X WX("% Here are the macros that actually typeset the section headings throughout");
- X WX("% the document. The fwlib system has been employed so as to easily allow the");
- X WX("% user to redefine the strengths of headings to taste. For example, the");
- X WX("% user could insert in the input document a similar set of definitions to these");
- X WX("% but with the b..e headings set to \\fwlibc. This would tone down the output.");
- X WX("\\def\\fwseca#1#2{\\fwliba{#1}{#2}}");
- X WX("\\def\\fwsecb#1#2{\\fwlibb{#1}{#2}}");
- X WX("\\def\\fwsecc#1#2{\\fwlibc{#1}{#2}}");
- X WX("\\def\\fwsecd#1#2{\\fwlibd{#1}{#2}}");
- X WX("\\def\\fwsece#1#2{\\fwlibe{#1}{#2}}");
- X WX("");
- X WX("");
- X WX("% Support for Explicit Typesetting");
- X WX("% --------------------------------");
- X WX("% FunnelWeb supports pragmas and other constructs that allow");
- X WX("% typesetter-independent typesetting commands to be given. The");
- X WX("% following macros support these features.");
- X WX("");
- X WX("% The in-text literal @{sloth@} and emphasise @[walrus@] features.");
- X WX("\\def\\fwlit#1{{\\tt #1}}");
- X WX("\\def\\fwemp#1{{\\it #1}}");
- X WX("");
- X WX("% The \"@p new_page\" pragma.");
- X WX("\\def\\fwnewpage{\\vfill\\eject}");
- X WX("");
- X WX("% The \"@p vskip Nmm\" pragma.");
- X WX("\\def\\fwvskip#1{\\null\\vskip #1mm}");
- X WX("");
- X WX("% The \"@p title <font> <align> <text>\" pragma.");
- X WX("\\def\\fwfontnormal#1{{\\fwfontnorm {#1}}}");
- X WX("\\def\\fwfonttitle#1{{\\fwfontboldd {#1}}}");
- X WX("\\def\\fwfontsmalltitle#1{{\\fwfontboldb {#1}}}");
- X WX("\\def\\fwleftline#1{\\leftline{#1}}");
- X WX("\\def\\fwcenterline#1{\\centerline{#1}}");
- X WX("\\def\\fwrightline#1{\\rightline{#1}}");
- X WX("");
- X WX("");
- X WX("% Support for Old FunnelWeb");
- X WX("% -------------------------");
- X WX("% The following macros were used extensively in the first version of");
- X WX("% FunnelWeb and are retained so that these older input files will still");
- X WX("% typeset cleanly.");
- X WX("\\def\\p#1{{\\tt #1}} % P for Program text.");
- X WX("\\def\\flagpage#1#2{");
- X WX(" \\null");
- X WX(" \\vfill");
- X WX(" \\centerline{\\fwfontboldd #1}");
- X WX(" \\vskip 1cm");
- X WX(" \\centerline{\\fwfontboldd #2}");
- X WX(" \\vfill");
- X WX(" \\null");
- X WX(" \\vfill");
- X WX("}");
- X WX("");
- X WX("%====================== End of FunnelWeb TeX Definitions =======================");
- END_OF_FILE
- if test 15944 -ne `wc -c <'sources/texhead.ctx'`; then
- echo shar: \"'sources/texhead.ctx'\" unpacked with wrong size!
- fi
- # end of 'sources/texhead.ctx'
- fi
- echo shar: End of archive 7 \(of 20\).
- cp /dev/null ark7isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 20 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-