summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/cwebdir/cwebacromac.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/cwebdir/cwebacromac.tex')
-rw-r--r--Build/source/texk/web2c/cwebdir/cwebacromac.tex125
1 files changed, 76 insertions, 49 deletions
diff --git a/Build/source/texk/web2c/cwebdir/cwebacromac.tex b/Build/source/texk/web2c/cwebdir/cwebacromac.tex
index f8462d06a37..1743ddd95d6 100644
--- a/Build/source/texk/web2c/cwebdir/cwebacromac.tex
+++ b/Build/source/texk/web2c/cwebdir/cwebacromac.tex
@@ -1,6 +1,8 @@
% hypertext macros for CWEB listings (in addition to cwebmac.tex)
-% Version 2.0 --- May 2024
+% Used in cwebmac.tex, pdfctwimac.tex, pdfproofmac.tex
+% Version 3.0 --- August 2024
\ifx\ifacrohint\undefined\endinput\fi % these are not standalone macros
+
\ifluatex % LuaTeX is almost like pdfTeX
\protected\def\pdfliteral {\pdfextension literal}
\protected\def\pdfstartlink {\pdfextension startlink\space}
@@ -15,7 +17,16 @@
\let\pdfoutput=\outputmode
\fi % end of LuaTeX->pdfTeX redirection macros
-% Used in cwebmac.tex, pdfctwimac.tex, pdfproofmac.tex
+\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}%
+ \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
\def\tocpages{1} % Most programs have one-page Table-of-Contents
\def\startpdf{\def\pagemode{/PageMode /UseOutlines}
\ifnum\contentspagenumber=0 \advance \pageno by -\tocpages
@@ -24,9 +35,52 @@
\else \twodigits=\pageno \pageno=\contentspagenumber
\advance \pageno by \tocpages \advance \twodigits by -\pageno
\def\pagelabels{/PageLabels << /Nums [ 0 << /S/D/St \the\pageno >>
- \the\twodigits << /S/D/St \contentspagenumber >> ] >>} \fi
+ \the\twodigits << /S/D/St \contentspagenumber >> ] >>}
+ \fi
\ifpdflua\pdfcatalog{\pagemode\space\pagelabels}
- \else \special{pdf: docview << \pagemode\space\pagelabels >>}\fi}
+ \else\special{pdf: docview << \pagemode\space\pagelabels >>}\fi}
+\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}
+
+% Local variables; there are a few externals like '\toksA' and '\countA'
+\newtoks\toksB \newtoks\toksC \newtoks\toksD \newtoks\toksF \newtoks\sanitizer
+\newif\iftokprocessed \newif\ifTnum \newif\ifinstr \newif\ifhavenum
+
+\ifacrohint % Common macros for \ifacro and \ifhint to create \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
\ifacro % The following are general pdf macros
\def\thewidth{\the\wd0 \space}
@@ -34,13 +88,14 @@
\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}} % changed 3.69
-\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
-\def\sanitizecommand#1#2{\addtokens\usersanitizer
+ depth \thedepth << /Type /Annot /Subtype /Link /Border [0 0 0]
+ /A << /S /GoTo /D (\romannumeral#1) >> >>}\box0\relax}
+\fi
+\def\sanitizecommand#1#2{\addtokens\sanitizer
{\noexpand\dosanitizecommand\noexpand#1{#2}}}
\def\dosanitizecommand#1#2{\ifx\nxt#1\addF{#2}\fi}
@@ -49,9 +104,11 @@
\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\makeolgobbletokk{\afterassignment\makeolgobbletok\let\nxt= }
\def\addF#1{\addtokens\toksF{#1}\tokprocessedtrue}
% now comes a routine to "sanitize" section names, for pdf outlines
\def\makeolproctok{\tokprocessedfalse
@@ -62,9 +119,8 @@
\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
+ \ifx\nxt~\addF\space \else\ifx\nxt\onespace\addF\space
+ \else\the\sanitizer
\iftokprocessed\else\makeolproctokctli
\iftokprocessed\else\makeolproctokctlii
\iftokprocessed\else\makeolproctokctliii % if not recognised, skip it
@@ -77,8 +133,7 @@
\else\expandafter\makeolproctokchar\meaning\nxt
\fi\fi\fi\fi\fi
\fi\fi\fi\fi\fi \fi\fi\fi
- \next
-}
+ \next}
\def\makeolproctokchar#1 #2 #3{\addF{#3}}
\def\makeolproctokctli{%
\ifx\nxt\CEE\addF{C}\let\next\makeolgobbletok % \CEE/
@@ -86,8 +141,9 @@
\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\Cee\addF{C}\else\ifx\nxt\dots\addF{...\space}%
\else\ifx\nxt\PB \let\next\makeolgobbletok \tokprocessedtrue % \PB{...}
+ \else\ifx\nxt\9 \expandafter\nxt\relax \let\next\makeolgobbletokk % \9{#1}
\else\ifx\nxt\.\tokprocessedtrue\instrtrue % \.{...}
% skip \|
\else\ifx\nxt\\\ifinstr\addF{\bschar\bschar}\else\tokprocessedtrue\fi
@@ -102,7 +158,7 @@
\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
+ \fi\fi\fi\fi
}
\def\makeolproctokctlii{%
\ifx\nxt\MG\addF{->}\else\ifx\nxt\GG\addF{>>}%
@@ -141,48 +197,19 @@
\fi\fi\fi\fi\fi
}
\def\outlinedone{\edef\outlinest{\global\noexpand\toksE={\the\toksF}}%
- \outlinest\let\outlinedone=\relax}
+ \outlinest\let\outlinedone=\relax\outlinedone}
\fi % End of pdf macros
\ifhint
-% The following uses HINT primitives to implement:
+% The following top level macros use 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\HINTlink#1{\HINTstartlink goto num #1 {#1}\HINTendlink}
\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