Debian Codegraph @

texmf-dist/tex/plain/cweb/ctproofmac.tex

raw
1 % standard macros for CWEB listings (in addition to plain.tex)
2 % Version 4.9 --- June 2023
3 % Modified for proofs in CTWILL
4 \ifx\renewenvironment\undefined\else\endinput\fi % LaTeX will use other macros
5 \xdef\fmtversion{\fmtversion+CTWILL4.9+PROOFS}
6
7 \let\:=\. % preserve a way to get the dot accent
8 % (all other accents will still work as usual)
9
10 \parskip 0pt % no stretch between paragraphs
11 \parindent 1em % for paragraphs and for the first line of C text
12
13 \font\ninerm=cmr9
14 \let\mc=\ninerm % medium caps
15 \def\CEE/{{\mc C\spacefactor1000}}
16 \def\UNIX/{{\mc U\kern-.05emNIX\spacefactor1000}}
17 \def\TEX/{\TeX}
18 \def\CPLUSPLUS/{{\mc C\PP\spacefactor1000}}
19 \def\Cee{\CEE/} % for backward compatibility
20 \def\Cpp{\CPLUSPLUS/} % for backward compatibility
21 \def\9#1{}
22 \font\eightrm=cmr8
23 \let\sc=\eightrm % small caps (NOT a caps-and-small-caps font)
24 \let\mainfont=\tenrm
25 \let\cmntfont\tenrm
26 %\font\tenss=cmss10 \let\cmntfont\tenss % alternative comment font
27 \font\titlefont=cmr7 scaled\magstep4 % title on the contents page
28 \font\ttitlefont=cmtt10 scaled\magstep2 % typewriter type in title
29 \font\tentex=cmtex10 % TeX extended character set (used in strings)
30 \fontdimen7\tentex=0pt % no double space after sentences
31
32 \def\\#1{\leavevmode\hbox{\it#1\/\kern.05em}} % italic type for identifiers
33 \def\|#1{\leavevmode\hbox{$#1$}} % one-letter identifiers look better this way
34 \def\&#1{\leavevmode\hbox{\bf
35 \def\_{\kern.04em\vbox{\hrule width.3em height .6pt}\kern.08em}%
36 #1\/\kern.05em}} % boldface type for reserved words
37 \def\.#1{\leavevmode\hbox{\tentex % typewriter type for strings
38 \let\\=\BS % backslash in a string
39 \let\{=\LB % left brace in a string
40 \let\}=\RB % right brace in a string
41 \let\~=\TL % tilde in a string
42 \let\ =\SP % space in a string
43 \let\_=\UL % underline in a string
44 \let\&=\AM % ampersand in a string
45 \let\^=\CF % circumflex in a string
46 #1\kern.05em}}
47 \def\){{\tentex\kern-.05em}\discretionary{\hbox{\tentex\BS}}{}{}}
48 \def\AT{@} % at sign for control text (not needed in versions >= 2.9)
49 \def\ATL{\par\noindent\bgroup\catcode`\_=12 \postATL} % print @l in limbo
50 \def\postATL#1 #2 {\bf letter \\{\uppercase{\char"#1}}
51 tangles as \tentex "#2"\egroup\par}
52 \def\noATL#1 #2 {}
53 \def\noatl{\let\ATL=\noATL} % suppress output from @l
54 \def\ATH{\X\kern-.5em:Preprocessor definitions\X}
55 \let\PB=\relax % hook for program brackets |...| in TeX part or section name
56
57 \chardef\AM=`\& % ampersand character in a string
58 \chardef\BS=`\\ % backslash in a string
59 \chardef\LB=`\{ % left brace in a string
60 \chardef\RB=`\} % right brace in a string
61 \def\SP{{\tt\char`\ }} % (visible) space in a string
62 \chardef\TL=`\~ % tilde in a string
63 \chardef\UL=`\_ % underline character in a string
64 \chardef\CF=`\^ % circumflex character in a string
65
66 \newbox\PPbox % symbol for ++
67 \setbox\PPbox=\hbox{\kern.5pt\raise1pt\hbox{\sevenrm+\kern-1pt+}\kern.5pt}
68 \def\PP{\copy\PPbox}
69 \newbox\MMbox \setbox\MMbox=\hbox{\kern.5pt\raise1pt\hbox{\sevensy\char0
70 \kern-1pt\char0}\kern.5pt}
71 \def\MM{\copy\MMbox}
72 \newbox\MGbox % symbol for ->
73 \setbox\MGbox=\hbox{\kern-2pt\lower3pt\hbox{\teni\char'176}\kern1pt}
74 \def\MG{\copy\MGbox}
75 \def\MRL#1{\mathrel{\let\K==#1}}
76 \let\GG=\gg
77 \let\LL=\ll
78 \let\NULL=\Lambda
79 \mathchardef\AND="2026 % bitwise and; also \& (unary operator)
80 \let\OR=\mid % bitwise or
81 \let\XOR=\oplus % bitwise exclusive or
82 \def\CM{{\sim}} % bitwise complement
83 \newbox\MODbox \setbox\MODbox=\hbox{\eightrm\%}
84 \def\MOD{\mathbin{\copy\MODbox}}
85 \def\DC{\kern.1em{::}\kern.1em} % symbol for ::
86 \def\PA{\mathbin{.*}} % symbol for .*
87 \def\MGA{\mathbin{\MG*}} % symbol for ->*
88 \def\this{\&{this}}
89
90 \newbox\bak \setbox\bak=\hbox to -1em{} % backspace one em
91 \newbox\bakk\setbox\bakk=\hbox to -2em{} % backspace two ems
92
93 \newcount\ind % current indentation in ems
94 \def\1{\global\advance\ind by1\hangindent\ind em} % indent one more notch
95 \def\2{\global\advance\ind by-1} % indent one less notch
96 \def\3#1{\hfil\penalty#10\hfilneg} % optional break within a statement
97 \def\4{\copy\bak} % backspace one notch
98 \def\5{\hfil\penalty-1\hfilneg\kern2.5em\copy\bakk\ignorespaces}% optional break
99 \def\6{\ifmmode\else\par % forced break
100 \hangindent\ind em\noindent\kern\ind em\copy\bakk\ignorespaces\fi}
101 \def\7{\Y\6} % forced break and a little extra space
102 \def\8{\hskip-\ind em\hskip 2em} % no indentation
103
104 \newcount\gdepth % depth of current major group, plus one
105 \newcount\secpagedepth
106 \secpagedepth=3 % page breaks will occur for depths -1, 0, and 1
107 \newtoks\gtitle % title of current major group
108 \newskip\intersecskip \intersecskip=12pt minus 3pt % space between sections
109 \let\yskip=\smallskip
110 \def\?{\mathrel?}
111 \def\,{\relax\ifmmode\mskip\thinmuskip\else\thinspace\fi}
112 \def\note#1#2.{\Y\noindent{\hangindent2em\baselineskip10pt\eightrm#1~#2.\par}}
113 \def\lapstar{\rlap{*}}
114 \def\stsec{\rightskip=0pt % get out of C mode (cf. \B)
115 \sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50
116 \noindent{\let\*=\lapstar\bf\secstar.\quad}}
117 \let\startsection=\stsec
118 \def\defin#1{\global\advance\ind by 2 \1\&{#1 }} % begin `define' or `format'
119 \def\A{\note{See also section}} % xref for doubly defined section name
120 \def\As{\note{See also sections}} % xref for multiply defined section name
121 \def\B{\rightskip=0pt plus 100pt minus 10pt % go into C mode
122 \sfcode`;=3000
123 \pretolerance 10000
124 \hyphenpenalty 1000 % so strings can be broken (discretionary \ is inserted)
125 \exhyphenpenalty 10000
126 \global\ind=2 \1\ \unskip}
127 \def\C#1{\5\5\quad$/\ast\,${\cmntfont #1}$\,\ast/$}
128 \let\SHC\C % "// short comments" treated like "/* ordinary comments */"
129 %\def\C#1{\5\5\quad$\triangleright\,${\cmntfont#1}$\,\triangleleft$}
130 %\def\SHC#1{\5\5\quad$\diamond\,${\cmntfont#1}}
131 \def\D{\defin{{\rm\#}define}} % macro definition
132 \let\E=\equiv % equivalence sign
133 \def\ET{ and~} % conjunction between two section numbers
134 \def\ETs{, and~} % conjunction between the last two of several section numbers
135 \def\F{\defin{format}} % format definition
136 \let\G=\ge % greater than or equal sign
137 % \H is long Hungarian umlaut accent
138 \let\I=\ne % unequal sign
139 \def\J{\.{@\&}} % CTANGLE's join operation
140 \let\K== % assignment operator
141 %\let\K=\leftarrow % "honest" alternative to standard assignment operator
142 % \L is Polish letter suppressed-L
143 \outer\def\M#1{\MN{#1}\ifon\vfil\penalty-100\vfilneg % beginning of section
144 \vskip\intersecskip\startsection\ignorespaces}
145 \outer\def\N#1#2#3.{\gdepth=#1\gtitle={#3}\MN{#2}% beginning of starred section
146 \ifon\ifnum#1<\secpagedepth \vfil\eject % force page break if depth is small
147 \else\vfil\penalty-100\vfilneg\vskip\intersecskip\fi\fi
148 \message{*\secno} % progress report
149 \edef\next{\write\cont{\ZZ{#3}{#1}{\secno}% write to contents file
150 {\noexpand\the\pageno}}}\next % \ZZ{title}{depth}{sec}{page}
151 \ifon\startsection{\bf#3.\quad}\ignorespaces}
152 \def\MN#1{\par % common code for \M, \N
153 {\xdef\secstar{#1}\let\*=\empty\xdef\secno{#1}}% remove \* from section name
154 \ifx\secno\secstar \onmaybe \else\ontrue \fi
155 \mark{{{\tensy x}\secno}{\the\gdepth}{\the\gtitle}}}
156 % each \mark is {section reference or null}{depth plus 1}{group title}
157 % \O is Scandinavian letter O-with-slash
158 % \P is paragraph sign
159 \def\Q{\note{This code is cited in section}} % xref for mention of a section
160 \def\Qs{\note{This code is cited in sections}} % xref for mentions of a section
161 \let\R=\lnot % logical not
162 % \S is section sign
163 \def\T#1{\leavevmode % octal, hex or decimal constant
164 \hbox{$\def\?{\kern.2em}%$%
165 \let\ \, % C++ digit separator becomes a little white space
166 \def\$##1{\egroup_{\rm##1}\bgroup}% suffix to constant
167 \def\_{\cdot 10^{\aftergroup}}% power of ten (via dirty trick)
168 \let\~=\oct \let\^=\hex \let\\=\bin {#1}$}}%$%
169 \def\U{\note{This code is used in section}} % xref for use of a section
170 \def\Us{\note{This code is used in sections}} % xref for uses of a section
171 \let\V=\lor % logical or
172 \let\W=\land % logical and
173 \def\X#1:#2\X{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi %$% section name
174 \XX$\langle\,${\let\I=\ne#2\eightrm\kern.5em#1}$\,\rangle$\XX}
175 \def\Y{\par\yskip}
176 \let\Z=\le
177 \let\ZZ=\let % now you can \write the control sequence \ZZ
178 \let\*=*
179
180 %\def\oct{\hbox{\rm\char'23\kern-.2em\it\aftergroup\?\aftergroup}} % WEB style
181 %\def\hex{\hbox{\rm\char"7D\tt\aftergroup}} % WEB style
182 \def\oct{\hbox{$^\circ$\kern-.1em\it\aftergroup\?\aftergroup}} % CWEB style
183 \def\hex{\hbox{$^{\scriptscriptstyle\#}$\tt\aftergroup}} % CWEB style
184 \def\bin{\hbox{$^{\scriptscriptstyle b}$\tt\aftergroup}} % new in CWEB 4.3
185 \def\vb#1{\leavevmode\hbox{\kern2pt\vrule\vtop{\vbox{\hrule
186 \hbox{\strut\kern2pt\.{#1}\kern2pt}}
187 \hrule}\vrule\kern2pt}} % verbatim string
188 \def\p#1{\cdot 2^{#1}} % power of two (hex exponent)
189
190 \def\onmaybe{\let\ifon=\maybe} \let\maybe=\iftrue
191 \newif\ifon \newif\iftitle \newif\ifpagesaved
192
193 \def\lheader{\mainfont\the\pageno\eightrm\qquad\grouptitle\hfill\title\qquad
194 \mainfont\topsecno} % top line on left-hand pages
195 \def\rheader{\mainfont\topsecno\eightrm\qquad\title\hfill\grouptitle
196 \qquad\mainfont\the\pageno} % top line on right-hand pages
197 \def\grouptitle{\let\i=I\let\j=J\uppercase\expandafter{\expandafter
198 \takethree\topmark}}
199 \def\topsecno{\expandafter\takeone\topmark}
200 \def\takeone#1#2#3{#1}
201 \def\taketwo#1#2#3{#2}
202 \def\takethree#1#2#3{#3}
203 \def\nullsec{\eightrm\kern-2em} % the \kern-2em cancels \qquad in headers
204
205 \def\page{\box255 }
206 \def\normaloutput#1#2#3{\ifodd\pageno\hoffset=\pageshift\fi
207 \shipout\vbox{
208 \vbox to\fullpageheight{
209 \iftitle\global\titlefalse
210 \else\hbox to\pagewidth{\vbox to10pt{}\ifodd\pageno #3\else#2\fi}\fi
211 \vfill#1}} % parameter #1 is the page itself
212 \global\advance\pageno by1}
213
214 \gtitle={\.{CWEB} output} % this running head is reset by starred sections
215 \mark{\noexpand\nullsec0{\the\gtitle}}
216 \def\title{\expandafter\uppercase\expandafter{\jobname}}
217 \def\topofcontents{\centerline{\titlefont\title}\vskip.7in
218 \vfill} % this material will start the table of contents page
219 \def\botofcontents{\vfill
220 \centerline{\covernote}} % this material will end the table of contents page
221 \def\covernote{}
222 \def\contentspagenumber{0} % default page number for table of contents
223 \newdimen\pagewidth \pagewidth=6.5in % the width of each page
224 \newdimen\pageheight \pageheight=8.7in % the height of each page
225 \newdimen\fullpageheight \fullpageheight=9in % page height including headlines
226 \newdimen\pageshift \pageshift=0in % shift righthand pages wrt lefthand ones
227 \def\magnify#1{\mag=#1\pagewidth=6.5truein\pageheight=8.7truein
228 \fullpageheight=9truein\setpage}
229 \def\setpage{\hsize\pagewidth\vsize\pageheight} % use after changing page size
230 \def\contentsfile{\jobname.toc} % file that gets table of contents info
231 \def\readcontents{\input \contentsfile}
232 \def\readindex{\input \jobname.idx}
233 \def\readsections{\input \jobname.scn}
234
235 \newwrite\cont
236 \output{\setbox0=\page % the first page is garbage
237 \openout\cont=\contentsfile
238 \write\cont{\catcode `\noexpand\@=11\relax} % \makeatletter
239 \global\output{\normaloutput\page\lheader\rheader}}
240 \setpage
241 \vbox to \vsize{} % the first \topmark won't be null
242
243 \def\mini{\Y\bgroup\obeylines}
244 {\obeylines
245 \gdef\[#1 #2 #3
246 {\noindent\kern.5\hsize #2\miniform#3, \S#1.\par}%
247 \gdef\]#1 #2 #3
248 {\noindent\kern.5\hsize #2\miniform#3, \extref#1.\par}}
249 \def\miniform{\futurelet\next\miniforma}
250 \def\miniforma{\ifx\next\zip
251 \else\if=\noexpand\next \let\next\gobbleq
252 \else\let\next\colon\fi\fi\next}
253 \def\zip{}
254 \def\gobbleq={\,=\,}
255 \def\colon{: }
256 \def\extref{\futurelet\next\extrefa}
257 \def\extrefa{\if"\next\let\next\gobblest\else\let\next\cite\fi\next}
258 \def\gobblest"#1"{{\tentex#1}}
259 \def\cite#1#2.{{\sc#1}\,\S#2.}
260 \let\FI=\fi
261 \let\shortpage=\relax
262 \let\forcebr=\relax
263 \def\uninitialized{???}
264
265 \def\ch{\note{The following sections were changed by the change file:}
266 \let\*=\relax}
267 \newbox\sbox % saved box preceding the index
268 \newbox\lbox % lefthand column in the index
269 \def\inx{\par\vskip6pt plus 1fil % we are beginning the index
270 \write\cont{} % ensure that the contents file isn't empty
271 \write\cont{\catcode `\noexpand\@=12\relax} % \makeatother
272 \closeout\cont % the contents information has been fully gathered
273 \output{\ifpagesaved\normaloutput{\box\sbox}\lheader\rheader\fi
274 \global\setbox\sbox=\page \global\pagesavedtrue}
275 \pagesavedfalse \eject % eject the page-so-far and predecessors
276 \setbox\sbox\vbox{\unvbox\sbox} % take it out of its box
277 \vsize=\pageheight \advance\vsize by -\ht\sbox % the remaining height
278 \hsize=.5\pagewidth \advance\hsize by -10pt
279 % column width for the index (20pt between cols)
280 \parfillskip 0pt plus .6\hsize % try to avoid almost empty lines
281 \def\lr{L} % this tells whether the left or right column is next
282 \output{\if L\lr\global\setbox\lbox=\page \gdef\lr{R}
283 \else\normaloutput{\vbox to\pageheight{\box\sbox\vss
284 \hbox to\pagewidth{\box\lbox\hfil\page}}}\lheader\rheader
285 \global\vsize\pageheight\gdef\lr{L}\global\pagesavedfalse\fi}
286 \message{Index:}
287 \parskip 0pt plus .5pt
288 \outer\def\I##1, {\par\hangindent2em\noindent##1:\kern1em} % index entry
289 \def\[##1]{$\underline{##1}$} % underlined index item
290 \rm \rightskip0pt plus 2.5em \tolerance 10000 \let\*=\lapstar
291 \hyphenpenalty 10000 \parindent0pt
292 \readindex}
293 \def\fin{\par\vfill\eject % this is done when we are ending the index
294 \ifpagesaved\null\vfill\eject\fi % output a null index column
295 \if L\lr\else\null\vfill\eject\fi % finish the current page
296 \parfillskip 0pt plus 1fil
297 \def\grouptitle{NAMES OF THE SECTIONS}
298 \let\topsecno=\nullsec
299 \message{Section names:}
300 \output={\normaloutput\page\lheader\rheader}
301 \setpage
302 \def\note##1##2.{\quad{\eightrm##1~##2.}}
303 \def\Q{\note{Cited in section}} % crossref for mention of a section
304 \def\Qs{\note{Cited in sections}} % crossref for mentions of a section
305 \def\U{\note{Used in section}} % crossref for use of a section
306 \def\Us{\note{Used in sections}} % crossref for uses of a section
307 \def\I{\par\hangindent 2em}\let\*=*
308 \readsections}
309 \def\con{\par\vfill\eject % finish the section names
310 \rightskip 0pt \hyphenpenalty 50 \tolerance 200
311 \setpage \output={\normaloutput\page\lheader\rheader}
312 \titletrue % prepare to output the table of contents
313 \pageno=\contentspagenumber
314 \def\grouptitle{TABLE OF CONTENTS}
315 \message{Table of contents:}
316 \topofcontents
317 \line{\hfil Section\hbox to3em{\hss Page}}
318 \let\ZZ=\contentsline
319 \readcontents\relax % read the contents info
320 \botofcontents \end} % print the contents page(s) and terminate
321 \def\contentsline#1#2#3#4{\ifnum#2=0 \smallbreak\fi
322 \line{\consetup{#2}#1
323 \rm\leaders\hbox to .5em{.\hfil}\hfil\ #3\hbox to3em{\hss#4}}}
324 \def\consetup#1{\ifcase#1 \bf % depth -1 (@**)
325 \or % depth 0 (@*)
326 \or \hskip2em % depth 1 (@*1)
327 \or \hskip4em % depth 2 (@*2)
328 \or \hskip6em % depth 3 (@*3)
329 \or \hskip8em % depth 4 (@*4)
330 \or \hskip10em % depth 5 (@*5)
331 \else \hskip12em \fi} % depth 6 or more
332 \def\noinx{\let\inx=\end} % no indexes or table of contents
333 \def\nosecs{\let\FIN=\fin \def\fin{\let\parfillskip=\end \FIN}}
334 % no index of section names or table of contents
335 \def\nocon{\let\con=\end} % no table of contents
336 \def\today{\ifcase\month\or
337 January\or February\or March\or April\or May\or June\or
338 July\or August\or September\or October\or November\or December\fi
339 \space\number\day, \number\year}
340 \newcount\twodigits
341 \def\hours{\twodigits=\time \divide\twodigits by 60 \printtwodigits
342 \multiply\twodigits by-60 \advance\twodigits by\time :\printtwodigits}
343 \def\gobbleone1{}
344 \def\printtwodigits{\advance\twodigits100
345 \expandafter\gobbleone\number\twodigits
346 \advance\twodigits-100 }
347 \def\datethis{\def\startsection{\leftline{\sc\today\ at \hours}\bigskip
348 \let\startsection=\stsec\stsec}}
349 % say `\datethis' in limbo, to get your listing timestamped before section 1
350 \def\datecontentspage{%
351 \def\topofcontents{\leftline{\sc\today\ at \hours}\bigskip
352 \centerline{\titlefont\title}\vfill}} % timestamps the contents page
353 \def\formatoff{\gdef\F##1\par{\setbox0=\lastbox\par}} % omits output of @f
354 \def\formaton{\gdef\F{\defin{format}}} % restores output of @f
355 % hack: you can say @t}\par\formaton{@> at end of an @f being suppressed