home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CDPD Public Domain Collection for CDTV 3
/
CDPDIII.bin
/
pd
/
programming
/
utils
/
cweb
/
amiga
/
cwebmacg.tex
< prev
next >
Wrap
Text File
|
1993-01-21
|
13KB
|
266 lines
% standard macros for CWEB listings (in addition to plain.tex)
% Version 2.8 --- September 1992
\let\:=\. % preserve a way to get the dot accent
% (all other accents will still work as usual)
\parskip 0pt % no stretch between paragraphs
\parindent 1em % for paragraphs and for the first line of C text
\font\ninerm=cmr9
\let\mc=\ninerm % medium caps
\def\Cee{{\mc C\spacefactor1000}}
\def\UNIX{{\mc UNIX\spacefactor1000}}
\font\eightrm=cmr8
\let\sc=\eightrm % small caps (NOT a caps-and-small-caps font)
\let\mainfont=\tenrm
\font\titlefont=cmr7 scaled\magstep4 % title on the contents page
\font\ttitlefont=cmtt10 scaled\magstep2 % typewriter type in title
\font\tentex=cmtex10 % TeX extended character set (used in strings)
\fontdimen7\tentex=0pt % no double space after sentences
\def\\#1{\leavevmode\hbox{\it#1\/\kern.05em}} % italic type for identifiers
\def\|#1{\leavevmode\hbox{$#1$}} % one-letter identifiers look better this way
\def\{\leavevmode\hbox{\bf
\def\_{\kern.04em\vbox{\hrule width.3em height .6pt}\kern.08em}%
#1\/\kern.05em}} % boldface type for reserved words
\def\.#1{\leavevmode\hbox{\tentex % typewriter type for strings
\let\\=\BS % backslash in a string
\let\{=\LB % left brace in a string
\let\}=\RB % right brace in a string
\let\~=\TL % tilde in a string
\let\ =\SP % space in a string
\let\_=\UL % underline in a string
\let\&=\AM % ampersand in a string
\let\^=\CF % circumflex in a string
#1\kern.05em}}
\def\){\discretionary{\hbox{\tentex\BS}}{}{}}
\def\AT{@} % at sign for control text
\chardef\AM=`\& % ampersand character in a string
\chardef\BS=`\\ % backslash in a string
\chardef\LB=`\{ % left brace in a string
\chardef\RB=`\} % right brace in a string
\def\SP{{\tt\char`\ }} % (visible) space in a string
\chardef\TL=`\~ % tilde in a string
\chardef\UL=`\_ % underline character in a string
\chardef\CF=`\^ % circumflex character in a string
\newbox\PPbox % symbol for ++
\setbox\PPbox=\hbox{\kern.5pt\raise1pt\hbox{\sevenrm+\kern-1pt+}\kern.5pt}
\def\PP{\copy\PPbox}
\newbox\MMbox \setbox\MMbox=\hbox{\kern.5pt\raise1pt\hbox{\sevensy\char0
\kern-1pt\char0}\kern.5pt}
\def\MM{\copy\MMbox}
\newbox\MGbox % symbol for ->
\setbox\MGbox=\hbox{\kern-2pt\lower3pt\hbox{\teni\char'176}\kern1pt}
\def\MG{\copy\MGbox}
\let\GG=\gg
\let\LL=\ll
\let\NULL=\Lambda
\mathchardef\AND="2026 % bitwise and; also \& (unary operator)
\let\OR=\mid % bitwise or
\let\XOR=\oplus % bitwise exclusive or
\def\CM{{\sim}} % bitwise complement
\newbox\MODbox \setbox\MODbox=\hbox{\eightrm\%}
\def\MOD{\mathbin{\copy\MODbox}}
\newbox\bak \setbox\bak=\hbox to -1em{} % backspace one em
\newbox\bakk\setbox\bakk=\hbox to -2em{} % backspace two ems
\newcount\ind % current indentation in ems
\def\1{\global\advance\ind by1\hangindent\ind em} % indent one more notch
\def\2{\global\advance\ind by-1} % indent one less notch
\def\3#1{\hfil\penalty#10\hfilneg} % optional break within a statement
\def\4{\copy\bak} % backspace one notch
\def\5{\hfil\penalty-1\hfilneg\kern2.5em\copy\bakk\ignorespaces}% optional break
\def\6{\ifmmode\else\par % forced break
\hangindent\ind em\noindent\kern\ind em\copy\bakk\ignorespaces\fi}
\def\7{\Y\6} % forced break and a little extra space
\def\8{\hskip-\ind em\hskip 2em} % no indentation
\let\yskip=\smallskip
\def\?{\mathrel?}
\def\note#1#2.{\Y\noindent{\hangindent2em\baselineskip10pt\eightrm#1~#2.\par}}
\def\lapstar{\rlap{*}}
\def\stsec{\rightskip=0pt % get out of C mode (cf. \B)
\sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50
\noindent{\let\*=\lapstar\bf\secstar.\quad}}
\let\startsection=\stsec
\def\defin#1{\global\advance\ind by 2 \1\&{#1 } } % begin `define' or `format'
\def\A{\note{Siehe auch Abschnitt}} % xref for doubly defined section name
\def\As{\note{Siehe auch die Abschnitte}} % xref for multiply defined section name
\def\B{\rightskip=0pt plus 100pt minus 10pt % go into C mode
\sfcode`;=3000
\pretolerance 10000
\hyphenpenalty 9999 % so strings can be broken (discretionary \ is inserted)
\exhyphenpenalty 10000
\global\ind=2 \1\ \unskip}
\def\C#1{\5\5\quad$/\ast\,$#1$\,\ast/$}
\def\D{\defin{\#define}} % macro definition
\let\E=\equiv % equivalence sign
\def\ET{ und~} % conjunction between two section numbers
\def\ETs{ und~} % conjunction between the last two of several section numbers
\def\F{\defin{format}} % format definition
\let\G=\ge % greater than or equal sign
% \H is long Hungarian umlaut accent
\let\I=\ne % unequal sign
\def\J{\.{@\&}} % TANGLE's join operation
\let\K== % can be changed to left arrow, if desired
% \L is Polish letter suppressed-L; we have no shorthand for \le
\outer\def\M#1.{\MN#1.\ifon\vfil\penalty-100\vfilneg % beginning of section
\vskip12ptminus3pt\startsection\ignorespaces}
\outer\def\N#1.#2.{\MN#1.\vfil\eject % beginning of starred section
\def\rhead{\let\i=I\uppercase{\ignorespaces#2}} % define running headline
\message{*\secno} % progress report
\edef\next{\write\cont{\Z{#2}{\secno}{\the\pageno}}}\next % to contents file
\ifon\startsection{\bf\ignorespaces#2.\quad}\ignorespaces}
\def\MN#1.{\par % common code for \M, \N
{\xdef\secstar{#1}\let\*=\empty\xdef\secno{#1}}
\ifx\secno\secstar \onmaybe \else\ontrue \fi \mark{{\tensy x}\secno}}
% \O is Scandinavian letter O-with-slash
% \P is paragraph sign
\def\Q{\note{Dieser Programmteil wird zitiert in Abschnitt}} % xref for mention of a section
\def\Qs{\note{Dieser Programmteil wird zitiert in den Abschnitten}} % xref for mentions of a section
\let\R=\lnot % logical not
% \S is section sign
\def\T#1{\leavevmode % octal, hex or decimal constant
\hbox{${\def\?{\kern.2em}%
\def\${\ell}% long constant
\def\_{\cdot 10^{\aftergroup}}% power of ten (via dirty trick)
\let\~=\oct \let\^=\hex #1}$}}
\def\U{\note{Dieser Programmteil wird verwendet in Abschnitt}} % xref for use of a section
\def\Us{\note{Dieser Programmteil wird verwendet in den Abschnitten}} % xref for uses of a section
\let\V=\lor % logical or
\let\W=\land % logical and
\def\X#1:#2\X{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi % section name
\XX$\langle\,${#2\eightrm\kern.5em#1}$\,\rangle$\XX}
\def\Y{\par\yskip}
\let\Z=\let % now you can \send the control sequence \Z
\let\*=*
%\def\oct{\hbox{\rm\char'23\kern-.2em\it\aftergroup\?\aftergroup}} % WEB style
%\def\hex{\hbox{\rm\char"7D\tt\aftergroup}} % WEB style
\def\oct{\hbox{$^\circ$\kern-.1em\it\aftergroup\?\aftergroup}}% CWEB style
\def\hex{\hbox{$^{\scriptscriptstyle\#}$\tt\aftergroup}} % CWEB style
\def\vb#1{\leavevmode\hbox{\kern2pt\vrule\vtop{\vbox{\hrule
\hbox{\strut\kern2pt\.{#1}\kern2pt}}
\hrule}\vrule\kern2pt}} % verbatim string
\def\onmaybe{\let\ifon=\maybe} \let\maybe=\iftrue
\newif\ifon \newif\iftitle \newif\ifpagesaved
\def\lheader{\mainfont\the\pageno\eightrm\qquad\rhead\hfill\title\qquad
\mainfont\topmark} % top line on left-hand pages
\def\rheader{\mainfont\topmark\eightrm\qquad\title\hfill\rhead
\qquad\mainfont\the\pageno} % top line on right-hand pages
\def\nullmark{\mark{\eightrm\kern-2em}} % cancels \qquad in headers
\def\page{\box255 }
\def\normaloutput#1#2#3{\shipout\vbox{
\ifodd\pageno\hoffset=\pageshift\fi
\vbox to\fullpageheight{
\iftitle\global\titlefalse
\else\hbox to\pagewidth{\vbox to10pt{}\ifodd\pageno #3\else#2\fi}\fi
\vfill#1}} % parameter #1 is the page itself
\global\advance\pageno by1}
\def\rhead{\.{CWEB} OUTPUT} % this running head is reset by starred sections
\def\title{\expandafter\uppercase\expandafter{\jobname}}
\def\topofcontents{\centerline{\titlefont\title}
\vfill} % this material will start the table of contents page
\def\botofcontents{\vfill
\centerline{\covernote}} % this material will end the table of contents page
\def\covernote{}
\def\contentspagenumber{0} % default page number for table of contents
\newdimen\pagewidth \pagewidth=6.5in % the width of each page
\newdimen\pageheight \pageheight=8.7in % the height of each page
\newdimen\fullpageheight \fullpageheight=9in % page height including headlines
\newdimen\pageshift \pageshift=0in % shift righthand pages wrt lefthand ones
\def\magnify#1{\mag=#1\pagewidth=6.5truein\pageheight=8.7truein
\fullpageheight=9truein\setpage}
\def\setpage{\hsize\pagewidth\vsize\pageheight} % use after changing page size
\def\contentsfile{\jobname.toc} % file that gets table of contents info
\def\readcontents{\input \jobname.toc}
\newwrite\cont
\output{\setbox0=\page % the first page is garbage
\openout\cont=\contentsfile
\write\cont{\catcode `\noexpand\@=11\relax} % \makeatletter
\global\output{\normaloutput\page\lheader\rheader}}
\setpage
\vbox to \vsize{} % the first \topmark won't be null
\def\ch{\note{Die folgenden Abschnitte sind vom Change-File ver\"andert worden:}
\let\*=\relax}
\newbox\sbox % saved box preceding the index
\newbox\lbox % lefthand column in the index
\def\inx{\par\vskip6pt plus 1fil % we are beginning the index
\write\cont{} % ensure that the contents file isn't empty
\write\cont{\catcode `\noexpand\@=12\relax} % \makeatother
\closeout\cont % the contents information has been fully gathered
\output{\ifpagesaved\normaloutput{\box\sbox}\lheader\rheader\fi
\global\setbox\sbox=\page \global\pagesavedtrue}
\pagesavedfalse \eject % eject the page-so-far and predecessors
\setbox\sbox\vbox{\unvbox\sbox} % take it out of its box
\vsize=\pageheight \advance\vsize by -\ht\sbox % the remaining height
\hsize=.5\pagewidth \advance\hsize by -10pt
% column width for the index (20pt between cols)
\parfillskip 0pt plus .6\hsize % try to avoid almost empty lines
\def\lr{L} % this tells whether the left or right column is next
\output{\if L\lr\global\setbox\lbox=\page \gdef\lr{R}
\else\normaloutput{\vbox to\pageheight{\box\sbox\vss
\hbox to\pagewidth{\box\lbox\hfil\page}}}\lheader\rheader
\global\vsize\pageheight\gdef\lr{L}\global\pagesavedfalse\fi}
\message{Index:}
\parskip 0pt plus .5pt
\outer\def\I##1, {\par\hangindent2em\noindent##1:\kern1em} % index entry
\def\[##1]{$\underline{##1}$} % underlined index item
\rm \rightskip0pt plus 2.5em \tolerance 10000 \let\*=\lapstar
\hyphenpenalty 10000 \parindent0pt}
\def\fin{\par\vfill\nullmark\eject % this is done when we are ending the index
\ifpagesaved\null\vfill\eject\fi % output a null index column
\if L\lr\else\null\vfill\eject\fi % finish the current page
\parfillskip 0pt plus 1fil
\def\rhead{ABSCHNITTSNAMEN}
\message{Section names:}
\output{\normaloutput\page\lheader\rheader}
\setpage
\def\note##1##2.{\quad{\eightrm##1~##2.}}
\def\Q{\note{Zitiert in Abschnitt}} % crossref for mention of a section
\def\Qs{\note{Zitiert in den Abschnitten}} % crossref for mentions of a section
\def\U{\note{Verwendet in Abschnitt}} % crossref for use of a section
\def\Us{\note{Verwendet in den Abschnitten}} % crossref for uses of a section
\def\I{\par\hangindent 2em}\let\*=*}
\def\con{\par\vfill\eject % finish the section names
\rightskip 0pt \hyphenpenalty 50 \tolerance 200
\setpage \output={\normaloutput\page\lheader\rheader}
\titletrue % prepare to output the table of contents
\pageno=\contentspagenumber \def\rhead{INHALTSVERZEICHNIS}
\message{Table of contents:}
\topofcontents
\line{\hfil Abschnitt\hbox to3em{\hss Seite}}
\def\Z##1##2##3{\line{\ignorespaces##1
\leaders\hbox to .5em{.\hfil}\hfil\ ##2\hbox to3em{\hss##3}}}
\readcontents\relax % read the contents info
\botofcontents \end} % print the contents page(s) and terminate
\def\noinx{\let\inx=\end} % no indexes or table of contents
\def\nosecs{\let\FIN=\fin \def\fin{\let\parfillskip=\end \FIN}}
% no index of section names or table of contents
\def\nocon{\let\con=\end} % no table of contents
\def\today{\number\day. \ifcase\month\or
Januar\or Februar\or M\"arz\or April\or Mai\or Juni\or
Juli\or August\or September\or Oktober\or November\or Dezember\fi
\space\number\year}
\newcount\twodigits
\def\hours{\twodigits=\time \divide\twodigits by 60 \printtwodigits:%
\multiply\twodigits by-60 \advance\twodigits by\time \printtwodigits}
\def\gobbleone1{}
\def\printtwodigits{\advance\twodigits100
\expandafter\gobbleone\number\twodigits
\advance\twodigits-100 }
\def\TeX{{\ifmmode\it\fi
\leavevmode\hbox{T\kern-.1667em\lower.424ex\hbox{E}\hskip-.125em X}}}
\def\,{\relax\ifmmode\mskip\thinmuskip\else\thinspace\fi}
\def\datethis{\def\startsection{\leftline{\sc\today,\, \hours}\bigskip
\let\startsection=\stsec\stsec}}
% say `\datethis' in limbo, to get your listing timestamped