cwebmac.tex
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:15k
- % standard macros for CWEB listings (in addition to plain.tex)
- % Version 3.1 --- September 1994
- ifxdocumentstyleundefinedelseendinputfi % LaTeX will use other macros
- xdeffmtversion{fmtversion+CWEB3.1}
- 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
- fontninerm=cmr9
- letmc=ninerm % medium caps
- defCEE/{{mc Cspacefactor1000}}
- defUNIX/{{mc Ukern-.05emNIXspacefactor1000}}
- defTEX/{TeX}
- defCPLUSPLUS/{{mc CPPspacefactor1000}}
- defCee{CEE/} % for backward compatibility
- def9#1{}
- fonteightrm=cmr8
- letsc=eightrm % small caps (NOT a caps-and-small-caps font)
- letmainfont=tenrm
- letcmntfonttenrm
- %fonttenss=cmss10 letcmntfonttenss % alternative comment font
- fonttitlefont=cmr7 scaledmagstep4 % title on the contents page
- fontttitlefont=cmtt10 scaledmagstep2 % typewriter type in title
- fonttentex=cmtex10 % TeX extended character set (used in strings)
- fontdimen7tentex=0pt % no double space after sentences
- def\#1{leavevmodehbox{it#1/kern.05em}} % italic type for identifiers
- def|#1{leavevmodehbox{$#1$}} % one-letter identifiers look better this way
- def{leavevmodehbox{bf
- def_{kern.04emvbox{hrule width.3em height .6pt}kern.08em}%
- #1/kern.05em}} % boldface type for reserved words
- def.#1{leavevmodehbox{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
- #1kern.05em}}
- def){discretionary{hbox{tentexBS}}{}{}}
- defAT{@} % at sign for control text (not needed in versions >= 2.9)
- defATL{parnoindentbgroupcatcode`_=12 postATL} % print @l in limbo
- defpostATL#1 #2 {bf letter \{uppercase{char"#1}}
- tangles as tentex "#2"egrouppar}
- defnoATL#1 #2 {}
- defnoatl{letATL=noATL} % suppress output from @l
- defATH{Xkern-.5em:Preprocessor definitionsX}
- letPB=relax % hook for program brackets |...| in TeX part or section name
- chardefAM=`& % ampersand character in a string
- chardefBS=`\ % backslash in a string
- chardefLB=`{ % left brace in a string
- chardefRB=`} % right brace in a string
- defSP{{ttchar` }} % (visible) space in a string
- chardefTL=`~ % tilde in a string
- chardefUL=`_ % underline character in a string
- chardefCF=`^ % circumflex character in a string
- newboxPPbox % symbol for ++
- setboxPPbox=hbox{kern.5ptraise1pthbox{sevenrm+kern-1pt+}kern.5pt}
- defPP{copyPPbox}
- newboxMMbox setboxMMbox=hbox{kern.5ptraise1pthbox{sevensychar0
- kern-1ptchar0}kern.5pt}
- defMM{copyMMbox}
- newboxMGbox % symbol for ->
- setboxMGbox=hbox{kern-2ptlower3pthbox{tenichar'176}kern1pt}
- defMG{copyMGbox}
- defMRL#1{mathrel{letK==#1}}
- %defMRL#1{KK#1}defKK#1#2{buildrel;#1over{#2}}
- letGG=gg
- letLL=ll
- letNULL=Lambda
- mathchardefAND="2026 % bitwise and; also & (unary operator)
- letOR=mid % bitwise or
- letXOR=oplus % bitwise exclusive or
- defCM{{sim}} % bitwise complement
- newboxMODbox setboxMODbox=hbox{eightrm%}
- defMOD{mathbin{copyMODbox}}
- defDC{kern.1em{::}kern.1em} % symbol for ::
- defPA{mathbin{.*}} % symbol for .*
- defMGA{mathbin{MG*}} % symbol for ->*
- defthis{&{this}}
- newboxbak setboxbak=hbox to -1em{} % backspace one em
- newboxbakksetboxbakk=hbox to -2em{} % backspace two ems
- newcountind % current indentation in ems
- def1{globaladvanceind by1hangindentind em} % indent one more notch
- def2{globaladvanceind by-1} % indent one less notch
- def3#1{hfilpenalty#10hfilneg} % optional break within a statement
- def4{copybak} % backspace one notch
- def5{hfilpenalty-1hfilnegkern2.5emcopybakkignorespaces}% optional break
- def6{ifmmodeelsepar % forced break
- hangindentind emnoindentkernind emcopybakkignorespacesfi}
- def7{Y6} % forced break and a little extra space
- def8{hskip-ind emhskip 2em} % no indentation
- newcountgdepth % depth of current major group, plus one
- newcountsecpagedepth
- secpagedepth=3 % page breaks will occur for depths -1, 0, and 1
- newtoksgtitle % title of current major group
- newskipintersecskip intersecskip=12pt minus 3pt % space between sections
- letyskip=smallskip
- def?{mathrel?}
- defnote#1#2.{Ynoindent{hangindent2embaselineskip10pteightrm#1~#2.par}}
- deflapstar{rlap{*}}
- defstsec{rightskip=0pt % get out of C mode (cf. B)
- sfcode`;=1500 pretolerance 200 hyphenpenalty 50 exhyphenpenalty 50
- noindent{let*=lapstarbfsecstar.quad}}
- letstartsection=stsec
- defdefin#1{globaladvanceind by 2 1&{#1 } } % begin `define' or `format'
- defA{note{See also section}} % xref for doubly defined section name
- defAs{note{See also sections}} % xref for multiply defined section name
- defB{rightskip=0pt plus 100pt minus 10pt % go into C mode
- sfcode`;=3000
- pretolerance 10000
- hyphenpenalty 1000 % so strings can be broken (discretionary is inserted)
- exhyphenpenalty 10000
- globalind=2 1 unskip}
- defC#1{55quad$/ast,${cmntfont #1}$,ast/$}
- letSHCC % "// short comments" treated like "/* ordinary comments */"
- %defC#1{55quad$triangleright,${cmntfont#1}$,triangleleft$}
- %defSHC#1{55quad$diamond,${cmntfont#1}}
- defD{defin{#define}} % macro definition
- letE=equiv % equivalence sign
- defET{ and~} % conjunction between two section numbers
- defETs{, and~} % conjunction between the last two of several section numbers
- defF{defin{format}} % format definition
- letG=ge % greater than or equal sign
- % H is long Hungarian umlaut accent
- letI=ne % unequal sign
- defJ{.{@&}} % TANGLE's join operation
- letK== % assignment operator
- %letK=leftarrow % "honest" alternative to standard assignment operator
- % L is Polish letter suppressed-L
- outerdefM#1{MN{#1}ifonvfilpenalty-100vfilneg % beginning of section
- vskipintersecskipstartsectionignorespaces}
- outerdefN#1#2#3.{gdepth=#1gtitle={#3}MN{#2}% beginning of starred section
- ifonifnum#1<secpagedepth vfileject % force page break if depth is small
- elsevfilpenalty-100vfilnegvskipintersecskipfifi
- message{*secno} % progress report
- edefnext{writecont{ZZ{#3}{#1}{secno}% write to contents file
- {noexpandthepageno}}}next % ZZ{title}{depth}{sec}{page}
- ifonstartsection{bf#3.quad}ignorespaces}
- defMN#1{par % common code for M, N
- {xdefsecstar{#1}let*=emptyxdefsecno{#1}}% remove * from section name
- ifxsecnosecstar onmaybe elseontrue fi
- mark{{{tensy x}secno}{thegdepth}{thegtitle}}}
- % each mark is {section reference or null}{depth plus 1}{group title}
- % O is Scandinavian letter O-with-slash
- % P is paragraph sign
- defQ{note{This code is cited in section}} % xref for mention of a section
- defQs{note{This code is cited in sections}} % xref for mentions of a section
- letR=lnot % logical not
- % S is section sign
- defT#1{leavevmode % octal, hex or decimal constant
- hbox{$def?{kern.2em}%
- def$##1{egroup_{,rm##1}bgroup}% suffix to constant
- def_{cdot 10^{aftergroup}}% power of ten (via dirty trick)
- let~=oct let^=hex {#1}$}}
- defU{note{This code is used in section}} % xref for use of a section
- defUs{note{This code is used in sections}} % xref for uses of a section
- letV=lor % logical or
- letW=land % logical and
- defX#1:#2X{ifmmodegdefXX{null$null}elsegdefXX{}fi % section name
- XX$langle,${#2eightrmkern.5em#1}$,rangle$XX}
- defY{paryskip}
- letZ=le
- letZZ=let % now you can write the control sequence ZZ
- let*=*
- %defoct{hbox{rmchar'23kern-.2emitaftergroup?aftergroup}} % WEB style
- %defhex{hbox{rmchar"7Dttaftergroup}} % WEB style
- defoct{hbox{$^circ$kern-.1emitaftergroup?aftergroup}}% CWEB style
- defhex{hbox{$^{scriptscriptstyle#}$ttaftergroup}} % CWEB style
- defvb#1{leavevmodehbox{kern2ptvrulevtop{vbox{hrule
- hbox{strutkern2pt.{#1}kern2pt}}
- hrule}vrulekern2pt}} % verbatim string
- defonmaybe{letifon=maybe} letmaybe=iftrue
- newififon newififtitle newififpagesaved
- deflheader{mainfontthepagenoeightrmqquadgrouptitlehfilltitleqquad
- mainfonttopsecno} % top line on left-hand pages
- defrheader{mainfonttopsecnoeightrmqquadtitlehfillgrouptitle
- qquadmainfontthepageno} % top line on right-hand pages
- defgrouptitle{leti=Iletj=Juppercaseexpandafter{expandafter
- takethreetopmark}}
- deftopsecno{expandaftertakeonetopmark}
- deftakeone#1#2#3{#1}
- deftaketwo#1#2#3{#2}
- deftakethree#1#2#3{#3}
- defnullsec{eightrmkern-2em} % the kern-2em cancels qquad in headers
- letpage=pagebody raggedbottom
- % defpage{box255 }normalbottom % faster, but loses plain TeX footnotes
- defnormaloutput#1#2#3{ifoddpagenohoffset=pageshiftfi
- shipoutvbox{
- vbox tofullpageheight{
- iftitleglobaltitlefalse
- elsehbox topagewidth{vbox to10pt{}ifoddpageno #3else#2fi}fi
- vfill#1}} % parameter #1 is the page itself
- globaladvancepageno by1}
- gtitle={.{CWEB} output} % this running head is reset by starred sections
- mark{noexpandnullsec0{thegtitle}}
- deftitle{expandafteruppercaseexpandafter{jobname}}
- deftopofcontents{centerline{titlefonttitle}vskip.7in
- vfill} % this material will start the table of contents page
- defbotofcontents{vfill
- centerline{covernote}} % this material will end the table of contents page
- defcovernote{}
- defcontentspagenumber{0} % default page number for table of contents
- newdimenpagewidth pagewidth=6.5in % the width of each page
- newdimenpageheight pageheight=8.7in % the height of each page
- newdimenfullpageheight fullpageheight=9in % page height including headlines
- newdimenpageshift pageshift=0in % shift righthand pages wrt lefthand ones
- defmagnify#1{mag=#1pagewidth=6.5trueinpageheight=8.7truein
- fullpageheight=9trueinsetpage}
- defsetpage{hsizepagewidthvsizepageheight} % use after changing page size
- defcontentsfile{jobname.toc} % file that gets table of contents info
- defreadcontents{input contentsfile}
- defreadindex{input jobname.idx}
- defreadsections{input jobname.scn}
- newwritecont
- output{setbox0=page % the first page is garbage
- openoutcont=contentsfile
- writecont{catcode `noexpand@=11relax} % makeatletter
- globaloutput{normaloutputpagelheaderrheader}}
- setpage
- vbox to vsize{} % the first topmark won't be null
- defch{note{The following sections were changed by the change file:}
- let*=relax}
- newboxsbox % saved box preceding the index
- newboxlbox % lefthand column in the index
- definx{parvskip6pt plus 1fil % we are beginning the index
- defpage{box255 } normalbottom
- writecont{} % ensure that the contents file isn't empty
- writecont{catcode `noexpand@=12relax} % makeatother
- closeoutcont % the contents information has been fully gathered
- output{ifpagesavednormaloutput{boxsbox}lheaderrheaderfi
- globalsetboxsbox=page globalpagesavedtrue}
- pagesavedfalse eject % eject the page-so-far and predecessors
- setboxsboxvbox{unvboxsbox} % take it out of its box
- vsize=pageheight advancevsize by -htsbox % the remaining height
- hsize=.5pagewidth advancehsize by -10pt
- % column width for the index (20pt between cols)
- parfillskip 0pt plus .6hsize % try to avoid almost empty lines
- deflr{L} % this tells whether the left or right column is next
- output{if Llrglobalsetboxlbox=page gdeflr{R}
- elsenormaloutput{vbox topageheight{boxsboxvss
- hbox topagewidth{boxlboxhfilpage}}}lheaderrheader
- globalvsizepageheightgdeflr{L}globalpagesavedfalsefi}
- message{Index:}
- parskip 0pt plus .5pt
- outerdefI##1, {parhangindent2emnoindent##1:kern1em} % index entry
- def[##1]{$underline{##1}$} % underlined index item
- rm rightskip0pt plus 2.5em tolerance 10000 let*=lapstar
- hyphenpenalty 10000 parindent0pt
- readindex}
- deffin{parvfilleject % this is done when we are ending the index
- ifpagesavednullvfillejectfi % output a null index column
- if Llrelsenullvfillejectfi % finish the current page
- parfillskip 0pt plus 1fil
- defgrouptitle{NAMES OF THE SECTIONS}
- lettopsecno=nullsec
- message{Section names:}
- output={normaloutputpagelheaderrheader}
- setpage
- defnote##1##2.{quad{eightrm##1~##2.}}
- defQ{note{Cited in section}} % crossref for mention of a section
- defQs{note{Cited in sections}} % crossref for mentions of a section
- defU{note{Used in section}} % crossref for use of a section
- defUs{note{Used in sections}} % crossref for uses of a section
- defI{parhangindent 2em}let*=*
- readsections}
- defcon{parvfilleject % finish the section names
- % ifoddpagenoelsetitletruenullvfillejectfi % for duplex printers
- rightskip 0pt hyphenpenalty 50 tolerance 200
- setpage output={normaloutputpagelheaderrheader}
- titletrue % prepare to output the table of contents
- pageno=contentspagenumber
- defgrouptitle{TABLE OF CONTENTS}
- message{Table of contents:}
- topofcontents
- line{hfil Sectionhbox to3em{hss Page}}
- letZZ=contentsline
- readcontentsrelax % read the contents info
- botofcontents end} % print the contents page(s) and terminate
- defcontentsline#1#2#3#4{ifnum#2=0 smallbreakfi
- line{consetup{#2}#1
- rmleadershbox to .5em{.hfil}hfil #3hbox to3em{hss#4}}}
- defconsetup#1{ifcase#1 bf % depth -1 (@**)
- or % depth 0 (@*)
- or hskip2em % depth 1 (@*1)
- or hskip4em % depth 2 (@*2)
- or hskip6em % depth 3 (@*3)
- or hskip8em % depth 4 (@*4)
- or hskip10em % depth 5 (@*5)
- else hskip12em fi} % depth 6 or more
- defnoinx{letinx=end} % no indexes or table of contents
- defnosecs{letFIN=fin deffin{letparfillskip=end FIN}}
- % no index of section names or table of contents
- defnocon{letcon=end} % no table of contents
- deftoday{ifcasemonthor
- Januaryor Februaryor Marchor Aprilor Mayor Juneor
- Julyor Augustor Septemberor Octoberor Novemberor Decemberfi
- spacenumberday, numberyear}
- newcounttwodigits
- defhours{twodigits=time dividetwodigits by 60 printtwodigits
- multiplytwodigits by-60 advancetwodigits bytime :printtwodigits}
- defgobbleone1{}
- defprinttwodigits{advancetwodigits100
- expandaftergobbleonenumbertwodigits
- advancetwodigits-100 }
- defTeX{{ifmmodeitfi
- leavevmodehbox{Tkern-.1667emlower.424exhbox{E}hskip-.125em X}}}
- def,{relaxifmmodemskipthinmuskipelsethinspacefi}
- defdatethis{defstartsection{leftline{sctoday at hours}bigskip
- letstartsection=stsecstsec}}
- % say `datethis' in limbo, to get your listing timestamped before section 1
- defdatecontentspage{%
- deftopofcontents{leftline{sctoday at hours}bigskip
- centerline{titlefonttitle}vfill}} % timestamps the contents page