diff options
Diffstat (limited to 'web/c_cpp/cweb/cwebmac.tex')
-rw-r--r-- | web/c_cpp/cweb/cwebmac.tex | 206 |
1 files changed, 27 insertions, 179 deletions
diff --git a/web/c_cpp/cweb/cwebmac.tex b/web/c_cpp/cweb/cwebmac.tex index 382400a3f7..e079a80ef5 100644 --- a/web/c_cpp/cweb/cwebmac.tex +++ b/web/c_cpp/cweb/cwebmac.tex @@ -1,20 +1,8 @@ % standard macros for CWEB listings (in addition to plain.tex) -% Version 4.10 --- August 2023 +% Version 4.11 --- October 2023 \ifx\renewenvironment\undefined\else\endinput\fi % LaTeX will use other macros -\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 -\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 -\let\ifacro=\ifpdf -\newif\ifacrohint \ifacro\acrohinttrue\fi \ifhint\acrohinttrue\fi +\xdef\fmtversion{\fmtversion+CWEB4.11} +\chardef\cwebversion=4 \chardef\cwebrevision=11 \let\:=\. % preserve a way to get the dot accent % (all other accents will still work as usual) @@ -134,162 +122,22 @@ \newif\iftokprocessed \newif\ifTnum \newif\ifinstr {\def\\{\global\let\spacechar= }\\ } -\ifacro % The following are pdf macros -\def\thewidth{\the\wd0 \space} -\def\theheight{\the\ht\strutbox\space} -\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 \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 - depth \thedepth << /Type /Annot /Subtype /Link - /Border [0 0 0] /A << /S /GoTo /D (#2) >> >>}\box0\relax}\fi -\def\sanitizecommand#1#2{\addtokens\usersanitizer - {\noexpand\dosanitizecommand\noexpand#1{#2}}} -\def\dosanitizecommand#1#2{\ifx\nxt#1\addF{#2}\fi} - -\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\makeolnexttok{\afterassignment\makeolproctok\let\nxt= } -\def\makeolgobbletok{\afterassignment\makeolnexttok\let\nxt= } -\def\addF#1{\addtokens\toksF{#1}\tokprocessedtrue} -% now comes a routine to "sanitize" section names, for pdf outlines -\def\makeolproctok{\tokprocessedfalse - \let\next\makeolnexttok % default - \ifx\nxt\outlinedone\let\next\outlinedone - \else\ifx{\nxt \else\ifx}\nxt \Tnumfalse \instrfalse % skip braces - \else\ifx$\nxt % or a $ sign - \else\ifx^\nxt \addF^\else\ifx_\nxt \addF_% sanitize ^ and _ - \else\ifx\nxt\spacechar \addF\space - \else\if\noexpand\nxt\relax % we have a control sequence; is it one we know? - \ifx\nxt~\addF\space - \else\ifx\nxt\onespace\addF\space - \else\the\usersanitizer - \iftokprocessed\else\makeolproctokctli - \iftokprocessed\else\makeolproctokctlii - \iftokprocessed\else\makeolproctokctliii % if not recognised, skip it - \fi\fi\fi\fi\fi - \else % we don't have a control sequence, it's an ordinary char - \ifx/\nxt \addF{\string\/}% quote chars special to PDF with backslash - \else\ifx(\nxt \addF{\string\(}\else\ifx)\nxt \addF{\string\)}% - \else\ifx[\nxt \addF{\string\[}\else\ifx]\nxt \addF{\string\]}% - \else\expandafter\makeolproctokchar\meaning\nxt - \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi - \next -} -\def\makeolproctokchar#1 #2 #3{\addF{#3}} -\def\makeolproctokctli{% - \ifx\nxt\CEE\addF{C}\let\next\makeolgobbletok % \CEE/ - \else\ifx\nxt\UNIX\addF{UNIX}\let\next\makeolgobbletok % \UNIX/ - \else\ifx\nxt\TEX\addF{TeX}\let\next\makeolgobbletok % \TEX/ - \else\ifx\nxt\TeX\addF{TeX}\else\ifx\nxt\LaTeX\addF{LaTeX}% - \else\ifx\nxt\CPLUSPLUS\addF{C++}\let\next\makeolgobbletok % \CPLUSPLUS/ - \else\ifx\nxt\Cee\addF{C}% - \else\ifx\nxt\PB \let\next\makeolgobbletok \tokprocessedtrue % \PB{...} - \else\ifx\nxt\.\tokprocessedtrue\instrtrue % \.{...} - % skip \| - \else\ifx\nxt\\\ifinstr\addF{\bschar\bschar}\else\tokprocessedtrue\fi - \else\ifx\nxt\&\ifinstr\addF&\else\tokprocessedtrue\fi - \else\ifx\nxt\~\ifTnum\addF{0}\else\addF\tildechar\fi % 077->\T{\~77} - \else\ifx\nxt\_\ifTnum\addF{E}\else\addF_\fi % 0.1E5->\T{0.1\_5} - \else\ifx\nxt\^\ifTnum\addF{0x}\else\addF^\fi % 0x77 -> \T{\^77} - \else\ifx\nxt\\\\\ifTnum\addF{0b}\else\addF\\\fi % 0b10111 -> \T{\\10111} - \else\ifx\nxt\$\ifTnum\tokprocessedtrue\else\addF$\fi %$% \T{77\$L} - \else\ifx\nxt\{\addF\lbchar \else\ifx\nxt\}\addF\rbchar - \else\ifx\nxt\ \addF\space \else\ifx\nxt\#\addF{\string\#}% - \else\ifx\nxt\PP\addF{++}\else\ifx\nxt\MM\addF{--}% - \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi -} -\def\makeolproctokctlii{% - \ifx\nxt\MG\addF{->}\else\ifx\nxt\GG\addF{>>}% - \else\ifx\nxt\LL\addF{<<}\else\ifx\nxt\NULL\addF{NULL}% - \else\ifx\nxt\AND\addF&\else\ifx\nxt\OR\addF|% - \else\ifx\nxt\XOR\addF^\else\ifx\nxt\CM\addF\tildechar - \else\ifx\nxt\MOD\addF{\string\%}\else\ifx\nxt\DC\addF{::}% - \else\ifx\nxt\PA\addF{.*}\else\ifx\nxt\MGA\addF{->*}% - \else\ifx\nxt\this\addF{this}\else\ifx\nxt\?\addF?% - \else\ifx\nxt\E\addF{==}\else\ifx\nxt\G\addF{>=}% - \else\ifx\nxt\I\addF{!=}\else\ifx\nxt\K\addF{=}% - \else\ifx\nxt\l\addF{l}\else\ifx\nxt\L\addF{L}% - \else\ifx\nxt\o\addF{o}\else\ifx\nxt\O\addF{O}% - \else\ifx\nxt\R\addF!% - \else\ifx\nxt\T \Tnumtrue \let\next\makeolgobbletok - \tokprocessedtrue % \T{number} - \else\ifx\nxt\AM\addF&\else\ifx\nxt\%\addF{\string\%}% - \fi\fi\fi\fi\fi \fi\fi\fi\fi\fi - \fi\fi\fi\fi\fi \fi\fi\fi\fi\fi - \fi\fi\fi\fi\fi\fi -} -\def\makeolproctokctliii{% - \ifx\nxt\V\addF{||}\else\ifx\nxt\W\addF{&&}\else\ifx\nxt\Z\addF{<=}% - \else\ifx\nxt\*\addF*\else\ifx\nxt\Xand\addF{\space and\space}% - \else\ifx\nxt\Xandxeq\addF{\space and_eq\space}% - \else\ifx\nxt\Xbitand\addF{\space bitand\space}% - \else\ifx\nxt\Xbitor\addF{\space bitor\space}% - \else\ifx\nxt\Xcompl\addF{\space compl\space}% - \else\ifx\nxt\Xnot\addF{\space not\space}% - \else\ifx\nxt\Xnotxeq\addF{\space not_eq\space}% - \else\ifx\nxt\Xor\addF{\space or\space}% - \else\ifx\nxt\Xorxeq\addF{\space or_eq\space}% - \else\ifx\nxt\Xxor\addF{\space xor\space}% - \else\ifx\nxt\Xxorxeq\addF{\space xor_eq\space}% - \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi - \fi\fi\fi\fi\fi -} -\def\outlinedone{\edef\outlinest{\global\noexpand\toksE={\the\toksF}}% - \outlinest\let\outlinedone=\relax} -\fi % End of pdf macros - -\ifhint -% The following uses HINT primitives to implement: -% \HINThome to mark the position of the home page -% \HINTlabel to attach a label to the top of a section -% \HINTlink to link a section number to the section label -% \HINTcontents to produce an 'outline' item -% These are the top level HINT macros that are used in this file -% No HINT primitives are used directly. -\def\HINThome{\HINTdest name {HINT.home}% - \HINToutline goto name {HINT.home} depth 1 {Table of Contents}} -\def\HINTlabel{{\let\*=\empty\HINTdest num \secstar top}} -\def\HINTlink#1#2{\HINTstartlink goto num #1 {#1}\HINTendlink}% #2 not used ??? -\def\HINTcontents#1#2#3{\HINToutline goto num #3 depth #2 {#1}} -\let\pdflink=\HINTlink -\fi % End of HINT macros - -% Common macros for \ifacro 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} -\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 macros - -\def\pdfURL#1#2{\ifpdf \ifpdftex\pdfannotlink height \theheight depth \thedepth +% Here we decide the output format, depending on the TeX engine in use: +\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 +\ifxetex\pdftrue\fi % XeTeX produces PDF output +\ifpdf \def\pdflinkcolor{0 0 1} \fi % the RGB values for hyperlink color +\let\ifacro=\ifpdf +\newif\ifacrohint \ifacro\acrohinttrue\fi \ifhint\acrohinttrue\fi +\newif\ifpdflua \ifluatex\pdfluatrue\fi \ifpdftex\pdfluatrue\fi +\ifpdflua % luaTeX and pdfTeX 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 +\ifacrohint \input cwebacromac \fi % load hypertext 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 % changed in 3.69 \else {\setbox0=\hbox{\special{pdf: bc [ \pdflinkcolor ]}{#1}% @@ -306,7 +154,7 @@ \ifhint\HINTlabel\fi% Start page before section \noindent{\let\*=\lapstar\bf\secstar.\quad}% \ifacro \smash{\raise\baselineskip\hbox to0pt{\let\*=\empty - \ifpdftex \pdfdest num \secstar fith% + \ifpdflua \pdfdest num \secstar fith% \else \special{pdf: dest (\romannumeral\secstar) [ @thispage /FitH @ypos ]}\fi}}\fi} \let\startsection=\stsec @@ -347,7 +195,7 @@ \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} - \ifpdf \ifpdftex\expandafter\xdef\csname curr#1\endcsname{\secno} + \ifpdf \ifpdflua\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 \else \special{pdf: outline #1 << /Title (\the\toksE) @@ -428,7 +276,7 @@ \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{\ifpdf \ifpdftex\pdfcatalog{/PageMode /UseOutlines} +\def\startpdf{\ifpdf \ifpdflua\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 @@ -450,7 +298,7 @@ \newwrite\cont \output{\setbox0=\page % the first page is garbage \openout\cont=\contentsfile - \write\cont{\catcode `\noexpand\@=11\relax} % \makeatletter + \write\cont{\catcode `\noexpand\@=11\relax} % \makeatletter \global\output{\normaloutput\page\lheader\rheader}} \setpage \vbox to \vsize{} % the first \topmark won't be null @@ -462,7 +310,7 @@ \def\inx{\par\vskip6pt plus 1fil % we are beginning the index \def\page{\box255 } \normalbottom \write\cont{} % ensure that the contents file isn't empty - \write\cont{\catcode `\noexpand\@=12\relax} % \makeatother + \write\cont{\catcode `\noexpand\@=12\relax} % \makeatother \closeout\cont % the contents information has been fully gathered \output{\ifpagesaved\normaloutput{\box\sbox}\lheader\rheader\fi \global\setbox\sbox=\page \global\pagesavedtrue \mark{\topmark}} @@ -490,7 +338,7 @@ \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 - \ifpdf \ifpdftex \makebookmarks % added in Version 3.68 + \ifpdf \ifpdflua \makebookmarks % added in Version 3.68 \countsections \fi\fi % and in Version 4.9 \parfillskip 0pt plus 1fil \def\grouptitle{NAMES OF THE SECTIONS} @@ -505,8 +353,8 @@ \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 % in versions < 3.68 - \ifpdftex \pdfdest name {NOS} fith % changed in version 3.69 +% \ifpdflua \makebookmarks \pdfdest name {NOS} fitb % in versions < 3.68 + \ifpdflua \pdfdest name {NOS} fith % changed in version 3.69 \pdfoutline goto name {NOS} count -\the\countD {\outsecname} \def\X##1:##2\X{\Xpdf##1:##2\X \firstsecno##1.% {\toksF={}\makeoutlinetoks##2\outlinedone\outlinedone}% |