fix getsup (HH)
[luatex.git] / source / texk / web2c / cwebdir / cwebmac.tex
blobc1880cd3c92434c9a42ede9a1d9e4dea4a059c02
1 % standard macros for CWEB listings (in addition to plain.tex)
2 % Version 3.69 --- February 2016
3 \ifx\renewenvironment\undefined\else\endinput\fi % LaTeX will use other macros
4 \xdef\fmtversion{\fmtversion+CWEB3.69}
5 \chardef\cwebversion=3 \chardef\cwebrevision=69
6 \newif\ifpdf
7 \ifx\pdf+\pdftrue\fi
8 % Uncomment the following line if you want PDF goodies to be the default
9 %\ifx\pdf-\else\pdftrue\fi
10 \def\pdflinkcolor{0 0 1} % the RGB values for hyperlink color
11 \newif\ifpdftex
12 \ifx\pdfoutput\undefined \pdftexfalse \else\ifnum\pdfoutput=0 \pdftexfalse
13 %\else \pdftextrue \pdfoutput=1 \input pdfcolor \let\setcolor\pdfsetcolor \fi\fi
14 \else \pdftextrue \pdfoutput=1 % changed in 3.69
15 \def\Black{\pdfliteral{0 g 0 G}} % use rgb colors for direct PDF output too
16 \def\Blue{\pdfliteral{0 0 1 rg 0 0 1 RG}}
17 \fi\fi
18 \newif\ifacro \ifpdf\acrotrue\fi \ifpdftex\acrotrue\fi
20 \let\:=\. % preserve a way to get the dot accent
21 % (all other accents will still work as usual)
23 \parskip 0pt % no stretch between paragraphs
24 \parindent 1em % for paragraphs and for the first line of C text
26 \font\ninerm=cmr9
27 \let\mc=\ninerm % medium caps
28 \def\CEE/{{\mc C\spacefactor1000}}
29 \def\UNIX/{{\mc U\kern-.05emNIX\spacefactor1000}}
30 \def\TEX/{\TeX}
31 \def\CPLUSPLUS/{{\mc C\PP\spacefactor1000}}
32 \def\Cee{\CEE/} % for backward compatibility
33 \def\9#1{}
34 % with this definition of \9 you can say @:sort key}{TeX code@>
35 % to alphabetize an index entry by the sort key but format with the TeX code
36 \font\eightrm=cmr8
37 \let\sc=\eightrm % for smallish caps (NOT a caps-and-small-caps font)
38 \let\mainfont=\tenrm
39 \let\cmntfont\tenrm
40 %\font\tenss=cmss10 \let\cmntfont\tenss % alternative comment font
41 \font\titlefont=cmr7 scaled\magstep4 % title on the contents page
42 \font\ttitlefont=cmtt10 scaled\magstep2 % typewriter type in title
43 \font\tentex=cmtex10 % TeX extended character set (used in strings)
44 \fontdimen7\tentex=0pt % no double space after sentences
46 \def\\#1{\leavevmode\hbox{\it#1\/\kern.05em}} % italic type for identifiers
47 \def\|#1{\leavevmode\hbox{$#1$}} % one-letter identifiers look better this way
48 \def\&#1{\leavevmode\hbox{\bf
49 \def\_{\kern.04em\vbox{\hrule width.3em height .6pt}\kern.08em}%
50 #1\/\kern.05em}} % boldface type for reserved words
51 \def\.#1{\leavevmode\hbox{\tentex % typewriter type for strings
52 \let\\=\BS % backslash in a string
53 \let\{=\LB % left brace in a string
54 \let\}=\RB % right brace in a string
55 \let\~=\TL % tilde in a string
56 \let\ =\SP % space in a string
57 \let\_=\UL % underline in a string
58 \let\&=\AM % ampersand in a string
59 \let\^=\CF % circumflex in a string
60 #1\kern.05em}}
61 \def\){{\tentex\kern-.05em}\discretionary{\hbox{\tentex\BS}}{}{}}
62 \def\AT{@} % at sign for control text (not needed in versions >= 2.9)
63 \def\ATL{\par\noindent\bgroup\catcode`\_=12 \postATL} % print @l in limbo
64 \def\postATL#1 #2 {\bf letter \\{\uppercase{\char"#1}}
65 tangles as \tentex "#2"\egroup\par}
66 \def\noATL#1 #2 {}
67 \def\noatl{\let\ATL=\noATL} % suppress output from @l
68 \def\ATH{{\acrofalse\X\kern-.5em:Preprocessor definitions\X}}
69 \let\PB=\relax % hook for program brackets |...| in TeX part or section name
71 \chardef\AM=`\& % ampersand character in a string
72 \chardef\BS=`\\ % backslash in a string
73 \chardef\LB=`\{ % left brace in a string
74 \chardef\RB=`\} % right brace in a string
75 \def\SP{{\tt\char`\ }} % (visible) space in a string
76 \chardef\TL=`\~ % tilde in a string
77 \chardef\UL=`\_ % underline character in a string
78 \chardef\CF=`\^ % circumflex character in a string
80 \newbox\PPbox % symbol for ++
81 \setbox\PPbox=\hbox{\kern.5pt\raise1pt\hbox{\sevenrm+\kern-1pt+}\kern.5pt}
82 \def\PP{\copy\PPbox}
83 \newbox\MMbox \setbox\MMbox=\hbox{\kern.5pt\raise1pt\hbox{\sevensy\char0
84 \kern-1pt\char0}\kern.5pt}
85 \def\MM{\copy\MMbox}
86 \newbox\MGbox % symbol for ->
87 \setbox\MGbox=\hbox{\kern-2pt\lower3pt\hbox{\teni\char'176}\kern1pt}
88 \def\MG{\copy\MGbox}
89 \def\MRL#1{\mathrel{\let\K==#1}}
90 %\def\MRL#1{\KK#1}\def\KK#1#2{\buildrel\;#1\over{#2}}
91 \let\GG=\gg
92 \let\LL=\ll
93 \let\NULL=\Lambda
94 \mathchardef\AND="2026 % bitwise and; also \& (unary operator)
95 \let\OR=\mid % bitwise or
96 \let\XOR=\oplus % bitwise exclusive or
97 \def\CM{{\sim}} % bitwise complement
98 \newbox\MODbox \setbox\MODbox=\hbox{\eightrm\%}
99 \def\MOD{\mathbin{\copy\MODbox}}
100 \def\DC{\kern.1em{::}\kern.1em} % symbol for ::
101 \def\PA{\mathbin{.*}} % symbol for .*
102 \def\MGA{\mathbin{\MG*}} % symbol for ->*
103 \def\this{\&{this}}
105 \newbox\bak \setbox\bak=\hbox to -1em{} % backspace one em
106 \newbox\bakk\setbox\bakk=\hbox to -2em{} % backspace two ems
108 \newcount\ind % current indentation in ems
109 \def\1{\global\advance\ind by1\hangindent\ind em} % indent one more notch
110 \def\2{\global\advance\ind by-1} % indent one less notch
111 \def\3#1{\hfil\penalty#10\hfilneg} % optional break within a statement
112 \def\4{\copy\bak} % backspace one notch
113 \def\5{\hfil\penalty-1\hfilneg\kern2.5em\copy\bakk\ignorespaces}% optional break
114 \def\6{\ifmmode\else\par % forced break
115 \hangindent\ind em\noindent\kern\ind em\copy\bakk\ignorespaces\fi}
116 \def\7{\Y\6} % forced break and a little extra space
117 \def\8{\hskip-\ind em\hskip 2em} % no indentation
119 \newcount\gdepth % depth of current major group, plus one
120 \newcount\secpagedepth
121 \secpagedepth=3 % page breaks will occur for depths -1, 0, and 1
122 \newtoks\gtitle % title of current major group
123 \newskip\intersecskip \intersecskip=12pt minus 3pt % space between sections
124 \let\yskip=\smallskip
125 \def\?{\mathrel?}
126 \def\note#1#2.{\Y\noindent{\hangindent2em%
127 \baselineskip10pt\eightrm#1~\ifacro{\pdfnote#2.}\else#2\fi.\par}}
129 \newtoks\toksA \newtoks\toksB \newtoks\toksC \newtoks\toksD
130 \newtoks\toksE \newtoks\toksF \newtoks\usersanitizer
131 \newcount\countA \countA=0 \newcount\countB \countB=0
132 \newcount\countC \countC=0
133 \newif\iftokprocessed \newif\ifTnum \newif\ifinstr
134 {\def\\{\global\let\spacechar= }\\ }
136 \ifacro % The following are pdf macros
137 \def\thewidth{\the\wd0 \space}
138 \def\theheight{\the\ht\strutbox\space}
139 \def\thedepth{\the\dp\strutbox\space}
140 \ifpdftex
141 \ifx\pdfannotlink\undefined\let\pdfannotlink\pdfstartlink\fi% for pdfTeX 0.14
142 \def\pdflink#1#2{\hbox{\pdfannotlink height\ht\strutbox depth\dp\strutbox
143 attr{/Border [0 0 0]} goto num #1 \Blue #1\Black\pdfendlink}} % changed 3.69
144 \else\def\pdflink#1#2{\setbox0=\hbox{\special{pdf: bc [ \pdflinkcolor ]}{#1}%
145 \special{pdf: ec}}\special{pdf: ann width \thewidth height \theheight
146 depth \thedepth << /Type /Annot /Subtype /Link
147 /Border [0 0 0] /A << /S /GoTo /D (#2) >> >>}\box0\relax}\fi
148 \def\pdfnote#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}\maketoks}\the\toksA}
149 \def\firstsecno#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}%
150 \def\makenote{\addtokens\toksB{\the\toksC}\def\makenote{\toksD={}
151 \toksC={}\let\space\empty}\makenote}\maketoks}}
152 \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
153 \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}%
154 \ifcat\noexpand\first0\countB=`#1\else\countB=0\fi\toksA={#2}}
155 \def\maketoks{\expandafter\poptoks\the\toksA|ENDTOKS|%
156 \ifnum\countB>`9 \countB=0 \fi
157 \ifnum\countB<`0
158 \ifnum0=\countC\else\makenote\fi
159 \ifx\first.\let\next=\maketoksdone\else
160 \let\next=\maketoks
161 \addtokens\toksB{\the\toksD}
162 \ifx\first,\addtokens\toksB{\space}\fi
164 \else \addtokens\toksC{\the\toksD}\global\countC=1\let\next=\maketoks
166 \next
168 \def\makenote{\addtokens\toksB
169 {\noexpand\pdflink{\the\toksC}{\romannumeral\the\toksC}}\toksC={}\global\countC=0}
170 \def\maketoksdone{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
171 \def\pdfURL#1#2{\ifpdftex\pdfannotlink height\ht\strutbox depth\dp\strutbox
172 attr {/Border [0 0 0]} user { /Type /Action /Subtype /Link /A
173 << /S /URI /URI (#2) >>}\Blue #1\Black \pdfendlink % changed in 3.69
174 \else \ifpdf{\setbox0=\hbox{\special{pdf: bc [ \pdflinkcolor ]}{#1}%
175 \special{pdf: ec}}\special{pdf: ann width \thewidth\space height \theheight
176 \space depth \thedepth\space << /Border [0 0 0]
177 /Type /Action /Subtype /Link /A << /S /URI /URI (#2) >> >>}\box0\relax}%
178 \else #1 ({\tt#2})\fi\fi}
179 {\catcode`\~=12 \gdef\TILDE/{~}} % ~ in a URL
180 {\catcode`\_=12 \gdef\UNDER/{_}} % _ in a URL
181 \def\sanitizecommand#1#2{\addtokens\usersanitizer
182 {\noexpand\dosanitizecommand\noexpand#1{#2}}}
183 \def\dosanitizecommand#1#2{\ifx\nxt#1\addF{#2}\fi}
185 \catcode`\[=1 \catcode`\]=2 \catcode`\{=12 \catcode`\}=12
186 \def\lbchar[{] \def\rbchar[}]
187 \catcode`\[=12 \catcode`\]=12 \catcode`\{=1 \catcode`\}=2
188 \catcode`\~=12 \def\tildechar{~} \catcode`\~=13
189 \catcode`\|=0 |catcode`|\=12 |def|bschar{\} |catcode`|\=0 \catcode`\|=12
190 \def\makeoutlinetoks{\Tnumfalse\afterassignment\makeolproctok\let\nxt= }
191 \def\makeolnexttok{\afterassignment\makeolproctok\let\nxt= }
192 \def\makeolgobbletok{\afterassignment\makeolnexttok\let\nxt= }
193 \def\addF#1{\addtokens\toksF{#1}\tokprocessedtrue}
194 % now comes a routine to "sanitize" section names, for pdf outlines
195 \def\makeolproctok{\tokprocessedfalse
196 \let\next\makeolnexttok % default
197 \ifx\nxt\outlinedone\let\next\outlinedone
198 \else\ifx{\nxt \else\ifx}\nxt \Tnumfalse \instrfalse % skip braces
199 \else\ifx$\nxt % or a $ sign
200 \else\ifx^\nxt \addF^\else\ifx_\nxt \addF_% sanitize ^ and _
201 \else\ifx\nxt\spacechar \addF\space
202 \else\if\noexpand\nxt\relax % we have a control sequence; is it one we know?
203 \ifx\nxt~\addF\space
204 \else\ifx\nxt\onespace\addF\space
205 \else\the\usersanitizer
206 \iftokprocessed\else\makeolproctokctli
207 \iftokprocessed\else\makeolproctokctlii
208 \iftokprocessed\else\makeolproctokctliii % if not recognised, skip it
209 \fi\fi\fi\fi\fi
210 \else % we don't have a control sequence, it's an ordinary char
211 \ifx/\nxt \addF{\string\/}% quote chars special to PDF with backslash
212 \else\ifx(\nxt \addF{\string\(}\else\ifx)\nxt \addF{\string\)}%
213 \else\ifx[\nxt \addF{\string\[}\else\ifx]\nxt \addF{\string\]}%
214 \else\expandafter\makeolproctokchar\meaning\nxt
215 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
216 \next
218 \def\makeolproctokchar#1 #2 #3{\addF{#3}}
219 \def\makeolproctokctli{%
220 \ifx\nxt\CEE\addF{C}\let\next\makeolgobbletok % \CEE/
221 \else\ifx\nxt\UNIX\addF{UNIX}\let\next\makeolgobbletok % \UNIX/
222 \else\ifx\nxt\TEX\addF{TeX}\let\next\makeolgobbletok % \TEX/
223 \else\ifx\nxt\TeX\addF{TeX}\else\ifx\nxt\LaTeX\addF{LaTeX}%
224 \else\ifx\nxt\CPLUSPLUS\addF{C++}\let\next\makeolgobbletok % \CPLUSPLUS/
225 \else\ifx\nxt\Cee\addF{C}%
226 \else\ifx\nxt\PB \let\next\makeolgobbletok \tokprocessedtrue % \PB{...}
227 \else\ifx\nxt\.\tokprocessedtrue\instrtrue % \.{...}
228 % skip \|
229 \else\ifx\nxt\\\ifinstr\addF{\bschar\bschar}\else\tokprocessedtrue\fi
230 \else\ifx\nxt\&\ifinstr\addF&\else\tokprocessedtrue\fi
231 \else\ifx\nxt\~\ifTnum\addF{0}\else\addF\tildechar\fi % 077->\T{\~77}
232 \else\ifx\nxt\_\ifTnum\addF{E}\else\addF_\fi % 0.1E5->\T{0.1\_5}
233 \else\ifx\nxt\^\ifTnum\addF{0x}\else\addF^\fi % 0x77 -> \T{\^77}
234 \else\ifx\nxt\$\ifTnum\tokprocessedtrue\else\addF$\fi % \T{77\$L}
235 \else\ifx\nxt\{\addF\lbchar \else\ifx\nxt\}\addF\rbchar
236 \else\ifx\nxt\ \addF\space \else\ifx\nxt\#\addF{\string\#}%
237 \else\ifx\nxt\PP\addF{++}\else\ifx\nxt\MM\addF{--}%
238 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
240 \def\makeolproctokctlii{%
241 \ifx\nxt\MG\addF{->}\else\ifx\nxt\GG\addF{>>}%
242 \else\ifx\nxt\LL\addF{<<}\else\ifx\nxt\NULL\addF{NULL}%
243 \else\ifx\nxt\AND\addF&\else\ifx\nxt\OR\addF|%
244 \else\ifx\nxt\XOR\addF^\else\ifx\nxt\CM\addF\tildechar
245 \else\ifx\nxt\MOD\addF{\string\%}\else\ifx\nxt\DC\addF{::}%
246 \else\ifx\nxt\PA\addF{.*}\else\ifx\nxt\MGA\addF{->*}%
247 \else\ifx\nxt\this\addF{this}\else\ifx\nxt\?\addF?%
248 \else\ifx\nxt\E\addF{==}\else\ifx\nxt\G\addF{>=}%
249 \else\ifx\nxt\I\addF{!=}\else\ifx\nxt\K\addF{=}%
250 \else\ifx\nxt\l\addF{l}\else\ifx\nxt\L\addF{L}%
251 \else\ifx\nxt\o\addF{o}\else\ifx\nxt\O\addF{O}%
252 \else\ifx\nxt\R\addF!%
253 \else\ifx\nxt\T \Tnumtrue \let\next\makeolgobbletok
254 \tokprocessedtrue % \T{number}
255 \else\ifx\nxt\AM\addF&\else\ifx\nxt\%\addF{\string\%}%
256 \fi\fi\fi\fi\fi \fi\fi\fi\fi\fi
257 \fi\fi\fi\fi\fi \fi\fi\fi\fi\fi
258 \fi\fi\fi\fi\fi\fi
260 \def\makeolproctokctliii{%
261 \ifx\nxt\V\addF{||}\else\ifx\nxt\W\addF{&&}\else\ifx\nxt\Z\addF{<=}%
262 \else\ifx\nxt\*\addF*\else\ifx\nxt\Xand\addF{\space and\space}%
263 \else\ifx\nxt\Xandxeq\addF{\space and_eq\space}%
264 \else\ifx\nxt\Xbitand\addF{\space bitand\space}%
265 \else\ifx\nxt\Xbitor\addF{\space bitor\space}%
266 \else\ifx\nxt\Xcompl\addF{\space compl\space}%
267 \else\ifx\nxt\Xnot\addF{\space not\space}%
268 \else\ifx\nxt\Xnotxeq\addF{\space not_eq\space}%
269 \else\ifx\nxt\Xor\addF{\space or\space}%
270 \else\ifx\nxt\Xorxeq\addF{\space or_eq\space}%
271 \else\ifx\nxt\Xxor\addF{\space xor\space}%
272 \else\ifx\nxt\Xxorxeq\addF{\space xor_eq\space}%
273 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
274 \fi\fi\fi\fi\fi
276 \def\outlinedone{\edef\outlinest{\global\noexpand\toksE={\the\toksF}}%
277 \outlinest\let\outlinedone=\relax}
278 \fi % End of pdf macros
280 \def\lapstar{\rlap{*}}
281 \def\stsec{\rightskip=0pt % get out of C mode (cf. \B)
282 \sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50
283 \noindent{\let\*=\lapstar\bf\secstar.\quad}%
284 \ifpdftex\smash{\raise\baselineskip\hbox to0pt{%
285 % \let\*=\empty\pdfdest num \secstar fith}} % bad space in versions < 3.68
286 \let\*=\empty\pdfdest num \secstar fith}}% changed in version 3.68
287 \else\ifpdf\smash{\raise\baselineskip\hbox to0pt{%
288 \let\*=\empty\special{%
289 pdf: dest (\romannumeral\secstar) [ @thispage /FitH @ypos ]}}}\fi\fi}
290 \let\startsection=\stsec
291 \def\defin#1{\global\advance\ind by 2 \1\&{#1 } } % begin `define' or `format'
292 \def\A{\note{See also section}} % xref for doubly defined section name
293 \def\As{\note{See also sections}} % xref for multiply defined section name
294 \def\B{\rightskip=0pt plus 100pt minus 10pt % go into C mode
295 \sfcode`;=3000
296 \pretolerance 10000
297 \hyphenpenalty 1000 % so strings can be broken (discretionary \ is inserted)
298 \exhyphenpenalty 10000
299 \global\ind=2 \1\ \unskip}
300 \def\C#1{\5\5\quad$/\ast\,${\cmntfont #1}$\,\ast/$}
301 \let\SHC\C % "// short comments" treated like "/* ordinary comments */"
302 %\def\C#1{\5\5\quad$\triangleright\,${\cmntfont#1}$\,\triangleleft$}
303 %\def\SHC#1{\5\5\quad$\diamond\,${\cmntfont#1}}
304 \def\D{\defin{\#define}} % macro definition
305 \let\E=\equiv % equivalence sign
306 \def\ET{ and~} % conjunction between two section numbers
307 \def\ETs{, and~} % conjunction between the last two of several section numbers
308 \def\F{\defin{format}} % format definition
309 \let\G=\ge % greater than or equal sign
310 % \H is long Hungarian umlaut accent
311 \let\I=\ne % unequal sign
312 \def\J{\.{@\&}} % TANGLE's join operation
313 \let\K== % assignment operator
314 %\let\K=\leftarrow % "honest" alternative to standard assignment operator
315 % \L is Polish letter suppressed-L
316 \outer\def\M#1{\MN{#1}\ifon\vfil\penalty-100\vfilneg % beginning of section
317 \vskip\intersecskip\startsection\ignorespaces}
318 \outer\def\N#1#2#3.{% beginning of starred section
319 \ifacro{\toksF={}\makeoutlinetoks#3\outlinedone\outlinedone}\fi
320 \gdepth=#1\gtitle={#3}\MN{#2}%
321 \ifon\ifnum#1<\secpagedepth \vfil\eject % force page break if depth is small
322 \else\vfil\penalty-100\vfilneg\vskip\intersecskip\fi\fi
323 \message{*\secno} % progress report
324 \def\stripprefix##1>{}\def\gtitletoks{#3}%
325 \edef\gtitletoks{\expandafter\stripprefix\meaning\gtitletoks}%
326 \edef\next{\write\cont{\ZZ{\gtitletoks}{#1}{\secno}% write to contents file
327 {\noexpand\the\pageno}{\the\toksE}}}\next % \ZZ{title}{depth}{sec}{page}{ss}
328 \ifpdftex\expandafter\xdef\csname curr#1\endcsname{\secno}
329 \ifnum#1>0\countB=#1 \advance\countB by-1
330 \advancenumber{chunk\the\countB.\expnumber{curr\the\countB}}\fi\fi
331 \ifpdf\special{pdf: outline #1 << /Title (\the\toksE) /Dest
332 [ @thispage /FitH @ypos ] >>}\fi
333 \ifon\startsection{\bf#3.\quad}\ignorespaces}
334 \def\MN#1{\par % common code for \M, \N
335 {\xdef\secstar{#1}\let\*=\empty\xdef\secno{#1}}% remove \* from section name
336 \ifx\secno\secstar \onmaybe \else\ontrue \fi
337 \mark{{{\tensy x}\secno}{\the\gdepth}{\the\gtitle}}}
338 % each \mark is {section reference or null}{depth plus 1}{group title}
339 % \O is Scandinavian letter O-with-slash
340 % \P is paragraph sign
341 \def\Q{\note{This code is cited in section}} % xref for mention of a section
342 \def\Qs{\note{This code is cited in sections}} % xref for mentions of a section
343 \let\R=\lnot % logical not
344 % \S is section sign
345 \def\T#1{\leavevmode % octal, hex or decimal constant
346 \hbox{$\def\?{\kern.2em}%
347 % \def\$##1{\egroup_{\,\rm##1}\bgroup}% suffix to constant % versions < 3.67
348 \def\$##1{\egroup_{\rm##1}\bgroup}% suffix to constant % in version 3.67
349 \def\_{\cdot 10^{\aftergroup}}% power of ten (via dirty trick)
350 \let\~=\oct \let\^=\hex {#1}$}}
351 \def\U{\note{This code is used in section}} % xref for use of a section
352 \def\Us{\note{This code is used in sections}} % xref for uses of a section
353 \let\V=\lor % logical or
354 \let\W=\land % logical and
355 \def\X#1:#2\X{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi %$% section name
356 \XX$\langle\,${\let\I=\ne#2\eightrm\kern.5em
357 \ifacro{\pdfnote#1.}\else#1\fi}$\,\rangle$\XX}
358 \def\Y{\par\yskip}
359 \let\Z=\le
360 \let\ZZ=\let % now you can \write the control sequence \ZZ
361 \let\*=*
363 \def\Xand{\W} \def\Xandxeq{\MRL{{\AND}{\K}}} \def\Xbitand{\AND}
364 \def\Xbitor{\OR} \def\Xcompl{\CM} \def\Xnot{\R} \def\Xnotxeq{\I} \def\Xor{\V}
365 \def\Xorxeq{\MRL{{\OR}{\K}}} \def\Xxor{\XOR} \def\Xxorxeq{\MRL{{\XOR}{\K}}}
367 %\def\oct{\hbox{\rm\char'23\kern-.2em\it\aftergroup\?\aftergroup}} % WEB style
368 %\def\hex{\hbox{\rm\char"7D\tt\aftergroup}} % WEB style
369 \def\oct{\hbox{$^\circ$\kern-.1em\it\aftergroup\?\aftergroup}}% CWEB style
370 \def\hex{\hbox{$^{\scriptscriptstyle\#}$\tt\aftergroup}} % CWEB style
371 \def\vb#1{\leavevmode\hbox{\kern2pt\vrule\vtop{\vbox{\hrule
372 \hbox{\strut\kern2pt\.{#1}\kern2pt}}
373 \hrule}\vrule\kern2pt}} % verbatim string
375 \def\onmaybe{\let\ifon=\maybe} \let\maybe=\iftrue
376 \newif\ifon \newif\iftitle \newif\ifpagesaved
378 \newif\ifheader
379 \def\lheader{\headertrue\mainfont\the\pageno\eightrm\qquad\grouptitle
380 \hfill\title\qquad\mainfont\topsecno} % top line on left-hand pages
381 \def\rheader{\headertrue\mainfont\topsecno\eightrm\qquad\title\hfill
382 \grouptitle\qquad\mainfont\the\pageno} % top line on right-hand pages
383 \def\grouptitle{\let\i=I\let\j=J\uppercase\expandafter{\expandafter
384 \takethree\topmark}}
385 \def\topsecno{\expandafter\takeone\topmark}
386 \def\takeone#1#2#3{#1}
387 \def\taketwo#1#2#3{#2}
388 \def\takethree#1#2#3{#3}
389 \def\nullsec{\eightrm\kern-2em} % the \kern-2em cancels \qquad in headers
391 \let\page=\pagebody \raggedbottom
392 % \def\page{\box255 }\normalbottom % faster, but loses plain TeX footnotes
393 \def\normaloutput#1#2#3{\ifodd\pageno\hoffset=\pageshift\fi
394 \shipout\vbox{
395 \vbox to\fullpageheight{
396 \iftitle\global\titlefalse
397 \else\hbox to\pagewidth{\vbox to10pt{}\ifodd\pageno #3\else#2\fi}\fi
398 \vfill#1}} % parameter #1 is the page itself
399 \global\advance\pageno by1}
401 \gtitle={\.{CWEB} output} % this running head is reset by starred sections
402 \mark{\noexpand\nullsec0{\the\gtitle}}
403 \def\title{\expandafter\uppercase\expandafter{\jobname}}
404 \def\topofcontents{\centerline{\titlefont\title}\vskip.7in
405 \vfill} % this material will start the table of contents page
406 \def\startpdf{\ifpdftex\pdfcatalog{/PageMode /UseOutlines}\else
407 \ifpdf{\special{pdf: docview << /PageMode /UseOutlines >>}}\fi\fi}
408 \def\botofcontents{\vfill
409 \centerline{\covernote}} % this material will end the table of contents page
410 \def\covernote{}
411 \def\contentspagenumber{0} % default page number for table of contents
412 \newdimen\pagewidth \pagewidth=6.5in % the width of each page
413 \newdimen\pageheight \pageheight=8.7in % the height of each page
414 \newdimen\fullpageheight \fullpageheight=9in % page height including headlines
415 \newdimen\pageshift \pageshift=0in % shift righthand pages wrt lefthand ones
416 \def\magnify#1{\mag=#1\pagewidth=6.5truein\pageheight=8.7truein
417 \fullpageheight=9truein\setpage}
418 \def\setpage{\hsize\pagewidth\vsize\pageheight} % use after changing page size
419 \def\contentsfile{\jobname.toc} % file that gets table of contents info
420 \def\readcontents{\input \contentsfile}
421 \def\readindex{\input \jobname.idx}
422 \def\readsections{\input \jobname.scn}
424 \newwrite\cont
425 \output{\setbox0=\page % the first page is garbage
426 \openout\cont=\contentsfile
427 \write\cont{\catcode `\noexpand\@=11\relax} % \makeatletter
428 \global\output{\normaloutput\page\lheader\rheader}}
429 \setpage
430 \vbox to \vsize{} % the first \topmark won't be null
432 \def\ch{\note{The following sections were changed by the change file:}
433 \let\*=\relax}
434 \newbox\sbox % saved box preceding the index
435 \newbox\lbox % lefthand column in the index
436 \def\inx{\par\vskip6pt plus 1fil % we are beginning the index
437 \def\page{\box255 } \normalbottom
438 \write\cont{} % ensure that the contents file isn't empty
439 \write\cont{\catcode `\noexpand\@=12\relax} % \makeatother
440 \closeout\cont % the contents information has been fully gathered
441 \output{\ifpagesaved\normaloutput{\box\sbox}\lheader\rheader\fi
442 \global\setbox\sbox=\page \global\pagesavedtrue}
443 \pagesavedfalse \eject % eject the page-so-far and predecessors
444 \setbox\sbox\vbox{\unvbox\sbox} % take it out of its box
445 \vsize=\pageheight \advance\vsize by -\ht\sbox % the remaining height
446 \hsize=.5\pagewidth \advance\hsize by -10pt
447 % column width for the index (20pt between cols)
448 \parfillskip 0pt plus .6\hsize % try to avoid almost empty lines
449 \def\lr{L} % this tells whether the left or right column is next
450 \output{\if L\lr\global\setbox\lbox=\page \gdef\lr{R}
451 \else\normaloutput{\vbox to\pageheight{\box\sbox\vss
452 \hbox to\pagewidth{\box\lbox\hfil\page}}}\lheader\rheader
453 \global\vsize\pageheight\gdef\lr{L}\global\pagesavedfalse\fi}
454 \message{Index:}
455 \parskip 0pt plus .5pt
456 \outer\def\I##1, ##2.{\par\hangindent2em\noindent##1:\kern1em
457 \ifacro\pdfnote##2.\else##2\fi.} % index entry
458 \def\[##1]{$\underline{##1}$} % underlined index item
459 \rm \rightskip0pt plus 2.5em \tolerance 10000 \let\*=\lapstar
460 \hyphenpenalty 10000 \parindent0pt
461 \readindex}
462 \def\fin{\par\vfill\eject % this is done when we are ending the index
463 \ifpagesaved\null\vfill\eject\fi % output a null index column
464 \if L\lr\else\null\vfill\eject\fi % finish the current page
465 \ifpdftex \makebookmarks \fi % added in Version 3.68
466 \parfillskip 0pt plus 1fil
467 \def\grouptitle{NAMES OF THE SECTIONS}
468 \let\topsecno=\nullsec
469 \message{Section names:}
470 \output={\normaloutput\page\lheader\rheader}
471 \setpage
472 \def\note##1##2.{\quad{\eightrm##1~\ifacro{\pdfnote##2.}\else{##2}\fi.}}
473 \def\Q{\note{Cited in section}} % crossref for mention of a section
474 \def\Qs{\note{Cited in sections}} % crossref for mentions of a section
475 \def\U{\note{Used in section}} % crossref for use of a section
476 \def\Us{\note{Used in sections}} % crossref for uses of a section
477 \def\I{\par\hangindent 2em}\let\*=*
478 \ifacro \def\outsecname{Names of the sections} \let\Xpdf\X
479 % \ifpdftex \makebookmarks \pdfdest name {NOS} fitb % in versions < 3.68
480 \ifpdftex \pdfdest name {NOS} fith % changed in version 3.69
481 \pdfoutline goto name {NOS} count -\secno {\outsecname}
482 \def\X##1:##2\X{\Xpdf##1:##2\X \firstsecno##1.%
483 {\toksF={}\makeoutlinetoks##2\outlinedone\outlinedone}%
484 \pdfoutline goto num \the\toksA \expandafter{\the\toksE}}
485 \else\ifpdf
486 \special{pdf: outline -1 << /Title (\outsecname)
487 /Dest [ @thispage /FitH @ypos ] >>}
488 \def\X##1:##2\X{\Xpdf##1:##2\X \firstsecno##1.%
489 {\toksF={}\makeoutlinetoks##2\outlinedone\outlinedone}%
490 \special{pdf: outline 0 << /Title (\the\toksE)
491 /A << /S /GoTo /D (\romannumeral\the\toksA) >> >>}}
492 \fi\fi\fi
493 \readsections}
494 \def\makebookmarks{\let\ZZ=\writebookmarkline \readcontents\relax}
495 \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
496 \else \csname#1\endcsname \fi} % Petr Olsak's macros from texinfo.tex
497 \def\advancenumber#1{\countA=\expnumber{#1}\relax \advance\countA by1
498 \expandafter\xdef\csname#1\endcsname{\the\countA}}
499 \def\writebookmarkline#1#2#3#4#5{{%
500 \let\(=\let \let\)=\let \let\[=\let \let\]=\let \let\/=\let
501 \pdfoutline goto num #3 count -\expnumber{chunk#2.#3} {#5}}}
502 \def\con{\par\vfill\eject % finish the section names
503 % \ifodd\pageno\else\titletrue\null\vfill\eject\fi % for duplex printers
504 \rightskip 0pt \hyphenpenalty 50 \tolerance 200
505 \setpage \output={\normaloutput\page\lheader\rheader}
506 \titletrue % prepare to output the table of contents
507 \pageno=\contentspagenumber
508 \def\grouptitle{TABLE OF CONTENTS}
509 \message{Table of contents:}
510 \topofcontents \startpdf
511 \line{\hfil Section\hbox to3em{\hss Page}}
512 \let\ZZ=\contentsline
513 \readcontents\relax % read the contents info
514 \botofcontents \end} % print the contents page(s) and terminate
515 \def\contentsline#1#2#3#4#5{\ifnum#2=0 \smallbreak\fi
516 \line{\consetup{#2}#1
517 \rm\leaders\hbox to .5em{.\hfil}\hfil
518 \ \ifacro\pdflink{#3}{\romannumeral#3}\else#3\fi\hbox to3em{\hss#4}}}
519 \def\consetup#1{\ifcase#1 \bf % depth -1 (@**)
520 \or % depth 0 (@*)
521 \or \hskip2em % depth 1 (@*1)
522 \or \hskip4em \or \hskip6em \or \hskip8em \or \hskip10em % depth 2,3,4,5
523 \else \hskip12em \fi} % depth 6 or more
524 \def\noinx{\let\inx=\end} % no indexes or table of contents
525 \def\nosecs{\let\FIN=\fin \def\fin{\let\parfillskip=\end \FIN}}
526 % no index of section names or table of contents
527 \def\nocon{\let\con=\end} % no table of contents
528 \def\today{\ifcase\month\or
529 January\or February\or March\or April\or May\or June\or
530 July\or August\or September\or October\or November\or December\fi
531 \space\number\day, \number\year}
532 \newcount\twodigits
533 \def\hours{\twodigits=\time \divide\twodigits by 60 \printtwodigits
534 \multiply\twodigits by-60 \advance\twodigits by\time :\printtwodigits}
535 \def\gobbleone1{}
536 \def\printtwodigits{\advance\twodigits100
537 \expandafter\gobbleone\number\twodigits
538 \advance\twodigits-100 }
539 \def\TeX{{\ifmmode\it\fi
540 \leavevmode\hbox{T\kern-.1667em\lower.424ex\hbox{E}\hskip-.125em X}}}
541 \def\,{\relax\ifmmode\mskip\thinmuskip\else\thinspace\fi}
542 \def\datethis{\def\startsection{\leftline{\sc\today\ at \hours}\bigskip
543 \let\startsection=\stsec\stsec}}
544 % say `\datethis' in limbo, to get your listing timestamped before section 1
545 %\def\datecontentspage{% versions up to 3.65
546 % \def\topofcontents{\leftline{\sc\today\ at \hours}\bigskip
547 % \centerline{\titlefont\title}\vfill}} % timestamps the contents page
548 \def\datecontentspage{% changed in version 3.66
549 \def\botofcontents{\vfill
550 \centerline{\covernote}
551 \bigskip
552 \leftline{\sc\today\ at \hours}}} % timestamps the contents page