1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64\unprotect
65
66\newtoks\CWEBmacros
67
68
69
70
71
72
73
74
75
76
77\unexpanded\def\activateCWEB
78 {\let\doCWEB\activateCWEBmacro
79 \the\CWEBmacros}
80
81\unexpanded\def\deactivateCWEB
82 {\let\doCWEB\deactivateCWEBmacro
83 \the\CWEBmacros}
84
85
86
87
88
89\installcorenamespace{newCWEB}
90\installcorenamespace{oldCWEB}
91
92\unexpanded\def\defCWEBmacro#1
93 {\appendtoks\doCWEB#1\to\CWEBmacros
94 \setuvalue{\??newCWEB\string#1}}
95
96\unexpanded\def\letCWEBmacro#1
97 {\appendtoks\doCWEB#1\to\CWEBmacros
98 \letvalue{\??newCWEB\string#1}}
99
100\unexpanded\def\defCWEBdummy#1#2#
101 {\appendtoks\doCWEB#1\to\CWEBmacros
102 \setuvalue{\??newCWEB\string#1}#2{}
103 \gobbleoneargument}
104
105
106
107
108\unexpanded\def\CWEBmacro#1
109 {\getvalue{\??newCWEB\string#1}}
110
111\unexpanded\def\activateCWEBmacro#1
112 {\letvalue{\??oldCWEB\string#1}=#1
113 \unexpanded\def#1{\CWEBmacro#1}}
114
115\unexpanded\def\deactivateCWEBmacro#1
116 {\expandafter\let\expandafter#1\csname\??oldCWEB\string#1\endcsname}
117
118\protect
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142\letCWEBmacro\: = \.
143
144
145
146
147
148
149\defCWEBmacro \CEE{{\tx C\spacefactor1000}}
150\defCWEBmacro \UNIX{{\tx UNIX\spacefactor1000}}
151\defCWEBmacro \TEX{\TeX}
152\defCWEBmacro\CPLUSPLUS{{\tx C\PP\spacefactor1000}}
153\defCWEBmacro \Cee{\CEE}
154
155
156
157
158
159
160
161\defCWEBmacro\\#1
162 {\dontleavehmode
163 \hbox{\it#1\/\kern.05em}}
164
165
166
167
168
169\defCWEBmacro\|#1
170 {\dontleavehmode
171 \hbox{$#1$}}
172
173
174
175
176
177\defCWEBmacro\
178 {\dontleavehmode
179 \hbox{\bf#1\/\kern.05em}}
180
181
182
183
184
185
186\defCWEBmacro\.#1
187 {\dontleavehmode
188 \hbox
189 {\tttf
190 \let\\=\BS
191 \let\{=\LB
192 \let\}=\RB
193 \let\~=\TL
194 \let\ =\SP
195 \let\_=\UL
196 \let\&=\AM
197 \let\^=\CF
198 #1\kern.05em}}
199
200
201
202
203
204\defCWEBmacro\)
205 {\discretionary{\hbox{\tttf\BS}}{}{}}
206
207
208
209
210
211\defCWEBmacro\AT{@}
212
213
214
215
216
217\defCWEBmacro\ATL
218 {\par
219 \noindent
220 \bgroup
221 \catcode\_=12
222 \postATL}
223
224\defCWEBmacro\postATL#1 #2
225 {\bf letter \\{\WORD{\char"#1}} tangles as \tttf \quotation{#2}
226 \egroup
227 \par}
228
229\defCWEBmacro\noATL#1 #2
230 {}
231
232
233
234
235
236\defCWEBmacro\noatl
237 {\let\ATL\noATL}
238
239
240
241
242
243
244
245
246
247\defCWEBmacro\PB
248 {\relax}
249
250\letCWEBmacro\AM \letterampersand
251\letCWEBmacro\BS \letterbackslash
252\letCWEBmacro\LB \letterleftbrace
253\letCWEBmacro\RB \letterrightbrace
254\letCWEBmacro\TL \lettertilde
255\letCWEBmacro\UL \letterunderscore
256\letCWEBmacro\CF \letterhat
257\letCWEBmacro\SP \textvisiblespace
258
259
260
261
262
263
264
265
266
267\defCWEBmacro\PP
268 {\kern.05em
269 \raise.1em\hbox{$\scriptstyle\kern.1em$}
270 \kern.05em}
271
272\defCWEBmacro\MM
273 {\kern.05em
274 \raise.1em\hbox{$\scriptstyle\kern.1em$}
275 \kern.05em}
276
277\defCWEBmacro\MG
278 {\kern.2em
279 \lower.3em\hbox{$\rightarrow$}
280 \kern .1em}
281
282\defCWEBmacro\MRL#1
283 {\mathrel{\let\K==#1}}
284
285
286
287
288\letCWEBmacro\GG = \gg
289\letCWEBmacro\LL = \ll
290\letCWEBmacro\NULL = \Lambda
291
292\letCWEBmacro\AND = \mathampersand
293
294\letCWEBmacro\OR = \mid
295\letCWEBmacro\XOR = \oplus
296\defCWEBmacro\CM {{\sim}}
297\defCWEBmacro\MOD {\mathbin{\tx\%}}
298\defCWEBmacro\DC {\kern.1em{::}\kern.1em}
299\defCWEBmacro\PA {\mathbin{.*}}
300\defCWEBmacro\MGA {\mathbin{\MG*}}
301\defCWEBmacro\this {\&{this}}
302
303\newcount\CWEBind
304
305\defCWEBmacro\1
306 {\global\advance\CWEBind \plusone
307 \hangindent\CWEBind \emwidth}
308
309\defCWEBmacro\2
310 {\global\advance\CWEBind \minusone}
311
312\defCWEBmacro\3#1
313 {\hfil
314 \penalty#10\relax
315 \hfilneg}
316
317\defCWEBmacro\4
318 {\hpack to 1em{}}
319
320\defCWEBmacro\5
321 {\hfil
322 \penalty\minusone
323 \hfilneg
324 \kern2.5em
325 \hpack to 2em{}
326 \ignorespaces}
327
328\defCWEBmacro\6
329 {\ifmmode \else
330 \par
331 \hangindent\CWEBind em
332 \noindent
333 \kern\CWEBind em
334 \hpack to 2em{}
335 \ignorespaces
336 \fi}
337
338\defCWEBmacro\7
339 {\Y
340 \6}
341
342\defCWEBmacro\8
343 {\hskip\CWEBind em
344 \hskip 2em}
345
346\defCWEBmacro\9#1
347 {}
348
349\newcount\CWEBgdepth
350\newcount\CWEBsecpagedepth
351
352\CWEBsecpagedepth=3
353
354\defCWEBmacro\?
355 {\mathrel?}
356
357\defCWEBmacro\lapstar
358 {\rlap{*}}
359
360\defCWEBmacro\defin#1
361 {\global\advance\CWEBind by 2 \1\&{#1 } }
362
363\defCWEBmacro\B
364 {\rightskip=0pt plus 100pt minus 10pt
365 \sfcode;=3000
366 \pretolerance 10000
367 \hyphenpenalty 1000
368 \exhyphenpenalty 10000
369 \global\CWEBind=2 \1\ \unskip}
370
371\defCWEBmacro\C#1
372 {\5\5\quad$\ast\,${\ss\detokenize{#1}}$\,\ast$}
373
374\defCWEBmacro\SHC#1
375 {\5\5\quad$\,${\ss#1}}
376
377\defCWEBmacro\D
378 {\defin{\#define}}
379
380\letCWEBmacro\E=\equiv
381
382
383
384
385
386
387
388\defCWEBmacro\F
389 {\defin{format}}
390
391\letCWEBmacro\G = \ge
392
393
394
395\letCWEBmacro\I = \ne
396
397\defCWEBmacro\J
398 {\.{@\&}}
399
400\letCWEBmacro\K = \leftarrow
401
402
403
404
405
406\defCWEBmacro\Q {\note{This code is cited in section}}
407\defCWEBmacro\Qs {\note{This code is cited in sections}}
408
409
410
411\defCWEBmacro\T#1
412 {\dontleavehmode
413 \hbox
414 {$\def\?{\kern.2em}
415 \def\$##1{\egroup_{\,\rm##1}\bgroup}
416 \def\_{\cdot 10{\aftergroup}}
417 \let\~=\oct
418 \let\^=\hex
419 {#1}$}}
420
421\defCWEBmacro\U {\note{This code is used in section}}
422\defCWEBmacro\Us {\note{This code is used in sections}}
423
424\letCWEBmacro\R = \lnot
425\letCWEBmacro\V = \lor
426\letCWEBmacro\W = \land
427
428\unprotect
429
430\def\theCWEByskip {\blank[\v!small]}
431\def\theCWEBvskip {\blank[\v!big]}
432
433\protect
434
435\defCWEBmacro\Y
436 {\par
437 \yskip}
438
439\defCWEBmacro\yskip
440 {\theCWEByskip}
441
442\letCWEBmacro\Z = \le
443\letCWEBmacro\ZZ = \relax
444\letCWEBmacro\* = *
445
446\defCWEBmacro\oct
447 {\hbox{$\circ$\kern.1em\it\aftergroup\?\aftergroup}}
448
449\defCWEBmacro\hex
450 {\hbox{${\scriptscriptstyle\#}$\tt\aftergroup}}
451
452\defCWEBmacro\vb#1
453 {\dontleavehmode
454 \hbox
455 {\kern.2em
456 \vrule
457 \vtop
458 {\vbox
459 {\hrule
460 \hbox{\strut\kern.2em\.{#1}\kern.2em}}
461 \hrule}
462 \vrule
463 \kern.2em}}
464
465\def\onmaybe
466 {\let\ifon=\maybe}
467
468\let\maybe=\iftrue
469
470\newif\ifon
471
472\def\botofcontents
473 {\vfill
474 \centerline{\covernote}}
475
476\def\covernote
477 {}
478
479
480
481\defCWEBmacro\contentspagenumber{0}
482
483\defCWEBdummy\magnify#1
484 {}
485
486\defCWEBmacro\ch
487 {\note{The following sections were changed by the change file:}
488 \let\*=\relax}
489
490\defCWEBmacro\consetup#1
491 {\ifcase#1 \bf
492 \or
493 \or \hskip 2em
494 \or \hskip 4em
495 \or \hskip 6em
496 \or \hskip 8em
497 \or \hskip10em
498 \else \hskip12em
499 \fi}
500
501\defCWEBdummy \inx {}
502\defCWEBdummy \fin {}
503\defCWEBdummy \con {}
504
505\defCWEBdummy \noinx {}
506\defCWEBdummy \nosecs {}
507\defCWEBdummy \nocon {}
508
509\defCWEBmacro\,
510 {\relax
511 \ifmmode
512 \mskip\thinmuskip
513 \else
514 \thinspace
515 \fi}
516
517\defCWEBdummy\datethis {}
518\defCWEBdummy\datecontentspage {}
519
520\defCWEBmacro\TeX
521 {{\ifmmode\it\fi
522 \dontleavehmode
523 \hbox{T\kern.1667em\lower.424ex\hbox{E}\hskip.125em X}}}
524
525
526
527\newif\ifCWEBnotes
528
529\defCWEBmacro\Q {\CWEBnotesfalse \note{This code is cited in section}}
530\defCWEBmacro\Qs {\CWEBnotestrue \note{This code is cited in sections}}
531
532\defCWEBmacro\U {\CWEBnotesfalse \note{This code is used in section}}
533\defCWEBmacro\Us {\CWEBnotestrue \note{This code is used in sections}}
534
535\defCWEBmacro\A {\CWEBnotesfalse \note{See also section}}
536\defCWEBmacro\As {\CWEBnotestrue \note{See also sections}}
537
538\defCWEBmacro\ET { and}
539\defCWEBmacro\ETs {, and}
540
541\def\processCWEBsectionnumber#1
542 {\bgroup
543 \def\[##1]{##1}
544 \xdef\CWEBreference{#1}
545 \egroup
546 \CWEBcomma{\goto{#1}[web:\CWEBreference]}}
547
548\unexpanded\def\processCWEBsectionnumbers[#1]
549 {\bgroup
550 \def\CWEBcomma{\def\CWEBcomma{, }}
551 \processlist(),\processCWEBsectionnumber(#1)
552 \egroup}
553
554\unexpanded\def\processCWEBsectionnotes
555 {\catcode\s=12
556 \doprocessCWEBsectionnotes}
557
558\def\doprocessCWEBsectionnote#1\ET#2#3.
559 {\processCWEBsectionnumbers[#1]
560 \if#2s
561 {, and\goto{##3}[web:#3]}
562 \else
563 { and\goto{##2##3}[web:#2#3]}
564 \fi}
565
566\unexpanded\def\doprocessCWEBsectionnotes#1.
567 {\ifCWEBnotes
568 \doprocessCWEBsectionnote#1.
569 \else
570 \goto{#1}[web:#1]
571 \fi
572 \afterCWEBnote
573 \egroup}
574
575\let\afterCWEBnote\relax
576
577\defCWEBmacro\note#1
578 {\bgroup
579 \Y\noindent
580 \def\afterCWEBnote{\par}
581 \hangindent2em
582
583 \tx#1\processCWEBsectionnotes}
584
585\unexpanded\def\oldCWEBmacroX#1:#2\X
586 {\ifmmode
587 \gdef\XX{\null$\null}
588 \else
589 \glet\XX\empty
590 \fi
591 \XX$\langle\,${#2\tx\kern.5em#1}$\,\rangle$\XX}
592
593\defCWEBmacro\ATH
594 {\oldCWEBmacroX\kern.5em:Preprocessor definitions\X}
595
596\unexpanded\def\newCWEBmacroX#1:#2\X
597 {\ifmmode
598 \gdef\XX{\null$\null}
599 \else
600 \glet\XX\empty
601 \fi
602 \XX$\langle\,$
603 {#2\tx\kern.5em\processCWEBsectionnumbers[{#1}]}
604 $\,\rangle$\XX}
605
606\defCWEBmacro\X#1:#2\X
607 {\newCWEBmacroX#1:#2\X}
608
609
610
611
612\let\CWEBsecno\empty
613
614\definelist[cweb]
615
616\defCWEBmacro\startsection
617 {\rightskip=0pt
618 \sfcode;=1500
619 \pretolerance 200
620 \hyphenpenalty 50
621 \exhyphenpenalty 50
622 \noindent
623 \bgroup
624 \let\*=\lapstar
625 \gotoCWEBsection{\bf\CWEBsecstar.\quad}[\CWEBsecno]
626 \egroup}
627
628\defCWEBmacro\MN#1
629 {\par
630 \begingroup
631 \xdef\CWEBsecstar{#1}
632 \let\*=\empty
633 \xdef\CWEBsecno{#1}
634 \endgroup
635 \ifx\CWEBsecno\CWEBsecstar
636 \onmaybe
637 \else
638 \ontrue
639 \fi}
640
641\defCWEBmacro\M#1
642 {\MN{#1}
643 \ifon
644 \vfil
645 \penalty100
646 \vfilneg
647 \theCWEBvskip
648 \startsection
649 \pagereference[web:#1]
650 \expanded{\marking[CWEBsectionnumber]{\secno}}
651 \expanded{\marking[CWEBsectiondepth]{\the\CWEBgdepth}}
652 \ignorespaces}
653
654\defCWEBmacro\N#1#2#3.
655 {\CWEBgdepth=#1
656 \MN{#2}
657 \ifon
658 \ifnum#1<\CWEBsecpagedepth
659 \page
660 \else
661 \vfil
662 \penalty100
663 \vfilneg
664 \theCWEBvskip
665 \fi
666 \fi
667 \writedatatolist[cweb][section=\CWEBsecno,title={#3},depth=#1]
668 \ifon
669 \startsection
670 \pagereference[web:#2]
671 \marking[CWEBsectiontitle] {#3}
672 \expanded{\marking[CWEBsectionnumber]{\CWEBsecno}}
673 \expanded{\marking[CWEBsectiondepth]{\the\CWEBgdepth}}
674 {\bf#3.\quad}
675 \ignorespaces}
676
677\newif\iflinktoCWEBfile
678
679\def\setCWEBlinkfile#1
680 {\linktoCWEBfiletrue
681 \def\otherCWEBfile{#1}}
682
683\unprotect
684
685\unexpanded\def\gotoCWEBsection#1[#2]
686 {\iflinktoCWEBfile
687 \bgroup
688 \setupinteraction[\c!color=,\c!style=]
689 \let\savedreferenceprefix=\referenceprefix
690 \goto{#1}[\otherCWEBfile::\savedreferenceprefix web:#2]
691 \egroup
692 \else
693 #1
694 \fi}
695
696\protect
697
698\unexpanded\def\ignoreCWEBinput
699 {\def\input ##1 {\let\input\normalinput}}
700
701\unexpanded\def\loadCWEBmacros#1
702 {\let\oldN=\N
703 \def\N{\bgroup\setbox0=\vbox\bgroup\endinput}
704 \ignoreCWEBinput
705 \ReadFile{#1.tex}
706 \egroup\egroup
707 \let\N=\oldN}
708
709\unexpanded\def\resetCWEBcontext
710 {\catcode\|=\othercatcode
711 \everypar \emptytoks
712 \parskip \zeropoint
713 \parindent \emwidth}
714
715\unexpanded\def\processCWEBsource #1
716 {\bgroup
717 \resetCWEBcontext
718 \activateCWEB
719 \ignoreCWEBinput
720 \let\end\relax
721 \marking[CWEBfilename]{#1}
722 \ReadFile{#1.tex}\relax
723 \par
724 \egroup}
725
726\unexpanded\def\resetCWEBindexentry
727 {\xdef\currentCWEBindexentry{}}
728
729\unexpanded\def\showCWEBindexentry#1
730 {\theCWEBvskip
731 \vskip3\lineheight
732 \goodbreak
733 \vskip3\lineheight
734 {\pagereference[web:#1]\bf#1}
735 \theCWEBvskip}
736
737
738 \def\dodofindfirstcharacter#1
739 {\ifx#1\relax
740 \let\next=\egroup
741 \else
742 \handlecase
743 {\expandafter\ifnum\expandafter\catcode\expandafter#1=11
744 \def\next##1\relax{\egroup\def\firstcharacter{#1}}
745 \fi}
746 \fi
747 \next}
748
749 \def\dofindfirstcharacter#1#2
750 {\def\firstcharacter{}
751 \bgroup
752 \defconvertedargument\ascii{#2}
753 \let\next\dodofindfirstcharacter
754 \let\handlecase#1
755 \expandafter\next\ascii\relax}
756
757 \def\FINDFIRSTCHARACTER
758 {\dofindfirstcharacter\uppercase}
759
760
761
762\unexpanded\def\checkCWEBindexentry#1
763 {\bgroup
764 \def\\##1{##1}
765 \def\|##1{##1}
766 \def\.##1{*##1}
767 \def\&##1{##1}
768 \def\9##1{##1}
769 \catcode*=11
770 \expandafter\def\expandafter\entry\expandafter{#1}
771 \defconvertedcommand\ascii\entry
772 \expanded{\FINDFIRSTCHARACTER{\ascii}}
773 \doifnot{\currentCWEBindexentry}{\firstcharacter}
774 {\doifnot{\firstcharacter}{*}
775 {\global\let\currentCWEBindexentry=\firstcharacter
776 \showCWEBindexentry{\currentCWEBindexentry}}}
777 \egroup}
778
779\unexpanded\def\theCWEBbeforeindex {\startcolumns}
780\unexpanded\def\theCWEBafterindex {\stopcolumns}
781
782\unexpanded\def\processCWEBindex #1
783 {\par
784 \bgroup
785 \forgetall
786 \setupalign[verytolerant,flushleft,nothyphenated]
787 \resetCWEBcontext
788 \activateCWEB
789 \resetCWEBindexentry
790 \def\I##1,
791 {\par
792 \checkCWEBindexentry{##1}
793 \hangindent2em
794 \noindent##1:\kern1em
795 \def\next####1.{\processCWEBsectionnumbers[{####1}]}
796 \next}
797 \def\[##1]
798 {$\underline{##1}$}
799 \let\*=\lapstar
800 \marking[CWEBfilename]{#1}
801 \marking[CWEBsectiontitle]{index}
802 \marking[CWEBsectionnumber]{}
803 \marking[CWEBsectiondepth]{}
804
805 \theCWEBbeforeindex
806 \ReadFile{#1.idx}\relax
807 \theCWEBafterindex
808 \par
809 \egroup}
810
811\unexpanded\def\processCWEBsections #1
812 {\par
813 \bgroup
814 \forgetall
815 \resetCWEBcontext
816 \activateCWEB
817
818 \parfillskip = 0pt plus 1fil
819 \parindent = 0pt
820 \let\topsecno=\nullsec
821 \def\note##1
822 {\quad
823 \bgroup
824 \tx
825 ##1\processCWEBsectionnotes}
826 \def\Q {\CWEBnotesfalse \note{Cited in section}}
827 \def\Qs{\CWEBnotestrue \note{Cited in sections}}
828 \def\U {\CWEBnotesfalse \note{Used in section}}
829 \def\Us{\CWEBnotestrue \note{Used in sections}}
830 \def\I {\par\hangindent 2em}
831 \let\*=*
832 \marking[CWEBfilename]{#1}
833 \marking[CWEBsectiontitle]{sections}
834 \marking[CWEBsectionnumber]{}
835 \marking[CWEBsectiondepth]{}
836
837 \ReadFile{#1.scn}\relax
838 \botofcontents
839 \par
840 \egroup}
841
842\unexpanded\def\processCWEBcontents #1
843 {\par
844 \bgroup
845 \forgetall
846 \resetCWEBcontext
847 \activateCWEB
848 \marking[CWEBfilename]{#1}
849 \marking[CWEBsectiontitle]{table of contents}
850 \marking[CWEBsectionnumber]{}
851 \marking[CWEBsectiondepth]{}
852 \forgetall
853 \placelist[cweb][criterium=all,command=\CWEBlistentry]
854 \par
855 \egroup}
856
857
858
859
860
861
862
863
864\installstructurelistprocessor{cweb}
865 {\begingroup
866 \advance\leftskip 3em
867 \advance\rightskip3em
868 \currentlistentrydestinationattribute
869 \dontleavehmode
870 \llap{\hbox \currentlistentryreferenceattribute{number} to 3em{\structurelistuservariable{section}\hss}}
871 \structurelistuservariable{title}
872 \hfill
873 \rlap{\hbox \currentlistentryreferenceattribute{page} to 3em{\hss\structurelistuservariable{depth}}}
874 \par
875 \endgroup}
876
877\endinput
878 |