diff options
Diffstat (limited to 'web/c_cpp/cweb/cwebmac.tex')
-rw-r--r-- | web/c_cpp/cweb/cwebmac.tex | 64 |
1 files changed, 32 insertions, 32 deletions
diff --git a/web/c_cpp/cweb/cwebmac.tex b/web/c_cpp/cweb/cwebmac.tex index e2d2ecb3a2..382400a3f7 100644 --- a/web/c_cpp/cweb/cwebmac.tex +++ b/web/c_cpp/cweb/cwebmac.tex @@ -1,24 +1,19 @@ % standard macros for CWEB listings (in addition to plain.tex) -% Version 4.8--- June 2022 +% Version 4.10 --- August 2023 \ifx\renewenvironment\undefined\else\endinput\fi % LaTeX will use other macros -\xdef\fmtversion{\fmtversion+CWEB4.8} -\chardef\cwebversion=4 \chardef\cwebrevision=7 -\newif\ifpdf -\ifx\pdf+\pdftrue\fi +\xdef\fmtversion{\fmtversion+CWEB4.10} +\chardef\cwebversion=4 \chardef\cwebrevision=10 +\input iftex.sty % TeX engine tests +\ifx\pdf+\pdftrue\fi % for plain TeX in combination with dvipdfm % Uncomment the following line if you want PDF goodies to be the default %\ifx\pdf-\else\pdftrue\fi \def\pdflinkcolor{0 0 1} % the RGB values for hyperlink color -\ifx\undefined\XeTeXrevision\else\pdftrue\fi % XeTeX produces PDF output -\newif\ifpdftex -\ifx\pdfoutput\undefined \pdftexfalse \else\ifnum\pdfoutput=0 \pdftexfalse -%\else \pdftextrue \pdfoutput=1 \input pdfcolor \let\setcolor\pdfsetcolor \fi\fi -\else \pdftextrue \pdfoutput=1 % changed in 3.69 +\ifxetex\pdftrue\fi % XeTeX produces PDF output +\ifpdftex % pdfTeX produces PDF output if \pdfoutput>0 \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\fi -\newif\ifhint -\ifx\HINTversion\undefined \hintfalse \else \hinttrue \fi -\newif\ifacro \ifpdf\acrotrue\fi \ifpdftex\acrotrue\fi +\fi +\let\ifacro=\ifpdf \newif\ifacrohint \ifacro\acrohinttrue\fi \ifhint\acrohinttrue\fi \let\:=\. % preserve a way to get the dot accent @@ -135,7 +130,7 @@ \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\countC \countC=0 \newcount\countD \countD=0 \newif\iftokprocessed \newif\ifTnum \newif\ifinstr {\def\\{\global\let\spacechar= }\\ } @@ -145,7 +140,7 @@ \def\thedepth{\the\dp\strutbox\space} \ifpdftex \ifx\pdfannotlink\undefined\let\pdfannotlink\pdfstartlink\fi% for pdfTeX 0.14 - \def\pdflink#1#2{\hbox{\pdfannotlink height\ht\strutbox depth\dp\strutbox + \def\pdflink#1#2{\hbox{\pdfannotlink height \theheight depth \thedepth attr{/Border [0 0 0]} goto num #1 \Blue #1\Black\pdfendlink}} % changed 3.69 \else\def\pdflink#1#2{\setbox0=\hbox{\special{pdf: bc [ \pdflinkcolor ]}{#1}% \special{pdf: ec}}\special{pdf: ann width \thewidth height \theheight @@ -294,14 +289,14 @@ \def\maketoksdone{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} \fi % End of common macros -\def\pdfURL#1#2{\ifpdftex\pdfannotlink height\ht\strutbox depth\dp\strutbox - attr {/Border [0 0 0]} user { /Type /Action /Subtype /Link /A +\def\pdfURL#1#2{\ifpdf \ifpdftex\pdfannotlink height \theheight depth \thedepth + attr {/Border [0 0 0]} user { /Type /Annot /Subtype /Link /A << /S /URI /URI (#2) >>}\Blue #1\Black \pdfendlink % changed in 3.69 - \else \ifpdf{\setbox0=\hbox{\special{pdf: bc [ \pdflinkcolor ]}{#1}% - \special{pdf: ec}}\special{pdf: ann width \thewidth\space height \theheight - \space depth \thedepth\space << /Border [0 0 0] - /Type /Action /Subtype /Link /A << /S /URI /URI (#2) >> >>}\box0\relax}% - \else #1 ({\tt#2})\fi\fi} + \else {\setbox0=\hbox{\special{pdf: bc [ \pdflinkcolor ]}{#1}% + \special{pdf: ec}}\special{pdf: ann width \thewidth height \theheight + depth \thedepth << /Border [0 0 0] /Type /Annot /Subtype /Link /A + << /S /URI /URI (#2) >> >>}\box0\relax}\fi + \else #1 ({\tt#2})\fi} {\catcode`\~=12 \gdef\TILDE/{~}} % ~ in a URL {\catcode`\_=12 \gdef\UNDER/{_}} % _ in a URL @@ -352,11 +347,11 @@ \edef\gtitletoks{\expandafter\stripprefix\meaning\gtitletoks}% \edef\next{\write\cont{\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} + \ifpdf \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 + \advancenumber{chunk\the\countB.\expnumber{curr\the\countB}}\fi + \else \special{pdf: outline #1 << /Title (\the\toksE) + /Dest [ @thispage /FitH @ypos ] >>}\fi \fi \ifon\startsection{\bf#3.\quad}\ignorespaces} \def\MN#1{\par % common code for \M, \N {\xdef\secstar{#1}\let\*=\empty\xdef\secno{#1}}% remove \* from section name @@ -428,13 +423,13 @@ \vfill#1}} % parameter #1 is the page itself \global\advance\pageno by1} -\gtitle={\.{CWEB} output} % this running head is reset by starred sections +\gtitle={{\tentex CWEB} output} % this running head is reset by starred sections \mark{\noexpand\nullsec0{\the\gtitle}} \def\title{\expandafter\uppercase\expandafter{\jobname}} \def\topofcontents{\centerline{\titlefont\title}\vskip.7in \vfill} % this material will start the table of contents page -\def\startpdf{\ifpdftex\pdfcatalog{/PageMode /UseOutlines}\else - \ifpdf{\special{pdf: docview << /PageMode /UseOutlines >>}}\fi\fi} +\def\startpdf{\ifpdf \ifpdftex\pdfcatalog{/PageMode /UseOutlines} + \else {\special{pdf: docview << /PageMode /UseOutlines >>}}\fi\fi} \def\botofcontents{\vfill \centerline{\covernote}} % this material will end the table of contents page \def\covernote{} @@ -495,7 +490,8 @@ \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 - \ifpdftex \makebookmarks \fi % added in Version 3.68 + \ifpdf \ifpdftex \makebookmarks % added in Version 3.68 + \countsections \fi\fi % and in Version 4.9 \parfillskip 0pt plus 1fil \def\grouptitle{NAMES OF THE SECTIONS} \let\topsecno=\nullsec @@ -511,7 +507,7 @@ \ifacro \def\outsecname{Names of the sections} \let\Xpdf\X % \ifpdftex \makebookmarks \pdfdest name {NOS} fitb % in versions < 3.68 \ifpdftex \pdfdest name {NOS} fith % changed in version 3.69 - \pdfoutline goto name {NOS} count -\secno {\outsecname} + \pdfoutline goto name {NOS} count -\the\countD {\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}} @@ -524,6 +520,10 @@ \fi\fi \readsections} \def\makebookmarks{\let\ZZ=\writebookmarkline \readcontents\relax} +\def\countsections{\message{Number of named sections:} + {\def\I{\global\advance\countD by 1}\def\X##1\X{\relax} + \def\Q##1.{\relax}\def\Qs##1.{\relax}\def\U##1.{\relax}\def\Us##1.{\relax} + \readsections\relax}\message{\the\countD}} \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% \else \csname#1\endcsname \fi} % Petr Olsak's macros from texinfo.tex \def\advancenumber#1{\countA=\expnumber{#1}\relax \advance\countA by1 |