home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / SPIDER.ZIP / webkernel.tex < prev   
Text File  |  1990-09-11  |  15KB  |  384 lines

  1. % Copyright 1989 by Norman Ramsey, Odyssey Research Associates
  2. % To be used for research purposes only
  3. % For more information, see file COPYRIGHT
  4.  
  5. %\let\plainmark=\mark
  6. %\def\mark#1{\message{(Marking ``#1'')}\plainmark{#1}}
  7.  
  8. % standard macros for WEB listings (in addition to PLAIN.TEX)
  9. % rename some old favorites
  10. \let\amp=\&
  11. \let\SS=\S
  12. \let\PP=\P
  13. \let\em=\it % compatibility with latex
  14.  
  15. \newif\iftwoside\twosidefalse
  16. \parskip 0pt % .1pt plus 0.1pt mins 0.1pt % no stretch between paragraphs
  17. \parindent 1em % for paragraphs and for the first line of Pascal text
  18.  
  19. \font\eightrm=cmr8
  20. \font\sc=cmcsc10
  21. \let\mainfont=\tenrm
  22. \font\titlefont=cmr7 scaled\magstep4 % title on the contents page
  23. \font\ttitlefont=cmtt10 scaled\magstep2 % typewriter type in title
  24. \font\tentex=cmtex10 % TeX extended character set (used in strings)
  25. \let\idfont\it
  26. \let\reservedfont\bf
  27.  
  28. \def\today{\ifcase\month\or
  29.   January\or February\or March\or April\or May\or June\or
  30.   July\or August\or September\or October\or November\or December\fi
  31.   \space\number\day, \number\year}
  32.  
  33. \def\\#1{\leavevmode\hbox{\idfont#1\/\kern.05em}} % italic type for identifiers
  34. \def\|#1{\leavevmode\hbox{$#1$}} % one-letter identifiers look better this way
  35. \def\{\leavevmode\hbox{\reservedfont#1\/}} % boldface type for reserved words
  36. \def\.#1{\leavevmode\hbox{\tentex % typewriter type for strings
  37.   \let\\=\BS % backslash in a string
  38.   \let\'=\RQ % right quote in a string
  39.   \let\`=\LQ % left quote in a string
  40.   \let\{=\LB % left brace in a string
  41.   \let\}=\RB % right brace in a string
  42.   \let\~=\TL % tilde in a string
  43.   \let\ =\SP % space in a string
  44.   \let\_=\UL % underline in a string
  45.   \let\&=\AM % ampersand in a string
  46.   #1}}
  47. \def\#{\hbox{\tt\char`\#}} % parameter sign
  48. \def\${\hbox{\tt\char`\$}} % dollar sign
  49. \def\%{\hbox{\tt\char`\%}} % percent sign
  50. \def\^{\ifmmode\mathchar"222 \else\char`^ \fi} % pointer or hat
  51. % circumflex accents can be obtained from \^^D instead of \^
  52. \def\AT!{@} % at sign for control text
  53. \def\@{@} % at sign in strings
  54. % EVERY WEAVE MUST DEFINE \? WHERE ? IS THE AT SIGN!!!!
  55.  
  56. % Macros to surround text in |...|
  57. \def\CD{\relax\ifmmode\let\DC\egroup\hbox\bgroup\else\let\DC\relax\fi}
  58. \let\DC=\relax
  59.  
  60. \chardef\AM=`\& % ampersand character in a string
  61. \chardef\BS=`\\ % backslash in a string
  62. \chardef\LB=`\{ % left brace in a string
  63. \def\LQ{{\tt\char'22}} % left quote in a string
  64. \chardef\RB=`\} % right brace in a string
  65. \def\RQ{{\tt\char'23}} % right quote in a string
  66. \def\SP{{\tt\char`\ }} % (visible) space in a string
  67. \chardef\TL=`\~ % tilde in a string
  68. \chardef\UL=`\_ % underline character in a string
  69.  
  70. \newbox\bak \setbox\bak=\hbox to -1em{} % backspace one em
  71. \newbox\bakk\setbox\bakk=\hbox to -2em{} % backspace two ems
  72.  
  73. \newcount\ind % current indentation in ems
  74. \def\0{\ifmmode\ifinner$\par % forced break
  75.   \hangindent\ind em\noindent\kern\ind em\ignorespaces$\fi
  76.   \else\par % forced break
  77.   \hangindent\ind em\noindent\kern\ind em\ignorespaces\fi}
  78. \def\1{\global\advance\ind by1\hangindent\ind em} % indent one more notch
  79. \def\2{\global\advance\ind by-1} % indent one less notch
  80. \def\3#1{\hfil\penalty#10\hfilneg} % optional break within a statement
  81. \def\4{\copy\bak} % backspace one notch
  82. \def\5{\hfil\penalty-1\hfilneg\kern2.5em\copy\bakk\ignorespaces}% optional break
  83. %\def\6{\ifmmode\else\par % forced break with no indentation
  84. %  \hangindent\ind em\noindent\kern\ind em\copy\bakk\ignorespaces\fi}
  85. \def\6{\ifmmode\else\par % forced break with no indentation
  86.   \hangindent\ind em\startline\ignorespaces\fi}
  87. \def\7{\Y\6} % forced break and a little extra space
  88. \def\8{\unskip} % no indentation--works only in code, not in |...|
  89. \def\startline{\noindent
  90.   \count255=\ind\advance\count255by-2
  91.   \hskip\count255 em}
  92.  
  93. \let\yskip=\smallskip
  94. \def\note#1#2.{\Y\noindent{\hangindent2em\baselineskip10pt\eightrm#1 #2.\par}}
  95. \def\lapstar{\rlap{*}}
  96. \def\startsection{\Q\noindent{\let\*=\lapstar\bf\modstar.\quad}}
  97. \def\defin#1{\global\advance\ind by 2 \1\&{#1 }} % begin `define' or `format'
  98. \def\A{\note{See also}} % cross-reference for multiply defined section names
  99. \def\B{\mathopen{\.{@\commentbegin}}} % begin controlled comment
  100. \def\C#1{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi % C comments
  101.   \XX\hfil\penalty-1\hfilneg\quad
  102.     $\commentbegin\,${#1}$\,\commentend$\XX}
  103. \def\D{\defin{define}} % macro definition
  104. \def\F{\defin{format}} % format definition
  105. \def\J{\.{@\&}} % TANGLE's join operation
  106. \outer\def\M#1.{\MN#1.\ifon\vfil\penalty-100\vfilneg % beginning of section
  107.   \vskip12ptminus3pt\startsection\ignorespaces}
  108. \outer\def\N#1.#2.{\MN#1.\headcheck#2\headcheck
  109.   \edef\rhead{\uppercase{\ignorespaces\themodtitle}} % define running headline
  110.   \message{*\modno} % progress report
  111.   \edef\next{\write\cont{\thetocskip
  112.     \Z{\theopen\relax
  113.         \themodtitle}{\modno}{\noexpand\the\pageno}}}\next % to contents file
  114.   \ifon\startsection{\bf\ignorespaces\themodtitle.\quad}\ignorespaces}
  115. \def\MN#1.{\par % common code for \M, \N
  116.   {\xdef\modstar{#1}\let\*=\empty\xdef\modno{#1}}
  117.   \ifx\modno\modstar \onmaybe \else\ontrue \fi \mark{\modno}}
  118. \def\O#1{% octal, hex or decimal constant
  119.   {\def\?{\kern.2em}%
  120.   \def\${\ell}% long constant
  121.   \def\_{\cdot 10^{\aftergroup}}% power of ten
  122.   \def\~{\hbox{\rm\char'23\kern-.2em\it\aftergroup\?\aftergroup}}% octal
  123.   \def\^{\hbox{\rm\char"7D\tt\aftergroup}}% double quotes for hex constant
  124.   #1}}
  125. \def\P{\rightskip=0pt plus 100pt minus 10pt % go into Pascal mode
  126.   \sfcode`;=3000
  127.   \pretolerance 10000
  128.   \hyphenpenalty 10000 \exhyphenpenalty 10000
  129.   \global\ind=2 \1\startline}%\ \unskip}
  130. \def\Q{\rightskip=0pt % get out of Pascal mode
  131.   \sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50 }
  132. \def\T{\mathclose{\.{@\commentend}}} % terminate controlled comment
  133. \def\U{\note{This code is used in}} % cross-reference for uses of sections
  134. \def\X#1:#2\X{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi % section name
  135.   \XX$\langle\,$#2{\eightrm\kern.5em#1}$\,\rangle$\XX}
  136. \def\XF#1:#2\XF{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi % section name
  137.   \XX{\tt(#2{\eightrm\kern.5em#1})}\XX}
  138. \def\Y{\par\yskip}
  139. \def\){\hbox{\.{@\$}}} % sign for string pool check sum
  140. \def\]{\hbox{\.{@\\}}} % sign for forced line break
  141. \def\=#1{\kern2pt\hbox{\vrule\vtop{\vbox{\hrule
  142.         \hbox{\strut\kern2pt\.{#1}\kern2pt}}
  143.       \hrule}\vrule}\kern2pt} % verbatim string
  144. \let\~=\ignorespaces
  145. \let\*=*
  146.  
  147.  
  148. \def\DO{\hbox{\sl\char'044}} % slant dollar sign
  149. \let\G=\ge % greater than or equal sign
  150. \def\H{{\rm\char'136}} % hat
  151. \let\I=\ne % unequal sign
  152. \let\K=\gets % left arrow
  153. \let\L=\le % less than or equal sign
  154. \let\R=\lnot % logical not
  155. \let\S=\equiv % equivalence sign
  156. \let\TI\sim % tilde
  157. \let\V=\lor % logical or
  158. \let\W=\land % logical and
  159. \let\Z=\let % now you can \send the control sequence \Z
  160.  
  161.  
  162. \def\onmaybe{\let\ifon=\maybe} \let\maybe=\iftrue
  163. \newif\ifon \newif\iftitle \newif\ifpagesaved
  164. \def\lheader{\mainfont\the\pageno\eightrm\qquad\rhead\hfill\title\qquad
  165.   \tensy x\mainfont\topmark} % top line on left-hand pages
  166. \def\rheader{\tensy x\mainfont\topmark\eightrm\qquad\title\hfill\rhead
  167.   \qquad\mainfont\the\pageno} % top line on right-hand pages
  168. \def\lfooter{\hfil} % bottom line on left-hand-pages
  169. \def\rfooter{\hfil} % bottom line on left-hand-pages
  170. \def\page{\box255 }
  171. \def\normaloutput#1#2#3#4#5{%
  172. %\message{(At start top, first, and bottom marks: \topmark, \firstmark, \botmark)}%
  173. \shipout\vbox{
  174.   \iftwoside\else\ifodd\pageno\hoffset=\pageshift\fi\fi
  175.   \vbox to\fullpageheight{
  176.      \iftitle
  177.      \else\hbox to\pagewidth{\vbox to10pt{}%
  178.        \ifodd\pageno#3\else
  179.         \iftwoside#2\else#3\fi
  180.     \fi}%
  181.      \fi
  182.      \vfill#1% parameter #1 is the page itself
  183.      \iftitle\global\titlefalse
  184.      \else\baselineskip=24pt\hbox to\pagewidth{\strut % see TeXbook p256
  185.     \ifodd\pageno#5\else
  186.         \iftwoside#4\else#5\fi
  187.     \fi}%
  188.      \fi
  189.   }%
  190. }%
  191. \global\advance\pageno by1
  192. %\message{(At end top, first, and bottom marks: \topmark, \firstmark, \botmark)}%
  193. }
  194.  
  195.  
  196. \def\rhead{\.{WEB} OUTPUT} % this running head is reset by starred sections
  197. \def\title{} % an optional title can be set by the user
  198. \def\topofcontents{\centerline{\titlefont\title}
  199.   \vfill} % this material will start the table of contents page
  200. \def\botofcontents{\vfill} % this material will end the table of contents page
  201. \def\contentspagenumber{0} % default page number for table of contents
  202. \newdimen\pagewidth \pagewidth=6.5in % the width of each page
  203. \newdimen\pageheight \pageheight=8.4in % the height of each page
  204. \newdimen\fullpageheight \fullpageheight=9in % page height including
  205.                          % headlines and footlines
  206. \newdimen\pageshift \pageshift=0in % shift righthand pages wrt lefthand ones
  207. \catcode`\@=11 % make at letter
  208. \def\m@g{\mag=\count@\pagewidth=6.5truein\pageheight=8.4truein
  209.   \fullpageheight=9truein\setpage}
  210. \catcode`\@=12 % make at other
  211. \def\setpage{\hsize\pagewidth\vsize\pageheight} % use after changing page size
  212.  
  213. \edef\contentsfile{\jobname.toc } % file that gets table of contents info
  214. \def\readcontents{\expandafter\input \contentsfile}
  215.  
  216. \newwrite\cont
  217. \output{\setbox0=\page % the first page is garbage
  218.   \openout\cont=\contentsfile
  219.   \write\cont{\string\catcode`\string\@=11}% a hack to make contents
  220.                          % take stuff in \.{---}
  221.   \global\output{\normaloutput\page\lheader\rheader\lfooter\rfooter}}
  222. \setpage
  223. \vbox to \vsize{} % the first \topmark won't be null
  224. % Delete as per bug report from kademan@stat.wisc.edu
  225. % Causes headings on first page to be missing
  226. % \eject
  227.  
  228. \def\ch{\note{The following sections were changed by the change file:}
  229.   \let\*=\relax}
  230. \newbox\sbox % saved box preceding the index
  231. \newbox\lbox % lefthand column in the index
  232. \def\inx{\par\vskip6pt plus 1fil % we are beginning the index
  233.   \write\cont{} % ensure that the contents file isn't empty
  234.   \closeout\cont % the contents information has been fully gathered
  235.   \output{\ifpagesaved\normaloutput{\box\sbox}\lheader\rheader
  236.         \lfooter\rfooter\fi
  237.     \global\setbox\sbox=\page \global\pagesavedtrue}
  238.   \pagesavedfalse \eject % eject the page-so-far and predecessors
  239.   \setbox\sbox\vbox{\unvbox\sbox} % take it out of its box
  240.   \vsize=\pageheight \advance\vsize by -\ht\sbox % the remaining height
  241.   \hsize=.5\pagewidth \advance\hsize by -10pt
  242.     % column width for the index (20pt between cols)
  243.   \parfillskip 0pt plus .6\hsize % try to avoid almost empty lines
  244.   \def\lr{L} % this tells whether the left or right column is next
  245.   \output{\if L\lr\global\setbox\lbox=\page \gdef\lr{R}
  246.     \else\normaloutput{\vbox to\pageheight{\box\sbox\vss
  247.         \hbox to\pagewidth{\box\lbox\hfil\page}}}\lheader\rheader
  248.     \lfooter\rfooter
  249.     \global\vsize\pageheight\gdef\lr{L}\global\pagesavedfalse\fi}
  250.   \message{Index:}
  251.   \parskip 0pt plus .5pt
  252.   \outer\def\:##1, {\par\hangindent2em\noindent##1:\kern1em} % index entry
  253.   \def\[##1]{$\underline{##1}$} % underlined index item
  254.   \rm \rightskip0pt plus 2.5em \tolerance 10000 \let\*=\lapstar
  255.   \hyphenpenalty 10000 \parindent0pt}
  256. \def\fin{\par\vfill\eject % this is done when we are ending the index
  257.   \ifpagesaved\null\vfill\eject\fi % output a null index column
  258.   \if L\lr\else\null\vfill\eject\fi % finish the current page
  259.   \parfillskip 0pt plus 1fil
  260.   \def\rhead{NAMES OF THE SECTIONS}
  261.   \message{Section names:}
  262.   \output{\normaloutput\page\lheader\rheader\lfooter\rfooter}
  263.   \setpage
  264.   \def\note##1##2.{\quad{\eightrm##1 ##2.}}
  265.   \def\U{\note{Used in}} % cross-reference for uses of sections
  266.   \def\:{\par\hangindent 2em}\let\*=*}
  267. \def\con{\par\vfill\eject % finish the section names
  268.   \rightskip 0pt \hyphenpenalty 50 \tolerance 200
  269.   \setpage
  270.   \output{\normaloutput\page\lheader\rheader\lfooter\rfooter}
  271.   \titletrue % prepare to output the table of contents
  272.   \pageno=\contentspagenumber \def\rhead{TABLE OF CONTENTS}
  273.   \message{Table of contents:}
  274.   \topofcontents
  275.   \line{\hfil Section\hbox to3em{\hss Page}}
  276.   \def\Z##1##2##3{\line{{\ignorespaces##1}
  277.     \leaders\hbox to .5em{.\hfil}\hfil\ ##2\hbox to3em{\hss##3}}}
  278.   \readcontents\relax % read the contents info
  279.   \botofcontents \end} % print the contents page(s) and terminate
  280. %\tracingstats1 % temporary (during development)
  281.  
  282.  
  283. \def\vert{|}
  284.         
  285. %%% this stuff is to allow inital =,1,2,3,4 in starred modules
  286. %%%     = means ``part'', don't skip page
  287. %%%    normal starred module is 0
  288. %%%        1,2,3,4 are submodules, and are indented
  289. %%%
  290. %%%    @*=    bold name in table of contents
  291. %%%        causes page eject
  292. %%%        suppresses page eject following
  293. %%%
  294. %%%    @*1,2    first level of indentation
  295. %%%    @*3,4    second level of indentation
  296. %%%
  297. %%%     @*1,3    cause page eject
  298. %%%     @*2,4    don't cause page eject
  299. %%%
  300.  
  301.  
  302. \newif\ifcancel\cancelfalse
  303. \catcode`\@=11
  304. \def\ifnextchar#1#2#3{\let\@tempe=#1\def\@tempa{#2}\def\@tempb{#3}\@ifnch}
  305. \def\@ifnch{\ifx \@tempc \@tempe\let\@tempd\@tempa\else\let\@tempd\@tempb\fi
  306.       \@tempd}
  307. \def\makethechar#1{\let\@tempc=#1}
  308. \catcode`\@=12
  309.  
  310. \def\headcheck#1#2\headcheck{%
  311.     \makethechar{#1}%
  312.     \def\theskipper{\vfil\penalty-100\vfilneg\vskip12ptminus3pt}%
  313.                 % skip before new module
  314.     \def\theopen{}% opening skip in toc entry
  315.     \def\thetocskip{}% vertical skip before toc entry
  316.     \def\themodtitle{{#2}}
  317.     \ifnextchar={%
  318.         \def\theskipper{\vfil\eject}%
  319.         \canceltrue
  320.         \def\theopen{\bf}%
  321.         \def\thetocskip{\vskip3ptplus1in\penalty-100
  322.             \vskip0ptplus-1in}%
  323.     }{\ifnextchar1{%
  324.         \cancelfalse
  325.         \def\theskipper{\vfil\eject}%
  326.         \def\theopen{\hskip2em}%
  327.     }{\ifnextchar2{%
  328.         \cancelfalse
  329.         \def\theopen{\hskip2em}%
  330.     }{\ifnextchar3{%
  331.         \cancelfalse
  332.         \def\theskipper{\vfil\eject}%
  333.         \def\theopen{\hskip4em}%
  334.     }{\ifnextchar4{%
  335.         \cancelfalse
  336.         \def\theopen{\hskip4em}%
  337.     }{% else 
  338.         \ifcancel\else
  339.             \def\theskipper{\vfil\eject}%
  340.         \fi
  341.         \cancelfalse
  342.         \def\themodtitle{#1{#2}}%
  343.     }}}}}%
  344.     \theskipper
  345. }
  346.  
  347.  
  348. %%%%%%%% for verbatim quoting of code
  349. % The following are copied from manmanc.tex and are taken from p421 of
  350. % the TeXbook  ... modified to \verbatim...\endverbatim
  351. % macros for verbatim scanning
  352. \chardef\other=12
  353. \def\ttverbatim{\begingroup
  354.   \catcode`\|=\other
  355.   \catcode`\\=\other
  356.   \catcode`\{=\other
  357.   \catcode`\}=\other
  358.   \catcode`\$=\other
  359.   \catcode`\&=\other
  360.   \catcode`\#=\other
  361.   \catcode`\%=\other
  362.   \catcode`\~=\other
  363.   \catcode`\_=\other
  364.   \catcode`\^=\other
  365.   \obeyspaces \obeylines \tt}
  366. {\obeyspaces\global\let =\ } % from texbook, p 381
  367.  
  368.  
  369. %\outer\def\verbatim{$$\let\par=\endgraf \ttverbatim \parskip=0pt
  370. %  \catcode`\|=0 \rightskip-5pc \ttfinish}
  371. %{\catcode`\|=0 |catcode`|\=\other % | is temporary escape character
  372. %  |obeylines % end of line is active
  373. %  |gdef|ttfinish#1^^M#2\endverbatim{#1|vbox{#2}|endgroup$$}}
  374.  
  375. \outer\def\verbatimcode{\par\ttverbatim\leftskip=2em\parskip=0pt
  376.   \ttfinishcode}
  377. {\catcode`\|=0 |catcode`|\=\other % | is temporary escape character
  378.   |obeylines % end of line is active
  379.   |gdef|ttfinishcode#1^^M#2\endverbatimcode{#1|vbox{#2}|endgroup}}
  380.  
  381.  
  382. % end of manmac stuff
  383.  
  384.