% Copyright 2012-2014, Alexander Shibakov
% This file is part of SPLinT
%
% SPLinT is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% SPLinT is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with SPLinT.  If not, see <http://www.gnu.org/licenses/>.

% limbo.sty version 2.3

\input epsf.tex
\input amssym.def

\catcode`\@=11 % a name space protection measure (weak)

% fonts
\font\tenboldi=cmbxti10
\font\nineboldi=cmbxti9
\font\eightboldi=cmbxti8
\font\sevenboldi=cmbxti7
\font\sixboldi=cmbxti6
\font\fiveboldi=cmbxti5

\font\twelvebi=cmmib10 at 12pt
\font\tenbi=cmmib10
\font\tencyr=lhr10
\font\ninebi=cmmib9
\font\sevenbi=cmmib7
\font\sixbi=cmmib6
\font\twelvebsy=cmbsy10 at 12pt
\font\ninebsy=cmbsy9
\font\sevenbsy=cmbsy7

\font\twelvei=cmmi10 at 12pt
\font\ninei=cmmi9
\font\twelvesy=cmsy10 at 12pt
\font\ninesy=cmsy9

\font\twelvetitle=cmssbx12
\font\tentitle=cmssbx10
\font\tentitlei=cmssbxo10
\font\ninetitle=cmssbx9
\font\eighttitle=cmssbx8
\font\seventitle=cmssbx7
\font\titlefrak=eufb10 at 12pt

\font\twelvetitleit=cmssbxo10 at 12pt
\font\ninetitleit=cmssbxo10 at 9pt
\font\seventitleit=cmssbxo10 at 7pt

\font\authorfont=cmssqi8
\font\affiliationfont=cmssq8
\font\timefont=cmss7
\font\keywordsfn=cmssbx8

\font\tentex=cmtex10

\font\inchhigh=cminch
\font\titlefont=cmssdc10 at 40pt

\font\ninerm=cmr9
\font\eightrm=cmr8
\font\sevenrm=cmr7
\font\ninecyr=lhr9
\font\eightcyr=lhr8
\font\sevencyr=lhr7
\font\sixrm=cmr6

\font\ninei=cmmi9
\font\eighti=cmmi8
\font\sixi=cmmi6
\skewchar\ninei='177 \skewchar\eighti='177 \skewchar\sixi='177

\font\ninesy=cmsy9
\font\eightsy=cmsy8
\font\sixsy=cmsy6
\skewchar\ninesy='60 \skewchar\eightsy='60 \skewchar\sixsy='60

\font\eightss=cmssq8

\font\eightssi=cmssqi8

\font\twelvebf=cmbx12
\font\ninebf=cmbx9
\font\eightbf=cmbx8
\font\sixbf=cmbx6

\font\ninett=cmtt9
\font\eighttt=cmtt8
\font\seventt=cmtt7

\hyphenchar\tentt=-1 % inhibit hyphenation in typewriter type
\hyphenchar\ninett=-1
\hyphenchar\eighttt=-1

\font\ninesl=cmsl9
\font\eightsl=cmsl8
\font\sevensl=cmsl7

\font\nineit=cmti9
\font\eightit=cmti8
\font\sevenit=cmti7
\font\sixit=cmti6
\font\fiveit=cmti5

\font\twelvemsam=msam10 at 12pt
\font\tenmsam=msam10
\font\ninemsam=msam9
\font\eightmsam=msam8
\font\sevenmsam=msam7
\font\sixmsam=msam6
\font\fivemsam=msam5

\font\twelvemsbm=msbm10 at 12pt
\font\tenmsbm=msbm10
\font\ninemsbm=msbm9
\font\eightmsbm=msbm8
\font\sevenmsbm=msbm7
\font\sixmsbm=msbm6
\font\fivemsbm=msbm5

\font\tenfrak=eufm10
\font\ninefrak=eufm9
\font\eightfrak=eufm8
\font\sevenfrak=eufm7

\font\hv=phvr

\newfam\itbfam
\newfam\frakfam
\newfam\msbmfam
\newfam\msamfam

% take `<=' and `>=' from Euler ...
% but this will be changed back in the title due to 
% the absence of the bold version

\mathchardef\leq="3\hexnumber@\msamfam36 \let\le=\leq
\mathchardef\geq="3\hexnumber@\msamfam3E \let\ge=\geq
\mathchardef\emptyset="0\hexnumber@\msbfam3F

% left and right `french quotes' (guillemots); the characters reside in lhr fonts

\chardef\lqq='375
\chardef\rqq='376

\def\cdotfill{\cleaders\hbox {$\m@th \mkern .5mu\cdot\mkern .5mu$}\hfill}
\def\dinkus{$\ast\ast\ast$}
\def\asterism{\setbox0\hbox{$\ast$}\copy0 \kern-.3\wd0 \raise\ht0 \copy0 \kern-.3\wd0 \copy0 }

\newskip\ttglue
\def\tenpoint{\def\rm{\fam0\tenrm}%
  \textfont0=\tenrm \scriptfont0=\sevenrm \scriptscriptfont0=\fiverm
  \textfont1=\teni \scriptfont1=\seveni \scriptscriptfont1=\fivei
  \textfont2=\tensy \scriptfont2=\sevensy \scriptscriptfont2=\fivesy
  \textfont3=\tenex \scriptfont3=\tenex \scriptscriptfont3=\tenex
  \def\it{\fam\itfam\tenit}%
  \textfont\itfam=\tenit\scriptfont\itfam=\sevenit
   \scriptscriptfont\itfam=\fiveit
  \def\itbold{\fam\itbfam\tenboldi}%
  \textfont\itbfam=\tenboldi\scriptfont\itfam=\sevenboldi
   \scriptscriptfont\itbfam=\fiveboldi
  \def\sl{\fam\slfam\tensl}%
  \textfont\slfam=\tensl
  \def\bf{\fam\bffam\tenbf}%
  \textfont\bffam=\tenbf \scriptfont\bffam=\sevenbf
   \scriptscriptfont\bffam=\fivebf
  \def\tt{\fam\ttfam\tentt 
    \let\{=\LB % left brace in a string
    \let\}=\RB % right brace in a string
  }%
  \def\ttl{\let\it\tentitlei\let\sl\tentitlei\tentitle}%
  \textfont\ttfam=\tentt
  \tt \ttglue=.5em plus.25em minus.15em
  \def\Bbb{\fam\msbmfam\tenmsbm}%
  \textfont\msbmfam=\tenmsbm\scriptfont\msbmfam=\sevenmsbm \scriptscriptfont\msbmfam=\fivemsbm
  \textfont\msamfam=\tenmsam\scriptfont\msamfam=\sevenmsam 
  \scriptscriptfont\msamfam=\fivemsam
  \textfont\frakfam=\tenfrak
  \def\frak##1{{\fam\frakfam\tenfrak ##1}}%
  \normalbaselineskip=12pt
  \let\sc=\eightrm
  \let\mc=\ninerm
  \let\cyr=\tencyr
  \let\big=\tenbig
  \setbox\strutbox=\hbox{\vrule height8.5pt depth3.5pt width0pt}%
  \normalbaselines\rm}

\def\ninepoint{\def\rm{\fam0\ninerm}%
  \textfont0=\ninerm \scriptfont0=\sixrm \scriptscriptfont0=\fiverm
  \textfont1=\ninei \scriptfont1=\sixi \scriptscriptfont1=\fivei
  \textfont2=\ninesy \scriptfont2=\sixsy \scriptscriptfont2=\fivesy
  \textfont3=\tenex \scriptfont3=\tenex \scriptscriptfont3=\tenex
  \def\it{\fam\itfam\nineit}%
  \textfont\itfam=\nineit\scriptfont\itfam=\sixit
  \def\itbold{\fam\itbfam\nineboldi}%
  \textfont\itbfam=\nineboldi\scriptfont\itfam=\sixboldi
  \def\sl{\fam\slfam\ninesl}%
  \textfont\slfam=\ninesl
  \def\bf{\fam\bffam\ninebf}%
  \textfont\bffam=\ninebf \scriptfont\bffam=\sixbf
   \scriptscriptfont\bffam=\fivebf
  \def\tt{\fam\ttfam\ninett
    \let\{=\LB % left brace in a string
    \let\}=\RB % right brace in a string
  }%
  \textfont\ttfam=\ninett
  \tt \ttglue=.5em plus.25em minus.15em
  \def\Bbb{\fam\msbmfam\ninemsbm}%
  \textfont\msbmfam=\ninemsbm\scriptfont\msbmfam=\sixmsbm \scriptscriptfont\msbmfam=\fivemsbm
  \textfont\msamfam=\ninemsam\scriptfont\msamfam=\sixmsam 
  \scriptscriptfont\msamfam=\fivemsam
  \textfont\frakfam=\ninefrak
  \def\frak##1{{\fam\frakfam\ninefrak ##1}}%
  \normalbaselineskip=11pt
  \let\sc=\sevenrm
  \let\mc=\eightrm
  \let\cyr=\ninecyr
  \let\big=\ninebig
  \setbox\strutbox=\hbox{\vrule height8pt depth3pt width0pt}%
  \normalbaselines\rm}

\def\eightpoint{\def\rm{\fam0\eightrm}%
  \textfont0=\eightrm \scriptfont0=\sixrm \scriptscriptfont0=\fiverm
  \textfont1=\eighti \scriptfont1=\sixi \scriptscriptfont1=\fivei
  \textfont2=\eightsy \scriptfont2=\sixsy \scriptscriptfont2=\fivesy
  \textfont3=\tenex \scriptfont3=\tenex \scriptscriptfont3=\tenex
  \def\it{\fam\itfam\eightit}%
  \def\itbold{\fam\itbfam\eightboldi}%
  \textfont\itfam=\eightit
  \def\sl{\fam\slfam\eightsl}%
  \textfont\slfam=\eightsl
  \def\bf{\fam\bffam\eightbf}%
  \textfont\bffam=\eightbf \scriptfont\bffam=\sixbf
   \scriptscriptfont\bffam=\fivebf
  \def\tt{\fam\ttfam\eighttt
    \let\{=\LB % left brace in a string
    \let\}=\RB % right brace in a string
  }%
  \textfont\ttfam=\eighttt
  \tt \ttglue=.5em plus.25em minus.15em
  \def\Bbb{\fam\msbmfam\eightmsbm}%
  \textfont\msbmfam=\eightmsbm\scriptfont\msbmfam=\sixmsbm \scriptscriptfont\msbmfam=\fivemsbm
  \textfont\msamfam=\eightmsam\scriptfont\msamfam=\sixmsam 
  \scriptscriptfont\msamfam=\fivemsam
  \textfont\frakfam=\eightfrak
  \def\frak##1{{\fam\frakfam\eightfrak ##1}}%
  \normalbaselineskip=9pt
  \let\sc=\sixrm
  \let\mc=\sevenrm
  \let\cyr=\eightcyr
  \let\big=\eightbig
  \setbox\strutbox=\hbox{\vrule height7pt depth2pt width0pt}%
  \normalbaselines\rm}

\def\sevenpoint{\def\rm{\fam0\sevenrm}%
  \textfont0=\sevenrm \scriptfont0=\sixrm \scriptscriptfont0=\fiverm
  \textfont1=\seveni \scriptfont1=\sixi \scriptscriptfont1=\fivei
  \textfont2=\sevensy \scriptfont2=\sixsy \scriptscriptfont2=\fivesy
  \textfont3=\tenex \scriptfont3=\tenex \scriptscriptfont3=\tenex
  \def\it{\fam\itfam\sevenit}%
  \def\itbold{\fam\itbfam\sevenboldi}%
  \textfont\itfam=\sevenit
  \def\sl{\fam\slfam\sevensl}%
  \textfont\slfam=\sevensl
  \def\bf{\fam\bffam\sevenbf}%
  \textfont\bffam=\sevenbf \scriptfont\bffam=\sixbf\scriptscriptfont\bffam=\fivebf
  \def\tt{\fam\ttfam\seventt
    \let\{=\LB % left brace in a string
    \let\}=\RB % right brace in a string
  }%
  \textfont\ttfam=\seventt
  \tt \ttglue=.5em plus.25em minus.15em
  \def\Bbb{\fam\msbmfam\sevenmsbm}%
  \textfont\msbmfam=\sevenmsbm\scriptfont\msbmfam=\sixmsbm \scriptscriptfont\msbmfam=\fivemsbm
  \textfont\msamfam=\sevenmsam\scriptfont\msamfam=\sixmsam 
  \scriptscriptfont\msamfam=\fivemsam
  \textfont\frakfam=\sevenfrak
  \def\frak##1{{\fam\frakfam\sevenfrak ##1}}%
  \normalbaselineskip=8pt
  \let\sc=\sixrm
  \let\mc=\sixrm
  \let\big=\sevenbig
  \setbox\strutbox=\hbox{\vrule height6pt depth2pt width0pt}%
  \normalbaselines\rm}

% temporary registers

\input trt1.sty

% we can prevent acrobat from defaulting to
% the "shrink to printable area" setting, which causes an 8.5"\times11" page to shrink
% by about 6\% to fit onto the printable region of the physical printer;
% this macro was contributed by Jeff Norden. 

\ifx\pdfcatalog\UNDEFINED\else
 \pdfcatalog{/ViewerPreferences<</PrintScaling/None>>}%
\fi

% a slightly involved way of determining whether we are making a pdf file is
% due to the fact that pdftex can output dvi files as well.

\newif\ifmakepdf

\ifx\pdfoutput\undefined
  \makepdffalse
\else
  \ifnum\pdfoutput>\z@ 
    \makepdftrue
  \else
    \makepdffalse
  \fi
\fi

% cleaning up whitespace

\newif\ifspaceleft

\def\removewhitespace{% a macro that removes glue, kerns, and
		      % penalties before the current point
  \loop\spaceleftfalse\unwhitespaceonce\ifspaceleft\repeat
}

\def\unwhitespaceonce{%
\ifhmode
    \ifdim\lastskip=\z@\else\unskip\spacelefttrue\fi
    \ifdim\lastkern=\z@\else\unkern\spacelefttrue\fi
    \ifnum\lastpenalty=\z@\else\unpenalty\spacelefttrue\fi
\fi}

% color management

% remember the cmyk color in an impossible control sequence

\def\colordef#1#2{\expandafter\def\csname cmykc@l@r #1\endcsname{#2}}

% color switch: we maintain our own color stack for pdf output;
% newer versions of pdf\TeX\ have `proper' color stack primitives
% which provide a more reliable implementation (across page breaks
% and inside insertions, for example) 

\def\colorset#1{\begingroup
  \ifmakepdf
    \expandafter\let\expandafter\currentc@l@r\csname cmykc@l@r #1\endcsname
    \edef\next{\noexpand\pdfliteral{\csname cmykc@l@r #1\endcsname\space k}}\next
  \else
    \special{ps:gsave}%
    \edef\next{\special{ps:\csname cmykc@l@r #1\endcsname\space setcmykcolor}}\next
  \fi
}

\def\currentc@l@r{1 1 1 1} % start out black

\def\quickcolordef#1#2{\colordef{#1}{#2}%
  \expandafter\def\csname color#1\endcsname##1{\colorset{#1}##1\restorecolor}}

\def\grayset#1{\begingroup
  \ifmakepdf
    \def\currentc@l@r##1k{#1 g}% so we can use \restoreco...
    \pdfliteral{#1 g}%
  \else
    \special{ps:gsave}\special{ps:#1 setgray}%
  \fi
}

\def\restorecolor{\endgroup
  \ifmakepdf
    \expandafter\pdfliteral\expandafter{\currentc@l@r\space k}%
  \else
    \special{ps:grestore}%
  \fi
}

% macros to provide pdf references to outside documents as well as inside the code

\def\locallink#1{%
  \ifmakepdf\colorset{link}\pdfstartlink attr {/Border [0 0 0]} goto name {#1}\fi}

\def\exlinkpage#1#2#3{\colorset{link}%
  \ifmakepdf\pdfstartlink attr {/Border [0 0 0]} goto file {#1} page #2 {#3}\fi}

\def\endlink{\ifmakepdf\pdfendlink\restorecolor\fi}

\def\namedspot#1{\ifmakepdf
  % raise the reference to make sure that the viewer window shows the
  % whole line in which the reference occurs
  \raise\ht\strutbox\vbox to 0pt{\vss\hbox to 0pt{\pdfdest name {#1} xyz}}%
\fi}

% macros to typeset hex values in customized form (useful when typesetting embedded code)

% the line translator: take a sequence of tokens and translate it into another sequence
%   #1 is the sequence of tokens (will be expanded) to insert at the beginning
%   #2 is the sequence of tokens (will be expanded) to insert before every token in the sequence
%   #3 is the first sequence of tokens (will be expanded) to insert between tokens in the sequence
%   #4 is the second sequence of tokens (will be expanded) to insert between tokens in the sequence
%   #5 is the sequence of tokens (will be expanded) to insert at the end
%   #6 is the command to execute after each token
%   #7 is original sequence
%   #8 is the resulting sequence

\def\linetranslator#1#2#3#4#5#6:#7>#8{%
  \def\ins@rt{#2}\def\insert@{#3}\def\@insert{#4}%
  \def\@nd{#5}\def\c@mmand{#6}\let\t@kens#8%
  \edef\next{\t@kens{\the\t@kens#1}}\next
  \expandafter\linetr@nslator\the#7\end}

\def\linetr@nslator#1#2{%
  \ifx#1\end
    \let\next\relax % no more tokens left
  \else
    \ifx#2\end % #1 is the last token
      \edef\next{\t@kens{\the\t@kens\ins@rt#1\@nd}}\next
    \else
      \edef\next{\t@kens{\the\t@kens\ins@rt#1\insert@\@insert}}\next
      \c@mmand
    \fi
    \let\next\linetr@nslator
  \fi\next#2
}

% the mask translator: take a sequence of pairs {length:number}{contents} and translate it into another sequence
%   #1 is the sequence of tokens (will be expanded) to insert at the beginning
%   #2 is the sequence of tokens (will be expanded) to insert before every pair in the sequence
%   #3 is the first sequence of tokens (will be expanded) to insert between pairs in the sequence
%   #4 is the second sequence of tokens (will be expanded) to insert between pairs in the sequence
%   #5 is the sequence of tokens (will be expanded) to insert at the end
%   #6 is the command to execute after each pair
%   #7 is original sequence
%   #8 is the resulting sequence

\def\masktranslator#1#2#3#4#5#6:#7>#8{%
  \def\ins@rt{#2}\def\insert@{#3}\def\@insert{#4}%
  \def\@nd{#5}\def\c@mmand{#6}\let\t@kens#8%
  \edef\next{\t@kens{\the\t@kens#1}}\next
  \m@sktranslator#7{"40000000}\relax\relax}

\def\m@sktranslator#1#2#3{%
  \ifnum#1<"40000000 % only happens when there are no pairs
    \ifnum#3<"40000000 % not the last pair
      \edef\next{\t@kens{\the\t@kens\ins@rt{#1}{#2}\insert@\@insert}}\next
      \c@mmand    
      \let\next\m@sktranslator
    \else
      \edef\next{\t@kens{\the\t@kens\ins@rt{#1}{#2}\@nd}}\next
      \let\next\m@sktr@nslator
    \fi
  \else
    \let\next\m@sktr@nslator
  \fi
  \next{#3}%
}

\def\m@sktr@nslator#1{}

% binary converter

\def\binary#1{%
  \ifx#1\end 
    \let\next\relax 
  \else 
    \bin@ry#1\let\next\binary
  \fi\next}

\let\bits\toksa % storage for binary conversion bits
\newtoks\bytes % storage for the binary representation
\let\quotient\tempca
\let\oldquotient\tempcb

\def\bin@ry#1{\tempcc=4 \quotient="#1 \oldquotient=\quotient 
\loop \divide\quotient by2 \multiply\quotient by2 \advance\oldquotient by-\quotient
  \advance\tempcc by\m@ne
  \edef\next{\bits{\the\oldquotient\the\bits}}\next
  \divide\quotient by2 \oldquotient=\quotient
\ifnum\tempcc > \z@
\repeat
\edef\next{\bytes{\the\bytes\the\bits}}\next
\bits{}}

% display macros:
%
%   o registers

\newtoks\digittable % the table representing the register
\newcount\columncount % counter for the current column

%   o fonts 

\font\fivessb=phvb at4pt

%   o generic control sequences

\def\incrementcc{\advance\columncount by\@ne}
\def\decrementcc{\advance\columncount by\m@ne}

%   o mask highlighting

% the strange looking definition of \m@skspan originates from \multispan in plain.tex:
%  \newcount\mscount
%  \def\multispan#1{\omit \mscount#1\relax
%    \loop\ifnum\mscount>\@ne \sp@n\repeat}
%  \def\sp@n{\span\omit\advance\mscount\m@ne}
%
% the number of `physical' columns to span is (2 * columns - 1) due to the fact that we 
% have to span the gaps between columns as well.

\def\m@skspan#1#2{%
  \multispan{#1\advance\mscount by\mscount\advance\mscount by-1}{\vrule\highltcl{\leaders\hrule height 4pt\hfil}\vrule}%
}

%   o mask underlining

\def\m@sksp@n#1#2{%
  \multispan{#1\advance\mscount by\mscount\advance\mscount by-1}{\hrulefill}%
}

%   o mask legend typesetting

\def\m@sklegend#1#2{%
  \multispan{#1\advance\mscount by\mscount\advance\mscount by-1}{\hfil\lgndcl{\fivessb#2}\hfil}%
}

%   o displaying each digit

\def\dgtdispl@y#1#2{%
  \ifx#20%
    \let\colorbg\lightcl\let\colord\darkcl
  \else
    \let\colorbg\darkcl\let\colord\lightcl
  \fi
  \vrule\colorbg{\vrule height4pt width 12.5pt}%
  \llap{\raise.6pt\hbox{\colord{\fivessb#1}$\,$}}\vrule
}

%   o typesetting space between digits

\def\c@lumnspacer#1{\tempca#1\tempcb\tempca\divide\tempca by8\multiply\tempca by8
  \ifnum\tempca=\tempcb
    \middlediamond
  \else
    \tempca#1\tempcb\tempca\divide\tempca by4\multiply\tempca by4
    \ifnum\tempca=\tempcb
      \middledot
    \else
      \hfil
    \fi
  \fi}

%     oo dimond to separate bytes

\def\middlediamond{\setbox0=\hbox{$\scriptscriptstyle\diamond$}\tempda=4pt \advance\tempda by-\ht0
  \divide\tempda by2 \hss\raise\tempda\box0\hss}%

%     oo dot to separate nybbles

\def\middledot{\setbox0=\hbox{.}\tempda=4pt \advance\tempda by-\ht0
  \divide\tempda by2 \hss\raise\tempda\box0\hss}%

%   o put it all together

\let\stcr\cr % so that this can be used inside \tabalign which redef's \cr

\def\regdisplay#1#2{{%
  \binary#1\end
  \linetranslator{}{\hrulefill\noexpand\eatone}{&$\,\,$}{&}{\stcr}{\incrementcc}:\bytes>\digittable
  \linetranslator{}{\noexpand\dgtdispl@y{\the\columncount}}{&\noexpand\c@lumnspacer{\the\columncount}}{&}%
    {\stcr}{\decrementcc}:\bytes>\digittable
  \masktranslator{}{\noexpand\m@sksp@n}{&\hfil}{&}{\stcr}{\relax}:{#2}>\digittable
  \masktranslator{}{\noexpand\m@skspan}{&\hfil}{&}{\stcr}{\relax}:{#2}>\digittable
  \masktranslator{}{\noexpand\m@sksp@n}{&\hfil}{&}{\stcr}{\relax}:{#2}>\digittable
  \expandafter\digittable\expandafter{\the\digittable\noalign{\vskip-3.8pt}}%
  \masktranslator{}{\noexpand\m@sklegend}{&\hfil}{&}{\stcr}{\relax}:{#2}>\digittable
  \vbox{\offinterlineskip
    \halign{&##\stcr
      \the\digittable
    }
  }%
}}

% an alternate display

\def\altmiddledot{\setbox0=\hbox{.}%
  \tempda=\ht\thezero \advance\tempda by-\ht0
  \divide\tempda by2 \advance\tempda by -\dp\thezero
  $\,$\raise\tempda\box0$\,$%
}

\def\altmiddlediamond{\setbox0=\hbox{$\scriptscriptstyle\diamond$}%
  \tempda=\ht\thezero \advance\tempda by-\ht0
  \divide\tempda by2 \advance\tempda by -\dp\thezero
  \hss\raise\tempda\box0\hss
}

\def\altdgtdispl@y#1#2{%
  \ifx#20%
    \let\colorbg\lightcl\let\colord\darkcl
  \else
    \let\colorbg\darkcl\let\colord\lightcl
  \fi
  \setbox0=\hbox{$\,$0$\,$}\tempda\ht0
  \advance\tempda by 2pt \ht0\tempda
  \vrule\colorbg{\lower1pt\hbox{\vrule height\ht0 depth\dp0 width \wd0}}%
  \llap{\colord{\raise.5pt\hbox{\fivessb#1$\,$}}}\vrule
}

\def\altc@lumnspacer#1{\tempca#1\tempcb\tempca
  \divide\tempca by4\multiply\tempca by4
  \ifnum\tempca=\tempcb
    \ %
  \else
    \kern1pt%
  \fi
}

\def\bytedisplay#1{{%
  \binary#1\end
  \linetranslator{}{\hrulefill\noexpand\eatone}{&\hfil}{&}{\stcr}{\incrementcc}:\bytes>\digittable
  \linetranslator{}{\noexpand\altdgtdispl@y{\the\columncount}}{&\noexpand\altc@lumnspacer{\the\columncount}}{&}%
    {\stcr}{\decrementcc}:\bytes>\digittable
  \linetranslator{}{\hrulefill\noexpand\eatone}{&\hfil}{&}{\stcr}{\incrementcc}:\bytes>\digittable
  \lower\dp\thezero\vbox{\offinterlineskip
    \halign{&##\stcr
      \the\digittable
    }
  }%
}}

\quickcolordef{peach}{0 0.06 0.14 0}
\quickcolordef{corn}{0 0.06 0.63 0.02}
\quickcolordef{sandybrown}{0 0.33 0.61 0.04}
\quickcolordef{darkwood}{0 0.29 0.5 0.48}
\quickcolordef{link}{0 0 1 0.30}

\def\colorblack#1{\grayset{0}#1\restorecolor}
\def\colorwhite#1{\grayset{1}#1\restorecolor}
\def\colorgray#1{\grayset{.5}#1\restorecolor}

\newif\iffullcolorpalette
\fullcolorpalettetrue

\iffullcolorpalette
  \let\lightcl=\colorpeach
  \let\shadedcl=\colorcorn
  \let\highltcl=\colorgray
  \let\lgndcl=\colorwhite
\else
  \let\lightcl=\colorwhite
  \let\shadedcl=\colorgray
  \let\highltcl=\colorwhite
  \let\lgndcl=\colorblack
%  \let\colorlinkstart=\begingroup
%  \let\colorlinkend=\endgroup
\fi
  \let\darkcl=\colorblack

% macros to typeset the hex numbers in `graphic' format

\newtoks\registerlegend

\def\registerdisplay#1\end{\edef\next{\the\registerlegend}%
  \ifx\next\empty
    \edef\next{\noexpand\bytedisplay{#1}}\next
  \else
    \edef\next{\noexpand\regdisplay{#1}{\the\registerlegend}}\next
  \fi  
}

\newbox\thezero

\setbox\thezero=\hbox{\lower1pt\hbox{\vbox{\offinterlineskip
\halign{#&$\,$#$\,$&#\cr
\noalign{\hrule}
\omit\vrule height1pt&&\omit\vrule height1pt\cr
\vrule&\phantom0&\vrule\cr
\omit\vrule height1pt&&\omit\vrule height1pt\cr
\noalign{\hrule}
}}}}

\def\texbinary{\global\let\oldT\T
  \global\def\T##1{{\let\end\relax\let\^\registerdisplay##1\end{\tt :}\let\^\hexify##1\end}}}

\def\endtexbinary{\global\let\T\oldT}

\def\hexify#1\end{\hbox{{\tt #1}$_{\scriptscriptstyle1\kern-.7pt6}$}}

% verbatim listing macros borrowed (with changes) from The TeXbook

\newcount\democodelc

\chardef\other=12
\def\ttverbatim{\begingroup
  \catcode`\\=\other
  \catcode`\{=\other
  \catcode`\}=\other
  \catcode`\$=\other
  \catcode`\&=\other
  \catcode`\#=\other
  \catcode`\%=\other
  \catcode`\~=\other
  \catcode`\_=\other
  \catcode`\|=\other
  \obeyspaces \obeylines \tt \ttglue=.5em plus.25em minus.15em }

{\catcode`\^=\active \catcode`\*=7 \obeylines
 \gdef^{\leavevmode\ttverbatim \spaceskip\ttglue \def**M{\endgroup\cr}\let^=\endgroup}}

\def\beginlines{\begingroup\parindent0pt \obeylines \everypar{\strut}\catcode`\^=\active}
\def\endlines{\endgroup}

\def\paddednumber#1{\ifnum #1 < 10 0\number#1\relax\else \number#1\fi}

% demo code display
% **H will produce a `|', **K can be used as an escape character, **L and **N 
% can be used i place of left and right braces to provide some control

{\catcode`\ =\active\gdef {\phantom{\char"20\relax}}\catcode`\^^H=\active\gdef^^H{\yl}}%

\newif\ifnumberlines

\def\begindemo{%
  \medskip
  \bgroup
  \def\linenoup{%
    \global\advance\democodelc by1 
    \ifnumberlines{\sevenrm\paddednumber\democodelc}\fi}
  \def\nooutput{\omit\hfil{\sevenrm\strut[more code $\ldots$]}\hfil\cr\noalign{\kern3pt}}
  \catcode`\^=\active\democodelc=0 \catcode`\*=7
  \chardef\*=`\*%
  \catcode`\^^H=\active % ^^H
  \catcode`\^^K=0 \catcode`\^^L=1 \catcode`\^^N=2
  \tabskip=0pt plus 1 fill 
  \halign \demoastyle\bgroup\linenoup\hskip\demomargin ##\hfil\hskip\demomargin%
  \ifnumberlines{\sevenrm\paddednumber\democodelc}\fi\cr%
}

\def\enddemo{\egroup\egroup\medskip\noindent}

\newskip\demomargin
\demomargin=3em

\def\demoastyle{to\hsize}

% macros to provide some primitive alignment

\def\texalignment{\setbox0\lastbox\setbox0\lastbox\unkern\begingroup\settabs 3 \columns
\let\C\tabC\let\8\tabalign\def\5{\relax\ifmmode\oopsamp\else\clearamp\fi}\def\6{\strut\cr}}

\def\oopsamp{$&$}
\def\clearamp{&}

\def\texalignmentshort{\setbox0\lastbox\setbox0\lastbox\unkern\begingroup\settabs 2 \columns
  \let\C\tabC\let\8\tabalign\def\5{\ifmmode\oopsamp\else\clearamp\fi}\def\6{\strut\cr}}

\def\endtexalignment{\vskip-\baselineskip\strut\endgroup}

\def\eatcr#1\6{\ignorespaces}

\newtoks\postlimbotoks

\def\postlimbostuff{%
}

\def\picture#1{\ifmakepdf\pdfximage{#1.pdf}\pdfrefximage\pdflastximage
  \else
  \epsfbox{#1.eps}\fi
}

\let\yl| % to use in \TeX\ mode instead of `|'
\def\greaterthan{>} % CTANGLE always leaves a space after `>' in the output which interferes with some macros

% redefinitions of various CWEB macros;

% macros that provide a way to customize printing of reserved words

\newtoks\tempseq
\tempseq={RVD}
\let\oldamp\&
\let\oldoneletterid\|
\def\replaceunderscore#1{\let\next\replaceunderscore
                         \ifx#1\_\tempseq=\expandafter{\the\tempseq x}\else
                           \ifx#1\#\tempseq=\expandafter{\the\tempseq H}\else
                             \ifx#1\end\let\next\relax\else\tempseq=\expandafter{\the\tempseq #1}\fi
                           \fi
                         \fi\next}
\def\reservedid#1{{\replaceunderscore#1\end
           \expandafter\let\expandafter\newseq\csname\the\tempseq\endcsname
         \ifx\relax\newseq\oldamp{#1}\else\newseq\fi}}

\def\reservedoneletterid#1{{%
    \expandafter\let\expandafter\newseq\csname\the\tempseq\string#1\endcsname
        \ifx\relax\newseq\oldoneletterid{#1}\else\newseq\fi}}

\def\defreserved#1{%
    \expandafter\def\csname\the\tempseq #1\endcsname
}

\let\&\reservedid
\let\|\reservedoneletterid

% cweb macros adopted to making typesetting languages other than C possible: Makefile and linker scripts.

\tempca=\catcode`\^^I% remember the old catcode
\catcode`\^^I=\active
\def\vb{\begingroup\catcode`\^^I=\active\vvb} % give the tab a chance to change its catcode before the argumen is scanned
\def\vvb#1{{%
  \hbox{\vbox{\tentex
  \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\ =\space % space in a string
  \let\_=\UL % underline in a string
  \let\&=\AM % ampersand in a string
  \let\^=\CF % circumflex in a string
  \let\$=\oldmathS % dollar sign
  \def^^I{$\llcorner$&$\lrcorner$}% a tab is a tab
  \tabalign{}#1\cr}}}\endgroup} % verbatim string
\catcode`\^^I=\tempca

\def\hex{\hbox{\tt\aftergroup}\aftergroup\hexsubscript}
\def\hexsubscript{\hbox{$_{\scriptscriptstyle1\kern-.7pt6}$}}
\let\K=\Leftarrow
\setbox\MGbox=\hbox{\hbox{\ninei\char'053}}
\def\R{\hbox{$^{\rm not}$}}
\let\CM\lnot
\def\MRL#1{\KK#1}\def\KK#1#2{\buildrel\;{\let\OR\lor\scriptscriptstyle#1}\over#2}
\def\C#1{\5\5\quad$\triangleright\,${\rm #1}$\,\triangleleft$}
\let\Z=\leq \let\G=\geq
\let\E==

\def\tabC#1{\quad$\triangleright\,${\cmntfont#1}$\,\triangleleft$}

% better `hash'

\let\oldhash\#
\def\#{\lower.5pt\hbox{\.{\oldhash}}}

\def\.#1{\leavevmode\hbox{\tt % 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
  \let\uscore\_\chardef\_=`\_%
  #1\kern.05em}}

% macros to change the appearance of section headers

\outer\def\N#1#2#3.{% beginning of starred section
  \ifacro{\toksF={}\makeoutlinetoks#3\outlinedone\outlinedone}\fi
  \gdepth=#1\gtitle={#3}\MN{#2}%
  \ifon\ifnum#1<\secpagedepth \vfil\eject % force page break if depth is small
    \else\vfil\penalty-100\vfilneg\vskip\intersecskip\fi\fi
  \message{*\secno} % progress report
  \def\stripprefix##1>{}\def\gtitletoks{#3}%
  \edef\gtitletoks{\expandafter\stripprefix\meaning\gtitletoks}%
  \edef\next{\write\cont{%\noexpand\noexpand\noexpand\eatone{\noexpand\meaning\noexpand\ZZ}%
              \noexpand\noexpand\noexpand % AS this is a (sort of) bug in cwebmac.tex
                                          % as long as the index is output (i.e. ...\eject) 
                                          % before all the sections this is unnecessary
                                          % uncomment the line after the brace to see what \ZZ
                                          % expands to in case of weird errors
              \ZZ{\gtitletoks}{#1}{\secno}% write to contents file
   {\noexpand\the\pageno}{\the\toksE}}}\next % \ZZ{title}{depth}{sec}{page}{ss}
  \ifpdftex\expandafter\xdef\csname curr#1\endcsname{\secno}%
    \ifnum#1>0\countB=#1 \advance\countB by-1
      \advancenumber{chunk\the\countB.\expnumber{curr\the\countB}}\fi\fi
  \ifpdf\special{pdf: outline #1 << /Title (\the\toksE) /Dest
    [ @thispage /FitH @ypos ] >>}\fi
  \ifon\startsection{\ttl#3.\ }\ignorespaces} % changed the font; AS

\let\oldN\N

\outer\def\textN#1#2#3.{% beginning of starred section in `text' mode
  \ifacro{\toksF={}\makeoutlinetoks#3\outlinedone\outlinedone}\fi
  \gdepth=#1\gtitle={#3}\MN{#2}%
  \ifon
      \ifnum#1<2
          \vfil\eject % force page break for chapters
      \else
          \vskip0pt plus 3.5\baselineskip\penalty-100\vskip0pt plus -3.5\baselineskip\vskip\intersecskip % no page break
      \fi
  \fi
  \message{*\secno} % progress report
  \def\stripprefix##1>{}\def\gtitletoks{#3}%
  \edef\gtitletoks{\expandafter\stripprefix\meaning\gtitletoks}%
  \edef\next{\write\cont{%\noexpand\noexpand\noexpand\eatone{\noexpand\meaning\noexpand\ZZ}%
              \noexpand\noexpand\noexpand % AS this is a (sort of) bug in cwebmac.tex
                                          % as long as the index is output (i.e. ...\eject) 
                                          % before all the sections this is unnecessary
                                          % uncomment the line after the brace to see what \ZZ
                                          % expands to in case of weird errors
              \ZZ{\gtitletoks}{#1}{\secno}% write to contents file
   {\noexpand\the\pageno}{\the\toksE}}}\next % \ZZ{title}{depth}{sec}{page}{ss}
  \ifpdftex\expandafter\xdef\csname curr#1\endcsname{\secno}%
    \ifnum#1>0\countB=#1 \advance\countB by-1
      \advancenumber{chunk\the\countB.\expnumber{curr\the\countB}}\fi\fi
  \ifpdf\special{pdf: outline #1 << /Title (\the\toksE) /Dest
    [ @thispage /FitH @ypos ] >>}\fi
  \ifon\startsection{\ttl#3}\smallskip\noindent\ignorespaces} 

\outer\def\textM#1{\MN{#1}\ifon\vskip0pt plus 3\baselineskip\penalty-100\vskip0pt plus -3\baselineskip % no page break
  \vskip\intersecskip\startsection\ignorespaces}

\def\MN#1{\par % common code for \M, \N
  {\xdef\secstar{#1}\let\*=\empty\xdef\secno{#1}}% remove \* from section name
  \ifx\secno\secstar \onmaybe \else\ontrue \fi
  \mark{{\secno}{\the\gdepth}{\the\gtitle}}} % remove the annoying
                                             % `paragraph' sign; AS

% a new start section macro: fix the extra space bug and push the setion number to the margins

\def\stseclap{\rightskip=0pt % get out of C mode (cf. \B)
  \sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50
  \noindent{\let\*=\lapstar\llap{\tentitle\secstar\quad}}% push it to the margins
  \ifpdftex\smash{\raise\baselineskip\hbox to0pt{%
     \let\*=\empty\ifmakepdf\pdfdest num \secstar fith\fi}}% this space is a bug in the original cwebmac.tex; AS
  \else\ifpdf\smash{\raise\baselineskip\hbox to0pt{%
     \let\*=\empty\special{%
       pdf: dest (\romannumeral\secstar) [ @thispage /FitH @ypos ]}}}\fi\fi}

\let\startsection\stseclap

% make page and sectoin number hang in the margins; \quad is chosen to
% be consistent with section appearance; the page numbers are printed
% in old-style numerals;

\def\lheader{\headertrue\llap{\mainfont\oldstyle\the\pageno\tentitle\quad}\eightpoint\rm\grouptitle
  \hfill\title\rlap{\tentitle\quad\tenpoint$^{\hbox{\sevenrm\topsecno}}_{\hbox{\sevenrm\botsecno}}$}} % top line on left-hand pages
\def\rheader{\headertrue
\llap{\tenpoint$^{\hbox{\sevenrm\topsecno}}_{\hbox{\sevenrm\botsecno}}$\tentitle\quad}% 
\eightpoint\rm\title\hfill
  \grouptitle\rlap{\tentitle\quad\mainfont\oldstyle\the\pageno}} % top line on right-hand pages

\def\botsecno{\expandafter\takeone\botmark} % the first section on the
                                            % next page

% from time to time, entries must be omitted from the index;
% the macros below implement a mechanism to do that

\newif\ifisindexable

\def\setindexable#1{%
    \isindexabletrue
    \expandafter\s@tindexable\expandafter{\unindexable}{#1}%
}

\def\s@tindexable#1#2{%
    \s@t@ndexable{#2}#1.\end
}

\def\s@t@ndexable#1#2#3\end{%
    \def\next{#1}%
    \def\nnext{#2}%
    \ifx\next\nnext
       \isindexablefalse
       \yybreak\eattoend
   \else
       \def\next{#3}%
       \ifx\next\dotcontainer
           \yybreak@\eattoend
       \else
           \yybreak@\s@t@ndexable
       \fi
   \yycontinue
   {#1}#3\end
}

\def\inxmod{%
  \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
  \message{Index:}
  \medskip
  \eightpoint\raggedright
  \fnotesstart=2
  \fnotesspan=1
  \noofcolumns=3
  \icgap=5pt%
  \linecount=3
  \setmcparams
  \dsskip=0pt%
  \adjskip=0pt plus 9pt%
  \def\unindexable{{$\TeXx$}}%
  \def\I##1, ##2.{%
      {%
          \setindexable{##1}%
          \ifisindexable
          \else
              \aftergroup\eatone
          \fi          
      }%
      {%
          \hangindent1em\noindent##1:\kern.5em
              \ifacro\pdfnote##2.\else##2\fi.%
          \par
      }%
  }%
  % indexing macros for grammar terms
  \def\termidstring##1{%
      \numberstochars##1\end
      \let\optstrextra\optstrextraesc
      \expandafter\nameproc\expandafter{\the\toksa}%
      \def\idxentry{{\it\the\toksa}}%
  }%
  \let\termhdrstring\termidstring
  \def\termstring##1{%
      \numberstochars##1\end
      \let\optstrextra\optstrextraesc
      \expandafter\nameproc\expandafter{\the\toksa}%
      \def\idxentry{{\tt"\the\toksa"}}%
  }%
  \def\texcsstring##1{%
      \numberstochars##1\end
      \def\idxentry{%
          \def\texnspace{index}%
          \def\getcescape{% an \ seen is really an \, and will not go through C string processing
              \def\next{escape}%
              \action\next\in\currentstate
          }
          \termindexfalse\expandafter\inlineTeXx\expandafter{\expandafter/\the\toksa}%
      }%
  }%
  \expandafter\def\csname acharswitch:index\endcsname{% correct reserved \TeX\ characters a la CWEB verbatim
      _$\#\%^&\ \\{%$
          \yybyte\expandafter{\csname \the\yybyte\endcsname}%
          \expandafter\yycp@\expandafter`\the\yybyte\relax
          \mkpurebyte
          \let\next\yyreturn
       }
  }%
  \expandafter\setspecialcharsfrom\csname acharswitch:index\endcsname
  \expandafter\let\expandafter\acharswitch\csname acharswitch:index\endcsname
  \def\texlexer{% now that all character codes are 12
      \let\default\yygetchar
      \let\next\yycp@
      \ifnum\yycp@>"3F %
          \ifnum\yycp@<"5B % an uppercase letter or @
                  \def\next{letter}%
          \fi
      \fi
      \ifnum\yycp@>"60 %
          \ifnum\yycp@<"7B % 
                  \def\next{letter}%
          \fi
      \fi
      \action\next\in\currentstate
  }%
  \def\indexseparator##1##2{%
      \vskip.5\baselineskip
      \centerline{\dinkus}%
      \vskip.5\baselineskip
  }
  \def\GI##1##2##3##4.{%
      {%
          \def\hostparsernamespace{##1}%
          \toksa{}##2{##3}%
          \I{\idxentry}##4.%
      }%
  }%
  % end indexing macros for grammar terms
  \let\*=\lapstar
  \def\[##1]{{\it##1}} % definitions
  \def\(##1){$\underline{##1}$} % underlined index item
  \def\e##1e{##1{\sevenpoint$^\circ$}} % terms in examples
  \def\f##1f{{\it##1\/\kern.2ex}${}^\circ$} % lhs in examples (italic correction does not seem to be enough)
  \def\g##1g{$\underline{##1}^\circ$} % definitions in examples
  \begindoublecols
  \readindex
  \par
  \vskip.5\baselineskip
  \centerline{B{\sc ISON AND} \TeX\ {\sc INDEX}}%
  \vskip.5\baselineskip
  \par
  \readgindex
}

\def\finmod{%
  \enddoublecols
  \closeout\exampletable
  \unsetfootnotes
  \parfillskip 0pt plus 1fil
  \def\grouptitle{NAMES OF THE SECTIONS}
  \let\topsecno=\nullsec
  \message{Section names:}
  \setpage
  \def\note##1##2.{\quad{\eightrm##1~\ifacro{\pdfnote##2.}\else{##2}\fi.}}
  \def\Q{\note{Cited in section}} % crossref for mention of a section
  \def\Qs{\note{Cited in sections}} % crossref for mentions of a section
  \def\U{\note{Used in section}} % crossref for use of a section
  \def\Us{\note{Used in sections}} % crossref for uses of a section
  \def\I{\par\hangindent 2em}\let\*=*
  \ifacro 
      \def\outsecname{Names of the sections} 
      \let\Xpdf\X
      %
      \ifpdftex 
          \makebookmarks
          \pdfdest name {NOS} fitb
          \pdfoutline goto name {NOS} count -\secno {\outsecname}
          \def\X##1:##2\X{\Xpdf##1:##2\X \firstsecno##1.%
          {\toksF={}\makeoutlinetoks##2\outlinedone\outlinedone}%
          \pdfoutline goto num \the\toksA \expandafter{\the\toksE}}
      \else
          \ifpdf
              \special{pdf: outline -1 << /Title (\outsecname)
                       /Dest [ @thispage /FitH @ypos ] >>}
              \def\X##1:##2\X{\Xpdf##1:##2\X \firstsecno##1.%
              {\toksF={}\makeoutlinetoks##2\outlinedone\outlinedone}%
              \special{pdf: outline 0 << /Title (\the\toksE)
                       /A << /S /GoTo /D (\romannumeral\the\toksA) >> >>}}
          \fi
      \fi
  \fi
  %
  \bigskip
  \vskip0pt plus 5pt
  \penalty-10
  \tenpoint
  \centerline{\sc A LIST OF ALL SECTIONS}
  \penalty300
  \medskip
  \readsections
}

\newread\trygindex

\def\readgindex{%
  \openin\trygindex=\jobname.gdy
  \ifeof\trygindex
  \else
      \closein\trygindex
      \input \jobname.gdy
  \fi
}

% main section macro

\let\oldB\B

\def\Bprod#1#2{% \Cee\ mode and defines mess us up so we handle defines automatically
               % but the \Cee\ mode has to be dealt with in each case
  \let\B@\B@@
  \ifx#1\D
      \let\B@\oldB
  \fi
  \ifx#2\D
      \let\B@\oldB
  \fi
  \B@#1#2%
}

% stage one macros for `\B' sections: collecting tokens

\newif\ifvbsection
\newif\ifmathy
\newtoks\bsectiontoks

\def\gettovb#1\vb{\table{}\bsectiontoks{#1}\setbox0=\vbox{#1\checkmathy}\futurelet\next\g@ttovb}

\def\checkmathy{%
  \ifmmode
      {}$\aftergroup\mathytrue%$
  \else
      \aftergroup\mathyfalse
  \fi
}

\def\g@ttovb{%
  \ifx\next\bgroup
      \vbsectiontrue
      \ifmathy
          \bsectiontoks\expandafter{\the\bsectiontoks{}$}%$
          \def\next{\vb{}${}\vb}%$
      \else
          \def\next{\vb}%
      \fi
  \else
      \vbsectionfalse
      \let\next\eatone
  \fi
  \next
}

\long\def\prodvvb#1{% the \endgroup finishes the \begingroup inserted by \vb
  \endgroup\toksa{#1}\concat\table\toksa
  \grabintervbjunk}

\long\def\grabintervbjunk#1\vb{\processintervb{#1}\futurelet\next\castgrabber}

\long\def\processintervb#1{%
  \toksa{\ignorespaces#1}\long\edef\next{\table{\the\table\noexpand\stashed{\the\toksa}}}\next
}

\def\castgrabber{%
  \ifx\next\end
      \let\next\eattoend
  \else
      \let\next\vb
  \fi
  \next
}

% commonly used names

\def\CWEB{\.{CWEB}}\def\CTANGLE{\.{CTANGLE}}\def\CWEAVE{\.{CWEAVE}}
\def\splint{\.{SPLinT}}
\def\POSIX{{\sc POSIX}}
\def\ISO{{\mc ISO}}
\def\bison{\.{bison}}
\def\flex{\.{flex}}
\def\gcc{\.{gcc}}
% from tugboat.cmn
\newbox\TestBox
\def\La{\tempca=\the\fam \leavevmode L%
        \setbox\TestBox=\hbox{$\fam\tempca\scriptstyle A$}%
        \kern-.5\wd\TestBox\raise.42ex\box\TestBox}
\def\LaTeX{\La\kern-.15em\TeX}

\def\sqbullet{\kern.3ex\vrule height .9ex width .8ex depth -.1ex }% square bullet (from manmac.tex)

\def\sqebullet{% empty square bullet
    \kern.3ex\vbox{\hsize=.8ex
        \hrule height .4pt
        \kern-.4pt
        \hbox to\hsize{\vrule height .9ex \hfill\vrule height .9ex} 
        \kern-.4pt
        \hrule height .4pt
        \kern.1ex
    }%
}

% debugging

\def\shownethe#1{%
    \edef\next{\the#1}%
    \ifx\next\empty
    \else
        \showthe#1%
    \fi
}

\def\showem#1#2#3{\toksa{#1}\toksb{#2}\toksc{#3}{\newlinechar=`^^J%
    \errmessage{%
        arg. 1: \the\toksa^^J%
        arg. 2: \the\toksb^^J%
        arg. 3: \the\toksc%
}}}

% sugar

\def\FOREVER{{\bf forever}}

% delay functions prettyprinting and other miscellanea;

\def\delayhalfsec{\hbox{wait \kern-.5pt\raise1pt\hbox{$\scriptstyle1$}%
\kern-1pt/\kern-1pt\lower1pt\hbox{$\scriptstyle2$} sec, }}
\def\delayquartersec{\hbox{wait \kern-.5pt\raise1pt\hbox{$\scriptstyle1$}%
\kern-1pt/\kern-1pt\lower1pt\hbox{$\scriptstyle4$} sec, }}

\def\delay#1sec{%
\hbox{\def\secmult{}wait
\getsecmult#1\end
\if\secmult u\def\secmodifier{ $\mu$\kern.05pt }\else
\if\secmult m\def\secmodifier{ m}\else
\if\secmult n\def\secmodifier{ n}\else
 \secmult\def\secmodifier{ }%
\fi\fi\fi
\secmodifier sec$\rm\scriptstyle s$, }
}

\def\getsecmult#1{%
\ifx#1\end\let\next\relax\else
 \secmult\def\secmult{#1}\let\next\getsecmult
\fi\next
}

% attribute prettyprinting;

\long\def\parseattrib#1#2\end{\csname attrib#1\endcsname}

\def\xxattributexx#1{\ifx(#1\let\next\xxattributex\else\let\next\xxattribute\fi\next#1}
\def\xxattributex((\\#1{%
  \expandafter\let\expandafter\currentattrib\csname attrib#1\endcsname
  \ifx\currentattrib\attribpacked
    \strut\colorblack{%
      \lower2pt\hbox{\vrule width \wd\thezero height 
         \ht\thezero depth
         \dp\thezero}}\llap{\colorwhite{\hbox{$\scriptscriptstyle\bf 01\kern.5pt$}}}%
    \let\next\eatparentheses
  \fi  
  \ifx\currentattrib\attribnoinline 
    {\ \bf noinline\rm_a}%
    \let\next\eatparentheses
  \fi  
  \ifx\currentattrib\attribformat 
    {\ \bf format\rm_a}%
    \let\next\eatarguments
  \fi  
  \next
}

\def\eatparentheses#1)){}
\def\eatarguments(\\#1,#2,#3))){(\hbox{\rm as }\.{#1})}

\def\xxattribute#1{\.{\_\_attribute\_\_} (\sc GNU) #1}

\let\attribnoinline=1
\let\attribpacked=2
\let\attribformat=3

\tenpoint
%\registerlegend{{8}{\noexpand\phantom{B}}}
