% pdccode.tex 1.6 1995/03/30 -- self-documenting TeX macros

%%%@TeX-definition-file {
%%% filename       = "$texmf/tex/plain/pdcmac/pdccode.tex",
%%% version        = "1.6",
%%% date           = "1995/03/30",
%%% package        = "pdcmac 1.0",
%%% author         = "P. Damian Cugley",
%%% email          = "damian.cugley@comlab.ox.ac.uk",
%%% address        = "Oxford University Computing Laboratory,
%%%                   Parks Road, Oxford  OX1 3QD, UK",
%%% codetable      = "USASCII",
%%% keywords       = "TeX, plain TeX, macros",
%%% supported      = "Maybe",
%%% abstract       = "Macros for documented TeX macros (DTX files).
%%%                   This file was generated by running
%%%                   plain TeX on pdccode.dtx",
%%% copyright      = "Copyright (c) 1991-1995 P. Damian Cugley",
%%% copying        = "DO NOT DISTRIBUTE THIS FILE.
%%%                   Distribute pdccode.dtx only as part of the
%%%                   package it came in.",
%%% dependencies   = "",
%%% }

\message{1.6 <pdc 1995/03/30>}

\toksdef\toksa=0
\def\rcs#1: #2,v #3 #4 #5 #6 #7 #8$#9\endrcs{
    \def\filename{#2}
    \def\fileversion{#3}
    \def\filedate{#4}
    \def\fileauthor{#6}
    \def\filelocker{#8}
}
\def\declareactivechar#1{%
    \toksa\expandafter{\verbatimplains\do#1}%
    \edef\verbatimplains{\the\toksa }%
    \catcode`#1\active
}
\def\verbatimplains{\do\\\do\{\do\}\do\_\do\$\do\#\do\&\do\%}
\def\verbatimactives{\do\`\do\'\do\~\do\^\do\ }
\chardef\other=12
\newtoks\everyverbatim
\bgroup \catcode`\^=13 \catcode`\'=13 \catcode`\`=13 \toksa={\egroup
    \def\setupverbatim{%
        \frenchspacing
        \spaceskip0pt \xspaceskip0pt % use spacing of font
        \def\do##1{\catcode\lq##112 }\verbatimplains
        \def\do##1{\catcode\lq##1\active }\verbatimactives
        \let`\ttlq \let'\ttrq
        \let~\tttilde \let^\ttcircum
        \the\everyverbatim
    }
}\the\toksa
\def\ttlq{\lower0.125ex \hbox{\char18 }}
\def\ttrq{\lower0.125ex \hbox{\char19 }}
\def\tttilde{\lower0.5ex \hbox{\char`\~ }}
\def\ttcircum{\lower0.5ex \hbox{\char`\^ }}
\def\defverbatim#1{%
    \ifcat\noexpand#1\noexpand~\else \declareactivechar#1 \fi
    \begingroup \uccode`\~=`#1 \uppercase{\toksa={\endgroup
        \def~{%
            \leavevmode
            \begingroup \tt \setupverbatim
            \catcode`#1\active \let~\endgroup
       }%
    }}\the\toksa
}
\defverbatim\|
\hyphenchar\tentt=-1
\newwrite\CODEwrite
\def\codefile#1{
    \ifeof\CODEwrite\else \endcodefile \fi
    \def\thecodefile{#1} \openout\CODEwrite=#1
}
\def\endcodefile{
    \message{Code written on \thecodefile.}
    \closeout\CODEwrite
}
\def\code{
    \smallskip
    \begingroup
    \let|\CODEline \let\|\CODElinex
    \let\{=\CODElb \let\}=\CODErb \let\\=\CODEbslash
    \def~{ } \let\~\CODEtilde
    \the\everycode
    \obeylines
}
\def\endcode{
    \smallbreak
    \endgroup
}
\def\CODEline{%
    \begingroup % matched by \CODElinei
    \setupverbatim \catcode`\|\other
    \CODElinei
}
\begingroup\catcode`\'=\active \catcode`\`=\active
            \catcode\lq\@=\catcode\lq\^ \catcode\lq\^=\active
            \catcode\lq\@@M=\active \toksa={\endgroup %
    \def\CODElinei#1@@M{%
        \begingroup\let`\lq \let'\rq %
            \let^\CODEcircum \let~ \CODEtilde%
            \edef\tmp{#1}%
            \write\CODEwrite\expandafter{\tmp}%
        \endgroup %
        \indent\the\everycodeline #1\par %
        \endgroup % matches \CODEline
    }%
}\the\toksa
\begingroup\catcode`\^^M=13 \toksa={\endgroup %
    \def\CODElinex#1^^M{%
        \edef\tmp{\write\CODEwrite{#1}}\tmp %
        {\indent\the\everycodeline #1\par}%
    }%
} \the\toksa
\begingroup\catcode`\/=0 \catcode`\\=\other /toksa={/endgroup
    /def/CODEbslash{\}
}/the/toksa
\begingroup\catcode`\^=\other \toksa={\endgroup
    \def\CODEcircum{^}
}\the\toksa
\begingroup\catcode`\~=\other \toksa={\endgroup
    \def\CODEtilde{~}
}\the\toksa
\begingroup\catcode`\%=\other \toksa={\endgroup
    \def\%{%}
}\the\toksa
\begingroup\catcode`\~=\other \toksa={\endgroup
    \def\CODEtilde{~}
}\the\toksa
\begingroup\catcode`\[=1 \catcode`\]=2
        \catcode`\{=\other \catcode`\}=\other
        \toksa=[\endgroup
    \def\CODElb[{] \def\CODErb[}]
]\the\toksa
\newtoks\everycode
\newtoks\everycodeline
\everycode{\tt \baselineskip=0.8\baselineskip \lineskiplimit=0pt }
\newcount\lineno
\everycodeline{\llap{$ \global\advance\lineno1
        \scriptstyle\the\lineno $\enspace}%
        \mark\expandafter{\the\lineno}}
\let\document\relax \let\enddocument\relax
\lefthyphenmin=3 \righthyphenmin=2 \errorcontextlines10000
\parindent=2em \hsize=36\fontdimen6\tentt \advance\hsize\parindent
\hoffset=210mm \advance\hoffset-\hsize \advance\hoffset-25mm
\newdimen\leftmargin \leftmargin=\hoffset \advance\leftmargin-25mm
\advance\hoffset-1in
\voffset=297mm \advance\voffset-11in
\advance\voffset7mm \advance\voffset20pt
\vsize=297mm \advance\vsize-2\voffset \advance\vsize-2\baselineskip
\advance\voffset-1in
\def\do#1{\fontdimen3#1=0pt \fontdimen4#1=0pt }
\do\tenrm \do\tenit \do\tenbf
\rightskip=0pt plus 2em minus 2pt \adjdemerits=0 \tolerance=500
\parfillskip=0pt plus 0.8\hsize
\def\author#1{\def\theauthor{#1}} \author{P. Damian Cugley}
\font\titlefont=cmssbx10 scaled \magstep3
\def\title#1{
    \vglue2\baselineskip
    \begingroup \parindent-\leftmargin \hyphenpenalty10000 \titlefont
 #1\smallskip
    \endgroup
    \leftline{Version \fileversion,
        last changed \fileauthor\space \mungedate\filedate}
    \ifx\filelocker\empty\else
        \leftline{Edited by \filelocker\unskip\ \today}
    \fi
    \medskip
    \hrule \vskip1pt \hrule \vskip1pt \hrule \vskip1pt \hrule
    \medskip
    \rightline{\theauthor}
    \bigskip
    \headline{\hfil\global\headline{%
        \sevenbf \hskip-\leftmargin \themarks \hfil #1
        \fileversion
        \ifx\filelocker\empty
            \space\mungedate\filedate
        \else
            e\space\today
        \fi
    }}
}
\def\themarks{%
    \ifx\firstmark\empty\else
        \firstmark
        \ifx\firstmark\botmark \else --\botmark \fi
    \fi
}
\def\today{\mungedate{\number\year/\twodigits\month/\twodigits\day}}
\def\twodigits#1{\ifnum#1<10 0\fi \number#1}
\def\mungedate#1{$ \textfont0=\font \mathcode`/="7B #1 $}
\font\secfont=cmssdc10 at 12pt
\font\subsecfont=cmssi10
\newcount\seccount
\newcount\subseccount
\def\section#1{%
    \advance\seccount1 \subseccount=0
    \bigbreak
    \begingroup
        \secfont \hyphenpenalty=10000 \tolerance=1000
        \rightskip=0pt plus 2em
        \noindent\llap{\number\seccount.\enspace}#1
        \medskip
    \endgroup
    \noindenttrue
}
\def\subsec#1{%
    \advance\subseccount1
    \medbreak
    \begingroup
        \subsecfont \hyphenpenalty=10000 \tolerance=1000
        \rightskip=0pt plus 2em
        \noindent\llap{\number\seccount.%
            \number\subseccount.\enspace}#1
        \nobreak\smallskip
    \endgroup
    \noindenttrue
}
\newif\ifnoindent
\everypar{%
    \ifnoindent
        {\setbox0=\lastbox}\global\noindentfalse
    \fi
}
\newskip\footnoterightskip \footnoterightskip=\rightskip
\catcode`@=11
\def\vfootnote#1{\insert\footins\bgroup
  \interlinepenalty\interfootnotelinepenalty
  \splittopskip\ht\strutbox % top baseline for broken footnotes
  \splitmaxdepth\dp\strutbox \floatingpenalty\@MM
  \leftskip\z@skip \rightskip\footnoterightskip
  \spaceskip\z@skip \xspaceskip\z@skip \rm
  \textindent{#1}\footstrut\futurelet\next\fo@t}
\catcode`@=11
\def\<#1>{\leavevmode\hbox{$\langle$\it#1\/$\rangle$}}
\def\cs#1{\leavevmode\hbox{\tt\char`\\#1}}
\def\arg#1{\leavevmode\hbox{{\tt\char`\{}#1{\tt\char`\}}}}
\def\pt{\,{\rm pt}} \def\em{\,{\rm em}} \def\mm{\,{\rm mm}}
\def\inch{''}
\def\flushtop#1{%
    \leavevmode
    \begingroup
        \setbox0=\hbox{#1}\setbox2=\hbox{X}%
        \dimen0=\ht2 \advance\dimen0-\ht0
        \raise\dimen0 \box0
    \endgroup
}
\def\TeX{T\kern-0.1em \lower0.5ex \hbox{E}X\spacefactor1000 }
\def\LaTeX{L\kern-0.1em \flushtop{a}\TeX}
\def\notepar{
    \smallskip
    \begingroup
    \leftskip2\parindent \advance\rightskip\parindent minus \parindent
    \noindent\kern-\parindent{\bf Note}\quad\it
    \ignorespaces
}
\def\endnotepar{
    \smallbreak
    \endgroup
}
\endinput
