diff --git a/texk/web2c/cwebdir/cwebmac.tex b/texk/web2c/cwebdir/cwebmac.tex
index d50987d..ae220c0 100644
--- a/texk/web2c/cwebdir/cwebmac.tex
+++ b/texk/web2c/cwebdir/cwebmac.tex
@@ -12,6 +12,8 @@
\ifx\pdfoutput\undefined \pdftexfalse \else\ifnum\pdfoutput=0 \pdftexfalse
\else \pdftextrue \pdfoutput=1 \input pdfcolor \let\setcolor\pdfsetcolor \fi\fi
\newif\ifacro \ifpdf\acrotrue\fi \ifpdftex\acrotrue\fi
+\newif\ifhypertex
+\ifx\hypertex+\hypertextrue\fi
\let\:=\. % preserve a way to get the dot accent
% (all other accents will still work as usual)
@@ -120,7 +122,7 @@
\let\yskip=\smallskip
\def\?{\mathrel?}
\def\note#1#2.{\Y\noindent{\hangindent2em%
- \baselineskip10pt\eightrm#1~\ifacro{\pdfnote#2.}\else#2\fi.\par}}
+ \baselineskip10pt\eightrm#1~\xrefnote#2.\par}}
\newtoks\toksA \newtoks\toksB \newtoks\toksC \newtoks\toksD
\newtoks\toksE \newtoks\toksF \newtoks\usersanitizer
@@ -129,7 +131,7 @@
\newif\iftokprocessed \newif\ifTnum \newif\ifinstr
{\def\\{\global\let\spacechar= }\\ }
-\ifacro % The following are pdf macros
+% The following are pdf macros
\def\thewidth{\the\wd0 \space}
\def\theheight{\the\ht\strutbox\space}
\def\thedepth{\the\dp\strutbox\space}
@@ -141,29 +143,16 @@
\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\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}
+% pdfpage can be a no-op for PDFs, but dvipdfmx's documentation
+% doesn't clarify how to write a /GoTo action in its made-up language,
+% so define it here.
+\def\pdfpage#1{\ifpdftex\else%
+ \special{pdf: dest (page.#1) [ @thispage /FitH @ypos ]}\fi}
+\ifpdftex
+ \def\pdfpagelink#1{\hbox{\pdfannotlink height\ht\strutbox depth\dp\strutbox
+ attr{/Border [0 0 0]} goto Page #1 {/Fit} \BlueGreen #1\Black\pdfendlink}}
+\else%
+ \def\pdfpagelink#1{\pdflink{#1}{page.#1}}\fi
\def\pdfURL#1#2{\ifpdftex\pdfannotlink height\ht\strutbox depth\dp\strutbox
attr {/Border [0 0 0]} user { /Type /Action /Subtype /Link /A
<< /S /URI /URI (#2) >>}\BlueGreen #1\Black \pdfendlink
@@ -271,18 +260,115 @@
}
\def\outlinedone{\edef\outlinest{\global\noexpand\toksE={\the\toksF}}%
\outlinest\let\outlinedone=\relax}
-\fi % End of pdf macros
+
+
+% Internal cross reference links for named section numbers pass
+% through here to parse the comma/space\ET delimited, period
+% terminated section number lists. These are used by both the pdf and
+% hypertex commands.
+\def\xrefnote#1.{\ifacro\xnote#1.\else\ifhypertex\xnote#1.\else#1\fi\fi}
+\def\xnote#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\seclink{\the\toksC}}\toksC={}\global\countC=0}
+\def\maketoksdone{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
+
+
+% HyperTeX routines.
+{\catcode`\#=11 \catcode`\@=6%
+ \gdef\htxlink@1@2{\hbox{\special{html:}{@1}%
+ \special{html:}}}%
+ \gdef\htxpagelink@1{\hbox{\special{html:}{@1}%
+ \special{html:}}}}
+\def\htxpage#1{\hbox{\special{html:}\special{html:}}}
+\def\htxURL#1#2{\hbox{\special{html:}{#1}\special{html:}}}%
+\def\htxdest#1{\hbox{\special{html:}\special{html:}}}
+
+% The rest of the file uses these control sequences to establish
+% destinations and create clickable links to those destinations in PDF
+% or DVI. (Some ambitious person might factor out the PDF outline code
+% that still remains in the following.)
+\def\secdest#1{%
+ \ifacro
+ \ifpdftex\smash{\raise\baselineskip\hbox to0pt{%
+% \let\*=\empty\pdfdest num \secstar fith}} % bad space in versions < 3.68
+ \let\*=\empty\pdfdest num #1 fith}}% changed in version 3.68
+ \else\smash{\raise\baselineskip\hbox to0pt{%
+ \let\*=\empty\special{%
+ pdf: dest (\romannumeral#1) [ @thispage /FitH @ypos ]}}}\fi%
+ \else\ifhypertex\htxdest{\romannumeral#1}\fi\fi}%
+\def\pagedest#1{%
+ \ifacro\pdfpage{\the\pageno}%
+ \else\ifhypertex\htxpage{#1}\fi\fi}
+\def\seclink#1{%
+ \ifacro\pdflink{#1}{\romannumeral#1}%
+ \else\ifhypertex\htxlink{#1}{\romannumeral#1}%
+ \else#1\fi\fi}
+\def\pagelink#1{%
+ \ifacro\pdfpagelink{#1}%
+ \else\ifhypertex\htxpagelink{#1}%
+ \else{#1}\fi\fi}
+
+\def\makeoutlineentry#1{%
+\ifacro{\toksF={}\makeoutlinetoks#1\outlinedone\outlinedone}\fi}
+\def\makeoutline{
+ \ifacro \def\outsecname{Names of the sections} \let\Xpdf\X
+% \ifpdftex \makebookmarks \pdfdest name {NOS} fitb % in versions < 3.68
+ \ifpdftex \pdfdest name {NOS} fitb % changed in version 3.68
+ \pdfoutline goto name {NOS} count -\secno {\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\ifpdf
+ \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\fi}
+\def\addtooutline#1{
+ \ifacro\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\fi}
+\def\startpdf{\ifacro\ifpdftex\pdfcatalog{/PageMode /UseOutlines}\else
+ \ifpdf{\special{pdf: docview << /PageMode /UseOutlines >>}}\fi\fi\fi}
+
+\def\makebookmarks{\ifacro\ifpdftex\let\ZZ=\writebookmarkline \readcontents\relax\fi\fi}
+\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
+ \expandafter\xdef\csname#1\endcsname{\the\countA}}
+\def\writebookmarkline#1#2#3#4#5{{%
+ \let\(=\let \let\)=\let \let\[=\let \let\]=\let \let\/=\let
+ \pdfoutline goto num #3 count -\expnumber{chunk#2.#3} {#5}}}
+% There should be no uses of pdf or hypertex macros below this line.
\def\lapstar{\rlap{*}}
\def\stsec{\rightskip=0pt % get out of C mode (cf. \B)
\sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50
\noindent{\let\*=\lapstar\bf\secstar.\quad}%
- \ifpdftex\smash{\raise\baselineskip\hbox to0pt{%
-% \let\*=\empty\pdfdest num \secstar fith}} % bad space in versions < 3.68
- \let\*=\empty\pdfdest num \secstar fith}}% changed in version 3.68
- \else\ifpdf\smash{\raise\baselineskip\hbox to0pt{%
- \let\*=\empty\special{%
- pdf: dest (\romannumeral\secstar) [ @thispage /FitH @ypos ]}}}\fi\fi}
+ \secdest{\secstar}}
\let\startsection=\stsec
\def\defin#1{\global\advance\ind by 2 \1\&{#1 } } % begin `define' or `format'
\def\A{\note{See also section}} % xref for doubly defined section name
@@ -312,7 +398,7 @@
\outer\def\M#1{\MN{#1}\ifon\vfil\penalty-100\vfilneg % beginning of section
\vskip\intersecskip\startsection\ignorespaces}
\outer\def\N#1#2#3.{% beginning of starred section
- \ifacro{\toksF={}\makeoutlinetoks#3\outlinedone\outlinedone}\fi
+ \makeoutlineentry{#1}
\gdepth=#1\gtitle={#3}\MN{#2}%
\ifon\ifnum#1<\secpagedepth \vfil\eject % force page break if depth is small
\else\vfil\penalty-100\vfilneg\vskip\intersecskip\fi\fi
@@ -321,11 +407,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}
- \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
+ \addtooutline{#1}
\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
@@ -349,8 +431,7 @@
\let\V=\lor % logical or
\let\W=\land % logical and
\def\X#1:#2\X{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi %$% section name
- \XX$\langle\,${\let\I=\ne#2\eightrm\kern.5em
- \ifacro{\pdfnote#1.}\else#1\fi}$\,\rangle$\XX}
+ \XX$\langle\,${\let\I=\ne#2\eightrm\kern.5em\xrefnote#1.}$\,\rangle$\XX}
\def\Y{\par\yskip}
\let\Z=\le
\let\ZZ=\let % now you can \write the control sequence \ZZ
@@ -389,6 +470,7 @@
\def\normaloutput#1#2#3{\ifodd\pageno\hoffset=\pageshift\fi
\shipout\vbox{
\vbox to\fullpageheight{
+ \pagedest{\the\pageno}
\iftitle\global\titlefalse
\else\hbox to\pagewidth{\vbox to10pt{}\ifodd\pageno #3\else#2\fi}\fi
\vfill#1}} % parameter #1 is the page itself
@@ -399,8 +481,6 @@
\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\botofcontents{\vfill
\centerline{\covernote}} % this material will end the table of contents page
\def\covernote{}
@@ -450,7 +530,7 @@
\message{Index:}
\parskip 0pt plus .5pt
\outer\def\I##1, ##2.{\par\hangindent2em\noindent##1:\kern1em
- \ifacro\pdfnote##2.\else##2\fi.} % index entry
+ \xrefnote##2.} % index entry
\def\[##1]{$\underline{##1}$} % underlined index item
\rm \rightskip0pt plus 2.5em \tolerance 10000 \let\*=\lapstar
\hyphenpenalty 10000 \parindent0pt
@@ -458,43 +538,21 @@
\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
+ \makebookmarks % added in Version 3.68
\parfillskip 0pt plus 1fil
\def\grouptitle{NAMES OF THE SECTIONS}
\let\topsecno=\nullsec
\message{Section names:}
\output={\normaloutput\page\lheader\rheader}
\setpage
- \def\note##1##2.{\quad{\eightrm##1~\ifacro{\pdfnote##2.}\else{##2}\fi.}}
+ \def\note##1##2.{\quad{\eightrm##1~\xrefnote##2.}}
\def\Q{\note{Cited in section}} % crossref for mention of a section
\def\Qs{\note{Cited in sections}} % crossref for mentions of a section
\def\U{\note{Used in section}} % crossref for use of a section
\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} fitb % changed in version 3.68
- \pdfoutline goto name {NOS} count -\secno {\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\ifpdf
- \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\fi
+ \makeoutline
\readsections}
-\def\makebookmarks{\let\ZZ=\writebookmarkline \readcontents\relax}
-\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
- \expandafter\xdef\csname#1\endcsname{\the\countA}}
-\def\writebookmarkline#1#2#3#4#5{{%
- \let\(=\let \let\)=\let \let\[=\let \let\]=\let \let\/=\let
- \pdfoutline goto num #3 count -\expnumber{chunk#2.#3} {#5}}}
\def\con{\par\vfill\eject % finish the section names
% \ifodd\pageno\else\titletrue\null\vfill\eject\fi % for duplex printers
\rightskip 0pt \hyphenpenalty 50 \tolerance 200
@@ -511,7 +569,7 @@
\def\contentsline#1#2#3#4#5{\ifnum#2=0 \smallbreak\fi
\line{\consetup{#2}#1
\rm\leaders\hbox to .5em{.\hfil}\hfil
- \ \ifacro\pdflink{#3}{\romannumeral#3}\else#3\fi\hbox to3em{\hss#4}}}
+ \ \seclink{#3}\hbox to3em{\hss\pagelink{#4}}}}
\def\consetup#1{\ifcase#1 \bf % depth -1 (@**)
\or % depth 0 (@*)
\or \hskip2em % depth 1 (@*1)