texinfo-commits
[Top][All Lists]
Advanced

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

[6905] sync


From: karl
Subject: [6905] sync
Date: Fri, 01 Jan 2016 18:33:27 +0000

Revision: 6905
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6905
Author:   karl
Date:     2016-01-01 18:33:25 +0000 (Fri, 01 Jan 2016)
Log Message:
-----------
sync

Modified Paths:
--------------
    trunk/build-aux/texinfo.tex
    trunk/makeinfo/README
    trunk/tp/Texinfo/Convert/Converter.pm
    trunk/util/dir-example

Property Changed:
----------------
    trunk/makeinfo/README
    trunk/tp/Texinfo/Convert/Converter.pm

Modified: trunk/build-aux/texinfo.tex
===================================================================
--- trunk/build-aux/texinfo.tex 2016-01-01 16:24:35 UTC (rev 6904)
+++ trunk/build-aux/texinfo.tex 2016-01-01 18:33:25 UTC (rev 6905)
@@ -3,7 +3,7 @@
 % Load plain if necessary, i.e., if running under initex.
 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
 %
-\def\texinfoversion{2015-07-01.07}
+\def\texinfoversion{2015-12-20.12}
 %
 % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
@@ -158,22 +158,10 @@
 \ifx\putwordDefopt\undefined    \gdef\putwordDefopt{User Option}\fi
 \ifx\putwordDeffunc\undefined   \gdef\putwordDeffunc{Function}\fi
 
-% Since the category of space is not known, we have to be careful.
-\chardef\spacecat = 10
-\def\spaceisspace{\catcode`\ =\spacecat}
+% Give the space character the catcode for a space.
+\def\spaceisspace{\catcode`\ =10\relax}
 
-% sometimes characters are active, so we need control sequences.
-\chardef\ampChar   = `\&
-\chardef\colonChar = `\:
-\chardef\commaChar = `\,
 \chardef\dashChar  = `\-
-\chardef\dotChar   = `\.
-\chardef\exclamChar= `\!
-\chardef\hashChar  = `\#
-\chardef\lquoteChar= `\`
-\chardef\questChar = `\?
-\chardef\rquoteChar= `\'
-\chardef\semiChar  = `\;
 \chardef\slashChar = `\/
 \chardef\underChar = `\_
 
@@ -196,17 +184,6 @@
   wide-spread wrap-around
 }
 
-% Margin to add to right of even pages, to left of odd pages.
-\newdimen\bindingoffset
-\newdimen\normaloffset
-\newdimen\pagewidth \newdimen\pageheight
-
-% For a final copy, take out the rectangles
-% that mark overfull boxes (in case you have decided
-% that the text looks ok even though it passes the margin).
-%
-\def\finalout{\overfullrule=0pt }
-
 % Sometimes it is convenient to have everything in the transcript file
 % and nothing on the terminal.  We don't just call \tracingall here,
 % since that produces some useless output on the terminal.  We also make
@@ -251,6 +228,15 @@
 \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
   \removelastskip\penalty-200\bigskip\fi\fi}
 
+% Output routine
+%
+
+% For a final copy, take out the rectangles
+% that mark overfull boxes (in case you have decided
+% that the text looks ok even though it passes the margin).
+%
+\def\finalout{\overfullrule=0pt }
+
 % Do @cropmarks to get crop marks.
 %
 \newif\ifcropmarks
@@ -273,11 +259,18 @@
 %
 % Another complication is to let the user choose whether \thischapter
 % (\thissection) refers to the chapter (section) in effect at the top
-% of a page, or that at the bottom of a page.  The solution is
-% described on page 260 of The TeXbook.  It involves outputting two
-% marks for the sectioning macros, one before the section break, and
-% one after.  I won't pretend I can describe this better than DEK...
+% of a page, or that at the bottom of a page.
+
+% \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 \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.
+%   @everyheadingmarks bottom uses \botmark.
 %
+% See page 260 of The TeXbook.
 \def\domark{%
   \toks0=\expandafter{\lastchapterdefs}%
   \toks2=\expandafter{\lastsectiondefs}%
@@ -285,11 +278,15 @@
   \toks6=\expandafter{\prevsectiondefs}%
   \toks8=\expandafter{\lastcolordefs}%
   \mark{%
-                   \the\toks0 \the\toks2  % 0: top marks (\last...)
-      \noexpand\or \the\toks4 \the\toks6  % 1: bottom marks (default, \prev...)
+                   \the\toks0 \the\toks2  % 0: marks for @everyheadingmarks top
+      \noexpand\or \the\toks4 \the\toks6  % 1: for @everyheadingmarks bottom
     \noexpand\else \the\toks8             % 2: color marks
   }%
 }
+
+% \gettopheadingmarks, \getbottomheadingmarks,
+% \getcolormarks - extract needed part of mark.
+%
 % \topmark doesn't work for the very first chapter (after the title
 % page or the contents), so we use \firstmark there -- this gets us
 % the mark with the chapter defs, unless the user sneaks in, e.g.,
@@ -310,32 +307,62 @@
 \def\prevsectiondefs{}
 \def\lastcolordefs{}
 
+% Margin to add to right of even pages, to left of odd pages.
+\newdimen\bindingoffset
+\newdimen\normaloffset
+\newdimen\pagewidth \newdimen\pageheight
+
 % Main output routine.
+%
 \chardef\PAGE = 255
 \output = {\onepageout{\pagecontents\PAGE}}
 
 \newbox\headlinebox
 \newbox\footlinebox
 
-% \onepageout takes a vbox as an argument.  Note that \pagecontents
-% does insertions, but you have to call it yourself.
+% \onepageout takes a vbox as an argument.
+% \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{%
   \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
   %
   \ifodd\pageno  \advance\hoffset by \bindingoffset
   \else \advance\hoffset by -\bindingoffset\fi
   %
+  % 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=\pagewidth \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.
+  %
+  % 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
+  \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
+  %
+  \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}%
-  %
-  \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
   \global\setbox\footlinebox = \vbox{\commmonheadfootline \makefootline}%
   %
   {%
+    % Set context for writing to auxiliary files like index files.
     % Have to do this stuff outside the \shipout because we want it to
     % take effect in \write's, yet the group defined by the \vbox ends
     % before the \shipout runs.
@@ -344,10 +371,10 @@
     \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{{\tt \indexbackslash }acronym}{32}{\code {\acronym}}
+               % \entry{{\indexbackslash }acronym}{32}{\code {\acronym}}
                % "\acronym" won't work when it's read back in;
                % it needs to be
-               % {\code {{\tt \backslashcurfont }acronym}
+               % {\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
@@ -405,6 +432,7 @@
 
 \newinsert\margin \dimen\margin=\maxdimen
 
+% Main part of page, including any footnotes
 \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
 {\catcode`\@ =11
 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
@@ -427,9 +455,13 @@
 \def\nsbot{\vbox
   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
 
+
+% Argument parsing
+
 % Parse an argument, then pass it to #1.  The argument is the rest of
 % the input line (except we remove a trailing comment).  #1 should be a
 % macro which expects an ordinary undelimited TeX argument.
+% For example, \def\foo{\parsearg\fooxxx}.
 %
 \def\parsearg{\parseargusing{}}
 \def\parseargusing#1#2{%
@@ -448,9 +480,11 @@
   }%
 }
 
-% First remove any @comment, then any @c comment.
+% 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.
 %
@@ -485,14 +519,13 @@
 %
 \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
 
+
+% \parseargdef - define a command taking an argument on the line
+%
 % \parseargdef\foo{...}
 %      is roughly equivalent to
 % \def\foo{\parsearg\Xfoo}
 % \def\Xfoo#1{...}
-%
-% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
-% favourite TeX trick.  --kasal, 16nov03
-
 \def\parseargdef#1{%
   \expandafter \doparseargdef \csname\string#1\endcsname #1%
 }
@@ -682,6 +715,12 @@
     \endgraf % Not \par, as it may have been set to \lisppar.
     \global\dimen1 = \prevdepth
   \egroup           % End the \vtop.
+  \addgroupbox
+  \prevdepth = \dimen1
+  \checkinserts
+}
+
+\def\addgroupbox{
   % \dimen0 is the vertical size of the group's box.
   \dimen0 = \ht\groupbox  \advance\dimen0 by \dp\groupbox
   % \dimen2 is how much space is left on the page (more or less).
@@ -694,9 +733,8 @@
     \fi
   \fi
   \box\groupbox
-  \prevdepth = \dimen1
-  \checkinserts
 }
+
 %
 % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
 % message, so this ends up printing address@hidden can only ...'.
@@ -939,12 +977,20 @@
 % @c is the same as @comment
 % @ignore ... @end ignore  is another way to write a comment
 %
-\def\comment{\begingroup \catcode`\^^M=\other%
+\def\comment{\begingroup \catcode`\^^M=\active%
address@hidden \catcode`\{=\other \catcode`\}=\other\commentxxx}%
+
+{\catcode`\^^M=\active%
+\gdef\commentxxx#1^^M{\endgroup%
+\futurelet\nexttoken\commentxxxx}%
+\gdef\commentxxxx{\ifx\nexttoken\aftermacro\expandafter\comment\fi}%
+}
+
+\def\c{\begingroup \catcode`\^^M=\active%
 address@hidden \catcode`\{=\other \catcode`\}=\other%
-\commentxxx}
-{\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
-%
-\let\c=\comment
+\cxxx}
+{\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}}
+% See comment in \scanmacro about why the definitions of @c and @comment differ
 
 % @paragraphindent NCHARS
 % We'll use ems for NCHARS, close enough.
@@ -1030,46 +1076,9 @@
 % @refill is a no-op.
 \let\refill=\relax
 
-% If working on a large document in chapters, it is convenient to
-% be able to disable indexing, cross-referencing, and contents, for test runs.
-% This is done with @novalidate (before @setfilename).
-%
-\newif\iflinks \linkstrue % by default we want the aux files.
-\let\novalidate = \linksfalse
+% @setfilename INFO-FILENAME - ignored
+\let\setfilename=\comment
 
-% @setfilename is done at the beginning of every texinfo file.
-% So open here the files we need to have open while reading the input.
-% This makes it possible to make a .fmt file for texinfo.
-\def\setfilename{%
-   \fixbackslash  % Turn off hack to swallow `\input texinfo'.
-   \iflinks
-     \tryauxfile
-     % Open the new aux file.  TeX will close it automatically at exit.
-     \immediate\openout\auxfile=\jobname.aux
-   \fi % \openindices needs to do some work in any case.
-   \openindices
-   \let\setfilename=\comment % Ignore extra @setfilename cmds.
-   %
-   % If texinfo.cnf is present on the system, read it.
-   % Useful for site-wide @afourpaper, etc.
-   \openin 1 texinfo.cnf
-   \ifeof 1 \else \input texinfo.cnf \fi
-   \closein 1
-   %
-   \comment % Ignore the actual filename.
-}
-
-% Called from \setfilename.
-%
-\def\openindices{%
-  \newindex{cp}%
-  \newcodeindex{fn}%
-  \newcodeindex{vr}%
-  \newcodeindex{tp}%
-  \newcodeindex{ky}%
-  \newcodeindex{pg}%
-}
-
 % @bye.
 \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
 
@@ -1086,6 +1095,7 @@
 \newtoks\toksC
 \newtoks\toksD
 \newbox\boxA
+\newbox\boxB
 \newcount\countA
 \newif\ifpdf
 \newif\ifpdfmakepagedest
@@ -1143,8 +1153,8 @@
   \def\rgbDarkRed{0.50 0.09 0.12}
   \def\rgbBlack{0 0 0}
   %
-  % k sets the color for filling (usual text, etc.);
-  % K sets the color for stroking (thin rules, e.g., normal _'s).
+  % rg sets the color for filling (usual text, etc.);
+  % RG sets the color for stroking (thin rules, e.g., normal _'s).
   \def\pdfsetcolor#1{\pdfliteral{#1 rg  #1 RG}}
   %
   % Set color, and create a mark which defines \thiscolor accordingly,
@@ -1822,8 +1832,10 @@
 % 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}{OT1TT}
 \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
-\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
+\def\df{\let\tentt=\deftt \let\tenbf = \defbf
+\let\tenttsl=\defttsl \let\tensl=\defsl \bf}
 
 % Fonts for indices, footnotes, small examples (9pt).
 \def\smallnominalsize{9pt}
@@ -1884,6 +1896,7 @@
 % Section fonts (14.4pt).
 \def\secnominalsize{14pt}
 \setfont\secrm\rmbshape{12}{\magstep1}{OT1}
+\setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1}
 \setfont\secit\itbshape{10}{\magstep2}{OT1IT}
 \setfont\secsl\slbshape{10}{\magstep2}{OT1}
 \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
@@ -1953,8 +1966,10 @@
 % 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}{OT1TT}
 \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
-\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
+\def\df{\let\tentt=\deftt \let\tenbf = \defbf
+\let\tensl=\defsl \let\tenttsl=\defttsl \bf}
 
 % Fonts for indices, footnotes, small examples (9pt).
 \def\smallnominalsize{9pt}
@@ -2425,8 +2440,8 @@
 %
 address@hidden
   \def\plainfrenchspacing{%
-    \sfcode\dotChar  address@hidden address@hidden address@hidden
-    address@hidden \sfcode\semiChar address@hidden \sfcode\commaChar 
address@hidden
+    address@hidden address@hidden address@hidden
+    \sfcode`\:address@hidden \sfcode`\;address@hidden \sfcode`\,address@hidden
     \def\endofsentencespacefactor{1000}% for @. and friends
   }
   \def\plainnonfrenchspacing{%
@@ -2614,9 +2629,9 @@
 
 % Allow line breaks around only a few characters (only).
 \def\urefcatcodes{%
-  \catcode\ampChar=\active   \catcode\dotChar=\active
-  \catcode\hashChar=\active  \catcode\questChar=\active
-  \catcode\slashChar=\active
+  \catcode`\&=\active \catcode`\.=\active
+  \catcode`\#=\active \catcode`\?=\active
+  \catcode`\/=\active
 }
 {
   \urefcatcodes
@@ -2773,11 +2788,6 @@
 %
 \def\dmn#1{\thinspace #1}
 
-% @l was never documented to mean ``switch to the Lisp font'',
-% and it is not used as such in any manual I can find.  We need it for
-% Polish suppressed-l.  --karl, 22sep96.
-%\def\l#1{{\li #1}\null}
-
 % @acronym for "FBI", "NATO", and the like.
 % We print this one point size smaller, since it's intended for
 % all-uppercase.
@@ -2830,23 +2840,24 @@
 \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
 %
 \def\math{%
-  \tex
-  \mathunderscore
-  \let\\ = \mathbackslash
-  \mathactive
-  % make the texinfo accent commands work in math mode
-  \let\"=\ddot
-  \let\'=\acute
-  \let\==\bar
-  \let\^=\hat
-  \let\`=\grave
-  \let\u=\breve
-  \let\v=\check
-  \let\~=\tilde
-  \let\dotaccent=\dot
-  % have to provide another name for sup operator
-  \let\mathopsup=\sup
-  $\finishmath
+  \ifmmode\else % only go into math if not in math mode already
+    \tex
+    \mathunderscore
+    \let\\ = \mathbackslash
+    \mathactive
+    % make the texinfo accent commands work in math mode
+    \let\"=\ddot
+    \let\'=\acute
+    \let\==\bar
+    \let\^=\hat
+    \let\`=\grave
+    \let\u=\breve
+    \let\v=\check
+    \let\~=\tilde
+    \let\dotaccent=\dot
+    % have to provide another name for sup operator
+    \let\mathopsup=\sup
+  $\expandafter\finishmath\fi
 }
 \def\finishmath#1{#1$\endgroup}  % Close the group opened by \tex.
 
@@ -2881,9 +2892,6 @@
 \def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
 \def\finishsup#1{$\ptexsp{\hbox{\selectfonts\lllsize #1}}$}%
 
-% ctrl is no longer a Texinfo command, but leave this definition for fun.
-\def\ctrl #1{{\tt \rawbackslash \hat}#1}
-
 % @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.
@@ -3391,7 +3399,7 @@
 \newtoks\evenfootline    % footline on even pages
 \newtoks\oddfootline     % footline on odd pages
 
-% Now make TeX use those variables
+% Now make \makeheadline and \makefootline in Plain TeX use those variables
 \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
                             \else \the\evenheadline \fi}}
 \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
@@ -3447,6 +3455,10 @@
 % @everyheadingmarks
 % @everyfootingmarks
 
+% These define \getoddheadingmarks, \getevenheadingmarks,
+% \getoddfootingmarks, and \getevenfootingmarks, each to one of
+% \gettopheadingmarks, \getbottomheadingmarks.
+%
 \def\evenheadingmarks{\headingmarks{even}{heading}}
 \def\oddheadingmarks{\headingmarks{odd}{heading}}
 \def\evenfootingmarks{\headingmarks{even}{footing}}
@@ -3494,7 +3506,7 @@
 \global\evenfootline={\hfil}
 \global\oddfootline={\hfil}
 \global\evenheadline={\line{\folio\hfil\thistitle}}
-\global\oddheadline={\line{\thischapter\hfil\folio}}
+\global\oddheadline={\line{\thischapterheading\hfil\folio}}
 \global\let\contentsalignmacro = \chapoddpage
 }
 \let\contentsalignmacro = \chappager
@@ -3505,8 +3517,8 @@
 \global\pageno=1
 \global\evenfootline={\hfil}
 \global\oddfootline={\hfil}
-\global\evenheadline={\line{\thischapter\hfil\folio}}
-\global\oddheadline={\line{\thischapter\hfil\folio}}
+\global\evenheadline={\line{\thischapterheading\hfil\folio}}
+\global\oddheadline={\line{\thischapterheading\hfil\folio}}
 \global\let\contentsalignmacro = \chappager
 }
 \def\HEADINGSon{\HEADINGSdouble}
@@ -3517,7 +3529,7 @@
 \global\evenfootline={\hfil}
 \global\oddfootline={\hfil}
 \global\evenheadline={\line{\folio\hfil\thistitle}}
-\global\oddheadline={\line{\thischapter\hfil\folio}}
+\global\oddheadline={\line{\thischapterheading\hfil\folio}}
 \global\let\contentsalignmacro = \chapoddpage
 }
 
@@ -3525,8 +3537,8 @@
 \def\HEADINGSsinglex{%
 \global\evenfootline={\hfil}
 \global\oddfootline={\hfil}
-\global\evenheadline={\line{\thischapter\hfil\folio}}
-\global\oddheadline={\line{\thischapter\hfil\folio}}
+\global\evenheadline={\line{\thischapterheading\hfil\folio}}
+\global\oddheadline={\line{\thischapterheading\hfil\folio}}
 \global\let\contentsalignmacro = \chappager
 }
 
@@ -3736,7 +3748,12 @@
    \noindent
    \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
    %
-   \vadjust{\penalty 1200}}% not good to break after first line of item.
+   \ifinner\else
+     \vadjust{\penalty 1200}% not good to break after first line of item.
+   \fi
+   % We can be in inner vertical mode in a footnote, although an
+   % @itemize looks awful there.
+  }%
   \flushcr
 }
 
@@ -4358,19 +4375,16 @@
 % except not \outer, so it can be used within macros and \if's.
 \edef\newwrite{\makecsname{ptexnewwrite}}
 
-% \newindex {foo} defines an index named foo.
-% It automatically defines \fooindex such that
-% \fooindex ...rest of line... puts an entry in the index foo.
-% It also defines \fooindfile to be the number of the output channel for
-% the file that accumulates this index.  The file's extension is foo.
+% \newindex {foo} defines an index named IX.
+% It automatically defines \IXindex such that
+% \IXindex ...rest of line... puts an entry in the index IX.
+% It also defines \IXindfile to be the number of the output channel for
+% the file that accumulates this index.  The file's extension is IX.
 % The name of an index should be no more than 2 characters long
 % for the sake of vms.
 %
 \def\newindex#1{%
-  \iflinks
-    \expandafter\newwrite \csname#1indfile\endcsname
-    \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
-  \fi
+  \expandafter\chardef\csname#1indfile\endcsname=0
   \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
     \noexpand\doindex{#1}}
 }
@@ -4384,15 +4398,20 @@
 \def\defcodeindex{\parsearg\newcodeindex}
 %
 \def\newcodeindex#1{%
-  \iflinks
-    \expandafter\newwrite \csname#1indfile\endcsname
-    \openout \csname#1indfile\endcsname \jobname.#1
-  \fi
+  \expandafter\chardef\csname#1indfile\endcsname=0
   \expandafter\xdef\csname#1index\endcsname{%
     \noexpand\docodeindex{#1}}%
 }
 
+% The default indices:
+\newindex{cp}%      concepts,
+\newcodeindex{fn}%  functions,
+\newcodeindex{vr}%  variables,
+\newcodeindex{tp}%  types,
+\newcodeindex{ky}%  keys
+\newcodeindex{pg}%  and programs.
 
+
 % @synindex foo bar    makes index foo feed into index bar.
 % Do this instead of @defindex foo if you don't want it as a separate index.
 %
@@ -4420,26 +4439,19 @@
   \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
 }
 
-% Define \doindex, the driver for all \fooindex macros.
+% Define \doindex, the driver for all index macros.
 % Argument #1 is generated by the calling \fooindex macro,
-%  and it is "foo", the name of the index.
+% and it the two-letter name of the index.
 
-% \doindex just uses \parsearg; it calls \doind for the actual work.
-% This is because \doind is more useful to call from other macros.
+\def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
+\def\doindexxxx #1{\doind{\indexname}{#1}}
 
-% There is also \dosubind {index}{topic}{subtopic}
-% which makes an entry in a two-level index such as the operation index.
-
-\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
-\def\singleindexer #1{\doind{\indexname}{#1}}
-
 % like the previous two, but they put @code around the argument.
-\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
-\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
+\def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
+\def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}}
 
-% Take care of Texinfo commands that can appear in an index entry.
-% Since there are some commands we want to expand, and others we don't,
-% we have to laboriously prevent expansion for those that we don't.
+% 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.
@@ -4455,31 +4467,6 @@
   \def\{{{\tt\char123}}%
   \def\}{{\tt\char125}}%
   %
-  % I don't entirely understand this, but when an index entry is
-  % generated from a macro call, the \endinput which \scanmacro inserts
-  % causes processing to be prematurely terminated.  This is,
-  % apparently, because \indexsorttmp is fully expanded, and \endinput
-  % is an expandable command.  The redefinition below makes \endinput
-  % disappear altogether for that purpose -- although logging shows that
-  % processing continues to some further point.  On the other hand, it
-  % seems \endinput does not hurt in the printed index arg, since that
-  % is still getting written without apparent harm.
-  %
-  % Sample source (mac-idx3.tex, reported by Graham Percival to
-  % help-texinfo, 22may06):
-  % @macro funindex {WORD}
-  % @findex xyz
-  % @end macro
-  % ...
-  % @funindex commtest
-  % This is not enough to reproduce the bug, but it gives the flavor.
-  %
-  % Sample whatsit resulting:
-  % address@hidden@folio address@hidden address@hidden }}}
-  %
-  % So:
-  \let\endinput = \empty
-  %
   % Do the redefinitions.
   \commondummies
 }
@@ -4608,6 +4595,8 @@
 }
 
 % \commondummiesnofonts: common to \commondummies and \indexnofonts.
+% Define \definedumyletter, \definedummyaccent and \definedummyword before
+% using.
 %
 \def\commondummiesnofonts{%
   % Control letters and accents.
@@ -4676,21 +4665,54 @@
   \definedummyword\verb
   \definedummyword\w
   \definedummyword\xref
-  %
-  % Consider:
-  %   @macro mkind{arg1,arg2}
-  %   @cindex \arg2\
-  %   @end macro
-  %   @mkind{foo, bar}
-  % The space after the comma will end up in the temporary definition
-  % that we make for arg2 (see \parsemargdef ff.).  We want all this to be
-  % expanded for the sake of the index, so we end up just seeing "bar".
-  \let\xeatspaces = \eatspaces
 }
 
 % For testing: output @{ and @} in index sort strings as \{ and \}.
 \newif\ifusebracesinindexes
 
+\let\indexlbrace\relax
+\let\indexrbrace\relax
+
address@hidden
+\catcode`\\=13
+  @address@hidden@def\{}}
+}
+
+{
+\catcode`\<=13
+\catcode`\-=13
+\catcode`\`=13
+  \gdef\indexnonalnumdisappear{%
+    \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else
+      % @set txiindexlquoteignore makes us ignore left quotes in the sort term.
+      % (Introduced for FSFS 2nd ed.)
+      \let`=\empty
+    \fi
+    %
+    \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else
+      \backslashdisappear
+    \fi
+    %
+    \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else
+      \def-{}%
+    \fi
+    \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else
+      \def<{}%
+    \fi
+    \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else
+      address@hidden
+    \fi
+  }
+
+  \gdef\indexnonalnumreappear{%
+    \useindexbackslash
+    \let-\normaldash
+    \let<\normalless
+    address@hidden@}%
+  }
+}
+
+
 % \indexnofonts is used when outputting the strings to sort the index
 % by, and when constructing control sequence names.  It eliminates all
 % control sequences and just writes whatever the best ASCII sort string
@@ -4703,7 +4725,6 @@
   \def\definedummyletter##1{\let##1\empty}%
   % All control words become @asis by default; overrides below.
   \let\definedummyword\definedummyaccent
-  %
   \commondummiesnofonts
   %
   % Don't no-op \tt, since it isn't a user-level command
@@ -4716,16 +4737,8 @@
   \def\_{\normalunderscore}%
   \def\-{}% @- shouldn't affect sorting
   %
-  % Unfortunately, texindex is not prepared to handle braces in the
-  % content at all.  So for index sorting, we map @{ and @} to strings
-  % starting with |, since that ASCII character is between ASCII { and }.
-  \ifusebracesinindexes
-    \def\lbracechar{\lbracecmd}%
-    \def\rbracechar{\rbracecmd}%
-  \else
-    \def\lbracechar{|a}%
-    \def\rbracechar{|b}%
-  \fi
+  \def\lbracechar{{\indexlbrace}}%
+  \def\rbracechar{{\indexrbrace}}%
   \let\{=\lbracechar
   \let\}=\rbracechar
   %
@@ -4737,7 +4750,7 @@
   \def\L{L}%
   \def\OE{OE}%
   \def\O{O}%
-  \def\TH{ZZZ}%
+  \def\TH{TH}%
   \def\aa{aa}%
   \def\ae{ae}%
   \def\dh{dzz}%
@@ -4749,7 +4762,7 @@
   \def\o{o}%
   \def\questiondown{?}%
   \def\ss{ss}%
-  \def\th{zzz}%
+  \def\th{th}%
   %
   \def\LaTeX{LaTeX}%
   \def\TeX{TeX}%
@@ -4786,9 +4799,6 @@
   \def\result{=>}%
   \def\textdegree{o}%
   %
-  \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax
-  \else \indexlquoteignore \fi
-  %
   % 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.
   % makeinfo does not expand macros in the argument to @deffn, which ends up
@@ -4802,19 +4812,18 @@
   \macrolist
 }
 
-% Undocumented (for FSFS 2nd ed.): @set txiindexlquoteignore makes us
-% ignore left quotes in the sort term.
-{\catcode`\`=\active
- \gdef\indexlquoteignore{\let`=\empty}}
 
-\let\indexbackslash=0  %overridden during \printindex.
 \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{\dosubind{#1}{#2}{}}
 
-% Workhorse for all \fooindexes.
+% 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?
+
+% 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).
@@ -4822,6 +4831,7 @@
 \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.
@@ -4837,7 +4847,49 @@
   \fi
 }
 
-% Write the entry in \toks0 to the index file:
+% Check if an index file has been opened, and if not, open it.
+\def\requireopenindexfile#1{%
+\ifnum\csname #1indfile\endcsname=0
+  \expandafter\newwrite \csname#1indfile\endcsname
+  \edef\suffix{#1}%
+  % A .fls suffix would conflict with the file extension for the output
+  % of -recorder, so use .f1s instead.
+  \ifx\suffix\indexisfl\def\suffix{f1}\fi
+  % Open the file
+  \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
+  % Using \immediate here prevents an object entering into the current box,
+  % which could confound checks such as those in \safewhatsit for preceding
+  % skips.
+\fi}
+\def\indexisfl{fl}
+
+% Output \ as {\indexbackslash}, because \ is an escape character in
+% the index files.
+\let\indexbackslash=\relax
address@hidden \catcode`\\=\active
+  @address@hidden@address@hidden
+}
+
+% 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{%
+  \begingroup
+  \indexnonalnumreappear
+  \indexwritesortasxxx}
+\gdef\indexwritesortasxxx#1{%
+  \xdef\indexsortkey{#1}\endgroup}
+}
+
+
+% Write the entry in \toks0 to the index file.
 %
 \def\dosubindwrite{%
   % Put the index entry in the margin if desired.
@@ -4847,14 +4899,20 @@
   %
   % Remember, we are within a group.
   \indexdummies % Must do this here, since \bf, etc expand at this stage
-  \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now
-      % so it will be output as is; and it will print as backslash.
-  %
-  % Process the index entry with all font commands turned off, to
-  % get the string to sort by.
+  \useindexbackslash % \indexbackslash isn't defined now so it will be output 
+                     % as is; and it will print as backslash.
+  % Get the string to sort by, by processing the index entry with all
+  % font commands turned off.
   {\indexnofonts
-   \edef\temp{\the\toks0}% need full expansion
-   \xdef\indexsorttmp{\temp}%
+   \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
@@ -4864,10 +4922,11 @@
   % sorted result.
   \edef\temp{%
     \write\writeto{%
-      \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}%
+      \string\entry{\indexsortkey}{\noexpand\folio}{\the\toks0}}%
   }%
   \temp
 }
+\newbox\dummybox % used above
 
 % Take care of unwanted page breaks/skips around a whatsit:
 %
@@ -4993,7 +5052,9 @@
   % as its first line, TeX doesn't complain about mismatched braces
   % (because it thinks @} is a control sequence).
   \catcode`\@ = 11
-  \openin 1 \jobname.#1s
+  % See comment in \requireopenindexfile.
+  \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
+  \openin 1 \jobname.\indexname s
   \ifeof 1
     % \enddoublecolumns gets confused if there is no text in the index,
     % and it loses the chapter title and the aux file entries for the
@@ -5001,43 +5062,96 @@
     % there is some text.
     \putwordIndexNonexistent
   \else
+    \catcode`\\ = 0
+    \escapechar = `\\
     %
     % 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.
-    \read 1 to \temp
+    \read 1 to \thisline
     \ifeof 1
       \putwordIndexIsEmpty
     \else
       % 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{\backslashcurfont}%
-      \catcode`\\ = 0
-      \escapechar = `\\
+      \def\indexbackslash{\ttbackslash}%
+      \let\indexlbrace\{   % Likewise, set these sequences for braces
+      \let\indexrbrace\}   % used in the sort key.
       \begindoublecolumns
-      \input \jobname.#1s
+      \let\entryorphanpenalty=\indexorphanpenalty
+      %
+      % Read input from the index file line by line.
+      \loopdo
+        \ifeof1
+          \let\firsttoken\relax
+        \else
+          \read 1 to \nextline
+          \edef\act{\gdef\noexpand\firsttoken{\getfirsttoken\nextline}}%
+          \act
+        \fi
+        \thisline
+        %
+        \ifeof1\else
+        \let\thisline\nextline
+      \repeat
+      %%
       \enddoublecolumns
     \fi
   \fi
   \closein 1
 \endgroup}
 
+\def\getfirsttoken#1{\expandafter\getfirsttokenx#1\endfirsttoken}
+\long\def\getfirsttokenx#1#2\endfirsttoken{\noexpand#1}
+
+\def\loopdo#1\repeat{\def\body{#1}\loopdoxxx}
+\def\loopdoxxx{\let\next=\relax\body\let\next=\loopdoxxx\fi\next}
+
 % These macros are used by the sorted index file itself.
 % Change them to control the appearance of the index.
 
-\def\initial#1{{%
-  % Some minor font changes for the special characters.
-  \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
+{\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
+\catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
+\catcode`\$=3
+\gdef\initialglyphs{%
+  % 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.
+  \def\indexbackslash{\math{\backslash}}%
+  \let\\=\indexbackslash
   %
+  % Can't get bold backslash so don't use bold forward slash
+  \catcode`\/=13
+  \def/{{\secrmnotbold \normalslash}}%
+  \def-{{\normaldash\normaldash}}% en dash `--'
+  \def^{{\chapbf \normalcaret}}%
+  \def~{{\chapbf \normaltilde}}%
+  \def\_{%
+     \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }%
+  \def|{$\vert$}%
+  \def<{$\less$}%
+  \def>{$\gtr$}%
+  \def+{$\normalplus$}%
+}}
+
+\def\initial{%
+  \bgroup
+  \initialglyphs
+  \initialx
+}
+
+\def\initialx#1{%
   % Remove any glue we may have, we'll be inserting our own.
   \removelastskip
   %
   % We like breaks before the index initials, so insert a bonus.
+  % The glue before the bonus allows a little bit of space at the
+  % bottom of a column to reduce an increase in inter-line spacing.
   \nobreak
-  \vskip 0pt plus 3\baselineskip
-  \penalty 0
-  \vskip 0pt plus -3\baselineskip
+  \vskip 0pt plus 5\baselineskip
+  \penalty -300 
+  \vskip 0pt plus -5\baselineskip
   %
   % Typeset the initial.  Making this add up to a whole number of
   % baselineskips increases the chance of the dots lining up from column
@@ -5045,24 +5159,24 @@
   % we need before each entry, but it's better.
   %
   % No shrink because it confuses \balancecolumns.
-  \vskip 1.67\baselineskip plus .5\baselineskip
-  \leftline{\secbf #1}%
+  \vskip 1.67\baselineskip plus 1\baselineskip
+  \leftline{\secfonts \kern-0.05em \secbf #1}%
+  % \secfonts is inside the argument of \leftline so that the change of
+  % \baselineskip will not affect any glue inserted before the vbox that
+  % \leftline creates.
   % Do our best not to break after the initial.
   \nobreak
   \vskip .33\baselineskip plus .1\baselineskip
-}}
+  \egroup % \initialglyphs
+}
 
+\newdimen\entryrightmargin
+\entryrightmargin=0pt
+
 % \entry typesets a paragraph consisting of the text (#1), dot leaders, and
 % then page number (#2) flushed to the right margin.  It is used for index
 % and table of contents entries.  The paragraph is indented by \leftskip.
 %
-% A straightforward implementation would start like this:
-%      \def\entry#1#2{...
-% But this freezes the catcodes in the argument, and can cause problems to
-% @code, which sets - active.  This problem was fixed by a kludge---
-% ``-'' was active throughout whole index, but this isn't really right.
-% The right solution is to prevent \entry from swallowing the whole text.
-%                                 --kasal, 21nov03
 \def\entry{%
   \begingroup
     %
@@ -5070,85 +5184,182 @@
     % affect previous text.
     \par
     %
-    % Do not fill out the last line with white space.
-    \parfillskip = 0in
-    %
     % No extra space above this paragraph.
     \parskip = 0in
     %
-    % Do not prefer a separate line ending with a hyphen to fewer lines.
-    \finalhyphendemerits = 0
-    %
-    % \hangindent is only relevant when the entry text and page number
-    % don't both fit on one line.  In that case, bob suggests starting the
-    % dots pretty far over on the line.  Unfortunately, a large
-    % indentation looks wrong when the entry text itself is broken across
-    % lines.  So we use a small indentation and put up with long leaders.
-    %
-    % \hangafter is reset to 1 (which is the value we want) at the start
-    % of each paragraph, so we need not do anything with that.
-    \hangindent = 2em
-    %
-    % When the entry text needs to be broken, just fill out the first line
-    % with blank space.
-    \rightskip = 0pt plus1fil
-    %
-    % A bit of stretch before each entry for the benefit of balancing
-    % columns.
-    \vskip 0pt plus1pt
-    %
     % When reading the text of entry, convert explicit line breaks
     % from @* into spaces.  The user might give these in long section
     % titles, for instance.
     \def\*{\unskip\space\ignorespaces}%
-    \def\entrybreak{\hfil\break}%
+    \def\entrybreak{\hfil\break}% An undocumented command
     %
+    % A bit of stretch before each entry for the benefit of balancing
+    % columns.
+    \vskip 0pt plus0.5pt
+    %
     % Swallow the left brace of the text (first parameter):
     \afterassignment\doentry
     \let\temp =
 }
 \def\entrybreak{\unskip\space\ignorespaces}%
 \def\doentry{%
+    % Save the text of the entry
+    \global\setbox\boxA=\hbox\bgroup
     \bgroup % Instead of the swallowed brace.
       \noindent
       \aftergroup\finishentry
       % And now comes the text of the entry.
+      % Not absorbing as a macro argument reduces the chance of problems
+      % with catcodes occurring.
 }
-\def\finishentry#1{%
address@hidden
+\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.
     %
-    % The following is kludged to not output a line of dots in the index if
-    % there are no page numbers.  The next person who breaks this will be
-    % cursed by a Unix daemon.
-    \setbox\boxA = \hbox{#1}%
-    \ifdim\wd\boxA = 0pt
-      \ %
+    % 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
       %
-      % If we must, put the page number on a line of its own, and fill out
-      % this line with blank space.  (The \hfil is overwhelmed with the
-      % fill leaders glue in \indexdotfill if the page number does fit.)
-      \hfil\penalty50
       \null\nobreak\indexdotfill % Have leaders before the page number.
       %
-      % The `\ ' here is removed by the implicit \unskip that TeX does as
-      % part of (the primitive) \par.  Without it, a spurious underfull
-      % \hbox ensues.
       \ifpdf
-       \pdfgettoks#1.%
-       \ \the\toksA
+        \pdfgettoks#1.%
+        \bgroup\let\domark\relax
+          \hskip\skip\thinshrinkable\the\toksA
+        \egroup
+        % The redefinion 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 \insertindexentrybox.
       \else
-       \ #1%
+        \hskip\skip\thinshrinkable #1%
       \fi
     \fi
-    \par
+    \egroup % end \boxA
+    \ifdim\wd\boxB = 0pt
+      \global\setbox\entryindexbox=\vbox{\unhbox\boxA}%
+    \else
+    \global\setbox\entryindexbox=\vbox\bgroup
+      \prevdepth=\entrylinedepth
+      \noindent
+      % We want the text of the entries to be aligned to the left, and the
+      % page numbers to be aligned to the right.
+      %
+      \advance\leftskip by 0pt plus 1fil
+      \advance\leftskip by 0pt plus -1fill
+      \rightskip = 0pt plus -1fil
+      \advance\rightskip by 0pt plus 1fill
+      % Cause last line, which could consist of page numbers on their own
+      % if the list of page numbers is long, to be aligned to the right.
+      \parfillskip=0pt plus -1fill
+      %
+      \hangindent=1em
+      %
+      \advance\rightskip by \entryrightmargin
+      % Determine how far we can stretch into the margin.
+      % This allows, e.g., "Appendix H  GNU Free Documentation License" to
+      % fit on one line in @letterpaper format.
+      \ifdim\entryrightmargin>2.1em
+        address@hidden
+      \else
+        address@hidden
+      \fi
+      \advance \parfillskip by 0pt minus address@hidden
+      %
+      address@hidden = \hsize
+      address@hidden by -1\leftskip
+      address@hidden by -1\entryrightmargin
+      address@hidden by address@hidden
+      \ifdim\wd\boxA > address@hidden % If the entry doesn't fit in one line
+      \ifdim\dimen@ > address@hidden   % due to long index text
+        \dimen@ = 0.7\dimen@ % Try to split the text roughly evenly
+        address@hidden = \hsize
+        \advance address@hidden by -1em
+        \ifnum\dimen@>address@hidden
+          % If the entry is too long, use the whole line
+          \dimen@ = address@hidden
+        \fi
+        \advance\leftskip by 0pt plus 1fill % ragged right
+        \advance \dimen@ by 1\rightskip
+        \parshape = 2 0pt \dimen@ 1em address@hidden
+        % Ideally we'd add a finite glue at the end of the first line only, but
+        % TeX doesn't seem to provide a way to do such a thing.
+      \fi\fi
+      \unhbox\boxA
+      %
+      % Do not prefer a separate line ending with a hyphen to fewer lines.
+      \finalhyphendemerits = 0
+      %
+      % Word spacing - no stretch
+      \spaceskip=\fontdimen2\font minus \fontdimen4\font
+      %
+      \linepenalty=1000  % Discourage line breaks.
+      \hyphenpenalty=5000  % Discourage hyphenation.
+      %
+      \par % format the paragraph
+    \egroup % The \vbox
+    \fi
   \endgroup
+  % delay text of entry until after penalty
+  \bgroup\aftergroup\insertindexentrybox
+  \entryorphanpenalty
+}}
+
+\newskip\thinshrinkable
+\skip\thinshrinkable=.15em minus .15em
+
+\newbox\entryindexbox
+\def\insertindexentrybox{%
+  \copy\entryindexbox
+  % The following gets the depth of the last box.  This is for even
+  % line spacing when entries span several lines.
+  \setbox\dummybox\vbox{%
+    \unvbox\entryindexbox
+    \nointerlineskip
+    \lastbox
+    \global\entrylinedepth=\prevdepth
+  }%
+  % Note that we couldn't simply \unvbox\entryindexbox followed by 
+  % \nointerlineskip\lastbox to remove the last box and then reinstate it, 
+  % because this resets how far the box has been \moveleft'ed to 0.  \unvbox
+  % doesn't affect \prevdepth either.
 }
+\newdimen\entrylinedepth
 
+% Default is no penalty
+\let\entryorphanpenalty\egroup
+
+% 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
+% orphaned index entries.
+\long\def\indexorphanpenalty{%
+  \def\isentry{\entry}%
+  \ifx\firsttoken\isentry
+  \else
+    \unskip\penalty 9000
+    % The \unskip here stops breaking before the glue.  It relies on the
+    % \vskip above being there, otherwise there is an error
+    % "You can't use `\unskip' in vertical mode".  There has to be glue
+    % in the current vertical list that hasn't been added to the
+    % "current page".  See Chapter 24 of the TeXbook.  This contradicts
+    % Section 8.3.7 in "TeX by Topic," though.
+  \fi
+  \egroup % now comes the box added with \aftergroup
+}
+
 % 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.
 \def\indexdotfill{\cleaders
-  \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1fill}
+  \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
 
+
 \def\primary #1{\line{#1\hfil}}
 
 \newskip\secondaryindent \secondaryindent=0.5cm
@@ -5169,12 +5380,39 @@
 % Define two-column mode, which we use to typeset indexes.
 % Adapted from the TeXbook, page 416, which is to say,
 % the manmac.tex format used to print the TeXbook itself.
address@hidden
address@hidden  % private names
 
 \newbox\partialpage
 \newdimen\doublecolumnhsize
+\newdimen\doublecolumntopgap
+\doublecolumntopgap = 0pt
 
+% 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 = {%
     %
@@ -5194,9 +5432,16 @@
       \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}%
   %
@@ -5223,13 +5468,19 @@
   %
   % Double the \vsize as well.  (We don't need a separate register here,
   % since nobody clobbers \vsize.)
+  \global\doublecolumntopgap = \topskip
+  \global\advance\doublecolumntopgap by -1\baselineskip
+  \advance\vsize by -1\doublecolumntopgap
   \vsize = 2\vsize
+  \topskip=0pt
+  \global\entrylinedepth=0pt\relax
 }
 
 % The double-column output routine for all double-column pages except
-% the last.
+% the last, which is done by \balancecolumns.
 %
 \def\doublecolumnout{%
+  %
   \splittopskip=\topskip \splitmaxdepth=\maxdepth
   % Get the available space for the double columns -- the normal
   % (undoubled) page height minus any material left over from the
@@ -5252,10 +5503,13 @@
   %
   \hsize = \doublecolumnhsize
   \wd0=\hsize \wd2=\hsize
-  \hbox to\pagewidth{\box0\hfil\box2}%
+  \vbox{%
+    \vskip\doublecolumntopgap
+    \hbox to\pagewidth{\box0\hfil\box2}}%
 }
-%
-% All done 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
@@ -5286,21 +5540,21 @@
   \penalty0
   %
   \output = {%
-    % Split the last of the double-column material.  Leave it on the
-    % current page, no automatic page break.
+    % Split the last of the double-column material.
+    \savemarks
     \balancecolumns
     %
-    % If we end up splitting too much material for the current page,
-    % though, there will be another page break right after this \output
-    % invocation ends.  Having called \balancecolumns once, we do not
+    % Having called \balancecolumns once, we do not
     % want to call it again.  Therefore, reset \output to its normal
-    % definition right away.  (We hope \balancecolumns will never be
-    % called on to balance too much material, but if it is, this makes
-    % the output somewhat more palatable.)
+    % definition right away.
     \global\output = {\onepageout{\pagecontents\PAGE}}%
   }%
   \eject
   \endgroup % started in \begindoublecolumns
+  \restoremarks
+  % Leave the double-column material on the current page, no automatic
+  % page break.
+  \box\balancedcolumns
   %
   % \pagegoal was set to the doubled \vsize above, since we restarted
   % the current page.  We're now back to normal single-column
@@ -5308,31 +5562,52 @@
   % \endgroup where \vsize got restored).
   \pagegoal = \vsize
 }
+\newbox\balancedcolumns
+\setbox\balancedcolumns=\vbox{shouldnt see this}%
 %
-% Called at the end of the double column material.
+% Only called for the last of the double column material.  \doublecolumnout 
+% does the others.
 \def\balancecolumns{%
   \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
   \dimen@ = \ht0
   \advance\dimen@ by \topskip
   \advance\dimen@ by-\baselineskip
-  \divide\dimen@ by 2 % target to split to
-  %debug\message{final 2-column material height=\the\ht0, address@hidden
-  \splittopskip = \topskip
-  % Loop until we get a decent breakpoint.
-  {%
-    \vbadness = 10000
-    \loop
-      \global\setbox3 = \copy0
-      \global\setbox1 = \vsplit3 to \dimen@
-    \ifdim\ht3>\dimen@
-      \global\advance\dimen@ by 1pt
-    \repeat
-  }%
-  %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}%
-  \setbox0=\vbox address@hidden
-  \setbox2=\vbox address@hidden
+  \ifdim\dimen@<14\baselineskip
+    % Don't split a short final column in two.
+    \setbox2=\vbox{}%
+  \else
+    \divide\dimen@ by 2 % target to split to
+    address@hidden = \dimen@
+    \splittopskip = \topskip
+    % Loop until the second column is no higher than the first
+    {%
+      \vbadness = 10000
+      \loop
+        \global\setbox3 = \copy0
+        \global\setbox1 = \vsplit3 to \dimen@
+        % Remove glue from bottom of first column to
+        % make sure it is higher than the second.
+        \global\setbox1 = \vbox{\unvbox1\unpenalty\unskip}%
+      \ifdim\ht3>\ht1
+        \global\advance\dimen@ by 1pt
+      \repeat
+    }%
+    address@hidden by 4
+    address@hidden by 5
+    \ifdim\ht3<address@hidden
+      % Column heights are too different, so don't make their bottoms
+      % flush with each other.  The glue at the end of the second column
+      % allows a second column to stretch, reducing the difference in
+      % height between the two.
+      \setbox0=\vbox address@hidden
+      \setbox2=\vbox address@hidden 0pt plus 0.3\ht0}%
+    \else
+      \setbox0=\vbox address@hidden
+      \setbox2=\vbox address@hidden
+    \fi
+  \fi
   %
-  \pagesofar
+  \global\setbox\balancedcolumns=\vbox{\pagesofar}%
 }
 \catcode`\@ = \other
 
@@ -5351,6 +5626,10 @@
     \let\lastnode=\empty      % no node to associate with
     \writetocentry{part}{#1}{}% but put it in the toc
     \headingsoff              % no headline or footline on the part page
+    % This outputs a mark at the end of the page that clears \thischapter
+    % and \thissection, as is done in \startcontents.
+    \let\pchapsepmacro\relax
+    \chapmacro{}{Yomitfromtoc}{}%
     \chapoddpage
   \endgroup
 }
@@ -5595,9 +5874,6 @@
 
 % @centerchap is like @unnumbered, but the heading is centered.
 \outer\parseargdef\centerchap{%
-  % Well, we could do the following in a group, but that would break
-  % an assumption that \chapmacro is called at the outermost level.
-  % Thus we are safer this way:                --kasal, 24feb04
   \let\centerparametersmaybe = \centerparameters
   \unnmhead0{#1}%
   \let\centerparametersmaybe = \relax
@@ -5721,7 +5997,11 @@
 
 % Define plain chapter starts, and page on/off switching for it.
 \def\chapbreak{\dobreak \chapheadingskip {-4000}}
+
+% Start a new page
 \def\chappager{\par\vfill\supereject}
+
+% \chapoddpage - start on an odd page for a new chapter
 % Because \domark is called before \chapoddpage, the filler page will
 % get the headings for the next chapter, which is wrong.  But we don't
 % care -- we just disable all headings on the filler page.
@@ -5757,7 +6037,7 @@
 
 \CHAPPAGon
 
-% Chapter opening.
+% \chapmacro - Chapter opening.
 %
 % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
 % Yappendix, Yomitfromtoc), #3 the chapter number.
@@ -6151,7 +6431,7 @@
   \savepageno = \pageno
   \begingroup                  % Set up to handle contents files properly.
     \raggedbottom              % Worry more about breakpoints than the bottom.
-    \advance\hsize by -\contentsrightmargin % Don't use the full line length.
+    \entryrightmargin=\contentsrightmargin % Don't use the full line length.
     %
     % Roman numerals for page numbers.
     \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
@@ -6256,7 +6536,7 @@
 
 % Chapters, in the main contents.
 \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
-%
+
 % Chapters, in the short toc.
 % See comments in \dochapentry re vbox and related settings.
 \def\shortchapentry#1#2#3#4{%
@@ -6271,7 +6551,7 @@
   \setbox0 = \hbox{\putwordAppendix{} M}%
   \hbox to \wd0{\putwordAppendix{} #1\hss}}
 %
-\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}}
+\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}}
 
 % Unnumbered chapters.
 \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
@@ -6304,6 +6584,8 @@
 \def\dochapentry#1#2{%
    \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
    \begingroup
+     % Move the page numbers slightly to the right
+     \advance\entryrightmargin by -0.05em
      \chapentryfonts
      \tocentry{#1}{\dopageno\bgroup#2\egroup}%
    \endgroup
@@ -6423,6 +6705,24 @@
     \endgraf
     \ifdim\lastskip<\envskipamount
       \removelastskip
+      \ifnum\lastpenalty<10000
+        % Penalize breaking before the environment, because preceding text
+        % often leads into it.
+        \penalty100
+      \fi
+      \vskip\envskipamount
+    \fi
+  \fi
+}}
+
+\def\afterenvbreak{{%
+  % =10000 instead of <10000 because of a special case in \itemzzz and
+  % \sectionheading, q.v.
+  \ifnum \lastpenalty=10000 \else
+    \advance\envskipamount by \parskip
+    \endgraf
+    \ifdim\lastskip<\envskipamount
+      \removelastskip
       % it's not a good place to break if the last penalty was \nobreak
       % or better ...
       \ifnum\lastpenalty<10000 \penalty-50 \fi
@@ -6431,8 +6731,6 @@
   \fi
 }}
 
-\let\afterenvbreak = \aboveenvbreak
-
 % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins; it will
 % also clear it, so that its embedded environments do the narrowing again.
 \let\nonarrowing=\relax
@@ -6476,7 +6774,7 @@
   % collide with the section heading.
   \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
   %
-  \vbox\bgroup
+  \setbox\groupbox=\vbox\bgroup
       \baselineskip=0pt\parskip=0pt\lineskip=0pt
       \carttop
       \hbox\bgroup
@@ -6500,6 +6798,7 @@
       \egroup
       \cartbot
   \egroup
+  \addgroupbox
   \checkinserts
 }
 
@@ -6977,7 +7276,7 @@
   \temp
 }
 
-% \domakedefun \deffn \deffnx \deffnheader
+% \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) }
 %
 % Define \deffn and \deffnx, without parameters.
 % \deffnheader has to be defined explicitly.
@@ -7315,34 +7614,43 @@
   }
 \fi
 
-\def\scanmacro#1{\begingroup
+\let\aftermacroxxx\relax
+\def\aftermacro{\aftermacroxxx}
+
+% alias because \c means cedilla in @tex or @math
+\let\texinfoc=\c
+
+% Used at the time of macro expansion.
+% Argument is macro body with arguments substituted
+\def\scanmacro#1{%
   \newlinechar`\^^M
-  \let\xeatspaces\eatspaces
+  \def\xprocessmacroarg{\eatspaces}%
   %
-  % Undo catcode changes of \startcontents and \doprintindex
-  % When called from @insertcopying or (short)caption, we need active
-  % backslash to get it printed correctly.  Previously, we had
-  % \catcode`\\=\other instead.  We'll see whether a problem appears
-  % with macro expansion.                              --kasal, 19aug04
-  address@hidden \catcode`\\=\active \escapechar=`\@
+  % Process the macro body under the current catcode regime.
+  \scantokens{#1\texinfoc}\aftermacro%
   %
-  % ... and for \example:
-  \spaceisspace
-  %
-  % The \empty here causes a following catcode 5 newline to be eaten as
-  % part of reading whitespace after a control sequence.  It does not
-  % eat a catcode 13 newline.  There's no good way to handle the two
-  % cases (untried: maybe e-TeX's \everyeof could help, though plain TeX
-  % would then have different behavior).  See the Macro Details node in
-  % the manual for the workaround we recommend for macros and
-  % line-oriented commands.
-  % 
-  \scantokens{#1\empty}%
-\endgroup}
+  % The \c is to remove the \newlinechar added by \scantokens, and
+  % can be noticed by \parsearg.
+  %   The \aftermacro allows a \comment at the end of the macro definition
+  % to duplicate itself past the final \newlinechar added by \scantokens:
+  % this is used in the definition of \group to comment out a newline.  We
+  % don't do the same for \c to support Texinfo files with macros that ended
+  % with a @c, which should no longer be necessary.
+  %   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
 \def\scanexp#1{%
+  \bgroup
+  % Undo catcode changes of \startcontents and \printindex
+  % When called from @insertcopying or (short)caption, we need active
+  % backslash to get it printed correctly.
+  % FIXME: This may not be needed.
+  address@hidden \catcode`\\=\active \escapechar=`\@
   \edef\temp{\noexpand\scanmacro{#1}}%
   \temp
+  \egroup
 }
 
 \newcount\paramno   % Count of parameters
@@ -7408,7 +7716,6 @@
   \catcode`\+=\other
   \catcode`\<=\other
   \catcode`\>=\other
-  address@hidden
   \catcode`\^=\other
   \catcode`\_=\other
   \catcode`\|=\other
@@ -7418,37 +7725,30 @@
 
 \def\scanargctxt{% used for copying and captions, not macros.
   \scanctxt
+  address@hidden
   \catcode`\\=\other
   \catcode`\^^M=\other
 }
 
 \def\macrobodyctxt{% used for @macro definitions
   \scanctxt
+  \catcode`\ =\other
+  address@hidden
   \catcode`\{=\other
   \catcode`\}=\other
   \catcode`\^^M=\other
   \usembodybackslash
 }
 
-\def\macroargctxt{% used when scanning invocations
+% Used when scanning braced macro arguments.  Note, however, that catcode
+% changes here are ineffectual if the macro invocation was nested inside
+% an argument to another Texinfo command.
+\def\macroargctxt{%
   \scanctxt
-  \catcode`\\=0
+  \catcode`\ =\active
+  \catcode`\^^M=\other
+  \catcode`\\=\active
 }
-% why catcode 0 for \ in the above?  To recognize \\ \{ \} as "escapes"
-% for the single characters \ { }.  Thus, we end up with the "commands"
-% that would be written @\ @{ @} in a Texinfo document.
-% 
-% We already have @{ and @}.  For @\, we define it here, and only for
-% this purpose, to produce a typewriter backslash (so, the @\ that we
-% define for @math can't be used with @macro calls):
-%
-\def\\{\normalbackslash}%
-% 
-% We would like to do this for \, too, since that is what makeinfo does.
-% But it is not possible, because Texinfo already has a command @, for a
-% cedilla accent.  Documents must use @comma{} instead.
-%
-% \anythingelse will almost certainly be an error of some kind.
 
 \def\macrolineargctxt{% used for whole-line arguments without braces
   \scanctxt
@@ -7526,59 +7826,36 @@
   \fi
 }
 
-% This makes use of the obscure feature that if the last token of a
-% <parameter list> is #, then the preceding argument is delimited by
-% an opening brace, and that opening brace is not consumed.
-% 
+% \getargs -- Parse the arguments to a @macro line.  Set \macname to
+% the name of the macro, and \argl to the braced argument list.
 \def\getargs#1{\getargsxxx#1{}}
 \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
 \def\getmacname#1 #2\relax{\macname={#1}}
 \def\getmacargs#1{\def\argl{#1}}
+% This made use of the feature that if the last token of a
+% <parameter list> is #, then the preceding argument is delimited by
+% an opening brace, and that opening brace is not consumed.
 
-% For macro processing make @ a letter so that we can make
-% private-to-Texinfo macro names.
address@hidden
-\catcode address@hidden
-
-% Parse the optional {params} list.  Set up \paramno and \paramlist
-% so \defmacro knows what to do.  Define \macarg.BLAH for each BLAH
-% in the params 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
+% Parse the optional {params} list to @macro or @rmacro.
+% Set \paramno to the number of arguments,
+% and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a
+% three-param macro.)  Define \macarg.BLAH for each BLAH in the params
+% 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.  
 %
 % That gets used by \mbodybackslash (above).
 %
-% We need to get `macro parameter char #' into several definitions.
-% The technique used is stolen from LaTeX: let \hash be something
-% unexpandable, insert that wherever you need a #, and then redefine
-% it to # just before using the token list produced.
+% If there are 10 or more arguments, a different technique is used: see
+% \parsemmanyargdef.
 %
-% The same technique is used to protect \eatspaces till just before
-% the macro is used.
-%
-% If there are 10 or more arguments, a different technique is used, where the
-% hook remains in the body, and when macro is to be expanded the body is
-% processed again to replace the arguments.
-%
-% In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
-% argument N value and then \edef  the body (nothing else will expand because 
of
-% the catcode regime underwhich the body was input).
-%
-% If you compile with TeX (not eTeX), and you have macros with 10 or more
-% arguments, no macro can have more than 256 arguments (else error).
-% 
 \def\parsemargdef#1;{%
   \paramno=0\def\paramlist{}%
   \let\hash\relax
-  \let\xeatspaces\relax
+  % \hash is redefined to `#' later to get it into definitions
+  \let\processmacroarg\relax
   \parsemargdefxxx#1,;,%
-  % In case that there are 10 or more arguments we parse again the arguments
-  % list to set new definitions for the \macarg.BLAH macros corresponding to
-  % each BLAH argument. It was anyhow needed to parse already once this list
-  % in order to count the arguments, and as macros with at most 9 arguments
-  % are by far more frequent than macro with 10 or more arguments, defining
-  % twice the \macarg.BLAH macros does not cost too much processing power.
   \ifnum\paramno<10\relax\else
     \paramno0\relax
     \parsemmanyargdef@@#1,;,% 10 or more arguments
@@ -7589,10 +7866,47 @@
   \else \let\next=\parsemargdefxxx
     \advance\paramno by 1
     \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
-        {\xeatspaces{\hash\the\paramno}}%
+        {\processmacroarg{\hash\the\paramno}}%
     \edef\paramlist{\paramlist\hash\the\paramno,}%
   \fi\next}
 
+% \parsemacbody, \parsermacbody
+%
+% 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 
+% body to be transformed.
+% Set \macrobody to the body of the macro, and call \defmacro.
+%
+{\catcode`\ address@hidden macro{%
+\xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
+{\catcode`\ address@hidden rmacro{%
+\xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
+
+% Make @ a letter, so that we can make private-to-Texinfo macro names.
address@hidden
+\catcode address@hidden
+
+%%%%%%%%%%%%%% Code for > 10 arguments only   %%%%%%%%%%%%%%%%%%
+
+% If there are 10 or more arguments, a different technique is used, where the
+% hook remains in the body, and when macro is to be expanded the body is
+% processed again to replace the arguments.
+%
+% In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
+% argument N value and then \edef the body (nothing else will expand because of
+% the catcode regime under which the body was input).
+%
+% If you compile with TeX (not eTeX), and you have macros with 10 or more
+% arguments, no macro can have more than 256 arguments (else error).
+%
+% In case that there are 10 or more arguments we parse again the arguments
+% list to set new definitions for the \macarg.BLAH macros corresponding to
+% each BLAH argument. It was anyhow needed to parse already once this list
+% in order to count the arguments, and as macros with at most 9 arguments
+% are by far more frequent than macro with 10 or more arguments, defining
+% twice the \macarg.BLAH macros does not cost too much processing power.
 \def\parsemmanyargdef@@#1,{%
   \if#1;\let\next=\relax
   \else 
@@ -7608,15 +7922,6 @@
     \advance\paramno by 1\relax
   \fi\next}
 
-% These two commands read recursive and nonrecursive macro bodies.
-% (They're different since rec and nonrec macros end differently.)
-%
-\catcode address@hidden
address@hidden macro%
-{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
address@hidden rmacro%
-{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
-\catcode address@hidden
 
 address@hidden
 address@hidden
@@ -7645,9 +7950,6 @@
     \getargvals@@
   \fi
 }
-
-% Internal for address@hidden
-%  
 \def\getargvals@@{%
   \ifx\paramlist\nilm@
       % Some sanity check needed here that \argvaluelist is also empty.
@@ -7755,16 +8057,7 @@
   \next
 }
 
-% Save the token stack pointer into macro #1:
address@hidden
-%
-% Restore the token stack pointer from number in macro #1:
-\def\texirestoretoksstackpoint#1{\expandafter\mathchardef
-  address@hidden
-% Variant \newtoks that can be used non-\outer:
-\def\texinonouternewtoks{\alloc@ 5\toks \toksdef address@hidden
-
-% Tailing missing arguments are set to empty.
+% Trailing missing arguments are set to empty.
 % 
 address@hidden
   \ifx\paramlist\nilm@
@@ -7795,81 +8088,130 @@
    \long\def#2{#4}%
 }
 
-% This defines a Texinfo @macro. There are eight cases: recursive and
-% nonrecursive macros of zero, one, up to nine, and many arguments.
-% Much magic with \expandafter here.
+
+%%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%%
+
+
+
+% Remove following spaces at the expansion stage.
+% This works because spaces are discarded before each argument when TeX is 
+% getting the arguments for a macro.
+% This must not be immediately followed by a }.
+\long\def\gobblespaces#1{#1}
+
+% This defines a Texinfo @macro or @rmacro, called by \parsemacbody.
+%    \macrobody has the body of the macro in it, with placeholders for
+% its parameters, looking like "\processmacroarg{\hash 1}".
+%    \paramno is the number of parameters
+%    \paramlist is a TeX parameter text, e.g. "#1,#2,#3,"
+% There are eight cases: recursive and nonrecursive macros of zero, one,
+% up to nine, and many arguments.
 % \xdef is used so that macro definitions will survive the file
-% they're defined in; @include reads the file inside a group.
+% they're defined in: @include reads the file inside a group.
 %
 \def\defmacro{%
   \let\hash=##% convert placeholders to macro parameter chars
-  \ifrecursive
+  \ifnum\paramno=1
+    \def\processmacroarg{\gobblespaces}%
+    % This removes the pair of braces around the argument.  We don't
+    % use \eatspaces, because this can cause ends of lines to be lost
+    % when the argument to \eatspaces is read, leading to line-based
+    % commands like "@itemize" not being read correctly.
+  \else
+    \def\processmacroarg{\xprocessmacroarg}%
+    \let\xprocessmacroarg\relax
+  \fi
+  \ifrecursive   %%%%%%%%%%%%%% Recursive %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     \ifcase\paramno
     % 0
       \expandafter\xdef\csname\the\macname\endcsname{%
-        \noexpand\scanmacro{\temp}}%
+        \noexpand\scanmacro{\macrobody}}%
     \or % 1
       \expandafter\xdef\csname\the\macname\endcsname{%
          \bgroup
          \noexpand\braceorline
-         \expandafter\noexpand\csname\the\macname xxx\endcsname}%
-      \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
-         \egroup\noexpand\scanmacro{\temp}}%
+         \expandafter\noexpand\csname\the\macname @@@\endcsname}%
+      \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
+         \expandafter\noexpand\csname\the\macname @@@@\endcsname{%
+           \noexpand\gobblespaces##1\empty}%
+           % The \empty is for \gobblespaces in case #1 is empty
+         }%
+      \expandafter\xdef\csname\the\macname @@@@\endcsname##1{%
+         \egroup\noexpand\scanmacro{\macrobody}}%
     \else
       \ifnum\paramno<10\relax % at most 9
+        % See non-recursive section below for comments
         \expandafter\xdef\csname\the\macname\endcsname{%
-           \bgroup\noexpand\macroargctxt
-           \noexpand\csname\the\macname xx\endcsname}%
-        \expandafter\xdef\csname\the\macname xx\endcsname##1{%
-            \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
+          \bgroup
+          \noexpand\expandafter
+          \noexpand\macroargctxt
+          \noexpand\expandafter
+          \expandafter\noexpand\csname\the\macname @@\endcsname}%
+        \expandafter\xdef\csname\the\macname @@\endcsname##1{%
+            \noexpand\passargtomacro
+            \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
+        \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
+            \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
         \expandafter\expandafter
         \expandafter\xdef
         \expandafter\expandafter
-          \csname\the\macname xxx\endcsname
-            \paramlist{\egroup\noexpand\scanmacro{\temp}}%
+          \csname\the\macname @@@@\endcsname\paramlist{%
+            \egroup\noexpand\scanmacro{\macrobody}}%
       \else % 10 or more
         \expandafter\xdef\csname\the\macname\endcsname{%
           address@hidden
         }%    
-        \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp
+        \global\expandafter\let\csname mac.\the\macname 
.body\endcsname\macrobody
         \global\expandafter\let\csname mac.\the\macname 
.recurse\endcsname\gobble
       \fi
     \fi
-  \else
+  \else  %%%%%%%%%%%%%%%%%%%%%% Non-recursive %%%%%%%%%%%%%%%%%%%%%%%%%%
     \ifcase\paramno
     % 0
       \expandafter\xdef\csname\the\macname\endcsname{%
-        \noexpand\norecurse{\the\macname}%
-        \noexpand\scanmacro{\temp}\egroup}%
+        \noexpand\scanmacro{\macrobody}}%
     \or % 1
       \expandafter\xdef\csname\the\macname\endcsname{%
          \bgroup
          \noexpand\braceorline
-         \expandafter\noexpand\csname\the\macname xxx\endcsname}%
-      \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
+         \expandafter\noexpand\csname\the\macname @@@\endcsname}%
+      \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
+         \expandafter\noexpand\csname\the\macname @@@@\endcsname{%
+           \noexpand\gobblespaces##1\empty}%
+           % The \empty is for \gobblespaces in case #1 is empty
+         }%
+      \expandafter\xdef\csname\the\macname @@@@\endcsname##1{%
         \egroup
-        \noexpand\norecurse{\the\macname}%
-        \noexpand\scanmacro{\temp}\egroup}%
+        \noexpand\scanmacro{\macrobody}%
+        }%
     \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 
+        % comma.
+        % @MACNAME@@@ removes braces surrounding the argument list.
+        % @MACNAME@@@@ scans the macro body with arguments substituted.
         \expandafter\xdef\csname\the\macname\endcsname{%
-           \bgroup\noexpand\macroargctxt
-           \expandafter\noexpand\csname\the\macname xx\endcsname}%
-        \expandafter\xdef\csname\the\macname xx\endcsname##1{%
-            \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
+          \bgroup
+          \noexpand\expandafter  % This \expandafter skip any spaces after the
+          \noexpand\macroargctxt % macro before we change the catcode of space.
+          \noexpand\expandafter
+          \expandafter\noexpand\csname\the\macname @@\endcsname}%
+        \expandafter\xdef\csname\the\macname @@\endcsname##1{%
+            \noexpand\passargtomacro
+            \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
+        \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
+            \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
         \expandafter\expandafter
         \expandafter\xdef
         \expandafter\expandafter
-        \csname\the\macname xxx\endcsname
-        \paramlist{%
-            \egroup
-            \noexpand\norecurse{\the\macname}%
-            \noexpand\scanmacro{\temp}\egroup}%
+          \csname\the\macname @@@@\endcsname\paramlist{%
+            \egroup\noexpand\scanmacro{\macrobody}}%
       \else % 10 or more:
         \expandafter\xdef\csname\the\macname\endcsname{%
           address@hidden
         }%
-        \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp
+        \global\expandafter\let\csname mac.\the\macname 
.body\endcsname\macrobody
         \global\expandafter\let\csname mac.\the\macname 
.recurse\endcsname\norecurse
       \fi
     \fi
@@ -7879,16 +8221,111 @@
 
 \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
 
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
address@hidden \catcode`\\=13  % We need to manipulate \ so use @ as escape
address@hidden@_=11  % private names
address@hidden@!=11  % used as argument separator
+
+% \passargtomacro#1#2 -
+% 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 
+% 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
+%
+% THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN  (... rest of input)
+%
+% where:
+% THE_MACRO - name of the macro we want to call
+% ARG_RESULT - argument list we build to pass to that macro
+% PENDING_BS - either a backslash or nothing
+% NEXT_TOKEN - used to look ahead in the input stream to see what's coming next
+
address@hidden@passargtomacro#1#2{%
+  @add_segment address@hidden@_finish\%
+}
address@hidden@address@hidden @address@hidden@address@hidden
+
+% #1 - THE_MACRO ARG_RESULT
+% #2 - PENDING_BS
+% #3 - NEXT_TOKEN
+% #4 used to look ahead
+%
+% If the next token is not a backslash, process the rest of the argument; 
+% otherwise, remove the next token.
address@hidden@look_ahead#1!#2#3#4{%
+  @ifx#4\%
+   @address@hidden 
+  @else
+   @address@hidden
+  @fi#1!{#2}#4#4%
+}
+
+% #1 - THE_MACRO ARG_RESULT
+% #2 - PENDING_BS
+% #3 - NEXT_TOKEN
+% #4 should be a backslash, which is gobbled.
+% #5 looks ahead
+%
+% Double backslash found.  Add a single backslash, and look ahead.
address@hidden@gobble_and_check_finish#1!#2#3#4#5{%
+  @add_segment#1\!{}#5#5%
+}
+
address@hidden@address@hidden
+
+% #1 - THE_MACRO ARG_RESULT
+% #2 - PENDING_BS
+% #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, 
+% 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
+% added to ARG_RESULT.
address@hidden@add_segment#1!#2#3#4\{%
address@hidden@_finish
+  @call_the_macro#1!%
address@hidden
+  % append the pending backslash to the result, followed by the next segment
+  @address@hidden@address@hidden
+  % this @fi is discarded by @look_ahead.
+  % 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 
+% conditional.
address@hidden@address@hidden@is_fi #1{#2}}
+
+}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 % \braceorline MAC is used for a one-argument macro MAC.  It checks
 % whether the next non-whitespace character is a {.  It sets the context
 % 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 just calls MAC itself.
+% 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\macroargctxt
-  \else\macrolineargctxt\expandafter\parsearg
+  \ifx\nchar\bgroup
+    \macroargctxt
+    \expandafter\passargtomacro
+  \else
+    \macrolineargctxt\expandafter\parsearg
   \fi \macnamexxx}
 
 
@@ -7970,6 +8407,7 @@
   \pdfmkdest{#1}%
   \iflinks
     {%
+      \requireauxfile
       \atdummies  % preserve commands, but don't expand them
       \edef\writexrdef##1##2{%
        address@hidden #1 of \setref, expanded by the \edef
@@ -8009,9 +8447,12 @@
 % node name, #4 the name of the Info file, #5 the name of the printed
 % manual.  All but the node name can be omitted.
 %
-\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
-\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
-\def\ref#1{\xrefX[#1,,,,,,,]}
+\def\pxref{\putwordsee{} \xrefXX}
+\def\xref{\putwordSee{} \xrefXX}
+\def\ref{\xrefXX}
+
+\def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX}
+\def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]}
 %
 \newbox\toprefbox
 \newbox\printedrefnamebox
@@ -8155,6 +8596,12 @@
       %
       % output the `page 3'.
       \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
+           \ifx,\tokenafterxref
+      \else\ifx.\tokenafterxref
+      \else\ifx;\tokenafterxref
+      \else\ifx)\tokenafterxref
+      \else,% add a , if xref not followed by punctuation
+      \fi\fi\fi\fi
     \fi\fi
   \fi
   \endlink
@@ -8225,6 +8672,7 @@
 % If its value is nonempty, SUFFIX is output afterward.
 %
 \def\refx#1#2{%
+  \requireauxfile
   {%
     \indexnofonts
     \otherbackslash
@@ -8288,6 +8736,23 @@
   \fi
 }
 
+% If working on a large document in chapters, it is convenient to
+% be able to disable indexing, cross-referencing, and contents, for test runs.
+% This is done with @novalidate at the beginning of the file.
+%
+\newif\iflinks \linkstrue % by default we want the aux files.
+\let\novalidate = \linksfalse
+
+% Used when writing to the aux file, or when using data from it.
+\def\requireauxfile{%
+  \iflinks
+    \tryauxfile
+    % Open the new aux file.  TeX will close it automatically at exit.
+    \immediate\openout\auxfile=\jobname.aux
+  \fi
+  \global\let\requireauxfile=\relax   % Only do this once.
+}
+
 % Read the last existing aux file, if any.  No error if none exists.
 %
 \def\tryauxfile{%
@@ -8581,6 +9046,7 @@
 \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
   \catcode`\^^M = 5     % in case we're inside an example
   \normalturnoffactive  % allow _ et al. in names
+  \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro
   % If the image is by itself, center it.
   \ifvmode
     \imagevmodetrue
@@ -8761,6 +9227,7 @@
       % \floatlabel-lof.  Besides \floatident, we include the short
       % caption if specified, else the full caption if specified, else nothing.
       {%
+        \requireauxfile
         \atdummies
         %
         % since we read the caption text in the macro world, where ^^M
@@ -8983,7 +9450,8 @@
 % @documentencoding sets the definition of non-ASCII characters
 % according to the specified encoding.
 %
-\parseargdef\documentencoding{%
+\def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
+\def\documentencodingzzz#1{%
   % Encoding being declared for the document.
   \def\declaredencoding{\csname #1.enc\endcsname}%
   %
@@ -9360,7 +9828,7 @@
        \gdef\UTFviiiTmp{#2}%
       % 
       \expandafter\ifx\csname uni:#1\endcsname \relax \else
-       \errmessage{Internal error, already defined: #1}%
+       \message{Internal error, already defined: #1}%
       \fi
       %
       % define an additional control sequence for this code point.
@@ -9710,6 +10178,83 @@
 
   \DeclareUnicodeCharacter{02DB}{\ogonek{ }}
 
+  % Greek letters upper case
+  \DeclareUnicodeCharacter{0391}{{\it A}}
+  \DeclareUnicodeCharacter{0392}{{\it B}}
+  \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}
+  \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}
+  \DeclareUnicodeCharacter{0395}{{\it E}}
+  \DeclareUnicodeCharacter{0396}{{\it Z}}
+  \DeclareUnicodeCharacter{0397}{{\it H}}
+  \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}
+  \DeclareUnicodeCharacter{0399}{{\it I}}
+  \DeclareUnicodeCharacter{039A}{{\it K}}
+  \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}
+  \DeclareUnicodeCharacter{039C}{{\it M}}
+  \DeclareUnicodeCharacter{039D}{{\it N}}
+  \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}
+  \DeclareUnicodeCharacter{039F}{{\it O}}
+  \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}
+  \DeclareUnicodeCharacter{03A1}{{\it P}}
+  %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma
+  \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}
+  \DeclareUnicodeCharacter{03A4}{{\it T}}
+  \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}
+  \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}
+  \DeclareUnicodeCharacter{03A7}{{\it X}}
+  \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}
+  \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}
+
+  % Vowels with accents
+  \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}
+  \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}
+  \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}
+  \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}
+  \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}
+  \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}
+
+  % Standalone accent
+  \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}
+
+  % Greek letters lower case
+  \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}
+  \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}
+  \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}
+  \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}
+  \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}
+  \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}
+  \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}
+  \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}
+  \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}
+  \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}
+  \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}
+  \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}
+  \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}
+  \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}
+  \DeclareUnicodeCharacter{03BF}{{\it o}} % omicron
+  \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}
+  \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}
+  \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}
+  \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}
+  \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}
+  \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}
+  \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}
+  \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}
+  \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}
+  \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}
+
+  % More Greek vowels with accents
+  \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}
+  \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}
+  \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}
+  \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}
+  \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}
+
+  % Variant Greek letters
+  \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}
+  \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}
+  \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}
+
   \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}
   \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}
   \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}
@@ -9837,6 +10382,7 @@
   \DeclareUnicodeCharacter{1EF8}{\~Y}
   \DeclareUnicodeCharacter{1EF9}{\~y}
 
+  % Punctuation
   \DeclareUnicodeCharacter{2013}{--}
   \DeclareUnicodeCharacter{2014}{---}
   \DeclareUnicodeCharacter{2018}{\quoteleft}
@@ -9848,18 +10394,166 @@
   \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}
   \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}
   \DeclareUnicodeCharacter{2022}{\bullet}
+  \DeclareUnicodeCharacter{202F}{\thinspace}
   \DeclareUnicodeCharacter{2026}{\dots}
   \DeclareUnicodeCharacter{2039}{\guilsinglleft}
   \DeclareUnicodeCharacter{203A}{\guilsinglright}
+
   \DeclareUnicodeCharacter{20AC}{\euro}
 
   \DeclareUnicodeCharacter{2192}{\expansion}
   \DeclareUnicodeCharacter{21D2}{\result}
 
+  % Mathematical symbols
+  \DeclareUnicodeCharacter{2200}{\ensuremath\forall}
+  \DeclareUnicodeCharacter{2203}{\ensuremath\exists}
+  \DeclareUnicodeCharacter{2208}{\ensuremath\in}
   \DeclareUnicodeCharacter{2212}{\minus}
-  \DeclareUnicodeCharacter{2217}{\point}
+  \DeclareUnicodeCharacter{2217}{\ast}
+  \DeclareUnicodeCharacter{221E}{\ensuremath\infty}
   \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}
+  \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}
+  \DeclareUnicodeCharacter{2229}{\ensuremath\cap}
   \DeclareUnicodeCharacter{2261}{\equiv}
+  \DeclareUnicodeCharacter{2264}{\ensuremath\leq}
+  \DeclareUnicodeCharacter{2265}{\ensuremath\geq}
+  \DeclareUnicodeCharacter{2282}{\ensuremath\subset}
+  \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}
+
+  \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}
+  \DeclareUnicodeCharacter{2032}{\ensuremath\prime}
+  \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}
+  \DeclareUnicodeCharacter{2111}{\ensuremath\Im}
+  \DeclareUnicodeCharacter{2113}{\ensuremath\ell}
+  \DeclareUnicodeCharacter{2118}{\ensuremath\wp}
+  \DeclareUnicodeCharacter{211C}{\ensuremath\Re}
+  \DeclareUnicodeCharacter{2127}{\ensuremath\mho}
+  \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}
+  \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}
+  \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}
+  \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}
+  \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}
+  \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}
+  \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}
+  \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}
+  \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}
+  \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}
+  \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}
+  \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}
+  \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}
+  \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}
+  \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}
+  \DeclareUnicodeCharacter{21BE}{\ensuremath\upharpoonright}
+  \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}
+  \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}
+  \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}
+  \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}
+  \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}
+  \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}
+  \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}
+  \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}
+  \DeclareUnicodeCharacter{21DD}{\ensuremath\leadsto}
+  \DeclareUnicodeCharacter{2201}{\ensuremath\complement}
+  \DeclareUnicodeCharacter{2202}{\ensuremath\partial}
+  \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}
+  \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}
+  \DeclareUnicodeCharacter{2209}{\ensuremath\notin}
+  \DeclareUnicodeCharacter{220B}{\ensuremath\owns}
+  \DeclareUnicodeCharacter{220F}{\ensuremath\prod}
+  \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}
+  \DeclareUnicodeCharacter{2211}{\ensuremath\sum}
+  \DeclareUnicodeCharacter{2213}{\ensuremath\mp}
+  \DeclareUnicodeCharacter{2218}{\ensuremath\circ}
+  \DeclareUnicodeCharacter{221A}{\ensuremath\surd}
+  \DeclareUnicodeCharacter{221D}{\ensuremath\propto}
+  \DeclareUnicodeCharacter{2220}{\ensuremath\angle}
+  \DeclareUnicodeCharacter{2223}{\ensuremath\mid}
+  \DeclareUnicodeCharacter{2228}{\ensuremath\vee}
+  \DeclareUnicodeCharacter{222A}{\ensuremath\cup}
+  \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}
+  \DeclareUnicodeCharacter{222E}{\ensuremath\oint}
+  \DeclareUnicodeCharacter{223C}{\ensuremath\sim}
+  \DeclareUnicodeCharacter{2240}{\ensuremath\wr}
+  \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}
+  \DeclareUnicodeCharacter{2245}{\ensuremath\cong}
+  \DeclareUnicodeCharacter{2248}{\ensuremath\approx}
+  \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}
+  \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}
+  \DeclareUnicodeCharacter{2260}{\ensuremath\neq}
+  \DeclareUnicodeCharacter{226A}{\ensuremath\ll}
+  \DeclareUnicodeCharacter{226B}{\ensuremath\gg}
+  \DeclareUnicodeCharacter{227A}{\ensuremath\prec}
+  \DeclareUnicodeCharacter{227B}{\ensuremath\succ}
+  \DeclareUnicodeCharacter{2283}{\ensuremath\supset}
+  \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}
+  \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}
+  \DeclareUnicodeCharacter{228F}{\ensuremath\sqsubset}
+  \DeclareUnicodeCharacter{2290}{\ensuremath\sqsupset}
+  \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}
+  \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}
+  \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}
+  \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}
+  \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}
+  \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}
+  \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}
+  \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}
+  \DeclareUnicodeCharacter{2299}{\ensuremath\odot}
+  \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}
+  \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}
+  \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}
+  \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}
+  \DeclareUnicodeCharacter{22A8}{\ensuremath\models}
+  \DeclareUnicodeCharacter{22B4}{\ensuremath\unlhd}
+  \DeclareUnicodeCharacter{22B5}{\ensuremath\unrhd}
+  \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}
+  \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}
+  \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}
+  \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}
+  \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}
+  \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}
+  \DeclareUnicodeCharacter{22C6}{\ensuremath\star}
+  \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}
+  \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}
+  \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}
+  \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}
+  \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}
+  \DeclareUnicodeCharacter{2322}{\ensuremath\frown}
+  \DeclareUnicodeCharacter{2323}{\ensuremath\smile}
+
+  \DeclareUnicodeCharacter{25A1}{\ensuremath\Box}
+  \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}
+  \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}
+  \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}
+  \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}
+  \DeclareUnicodeCharacter{25C7}{\ensuremath\Diamond}
+  \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}
+  \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}
+  \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}
+  \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}
+  \DeclareUnicodeCharacter{266D}{\ensuremath\flat}
+  \DeclareUnicodeCharacter{266E}{\ensuremath\natural}
+  \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}
+  \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}
+  \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}
+  \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}
+  \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}
+  \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}
+  \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}
+  \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}
+  \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}
+  \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}
+  \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}
+  \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}
+  \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}
+  \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}
+  \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}
+  \DeclareUnicodeCharacter{2A1D}{\ensuremath\Join}
+  \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}
+  \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}
+  \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}
+
+  \global\mathchardef\checkmark="1370 % actually the square root sign
+  \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}
 }% end of \utfeightchardefs
 
 % US-ASCII character definitions.
@@ -10177,26 +10871,25 @@
 % this is not a problem.
 \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
 
-% Turn off all special characters except @
-% (and those which the user can use as if they were ordinary).
+% Set catcodes for Texinfo file
+
+% Active characters for printing the wanted glyph.
 % Most of these we simply print from the \tt font, but for some, we can
 % use math or other variants that look better in normal text.
-
+%
 \catcode`\"=\active
 \def\activedoublequote{{\tt\char34}}
 \let"=\activedoublequote
 \catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde
-\chardef\hat=`\^
-\catcode`\^=\active \def\activehat{{\tt \hat}} \let^ = \activehat
+\chardef\hatchar=`\^
+\catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat
 
 \catcode`\_=\active
 \def_{\ifusingtt\normalunderscore\_}
+\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
 \let\realunder=_
-% Subroutine for the previous macro.
-\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
 
-\catcode`\|=\active
-\def|{{\tt\char124}}
+\catcode`\|=\active \def|{{\tt\char124}}
 
 \chardef \less=`\<
 \catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless
@@ -10204,7 +10897,9 @@
 \catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr
 \catcode`\+=\active \def+{{\tt \char 43}}
 \catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
+\catcode`\-=\active \let-=\normaldash
 
+
 % used for headline/footline in the output routine, in case the page
 % breaks in the middle of an @tex block.
 \def\texinfochars{%
@@ -10218,12 +10913,6 @@
   % in principle, all other definitions in \tex have to be undone too.
 }
 
-% If a .fmt file is being used, characters that might appear in a file
-% name cannot be active until we have parsed the command line.
-% So turn them off again, and have \everyjob (or @setfilename) turn them on.
-% \otherifyactive is called near the end of this file.
-\def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
-
 % Used sometimes to turn off (effectively) the active characters even after
 % parsing them.
 \def\turnoffactive{%
@@ -10242,23 +10931,22 @@
 % \doublebackslash is two of them (for the pdf outlines).
 {\catcode`\\=\other @address@hidden @address@hidden
 
-% In texinfo, backslash is an active character; it prints the backslash
+% In Texinfo, backslash is an active character; it prints the backslash
 % in fixed width font.
 \catcode`\\=\active  % @ for escape char from now on.
 
-% The story here is that in math mode, the \char of \backslashcurfont
-% ends up printing the roman \ from the math symbol font (because \char
-% in math mode uses the \mathcode, and plain.tex sets
-% \mathcode`\\="026E).  It seems better for @backslashchar{} to always
-% print a typewriter backslash, hence we use an explicit \mathchar,
+% Print a typewriter backslash.  For math mode, we can't simply use
+% \backslashcurfont: the story here is that in math mode, the \char
+% of \backslashcurfont ends up printing the roman \ from the math symbol
+% font (because \char in math mode uses the \mathcode, and plain.tex
+% sets \mathcode`\\="026E).  Hence we use an explicit \mathchar,
 % which is the decimal equivalent of "715c (class 7, e.g., use \fam;
 % ignored family value; char position "5C).  We can't use " for the
 % usual hex value because it has already been made active.
address@hidden@address@hidden @ifmmode @mathchar29020 @else @backslashcurfont 
@fi}}
address@hidden@backslashchar = @normalbackslash % @backslashchar{} is for user 
documents.
 
-% On startup, @fixbackslash assigns:
-%  @let \ = @normalbackslash
address@hidden@address@hidden @ifmmode @mathchar29020 @else @backslashcurfont 
@fi}}
address@hidden@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.  We switch back and forth between these.
@@ -10266,8 +10954,7 @@
 @address@hidden@address@hidden
 
 % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
-% the literal character `\'.  Also revert - to its normal character, in
-% case the active - from code has slipped in.
+% the literal character `\'.
 %
 address@hidden = @active
  @address@hidden
@@ -10278,40 +10965,66 @@
    @address@hidden
    @let<address@hidden
    @let>address@hidden
-   @address@hidden
    @address@hidden
    @address@hidden
    @let|address@hidden
    @address@hidden
+   @address@hidden
    @markupsetuplqdefault
    @markupsetuprqdefault
    @unsepspaces
  }
 }
 
-% Make _ and + \other characters, temporarily.
-% This is canceled by @fixbackslash.
address@hidden
+% If a .fmt file is being used, characters that might appear in a file
+% name cannot be active until we have parsed the command line.
+% So turn them off again, and have @fixbackslash turn them back on.
address@hidden@other @address@hidden@other
 
+% \enablebackslashhack - allow file to begin `\input texinfo'
+%
 % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
 % That is what \eatinput is for; after that, the `\' should revert to printing
 % a backslash.
-%
address@hidden@eatinput input address@hidden
address@hidden@let\ = @eatinput
+% If the file did not have a `\input texinfo', then it is turned off after
+% the first line; otherwise the first `\' in the file would cause an error.
+% This is used on the very last line of this file, texinfo.tex.
+% We also use @c to call @fixbackslash, in case ends of lines are hidden.
+{
address@hidden@^=7
address@hidden@address@hidden@enablebackslashhack{%
+  @address@hidden = @eatinput%
+  @address@hidden
+  @address@hidden@address@hidden
+  @def address@hidden@secondlinenl}%
+  @gdef @address@hidden@thirdlinenl}%
+  @gdef @address@hidden
+}}
 
-% On the other hand, perhaps the file did not have a `\input texinfo'. Then
-% the first `\' in the file would cause an error. This macro tries to fix
-% that, assuming it is called before the first `\' could plausibly occur.
-% Also turn back on active characters that might appear in the input
-% file name, in case not using a pre-dumped format.
-%
address@hidden@^=7 @address@hidden
address@hidden@eatinput input address@hidden
+
 @address@hidden
-  @address@hidden @let\ = @normalbackslash @fi
+  @address@hidden @let\ = @ttbackslash @fi
+  @catcode13=5 % regular end of line
+  @address@hidden@texinfoc
+  % Also turn back on active characters that might appear in the input
+  % file name, in case not using a pre-dumped format.
   @address@hidden
   @address@hidden@active
+  %
+  % If texinfo.cnf is present on the system, read it.
+  % Useful for site-wide @afourpaper, etc.  This macro, @fixbackslash, gets
+  % called at the beginning of every Texinfo file.  Not opening texinfo.cnf
+  % directly in this file, texinfo.tex, makes it possible to make a format
+  % file for Texinfo.
+  %
+  @openin 1 texinfo.cnf
+  @ifeof 1 @else @input texinfo.cnf @fi
+  @closein 1
 }
 
+
 % Say @foo, not \foo, in error messages.
 @escapechar = `@@
 
@@ -10351,3 +11064,4 @@
 @ignore
    arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115
 @end ignore
address@hidden

Modified: trunk/makeinfo/README
===================================================================
--- trunk/makeinfo/README       2016-01-01 16:24:35 UTC (rev 6904)
+++ trunk/makeinfo/README       2016-01-01 18:33:25 UTC (rev 6905)
@@ -1,7 +1,7 @@
-$Id: README,v 1.4 2010-07-18 18:49:02 karl Exp $
+$Id$
 texinfo/makeinfo/README
 
-  Copyright (C) 2002, 2010, 2015 Free Software Foundation, Inc.
+  Copyright (C) 2002, 2010, 2015, 2016 Free Software Foundation, Inc.
 
   Copying and distribution of this file, with or without modification,
   are permitted in any medium without royalty provided the copyright


Property changes on: trunk/makeinfo/README
___________________________________________________________________
Added: svn:keywords
   + Date Author Id

Modified: trunk/tp/Texinfo/Convert/Converter.pm
===================================================================
--- trunk/tp/Texinfo/Convert/Converter.pm       2016-01-01 16:24:35 UTC (rev 
6904)
+++ trunk/tp/Texinfo/Convert/Converter.pm       2016-01-01 18:33:25 UTC (rev 
6905)
@@ -1,7 +1,7 @@
 # $Id$
 # Converter.pm: Common code for Converters.
 #
-# Copyright 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.
+# Copyright 2011, 2012, 2013, 2014, 2015, 2016 Free Software Foundation, Inc.
 # 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by


Property changes on: trunk/tp/Texinfo/Convert/Converter.pm
___________________________________________________________________
Added: svn:keywords
   + Date Author Id

Modified: trunk/util/dir-example
===================================================================
--- trunk/util/dir-example      2016-01-01 16:24:35 UTC (rev 6904)
+++ trunk/util/dir-example      2016-01-01 18:33:25 UTC (rev 6905)
@@ -532,7 +532,7 @@
 * stty: (coreutils)stty invocation.             Print/change terminal settings.
 * su: (coreutils)su invocation.                 Modify user and group ID.
 * sum: (coreutils)sum invocation.               Print traditional checksum.
-* sync: (coreutils)sync invocation.             Synchronize memory and disk.
+* sync: (coreutils)sync invocation.             Synchronize memory to disk.
 * syslogd: (inetutils)syslogd invocation.       Syslog server.
 * tabs: (tput)Invoking tabs.                    Tab settings.
 * tac: (coreutils)tac invocation.               Reverse files.




reply via email to

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