texlive[72015] Master/texmf-dist: pwebmac (12aug24)

commits+karl at tug.org commits+karl at tug.org
Mon Aug 12 22:04:43 CEST 2024


Revision: 72015
          https://tug.org/svn/texlive?view=revision&revision=72015
Author:   karl
Date:     2024-08-12 22:04:42 +0200 (Mon, 12 Aug 2024)
Log Message:
-----------
pwebmac (12aug24)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/plain/pwebmac/README.md
    trunk/Master/texmf-dist/doc/plain/pwebmac/index.md
    trunk/Master/texmf-dist/doc/plain/pwebmac/makeall
    trunk/Master/texmf-dist/doc/plain/pwebmac/webman.ch
    trunk/Master/texmf-dist/tex/plain/pwebmac/pwebmac.tex

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/plain/pwebmac/editorsnote.tex

Modified: trunk/Master/texmf-dist/doc/plain/pwebmac/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/plain/pwebmac/README.md	2024-08-12 12:00:40 UTC (rev 72014)
+++ trunk/Master/texmf-dist/doc/plain/pwebmac/README.md	2024-08-12 20:04:42 UTC (rev 72015)
@@ -38,4 +38,4 @@
 
 The `pwebmac` package is free software and may be used without constraints.
 
-This is version **4.12** of the `pwebmac` package — 2024-05-24, Andreas Scherer.
+This is version **5.0** of the `pwebmac` package — 2024-08-12, Andreas Scherer.

Added: trunk/Master/texmf-dist/doc/plain/pwebmac/editorsnote.tex
===================================================================
--- trunk/Master/texmf-dist/doc/plain/pwebmac/editorsnote.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/plain/pwebmac/editorsnote.tex	2024-08-12 20:04:42 UTC (rev 72015)
@@ -0,0 +1,22 @@
+\font\ninett=cmtt9
+
+\def\editorsnote{\noindent Editor's Note: The present variant of
+  this {\ninett C/WEB} source file has been modified for use in
+  the \TeX~Live system.}
+
+\def\changedsections{\jobname.chs}
+\def\readchanges{\input \changedsections}
+\newread\testread \newwrite\writechanges
+\openin\testread=\changedsections\relax
+\ifeof\testread % First run
+  \let\readchanges=\relax
+  \let\CH=\ch
+  \def\ch#1.{\begingroup
+    \let\\=\BS \let\*=\let \let\ch=\relax
+    \immediate\openout\writechanges=\changedsections
+    \immediate\write\writechanges{\par\noindent\ch#1.}
+    \immediate\closeout\writechanges
+    \let\ch=\CH \ch#1.
+    \endgroup}
+\else\closein\testread % Second run
+\fi


Property changes on: trunk/Master/texmf-dist/doc/plain/pwebmac/editorsnote.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/plain/pwebmac/index.md
===================================================================
--- trunk/Master/texmf-dist/doc/plain/pwebmac/index.md	2024-08-12 12:00:40 UTC (rev 72014)
+++ trunk/Master/texmf-dist/doc/plain/pwebmac/index.md	2024-08-12 20:04:42 UTC (rev 72015)
@@ -61,8 +61,10 @@
   [`WEBMAN`](web/webman.pdf) \|
   [`WEAVE`](web/weave.pdf)+[`chg`](web/weave-changes.pdf) \|
   [`TANGLE`](web/tangle.pdf)+[`chg`](web/tangle-changes.pdf) \|
-  [`TWILL`](web/twill.pdf) \]
+  [`TWILL`](web/twill.pdf)[^1] \]
 
+[^1]: `TWILL` is presented here as a changed variant of `WEAVE`.
+
 ## Complementary WEB programs by other authors
 
 * `other/` \[
@@ -81,14 +83,21 @@
   [`COMMON`](cweb/common.pdf)+[`chg`](cweb/common-changes.pdf) \|
   [`CTANGLE`](cweb/ctangle.pdf)+[`chg`](cweb/ctangle-changes.pdf) \|
   [`CWEAVE`](cweb/cweave.pdf)+[`chg`](cweb/cweave-changes.pdf) \|\
-  [`CTWILL`](cweb/ctwill.pdf) \|
+  [`CTWILL`](cweb/ctwill.pdf)[^2] \|
   [`REFSORT`](cweb/refsort.pdf)+[`chg`](cweb/refsort-changes.pdf) \|
   [`TWINX`](cweb/twinx.pdf)+[`chg`](cweb/twinx-changes.pdf) \]
 * `ctie/` \[ [`CTIE`](ctie/ctie.pdf)+[`chg`](ctie/ctie-changes.pdf) \]
 * `tie/` \[ [`TIE`](tie/tie.pdf)+[`chg`](tie/tie-changes.pdf) \]
 * `hitex/` \[ [`HiTeX`](hitex/hitex.pdf) \]
-* `mp/` \[ [`MetaPost`](mp/mp.pdf) \]
+* `mp/` \[ [`MP`](mp/mp.pdf) \| [`MPOST`](mp/mpost.pdf) \][^3]
 
+[^2]: `CTWILL` is presented here in its own format with “mini-indexes” for
+  every two consecutive pages.
+
+[^3]: `MP` and `MPOST` have received quite a few changes “behind the scenes” in
+  order to present them in this collection; see project
+  [`mplibdir`](https://github.com/ascherer/mplibdir) for details.
+
 ## Errata for “Computers & Typesetting” by Donald E.\ Knuth
 
 * `errata/`
@@ -109,4 +118,4 @@
 
 ## Happy C/WEB Programming!
 
-2024-05-20 Andreas Scherer
+2024-08-11 Andreas Scherer

Modified: trunk/Master/texmf-dist/doc/plain/pwebmac/makeall
===================================================================
--- trunk/Master/texmf-dist/doc/plain/pwebmac/makeall	2024-08-12 12:00:40 UTC (rev 72014)
+++ trunk/Master/texmf-dist/doc/plain/pwebmac/makeall	2024-08-12 20:04:42 UTC (rev 72015)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/sh -e
 
 PROG=$(basename $0)
 
@@ -11,7 +11,7 @@
 Produce TeX output in DVI, PDF or HINT format from a set of C/WEB programs
 included in the 'TeX Live' source tree.
 
-Options are (--long options only with GNU getopt):
+Options are (--long options only with Linux-getopt):
 	-c, --changes		Apply change file to C/WEB source
 	-f, --files STRING	Process only subset of C/WEB programs
 	-h, --help		Print this help message and exit
@@ -28,7 +28,7 @@
 LONGOPTS=changes,files:,help,new,outdir:,pdftocfront,tex:,validpdf
 SHRTOPTS=cf:hno:pt:v
 
-CHANGES=false # apply changefile to C/WEB source
+CHANGES= # apply changefile to C/WEB source
 FILESELECT=false # user-defined '--files' selection
 NEW=false # '\input pwebmac' instead of '\input webmac' for PDF et al.
 OUTDIR=. # path where the resulting tarballs are placed
@@ -36,6 +36,9 @@
 TEX=tex # or 'pdftex' or 'xetex' or 'hitex' or 'luatex'
 VALID=false # give 'pdftex' a chance to produce valid output
 
+# Extra material -- unpublished
+LOCALSTUFF=/opt/github/web
+
 # Initial list of C/WEB sources to process, overridable with option '-f':
 KNUTHWHERE=$(locate /bibtex.web)
 if [ -z "$KNUTHWHERE" ]
@@ -46,7 +49,8 @@
 FILES="$KNUTHWARE/*.web pdftex.web xetex.web twill"
 WEBINPUTS=$KNUTHWARE//:
 
-FILES="$FILES common ctangle cweave ctwill refsort twinx ctie tie hitex mp"
+FILES="$FILES common ctangle cweave ctwill refsort twinx ctie tie hitex \
+	mp mpost mpmath mpmathbinary mpmathdecimal mpmathdouble mpstrings tfmin"
 CWEBINPUTS=$KNUTHWARE//:
 
 KNUTHWHERE=$(locate /glue.web)
@@ -58,7 +62,7 @@
 
 export WEBINPUTS CWEBINPUTS
 
-getopt -T >/dev/null
+getopt -T >/dev/null && true # keep going
 
 if [ $? -eq 4 ] # Check for Linux-getopt with extensions
 then OPTS=$(getopt -n $PROG -o $SHRTOPTS -l $LONGOPTS -- "$@")
@@ -73,7 +77,7 @@
 while true
 do
 	case "$1" in
-		-c | --changes ) CHANGES=true; shift ;;
+		-c | --changes ) CHANGES="-changes"; shift ;;
 		-f | --files ) FILES="$2"; FILESELECT=true; shift 2 ;;
 		-h | --help ) usage; exit 0 ;;
 		-n | --new ) NEW=true; shift ;;
@@ -106,16 +110,15 @@
 	pdftex | luatex ) # actually only necessary for 'pwebmac.tex'
 		VALID=true ;;
 
-	tex ) # plain TeX
-		XETEX="$XETEX --no-pdf" # XeTeX's extended DVI format
+	* ) # plain TeX and XeTeX use different approaches
+		[ tex = "$TEX" ] && XETEX="$XETEX --no-pdf"
+			# XeTeX's extended DVI format
 		VALID=false ;;
-
-	* ) VALID=false ;; # plain TeX and XeTeX use different approach
 esac
 
 # Valid PDF output from 'pdftex' and 'luatex': In 'pwebmac.tex' set '\countD'
 # to the actual number of @<named modules@>, not the number of all sections.
-if $VALID
+if $VALID && { [ pdftex = "$TEX" ] || [ luatex = "$TEX" ]; }
 then
 	NEW=true # PDF output requires 'pwebmac.tex'
 	TEX="$TEX --shell-escape"
@@ -122,11 +125,10 @@
 fi
 
 # Use alternative TeX macros more suited for PDF output.
-if $NEW
-then WEAVE="$WEAVE -p"
-fi
+[ -n "$CHANGES" ] && NEW=true
+$NEW && WEAVE="$WEAVE -p"
 
-# WEB and CWEB programs we want to get formatted
+# Loop over WEB and CWEB programs we want to get formatted
 for f in $FILES
 do
 	f=$(basename $f .web)
@@ -133,23 +135,26 @@
 
 	case $f in
 		pdftex ) # Fix several 'Overfull \hbox'es
-			tie -m $f.web $f.web /opt/github/web/$f.ch ;;
+			tie -m $f.web $f.web $LOCALSTUFF/$f.ch ;;
 
-		hitex | mp ) # Beautifications for 'hitex.w' and 'mp.w'
-			tie -m $f.w $f.w /opt/github/web/$f.ch ;;
+		mp | mpost | mpmath* | mpstrings | tfmin )
+			# Beautifications for MetaPost
+			tie -m $f.w $f.w $LOCALSTUFF/$f.ch ;;
 
 		weave | twill )
-			cp $KNUTHWARE/weave.web .
 			if [ "$HITEX" = "$TEX" ] # Fix non-constant factor
-			then $SED_I -e "s/\\\\the\\\\hsize/460pt/" weave.web
+			then
+				cp $KNUTHWARE/weave.web .
+				$SED_I weave.web -e 's/\\the\\hsize/460pt/'
 			fi ;;
 	esac
 
-	if $CHANGES
+	if [ -n "$CHANGES" ]
 	then
 		case $f in
 			# These are changes in and of themselves
-			ctwill | twill | glue | hitex | mp ) continue ;;
+			ctwill | twill | glue | hitex | mp | mpost | \
+				mpmath* | mpstrings | tfmin ) continue ;;
 
 			# CWEB programs have individual changefiles
 			common ) $CWEAVE $f comm-w2c ;;
@@ -162,93 +167,82 @@
 			# main WEB programs have complex change files
 			tex | mf | pdftex | xetex )
 				WEBINPUTS=.:$KNUTHWARE/../../Work//:$WEBINPUTS: \
-				$WEAVE $f $f-final
+				$WEAVE $f $f-final ;;
 
-				# FIX: XeTeX uses '\pdfTeX' from section 114,
-				# which is not changed and thus 'disappears';
-				# repeat in preamble.
-				if [ xetex = $f ]
-				then $SED_I -e "s/\(\\\\let\\\\maybe\)/\\\\def\\\\pdfTeX{pdf\\\\TeX}\n\1/" $f.tex
-				fi ;;
-
 			# all other WEB codes have singular changefiles
 			* ) $WEAVE $f $f ;;
 		esac
 
 		# only document changed modules/sections
-		$SED_I -e "s/\(\\\\let\\\\maybe=\)\\\\iftrue/\1\\\\iffalse/" \
-			$f.tex
-	else
+		$SED_I $f.tex -e '/\\let\\maybe/s/\\iftrue/\\iffalse/'
+	else # -z $CHANGES
 		case $f in
-			ctwill )
-				# apply tons of editorial changes to 'ctwill.w'
-				if [ "$HITEX" = "$TEX" ]
-				then ctie -m $f.w cweave.w $f-w2c.ch $f-hint.ch
-				else ctie -m $f.w cweave.w $f-w2c.ch $f-mini.ch
-				fi
+			ctwill ) # apply tons of editorial changes to 'ctwill.w'
+				[ "$HITEX" = "$TEX" ] &&
+					ctie -m $f.w cweave.w $f-w2c.ch $f-hint.ch ||
+					ctie -m $f.w cweave.w $f-w2c.ch $f-mini.ch
 				$CTWILL $f # prime the pump
 				$CTWILL $f ;; # get decent answers
 
 			c* | refsort | twinx | tie ) $CWEAVE $f ;;
+			hitex ) $CWEAVE $f || true ;; # lots of unused sections
 
-			hitex | mp ) CWEBINPUTS=.: $CWEAVE $f ;;
+			mp | mpost | mpmath* | mpstrings | tfmin )
+				CWEBINPUTS=.: $CWEAVE $f ;;
 
-			twill )
-				WEBINPUTS=.:$WEBINPUTS \
-				tie -m $f.web weave.web weave.ch weav-$f.ch
-				WEBINPUTS=.: $WEAVE $f ;;
+			twill ) WEBINPUTS=.:$WEBINPUTS \
+				tie -c $f.ch weave.web weave.ch weav-$f.ch
+				WEBINPUTS=.:$WEBINPUTS $WEAVE weave $f $f ;;
 
-			pdftex | weave ) WEBINPUTS=.: $WEAVE $f ;;
+			pdftex | weave ) WEBINPUTS=.:$WEBINPUTS $WEAVE $f ;;
 
 			* ) $WEAVE $f ;;
 		esac
-	fi
+	fi # $CHANGES
 
 	# 'pwebmac' is for WEB only; do nothing for CWEB programs
-	if $NEW && echo $f | grep -v -q -E '^c|refsort|twinx|tie|hitex|mp'
+	if $NEW && echo $f | grep -v -q -E \
+		'^c|refsort|twinx|tie|hitex|^mp|tfmin'
 	then
 		# timestamp on table-of-contents page or the first page
 		case $f in
 			bibtex | patgen | tangle | weave | twill )
-				$SED_I -e "s/\(\\\\def\\\\title\)/\\\\datecontentspage\n\1/" $f.tex ;;
+				$SED_I $f.tex -e 's/\\def\\title{/\\datecontentspage\n&/' ;; # }
 
 			mf | tex | pdftex | xetex )
-				$SED_I -e "s/\(\\\\def\\\\topofcontents\)/\\\\datethis\n\\\\emergencystretch=.1\\\\hsize\n\1/" $f.tex
-
 				# amend '\N' redefinition for PDF outlines in
 				# Metafont and TeX (also pdfTeX and XeTeX)
 				# 'pwebmac' defines headers differently
-				$SED_I -e "s/\(\\\\outer\\\\def\\\\N.*{\)/\1%/" \
-					 -e "s/\\\\def\\\\rhead\(.*}\)/\\\\gtitle=\1\\\\MN#1.\\\\vfill\\\\eject/" \
-					 $f.tex
-
+				cat > texmf-pdf.sed << 'FI'
+s/\\outer\\def\\N.*{/&%/
+s/\\def\\rhead\({.*}\)/\\gtitle=\1\\MN#1.\\vfill\\eject/
+s/\\def\\title{/\\datethis\n\\emergencystretch=.1\\hsize\n&/
+FI
 				# active links in PDF outlines/bookmarks
-				cat > texmf-pdf.patch << FI
-  \ifpdf{\toksF={}\makeoutlinetoks{[#2] #3}\outlinedone\outlinedone}\fi
+				cat > texmf-pdf.patch1 << FI
+  \ifpdf{\makeoutlinetoks{[#2] #3}\outlinedone}\fi
 FI
-				$SED_I -e "/\\\\outer\\\\def\\\\N/ {
-					r texmf-pdf.patch
-					}" $f.tex
-
-				$SED_I -e "s/{\\\\the\\\\pageno}}}\\\\next/{\\\\the\\\\pageno}{\\\\the\\\\toksE}}}\\\\next/" $f.tex
-
-				cat > texmf-pdf.patch << FI
+				cat >> texmf-pdf.sed << 'FI'
+/\\outer\\def\\N/r texmf-pdf.patch1
+s/{\\the\\pageno}/&{\\the\\toksE}/
+FI
+				cat > texmf-pdf.patch2 << FI
   \ifpdflua\relax\else
   \ifpdf\special{pdf: outline 0 << /Title (\the\toksE) /Dest
     [ @thispage /FitH @ypos ] >>}\fi\fi
 FI
-				$SED_I -e "/  \\\\edef\\\\next/ {
-					r texmf-pdf.patch
-					}" $f.tex
-				rm texmf-pdf.patch ;;
+				cat >> texmf-pdf.sed << 'FI'
+/\\edef\\next/r texmf-pdf.patch2
+FI
+				$SED_I $f.tex -f texmf-pdf.sed
+				rm -f texmf-pdf.* ;;
 
-			* ) $SED_I -e "s/\(\\\\def\\\\botofcontents\)/%\1/" \
-				-e "s/  \\\\centerline{\(\\\\hsize\)/\\\\def\\\\covernote{\1/" \
-				-e "s/\(Publishing Company.}}\)}/\1\n\\\\datecontentspage/" \
-				-e "s/\(trademark of the American Mathematical Society.}}\)}/\1\n\\\\datecontentspage/" \
-				$f.tex ;;
+			* ) $SED_I $f.tex -e '/\\def\\botofcontents/d' \
+				-e 's/  \\centerline{\(\\hsize\)/\\def\\covernote{\1/' \
+				-e 's/\(Publishing Company.}}\)}/\1\n\\datecontentspage/' \
+				-e 's/\(Mathematical Society.}}\)}/\1\n\\datecontentspage/' ;;
 		esac
-	fi
+	fi # $NEW
 
 	# special treatment for individual C/WEB programs
 	case $f in
@@ -258,56 +252,92 @@
 		# 'E' no longer free to be active character
 		# fix table-of-contents page for bibtex
 		# FIX: don't wait for Oren Patashnik.
-		bibtex ) $SED_I -e "s/\\\\def\\\\titlepage{F}/\\\\titletrue/" $f.tex
-			if ! $CHANGES
-			then $SED_I -e "71,78d" $f.tex
-			fi ;;
+		bibtex ) $SED_I $f.tex -e 's/\\def\\titlepage{F}/\\titletrue/'
+			[ -z "$CHANGES" ] && $SED_I $f.tex -e "71,78d" ;;
 
+		# FIX: GFtoDVI uses 'Metafont' in a module name;
+		# this should appear correctly in the bookmarks, too.
+		gftodvi ) $NEW && $SED_I $f.tex \
+			-e 's/\\def\\(/\\ifpdf\\sanitizecommand\\MF{Metafont}\\fi\n\n&/' ;; # )
+
 		# FIX: 'glue.web' obviously uses an old 'webmac.tex'.
-		glue ) $SED_I -e "s/\(\\\\def\\\\title{GLUE}\)/\1\n\\\\pageno=\\\\contentspagenumber \\\\advance\\\\pageno by1\\\\relax/" \
-			-e "s/titlefalse/titletrue/" $f.tex ;;
+		glue ) $SED_I $f.tex -e 's/titlefalse/titletrue/' \
+			-e 's/\\def\\title{GLUE}/&\n\\pageno=\\contentspagenumber \\advance\\pageno by1\\relax/' ;;
 
+		# FIX: Metafont uses '\over' in several module names;
+		# this should appear correctly in the bookmarks, too.
+		mf ) $NEW && $SED_I $f.tex \
+			-e 's/\\def\\(/\\ifpdf\n\\sanitizecommand\\MF{Metafont}\n\\sanitizecommand\\over{\/}\n\\sanitizecommand\\langle{<}\n\\sanitizecommand\\rangle{>}\n\\fi\n\n&/' ;; # )
+
+		# FIX: MFT uses '\pb' in several module names;
+		# this should appear correctly in the bookmarks, too.
+		mft ) $NEW && $SED_I $f.tex \
+			-e 's/\\def\\pb.*/&\n\\ifpdf\\sanitizecommand\\pb{\|...\|}\\fi/' ;;
+
 		# FIX: pdfTeX uses '\pdfTeX' in section names; these should
 		# appear correctly in the bookmarks, too.
-		pdftex )
-			if $NEW && [ tex != "$TEX" ] && [ "$HITEX" != "$TEX" ]
-			then $SED_I -e "s/\(\\\\def\\\\pdfTeX{pdf\\\\TeX}\)/\1 \\\\sanitizecommand\\\\pdfTeX{pdfTeX}\\\\sanitizecommand\\\\eTeX{e-TeX}/" $f.tex
-			fi ;;
+		pdftex ) $NEW && $SED_I $f.tex \
+			-e 's/\\def\\pdfeTeX{pdf\\eTeX}/&\n\\ifpdf\n\\sanitizecommand\\pdfTeX{pdfTeX}\n\\sanitizecommand\\eTeX{e-TeX}\n\\sanitizecommand\\over{\/}\n\\fi/' ;;
 
 		# FIX: weave uses '\max' in name of module 173; this should
 		# appear correctly in the bookmarks, too.
-		weave )
-			if $NEW && [ tex != "$TEX" ] && [ "$HITEX" != "$TEX" ]
-			then $SED_I -e "s/\(\\\\def\\\\({}\)/\\\\sanitizecommand\\\\max{max}\n\1/" $f.tex
-			fi ;;
+		weave ) $NEW && $SED_I $f.tex \
+			-e 's/\\def\\({}/\\ifpdf\\sanitizecommand\\max{max}\\fi\n&/' ;; # )
 
 		# FIX: purge obsolete macros from XeTeX.
-		xetex ) $SED_I -e "/\\\\input xewebmac/d" $f.tex ;;
+		# FIX: XeTeX uses '\pdfTeX' from section 114, which is not
+		# changed and thus 'disappears'; repeat in preamble.
+		# FIX: apply '\sanitizecommand' for bookmarks.
+		xetex ) $SED_I $f.tex -e '/\\input xewebmac/d' \
+			-e 's/\\let\\maybe/\\def\\pdfTeX{pdf\\TeX}\n&/'
+			$NEW && $SED_I $f.tex \
+				-e 's/\\def\\pdfTeX{pdf\\TeX}/&\n\\ifpdf\\sanitizecommand\\pdfTeX{pdfTeX}\\fi/' \
+				-e 's/\\def\\eTeX/\\ifpdf\n\\sanitizecommand\\eTeX{e-TeX}\n\\sanitizecommand\\over{\/}\n\\fi\n&/' ;;
 
 		# timestamp on table-of-contents page or the first page
-		hitex | mp ) $SED_I -e "s/\(\\\\def\\\\topofcontents\)/\\\\datethis\n\\\\emergencystretch=.1\\\\hsize\n\1/" $f.tex ;;
+		hitex | mp ) $SED_I $f.tex -e 's/\\def\\topofcontents/\\datethis\n\\emergencystretch=.1\\hsize\n&/' ;;
+		common | ctangle | cweave | ctie | tie ) $SED_I $f.tex -e 's/\\def\\botofcontents/\\datethis\n&/' ;;
+		mpost | mpmath* | mpstrings | tfmin ) $SED_I $f.tex -e 's/\\def\\title{/\\datecontentspage\n\n&/' ;; # }
 	esac
 
 	# shift table-of-contents pages to the front in PDF
 	if $PDFTOCFRONT && echo $f | grep -v -q -E 'ctwill|hitex'
+	then $SED_I $f.tex \
+		-e '0,/\\N[1{]/s/\\N[1{]/\\input pdfwebtocfront\n\n&/'
+	fi # $PDFTOCFRONT
+
+	if [ -n "$CHANGES" ] || [ twill = "$f" ]
 	then
-		$SED_I -e "0,/\\\\N[1{]/s/\(\\\\N[1{]\)/\\\\input pdfwebtocfront\n\n\1/" $f.tex
+		# We add an Editor's Note and the list of changed
+		# sections on the ToC page.
+		cp $LOCALSTUFF/editorsnote.tex .
 
-		# only XeTeX can process XETEX.WEB
-		if [ xetex = $f ]
-		then $XETEX $f # run XeTeX twice
-		else $TEX $f # run TeX twice
-		fi
+		case $f in
+			mf ) $SED_I $f.tex -e 's/\\datethis/\\input editorsnote.tex\n\\def&{\\def\\startsection{\\leftline{\\sc\\today\\ at \\hours}\n  \\medskip\\editorsnote\\readchanges\\bigskip\n  \\let\\startsection=\\stsec\\stsec}}\n&/' ;;
 
-		# run TEX.WEB three times to fix table-of-contents
-		if [ tex = $f ]
-		then $TEX $f
-		fi
-	fi
+			# TeX and XeTeX grow significantly for TeX Live
+			# so there's enough room on the last ToC page.
+			pdftex | tex | xetex ) $SED_I $f.tex \
+				-e '/\\datethis/d' \
+				-e 's/\(\\def\\botofcontents\).*/\\input editorsnote.tex\n\1{\\hsize6.5in\\vskip 0pt plus 1filll\n  \\editorsnote\\readchanges\\medskip\\noindent\\sc\\today\\ at \\hours}/' \
+				-e 's/\\input pdfwebtocfront/&\n\n\\def\\tocpages{2}/' ;;
 
+			bibtex | patgen | tangle | weave | refsort | twinx ) $SED_I $f.tex -e 's/\\date.*/\\input editorsnote\n\\def\\covernote{\\vbox{\\editorsnote\\readchanges\\par}}\n\\datecontentspage/' ;;
+
+			common | ctangle | cweave | ctie | tie ) $SED_I $f.tex \
+				-e 's/\\def\\covernote/\\input editorsnote.tex\n&/' \
+				-e 's/^}}/\\bigskip\\editorsnote\\readchanges\\par&/' ;;
+
+			twill ) $SED_I $f.tex \
+				-e 's/\\datecontentspage/\\input editorsnote.tex\n\\def\\covernote{\\vbox{\\editorsnote\\readchanges\\par}}\n&/' ;;
+
+			* ) $SED_I $f.tex \
+				-e 's/\\def\\title{/\\input editorsnote.tex\n&/' \
+				-e 's/\\vbox{\\ninerm/&\\editorsnote\\readchanges\\medskip/' ;;
+		esac
+	fi # $CHANGES
+
 	case $f in
-		xetex ) $XETEX $f ;; # only XeTeX can process XETEX.WEB
-
 		ctwill ) # gives two different outcomes
 			if [ "$HITEX" = "$TEX" ] # sort mini-indexes
 			then # directly in the TeX file
@@ -318,125 +348,99 @@
 			fi
 			$TEX $f ;;
 
-		refsort ) $TEX -interaction nonstopmode $f ;;
-
-		* ) $TEX $f ;;
+		* ) # run TeX twice
+			if $PDFTOCFRONT || [ -n "$CHANGES" ]
+			then # only XeTeX can process XETEX.WEB
+				[ xetex = $f ] && $XETEX $f || $TEX $f
+			fi
+			[ xetex = $f ] && $XETEX $f || $TEX $f ;;
 	esac
 done
 
+# create tarballs w/o changes for publication
 if ( $PDFTOCFRONT || [ "$HITEX" = "$TEX" ] ) && ! $FILESELECT
 then
-	# create tarballs w/o changes for publication
-	if $CHANGES
+	if [ -z "$CHANGES" ]
 	then
-		for f in *.$PDF
-		do
-			case $f in *-changes.$PDF ) rm -f $f; continue ;;
-			esac
-			mv $f $(basename $f .$PDF)-changes.$PDF
+		export TEXINPUTS=.:$(kpsewhich --var-value=TEXMFDIST)//:$KNUTHWARE//
+		touch pages.tex # let 'manmac' produce output at all
+
+		$TEX -jobname=errorlog $LOCALSTUFF/Xerrorlog.tex
+		for f in one two three four five six seven eight nine ten \
+			eleven twelve
+		do $TEX -jobname errata.$f errata.$f
 		done
-		if [ "$HITEX" = "$TEX" ]
-		then
-			rm -f xetex-changes.pdf
-			mv xetex.pdf xetex-changes.pdf
-		fi
-		$PAX "$OUTDIR/etc-changes.tar.gz" -s ,^,etc/, \
-			vftovp-changes.$PDF vptovf-changes.$PDF
-		$PAX "$OUTDIR/mf-changes.tar.gz" -s ,^,mf/, \
-			mf-changes.$PDF
-		$PAX "$OUTDIR/mfware-changes.tar.gz" -s ,^,mfware/, \
-			gftodvi-changes.$PDF gftopk-changes.$PDF \
-			gftype-changes.$PDF mft-changes.$PDF
-		$PAX "$OUTDIR/tex-changes.tar.gz" -s ,^,tex/, \
-			tex-changes.$PDF
-		$PAX "$OUTDIR/texware-changes.tar.gz" -s ,^,texware/, \
-			dvitype-changes.$PDF pltotf-changes.$PDF \
-			pooltype-changes.$PDF tftopl-changes.$PDF
-		$PAX "$OUTDIR/web-changes.tar.gz" -s ,^,web/, \
-			tangle-changes.$PDF weave-changes.$PDF
-		$PAX "$OUTDIR/bibtex-changes.tar.gz" -s ,^,bibtex/, \
-			bibtex-changes.$PDF
-		$PAX "$OUTDIR/other-changes.tar.gz" -s ,^,other/, \
-			dvicopy-changes.$PDF patgen-changes.$PDF \
-			pktogf-changes.$PDF pktype-changes.$PDF
-		$PAX "$OUTDIR/pdftex-changes.tar.gz" -s ,^,pdftex/, \
-			pdftex-changes.$PDF
-		$PAX "$OUTDIR/xetex-changes.tar.gz" -s ,^,xetex/, \
-			xetex-changes.pdf
-		$PAX "$OUTDIR/ctie-changes.tar.gz" -s ,^,ctie/, \
-			ctie-changes.$PDF
-		$PAX "$OUTDIR/tie-changes.tar.gz" -s ,^,tie/, \
-			tie-changes.$PDF
-		$PAX "$OUTDIR/cweb-changes.tar.gz" -s ,^,cweb/, \
-			common-changes.$PDF ctangle-changes.$PDF \
-			cweave-changes.$PDF refsort-changes.$PDF \
-			twinx-changes.$PDF
-	else
+		$TEX errata
+		$PAX "$OUTDIR/errata.tar.gz" -s ,^,errata/, err*.$PDF
+
+		$PAX "$OUTDIR/hitex.tar.gz" -s ,^,hitex/, hitex.$PDF
+		$PAX "$OUTDIR/mp.tar.gz" -s ,^,mp/, mp.$PDF mpost.$PDF
+
 		# Finally, build the remaining documents
 		# * TeX and Metafont test routines
 		# * WEB and CWEB manuals
-		export TEXINPUTS=.:$(kpsewhich --var-value=TEXMFDIST)//:$KNUTHWARE//
-
 		rm -f trapman.tex webman.tex cwebman.tex
 
 		# FIX: Prepare 'trapman' for automatic processing; several
 		# input files are renamed in TeX Live (in fact, there are
 		# additional files for MetaPost).
-		f=$(kpsewhich -engine tex trapman)
-		tie -m $(basename $f) $f /opt/github/web/$(basename $f .tex).ch
-
 		# Prepare 'webman' with section links and bookmarks.
-		f=$(kpsewhich -engine tex webman)
-		tie -m $(basename $f) $f /opt/github/web/$(basename $f .tex).ch
+		for f in trapman webman
+		do
+			f=$(kpsewhich -engine tex $f)
+			tie -m $(basename $f) $f $LOCALSTUFF/$(basename $f .tex).ch
+		done
 
 		# Prepare 'cwebman' with footnotes describing the extended CWEB.
 		f=$(kpsewhich -engine tex cwebman)
 		tie -m $(basename $f) $f $(basename $f .tex)-w2c.ch
-		if [ "$HITEX" = "$TEX" ]
-		then $SED_I -e "s/\(\\\\input cwebmac\)/\1\n\\\\input hiplainpage/" cwebman.tex
-		fi
 
-		touch pages.tex # let 'manmac' produce output at all
-
 		for f in tripman trapman webman cwebman
 		do $TEX $f
 		done
 
-		$TEX -jobname=errorlog /opt/github/web/Xerrorlog.tex
-
-		for f in one two three four five six seven eight nine ten \
-			eleven twelve
-		do $TEX -jobname errata.$f errata.$f
-		done
-
-		$TEX errata
-
-		$PAX "$OUTDIR/errata.tar.gz" -s ,^,errata/, \
-			errorlog.$PDF errata.*.$PDF errata.$PDF
-		$PAX "$OUTDIR/etc.tar.gz" -s ,^,etc/, vftovp.$PDF vptovf.$PDF
 		$PAX "$OUTDIR/mf.tar.gz" -s ,^,mf/, mf.$PDF trapman.$PDF
-		$PAX "$OUTDIR/mfware.tar.gz" -s ,^,mfware/, \
-			gftodvi.$PDF gftopk.$PDF gftype.$PDF mft.$PDF
 		$PAX "$OUTDIR/tex.tar.gz" -s ,^,tex/, \
 			glue.$PDF tex.$PDF tripman.$PDF
-		$PAX "$OUTDIR/texware.tar.gz" -s ,^,texware/, \
-			dvitype.$PDF pltotf.$PDF pooltype.$PDF tftopl.$PDF
 		$PAX "$OUTDIR/web.tar.gz" -s ,^,web/, \
 			webman.$PDF tangle.$PDF weave.$PDF twill.$PDF
-		$PAX "$OUTDIR/bibtex.tar.gz" -s ,^,bibtex/, bibtex.$PDF
-		$PAX "$OUTDIR/other.tar.gz" -s ,^,other/, \
-			dvicopy.$PDF patgen.$PDF pktogf.$PDF pktype.$PDF
-		$PAX "$OUTDIR/hitex.tar.gz" -s ,^,hitex/, hitex.$PDF
-		$PAX "$OUTDIR/mp.tar.gz" -s ,^,mp/, mp.$PDF
-		$PAX "$OUTDIR/pdftex.tar.gz" -s ,^,pdftex/, pdftex.$PDF
-		$PAX "$OUTDIR/xetex.tar.gz" -s ,^,xetex/, xetex.pdf
-		$PAX "$OUTDIR/ctie.tar.gz" -s ,^,ctie/, ctie.$PDF
-		$PAX "$OUTDIR/tie.tar.gz" -s ,^,tie/, tie.$PDF
 		$PAX "$OUTDIR/cweb.tar.gz" -s ,^,cweb/, \
 			cwebman.$PDF common.$PDF ctangle.$PDF cweave.$PDF \
 			ctwill.$PDF refsort.$PDF twinx.$PDF
-	fi
+	else # -n $CHANGES
+		for f in *.$PDF
+		do
+			case $f in *$CHANGES.$PDF ) rm -f $f; continue ;; esac
+			mv $f $(basename $f .$PDF)$CHANGES.$PDF
+		done
+		[ "$HITEX" = "$TEX" ] && mv -f xetex.pdf xetex$CHANGES.pdf
+		$PAX "$OUTDIR/mf$CHANGES.tar.gz" -s ,^,mf/, mf$CHANGES.$PDF
+		$PAX "$OUTDIR/tex$CHANGES.tar.gz" -s ,^,tex/, tex$CHANGES.$PDF
+		$PAX "$OUTDIR/web$CHANGES.tar.gz" -s ,^,web/, \
+			tangle$CHANGES.$PDF weave$CHANGES.$PDF
+		$PAX "$OUTDIR/cweb$CHANGES.tar.gz" -s ,^,cweb/, \
+			common$CHANGES.$PDF ctangle$CHANGES.$PDF \
+			cweave$CHANGES.$PDF refsort$CHANGES.$PDF \
+			twinx$CHANGES.$PDF
+	fi # $CHANGES
 
+	$PAX "$OUTDIR/etc$CHANGES.tar.gz" -s ,^,etc/, \
+		vftovp$CHANGES.$PDF vptovf$CHANGES.$PDF
+	$PAX "$OUTDIR/mfware$CHANGES.tar.gz" -s ,^,mfware/, \
+		gftodvi$CHANGES.$PDF gftopk$CHANGES.$PDF \
+		gftype$CHANGES.$PDF mft$CHANGES.$PDF
+	$PAX "$OUTDIR/texware$CHANGES.tar.gz" -s ,^,texware/, \
+		dvitype$CHANGES.$PDF pltotf$CHANGES.$PDF \
+		pooltype$CHANGES.$PDF tftopl$CHANGES.$PDF
+	$PAX "$OUTDIR/other$CHANGES.tar.gz" -s ,^,other/, \
+		dvicopy$CHANGES.$PDF patgen$CHANGES.$PDF \
+		pktogf$CHANGES.$PDF pktype$CHANGES.$PDF
+	$PAX "$OUTDIR/xetex$CHANGES.tar.gz" -s ,^,xetex/, \
+		xetex$CHANGES.pdf
+	for f in bibtex pdftex ctie tie
+	do $PAX "$OUTDIR/$f$CHANGES.tar.gz" -s ,^,$f/, $f$CHANGES.$PDF
+	done
+
 	# Notes to self:
 	# (1) Create a user-friendly central entrypoint with
 	#     (a) pandoc index.md -o index.pdf

Modified: trunk/Master/texmf-dist/doc/plain/pwebmac/webman.ch
===================================================================
--- trunk/Master/texmf-dist/doc/plain/pwebmac/webman.ch	2024-08-12 12:00:40 UTC (rev 72014)
+++ trunk/Master/texmf-dist/doc/plain/pwebmac/webman.ch	2024-08-12 20:04:42 UTC (rev 72015)
@@ -56,6 +56,12 @@
   \else Appendix~#1\fi}
 @z
 
+ at x l.21
+\def\runninghead{{\tentt WEB} USER MANUAL}
+ at y
+\def\runninghead{{\ninett WEB} USER MANUAL}
+ at z
+
 @x l.34
 \vskip 15pt plus 3pt minus 3pt
 \noindent This memo describes how to write programs in the
@@ -64,22 +70,27 @@
 This memo describes how to write programs in the
 @z
 
- at x l.180
-\yskip\item{1)} A \TeX\ part, containing explanatory material about what
+ at x l.126
+well known work of Pierre-Arnoul de Marneffe [``Holon programming: A
+survey,'' Univ.\ de Liege, Service Informatique, Liege, Belgium, 1973; 135
 @y
-\yskip\itemitem{1)} A \TeX\ part, containing explanatory material about what
+well known work of Pierre-Arnoul de Marneffe [``\pdfURL{Holon programming:
+A survey}{https://github.com/holon-scribe/holon-programming},'' Univ.\ de
+Li\`ege, Service d'Informatique, Li\`ege, Belgium, 1973; 135
 @z
 
- at x l.183
-\item{2)} A definition part, containing macro definitions that serve as
+ at x l.180
+\yskip\item{1)} A \TeX\ part, containing explanatory material about what
 @y
-\itemitem{2)} A definition part, containing macro definitions that serve as
+\begingroup\parindent=2.5em
+\yskip\item{1)} A \TeX\ part, containing explanatory material about what
 @z
 
- at x l.187
-\item{3)} A \PASCAL\ part, containing a piece of the program that
+ at x l.190
+that its structure is readily perceived.
 @y
-\itemitem{3)} A \PASCAL\ part, containing a piece of the program that
+that its structure is readily perceived.\par
+\endgroup
 @z
 
 @x l.304
@@ -102,7 +113,7 @@
 gives precise details about this
 @z
 
- at x l.626
+ at x l.628
 outputs of \.{WEAVE} and \.{TANGLE} (see Appendix~C\null). Meta-comments
 @y
 outputs of \.{WEAVE} (see \Appendix B\null) and \.{TANGLE}
@@ -109,7 +120,22 @@
 (see \Appendix C\null). Meta-comments
 @z
 
- at x l.893
+ at x l.788
+\yskip\itemitem{a)}Comments in \PASCAL\ text should appear only after
+ at y
+\yskip
+\begingroup\parindent=1.5em
+\itemitem{a)}Comments in \PASCAL\ text should appear only after
+ at z
+
+ at x l.796
+statements.
+ at y
+statements.\par
+\endgroup
+ at z
+
+ at x l.895
 examples of ``real'' programs. Appendix~A shows the \.{WEB} input that
 generated modules 55--59 of the \.{WEAVE} program; Appendix~B shows the
 corresponding \TeX\ code output by \.{WEAVE}; and Appendix~C shows excerpts
@@ -119,7 +145,7 @@
 corresponding \TeX\ code output by \.{WEAVE}; and \Appendix C shows excerpts
 @z
 
- at x l.900
+ at x l.901
 report, in Appendices D and~E. The reader should first compare Appendix~A
 to the corresponding portion of Appendix~D; then the same material should
 be compared to Appendices B and~C. Finally, if time permits, the reader may
@@ -133,7 +159,7 @@
 and~\pdfURL{E}{tangle.pdf}, since \.{WEAVE}
 @z
 
- at x l.908
+ at x l.909
 Finally, Appendix F is the `\.{webmac}' file that sets \TeX\ up to accept
 the output of \.{WEAVE}; Appendix~G discusses how to use some of its macros
 to vary the output formats; and Appendix~H discusses what needs to be done
@@ -145,7 +171,7 @@
 to vary the output formats; and \Appendix H discusses what needs to be done
 @z
 
- at x l.913
+ at x l.914
 The programs in Appendices D and E will optionally keep statistics on
 @y
 The programs in Appendices \pdfURL{D}{weave.pdf} and \pdfURL{E}{tangle.pdf}
@@ -153,9 +179,11 @@
 @z
 
 @x l.989
+
\def\runninghead{APPENDIX A --- {\tentt WEB} FILE FORMAT}
 \section Appendix A.
 This excerpt from \.{WEAVE.WEB} produced modules 55--59 in Appendix~D.
 @y
+
\def\runninghead{APPENDIX A --- {\ninett WEB} FILE FORMAT}
 \def\bkminfo{WEB file format}
 \section Appendix A.
 This excerpt from \.{WEAVE.WEB} produced modules 55--59 in
@@ -169,9 +197,11 @@
 @z
 
 @x l.1061
+
\def\runninghead{APPENDIX B --- TRANSLATION BY {\tentt WEAVE}}
 \section Appendix B.
 This excerpt from \.{WEAVE.TEX} corresponds to Appendix A.
 @y
+
\def\runninghead{APPENDIX B --- TRANSLATION BY {\ninett WEAVE}}
 \def\bkminfo{Translations by WEAVE}
 \section Appendix B.
 This excerpt from \.{WEAVE.TEX} corresponds to \Appendix A.
@@ -190,8 +220,10 @@
 @z
 
 @x l.1143
+
\def\runninghead{APPENDIX C --- TRANSLATION BY {\tentt TANGLE}}
 \section Appendix C.
 @y
+
\def\runninghead{APPENDIX C --- TRANSLATION BY {\ninett TANGLE}}
 \def\bkminfo{Translation by TANGLE}
 \section Appendix C.
 @z
@@ -543,7 +575,7 @@
 a variety of formats
 @z
 
- at x l.1425
+ at x l.1463
 in small caps. For example, Appendix~D was produced after saying
 @y
 in small caps. For example, \pdfURL{Appendix~D}{weave.pdf} was produced
@@ -550,7 +582,7 @@
 after saying
 @z
 
- at x l.1468
+ at x l.1469
 \.{\\pageno=\\contentspagenumber} \.{\\advance\\pageno by 1}'. (Appendix~D
 @y
 \.{\\pageno=\\contentspagenumber} \.{\\advance\\pageno by 1}'.
@@ -557,7 +589,7 @@
 (\pdfURL{Appendix~D}{weave.pdf}
 @z
 
- at x l.1479
+ at x l.1480
 For example, Appendix~D was produced with the following definitions:
 @y
 For example, \pdfURL{Appendix~D}{weave.pdf} was produced with the following
@@ -564,7 +596,7 @@
 definitions:
 @z
 
- at x l.1491
+ at x l.1492
 for every starred module. For example, when Appendix~D was being generated,
 @y
 for every starred module. For example, when \pdfURL{Appendix~D}{weave.pdf}
@@ -571,7 +603,7 @@
 was being generated,
 @z
 
- at x l.569
+ at x l.1569
 \.{\\ch}, \.{\\fin}, and \.{\\con}. \.{WEAVE} itself need not be changed.
 @y
 \.{\\ch}, \.{\\fin}, and \.{\\con}. \.{WEAVE} itself need not be changed.
@@ -582,7 +614,7 @@
 table-of-contents to the front of the {\mc PDF} output.
 @z
 
- at x l.1583
+ at x l.1584
 dependencies'' in the index of Appendix~E above, and figure out what changes
 @y
 dependencies'' in the index of \pdfURL{Appendix~E}{tangle.pdf} above,
@@ -595,25 +627,25 @@
 first change files; then you can be sure that your compiler will handle
 @z
 
- at x l.1609
+ at x l.1610
 the index to Appendix~D.
 @y
 the index to \pdfURL{Appendix~D}{weave.pdf}.
 @z
 
- at x l.1616
+ at x l.1617
 Appendix~E. This listing will incorporate your changes.
 @y
 \pdfURL{Appendix~E}{tangle.pdf}. This listing will incorporate your changes.
 @z
 
- at x l.1620
+ at x l.1621
 Appendix~D that incorporates your changes.
 @y
 \pdfURL{Appendix~D}{weave.pdf} that incorporates your changes.
 @z
 
- at x l.1632
+ at x l.1631
 \def\substep(10.#1){\par\hangindent 4em\noindent
   \hbox to 4em{\hfil(10.#1) }\ignorespaces}
 @y
@@ -621,7 +653,7 @@
   \hbox to 3em{\hfil(10.#1) }\ignorespaces}
 @z
 
- at x l.1666
+ at x l.1667
 computer by following Appendices D and E. Then you have to simulate the
 @y
 computer by following Appendices \pdfURL{D}{weave.pdf}

Modified: trunk/Master/texmf-dist/tex/plain/pwebmac/pwebmac.tex
===================================================================
--- trunk/Master/texmf-dist/tex/plain/pwebmac/pwebmac.tex	2024-08-12 12:00:40 UTC (rev 72014)
+++ trunk/Master/texmf-dist/tex/plain/pwebmac/pwebmac.tex	2024-08-12 20:04:42 UTC (rev 72015)
@@ -5,7 +5,7 @@
 % macro integration \`a la CWEB by Andreas Scherer <andreas_tex at freenet.de>.
 % This file is not copyrighted and can be used freely.
 \ifx\renewenvironment\undefined\else\endinput\fi % LaTeX will use other macros
-\xdef\fmtversion{\fmtversion+PWEBMAC4.12}
+\xdef\fmtversion{\fmtversion+PWEBMAC5.0}
 
 \parskip 0pt % no stretch between paragraphs
 \parindent 1em % for paragraphs and for the first line of Pascal text
@@ -74,8 +74,8 @@
 \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\countD \countD=0
-\newif\iftokprocessed \newif\ifTnum \newif\ifinstr
+\newcount\countNOS \countNOS=0
+\newif\iftokprocessed \newif\ifTnum \newif\ifinstr \newif\ifhavenum
 {\def\\{\global\let\spacechar= }\\ }
 
 % Here we decide the output format, depending on the TeX engine in use:
@@ -89,8 +89,7 @@
 \newif\ifpdflua \ifluatex\pdfluatrue\fi \ifpdftex\pdfluatrue\fi
 \ifpdflua % pdfTeX and luaTeX 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
+  \def\Blue{\pdfliteral{\pdflinkcolor\space rg \pdflinkcolor\space RG}} \fi
 
 \ifluatex % LuaTeX is almost like pdfTeX
 \protected\def\pdfliteral   {\pdfextension literal}
@@ -108,6 +107,32 @@
 \let\pdfoutput=\outputmode
 \fi % end of LuaTeX->pdfTeX redirection macros
 
+\ifacrohint % Common macros for \ifpdf and \ifhint for \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
+
 \ifpdf % The following are general pdf macros from 'cwebmac.tex 3.70'
 \def\thewidth{\the\wd0 \space}
 \def\theheight{\the\ht\strutbox\space}
@@ -114,15 +139,16 @@
 \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}}
-\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
+      depth \thedepth << /Type /Annot /Subtype /Link /Border [0 0 0]
+      /A << /S /GoTo /D (\romannumeral#1) >> >>}\box0\relax}\fi
 \def\sanitizecommand#1#2{\addtokens\usersanitizer
        {\noexpand\dosanitizecommand\noexpand#1{#2}}}
 \def\dosanitizecommand#1#2{\ifx\nxt#1\addF{#2}\fi}
+\ifhint\else\sanitizecommand\to{..}\fi % a trivial example; requires \addtokens
 
 \catcode`\[=1 \catcode`\]=2 \catcode`\{=12 \catcode`\}=12
   \def\lbchar[{]  \def\rbchar[}]
@@ -129,7 +155,8 @@
 \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\addF#1{\addtokens\toksF{#1}\tokprocessedtrue}
@@ -191,7 +218,7 @@
 }
 \def\makeolproctokchar#1 #2 #3{\addF{#3}}
 \def\outlinedone{\edef\outlinest{\global\noexpand\toksE={\the\toksF}}%
-  \outlinest\let\outlinedone=\relax}
+  \outlinest\let\outlinedone=\relax\outlinedone}
 \fi % End of general pdf macros
 
 \ifhint
@@ -205,40 +232,11 @@
 \def\HINThome{\HINTdest name {HINT.home}%
   \HINToutline goto name {HINT.home} depth 1 {Table of Contents}}
 \def\HINTlabel{{\let\*=\empty\HINTdest num \modstar 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{\HINToutline goto num #2 depth 1 {#1}}
 \let\pdflink=\HINTlink
 \fi % End of HINT macros
 
-% 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={}%
-    \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}
-\ifhint\else\sanitizecommand\to{..}\fi % a trivial example; requires \addtokens
-\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 pdf/hint 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
@@ -280,7 +278,7 @@
 \outer\def\M#1.{\MN#1.\ifon\vfil\penalty-100\vfilneg % beginning of section
   \vskip\intersecskip\startsection\ignorespaces}
 \outer\def\N#1.#2.{% beginning of starred section
-  \ifpdf{\toksF={}\makeoutlinetoks#2\outlinedone\outlinedone}\fi
+  \ifpdf{\makeoutlinetoks#2\outlinedone}\fi
   \gtitle={#2}\MN#1.\vfil\eject % define running headline
   \message{*\modno} % progress report
   \def\stripprefix##1>{}\def\gtitletoks{#2}%
@@ -411,10 +409,24 @@
   \message{Index:}
   \parskip 0pt plus .5pt
   \outer\def\:##1, ##2.{\par\hangindent2em\noindent##1:\kern1em
-    \ifacrohint\pdfnote##2.\else##2\fi.} % index entry
+    \scan##2!.} % index entry
   \let\ttentry=\. \def\.##1{\ttentry{##1\kern.2em}} % give \tt a little room
-  \def\[##1]{$\underline{##1}$} % underlined index item
-  \rm \rightskip0pt plus 2.5em \tolerance 10000 \let\*=\lapstar
+  \def\[##1]{$\underline{\scan##1!}$\scan} % underlined index item
+  \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}
+  \rm \rightskip0pt plus 2.5em \tolerance 10000
   \hyphenpenalty 10000 \parindent0pt}
 \def\fin{\par\vfill\eject % this is done when we are ending the index
   \ifpagesaved\null\vfill\eject\fi % output a null index column
@@ -421,7 +433,7 @@
   \if L\lr\else\null\vfill\eject\fi % finish the current page
   \ifpdflua \makebookmarks % added in Version 4.5
     \ifnum\pdfshellescape=1 {\let\\=\BS % count the @<named sections@>
-      \global\countD=\input{|grep -c -e '\\:\\X' \jobname.tex}} \fi\fi
+      \global\countNOS=\input{|grep -c -e '\\:\\X' \jobname.tex}} \fi\fi
   \parfillskip 0pt plus 1fil
   \def\grouptitle{NAMES OF THE SECTIONS}
   \let\topsecno=\nullsec
@@ -435,18 +447,16 @@
   \def\:{\par\hangindent 2em}\let\*=*\let\.=\ttentry
   \ifpdf \def\outsecname{Names of the sections} \let\Xpdf\X
   \ifpdflua \pdfdest name {NOS} fith
-    \ifnum \the\countD>0 \xdef\modno{\the\countD} \fi
+    \ifnum \countNOS>0 \xdef\modno{\the\countNOS} \fi
     \pdfoutline goto name {NOS} count -\modno {\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 \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}
+      /Dest [ @thispage /FitH @ypos ] >>}\fi
+  \def\X##1:##2\X{\Xpdf##1:##2\X \firstsecno##1.%
+    {\makeoutlinetoks##2\outlinedone}%
+    \ifpdflua \pdfoutline goto num \the\toksA \expandafter{\the\toksE}
+    \else \special{pdf: outline 0 << /Title (\the\toksE)
+        /A << /S /GoTo /D (\romannumeral\the\toksA) >> >>}\fi}
+  \fi}
 \def\makebookmarks{\def\?##1]{[##1]}%
   \let\Z=\writebookmarkline \readcontents\relax}
 \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
@@ -474,9 +484,9 @@
     \line{\ignorespaces#1
       \rm\leaders\hbox to .5em{.\hfil}\hfil
       \ \ifhint
-          \HINTlink{#2}{\romannumeral#2}% No page numbers in HINT
+          \HINTlink{#2}% No page numbers in HINT
           \HINTcontents{#1}{#2}%
-        \else\ifpdf\pdflink{#2}{\romannumeral#2}\else#2\fi
+        \else\ifpdf\pdflink{#2}\else#2\fi
           \hbox to3em{\hss#3}\fi}}
 \def\today{\ifcase\month\or
   January\or February\or March\or April\or May\or June\or



More information about the tex-live-commits mailing list.