texlive[63652] Master/texmf-dist/tex/plain/cweb: {CWEB] Modernize
commits+ascherer at tug.org
commits+ascherer at tug.org
Sun Jun 19 15:31:24 CEST 2022
Revision: 63652
http://tug.org/svn/texlive?view=revision&revision=63652
Author: ascherer
Date: 2022-06-19 15:31:24 +0200 (Sun, 19 Jun 2022)
Log Message:
-----------
{CWEB] Modernize CWEB/CTWILL macros.
Use 'iftex.sty' to detect the TeX engine in use (plain TeX, PDFTeX,
XeTeX, and HiTeX are explicitly supported at this time).
Simplify the \if... logic in the CWEB/CTWILL macros accordingly.
'\ifacro' is fully replaced by 'ifpdf'.
Modified Paths:
--------------
trunk/Master/texmf-dist/tex/plain/cweb/cwebbin/dctproofmac.tex
trunk/Master/texmf-dist/tex/plain/cweb/cwebbin/dctwimac.tex
trunk/Master/texmf-dist/tex/plain/cweb/cwebbin/pdfctwimac.tex
trunk/Master/texmf-dist/tex/plain/cweb/cwebmac.tex
Modified: trunk/Master/texmf-dist/tex/plain/cweb/cwebbin/dctproofmac.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/cweb/cwebbin/dctproofmac.tex 2022-06-19 13:01:23 UTC (rev 63651)
+++ trunk/Master/texmf-dist/tex/plain/cweb/cwebbin/dctproofmac.tex 2022-06-19 13:31:24 UTC (rev 63652)
@@ -1,7 +1,7 @@
\ifx\undefined\documentclass\input ctproofmac.tex
\else\endinput\fi % LaTeX will use other macros
-\let\acrofalse=\relax
+\let\pdffalse=\relax
\input dcwebstrings.tex
\def\fin{\par\vfill\eject % this is done when we are ending the index
Modified: trunk/Master/texmf-dist/tex/plain/cweb/cwebbin/dctwimac.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/cweb/cwebbin/dctwimac.tex 2022-06-19 13:01:23 UTC (rev 63651)
+++ trunk/Master/texmf-dist/tex/plain/cweb/cwebbin/dctwimac.tex 2022-06-19 13:31:24 UTC (rev 63652)
@@ -1,7 +1,7 @@
\ifx\undefined\documentclass\input ctwimac.tex
\else\endinput\fi % LaTeX will use other macros
-\let\acrofalse=\relax
+\let\pdffalse=\relax
\input dcwebstrings.tex
\def\fin{\parfillskip 0pt plus 1fil
Modified: trunk/Master/texmf-dist/tex/plain/cweb/cwebbin/pdfctwimac.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/cweb/cwebbin/pdfctwimac.tex 2022-06-19 13:01:23 UTC (rev 63651)
+++ trunk/Master/texmf-dist/tex/plain/cweb/cwebbin/pdfctwimac.tex 2022-06-19 13:31:24 UTC (rev 63652)
@@ -1,25 +1,21 @@
% standard macros for CWEB listings (in addition to plain.tex)
-% Version 4.5 --- October 2021
+% Version 4.9 --- June 2022
% modified for pages produced by CTWILL
% further modified for page size of the MMIXware book
% modified for PDF output with 'tex "\let\pdf+', 'pdftex', and 'xetex'
% This file is not copyrighted and can be used freely.
\ifx\renewenvironment\undefined\else\endinput\fi % LaTeX will use other macros
-\xdef\fmtversion{\fmtversion+CTWILL4.5+LNCS+PDF}
-
-\newif\ifpdf
-\ifx\pdf+\pdftrue\fi
+\xdef\fmtversion{\fmtversion+CTWILL4.9+LNCS+PDF}
+\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
+\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\PDFlinkcolor{\pdfliteral{\pdflinkcolor\space rg \pdflinkcolor\space RG}}
-\fi\fi
-\newif\ifacro \ifpdf\acrotrue\fi \ifpdftex\acrotrue\fi
+\fi
\let\:=\. % preserve a way to get the dot accent
% (all other accents will still work as usual)
@@ -180,7 +176,7 @@
tangles as \tentex "#2"\egroup\par}
\def\noATL#1 #2 {}
\def\noatl{\let\ATL=\noATL} % suppress output from @l
-\def\ATH{{\acrofalse\X\kern-.5em:Preprocessor definitions\X}}
+\def\ATH{{\pdffalse\X\kern-.5em:Preprocessor definitions\X}}
\let\PB=\relax % hook for program brackets |...| in TeX part or section name
\chardef\AM=`\& % ampersand character in a string
@@ -238,16 +234,16 @@
\def\,{\relax\ifmmode\mskip\thinmuskip\else\thinspace\fi}
\def\note#1#2.{\par\penalty5000
\Y\noindent{\hangindent2\em\baselineskip10pt%
- \eightrm#1~\ifacro{\pdfnote#2.}\else#2\fi.\par}}
+ \eightrm#1~\ifpdf{\pdfnote#2.}\else#2\fi.\par}}
\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= }\\ }
-\ifacro % The following are pdf macros
+\ifpdf % The following are pdf macros
\def\thewidth{\the\wd0 \space}
\def\theheight{\the\ht\strutbox\space}
\def\thedepth{\the\dp\strutbox\space}
@@ -282,14 +278,14 @@
\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}
-\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) >>}\PDFlinkcolor #1\Black \pdfendlink
- \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}
+\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 {\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\sanitizecommand#1#2{\addtokens\usersanitizer
@@ -396,7 +392,7 @@
\def\stsec{\tenpoint\rightskip=0pt % get out of C mode (cf. \B)
\sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50
\noindent\strut{\let\*=\lapstar\bf\secno.\quad}%
- \ifacro \smash{\raise\baselineskip\hbox to0pt{\let\*=\empty
+ \ifpdf \smash{\raise\baselineskip\hbox to0pt{\let\*=\empty
\ifpdftex \pdfdest num \secstar fith%
\else \special{pdf: dest (\romannumeral\secstar)
[ @thispage /FitH @ypos ]}\fi}}\fi}
@@ -438,7 +434,7 @@
\outer\def\NN{\ifvoid\partialpage\leftfalse
\else\ifdim\ht\partialpage<\pageht \lefttrue\else\leftfalse\fi\fi\NNN}
\outer\def\NNN#1#2#3.{% beginning of starred section
- \ifacro{\toksF={}\makeoutlinetoks#3\outlinedone\outlinedone}\fi
+ \ifpdf{\toksF={}\makeoutlinetoks#3\outlinedone\outlinedone}\fi
\gdepth=#1\gtitle={#3}\def\secno{#2}\xdef\secstar{#2}
\ifleft \flushout
\gdef\rlhead{\let\i=I\uppercase{\ignorespaces#3}} % running left headline
@@ -480,7 +476,7 @@
\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\sevenrm\kern.5em
- \ifacro{\pdfnote#1.}\else#1\fi}$\,\rangle$\XX}
+ \ifpdf{\pdfnote#1.}\else#1\fi}$\,\rangle$\XX}
\def\Y{\par\yskip}
\let\Z=\le
\let\ZZ=\let % now you can \write the control sequence \ZZ
@@ -612,7 +608,7 @@
{\obeylines\gdef\makeinref#1 #2 #3
{\ifsorted\else\ttoks={\[#1 #2 #3}\immediate\write\reffile{+ \the\ttoks}\fi %
\hangindent=1em \noindent #2\miniform#3, %<== space!
- \S\ifacro{\pdfnote#1.}\else{#1}\fi.\par}}
+ \S\ifpdf{\pdfnote#1.}\else{#1}\fi.\par}}
{\obeylines\gdef\makeoutref#1 #2 #3
{\ifsorted\else\ttoks={\]#1 #2 #3}\immediate\write\reffile{+ \the\ttoks}\fi %
\hangindent=1em \noindent #2\miniform#3, \extref#1.\par}}
@@ -652,8 +648,8 @@
%\global\advance\pageno by1}
%\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{}
@@ -676,11 +672,12 @@
\immediate\write\cont{\catcode `\noexpand\@=12\relax} % \makeatother
\immediate\closeout\cont % the contents information has been fully gathered
\fi}
-\def\fin{\ifacro \message{Section names:}
+\def\fin{\ifpdf \message{Section names:}
\def\U##1.{} \def\Us##1.{} \let\I=\relax \let\*=*
\def\outsecname{Names of the sections}
- \ifpdftex \makebookmarks
- \pdfoutline goto num 1 count -\secno {\outsecname}
+ \ifpdftex \makebookmarks \countsections
+ \pdfdest name {NOS} fith
+ \pdfoutline goto name {NOS} count -\the\countD {\outsecname}
\def\X##1:##2\X{\firstsecno##1.%
{\toksF={}\makeoutlinetoks##2\outlinedone\outlinedone}%
\pdfoutline goto num \the\toksA \expandafter{\the\toksE}}
@@ -692,6 +689,10 @@
/A << /S /GoTo /D (\romannumeral\the\toksA) >> >>}}
\fi \readsections \fi}
\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\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}}}
@@ -712,7 +713,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}}}
+ %\ \ifpdf\pdflink{#3}{\romannumeral#3}\else#3\fi\hbox to3em{\hss#4}}}
%\def\consetup#1{\ifcase#1 \bf % depth -1 (@**)
%\or % depth 0 (@*)
%\or \hskip2em % depth 1 (@*1)
Modified: trunk/Master/texmf-dist/tex/plain/cweb/cwebmac.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/cweb/cwebmac.tex 2022-06-19 13:01:23 UTC (rev 63651)
+++ trunk/Master/texmf-dist/tex/plain/cweb/cwebmac.tex 2022-06-19 13:31:24 UTC (rev 63652)
@@ -1,25 +1,19 @@
% standard macros for CWEB listings (in addition to plain.tex)
-% Version 4.8 --- June 2022
+% Version 4.9 --- June 2022
\ifx\renewenvironment\undefined\else\endinput\fi % LaTeX will use other macros
-\xdef\fmtversion{\fmtversion+CWEB4.8}
-\chardef\cwebversion=4 \chardef\cwebrevision=8
-\newif\ifpdf
-\ifx\pdf+\pdftrue\fi
+\xdef\fmtversion{\fmtversion+CWEB4.9}
+\chardef\cwebversion=4 \chardef\cwebrevision=9
+\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
-\newif\ifacrohint \ifacro\acrohinttrue\fi \ifhint\acrohinttrue\fi
+\fi
+\newif\ifacrohint \ifpdf\acrohinttrue\fi \ifhint\acrohinttrue\fi
\let\:=\. % preserve a way to get the dot accent
% (all other accents will still work as usual)
@@ -139,7 +133,7 @@
\newif\iftokprocessed \newif\ifTnum \newif\ifinstr
{\def\\{\global\let\spacechar= }\\ }
-\ifacro % The following are pdf macros
+\ifpdf % The following are pdf macros
\def\thewidth{\the\wd0 \space}
\def\theheight{\the\ht\strutbox\space}
\def\thedepth{\the\dp\strutbox\space}
@@ -267,7 +261,7 @@
\let\pdflink=\HINTlink
\fi % End of HINT macros
-% Common macros for \ifacro and \ifhint
+% 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={}%
@@ -294,14 +288,14 @@
\def\maketoksdone{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
\fi % End of common macros
-\def\pdfURL#1#2{\ifpdftex\pdfannotlink height \theheight depth \thedepth
- 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}%
+ \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 /Action /Subtype /Link /A << /S /URI /URI (#2) >> >>}\box0\relax}%
- \else #1 ({\tt#2})\fi\fi}
+ 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
@@ -310,7 +304,7 @@
\sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50
\ifhint\HINTlabel\fi% Start page before section
\noindent{\let\*=\lapstar\bf\secstar.\quad}%
- \ifacro \smash{\raise\baselineskip\hbox to0pt{\let\*=\empty
+ \ifpdf \smash{\raise\baselineskip\hbox to0pt{\let\*=\empty
\ifpdftex \pdfdest num \secstar fith%
\else \special{pdf: dest (\romannumeral\secstar)
[ @thispage /FitH @ypos ]}\fi}}\fi}
@@ -343,7 +337,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
+ \ifpdf{\toksF={}\makeoutlinetoks#3\outlinedone\outlinedone}\fi
\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
@@ -352,11 +346,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
- \else \ifpdf\special{pdf: outline #1 << /Title (\the\toksE) /Dest
- [ @thispage /FitH @ypos ] >>}\fi\fi
+ \advancenumber{chunk\the\countB.\expnumber{curr\the\countB}}\fi\fi
+ \else \special{pdf: outline #1 << /Title (\the\toksE) /Dest
+ [ @thispage /FitH @ypos ] >>}\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
@@ -433,8 +427,8 @@
\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 +489,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 \countsections \fi % added in Version 3.68 and 4.9
+ \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
@@ -508,7 +503,7 @@
\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
+ \ifpdf \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 -\the\countD {\outsecname}
@@ -555,7 +550,7 @@
\ \ifhint
\HINTlink{#3}{\romannumeral#3}% No page numbers in HINT
\HINTcontents{#1}{#2}{#3}%
- \else\ifacro\pdflink{#3}{\romannumeral#3}\else#3\fi
+ \else\ifpdf\pdflink{#3}{\romannumeral#3}\else#3\fi
\hbox to3em{\hss#4}\fi}}
\def\consetup#1{\ifcase#1 \bf % depth -1 (@**)
\or % depth 0 (@*)
More information about the tex-live-commits
mailing list.