diff options
Diffstat (limited to 'web/pwebmac/pwebmac.tex')
-rw-r--r-- | web/pwebmac/pwebmac.tex | 126 |
1 files changed, 68 insertions, 58 deletions
diff --git a/web/pwebmac/pwebmac.tex b/web/pwebmac/pwebmac.tex index 01bba0e19f..50070a7dc2 100644 --- a/web/pwebmac/pwebmac.tex +++ b/web/pwebmac/pwebmac.tex @@ -5,7 +5,7 @@ % macro integration \`a la CWEB by Andreas Scherer <andreas_tex@freenet.de>. % This file is not copyrighted and can be used freely. \ifx\renewenvironment\undefined\else\endinput\fi % LaTeX will use other macros -\xdef\fmtversion{\fmtversion+PWEBMAC4.12} +\xdef\fmtversion{\fmtversion+PWEBMAC5.0} \parskip 0pt % no stretch between paragraphs \parindent 1em % for paragraphs and for the first line of Pascal text @@ -74,8 +74,8 @@ \newtoks\toksA \newtoks\toksB \newtoks\toksC \newtoks\toksD \newtoks\toksE \newtoks\toksF \newtoks\usersanitizer \newcount\countA \countA=0 \newcount\countB \countB=0 -\newcount\countC \countC=0 \newcount\countD \countD=0 -\newif\iftokprocessed \newif\ifTnum \newif\ifinstr +\newcount\countNOS \countNOS=0 +\newif\iftokprocessed \newif\ifTnum \newif\ifinstr \newif\ifhavenum {\def\\{\global\let\spacechar= }\\ } % Here we decide the output format, depending on the TeX engine in use: @@ -89,8 +89,7 @@ \newif\ifpdflua \ifluatex\pdfluatrue\fi \ifpdftex\pdfluatrue\fi \ifpdflua % pdfTeX and luaTeX produce PDF output if \pdfoutput>0 (default) \def\Black{\pdfliteral{0 g 0 G}} % use rgb colors for direct PDF output too - \def\Blue{\pdfliteral{\pdflinkcolor\space rg \pdflinkcolor\space RG}} -\fi + \def\Blue{\pdfliteral{\pdflinkcolor\space rg \pdflinkcolor\space RG}} \fi \ifluatex % LuaTeX is almost like pdfTeX \protected\def\pdfliteral {\pdfextension literal} @@ -108,28 +107,56 @@ \let\pdfoutput=\outputmode \fi % end of LuaTeX->pdfTeX redirection macros +\ifacrohint % Common macros for \ifpdf and \ifhint for \pdflink's +\def\pdfnote#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}\maketoks}\the\toksA} +\def\firstsecno#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}% + \def\makenote{\addtokens\toksB{\the\toksC}\def\makenote{\let\space\empty + \toksC={}\toksD={}}\makenote}\maketoks}} +\def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} +\def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}% + \ifcat\noexpand\first0\countB=`#1\else\countB=0\fi} +\def\maketoks{\expandafter\poptoks\the\toksA|ENDTOKS|% + \let\next=\maketoks % continue processing by default + \ifnum\countB>`9 \countB=0 \fi + \ifnum\countB<`0 + \ifhavenum\makenote\fi + \ifx\first.\let\next=\maketoksdone % fullstop + \else \addtokens\toksB{\the\toksD} + \ifx\first,\addtokens\toksB{\space}\fi + \fi + \else \addtokens\toksC{\the\toksD}\global\havenumtrue + \fi + \next +} +\def\makenote{\addtokens\toksB + {\noexpand\pdflink{\the\toksC}}\toksC={}\global\havenumfalse} +\def\maketoksdone{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} +\fi % End of common pdf/hint macros + \ifpdf % The following are general pdf macros from 'cwebmac.tex 3.70' \def\thewidth{\the\wd0 \space} \def\theheight{\the\ht\strutbox\space} \def\thedepth{\the\dp\strutbox\space} \ifpdflua \ifx\pdfannotlink\undefined\let\pdfannotlink\pdfstartlink\fi% for pdfTeX 0.14 - \def\pdflink#1#2{\hbox{\pdfannotlink height \theheight depth \thedepth + \def\pdflink#1{\hbox{\pdfannotlink height \theheight depth \thedepth attr{/Border [0 0 0]} goto num #1 \Blue #1\Black\pdfendlink}} -\else\def\pdflink#1#2{\setbox0=\hbox{\special{pdf: bc [ \pdflinkcolor ]}{#1}% +\else\def\pdflink#1{\setbox0=\hbox{\special{pdf: bc [ \pdflinkcolor ]}{#1}% \special{pdf: ec}}\special{pdf: ann width \thewidth height \theheight - depth \thedepth << /Type /Annot /Subtype /Link - /Border [0 0 0] /A << /S /GoTo /D (#2) >> >>}\box0\relax}\fi + depth \thedepth << /Type /Annot /Subtype /Link /Border [0 0 0] + /A << /S /GoTo /D (\romannumeral#1) >> >>}\box0\relax}\fi \def\sanitizecommand#1#2{\addtokens\usersanitizer {\noexpand\dosanitizecommand\noexpand#1{#2}}} \def\dosanitizecommand#1#2{\ifx\nxt#1\addF{#2}\fi} +\ifhint\else\sanitizecommand\to{..}\fi % a trivial example; requires \addtokens \catcode`\[=1 \catcode`\]=2 \catcode`\{=12 \catcode`\}=12 \def\lbchar[{] \def\rbchar[}] \catcode`\[=12 \catcode`\]=12 \catcode`\{=1 \catcode`\}=2 \catcode`\~=12 \def\tildechar{~} \catcode`\~=13 \catcode`\|=0 |catcode`|\=12 |def|bschar{\} |catcode`|\=0 \catcode`\|=12 -\def\makeoutlinetoks{\Tnumfalse\afterassignment\makeolproctok\let\nxt= } +\def\makeoutlinetoks{\toksF={}\Tnumfalse + \afterassignment\makeolproctok\let\nxt= } \def\makeolnexttok{\afterassignment\makeolproctok\let\nxt= } \def\makeolgobbletok{\afterassignment\makeolnexttok\let\nxt= } \def\addF#1{\addtokens\toksF{#1}\tokprocessedtrue} @@ -191,7 +218,7 @@ } \def\makeolproctokchar#1 #2 #3{\addF{#3}} \def\outlinedone{\edef\outlinest{\global\noexpand\toksE={\the\toksF}}% - \outlinest\let\outlinedone=\relax} + \outlinest\let\outlinedone=\relax\outlinedone} \fi % End of general pdf macros \ifhint @@ -205,40 +232,11 @@ \def\HINThome{\HINTdest name {HINT.home}% \HINToutline goto name {HINT.home} depth 1 {Table of Contents}} \def\HINTlabel{{\let\*=\empty\HINTdest num \modstar top}} -\def\HINTlink#1#2{\HINTstartlink goto num #1 {#1}\HINTendlink}% #2 not used ??? +\def\HINTlink#1{\HINTstartlink goto num #1 {#1}\HINTendlink} \def\HINTcontents#1#2{\HINToutline goto num #2 depth 1 {#1}} \let\pdflink=\HINTlink \fi % End of HINT macros -% Common macros for \ifpdf and \ifhint -\ifacrohint -\def\pdfnote#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}\maketoks}\the\toksA} -\def\firstsecno#1.{\setbox0=\hbox{\toksA={#1.}\toksB={}% - \def\makenote{\addtokens\toksB{\the\toksC}\def\makenote{\toksD={} - \toksC={}\let\space\empty}\makenote}\maketoks}} -\def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} -\ifhint\else\sanitizecommand\to{..}\fi % a trivial example; requires \addtokens -\def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}% - \ifcat\noexpand\first0\countB=`#1\else\countB=0\fi\toksA={#2}} -\def\maketoks{\expandafter\poptoks\the\toksA|ENDTOKS|% - \ifnum\countB>`9 \countB=0 \fi - \ifnum\countB<`0 - \ifnum0=\countC\else\makenote\fi - \ifx\first.\let\next=\maketoksdone\else - \let\next=\maketoks - \addtokens\toksB{\the\toksD} - \ifx\first,\addtokens\toksB{\space}\fi - \fi - \else \addtokens\toksC{\the\toksD}\global\countC=1\let\next=\maketoks - \fi - \next -} -\def\makenote{\addtokens\toksB - {\noexpand\pdflink{\the\toksC}{\romannumeral\the\toksC}}% - \toksC={}\global\countC=0} -\def\maketoksdone{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} -\fi % End of common pdf/hint macros - \def\pdfURL#1#2{\ifpdf \ifpdflua\pdfannotlink height \theheight depth \thedepth attr {/Border [0 0 0]} user { /Type /Annot /Subtype /Link /A << /S /URI /URI (#2) >> }\Blue #1\Black \pdfendlink @@ -280,7 +278,7 @@ \outer\def\M#1.{\MN#1.\ifon\vfil\penalty-100\vfilneg % beginning of section \vskip\intersecskip\startsection\ignorespaces} \outer\def\N#1.#2.{% beginning of starred section - \ifpdf{\toksF={}\makeoutlinetoks#2\outlinedone\outlinedone}\fi + \ifpdf{\makeoutlinetoks#2\outlinedone}\fi \gtitle={#2}\MN#1.\vfil\eject % define running headline \message{*\modno} % progress report \def\stripprefix##1>{}\def\gtitletoks{#2}% @@ -411,17 +409,31 @@ \message{Index:} \parskip 0pt plus .5pt \outer\def\:##1, ##2.{\par\hangindent2em\noindent##1:\kern1em - \ifacrohint\pdfnote##2.\else##2\fi.} % index entry + \scan##2!.} % index entry \let\ttentry=\. \def\.##1{\ttentry{##1\kern.2em}} % give \tt a little room - \def\[##1]{$\underline{##1}$} % underlined index item - \rm \rightskip0pt plus 2.5em \tolerance 10000 \let\*=\lapstar + \def\[##1]{$\underline{\scan##1!}$\scan} % underlined index item + \ifacrohint\def\digits{\pdflink{\the\countA}\scan} + \else\def\digits{{\the\countA}\scan}\fi + \def\scan##1{\begingroup + \ifx!##1% exit on exclamation point + \else\ifx,##1,\space\aftergroup\scan % insert ,\space}\scan... + \else\ifx\[##1\aftergroup##1% insert }\[... + \else\ifx\*##1\aftergroup\lapstar\aftergroup\scan % insert }\lapstar\scan... + \else\ifnum`##1>`9##1\aftergroup\scan % insert #1}\scan... + \else\ifnum`##1<`0##1\aftergroup\scan % insert #1}\scan... + \else + \afterassignment\digits \aftergroup\countA + \aftergroup##1% insert }\countA=#1\digits... + \fi\fi\fi\fi\fi \fi + \endgroup} + \rm \rightskip0pt plus 2.5em \tolerance 10000 \hyphenpenalty 10000 \parindent0pt} \def\fin{\par\vfill\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 \ifpdflua \makebookmarks % added in Version 4.5 \ifnum\pdfshellescape=1 {\let\\=\BS % count the @<named sections@> - \global\countD=\input{|grep -c -e '\\:\\X' \jobname.tex}} \fi\fi + \global\countNOS=\input{|grep -c -e '\\:\\X' \jobname.tex}} \fi\fi \parfillskip 0pt plus 1fil \def\grouptitle{NAMES OF THE SECTIONS} \let\topsecno=\nullsec @@ -435,18 +447,16 @@ \def\:{\par\hangindent 2em}\let\*=*\let\.=\ttentry \ifpdf \def\outsecname{Names of the sections} \let\Xpdf\X \ifpdflua \pdfdest name {NOS} fith - \ifnum \the\countD>0 \xdef\modno{\the\countD} \fi + \ifnum \countNOS>0 \xdef\modno{\the\countNOS} \fi \pdfoutline goto name {NOS} count -\modno {\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 \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} + /Dest [ @thispage /FitH @ypos ] >>}\fi + \def\X##1:##2\X{\Xpdf##1:##2\X \firstsecno##1.% + {\makeoutlinetoks##2\outlinedone}% + \ifpdflua \pdfoutline goto num \the\toksA \expandafter{\the\toksE} + \else \special{pdf: outline 0 << /Title (\the\toksE) + /A << /S /GoTo /D (\romannumeral\the\toksA) >> >>}\fi} + \fi} \def\makebookmarks{\def\?##1]{[##1]}% \let\Z=\writebookmarkline \readcontents\relax} \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% @@ -474,9 +484,9 @@ \line{\ignorespaces#1 \rm\leaders\hbox to .5em{.\hfil}\hfil \ \ifhint - \HINTlink{#2}{\romannumeral#2}% No page numbers in HINT + \HINTlink{#2}% No page numbers in HINT \HINTcontents{#1}{#2}% - \else\ifpdf\pdflink{#2}{\romannumeral#2}\else#2\fi + \else\ifpdf\pdflink{#2}\else#2\fi \hbox to3em{\hss#3}\fi}} \def\today{\ifcase\month\or January\or February\or March\or April\or May\or June\or |