gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-anastasis] branch master updated: -adapt to latest libgnunetpq


From: gnunet
Subject: [taler-anastasis] branch master updated: -adapt to latest libgnunetpq
Date: Sun, 24 Jul 2022 11:33:39 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository anastasis.

The following commit(s) were added to refs/heads/master by this push:
     new 8fd36a4  -adapt to latest libgnunetpq
8fd36a4 is described below

commit 8fd36a4defb96770ccc7f3f1fca689a0c433f149
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Sun Jul 24 11:33:36 2022 +0200

    -adapt to latest libgnunetpq
---
 doc/texinfo.tex                        | 1599 ++++++++++++++++----------------
 src/stasis/Makefile.am                 |    4 +-
 src/stasis/{drop0001.sql => drop.sql}  |    0
 src/stasis/plugin_anastasis_postgres.c |    7 +-
 src/stasis/stasis-0000.sql             |  293 ------
 5 files changed, 784 insertions(+), 1119 deletions(-)

diff --git a/doc/texinfo.tex b/doc/texinfo.tex
index 3c7051d..ac5c1d9 100644
--- a/doc/texinfo.tex
+++ b/doc/texinfo.tex
@@ -1,11 +1,14 @@
 % texinfo.tex -- TeX macros to handle Texinfo files.
-%
+% 
 % Load plain if necessary, i.e., if running under initex.
 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
 %
-\def\texinfoversion{2020-10-24.12}
+\def\texinfoversion{2018-02-12.17}
 %
-% Copyright 1985, 1986, 1988, 1990-2020 Free Software Foundation, Inc.
+% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
+% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+% 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
+% Free Software Foundation, Inc.
 %
 % This texinfo.tex file is free software: you can redistribute it and/or
 % modify it under the terms of the GNU General Public License as
@@ -33,7 +36,7 @@
 % The texinfo.tex in any given distribution could well be out
 % of date, so if that's what you're using, please check.
 %
-% Send bug reports to bug-texinfo@gnu.org.  Please include a
+% Send bug reports to bug-texinfo@gnu.org.  Please include including a
 % complete document in each bug report with which we can reproduce the
 % problem.  Patches are, of course, greatly appreciated.
 %
@@ -179,7 +182,7 @@
 % Hyphenation fixes.
 \hyphenation{
   Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
-  ap-pen-dix bit-map bit-maps
+  auto-ma-ti-cal-ly ap-pen-dix bit-map bit-maps
   data-base data-bases eshell fall-ing half-way long-est man-u-script
   man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
   par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
@@ -218,7 +221,7 @@
 % @errormsg{MSG}.  Do the index-like expansions on MSG, but if things
 % aren't perfect, it's not the end of the world, being an error message,
 % after all.
-%
+% 
 \def\errormsg{\begingroup \indexnofonts \doerrormsg}
 \def\doerrormsg#1{\errmessage{#1}}
 
@@ -241,7 +244,17 @@
 %
 \def\finalout{\overfullrule=0pt }
 
+% Do @cropmarks to get crop marks.
+%
+\newif\ifcropmarks
+\let\cropmarks = \cropmarkstrue
+%
+% Dimensions to add cropmarks at corners.
+% Added by P. A. MacKay, 12 Nov. 1986
+%
 \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
+\newdimen\cornerlong  \cornerlong=1pc
+\newdimen\cornerthick \cornerthick=.3pt
 \newdimen\topandbottommargin \topandbottommargin=.75in
 
 % Output a mark which sets \thischapter, \thissection and \thiscolor.
@@ -257,8 +270,8 @@
 
 % \domark is called twice inside \chapmacro, to add one
 % mark before the section break, and one after.
-%   In the second call \prevchapterdefs is the same as \currentchapterdefs,
-% and \prevsectiondefs is the same as \currentsectiondefs.
+%   In the second call \prevchapterdefs is the same as \lastchapterdefs,
+% and \prevsectiondefs is the same as \lastsectiondefs.
 %   Then if the page is not broken at the mark, some of the previous
 % section appears on the page, and we can get the name of this section
 % from \firstmark for @everyheadingmarks top.
@@ -266,11 +279,11 @@
 %
 % See page 260 of The TeXbook.
 \def\domark{%
-  \toks0=\expandafter{\currentchapterdefs}%
-  \toks2=\expandafter{\currentsectiondefs}%
+  \toks0=\expandafter{\lastchapterdefs}%
+  \toks2=\expandafter{\lastsectiondefs}%
   \toks4=\expandafter{\prevchapterdefs}%
   \toks6=\expandafter{\prevsectiondefs}%
-  \toks8=\expandafter{\currentcolordefs}%
+  \toks8=\expandafter{\lastcolordefs}%
   \mark{%
                    \the\toks0 \the\toks2  % 0: marks for @everyheadingmarks top
       \noexpand\or \the\toks4 \the\toks6  % 1: for @everyheadingmarks bottom
@@ -287,19 +300,19 @@
 % @setcolor (or @url, or @link, etc.) between @contents and the very
 % first @chapter.
 \def\gettopheadingmarks{%
-  \ifcase0\the\savedtopmark\fi
+  \ifcase0\topmark\fi
   \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
 }
 \def\getbottomheadingmarks{\ifcase1\botmark\fi}
-\def\getcolormarks{\ifcase2\the\savedtopmark\fi}
+\def\getcolormarks{\ifcase2\topmark\fi}
 
 % Avoid "undefined control sequence" errors.
-\def\currentchapterdefs{}
-\def\currentsectiondefs{}
-\def\currentsection{}
+\def\lastchapterdefs{}
+\def\lastsectiondefs{}
+\def\lastsection{}
 \def\prevchapterdefs{}
 \def\prevsectiondefs{}
-\def\currentcolordefs{}
+\def\lastcolordefs{}
 
 % Margin to add to right of even pages, to left of odd pages.
 \newdimen\bindingoffset
@@ -309,61 +322,51 @@
 % Main output routine.
 %
 \chardef\PAGE = 255
-\newtoks\defaultoutput
-\defaultoutput = {\savetopmark\onepageout{\pagecontents\PAGE}}
-\output=\expandafter{\the\defaultoutput}
+\output = {\onepageout{\pagecontents\PAGE}}
 
 \newbox\headlinebox
 \newbox\footlinebox
 
-% When outputting the double column layout for indices, an output routine
-% is run several times, which hides the original value of \topmark.  This
-% can lead to a page heading being output and duplicating the chapter heading
-% of the index.  Hence, save the contents of \topmark at the beginning of
-% the output routine.  The saved contents are valid until we actually
-% \shipout a page.
-%
-% (We used to run a short output routine to actually set \topmark and
-% \firstmark to the right values, but if this was called with an empty page
-% containing whatsits for writing index entries, the whatsits would be thrown
-% away and the index auxiliary file would remain empty.)
-%
-\newtoks\savedtopmark
-\newif\iftopmarksaved
-\topmarksavedtrue
-\def\savetopmark{%
-  \iftopmarksaved\else
-    \global\savedtopmark=\expandafter{\topmark}%
-    \global\topmarksavedtrue
-  \fi
-}
-
 % \onepageout takes a vbox as an argument.
-% \shipout a vbox for a single page, adding an optional header, footer
-% and footnote.  This also causes index entries for this page to be written
-% to the auxiliary files.
+% \shipout a vbox for a single page, adding an optional header, footer,
+% cropmarks, and footnote.  This also causes index entries for this page
+% to be written to the auxiliary files.
 %
 \def\onepageout#1{%
-  \hoffset=\normaloffset
+  \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
   %
   \ifodd\pageno  \advance\hoffset by \bindingoffset
   \else \advance\hoffset by -\bindingoffset\fi
   %
-  \checkchapterpage
+  % Common context changes for both heading and footing.
+  % Do this outside of the \shipout so @code etc. will be expanded in
+  % the headline as they should be, not taken literally (outputting ''code).
+  \def\commmonheadfootline{\let\hsize=\txipagewidth \texinfochars}
   %
   % Retrieve the information for the headings from the marks in the page,
   % and call Plain TeX's \makeheadline and \makefootline, which use the
   % values in \headline and \footline.
   %
-  % Common context changes for both heading and footing.
-  % Do this outside of the \shipout so @code etc. will be expanded in
-  % the headline as they should be, not taken literally (outputting ''code).
-  \def\commonheadfootline{\let\hsize=\txipagewidth \texinfochars}
+  % This is used to check if we are on the first page of a chapter.
+  \ifcase1\topmark\fi
+  \let\prevchaptername\thischaptername
+  \ifcase0\firstmark\fi
+  \let\curchaptername\thischaptername
   %
   \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
-  \global\setbox\headlinebox = \vbox{\commonheadfootline \makeheadline}%
   \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
-  \global\setbox\footlinebox = \vbox{\commonheadfootline \makefootline}%
+  %
+  \ifx\curchaptername\prevchaptername
+    \let\thischapterheading\thischapter
+  \else
+    % \thischapterheading is the same as \thischapter except it is blank
+    % for the first page of a chapter.  This is to prevent the chapter name 
+    % being shown twice.
+    \def\thischapterheading{}%
+  \fi
+  %
+  \global\setbox\headlinebox = \vbox{\commmonheadfootline \makeheadline}%
+  \global\setbox\footlinebox = \vbox{\commmonheadfootline \makefootline}%
   %
   {%
     % Set context for writing to auxiliary files like index files.
@@ -371,12 +374,37 @@
     % take effect in \write's, yet the group defined by the \vbox ends
     % before the \shipout runs.
     %
-    \atdummies         % don't expand commands in the output.
-    \turnoffactive
+    \indexdummies         % don't expand commands in the output.
+    \normalturnoffactive  % \ in index entries must not stay \, e.g., if
+               % the page break happens to be in the middle of an example.
+               % We don't want .vr (or whatever) entries like this:
+               % \entry{{\indexbackslash }acronym}{32}{\code {\acronym}}
+               % "\acronym" won't work when it's read back in;
+               % it needs to be
+               % {\code {{\backslashcurfont }acronym}
     \shipout\vbox{%
       % Do this early so pdf references go to the beginning of the page.
       \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
       %
+      \ifcropmarks \vbox to \outervsize\bgroup
+        \hsize = \outerhsize
+        \vskip-\topandbottommargin
+        \vtop to0pt{%
+          \line{\ewtop\hfil\ewtop}%
+          \nointerlineskip
+          \line{%
+            \vbox{\moveleft\cornerthick\nstop}%
+            \hfill
+            \vbox{\moveright\cornerthick\nstop}%
+          }%
+          \vss}%
+        \vskip\topandbottommargin
+        \line\bgroup
+          \hfil % center the page within the outer (page) hsize.
+          \ifodd\pageno\hskip\bindingoffset\fi
+          \vbox\bgroup
+      \fi
+      %
       \unvbox\headlinebox
       \pagebody{#1}%
       \ifdim\ht\footlinebox > 0pt
@@ -387,9 +415,24 @@
         \unvbox\footlinebox
       \fi
       %
-    }%
-  }%
-  \global\topmarksavedfalse
+      \ifcropmarks
+          \egroup % end of \vbox\bgroup
+        \hfil\egroup % end of (centering) \line\bgroup
+        \vskip\topandbottommargin plus1fill minus1fill
+        \boxmaxdepth = \cornerthick
+        \vbox to0pt{\vss
+          \line{%
+            \vbox{\moveleft\cornerthick\nsbot}%
+            \hfill
+            \vbox{\moveright\cornerthick\nsbot}%
+          }%
+          \nointerlineskip
+          \line{\ewbot\hfil\ewbot}%
+        }%
+      \egroup % \vbox from first cropmarks clause
+      \fi
+    }% end of \shipout\vbox
+  }% end of group with \indexdummies
   \advancepageno
   \ifnum\outputpenalty>-20000 \else\dosupereject\fi
 }
@@ -408,22 +451,17 @@
 \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
 }
 
-% Check if we are on the first page of a chapter.  Used for printing headings.
-\newif\ifchapterpage
-\def\checkchapterpage{%
-  % Get the chapter that was current at the end of the last page
-  \ifcase1\the\savedtopmark\fi
-  \let\prevchaptername\thischaptername
-  %
-  \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
-  \let\curchaptername\thischaptername
-  %
-  \ifx\curchaptername\prevchaptername
-    \chapterpagefalse
-  \else
-    \chapterpagetrue
-  \fi
-}
+% Here are the rules for the cropmarks.  Note that they are
+% offset so that the space between them is truly \outerhsize or \outervsize
+% (P. A. MacKay, 12 November, 1986)
+%
+\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
+\def\nstop{\vbox
+  {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
+\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
+\def\nsbot{\vbox
+  {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
+
 
 % Argument parsing
 
@@ -449,10 +487,11 @@
   }%
 }
 
-% First remove any @comment, then any @c comment.  Pass the result on to
-% \argcheckspaces.
+% First remove any @comment, then any @c comment.  Also remove a @texinfoc
+% comment (see \scanmacro for details).  Pass the result on to \argcheckspaces.
 \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
-\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
+\def\argremovec#1\c#2\ArgTerm{\argremovetexinfoc #1\texinfoc\ArgTerm}
+\def\argremovetexinfoc#1\texinfoc#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
 
 % Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
 %
@@ -1011,7 +1050,7 @@ where each line of input produces a line of output.}
 \let\setfilename=\comment
 
 % @bye.
-\outer\def\bye{\chappager\pagelabels\tracingstats=1\ptexend}
+\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
 
 
 \message{pdf,}
@@ -1053,7 +1092,7 @@ where each line of input produces a line of output.}
             tex.sprint(
               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
                             string.char(0x5c) .. string.char(0x25) .. '03o',
-                            math.floor(c / 256), math.floor(c % 256)))
+                            (c / 256), (c % 256)))
           else
             c = c - 0x10000
             local c_hi = c / 1024 + 0xd800
@@ -1063,8 +1102,8 @@ where each line of input produces a line of output.}
                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
                             string.char(0x5c) .. string.char(0x25) .. '03o',
-                            math.floor(c_hi / 256), math.floor(c_hi % 256),
-                            math.floor(c_lo / 256), math.floor(c_lo % 256)))
+                            (c_hi / 256), (c_hi % 256),
+                            (c_lo / 256), (c_lo % 256)))
           end
         end
       end
@@ -1077,19 +1116,15 @@ where each line of input produces a line of output.}
       function PDFescstr(str)
         for c in string.bytes(str) do
           if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then
-            tex.sprint(-2,
+            tex.sprint(
               string.format(string.char(0x5c) .. string.char(0x25) .. '03o',
                             c))
           else
-            tex.sprint(-2, string.char(c))
+            tex.sprint(string.char(c))
           end
         end
       end
     }
-    % The -2 in the arguments here gives all the input to TeX catcode 12
-    % (other) or 10 (space), preventing undefined control sequence errors. See
-    % https://lists.gnu.org/archive/html/bug-texinfo/2019-08/msg00031.html
-    %
   \endgroup
   \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}}
   \ifnum\luatexversion>84
@@ -1128,60 +1163,11 @@ where each line of input produces a line of output.}
   \fi
 \fi
 
-\newif\ifpdforxetex
-\pdforxetexfalse
-\ifpdf
-  \pdforxetextrue
-\fi
-\ifx\XeTeXrevision\thisisundefined\else
-  \pdforxetextrue
-\fi
-
-
-% Output page labels information.
-% See PDF reference v.1.7 p.594, section 8.3.1.
-\ifpdf
-\def\pagelabels{%
-  \def\title{0 << /P (T-) /S /D >>}%
-  \edef\roman{\the\romancount << /S /r >>}%
-  \edef\arabic{\the\arabiccount << /S /D >>}%
-  %
-  % Page label ranges must be increasing.  Remove any duplicates.
-  % (There is a slight chance of this being wrong if e.g. there is
-  % a @contents but no @titlepage, etc.)
-  %
-  \ifnum\romancount=0 \def\roman{}\fi
-  \ifnum\arabiccount=0 \def\title{}%
-  \else
-    \ifnum\romancount=\arabiccount \def\roman{}\fi
-  \fi
-  %
-  \ifnum\romancount<\arabiccount
-    \pdfcatalog{/PageLabels << /Nums [\title \roman \arabic ] >> }\relax
-  \else
-    \pdfcatalog{/PageLabels << /Nums [\title \arabic \roman ] >> }\relax
-  \fi
-}
-\else
-  \let\pagelabels\relax
-\fi
-
-\newcount\pagecount \pagecount=0
-\newcount\romancount \romancount=0
-\newcount\arabiccount \arabiccount=0
-\ifpdf
-  \let\ptxadvancepageno\advancepageno
-  \def\advancepageno{%
-    \ptxadvancepageno\global\advance\pagecount by 1
-  }
-\fi
-
-
 % PDF uses PostScript string constants for the names of xref targets,
 % for display in the outlines, and in other places.  Thus, we have to
 % double any backslashes.  Otherwise, a name like "\node" will be
 % interpreted as a newline (\n), followed by o, d, e.  Not good.
-%
+% 
 % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
 % related messages.  The final outcome is that it is up to the TeX user
 % to double the backslashes and otherwise make the string valid, so
@@ -1233,7 +1219,7 @@ output) for that.)}
   % Set color, and create a mark which defines \thiscolor accordingly,
   % so that \makeheadline knows which color to restore.
   \def\setcolor#1{%
-    \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
+    \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
     \domark
     \pdfsetcolor{#1}%
   }
@@ -1241,7 +1227,7 @@ output) for that.)}
   \def\maincolor{\rgbBlack}
   \pdfsetcolor{\maincolor}
   \edef\thiscolor{\maincolor}
-  \def\currentcolordefs{}
+  \def\lastcolordefs{}
   %
   \def\makefootline{%
     \baselineskip24pt
@@ -1467,13 +1453,7 @@ output) for that.)}
       % subentries, which we calculated on our first read of the .toc above.
       %
       % We use the node names as the destinations.
-      %
-      % Currently we prefix the section name with the section number
-      % for chapter and appendix headings only in order to avoid too much
-      % horizontal space being required in the PDF viewer.
       \def\numchapentry##1##2##3##4{%
-        \dopdfoutline{##2 ##1}{count-\expnumber{chap##2}}{##3}{##4}}%
-      \def\unnchapentry##1##2##3##4{%
         \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
       \def\numsecentry##1##2##3##4{%
         \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
@@ -1492,7 +1472,7 @@ output) for that.)}
       % their "best" equivalent, based on the @documentencoding.  Too
       % much work for too little return.  Just use the ASCII equivalents
       % we use for the index sort strings.
-      %
+      % 
       \indexnofonts
       \setupdatafile
       % We can have normal brace characters in the PDF outlines, unlike
@@ -1548,9 +1528,6 @@ output) for that.)}
       \startlink attr{/Border [0 0 0]}%
         user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
     \endgroup}
-  % \pdfgettoks - Surround page numbers in #1 with @pdflink.  #1 may
-  % be a simple number, or a list of numbers in the case of an index
-  % entry.
   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
@@ -1625,7 +1602,7 @@ output) for that.)}
   % Set color, and create a mark which defines \thiscolor accordingly,
   % so that \makeheadline knows which color to restore.
   \def\setcolor#1{%
-    \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
+    \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
     \domark
     \pdfsetcolor{#1}%
   }
@@ -1633,7 +1610,7 @@ output) for that.)}
   \def\maincolor{\rgbBlack}
   \pdfsetcolor{\maincolor}
   \edef\thiscolor{\maincolor}
-  \def\currentcolordefs{}
+  \def\lastcolordefs{}
   %
   \def\makefootline{%
     \baselineskip24pt
@@ -1715,13 +1692,9 @@ output) for that.)}
       % Therefore, we read toc only once.
       %
       % We use node names as destinations.
-      %
-      % Currently we prefix the section name with the section number
-      % for chapter and appendix headings only in order to avoid too much
-      % horizontal space being required in the PDF viewer.
       \def\partentry##1##2##3##4{}% ignore parts in the outlines
       \def\numchapentry##1##2##3##4{%
-        \dopdfoutline{##2 ##1}{1}{##3}{##4}}%
+        \dopdfoutline{##1}{1}{##3}{##4}}%
       \def\numsecentry##1##2##3##4{%
         \dopdfoutline{##1}{2}{##3}{##4}}%
       \def\numsubsecentry##1##2##3##4{%
@@ -1733,8 +1706,7 @@ output) for that.)}
       \let\appsecentry\numsecentry%
       \let\appsubsecentry\numsubsecentry%
       \let\appsubsubsecentry\numsubsubsecentry%
-      \def\unnchapentry##1##2##3##4{%
-        \dopdfoutline{##1}{1}{##3}{##4}}%
+      \let\unnchapentry\numchapentry%
       \let\unnsecentry\numsecentry%
       \let\unnsubsecentry\numsubsecentry%
       \let\unnsubsubsecentry\numsubsubsecentry%
@@ -2230,7 +2202,7 @@ end
 % A few fonts for @defun names and args.
 \setfont\defbf\bfshape{10}{\magstep1}{OT1}
 \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
-\setfont\defsl\slshape{10}{\magstep1}{OT1}
+\setfont\defsl\slshape{10}{\magstep1}{OT1TT}
 \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
 \def\df{\let\ttfont=\deftt \let\bffont = \defbf
 \let\ttslfont=\defttsl \let\slfont=\defsl \bf}
@@ -2378,7 +2350,7 @@ end
 % A few fonts for @defun names and args.
 \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
 \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
-\setfont\defsl\slshape{10}{\magstephalf}{OT1}
+\setfont\defsl\slshape{10}{\magstephalf}{OT1TT}
 \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
 \def\df{\let\ttfont=\deftt \let\bffont = \defbf
 \let\slfont=\defsl \let\ttslfont=\defttsl \bf}
@@ -2547,7 +2519,7 @@ end
 \def\it{\fam=\itfam \setfontstyle{it}}
 \def\sl{\fam=\slfam \setfontstyle{sl}}
 \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
-\def\tt{\fam=\ttfam \setfontstyle{tt}}\def\ttstylename{tt}
+\def\tt{\fam=\ttfam \setfontstyle{tt}}
 
 % Texinfo sort of supports the sans serif font style, which plain TeX does not.
 % So we set up a \sf.
@@ -2781,7 +2753,7 @@ end
 }
 
 % Commands to set the quote options.
-%
+% 
 \parseargdef\codequoteundirected{%
   \def\temp{#1}%
   \ifx\temp\onword
@@ -2822,7 +2794,7 @@ end
 % If we are in a monospaced environment, however, 1) always use \ttsl,
 % and 2) do not add an italic correction.
 \def\dosmartslant#1#2{%
-  \ifusingtt
+  \ifusingtt 
     {{\ttsl #2}\let\next=\relax}%
     {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
   \next
@@ -2901,7 +2873,7 @@ end
 
 % @t, explicit typewriter.
 \def\t#1{%
-  {\tt \plainfrenchspacing #1}%
+  {\tt \rawbackslash \plainfrenchspacing #1}%
   \null
 }
 
@@ -2928,6 +2900,7 @@ end
     % Turn off hyphenation.
     \nohyphenation
     %
+    \rawbackslash
     \plainfrenchspacing
     #1%
   }%
@@ -2969,14 +2942,14 @@ end
   \gdef\codedash{\futurelet\next\codedashfinish}
   \gdef\codedashfinish{%
     \normaldash % always output the dash character itself.
-    %
+    % 
     % Now, output a discretionary to allow a line break, unless
     % (a) the next character is a -, or
     % (b) the preceding character is a -.
     % E.g., given --posix, we do not want to allow a break after either -.
     % Given --foo-bar, we do want to allow a break between the - and the b.
     \ifx\next\codedash \else
-      \ifx\codedashprev\codedash
+      \ifx\codedashprev\codedash 
       \else \discretionary{}{}{}\fi
     \fi
     % we need the space after the = for the case when \next itself is a
@@ -3038,18 +3011,10 @@ end
 % arg (if given), and not the url (which is then just the link target).
 \newif\ifurefurlonlylink
 
-% The default \pretolerance setting stops the penalty inserted in
-% \urefallowbreak being a discouragement to line breaking.  Set it to
-% a negative value for this paragraph only.  Hopefully this does not
-% conflict with redefinitions of \par done elsewhere.
-\def\nopretolerance{%
-\pretolerance=-1
-\def\par{\endgraf\pretolerance=100 \let\par\endgraf}%
-}
-
 % The main macro is \urefbreak, which allows breaking at expected
-% places within the url.
-\def\urefbreak{\nopretolerance \begingroup \urefcatcodes \dourefbreak}
+% places within the url.  (There used to be another version, which
+% didn't support automatic breaking.)
+\def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
 \let\uref=\urefbreak
 %
 \def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
@@ -3066,7 +3031,7 @@ end
         % For pdfTeX and LuaTeX
         \ifurefurlonlylink
           % PDF plus option to not display url, show just arg
-          \unhbox0
+          \unhbox0             
         \else
           % PDF, normally display both arg and url for consistency,
           % visibility, if the pdf is eventually used to print, etc.
@@ -3079,7 +3044,7 @@ end
           % For XeTeX
           \ifurefurlonlylink
             % PDF plus option to not display url, show just arg
-            \unhbox0
+            \unhbox0             
           \else
             % PDF, normally display both arg and url for consistency,
             % visibility, if the pdf is eventually used to print, etc.
@@ -3122,33 +3087,41 @@ end
   \global\def/{\normalslash}
 }
 
-\def\urefcodeamp{\urefprebreak \&\urefpostbreak}
-\def\urefcodedot{\urefprebreak .\urefpostbreak}
-\def\urefcodehash{\urefprebreak \#\urefpostbreak}
-\def\urefcodequest{\urefprebreak ?\urefpostbreak}
+% we put a little stretch before and after the breakable chars, to help
+% line breaking of long url's.  The unequal skips make look better in
+% cmtt at least, especially for dots.
+\def\urefprestretchamount{.13em}
+\def\urefpoststretchamount{.1em}
+\def\urefprestretch{\urefprebreak \hskip0pt plus\urefprestretchamount\relax}
+\def\urefpoststretch{\urefpostbreak \hskip0pt plus\urefprestretchamount\relax}
+%
+\def\urefcodeamp{\urefprestretch \&\urefpoststretch}
+\def\urefcodedot{\urefprestretch .\urefpoststretch}
+\def\urefcodehash{\urefprestretch \#\urefpoststretch}
+\def\urefcodequest{\urefprestretch ?\urefpoststretch}
 \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
 {
   \catcode`\/=\active
   \global\def\urefcodeslashfinish{%
-    \urefprebreak \slashChar
+    \urefprestretch \slashChar
     % Allow line break only after the final / in a sequence of
     % slashes, to avoid line break between the slashes in http://.
-    \ifx\next/\else \urefpostbreak \fi
+    \ifx\next/\else \urefpoststretch \fi
   }
 }
 
-% By default we'll break after the special characters, but some people like to
-% break before the special chars, so allow that.  Also allow no breaking at
-% all, for manual control.
-%
+% One more complication: by default we'll break after the special
+% characters, but some people like to break before the special chars, so
+% allow that.  Also allow no breaking at all, for manual control.
+% 
 \parseargdef\urefbreakstyle{%
   \def\txiarg{#1}%
   \ifx\txiarg\wordnone
     \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
   \else\ifx\txiarg\wordbefore
-    \def\urefprebreak{\urefallowbreak}\def\urefpostbreak{\nobreak}
+    \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
   \else\ifx\txiarg\wordafter
-    \def\urefprebreak{\nobreak}\def\urefpostbreak{\urefallowbreak}
+    \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
   \else
     \errhelp = \EMsimple
     \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
@@ -3158,19 +3131,6 @@ end
 \def\wordbefore{before}
 \def\wordnone{none}
 
-% Allow a ragged right output to aid breaking long URL's.  There can
-% be a break at the \allowbreak with no extra glue (if the existing stretch in
-% the line is sufficient), a break at the \penalty with extra glue added
-% at the end of the line, or no break at all here.
-%   Changing the value of the penalty and/or the amount of stretch affects how
-% preferable one choice is over the other.
-\def\urefallowbreak{%
-  \penalty0\relax
-  \hskip 0pt plus 2 em\relax
-  \penalty1000\relax
-  \hskip 0pt plus -2 em\relax
-}
-
 \urefbreakstyle after
 
 % @url synonym for @uref, since that's how everyone uses it.
@@ -3181,7 +3141,7 @@ end
 % So now @email is just like @uref, unless we are pdf.
 %
 %\def\email#1{\angleleft{\tt #1}\angleright}
-\ifpdforxetex
+\ifpdf
   \def\email#1{\doemail#1,,\finish}
   \def\doemail#1,#2,#3\finish{\begingroup
     \unsepspaces
@@ -3191,7 +3151,18 @@ end
     \endlink
   \endgroup}
 \else
-  \let\email=\uref
+  \ifx\XeTeXrevision\thisisundefined
+    \let\email=\uref
+  \else
+    \def\email#1{\doemail#1,,\finish}
+    \def\doemail#1,#2,#3\finish{\begingroup
+      \unsepspaces
+      \pdfurl{mailto:#1}%
+      \setbox0 = \hbox{\ignorespaces #2}%
+      \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
+      \endlink
+    \endgroup}
+  \fi
 \fi
 
 % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
@@ -3364,29 +3335,10 @@ end
 \def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
 \def\finishsup#1{$\ptexsp{\hbox{\switchtolllsize #1}}$}%
 
-% provide this command from LaTeX as it is very common
-\def\frac#1#2{{{#1}\over{#2}}}
-
-% @displaymath.
-% \globaldefs is needed to recognize the end lines in \tex and
-% \end tex.  Set \thisenv as @end displaymath is seen before @end tex.
-{\obeylines
-\globaldefs=1
-\envdef\displaymath{%
-\tex
-\def\thisenv{\displaymath}%
-$$%
-}
-
-\def\Edisplaymath{$$
-\def\thisenv{\tex}%
-\end tex
-}}
-
 % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
 % Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
 % except specified as a normal braced arg, so no newlines to worry about.
-%
+% 
 \def\outfmtnametex{tex}
 %
 \long\def\inlinefmt#1{\doinlinefmt #1,\finish}
@@ -3394,7 +3346,7 @@ $$%
   \def\inlinefmtname{#1}%
   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
 }
-%
+% 
 % @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
 % FMTNAME is tex, else ELSE-TEXT.
 \long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
@@ -3410,7 +3362,7 @@ $$%
 % *right* brace they would have to use a command anyway, so they may as
 % well use a command to get a left brace too.  We could re-use the
 % delimiter character idea from \verb, but it seems like overkill.
-%
+% 
 \long\def\inlineraw{\tex \doinlineraw}
 \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
 \def\doinlinerawtwo#1,#2,\finish{%
@@ -3587,7 +3539,7 @@ $$%
 
 % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
 %
-\def\pounds{\ifmonospace{\ecfont\char"BF}\else{\it\$}\fi}
+\def\pounds{{\it\$}}
 
 % @euro{} comes from a separate font, depending on the current style.
 % We use the free feym* fonts from the eurosym package by Henrik
@@ -3687,7 +3639,7 @@ $$%
 % for non-CM glyphs.  That is ec* for regular text and tc* for the text
 % companion symbols (LaTeX TS1 encoding).  Both are part of the ec
 % package and follow the same conventions.
-%
+% 
 \def\ecfont{\etcfont{e}}
 \def\tcfont{\etcfont{t}}
 %
@@ -3736,19 +3688,11 @@ $$%
 \fi
 
 % Quotes.
+\chardef\quotedblleft="5C
+\chardef\quotedblright=`\"
 \chardef\quoteleft=`\`
 \chardef\quoteright=`\'
 
-% only change font for tt for correct kerning and to avoid using
-% \ecfont unless necessary.
-\def\quotedblleft{%
-  \ifmonospace{\ecfont\char"10}\else{\char"5C}\fi
-}
-
-\def\quotedblright{%
-  \ifmonospace{\ecfont\char"11}\else{\char`\"}\fi
-}
-
 
 \message{page headings,}
 
@@ -3767,7 +3711,7 @@ $$%
               after the title page.}}%
 \def\setshortcontentsaftertitlepage{%
   \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
-              command; move your @shortcontents and @contents commands if you
+              command; move your @shortcontents and @contents commands if you 
               want the contents after the title page.}}%
 
 \parseargdef\shorttitlepage{%
@@ -3822,7 +3766,7 @@ $$%
 % don't worry much about spacing, ragged right.  This should be used
 % inside a \vbox, and fonts need to be set appropriately first. \par should
 % be specified before the end of the \vbox, since a vbox is a group.
-%
+% 
 \def\raggedtitlesettings{%
   \rm
   \hyphenpenalty=10000
@@ -3870,19 +3814,12 @@ $$%
 
 \newtoks\evenheadline    % headline on even pages
 \newtoks\oddheadline     % headline on odd pages
-\newtoks\evenchapheadline% headline on even pages with a new chapter
-\newtoks\oddchapheadline % headline on odd pages with a new chapter
 \newtoks\evenfootline    % footline on even pages
 \newtoks\oddfootline     % footline on odd pages
 
 % Now make \makeheadline and \makefootline in Plain TeX use those variables
-\headline={{\textfonts\rm
-            \ifchapterpage
-              \ifodd\pageno\the\oddchapheadline\else\the\evenchapheadline\fi
-            \else
-              \ifodd\pageno\the\oddheadline\else\the\evenheadline\fi
-            \fi}}
-
+\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
+                            \else \the\evenheadline \fi}}
 \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
                             \else \the\evenfootline \fi}\HEADINGShook}
 \let\HEADINGShook=\relax
@@ -3898,14 +3835,12 @@ $$%
 \def\evenheading{\parsearg\evenheadingxxx}
 \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
 \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
-  \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
-  \global\evenchapheadline=\evenheadline}
+\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
 
 \def\oddheading{\parsearg\oddheadingxxx}
 \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
 \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
-  \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}%
-  \global\oddchapheadline=\oddheadline}
+\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
 
 \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
 
@@ -3972,34 +3907,37 @@ $$%
 \parseargdef\headings{\csname HEADINGS#1\endcsname}
 
 \def\headingsoff{% non-global headings elimination
-  \evenheadline={\hfil}\evenfootline={\hfil}\evenchapheadline={\hfil}%
-   \oddheadline={\hfil}\oddfootline={\hfil}\oddchapheadline={\hfil}%
+  \evenheadline={\hfil}\evenfootline={\hfil}%
+   \oddheadline={\hfil}\oddfootline={\hfil}%
 }
 
 \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
 \HEADINGSoff  % it's the default
 
 % When we turn headings on, set the page number to 1.
-\def\pageone{
-  \global\pageno=1
-  \global\arabiccount = \pagecount
-}
-
 % For double-sided printing, put current file name in lower left corner,
 % chapter name on inside top of right hand pages, document
 % title on inside top of left hand pages, and page numbers on outside top
 % edge of all pages.
 \def\HEADINGSdouble{%
-\pageone
-\HEADINGSdoublex
+\global\pageno=1
+\global\evenfootline={\hfil}
+\global\oddfootline={\hfil}
+\global\evenheadline={\line{\folio\hfil\thistitle}}
+\global\oddheadline={\line{\thischapterheading\hfil\folio}}
+\global\let\contentsalignmacro = \chapoddpage
 }
 \let\contentsalignmacro = \chappager
 
 % For single-sided printing, chapter title goes across top left of page,
 % page number on top right.
 \def\HEADINGSsingle{%
-\pageone
-\HEADINGSsinglex
+\global\pageno=1
+\global\evenfootline={\hfil}
+\global\oddfootline={\hfil}
+\global\evenheadline={\line{\thischapterheading\hfil\folio}}
+\global\oddheadline={\line{\thischapterheading\hfil\folio}}
+\global\let\contentsalignmacro = \chappager
 }
 \def\HEADINGSon{\HEADINGSdouble}
 
@@ -4009,9 +3947,7 @@ $$%
 \global\evenfootline={\hfil}
 \global\oddfootline={\hfil}
 \global\evenheadline={\line{\folio\hfil\thistitle}}
-\global\oddheadline={\line{\thischapter\hfil\folio}}
-\global\evenchapheadline={\line{\folio\hfil}}
-\global\oddchapheadline={\line{\hfil\folio}}
+\global\oddheadline={\line{\thischapterheading\hfil\folio}}
 \global\let\contentsalignmacro = \chapoddpage
 }
 
@@ -4019,22 +3955,8 @@ $$%
 \def\HEADINGSsinglex{%
 \global\evenfootline={\hfil}
 \global\oddfootline={\hfil}
-\global\evenheadline={\line{\thischapter\hfil\folio}}
-\global\oddheadline={\line{\thischapter\hfil\folio}}
-\global\evenchapheadline={\line{\hfil\folio}}
-\global\oddchapheadline={\line{\hfil\folio}}
-\global\let\contentsalignmacro = \chappager
-}
-
-% for @setchapternewpage off
-\def\HEADINGSsinglechapoff{%
-\pageone
-\global\evenfootline={\hfil}
-\global\oddfootline={\hfil}
-\global\evenheadline={\line{\thischapter\hfil\folio}}
-\global\oddheadline={\line{\thischapter\hfil\folio}}
-\global\evenchapheadline=\evenheadline
-\global\oddchapheadline=\oddheadline
+\global\evenheadline={\line{\thischapterheading\hfil\folio}}
+\global\oddheadline={\line{\thischapterheading\hfil\folio}}
 \global\let\contentsalignmacro = \chappager
 }
 
@@ -4467,7 +4389,7 @@ $$%
 }
 
 % multitable-only commands.
-%
+% 
 % @headitem starts a heading row, which we typeset in bold.  Assignments
 % have to be global since we are inside the implicit group of an
 % alignment entry.  \everycr below resets \everytab so we don't have to
@@ -4774,6 +4696,19 @@ $$%
   }
 }
 
+% We have this subroutine so that we can handle at least some @value's
+% properly in indexes (we call \makevalueexpandable in \indexdummies).
+% The command has to be fully expandable (if the variable is set), since
+% the result winds up in the index file.  This means that if the
+% variable's value contains other Texinfo commands, it's almost certain
+% it will fail (although perhaps we could fix that with sufficient work
+% to do a one-level expansion on the result, instead of complete).
+% 
+% Unfortunately, this has the consequence that when _ is in the *value*
+% of an @set, it does not print properly in the roman fonts (get the cmr
+% dot accent at position 126 instead).  No fix comes to mind, and it's
+% been this way since 2003 or earlier, so just ignore it.
+% 
 \def\expandablevalue#1{%
   \expandafter\ifx\csname SET#1\endcsname\relax
     {[No value for ``#1'']}%
@@ -4786,13 +4721,13 @@ $$%
 % Like \expandablevalue, but completely expandable (the \message in the
 % definition above operates at the execution level of TeX).  Used when
 % writing to auxiliary files, due to the expansion that \write does.
-% If flag is undefined, pass through an unexpanded @value command: maybe it
+% If flag is undefined, pass through an unexpanded @value command: maybe it 
 % will be set by the time it is read back in.
 %
 % NB flag names containing - or _ may not work here.
 \def\dummyvalue#1{%
   \expandafter\ifx\csname SET#1\endcsname\relax
-    \string\value{#1}%
+    \noexpand\value{#1}%
   \else
     \csname SET#1\endcsname
   \fi
@@ -4802,7 +4737,7 @@ $$%
 % if possible, otherwise sort late.
 \def\indexnofontsvalue#1{%
   \expandafter\ifx\csname SET#1\endcsname\relax
-    ZZZZZZZ%
+    ZZZZZZZ
   \else
     \csname SET#1\endcsname
   \fi
@@ -4810,7 +4745,7 @@ $$%
 
 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
 % with @set.
-%
+% 
 % To get the special treatment we need for `@end ifset,' we call
 % \makecond and then redefine.
 %
@@ -4843,7 +4778,7 @@ $$%
 % without the @) is in fact defined.  We can only feasibly check at the
 % TeX level, so something like `mathcode' is going to considered
 % defined even though it is not a Texinfo command.
-%
+% 
 \makecond{ifcommanddefined}
 \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
 %
@@ -4949,18 +4884,32 @@ $$%
 
 % like the previous two, but they put @code around the argument.
 \def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
-\def\docodeindexxxx #1{\docind{\indexname}{#1}}
+\def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}}
 
+
+% Used when writing an index entry out to an index file to prevent
+% expansion of Texinfo commands that can appear in an index entry.
+%
+\def\indexdummies{%
+  \escapechar = `\\     % use backslash in output files.
+  \definedummyletter\@%
+  \definedummyletter\ %
+  %
+  % For texindex which always views { and } as separators.
+  \def\{{\lbracechar{}}%
+  \def\}{\rbracechar{}}%
+  %
+  % Do the redefinitions.
+  \definedummies
+}
 
-% Used for the aux, toc and index files to prevent expansion of Texinfo
-% commands.
+% Used for the aux and toc files, where @ is the escape character.
 %
 \def\atdummies{%
   \definedummyletter\@%
   \definedummyletter\ %
   \definedummyletter\{%
   \definedummyletter\}%
-  \definedummyletter\&%
   %
   % Do the redefinitions.
   \definedummies
@@ -4984,7 +4933,8 @@ $$%
 \def\definedummyletter#1{\def#1{\string#1}}%
 \let\definedummyaccent\definedummyletter
 
-% Called from \atdummies to prevent the expansion of commands.
+% Called from \indexdummies and \atdummies, to effectively prevent
+% the expansion of commands.
 %
 \def\definedummies{%
   %
@@ -5031,10 +4981,8 @@ $$%
   \definedummyword\TeX
   %
   % Assorted special characters.
-  \definedummyword\ampchar
   \definedummyword\atchar
   \definedummyword\arrow
-  \definedummyword\backslashchar
   \definedummyword\bullet
   \definedummyword\comma
   \definedummyword\copyright
@@ -5071,8 +5019,6 @@ $$%
   \definedummyword\sup
   \definedummyword\textdegree
   %
-  \definedummyword\subentry
-  %
   % We want to disable all macros so that they are not expanded by \write.
   \macrolist
   \let\value\dummyvalue
@@ -5153,10 +5099,11 @@ $$%
   \commondummyword\xref
 }
 
+% For testing: output @{ and @} in index sort strings as \{ and \}.
+\newif\ifusebracesinindexes
+
 \let\indexlbrace\relax
 \let\indexrbrace\relax
-\let\indexatchar\relax
-\let\indexbackslash\relax
 
 {\catcode`\@=0
 \catcode`\\=13
@@ -5190,8 +5137,10 @@ $$%
   }
 
   \gdef\indexnonalnumreappear{%
+    \useindexbackslash
     \let-\normaldash
     \let<\normalless
+    \def\@{@}%
   }
 }
 
@@ -5225,66 +5174,64 @@ $$%
   \let\lbracechar\{%
   \let\rbracechar\}%
   %
-  %
-  \let\do\indexnofontsdef
-  %
   % Non-English letters.
-  \do\AA{AA}%
-  \do\AE{AE}%
-  \do\DH{DZZ}%
-  \do\L{L}%
-  \do\OE{OE}%
-  \do\O{O}%
-  \do\TH{TH}%
-  \do\aa{aa}%
-  \do\ae{ae}%
-  \do\dh{dzz}%
-  \do\exclamdown{!}%
-  \do\l{l}%
-  \do\oe{oe}%
-  \do\ordf{a}%
-  \do\ordm{o}%
-  \do\o{o}%
-  \do\questiondown{?}%
-  \do\ss{ss}%
-  \do\th{th}%
-  %
-  \do\LaTeX{LaTeX}%
-  \do\TeX{TeX}%
-  %
-  % Assorted special characters.
-  \do\atchar{@}%
-  \do\arrow{->}%
-  \do\bullet{bullet}%
-  \do\comma{,}%
-  \do\copyright{copyright}%
-  \do\dots{...}%
-  \do\enddots{...}%
-  \do\equiv{==}%
-  \do\error{error}%
-  \do\euro{euro}%
-  \do\expansion{==>}%
-  \do\geq{>=}%
-  \do\guillemetleft{<<}%
-  \do\guillemetright{>>}%
-  \do\guilsinglleft{<}%
-  \do\guilsinglright{>}%
-  \do\leq{<=}%
-  \do\lbracechar{\{}%
-  \do\minus{-}%
-  \do\point{.}%
-  \do\pounds{pounds}%
-  \do\print{-|}%
-  \do\quotedblbase{"}%
-  \do\quotedblleft{"}%
-  \do\quotedblright{"}%
-  \do\quoteleft{`}%
-  \do\quoteright{'}%
-  \do\quotesinglbase{,}%
-  \do\rbracechar{\}}%
-  \do\registeredsymbol{R}%
-  \do\result{=>}%
-  \do\textdegree{o}%
+  \def\AA{AA}%
+  \def\AE{AE}%
+  \def\DH{DZZ}%
+  \def\L{L}%
+  \def\OE{OE}%
+  \def\O{O}%
+  \def\TH{TH}%
+  \def\aa{aa}%
+  \def\ae{ae}%
+  \def\dh{dzz}%
+  \def\exclamdown{!}%
+  \def\l{l}%
+  \def\oe{oe}%
+  \def\ordf{a}%
+  \def\ordm{o}%
+  \def\o{o}%
+  \def\questiondown{?}%
+  \def\ss{ss}%
+  \def\th{th}%
+  %
+  \def\LaTeX{LaTeX}%
+  \def\TeX{TeX}%
+  %
+  % Assorted special characters.  \defglyph gives the control sequence a
+  % definition that removes the {} that follows its use.
+  \defglyph\atchar{@}%
+  \defglyph\arrow{->}%
+  \defglyph\bullet{bullet}%
+  \defglyph\comma{,}%
+  \defglyph\copyright{copyright}%
+  \defglyph\dots{...}%
+  \defglyph\enddots{...}%
+  \defglyph\equiv{==}%
+  \defglyph\error{error}%
+  \defglyph\euro{euro}%
+  \defglyph\expansion{==>}%
+  \defglyph\geq{>=}%
+  \defglyph\guillemetleft{<<}%
+  \defglyph\guillemetright{>>}%
+  \defglyph\guilsinglleft{<}%
+  \defglyph\guilsinglright{>}%
+  \defglyph\leq{<=}%
+  \defglyph\lbracechar{\{}%
+  \defglyph\minus{-}%
+  \defglyph\point{.}%
+  \defglyph\pounds{pounds}%
+  \defglyph\print{-|}%
+  \defglyph\quotedblbase{"}%
+  \defglyph\quotedblleft{"}%
+  \defglyph\quotedblright{"}%
+  \defglyph\quoteleft{`}%
+  \defglyph\quoteright{'}%
+  \defglyph\quotesinglbase{,}%
+  \defglyph\rbracechar{\}}%
+  \defglyph\registeredsymbol{R}%
+  \defglyph\result{=>}%
+  \defglyph\textdegree{o}%
   %
   % We need to get rid of all macros, leaving only the arguments (if present).
   % Of course this is not nearly correct, but it is the best we can do for now.
@@ -5299,38 +5246,41 @@ $$%
   \macrolist
   \let\value\indexnofontsvalue
 }
+\def\defglyph#1#2{\def#1##1{#2}} % see above
 
-% Give the control sequence a definition that removes the {} that follows
-% its use, e.g. @AA{} -> AA
-\def\indexnofontsdef#1#2{\def#1##1{#2}}%
-
+
 
 
+\let\SETmarginindex=\relax % put index entries in margin (undocumented)?
 
+% Most index entries go through here, but \dosubind is the general case.
 % #1 is the index name, #2 is the entry text.
-\def\doind#1#2{%
-  \iflinks
-  {%
-    %
-    \requireopenindexfile{#1}%
-    \edef\writeto{\csname#1indfile\endcsname}%
-    %
-    \def\indextext{#2}%
-    \safewhatsit\doindwrite
-  }%
-  \fi
-}
+\def\doind#1#2{\dosubind{#1}{#2}{}}
+
+% There is also \dosubind {index}{topic}{subtopic}
+% which makes an entry in a two-level index such as the operation index.
+% TODO: Two-level index?  Operation index?
 
-% Same as \doind, but for code indices
-\def\docind#1#2{%
+% Workhorse for all indexes.
+% #1 is name of index, #2 is stuff to put there, #3 is subentry --
+% empty if called from \doind, as we usually are (the main exception
+% is with most defuns, which call us directly).
+%
+\def\dosubind#1#2#3{%
   \iflinks
   {%
-    %
     \requireopenindexfile{#1}%
+    % Store the main index entry text (including the third arg).
+    \toks0 = {#2}%
+    % If third arg is present, precede it with a space.
+    \def\thirdarg{#3}%
+    \ifx\thirdarg\empty \else
+      \toks0 = \expandafter{\the\toks0 \space #3}%
+    \fi
+    %
     \edef\writeto{\csname#1indfile\endcsname}%
     %
-    \def\indextext{#2}%
-    \safewhatsit\docindwrite
+    \safewhatsit\dosubindwrite
   }%
   \fi
 }
@@ -5345,14 +5295,28 @@ $$%
   \ifx\suffix\indexisfl\def\suffix{f1}\fi
   % Open the file
   \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
-  % Using \immediate above here prevents an object entering into the current
+  % Using \immediate above here prevents an object entering into the current 
   % box, which could confound checks such as those in \safewhatsit for
   % preceding skips.
   \typeout{Writing index file \jobname.\suffix}%
 \fi}
 \def\indexisfl{fl}
 
-% Definition for writing index entry sort key.
+% Output \ as {\indexbackslash}, because \ is an escape character in
+% the index files.
+\let\indexbackslash=\relax
+{\catcode`\@=0 \catcode`\\=\active
+  @gdef@useindexbackslash{@def\{{@indexbackslash}}}
+}
+
+% Definition for writing index entry text.
+\def\sortas#1{\ignorespaces}%
+
+% Definition for writing index entry sort key.  Should occur at the at
+% the beginning of the index entry, like
+%     @cindex @sortas{september} \september
+% The \ignorespaces takes care of following space, but there's no way
+% to remove space before it.
 {
 \catcode`\-=13
 \gdef\indexwritesortas{%
@@ -5363,158 +5327,51 @@ $$%
   \xdef\indexsortkey{#1}\endgroup}
 }
 
-\def\indexwriteseealso#1{
-  \gdef\pagenumbertext{\string\seealso{#1}}%
-}
-\def\indexwriteseeentry#1{
-  \gdef\pagenumbertext{\string\seeentry{#1}}%
-}
-
-% The default definitions
-\def\sortas#1{}%
-\def\seealso#1{\i{\putwordSeeAlso}\ #1}% for sorted index file only
-\def\putwordSeeAlso{See also}
-\def\seeentry#1{\i{\putwordSee}\ #1}% for sorted index file only
-
 
-% Given index entry text like "aaa @subentry bbb @sortas{ZZZ}":
-%   * Set \bracedtext to "{aaa}{bbb}"
-%   * Set \fullindexsortkey to "aaa @subentry ZZZ"
-%   * If @seealso occurs, set \pagenumbertext
+% Write the entry in \toks0 to the index file.
 %
-\def\splitindexentry#1{%
-  \gdef\fullindexsortkey{}%
-  \xdef\bracedtext{}%
-  \def\sep{}%
-  \def\seealso##1{}%
-  \def\seeentry##1{}%
-  \expandafter\doindexsegment#1\subentry\finish\subentry
-}
-
-% append the results from the next segment
-\def\doindexsegment#1\subentry{%
-  \def\segment{#1}%
-  \ifx\segment\isfinish
-  \else
-    %
-    % Fully expand the segment, throwing away any @sortas directives, and
-    % trim spaces.
-    \edef\trimmed{\segment}%
-    \edef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
-    \ifincodeindex
-      \edef\trimmed{\noexpand\code{\trimmed}}%
-    \fi
-    %
-    \xdef\bracedtext{\bracedtext{\trimmed}}%
-    %
-    % Get the string to sort by.  Process the segment with all
-    % font commands turned off.
-    \bgroup
-      \let\sortas\indexwritesortas
-      \let\seealso\indexwriteseealso
-      \let\seeentry\indexwriteseeentry
-      \indexnofonts
-      % The braces around the commands are recognized by texindex.
-      \def\lbracechar{{\string\indexlbrace}}%
-      \def\rbracechar{{\string\indexrbrace}}%
-      \let\{=\lbracechar
-      \let\}=\rbracechar
-      \def\@{{\string\indexatchar}}%
-      \def\atchar##1{\@}%
-      \def\backslashchar{{\string\indexbackslash}}%
-      \uccode`\~=`\\ \uppercase{\let~\backslashchar}%
-      %
-      \let\indexsortkey\empty
-      \global\let\pagenumbertext\empty
-      % Execute the segment and throw away the typeset output.  This executes
-      % any @sortas or @seealso commands in this segment.
-      \setbox\dummybox = \hbox{\segment}%
-      \ifx\indexsortkey\empty{%
-        \indexnonalnumdisappear
-        \xdef\trimmed{\segment}%
-        \xdef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
-        \xdef\indexsortkey{\trimmed}%
-        \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
-      }\fi
-      %
-      % Append to \fullindexsortkey.
-      \edef\tmp{\gdef\noexpand\fullindexsortkey{%
-                  \fullindexsortkey\sep\indexsortkey}}%
-      \tmp
-    \egroup
-    \def\sep{\subentry}%
-    %
-    \expandafter\doindexsegment
-  \fi
-}
-\def\isfinish{\finish}%
-\newbox\dummybox % used above
-
-\let\subentry\relax
-
-% Use \ instead of @ in index files.  To support old texi2dvi and texindex.
-% This works without changing the escape character used in the toc or aux
-% files because the index entries are fully expanded here, and \string uses
-% the current value of \escapechar.
-\def\escapeisbackslash{\escapechar=`\\}
-
-% Use \ in index files by default.  texi2dvi didn't support @ as the escape
-% character (as it checked for "\entry" in the files, and not "@entry").  When
-% the new version of texi2dvi has had a chance to become more prevalent, then
-% the escape character can change back to @ again.  This should be an easy
-% change to make now because both @ and \ are only used as escape characters in
-% index files, never standing for themselves.
-%
-\set txiindexescapeisbackslash
-
-% Write the entry in \indextext to the index file.
-%
-
-\newif\ifincodeindex
-\def\doindwrite{\incodeindexfalse\doindwritex}
-\def\docindwrite{\incodeindextrue\doindwritex}
-
-\def\doindwritex{%
-  \maybemarginindex
-  %
-  \atdummies
-  %
-  \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax\else
-    \escapeisbackslash
+\def\dosubindwrite{%
+  % Put the index entry in the margin if desired.
+  \ifx\SETmarginindex\relax\else
+    \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
   \fi
   %
-  % For texindex which always views { and } as separators.
-  \def\{{\lbracechar{}}%
-  \def\}{\rbracechar{}}%
-  \uccode`\~=`\\ \uppercase{\def~{\backslashchar{}}}%
-  %
-  % Split the entry into primary entry and any subentries, and get the index
-  % sort key.
-  \splitindexentry\indextext
+  % Remember, we are within a group.
+  \indexdummies % Must do this here, since \bf, etc expand at this stage
+  \useindexbackslash % \indexbackslash isn't defined now so it will be output 
+                     % as is; and it will print as backslash.
+  % The braces around \indexbrace are recognized by texindex.
+  %
+  % Get the string to sort by, by processing the index entry with all
+  % font commands turned off.
+  {\indexnofonts
+   \def\lbracechar{{\indexlbrace}}%
+   \def\rbracechar{{\indexrbrace}}%
+   \let\{=\lbracechar
+   \let\}=\rbracechar
+   \indexnonalnumdisappear
+   \xdef\indexsortkey{}%
+   \let\sortas=\indexwritesortas
+   \edef\temp{\the\toks0}%
+   \setbox\dummybox = \hbox{\temp}% Make sure to execute any \sortas
+   \ifx\indexsortkey\empty
+     \xdef\indexsortkey{\temp}%
+     \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
+   \fi
+  }%
   %
   % Set up the complete index entry, with both the sort key and
   % the original text, including any font commands.  We write
   % three arguments to \entry to the .?? file (four in the
   % subentry case), texindex reduces to two when writing the .??s
   % sorted result.
-  %
   \edef\temp{%
     \write\writeto{%
-      \string\entry{\fullindexsortkey}%
-        {\ifx\pagenumbertext\empty\noexpand\folio\else\pagenumbertext\fi}%
-        \bracedtext}%
+      \string\entry{\indexsortkey}{\noexpand\folio}{\the\toks0}}%
   }%
   \temp
 }
-
-% Put the index entry in the margin if desired (undocumented).
-\def\maybemarginindex{%
-  \ifx\SETmarginindex\relax\else
-    \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \relax\indextext}}%
-  \fi
-}
-\let\SETmarginindex=\relax
-
+\newbox\dummybox % used above
 
 % Take care of unwanted page breaks/skips around a whatsit:
 %
@@ -5602,14 +5459,9 @@ $$%
 %  \entry {topic}{pagelist}
 %     for a topic that is used without subtopics
 %  \primary {topic}
-%  \entry {topic}{}
 %     for the beginning of a topic that is used with subtopics
 %  \secondary {subtopic}{pagelist}
 %     for each subtopic.
-%  \secondary {subtopic}{}
-%     for a subtopic with sub-subtopics
-%  \tertiary {subtopic}{subsubtopic}{pagelist}
-%     for each sub-subtopic.
 
 % Define the user-accessible indexing commands
 % @findex, @vindex, @kindex, @cindex.
@@ -5621,6 +5473,11 @@ $$%
 \def\tindex {\tpindex}
 \def\pindex {\pgindex}
 
+\def\cindexsub {\begingroup\obeylines\cindexsub}
+{\obeylines %
+\gdef\cindexsub "#1" #2^^M{\endgroup %
+\dosubind{cp}{#2}{#1}}}
+
 % Define the macros used in formatting output of the sorted index material.
 
 % @printindex causes a particular index (the ??s file) to get printed.
@@ -5634,10 +5491,14 @@ $$%
   \plainfrenchspacing
   \everypar = {}% don't want the \kern\-parindent from indentation suppression.
   %
+  % See if the index file exists and is nonempty.
+  % Change catcode of @ here so that if the index file contains
+  % \initial {@}
+  % as its first line, TeX doesn't complain about mismatched braces
+  % (because it thinks @} is a control sequence).
+  \catcode`\@ = 12
   % See comment in \requireopenindexfile.
   \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
-  %
-  % See if the index file exists and is nonempty.
   \openin 1 \jobname.\indexname s
   \ifeof 1
     % \enddoublecolumns gets confused if there is no text in the index,
@@ -5647,6 +5508,8 @@ $$%
     \putwordIndexNonexistent
     \typeout{No file \jobname.\indexname s.}%
   \else
+    \catcode`\\ = 0
+    %
     % If the index file exists but is empty, then \openin leaves \ifeof
     % false.  We have to make TeX try to read something from the file, so
     % it can discover if there is anything in it.
@@ -5654,55 +5517,47 @@ $$%
     \ifeof 1
       \putwordIndexIsEmpty
     \else
-      \expandafter\printindexzz\thisline\relax\relax\finish%
+      % Index files are almost Texinfo source, but we use \ as the escape
+      % character.  It would be better to use @, but that's too big a change
+      % to make right now.
+      \def\indexbackslash{\ttbackslash}%
+      \let\indexlbrace\{   % Likewise, set these sequences for braces
+      \let\indexrbrace\}   % used in the sort key.
+      \begindoublecolumns
+      \let\dotheinsertentrybox\dotheinsertentryboxwithpenalty
+      %
+      % Read input from the index file line by line.
+      \loopdo
+        \ifeof1 \else
+          \read 1 to \nextline
+        \fi
+        %
+        \indexinputprocessing
+        \thisline
+        %
+        \ifeof1\else
+        \let\thisline\nextline
+      \repeat
+      %%
+      \enddoublecolumns
     \fi
   \fi
   \closein 1
 \endgroup}
+\def\loopdo#1\repeat{\def\body{#1}\loopdoxxx}
+\def\loopdoxxx{\let\next=\relax\body\let\next=\loopdoxxx\fi\next}
 
-% If the index file starts with a backslash, forgo reading the index
-% file altogether.  If somebody upgrades texinfo.tex they may still have
-% old index files using \ as the escape character.  Reading this would
-% at best lead to typesetting garbage, at worst a TeX syntax error.
-\def\printindexzz#1#2\finish{%
-  \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax
-    \uccode`\~=`\\ \uppercase{\if\noexpand~}\noexpand#1
-      \expandafter\ifx\csname SETtxiskipindexfileswithbackslash\endcsname\relax
-\errmessage{%
-ERROR: A sorted index file in an obsolete format was skipped.
-To fix this problem, please upgrade your version of 'texi2dvi'
-or 'texi2pdf' to that at <https://ftp.gnu.org/gnu/texinfo>.
-If you are using an old version of 'texindex' (part of the Texinfo
-distribution), you may also need to upgrade to a newer version (at least 6.0).
-You may be able to typeset the index if you run
-'texindex \jobname.\indexname' yourself.
-You could also try setting the 'txiindexescapeisbackslash' flag by
-running a command like
-'texi2dvi -t "@set txiindexescapeisbackslash" \jobname.texi'.  If you do
-this, Texinfo will try to use index files in the old format.
-If you continue to have problems, deleting the index files and starting again
-might help (with 'rm \jobname.?? \jobname.??s')%
-}%
-      \else
-        (Skipped sorted index file in obsolete format)
-      \fi
-    \else
-      \begindoublecolumns
-      \input \jobname.\indexname s
-      \enddoublecolumns
-    \fi
+\def\indexinputprocessing{%
+  \ifeof1
+    \let\firsttoken\relax
   \else
-    \begindoublecolumns
-    \catcode`\\=0\relax
-    %
-    % Make @ an escape character to give macros a chance to work.  This
-    % should work because we (hopefully) don't otherwise use @ in index files.
-    %\catcode`\@=12\relax
-    \catcode`\@=0\relax
-    \input \jobname.\indexname s
-    \enddoublecolumns
+    \edef\act{\gdef\noexpand\firsttoken{\getfirsttoken\nextline}}%
+    \act
   \fi
 }
+\def\getfirsttoken#1{\expandafter\getfirsttokenx#1\endfirsttoken}
+\long\def\getfirsttokenx#1#2\endfirsttoken{\noexpand#1}
+
 
 % These macros are used by the sorted index file itself.
 % Change them to control the appearance of the index.
@@ -5711,19 +5566,12 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 \catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
 \catcode`\$=3
 \gdef\initialglyphs{%
-  % special control sequences used in the index sort key
-  \let\indexlbrace\{%
-  \let\indexrbrace\}%
-  \let\indexatchar\@%
-  \def\indexbackslash{\math{\backslash}}%
-  %
   % Some changes for non-alphabetic characters.  Using the glyphs from the
   % math fonts looks more consistent than the typewriter font used elsewhere
   % for these characters.
-  \uccode`\~=`\\ \uppercase{\def~{\math{\backslash}}}
+  \def\indexbackslash{\math{\backslash}}%
+  \let\\=\indexbackslash
   %
-  % In case @\ is used for backslash
-  \uppercase{\let\\=~}
   % Can't get bold backslash so don't use bold forward slash
   \catcode`\/=13
   \def/{{\secrmnotbold \normalslash}}%
@@ -5753,7 +5601,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   % bottom of a column to reduce an increase in inter-line spacing.
   \nobreak
   \vskip 0pt plus 5\baselineskip
-  \penalty -300
+  \penalty -300 
   \vskip 0pt plus -5\baselineskip
   %
   % Typeset the initial.  Making this add up to a whole number of
@@ -5782,6 +5630,12 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 %
 \def\entry{%
   \begingroup
+    %
+    % For pdfTeX and XeTeX.
+    % The redefinition of \domark stops marks being added in \pdflink to 
+    % preserve coloured links across page boundaries.  Otherwise the marks
+    % would get in the way of \lastbox in \insertentrybox.
+    \let\domark\relax
     %
     % Start a new paragraph if necessary, so our assignments below can't
     % affect previous text.
@@ -5815,31 +5669,35 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 \gdef\finishentry#1{%
     \egroup % end box A
     \dimen@ = \wd\boxA % Length of text of entry
-    \global\setbox\boxA=\hbox\bgroup
-      \unhbox\boxA
-      % #1 is the page number.
+    \global\setbox\boxA=\hbox\bgroup\unhbox\boxA
+    % #1 is the page number.
+    %
+    % Get the width of the page numbers, and only use
+    % leaders if they are present.
+    \global\setbox\boxB = \hbox{#1}%
+    \ifdim\wd\boxB = 0pt
+      \null\nobreak\hfill\ %
+    \else
+      %
+      \null\nobreak\indexdotfill % Have leaders before the page number.
       %
-      % Get the width of the page numbers, and only use
-      % leaders if they are present.
-      \global\setbox\boxB = \hbox{#1}%
-      \ifdim\wd\boxB = 0pt
-        \null\nobreak\hfill\ %
+      \ifpdf
+        \pdfgettoks#1.%
+        \hskip\skip\thinshrinkable\the\toksA
       \else
-        %
-        \null\nobreak\indexdotfill % Have leaders before the page number.
-        %
-        \ifpdforxetex
+        \ifx\XeTeXrevision\thisisundefined
+          \hskip\skip\thinshrinkable #1%
+        \else
           \pdfgettoks#1.%
           \hskip\skip\thinshrinkable\the\toksA
-        \else
-          \hskip\skip\thinshrinkable #1%
         \fi
       \fi
+    \fi
     \egroup % end \boxA
     \ifdim\wd\boxB = 0pt
-      \noindent\unhbox\boxA\par
-      \nobreak
-    \else\bgroup
+      \global\setbox\entrybox=\vbox{\unhbox\boxA}%
+    \else
+    \global\setbox\entrybox=\vbox\bgroup
       % We want the text of the entries to be aligned to the left, and the
       % page numbers to be aligned to the right.
       %
@@ -5869,7 +5727,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
       \advance\dimen@ii by 1\dimen@i
       \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line
       \ifdim\dimen@ > 0.8\dimen@ii   % due to long index text
-        % Try to split the text roughly evenly.  \dimen@ will be the length of
+        % Try to split the text roughly evenly.  \dimen@ will be the length of 
         % the first line.
         \dimen@ = 0.7\dimen@
         \dimen@ii = \hsize
@@ -5905,11 +5763,55 @@ might help (with 'rm \jobname.?? \jobname.??s')%
     \egroup % The \vbox
     \fi
   \endgroup
+  \dotheinsertentrybox
 }}
 
 \newskip\thinshrinkable
 \skip\thinshrinkable=.15em minus .15em
 
+\newbox\entrybox
+\def\insertentrybox{%
+  \ourunvbox\entrybox
+}
+
+% default definition
+\let\dotheinsertentrybox\insertentrybox
+
+% Use \lastbox to take apart vbox box by box, and add each sub-box
+% to the current vertical list.
+\def\ourunvbox#1{%
+\bgroup % for local binding of \delayedbox
+  % Remove the last box from box #1
+  \global\setbox#1=\vbox{%
+    \unvbox#1%
+    \unskip % remove any glue
+    \unpenalty
+    \global\setbox\interbox=\lastbox
+  }%
+  \setbox\delayedbox=\box\interbox
+  \ifdim\ht#1=0pt\else
+    \ourunvbox#1 % Repeat on what's left of the box
+    \nobreak
+  \fi
+  \box\delayedbox
+\egroup
+}
+\newbox\delayedbox
+\newbox\interbox
+
+% Used from \printindex.  \firsttoken should be the first token
+% after the \entry.  If it's not another \entry, we are at the last
+% line of a group of index entries, so insert a penalty to discourage
+% widowed index entries.
+\def\dotheinsertentryboxwithpenalty{%
+  \ifx\firsttoken\isentry
+  \else
+    \penalty 9000
+  \fi
+  \insertentrybox
+}
+\def\isentry{\entry}%
+
 % Like plain.tex's \dotfill, except uses up at least 1 em.
 % The filll stretch here overpowers both the fil and fill stretch to push
 % the page number to the right.
@@ -5919,15 +5821,24 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 
 \def\primary #1{\line{#1\hfil}}
 
-\def\secondary{\indententry{0.5cm}}
-\def\tertiary{\indententry{1cm}}
-
-\def\indententry#1#2#3{%
-  \bgroup
-  \leftskip=#1
-  \entry{#2}{#3}%
-  \egroup
-}
+\newskip\secondaryindent \secondaryindent=0.5cm
+\def\secondary#1#2{{%
+  \parfillskip=0in
+  \parskip=0in
+  \hangindent=1in
+  \hangafter=1
+  \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
+  \ifpdf
+    \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
+  \else
+    \ifx\XeTeXrevision\thisisundefined
+      #2
+    \else
+      \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
+    \fi
+  \fi
+  \par
+}}
 
 % Define two-column mode, which we use to typeset indexes.
 % Adapted from the TeXbook, page 416, which is to say,
@@ -5937,21 +5848,60 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 \newbox\partialpage
 \newdimen\doublecolumnhsize
 
+% Use inside an output routine to save \topmark and \firstmark
+\def\savemarks{%
+  \global\savedtopmark=\expandafter{\topmark }%
+  \global\savedfirstmark=\expandafter{\firstmark }%
+}
+\newtoks\savedtopmark
+\newtoks\savedfirstmark
+
+% Set \topmark and \firstmark for next time \output runs.
+% Can't be run from withinside \output (because any material
+% added while an output routine is active, including 
+% penalties, is saved for after it finishes).  The page so far
+% should be empty, otherwise what's on it will be thrown away.
+\def\restoremarks{%
+  \mark{\the\savedtopmark}%
+  \bgroup\output = {%
+    \setbox\dummybox=\box\PAGE
+  }abc\eject\egroup
+  % "abc" because output routine doesn't fire for a completely empty page.
+  \mark{\the\savedfirstmark}%
+}
+
 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
   % If not much space left on page, start a new page.
   \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
   %
   % Grab any single-column material above us.
   \output = {%
-    \savetopmark
+    %
+    % Here is a possibility not foreseen in manmac: if we accumulate a
+    % whole lot of material, we might end up calling this \output
+    % routine twice in a row (see the doublecol-lose test, which is
+    % essentially a couple of indexes with @setchapternewpage off).  In
+    % that case we just ship out what is in \partialpage with the normal
+    % output routine.  Generally, \partialpage will be empty when this
+    % runs and this will be a no-op.  See the indexspread.tex test case.
+    \ifvoid\partialpage \else
+      \onepageout{\pagecontents\partialpage}%
+    \fi
     %
     \global\setbox\partialpage = \vbox{%
       % Unvbox the main output page.
       \unvbox\PAGE
       \kern-\topskip \kern\baselineskip
     }%
+    \savemarks
   }%
   \eject % run that output routine to set \partialpage
+  \restoremarks
+  %
+  % We recover the two marks that the last output routine saved in order
+  % to propagate the information in marks added around a chapter heading,
+  % which could be otherwise be lost by the time the final page is output.
+  %
   %
   % Use the double-column output routine for subsequent pages.
   \output = {\doublecolumnout}%
@@ -5977,9 +5927,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
     \divide\doublecolumnhsize by 2
   \hsize = \doublecolumnhsize
   %
-  % Get the available space for the double columns -- the normal
-  % (undoubled) page height minus any material left over from the
-  % previous page.
+  % Double the \vsize as well.
   \advance\vsize by -\ht\partialpage
   \vsize = 2\vsize
   %
@@ -5992,15 +5940,17 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 %
 \def\doublecolumnout{%
   %
-  \savetopmark
   \splittopskip=\topskip \splitmaxdepth=\maxdepth
+  % Get the available space for the double columns -- the normal
+  % (undoubled) page height minus any material left over from the
+  % previous page.
   \dimen@ = \vsize
   \divide\dimen@ by 2
   %
   % box0 will be the left-hand column, box2 the right.
   \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@
   \global\advance\vsize by 2\ht\partialpage
-  \onepageout\pagesofar % empty except for the first time we are called
+  \onepageout\pagesofar
   \unvbox\PAGE
   \penalty\outputpenalty
 }
@@ -6016,7 +5966,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 }
 
 
-% Finished with double columns.
+% Finished with with double columns.
 \def\enddoublecolumns{%
   % The following penalty ensures that the page builder is exercised
   % _before_ we change the output routine.  This is necessary in the
@@ -6048,7 +5998,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   %
   \output = {%
     % Split the last of the double-column material.
-    \savetopmark
+    \savemarks
     \balancecolumns
   }%
   \eject % call the \output just set
@@ -6056,9 +6006,10 @@ might help (with 'rm \jobname.?? \jobname.??s')%
     % Having called \balancecolumns once, we do not
     % want to call it again.  Therefore, reset \output to its normal
     % definition right away.
-    \global\output=\expandafter{\the\defaultoutput}
+    \global\output = {\onepageout{\pagecontents\PAGE}}%
     %
     \endgroup % started in \begindoublecolumns
+    \restoremarks
     % Leave the double-column material on the current page, no automatic
     % page break.
     \box\balancedcolumns
@@ -6077,19 +6028,18 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 \newbox\balancedcolumns
 \setbox\balancedcolumns=\vbox{shouldnt see this}%
 %
-% Only called for the last of the double column material.  \doublecolumnout
+% Only called for the last of the double column material.  \doublecolumnout 
 % does the others.
 \def\balancecolumns{%
   \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120.
   \dimen@ = \ht0
-  \ifdim\dimen@<7\baselineskip
+  \advance\dimen@ by \topskip
+  \advance\dimen@ by-\baselineskip
+  \ifdim\dimen@<5\baselineskip
     % Don't split a short final column in two.
     \setbox2=\vbox{}%
     \global\setbox\balancedcolumns=\vbox{\pagesofar}%
   \else
-    % double the leading vertical space
-    \advance\dimen@ by \topskip
-    \advance\dimen@ by-\baselineskip
     \divide\dimen@ by 2 % target to split to
     \dimen@ii = \dimen@
     \splittopskip = \topskip
@@ -6105,7 +6055,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
     }%
     % Now the left column is in box 1, and the right column in box 3.
     %
-    % Check whether the left column has come out higher than the page itself.
+    % Check whether the left column has come out higher than the page itself.  
     % (Note that we have doubled \vsize for the double columns, so
     % the actual height of the page is 0.5\vsize).
     \ifdim2\ht1>\vsize
@@ -6224,9 +6174,11 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 
 % @raisesections: treat @section as chapter, @subsection as section, etc.
 \def\raisesections{\global\advance\secbase by -1}
+\let\up=\raisesections % original BFox name
 
 % @lowersections: treat @chapter as section, @section as subsection, etc.
 \def\lowersections{\global\advance\secbase by 1}
+\let\down=\lowersections % original BFox name
 
 % we only have subsub.
 \chardef\maxseclevel = 3
@@ -6402,7 +6354,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 \let\top\unnumbered
 
 % Sections.
-%
+% 
 \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
 \def\seczzz#1{%
   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
@@ -6425,7 +6377,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 }
 
 % Subsections.
-%
+% 
 % normally calls numberedsubseczzz:
 \outer\parseargdef\numberedsubsec{\numhead2{#1}}
 \def\numberedsubseczzz#1{%
@@ -6450,7 +6402,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 }
 
 % Subsubsections.
-%
+% 
 % normally numberedsubsubseczzz:
 \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
 \def\numberedsubsubseczzz#1{%
@@ -6540,16 +6492,18 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 \def\CHAPPAGoff{%
 \global\let\contentsalignmacro = \chappager
 \global\let\pchapsepmacro=\chapbreak
-\global\def\HEADINGSon{\HEADINGSsinglechapoff}}
+\global\let\pagealignmacro=\chappager}
 
 \def\CHAPPAGon{%
 \global\let\contentsalignmacro = \chappager
 \global\let\pchapsepmacro=\chappager
+\global\let\pagealignmacro=\chappager
 \global\def\HEADINGSon{\HEADINGSsingle}}
 
 \def\CHAPPAGodd{%
 \global\let\contentsalignmacro = \chapoddpage
 \global\let\pchapsepmacro=\chapoddpage
+\global\let\pagealignmacro=\chapoddpage
 \global\def\HEADINGSon{\HEADINGSdouble}}
 
 \CHAPPAGon
@@ -6569,22 +6523,27 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   \expandafter\ifx\thisenv\titlepage\else
     \checkenv{}% chapters, etc., should not start inside an environment.
   \fi
+  % FIXME: \chapmacro is currently called from inside \titlepage when
+  % \setcontentsaftertitlepage to print the "Table of Contents" heading, but
+  % this should probably be done by \sectionheading with an option to print
+  % in chapter size.
+  %
   % Insert the first mark before the heading break (see notes for \domark).
-  \let\prevchapterdefs=\currentchapterdefs
-  \let\prevsectiondefs=\currentsectiondefs
-  \gdef\currentsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
+  \let\prevchapterdefs=\lastchapterdefs
+  \let\prevsectiondefs=\lastsectiondefs
+  \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
                         \gdef\thissection{}}%
   %
   \def\temptype{#2}%
   \ifx\temptype\Ynothingkeyword
-    \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
+    \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
                           \gdef\thischapter{\thischaptername}}%
   \else\ifx\temptype\Yomitfromtockeyword
-    \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
+    \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
                           \gdef\thischapter{}}%
   \else\ifx\temptype\Yappendixkeyword
     \toks0={#1}%
-    \xdef\currentchapterdefs{%
+    \xdef\lastchapterdefs{%
       \gdef\noexpand\thischaptername{\the\toks0}%
       \gdef\noexpand\thischapternum{\appendixletter}%
       % \noexpand\putwordAppendix avoids expanding indigestible
@@ -6595,7 +6554,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
     }%
   \else
     \toks0={#1}%
-    \xdef\currentchapterdefs{%
+    \xdef\lastchapterdefs{%
       \gdef\noexpand\thischaptername{\the\toks0}%
       \gdef\noexpand\thischapternum{\the\chapno}%
       % \noexpand\putwordChapter avoids expanding indigestible
@@ -6615,18 +6574,18 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   %
   % Now the second mark, after the heading break.  No break points
   % between here and the heading.
-  \let\prevchapterdefs=\currentchapterdefs
-  \let\prevsectiondefs=\currentsectiondefs
+  \let\prevchapterdefs=\lastchapterdefs
+  \let\prevsectiondefs=\lastsectiondefs
   \domark
   %
   {%
     \chapfonts \rm
     \let\footnote=\errfootnoteheading % give better error message
     %
-    % Have to define \currentsection before calling \donoderef, because the
+    % Have to define \lastsection before calling \donoderef, because the
     % xref code eventually uses it.  On the other hand, it has to be called
     % after \pchapsepmacro, or the headline will change too soon.
-    \gdef\currentsection{#1}%
+    \gdef\lastsection{#1}%
     %
     % Only insert the separating space if we have a chapter/appendix
     % number, and don't print the unnumbered ``number''.
@@ -6715,10 +6674,10 @@ might help (with 'rm \jobname.?? \jobname.??s')%
     \csname #2fonts\endcsname \rm
     %
     % Insert first mark before the heading break (see notes for \domark).
-    \let\prevsectiondefs=\currentsectiondefs
+    \let\prevsectiondefs=\lastsectiondefs
     \ifx\temptype\Ynothingkeyword
       \ifx\sectionlevel\seckeyword
-        
\gdef\currentsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
+        \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
                               \gdef\thissection{\thissectionname}}%
       \fi
     \else\ifx\temptype\Yomitfromtockeyword
@@ -6726,7 +6685,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
     \else\ifx\temptype\Yappendixkeyword
       \ifx\sectionlevel\seckeyword
         \toks0={#1}%
-        \xdef\currentsectiondefs{%
+        \xdef\lastsectiondefs{%
           \gdef\noexpand\thissectionname{\the\toks0}%
           \gdef\noexpand\thissectionnum{#4}%
           % \noexpand\putwordSection avoids expanding indigestible
@@ -6739,7 +6698,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
     \else
       \ifx\sectionlevel\seckeyword
         \toks0={#1}%
-        \xdef\currentsectiondefs{%
+        \xdef\lastsectiondefs{%
           \gdef\noexpand\thissectionname{\the\toks0}%
           \gdef\noexpand\thissectionnum{#4}%
           % \noexpand\putwordSection avoids expanding indigestible
@@ -6765,28 +6724,28 @@ might help (with 'rm \jobname.?? \jobname.??s')%
     %
     % Now the second mark, after the heading break.  No break points
     % between here and the heading.
-    \global\let\prevsectiondefs=\currentsectiondefs
+    \global\let\prevsectiondefs=\lastsectiondefs
     \domark
     %
     % Only insert the space after the number if we have a section number.
     \ifx\temptype\Ynothingkeyword
       \setbox0 = \hbox{}%
       \def\toctype{unn}%
-      \gdef\currentsection{#1}%
+      \gdef\lastsection{#1}%
     \else\ifx\temptype\Yomitfromtockeyword
       % for @headings -- no section number, don't include in toc,
-      % and don't redefine \currentsection.
+      % and don't redefine \lastsection.
       \setbox0 = \hbox{}%
       \def\toctype{omit}%
       \let\sectionlevel=\empty
     \else\ifx\temptype\Yappendixkeyword
       \setbox0 = \hbox{#4\enspace}%
       \def\toctype{app}%
-      \gdef\currentsection{#1}%
+      \gdef\lastsection{#1}%
     \else
       \setbox0 = \hbox{#4\enspace}%
       \def\toctype{num}%
-      \gdef\currentsection{#1}%
+      \gdef\lastsection{#1}%
     \fi\fi\fi
     %
     % Write the toc entry (before \donoderef).  See comments in \chapmacro.
@@ -6876,8 +6835,13 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   % 1 and 2 (the page numbers aren't printed), and so are the first
   % two pages of the document.  Thus, we'd have two destinations named
   % `1', and two named `2'.
-  \ifpdforxetex
+  \ifpdf
     \global\pdfmakepagedesttrue
+  \else
+    \ifx\XeTeXrevision\thisisundefined
+    \else
+      \global\pdfmakepagedesttrue
+    \fi
   \fi
 }
 
@@ -6914,7 +6878,9 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 %
 \def\startcontents#1{%
   % If @setchapternewpage on, and @headings double, the contents should
-  % start on an odd page, unlike chapters.
+  % start on an odd page, unlike chapters.  Thus, we maintain
+  % \contentsalignmacro in parallel with \pagealignmacro.
+  % From: Torbjorn Granlund <tege@matematik.su.se>
   \contentsalignmacro
   \immediate\closeout\tocfile
   %
@@ -6929,9 +6895,6 @@ might help (with 'rm \jobname.?? \jobname.??s')%
     %
     % Roman numerals for page numbers.
     \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
-    \def\thistitle{}% no title in double-sided headings
-    % Record where the Roman numerals started.
-    \ifnum\romancount=0 \global\romancount=\pagecount \fi
 }
 
 % redefined for the two-volume lispref.  We always output on
@@ -6954,7 +6917,8 @@ might help (with 'rm \jobname.?? \jobname.??s')%
     \fi
     \closein 1
   \endgroup
-  \contentsendroman
+  \lastnegativepageno = \pageno
+  \global\pageno = \savepageno
 }
 
 % And just the chapters.
@@ -6989,20 +6953,10 @@ might help (with 'rm \jobname.?? \jobname.??s')%
     \vfill \eject
     \contentsalignmacro % in case @setchapternewpage odd is in effect
   \endgroup
-  \contentsendroman
-}
-\let\shortcontents = \summarycontents
-
-% Get ready to use Arabic numerals again
-\def\contentsendroman{%
   \lastnegativepageno = \pageno
   \global\pageno = \savepageno
-  %
-  % If \romancount > \arabiccount, the contents are at the end of the
-  % document.  Otherwise, advance where the Arabic numerals start for
-  % the page numbers.
-  \ifnum\romancount>\arabiccount\else\global\arabiccount=\pagecount\fi
 }
+\let\shortcontents = \summarycontents
 
 % Typeset the label for a chapter or appendix for the short contents.
 % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
@@ -7250,7 +7204,11 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 
 % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
 % environment contents.
-
+\font\circle=lcircle10
+\newdimen\circthick
+\newdimen\cartouter\newdimen\cartinner
+\newskip\normbskip\newskip\normpskip\newskip\normlskip
+\circthick=\fontdimen8\circle
 %
 \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
 \def\ctr{{\hskip 6pt\circle\char'010}}
@@ -7265,18 +7223,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 %
 \newskip\lskip\newskip\rskip
 
-% only require the font if @cartouche is actually used
-\def\cartouchefontdefs{%
-  \font\circle=lcircle10\relax
-  \circthick=\fontdimen8\circle
-}
-\newdimen\circthick
-\newdimen\cartouter\newdimen\cartinner
-\newskip\normbskip\newskip\normpskip\newskip\normlskip
-
-
 \envdef\cartouche{%
-  \cartouchefontdefs
   \ifhmode\par\fi  % can't be in the midst of a paragraph.
   \startsavinginserts
   \lskip=\leftskip \rskip=\rightskip
@@ -7455,9 +7402,13 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 
 
 % @raggedright does more-or-less normal line breaking but no right
-% justification.  From plain.tex.
+% justification.  From plain.tex.  Don't stretch around special
+% characters in urls in this environment, since the stretch at the right
+% should be enough.
 \envdef\raggedright{%
   \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
+  \def\urefprestretchamount{0pt}%
+  \def\urefpoststretchamount{0pt}%
 }
 \let\Eraggedright\par
 
@@ -7516,7 +7467,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 
 % @indentedblock is like @quotation, but indents only on the left and
 % has no optional argument.
-%
+% 
 \makedispenvdef{indentedblock}{\indentedblockstart}
 %
 \def\indentedblockstart{%
@@ -7591,9 +7542,13 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
 %
 % We typeset each line of the verbatim in an \hbox, so we can handle
-% tabs.
+% tabs.  The \global is in case the verbatim line starts with an accent,
+% or some other command that starts with a begin-group.  Otherwise, the
+% entire \verbbox would disappear at the corresponding end-group, before
+% it is typeset.  Meanwhile, we can't have nested verbatim commands
+% (can we?), so the \global won't be overwriting itself.
 \newbox\verbbox
-\def\starttabbox{\setbox\verbbox=\hbox\bgroup}
+\def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
 %
 \begingroup
   \catcode`\^^I=\active
@@ -7604,8 +7559,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
       \divide\dimen\verbbox by\tabw
       \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
       \advance\dimen\verbbox by\tabw  % advance to next multiple of \tabw
-      \wd\verbbox=\dimen\verbbox
-      \leavevmode\box\verbbox \starttabbox
+      \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
     }%
   }
 \endgroup
@@ -7615,7 +7569,9 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   \let\nonarrowing = t%
   \nonfillstart
   \tt % easiest (and conventionally used) font for verbatim
-  \def\par{\egroup\leavevmode\box\verbbox\endgraf\starttabbox}%
+  % The \leavevmode here is for blank lines.  Otherwise, we would
+  % never \starttabox and the \egroup would end verbatim mode.
+  \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
   \tabexpand
   \setupmarkupstyle{verbatim}%
   % Respect line breaks,
@@ -7623,6 +7579,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   % make each space count.
   % Must do in this order:
   \obeylines \uncatcodespecials \sepspaces
+  \everypar{\starttabbox}%
 }
 
 % Do the @verb magic: verbatim text is quoted by unique
@@ -7657,16 +7614,13 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   % ignore everything up to the first ^^M, that's the newline at the end
   % of the @verbatim input line itself.  Otherwise we get an extra blank
   % line in the output.
-  \xdef\doverbatim#1^^M#2@end verbatim{%
-    \starttabbox#2\egroup\noexpand\end\gobble verbatim}%
+  \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
   % We really want {...\end verbatim} in the body of the macro, but
   % without the active space; thus we have to use \xdef and \gobble.
-  % The \egroup ends the \verbbox started at the end of the last line in
-  % the block.
 \endgroup
 %
 \envdef\verbatim{%
-    \setnormaldispenv\setupverbatim\doverbatim
+    \setupverbatim\doverbatim
 }
 \let\Everbatim = \afterenvbreak
 
@@ -7679,12 +7633,9 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   {%
     \makevalueexpandable
     \setupverbatim
-    {%
-      \indexnofonts       % Allow `@@' and other weird things in file names.
-      \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
-      \edef\tmp{\noexpand\input #1 }
-      \expandafter
-    }\expandafter\starttabbox\tmp\egroup
+    \indexnofonts       % Allow `@@' and other weird things in file names.
+    \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
+    \input #1
     \afterenvbreak
   }%
 }
@@ -7813,7 +7764,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 % @deftypefnnewline on|off says whether the return type of typed functions
 % are printed on their own line.  This affects @deftypefn, @deftypefun,
 % @deftypeop, and @deftypemethod.
-%
+% 
 \parseargdef\deftypefnnewline{%
   \def\temp{#1}%
   \ifx\temp\onword
@@ -7829,21 +7780,6 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   \fi\fi
 }
 
-% \dosubind {index}{topic}{subtopic}
-%
-% If SUBTOPIC is present, precede it with a space, and call \doind.
-% (At some time during the 20th century, this made a two-level entry in an
-% index such as the operation index.  Nobody seemed to notice the change in
-% behaviour though.)
-\def\dosubind#1#2#3{%
-  \def\thirdarg{#3}%
-  \ifx\thirdarg\empty
-    \doind{#1}{#2}%
-  \else
-    \doind{#1}{#2\space#3}%
-  \fi
-}
-
 % Untyped functions:
 
 % @deffn category name args
@@ -7858,6 +7794,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 % \deffngeneral {subind}category name args
 %
 \def\deffngeneral#1#2 #3 #4\endheader{%
+  % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
   \dosubind{fn}{\code{#3}}{#1}%
   \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
 }
@@ -8008,7 +7945,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
       \tclose{\temp}% typeset the return type
       \ifrettypeownline
         % put return type on its own line; prohibit line break following:
-        \hfil\vadjust{\nobreak}\break
+        \hfil\vadjust{\nobreak}\break  
       \else
         \space  % type on same line, so just followed by a space
       \fi
@@ -8064,7 +8001,6 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
   \gdef\magicamp{\let&=\amprm}
 }
-\let\ampchar\&
 
 \newcount\parencount
 
@@ -8145,18 +8081,36 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   }
 \fi
 
+% alias because \c means cedilla in @tex or @math
+\let\texinfoc=\c
+
+\newcount\savedcatcodeone
+\newcount\savedcatcodetwo
+
 % Used at the time of macro expansion.
 % Argument is macro body with arguments substituted
 \def\scanmacro#1{%
   \newlinechar`\^^M
   \def\xeatspaces{\eatspaces}%
   %
+  % Temporarily undo catcode changes of \printindex.  Set catcode of @ to
+  % 0 so that @-commands in macro expansions aren't printed literally when 
+  % formatting an index file, where \ is used as the escape character.
+  \savedcatcodeone=\catcode`\@
+  \savedcatcodetwo=\catcode`\\
+  \catcode`\@=0
+  \catcode`\\=\active
+  %
   % Process the macro body under the current catcode regime.
-  \scantokens{#1@comment}%
+  \scantokens{#1@texinfoc}%
+  %
+  \catcode`\@=\savedcatcodeone
+  \catcode`\\=\savedcatcodetwo
   %
-  % The \comment is to remove the \newlinechar added by \scantokens, and
-  % can be noticed by \parsearg.  Note \c isn't used because this means cedilla
-  % in math mode.
+  % The \texinfoc is to remove the \newlinechar added by \scantokens, and
+  % can be noticed by \parsearg.
+  %   We avoid surrounding the call to \scantokens with \bgroup and \egroup
+  % to allow macros to open or close groups themselves.
 }
 
 % Used for copying and captions
@@ -8257,14 +8211,12 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 \def\macroargctxt{%
   \scanctxt
   \catcode`\ =\active
-  \catcode`\@=\other
   \catcode`\^^M=\other
   \catcode`\\=\active
 }
 
 \def\macrolineargctxt{% used for whole-line arguments without braces
   \scanctxt
-  \catcode`\@=\other
   \catcode`\{=\other
   \catcode`\}=\other
 }
@@ -8356,7 +8308,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 % list to some hook where the argument is to be expanded.  If there are
 % less than 10 arguments that hook is to be replaced by ##N where N
 % is the position in that list, that is to say the macro arguments are to be
-% defined `a la TeX in the macro body.
+% defined `a la TeX in the macro body.  
 %
 % That gets used by \mbodybackslash (above).
 %
@@ -8387,8 +8339,8 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 %
 % Read recursive and nonrecursive macro bodies. (They're different since
 % rec and nonrec macros end differently.)
-%
-% We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro
+% 
+% We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro 
 % body to be transformed.
 % Set \macrobody to the body of the macro, and call \defmacro.
 %
@@ -8422,7 +8374,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 % twice the \macarg.BLAH macros does not cost too much processing power.
 \def\parsemmanyargdef@@#1,{%
   \if#1;\let\next=\relax
-  \else
+  \else 
     \let\next=\parsemmanyargdef@@
     \edef\tempb{\eatspaces{#1}}%
     \expandafter\def\expandafter\tempa
@@ -8507,7 +8459,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 
 % Replace arguments by their values in the macro body, and place the result
 % in macro \@tempa.
-%
+% 
 \def\macvalstoargs@{%
   %  To do this we use the property that token registers that are \the'ed
   % within an \edef  expand only once. So we are going to place all argument
@@ -8531,9 +8483,9 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
   }
 
-% Define the named-macro outside of this group and then close this group.
-%
-\def\macargexpandinbody@{%
+% Define the named-macro outside of this group and then close this group. 
+% 
+\def\macargexpandinbody@{% 
   \expandafter
   \endgroup
   \macargdeflist@
@@ -8571,7 +8523,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 }
 
 % Trailing missing arguments are set to empty.
-%
+% 
 \def\setemptyargvalues@{%
   \ifx\paramlist\nilm@
     \let\next\macargexpandinbody@
@@ -8648,7 +8600,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   \else % at most 9
     \ifnum\paramno<10\relax
       % @MACNAME sets the context for reading the macro argument
-      % @MACNAME@@ gets the argument, processes backslashes and appends a
+      % @MACNAME@@ gets the argument, processes backslashes and appends a 
       % comma.
       % @MACNAME@@@ removes braces surrounding the argument list.
       % @MACNAME@@@@ scans the macro body with arguments substituted.
@@ -8692,11 +8644,11 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 % Call #1 with a list of tokens #2, with any doubled backslashes in #2
 % compressed to one.
 %
-% This implementation works by expansion, and not execution (so we cannot use
-% \def or similar).  This reduces the risk of this failing in contexts where
-% complete expansion is done with no execution (for example, in writing out to
+% This implementation works by expansion, and not execution (so we cannot use 
+% \def or similar).  This reduces the risk of this failing in contexts where 
+% complete expansion is done with no execution (for example, in writing out to 
 % an auxiliary file for an index entry).
-%
+% 
 % State is kept in the input stream: the argument passed to
 % @look_ahead, @gobble_and_check_finish and @add_segment is
 %
@@ -8718,11 +8670,11 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 % #3 - NEXT_TOKEN
 % #4 used to look ahead
 %
-% If the next token is not a backslash, process the rest of the argument;
+% If the next token is not a backslash, process the rest of the argument; 
 % otherwise, remove the next token.
 @gdef@look_ahead#1!#2#3#4{%
   @ifx#4\%
-   @expandafter@gobble_and_check_finish
+   @expandafter@gobble_and_check_finish 
   @else
    @expandafter@add_segment
   @fi#1!{#2}#4#4%
@@ -8746,9 +8698,9 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 % #3 - NEXT_TOKEN
 % #4 is input stream until next backslash
 %
-% Input stream is either at the start of the argument, or just after a
-% backslash sequence, either a lone backslash, or a doubled backslash.
-% NEXT_TOKEN contains the first token in the input stream: if it is \finish,
+% Input stream is either at the start of the argument, or just after a 
+% backslash sequence, either a lone backslash, or a doubled backslash.  
+% NEXT_TOKEN contains the first token in the input stream: if it is \finish, 
 % finish; otherwise, append to ARG_RESULT the segment of the argument up until
 % the next backslash.  PENDING_BACKSLASH contains a backslash to represent
 % a backslash just before the start of the input stream that has not been
@@ -8760,13 +8712,13 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   % append the pending backslash to the result, followed by the next segment
   @expandafter@is_fi@look_ahead#1#2#4!{\}@fi
   % this @fi is discarded by @look_ahead.
-  % we can't get rid of it with \expandafter because we don't know how
+  % we can't get rid of it with \expandafter because we don't know how 
   % long #4 is.
 }
 
 % #1 - THE_MACRO
 % #2 - ARG_RESULT
-% #3 discards the res of the conditional in @add_segment, and @is_fi ends the
+% #3 discards the res of the conditional in @add_segment, and @is_fi ends the 
 % conditional.
 @gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}}
 
@@ -8778,7 +8730,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 % for reading the argument (slightly different in the two cases).  Then,
 % to read the argument, in the whole-line case, it then calls the regular
 % \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
-%
+% 
 \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
 \def\braceorlinexxx{%
   \ifx\nchar\bgroup
@@ -8828,29 +8780,9 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 % also remove a trailing comma, in case of something like this:
 % @node Help-Cross,  ,  , Cross-refs
 \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
-\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}\omittopnode}
-
-% Used so that the @top node doesn't have to be wrapped in an @ifnottex
-% conditional.
-% \doignore goes to more effort to skip nested conditionals but we don't need
-% that here.
-\def\omittopnode{%
-   \ifx\lastnode\wordTop
-   \expandafter\ignorenode\fi
-}
-\def\wordTop{Top}
-
-% Until the next @node or @bye command, divert output to a box that is not
-% output.
-\def\ignorenode{\setbox\dummybox\vbox\bgroup\def\node{\egroup\node}%
-\ignorenodebye
-}
-
-{\let\bye\relax
-\gdef\ignorenodebye{\let\bye\ignorenodebyedef}
-\gdef\ignorenodebyedef{\egroup(`Top' node ignored)\bye}}
-% The redefinition of \bye here is because it is declared \outer
+\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
 
+\let\nwnode=\node
 \let\lastnode=\empty
 
 % Write a cross-reference definition for the current node.  #1 is the
@@ -8873,7 +8805,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 
 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
 % anchor), which consists of three parts:
-% 1) NAME-title - the current sectioning name taken from \currentsection,
+% 1) NAME-title - the current sectioning name taken from \lastsection,
 %                 or the anchor name.
 % 2) NAME-snt   - section number and type, passed as the SNT arg, or
 %                 empty for anchors.
@@ -8895,7 +8827,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
        \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
          ##1}{##2}}% these are parameters of \writexrdef
       }%
-      \toks0 = \expandafter{\currentsection}%
+      \toks0 = \expandafter{\lastsection}%
       \immediate \writexrdef{title}{\the\toks0 }%
       \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
       \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
@@ -8907,7 +8839,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 % automatically in xrefs, if the third arg is not explicitly specified.
 % This was provided as a "secret" @set xref-automatic-section-title
 % variable, now it's official.
-%
+% 
 \parseargdef\xrefautomaticsectiontitle{%
   \def\temp{#1}%
   \ifx\temp\onword
@@ -8923,7 +8855,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   \fi\fi
 }
 
-%
+% 
 % @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
 % the node name, #2 the name of the Info cross-reference, #3 the printed
 % node name, #4 the name of the Info file, #5 the name of the printed
@@ -9076,34 +9008,40 @@ might help (with 'rm \jobname.?? \jobname.??s')%
     \fi
   \else
     % node/anchor (non-float) references.
-    %
+    % 
     % If we use \unhbox to print the node names, TeX does not insert
     % empty discretionaries after hyphens, which means that it will not
     % find a line break at a hyphen in a node names.  Since some manuals
     % are best written with fairly long node names, containing hyphens,
     % this is a loss.  Therefore, we give the text of the node name
     % again, so it is as if TeX is seeing it for the first time.
-    %
+    % 
     \ifdim \wd\printedmanualbox > 0pt
       % Cross-manual reference with a printed manual name.
-      %
+      % 
       \crossmanualxref{\cite{\printedmanual\unskip}}%
     %
     \else\ifdim \wd\infofilenamebox > 0pt
       % Cross-manual reference with only an info filename (arg 4), no
       % printed manual name (arg 5).  This is essentially the same as
       % the case above; we output the filename, since we have nothing else.
-      %
+      % 
       \crossmanualxref{\code{\infofilename\unskip}}%
     %
     \else
       % Reference within this manual.
       %
-      % Only output a following space if the -snt ref is nonempty; for
-      % @unnumbered and @anchor, it won't be.
-      \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
-      \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
-      %
+      % _ (for example) has to be the character _ for the purposes of the
+      % control sequence corresponding to the node, but it has to expand
+      % into the usual \leavevmode...\vrule stuff for purposes of
+      % printing. So we \turnoffactive for the \refx-snt, back on for the
+      % printing, back off for the \refx-pg.
+      {\turnoffactive
+       % Only output a following space if the -snt ref is nonempty; for
+       % @unnumbered and @anchor, it won't be.
+       \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
+       \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
+      }%
       % output the `[mynode]' via the macro below so it can be overridden.
       \xrefprintnodename\printedrefname
       %
@@ -9127,20 +9065,20 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 \endgroup}
 
 % Output a cross-manual xref to #1.  Used just above (twice).
-%
+% 
 % Only include the text "Section ``foo'' in" if the foo is neither
 % missing or Top.  Thus, @xref{,,,foo,The Foo Manual} outputs simply
 % "see The Foo Manual", the idea being to refer to the whole manual.
-%
+% 
 % But, this being TeX, we can't easily compare our node name against the
 % string "Top" while ignoring the possible spaces before and after in
 % the input.  By adding the arbitrary 7sp below, we make it much less
 % likely that a real node name would have the same width as "Top" (e.g.,
 % in a monospaced font).  Hopefully it will never happen in practice.
-%
+% 
 % For the same basic reason, we retypeset the "Top" at every
 % reference, since the current font is indeterminate.
-%
+% 
 \def\crossmanualxref#1{%
   \setbox\toprefbox = \hbox{Top\kern7sp}%
   \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
@@ -9187,13 +9125,13 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   \fi\fi\fi
 }
 
-% \refx{NAME}{SUFFIX} - reference a cross-reference string named NAME.  SUFFIX
+% \refx{NAME}{SUFFIX} - reference a cross-reference string named NAME.  SUFFIX 
 % is output afterwards if non-empty.
 \def\refx#1#2{%
   \requireauxfile
   {%
     \indexnofonts
-    \turnoffactive
+    \otherbackslash
     \def\value##1{##1}%
     \expandafter\global\expandafter\let\expandafter\thisrefX
       \csname XR#1\endcsname
@@ -9219,9 +9157,9 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   #2% Output the suffix in any case.
 }
 
-% This is the macro invoked by entries in the aux file.  Define a control
-% sequence for a cross-reference target (we prepend XR to the control sequence
-% name to avoid collisions).  The value is the page number.  If this is a float
+% This is the macro invoked by entries in the aux file.  Define a control 
+% sequence for a cross-reference target (we prepend XR to the control sequence 
+% name to avoid collisions).  The value is the page number.  If this is a 
float 
 % type, we have more work to do.
 %
 \def\xrdef#1#2{%
@@ -9237,10 +9175,10 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   \bgroup
     \expandafter\gdef\csname XR\safexrefname\endcsname{#2}%
   \egroup
-  % We put the \gdef inside a group to avoid the definitions building up on
-  % TeX's save stack, which can cause it to run out of space for aux files with
+  % We put the \gdef inside a group to avoid the definitions building up on 
+  % TeX's save stack, which can cause it to run out of space for aux files 
with 
   % thousands of lines.  \gdef doesn't use the save stack, but \csname does
-  % when it defines an unknown control sequence as \relax.
+  % when it defines an unknown control sequence as \relax. 
   %
   % Was that xref control sequence that we just defined for a float?
   \expandafter\iffloat\csname XR\safexrefname\endcsname
@@ -9319,6 +9257,19 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   \catcode`\^^]=\other
   \catcode`\^^^=\other
   \catcode`\^^_=\other
+  % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
+  % in xref tags, i.e., node names.  But since ^^e4 notation isn't
+  % supported in the main text, it doesn't seem desirable.  Furthermore,
+  % that is not enough: for node names that actually contain a ^
+  % character, we would end up writing a line like this: 'xrdef {'hat
+  % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
+  % argument, and \hat is not an expandable control sequence.  It could
+  % all be worked out, but why?  Either we support ^^ or we don't.
+  %
+  % The other change necessary for this was to define \auxhat:
+  % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
+  % and then to call \auxhat in \setq.
+  %
   \catcode`\^=\other
   %
   % Special characters.  Should be turned off anyway, but...
@@ -9336,7 +9287,14 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   \catcode`\%=\other
   \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
   %
-  \catcode`\\=\active
+  % This is to support \ in node names and titles, since the \
+  % characters end up in a \csname.  It's easier than
+  % leaving it active and making its active definition an actual \
+  % character.  What I don't understand is why it works in the *value*
+  % of the xrdef.  Seems like it should be a catcode12 \, and that
+  % should not typeset properly.  But it works, so I'm moving on for
+  % now.  --karl, 15jan04.
+  \catcode`\\=\other
   %
   % @ is our escape character in .aux files, and we need braces.
   \catcode`\{=1
@@ -9599,7 +9557,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
   %
   \ifimagevmode
     \medskip  % space after a standalone image
-  \fi
+  \fi  
   \ifx\centersub\centerV \egroup \fi
 \endgroup}
 
@@ -9667,13 +9625,13 @@ might help (with 'rm \jobname.?? \jobname.??s')%
       \global\advance\floatno by 1
       %
       {%
-        % This magic value for \currentsection is output by \setref as the
+        % This magic value for \lastsection is output by \setref as the
         % XREFLABEL-title value.  \xrefX uses it to distinguish float
         % labels (which have a completely different output format) from
         % node and anchor labels.  And \xrdef uses it to construct the
         % lists of floats.
         %
-        \edef\currentsection{\floatmagic=\safefloattype}%
+        \edef\lastsection{\floatmagic=\safefloattype}%
         \setref{\floatlabel}{Yfloat}%
       }%
     \fi
@@ -9796,7 +9754,7 @@ might help (with 'rm \jobname.?? \jobname.??s')%
 
 % #1 is the control sequence we are passed; we expand into a conditional
 % which is true if #1 represents a float ref.  That is, the magic
-% \currentsection value which we \setref above.
+% \lastsection value which we \setref above.
 %
 \def\iffloat#1{\expandafter\doiffloat#1==\finish}
 %
@@ -10430,7 +10388,7 @@ directory should work if nowhere else does.}
         \uppercase{.}
       \endgroup
     \else
-      \errhelp = \EMsimple
+      \errhelp = \EMsimple     
       \errmessage{Unicode character U+#1 not supported, sorry}%
     \fi
   \else
@@ -10463,7 +10421,7 @@ directory should work if nowhere else does.}
     \countUTFz = "#1\relax
     \begingroup
       \parseXMLCharref
-
+    
       % Give \u8:... its definition.  The sequence of seven \expandafter's
       % expands after the \gdef three times, e.g.
       %
@@ -10475,7 +10433,7 @@ directory should work if nowhere else does.}
       \expandafter\expandafter
       \expandafter\expandafter
       \expandafter\gdef       \UTFviiiTmp{#2}%
-      %
+      % 
       \expandafter\ifx\csname uni:#1\endcsname \relax \else
        \message{Internal error, already defined: #1}%
       \fi
@@ -10514,7 +10472,7 @@ directory should work if nowhere else does.}
     \divide\countUTFz by 64
     \countUTFy = \countUTFz  % Save to be the future value of \countUTFz.
     \multiply\countUTFz by 64
-
+    
     % \countUTFz is now \countUTFx with the last 5 bits cleared.  Subtract
     % in order to get the last five bits.
     \advance\countUTFx by -\countUTFz
@@ -10549,7 +10507,7 @@ directory should work if nowhere else does.}
 % U+0080..U+00FF = 
https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
 % U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
 % U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
-%
+% 
 % Many of our renditions are less than wonderful, and all the missing
 % characters are available somewhere.  Loading the necessary fonts
 % awaits user request.  We can't truly support Unicode without
@@ -10850,8 +10808,6 @@ directory should work if nowhere else does.}
   \DeclareUnicodeCharacter{0233}{\=y}%
   \DeclareUnicodeCharacter{0237}{\dotless{j}}%
   %
-  \DeclareUnicodeCharacter{02BC}{'}%
-  %
   \DeclareUnicodeCharacter{02DB}{\ogonek{ }}%
   %
   % Greek letters upper case
@@ -11286,14 +11242,21 @@ directory should work if nowhere else does.}
    \relax
 }
 
-% Define all Unicode characters we know about.  This makes UTF-8 the default
-% input encoding and allows @U to work.
+% define all Unicode characters we know about, for the sake of @U.
 \iftxinativeunicodecapable
   \nativeunicodechardefsatu
 \else
   \utfeightchardefs
 \fi
 
+
+% Make non-ASCII characters printable again for compatibility with
+% existing Texinfo documents that may use them, even without declaring a
+% document encoding.
+%
+\setnonasciicharscatcode \other
+
+
 \message{formatting,}
 
 \newdimen\defaultparindent \defaultparindent = 15pt
@@ -11486,18 +11449,6 @@ directory should work if nowhere else does.}
   \globaldefs = 0
 }}
 
-\def\bsixpaper{{\globaldefs = 1
-  \afourpaper
-  \internalpagesizes{140mm}{100mm}%
-                    {-6.35mm}{-12.7mm}%
-                    {\bindingoffset}{14pt}%
-                    {176mm}{125mm}%
-  \let\SETdispenvsize=\smallword
-  \lispnarrowing = 0.2in
-  \globaldefs = 0
-}}
-
-
 % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
 % Perhaps we should allow setting the margins, \topskip, \parskip,
 % and/or leading, also. Or perhaps we should compute them somehow.
@@ -11511,12 +11462,12 @@ directory should work if nowhere else does.}
   \setleading{\textleading}%
   %
   \dimen0 = #1\relax
-  \advance\dimen0 by 2.5in % default 1in margin above heading line
-                           % and 1.5in to include heading, footing and
-                           % bottom margin
+  \advance\dimen0 by \voffset
+  \advance\dimen0 by 1in % reference point for DVI is 1 inch from top of page
   %
   \dimen2 = \hsize
-  \advance\dimen2 by 2in % default to 1 inch margin on each side
+  \advance\dimen2 by \normaloffset
+  \advance\dimen2 by 1in % reference point is 1 inch from left edge of page
   %
   \internalpagesizes{#1}{\hsize}%
                     {\voffset}{\normaloffset}%
@@ -11601,9 +11552,9 @@ directory should work if nowhere else does.}
 \def\texinfochars{%
   \let< = \activeless
   \let> = \activegtr
-  \let~ = \activetilde
+  \let~ = \activetilde 
   \let^ = \activehat
-  \markupsetuplqdefault \markupsetuprqdefault
+  \markupsetuplqdefault \markupsetuprqdefault 
   \let\b = \strong
   \let\i = \smartitalic
   % in principle, all other definitions in \tex have to be undone too.
@@ -11621,9 +11572,11 @@ directory should work if nowhere else does.}
 % \backslashcurfont outputs one backslash character in current font,
 % as in \char`\\.
 \global\chardef\backslashcurfont=`\\
+\global\let\rawbackslashxx=\backslashcurfont  % let existing .??s files work
 
-% \realbackslash is an actual character `\' with catcode other.
-{\catcode`\\=\other @gdef@realbackslash{\}}
+% \realbackslash is an actual character `\' with catcode other, and
+% \doublebackslash is two of them (for the pdf outlines).
+{\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
 
 % In Texinfo, backslash is an active character; it prints the backslash
 % in fixed width font.
@@ -11641,8 +11594,10 @@ directory should work if nowhere else does.}
 @def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
 @let@backslashchar = @ttbackslash % @backslashchar{} is for user documents.
 
+% \rawbackslash defines an active \ to do \backslashcurfont.
 % \otherbackslash defines an active \ to be a literal `\' character with
-% catcode other.
+% catcode other.  We switch back and forth between these.
+@gdef@rawbackslash{@let\=@backslashcurfont}
 @gdef@otherbackslash{@let\=@realbackslash}
 
 % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
@@ -11714,7 +11669,7 @@ directory should work if nowhere else does.}
   @ifx\@eatinput @let\ = @ttbackslash @fi
   @catcode13=5 % regular end of line
   @enableemergencynewline
-  @let@c=@comment
+  @let@c=@texinfoc
   @let@parsearg@originalparsearg
   % Also turn back on active characters that might appear in the input
   % file name, in case not using a pre-dumped format.
@@ -11760,7 +11715,7 @@ directory should work if nowhere else does.}
 @markupsetuprqdefault
 
 @c Local variables:
-@c eval: (add-hook 'before-save-hook 'time-stamp)
+@c eval: (add-hook 'write-file-hooks 'time-stamp)
 @c page-delimiter: "^\\\\message\\|emacs-page"
 @c time-stamp-start: "def\\\\texinfoversion{"
 @c time-stamp-format: "%:y-%02m-%02d.%02H"
diff --git a/src/stasis/Makefile.am b/src/stasis/Makefile.am
index 140f65e..d1a0b39 100644
--- a/src/stasis/Makefile.am
+++ b/src/stasis/Makefile.am
@@ -16,9 +16,9 @@ endif
 sqldir = $(prefix)/share/anastasis/sql/
 
 sql_DATA = \
-  stasis-0000.sql \
+  versioning.sql \
   stasis-0001.sql \
-  drop0001.sql
+  drop.sql
 
 pkgcfgdir = $(prefix)/share/anastasis/config.d/
 
diff --git a/src/stasis/drop0001.sql b/src/stasis/drop.sql
similarity index 100%
rename from src/stasis/drop0001.sql
rename to src/stasis/drop.sql
diff --git a/src/stasis/plugin_anastasis_postgres.c 
b/src/stasis/plugin_anastasis_postgres.c
index 3b1136d..7ba6b73 100644
--- a/src/stasis/plugin_anastasis_postgres.c
+++ b/src/stasis/plugin_anastasis_postgres.c
@@ -83,16 +83,19 @@ postgres_drop_tables (void *cls)
 {
   struct PostgresClosure *pg = cls;
   struct GNUNET_PQ_Context *conn;
+  enum GNUNET_GenericReturnValue ret;
 
   conn = GNUNET_PQ_connect_with_cfg (pg->cfg,
                                      "stasis-postgres",
-                                     "drop",
+                                     NULL,
                                      NULL,
                                      NULL);
   if (NULL == conn)
     return GNUNET_SYSERR;
+  ret = GNUNET_PQ_exec_sql (conn,
+                            "drop");
   GNUNET_PQ_disconnect (conn);
-  return GNUNET_OK;
+  return ret;
 }
 
 
diff --git a/src/stasis/stasis-0000.sql b/src/stasis/stasis-0000.sql
deleted file mode 100644
index 116f409..0000000
--- a/src/stasis/stasis-0000.sql
+++ /dev/null
@@ -1,293 +0,0 @@
--- LICENSE AND COPYRIGHT
---
--- Copyright (C) 2010 Hubert depesz Lubaczewski
---
--- This program is distributed under the (Revised) BSD License:
--- L<http://www.opensource.org/licenses/bsd-license.php>
---
--- Redistribution and use in source and binary forms, with or without
--- modification, are permitted provided that the following conditions
--- are met:
---
--- * Redistributions of source code must retain the above copyright
--- notice, this list of conditions and the following disclaimer.
---
--- * Redistributions in binary form must reproduce the above copyright
---   notice, this list of conditions and the following disclaimer in the
---   documentation and/or other materials provided with the distribution.
---
--- * Neither the name of Hubert depesz Lubaczewski's Organization
---   nor the names of its contributors may be used to endorse or
---   promote products derived from this software without specific
---   prior written permission.
---
--- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
--- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
--- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
ARE
--- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
--- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
--- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
--- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
--- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
LIABILITY,
--- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
USE
--- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---
--- Code origin: 
https://gitlab.com/depesz/Versioning/blob/master/install.versioning.sql
---
---
--- # NAME
---
--- **Versioning** - simplistic take on tracking and applying changes to 
databases.
---
--- # DESCRIPTION
---
--- This project strives to provide simple way to manage changes to
--- database.
---
--- Instead of making changes on development server, then finding
--- differences between production and development, deciding which ones
--- should be installed on production, and finding a way to install them -
--- you start with writing diffs themselves!
---
--- # INSTALLATION
---
--- To install versioning simply run install.versioning.sql in your database
--- (all of them: production, stage, test, devel, ...).
---
--- # USAGE
---
--- In your files with patches to database, put whole logic in single
--- transaction, and use \_v.\* functions - usually \_v.register_patch() at
--- least to make sure everything is OK.
---
--- For example. Let's assume you have patch files:
---
--- ## 0001.sql:
---
--- ```
--- create table users (id serial primary key, username text);
--- ```
---
--- ## 0002.sql:
---
--- ```
--- insert into users (username) values ('depesz');
--- ```
--- To change it to use versioning you would change the files, to this
--- state:
---
--- 0000.sql:
---
--- ```
--- BEGIN;
--- select _v.register_patch('000-base', NULL, NULL);
--- create table users (id serial primary key, username text);
--- COMMIT;
--- ```
---
--- ## 0002.sql:
---
--- ```
--- BEGIN;
--- select _v.register_patch('001-users', ARRAY['000-base'], NULL);
--- insert into users (username) values ('depesz');
--- COMMIT;
--- ```
---
--- This will make sure that patch 001-users can only be applied after
--- 000-base.
---
--- # AVAILABLE FUNCTIONS
---
--- ## \_v.register_patch( TEXT )
---
--- Registers named patch, or dies if it is already registered.
---
--- Returns integer which is id of patch in \_v.patches table - only if it
--- succeeded.
---
--- ## \_v.register_patch( TEXT, TEXT[] )
---
--- Same as \_v.register_patch( TEXT ), but checks is all given patches (given 
as
--- array in second argument) are already registered.
---
--- ## \_v.register_patch( TEXT, TEXT[], TEXT[] )
---
--- Same as \_v.register_patch( TEXT, TEXT[] ), but also checks if there are no 
conflicts with preexisting patches.
---
--- Third argument is array of names of patches that conflict with current one. 
So
--- if any of them is installed - register_patch will error out.
---
--- ## \_v.unregister_patch( TEXT )
---
--- Removes information about given patch from the versioning data.
---
--- It doesn't remove objects that were created by this patch - just removes
--- metainformation.
---
--- ## \_v.assert_user_is_superuser()
---
--- Make sure that current patch is being loaded by superuser.
---
--- If it's not - it will raise exception, and break transaction.
---
--- ## \_v.assert_user_is_not_superuser()
---
--- Make sure that current patch is not being loaded by superuser.
---
--- If it is - it will raise exception, and break transaction.
---
--- ## \_v.assert_user_is_one_of(TEXT, TEXT, ... )
---
--- Make sure that current patch is being loaded by one of listed users.
---
--- If ```current_user``` is not listed as one of arguments - function will 
raise
--- exception and break the transaction.
-
-BEGIN;
-
--- This file adds versioning support to database it will be loaded to.
--- It requires that PL/pgSQL is already loaded - will raise exception 
otherwise.
--- All versioning "stuff" (tables, functions) is in "_v" schema.
-
--- All functions are defined as 'RETURNS SETOF INT4' to be able to make them 
to RETURN literally nothing (0 rows).
--- >> RETURNS VOID<< IS similar, but it still outputs "empty line" in psql 
when calling.
-CREATE SCHEMA IF NOT EXISTS _v;
-COMMENT ON SCHEMA _v IS 'Schema for versioning data and functionality.';
-
-CREATE TABLE IF NOT EXISTS _v.patches (
-    patch_name  TEXT        PRIMARY KEY,
-    applied_tsz TIMESTAMPTZ NOT NULL DEFAULT now(),
-    applied_by  TEXT        NOT NULL,
-    requires    TEXT[],
-    conflicts   TEXT[]
-);
-COMMENT ON TABLE _v.patches              IS 'Contains information about what 
patches are currently applied on database.';
-COMMENT ON COLUMN _v.patches.patch_name  IS 'Name of patch, has to be unique 
for every patch.';
-COMMENT ON COLUMN _v.patches.applied_tsz IS 'When the patch was applied.';
-COMMENT ON COLUMN _v.patches.applied_by  IS 'Who applied this patch 
(PostgreSQL username)';
-COMMENT ON COLUMN _v.patches.requires    IS 'List of patches that are required 
for given patch.';
-COMMENT ON COLUMN _v.patches.conflicts   IS 'List of patches that conflict 
with given patch.';
-
-CREATE OR REPLACE FUNCTION _v.register_patch( IN in_patch_name TEXT, IN 
in_requirements TEXT[], in_conflicts TEXT[], OUT versioning INT4 ) RETURNS 
setof INT4 AS $$
-DECLARE
-    t_text   TEXT;
-    t_text_a TEXT[];
-    i INT4;
-BEGIN
-    -- Thanks to this we know only one patch will be applied at a time
-    LOCK TABLE _v.patches IN EXCLUSIVE MODE;
-
-    SELECT patch_name INTO t_text FROM _v.patches WHERE patch_name = 
in_patch_name;
-    IF FOUND THEN
-        RAISE EXCEPTION 'Patch % is already applied!', in_patch_name;
-    END IF;
-
-    t_text_a := ARRAY( SELECT patch_name FROM _v.patches WHERE patch_name = 
any( in_conflicts ) );
-    IF array_upper( t_text_a, 1 ) IS NOT NULL THEN
-        RAISE EXCEPTION 'Versioning patches conflict. Conflicting patche(s) 
installed: %.', array_to_string( t_text_a, ', ' );
-    END IF;
-
-    IF array_upper( in_requirements, 1 ) IS NOT NULL THEN
-        t_text_a := '{}';
-        FOR i IN array_lower( in_requirements, 1 ) .. array_upper( 
in_requirements, 1 ) LOOP
-            SELECT patch_name INTO t_text FROM _v.patches WHERE patch_name = 
in_requirements[i];
-            IF NOT FOUND THEN
-                t_text_a := t_text_a || in_requirements[i];
-            END IF;
-        END LOOP;
-        IF array_upper( t_text_a, 1 ) IS NOT NULL THEN
-            RAISE EXCEPTION 'Missing prerequisite(s): %.', array_to_string( 
t_text_a, ', ' );
-        END IF;
-    END IF;
-
-    INSERT INTO _v.patches (patch_name, applied_tsz, applied_by, requires, 
conflicts ) VALUES ( in_patch_name, now(), current_user, coalesce( 
in_requirements, '{}' ), coalesce( in_conflicts, '{}' ) );
-    RETURN;
-END;
-$$ language plpgsql;
-COMMENT ON FUNCTION _v.register_patch( TEXT, TEXT[], TEXT[] ) IS 'Function to 
register patches in database. Raises exception if there are conflicts, 
prerequisites are not installed or the migration has already been installed.';
-
-CREATE OR REPLACE FUNCTION _v.register_patch( TEXT, TEXT[] ) RETURNS setof 
INT4 AS $$
-    SELECT _v.register_patch( $1, $2, NULL );
-$$ language sql;
-COMMENT ON FUNCTION _v.register_patch( TEXT, TEXT[] ) IS 'Wrapper to allow 
registration of patches without conflicts.';
-CREATE OR REPLACE FUNCTION _v.register_patch( TEXT ) RETURNS setof INT4 AS $$
-    SELECT _v.register_patch( $1, NULL, NULL );
-$$ language sql;
-COMMENT ON FUNCTION _v.register_patch( TEXT ) IS 'Wrapper to allow 
registration of patches without requirements and conflicts.';
-
-CREATE OR REPLACE FUNCTION _v.unregister_patch( IN in_patch_name TEXT, OUT 
versioning INT4 ) RETURNS setof INT4 AS $$
-DECLARE
-    i        INT4;
-    t_text_a TEXT[];
-BEGIN
-    -- Thanks to this we know only one patch will be applied at a time
-    LOCK TABLE _v.patches IN EXCLUSIVE MODE;
-
-    t_text_a := ARRAY( SELECT patch_name FROM _v.patches WHERE in_patch_name = 
ANY( requires ) );
-    IF array_upper( t_text_a, 1 ) IS NOT NULL THEN
-        RAISE EXCEPTION 'Cannot uninstall %, as it is required by: %.', 
in_patch_name, array_to_string( t_text_a, ', ' );
-    END IF;
-
-    DELETE FROM _v.patches WHERE patch_name = in_patch_name;
-    GET DIAGNOSTICS i = ROW_COUNT;
-    IF i < 1 THEN
-        RAISE EXCEPTION 'Patch % is not installed, so it can''t be 
uninstalled!', in_patch_name;
-    END IF;
-
-    RETURN;
-END;
-$$ language plpgsql;
-COMMENT ON FUNCTION _v.unregister_patch( TEXT ) IS 'Function to unregister 
patches in database. Dies if the patch is not registered, or if unregistering 
it would break dependencies.';
-
-CREATE OR REPLACE FUNCTION _v.assert_patch_is_applied( IN in_patch_name TEXT ) 
RETURNS TEXT as $$
-DECLARE
-    t_text TEXT;
-BEGIN
-    SELECT patch_name INTO t_text FROM _v.patches WHERE patch_name = 
in_patch_name;
-    IF NOT FOUND THEN
-        RAISE EXCEPTION 'Patch % is not applied!', in_patch_name;
-    END IF;
-    RETURN format('Patch %s is applied.', in_patch_name);
-END;
-$$ language plpgsql;
-COMMENT ON FUNCTION _v.assert_patch_is_applied( TEXT ) IS 'Function that can 
be used to make sure that patch has been applied.';
-
-CREATE OR REPLACE FUNCTION _v.assert_user_is_superuser() RETURNS TEXT as $$
-DECLARE
-    v_super bool;
-BEGIN
-    SELECT usesuper INTO v_super FROM pg_user WHERE usename = current_user;
-    IF v_super THEN
-        RETURN 'assert_user_is_superuser: OK';
-    END IF;
-    RAISE EXCEPTION 'Current user is not superuser - cannot continue.';
-END;
-$$ language plpgsql;
-COMMENT ON FUNCTION _v.assert_user_is_superuser() IS 'Function that can be 
used to make sure that patch is being applied using superuser account.';
-
-CREATE OR REPLACE FUNCTION _v.assert_user_is_not_superuser() RETURNS TEXT as $$
-DECLARE
-    v_super bool;
-BEGIN
-    SELECT usesuper INTO v_super FROM pg_user WHERE usename = current_user;
-    IF v_super THEN
-        RAISE EXCEPTION 'Current user is superuser - cannot continue.';
-    END IF;
-    RETURN 'assert_user_is_not_superuser: OK';
-END;
-$$ language plpgsql;
-COMMENT ON FUNCTION _v.assert_user_is_not_superuser() IS 'Function that can be 
used to make sure that patch is being applied using normal (not superuser) 
account.';
-
-CREATE OR REPLACE FUNCTION _v.assert_user_is_one_of(VARIADIC 
p_acceptable_users TEXT[] ) RETURNS TEXT as $$
-DECLARE
-BEGIN
-    IF current_user = any( p_acceptable_users ) THEN
-        RETURN 'assert_user_is_one_of: OK';
-    END IF;
-    RAISE EXCEPTION 'User is not one of: % - cannot continue.', 
p_acceptable_users;
-END;
-$$ language plpgsql;
-COMMENT ON FUNCTION _v.assert_user_is_one_of(TEXT[]) IS 'Function that can be 
used to make sure that patch is being applied by one of defined users.';
-
-COMMIT;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]