Index: INSTALL
===================================================================
RCS file: /sources/global/global/INSTALL,v
retrieving revision 1.36
diff -c -r1.36 INSTALL
*** INSTALL	1 Feb 2021 05:43:20 -0000	1.36
--- INSTALL	4 May 2024 18:43:04 -0000
***************
*** 1,87 ****
! ___________________________________
! |      |  |  |     |  _  |     |  |
! |  |___|  |  |  |  |    _|  |  |  |    GNU GLOBAL source code tagging system
! |  |   |  |  |  |  |     |     |  |
! |  ~~  |   ~~|     |  ~  |  |  |   ~~|          for all hackers.
! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!  Copyright (c) 2000, 2002, 2003, 2004, 2006, 2011 Tama Communications Corporation
  
!  This file is free software; as a special exception the author gives
!  unlimited permission to copy and/or distribute it, with or without
!  modifications, as long as this notice is preserved.
  
!  This program is distributed in the hope that it will be useful, but
!  WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
!  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  
! 		----------------------------------
! 
! Installation of GNU Global.
! 
! [Note]  Though GNU Global supports only UNIX(POSIX) environment,
!         some outside projects develop DOS or Windows 32 version of it.
!         Please see:
!                 http://www.gnu.org/software/global/download.html
! 
! 1. Preparation.
! 
! o If you want to use the -I option of global(1) then idutils(1) is needed.
! 
!    You can get idutils at:
! 
! 	ftp://ftp.gnu.org/pub/gnu/idutils/
!   
! o If you want to use the --form(-f) or --dynamic(-D) option of htags(1) then
!   Perl version 5 or later is needed.
! 
!    If you don't have it, you can fetch it from this site.
! 
! 	http://www.perl.com/CPAN/
! 
! 2. How to install.
! 
! 	$ ./configure
! 	$ make
! 	# make install
! 
! 	(You can see the options of configure by invoking './configure --help')
! 
! 3. Using Global with editors.
! 
! o Emacs
! 
!    Global supports GNU Emacs and XEmacs. If you meet some troubles,
!    please mail to bug-global@gnu.org.
! 
!    You can get them at:
! 
! 	GNU emacs:
! 		ftp://ftp.gnu.org/pub/gnu/emacs/
! 	XEmacs:
! 		http://www.xemacs.org
! 
!    Installation procedure is written in gtags.el itself.
! 
! o Elvis
! 
!    You need Elvis 2.1 or later. You can get it at:
! 
! 	http://elvis.vi-editor.org/
! 
!    Please copy an elvis script to your home directory.
! 
! 	$ cp /usr/local/share/gtags/elvis.rc $HOME/.elvisrc
! 	$ PATH=/usr/local/share/gtags/script:$PATH
! 
! o Vim
! 
!    You can get it at:
! 
! 	http://www.vim.org/
! 
!    Please copy vim scripts to your plug-in directory.
! 
! 	$ cp /usr/local/share/gtags/gtags.vim $HOME/.vim/plugin
! 	$ cp /usr/local/share/gtags/gtags-cscope.vim $HOME/.vim/plugin
! 
! Good luck!
--- 1,368 ----
! Installation Instructions
! *************************
  
!    Copyright (C) 1994-1996, 1999-2002, 2004-2017, 2020-2021 Free
! Software Foundation, Inc.
  
!    Copying and distribution of this file, with or without modification,
! are permitted in any medium without royalty provided the copyright
! notice and this notice are preserved.  This file is offered as-is,
! without warranty of any kind.
! 
! Basic Installation
! ==================
! 
!    Briefly, the shell command './configure && make && make install'
! should configure, build, and install this package.  The following
! more-detailed instructions are generic; see the 'README' file for
! instructions specific to this package.  Some packages provide this
! 'INSTALL' file but do not implement all of the features documented
! below.  The lack of an optional feature in a given package is not
! necessarily a bug.  More recommendations for GNU packages can be found
! in *note Makefile Conventions: (standards)Makefile Conventions.
! 
!    The 'configure' shell script attempts to guess correct values for
! various system-dependent variables used during compilation.  It uses
! those values to create a 'Makefile' in each directory of the package.
! It may also create one or more '.h' files containing system-dependent
! definitions.  Finally, it creates a shell script 'config.status' that
! you can run in the future to recreate the current configuration, and a
! file 'config.log' containing compiler output (useful mainly for
! debugging 'configure').
! 
!    It can also use an optional file (typically called 'config.cache' and
! enabled with '--cache-file=config.cache' or simply '-C') that saves the
! results of its tests to speed up reconfiguring.  Caching is disabled by
! default to prevent problems with accidental use of stale cache files.
! 
!    If you need to do unusual things to compile the package, please try
! to figure out how 'configure' could check whether to do them, and mail
! diffs or instructions to the address given in the 'README' so they can
! be considered for the next release.  If you are using the cache, and at
! some point 'config.cache' contains results you don't want to keep, you
! may remove or edit it.
! 
!    The file 'configure.ac' (or 'configure.in') is used to create
! 'configure' by a program called 'autoconf'.  You need 'configure.ac' if
! you want to change it or regenerate 'configure' using a newer version of
! 'autoconf'.
! 
!    The simplest way to compile this package is:
! 
!   1. 'cd' to the directory containing the package's source code and type
!      './configure' to configure the package for your system.
! 
!      Running 'configure' might take a while.  While running, it prints
!      some messages telling which features it is checking for.
! 
!   2. Type 'make' to compile the package.
! 
!   3. Optionally, type 'make check' to run any self-tests that come with
!      the package, generally using the just-built uninstalled binaries.
! 
!   4. Type 'make install' to install the programs and any data files and
!      documentation.  When installing into a prefix owned by root, it is
!      recommended that the package be configured and built as a regular
!      user, and only the 'make install' phase executed with root
!      privileges.
! 
!   5. Optionally, type 'make installcheck' to repeat any self-tests, but
!      this time using the binaries in their final installed location.
!      This target does not install anything.  Running this target as a
!      regular user, particularly if the prior 'make install' required
!      root privileges, verifies that the installation completed
!      correctly.
! 
!   6. You can remove the program binaries and object files from the
!      source code directory by typing 'make clean'.  To also remove the
!      files that 'configure' created (so you can compile the package for
!      a different kind of computer), type 'make distclean'.  There is
!      also a 'make maintainer-clean' target, but that is intended mainly
!      for the package's developers.  If you use it, you may have to get
!      all sorts of other programs in order to regenerate files that came
!      with the distribution.
! 
!   7. Often, you can also type 'make uninstall' to remove the installed
!      files again.  In practice, not all packages have tested that
!      uninstallation works correctly, even though it is required by the
!      GNU Coding Standards.
! 
!   8. Some packages, particularly those that use Automake, provide 'make
!      distcheck', which can by used by developers to test that all other
!      targets like 'make install' and 'make uninstall' work correctly.
!      This target is generally not run by end users.
! 
! Compilers and Options
! =====================
! 
!    Some systems require unusual options for compilation or linking that
! the 'configure' script does not know about.  Run './configure --help'
! for details on some of the pertinent environment variables.
! 
!    You can give 'configure' initial values for configuration parameters
! by setting variables in the command line or in the environment.  Here is
! an example:
! 
!      ./configure CC=c99 CFLAGS=-g LIBS=-lposix
! 
!    *Note Defining Variables::, for more details.
! 
! Compiling For Multiple Architectures
! ====================================
! 
!    You can compile the package for more than one kind of computer at the
! same time, by placing the object files for each architecture in their
! own directory.  To do this, you can use GNU 'make'.  'cd' to the
! directory where you want the object files and executables to go and run
! the 'configure' script.  'configure' automatically checks for the source
! code in the directory that 'configure' is in and in '..'.  This is known
! as a "VPATH" build.
! 
!    With a non-GNU 'make', it is safer to compile the package for one
! architecture at a time in the source code directory.  After you have
! installed the package for one architecture, use 'make distclean' before
! reconfiguring for another architecture.
! 
!    On MacOS X 10.5 and later systems, you can create libraries and
! executables that work on multiple system types--known as "fat" or
! "universal" binaries--by specifying multiple '-arch' options to the
! compiler but only a single '-arch' option to the preprocessor.  Like
! this:
! 
!      ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
!                  CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
!                  CPP="gcc -E" CXXCPP="g++ -E"
! 
!    This is not guaranteed to produce working output in all cases, you
! may have to build one architecture at a time and combine the results
! using the 'lipo' tool if you have problems.
! 
! Installation Names
! ==================
! 
!    By default, 'make install' installs the package's commands under
! '/usr/local/bin', include files under '/usr/local/include', etc.  You
! can specify an installation prefix other than '/usr/local' by giving
! 'configure' the option '--prefix=PREFIX', where PREFIX must be an
! absolute file name.
! 
!    You can specify separate installation prefixes for
! architecture-specific files and architecture-independent files.  If you
! pass the option '--exec-prefix=PREFIX' to 'configure', the package uses
! PREFIX as the prefix for installing programs and libraries.
! Documentation and other data files still use the regular prefix.
! 
!    In addition, if you use an unusual directory layout you can give
! options like '--bindir=DIR' to specify different values for particular
! kinds of files.  Run 'configure --help' for a list of the directories
! you can set and what kinds of files go in them.  In general, the default
! for these options is expressed in terms of '${prefix}', so that
! specifying just '--prefix' will affect all of the other directory
! specifications that were not explicitly provided.
! 
!    The most portable way to affect installation locations is to pass the
! correct locations to 'configure'; however, many packages provide one or
! both of the following shortcuts of passing variable assignments to the
! 'make install' command line to change installation locations without
! having to reconfigure or recompile.
! 
!    The first method involves providing an override variable for each
! affected directory.  For example, 'make install
! prefix=/alternate/directory' will choose an alternate location for all
! directory configuration variables that were expressed in terms of
! '${prefix}'.  Any directories that were specified during 'configure',
! but not in terms of '${prefix}', must each be overridden at install time
! for the entire installation to be relocated.  The approach of makefile
! variable overrides for each directory variable is required by the GNU
! Coding Standards, and ideally causes no recompilation.  However, some
! platforms have known limitations with the semantics of shared libraries
! that end up requiring recompilation when using this method, particularly
! noticeable in packages that use GNU Libtool.
! 
!    The second method involves providing the 'DESTDIR' variable.  For
! example, 'make install DESTDIR=/alternate/directory' will prepend
! '/alternate/directory' before all installation names.  The approach of
! 'DESTDIR' overrides is not required by the GNU Coding Standards, and
! does not work on platforms that have drive letters.  On the other hand,
! it does better at avoiding recompilation issues, and works well even
! when some directory options were not specified in terms of '${prefix}'
! at 'configure' time.
! 
! Optional Features
! =================
! 
!    If the package supports it, you can cause programs to be installed
! with an extra prefix or suffix on their names by giving 'configure' the
! option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'.
! 
!    Some packages pay attention to '--enable-FEATURE' options to
! 'configure', where FEATURE indicates an optional part of the package.
! They may also pay attention to '--with-PACKAGE' options, where PACKAGE
! is something like 'gnu-as' or 'x' (for the X Window System).  The
! 'README' should mention any '--enable-' and '--with-' options that the
! package recognizes.
! 
!    For packages that use the X Window System, 'configure' can usually
! find the X include and library files automatically, but if it doesn't,
! you can use the 'configure' options '--x-includes=DIR' and
! '--x-libraries=DIR' to specify their locations.
! 
!    Some packages offer the ability to configure how verbose the
! execution of 'make' will be.  For these packages, running './configure
! --enable-silent-rules' sets the default to minimal output, which can be
! overridden with 'make V=1'; while running './configure
! --disable-silent-rules' sets the default to verbose, which can be
! overridden with 'make V=0'.
! 
! Particular systems
! ==================
! 
!    On HP-UX, the default C compiler is not ANSI C compatible.  If GNU CC
! is not installed, it is recommended to use the following options in
! order to use an ANSI C compiler:
! 
!      ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
! 
! and if that doesn't work, install pre-built binaries of GCC for HP-UX.
! 
!    HP-UX 'make' updates targets which have the same timestamps as their
! prerequisites, which makes it generally unusable when shipped generated
! files such as 'configure' are involved.  Use GNU 'make' instead.
! 
!    On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
! parse its '<wchar.h>' header file.  The option '-nodtk' can be used as a
! workaround.  If GNU CC is not installed, it is therefore recommended to
! try
! 
!      ./configure CC="cc"
! 
! and if that doesn't work, try
! 
!      ./configure CC="cc -nodtk"
! 
!    On Solaris, don't put '/usr/ucb' early in your 'PATH'.  This
! directory contains several dysfunctional programs; working variants of
! these programs are available in '/usr/bin'.  So, if you need '/usr/ucb'
! in your 'PATH', put it _after_ '/usr/bin'.
! 
!    On Haiku, software installed for all users goes in '/boot/common',
! not '/usr/local'.  It is recommended to use the following options:
! 
!      ./configure --prefix=/boot/common
! 
! Specifying the System Type
! ==========================
! 
!    There may be some features 'configure' cannot figure out
! automatically, but needs to determine by the type of machine the package
! will run on.  Usually, assuming the package is built to be run on the
! _same_ architectures, 'configure' can figure that out, but if it prints
! a message saying it cannot guess the machine type, give it the
! '--build=TYPE' option.  TYPE can either be a short name for the system
! type, such as 'sun4', or a canonical name which has the form:
! 
!      CPU-COMPANY-SYSTEM
! 
! where SYSTEM can have one of these forms:
! 
!      OS
!      KERNEL-OS
! 
!    See the file 'config.sub' for the possible values of each field.  If
! 'config.sub' isn't included in this package, then this package doesn't
! need to know the machine type.
! 
!    If you are _building_ compiler tools for cross-compiling, you should
! use the option '--target=TYPE' to select the type of system they will
! produce code for.
! 
!    If you want to _use_ a cross compiler, that generates code for a
! platform different from the build platform, you should specify the
! "host" platform (i.e., that on which the generated programs will
! eventually be run) with '--host=TYPE'.
! 
! Sharing Defaults
! ================
! 
!    If you want to set default values for 'configure' scripts to share,
! you can create a site shell script called 'config.site' that gives
! default values for variables like 'CC', 'cache_file', and 'prefix'.
! 'configure' looks for 'PREFIX/share/config.site' if it exists, then
! 'PREFIX/etc/config.site' if it exists.  Or, you can set the
! 'CONFIG_SITE' environment variable to the location of the site script.
! A warning: not all 'configure' scripts look for a site script.
! 
! Defining Variables
! ==================
! 
!    Variables not defined in a site shell script can be set in the
! environment passed to 'configure'.  However, some packages may run
! configure again during the build, and the customized values of these
! variables may be lost.  In order to avoid this problem, you should set
! them in the 'configure' command line, using 'VAR=value'.  For example:
! 
!      ./configure CC=/usr/local2/bin/gcc
! 
! causes the specified 'gcc' to be used as the C compiler (unless it is
! overridden in the site shell script).
! 
! Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an
! Autoconf limitation.  Until the limitation is lifted, you can use this
! workaround:
! 
!      CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
! 
! 'configure' Invocation
! ======================
! 
!    'configure' recognizes the following options to control how it
! operates.
! 
! '--help'
! '-h'
!      Print a summary of all of the options to 'configure', and exit.
! 
! '--help=short'
! '--help=recursive'
!      Print a summary of the options unique to this package's
!      'configure', and exit.  The 'short' variant lists options used only
!      in the top level, while the 'recursive' variant lists options also
!      present in any nested packages.
! 
! '--version'
! '-V'
!      Print the version of Autoconf used to generate the 'configure'
!      script, and exit.
! 
! '--cache-file=FILE'
!      Enable the cache: use and save the results of the tests in FILE,
!      traditionally 'config.cache'.  FILE defaults to '/dev/null' to
!      disable caching.
! 
! '--config-cache'
! '-C'
!      Alias for '--cache-file=config.cache'.
! 
! '--quiet'
! '--silent'
! '-q'
!      Do not print messages saying which checks are being made.  To
!      suppress all normal output, redirect it to '/dev/null' (any error
!      messages will still be shown).
! 
! '--srcdir=DIR'
!      Look for the package's source code in directory DIR.  Usually
!      'configure' can determine that directory automatically.
! 
! '--prefix=DIR'
!      Use DIR as the installation prefix.  *note Installation Names:: for
!      more details, including other options available for fine-tuning the
!      installation locations.
! 
! '--no-create'
! '-n'
!      Run the configure checks, but stop before creating any output
!      files.
  
! 'configure' also accepts some other, not widely useful, options.  Run
! 'configure --help' for more details.
Index: doc/texinfo.tex
===================================================================
RCS file: /sources/global/global/doc/texinfo.tex,v
retrieving revision 1.5
diff -c -r1.5 texinfo.tex
*** doc/texinfo.tex	21 Jan 2011 23:53:57 -0000	1.5
--- doc/texinfo.tex	4 May 2024 18:43:05 -0000
***************
*** 1,13 ****
  % texinfo.tex -- TeX macros to handle Texinfo files.
! % 
  % Load plain if necessary, i.e., if running under initex.
  \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
  %
! \def\texinfoversion{2011-01-15.17}
  %
! % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
! % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
! % 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
  %
  % This texinfo.tex file is free software: you can redistribute it and/or
  % modify it under the terms of the GNU General Public License as
--- 1,11 ----
  % texinfo.tex -- TeX macros to handle Texinfo files.
! %
  % Load plain if necessary, i.e., if running under initex.
  \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
  %
! \def\texinfoversion{2021-04-25.21}
  %
! % Copyright 1985, 1986, 1988, 1990-2021 Free Software Foundation, Inc.
  %
  % This texinfo.tex file is free software: you can redistribute it and/or
  % modify it under the terms of the GNU General Public License as
***************
*** 20,40 ****
  % General Public License for more details.
  %
  % You should have received a copy of the GNU General Public License
! % along with this program.  If not, see <http://www.gnu.org/licenses/>.
  %
  % As a special exception, when this file is read by TeX when processing
  % a Texinfo source document, you may use the result without
! % restriction.  (This has been our intent since Texinfo was invented.)
  %
  % Please try the latest version of texinfo.tex before submitting bug
  % reports; you can get the latest version from:
! %   http://www.gnu.org/software/texinfo/ (the Texinfo home page), or
! %   ftp://tug.org/tex/texinfo.tex
! %     (and all CTAN mirrors, see http://www.ctan.org).
  % The texinfo.tex in any given distribution could well be out
  % of date, so if that's what you're using, please check.
  %
! % Send bug reports to bug-texinfo@gnu.org.  Please include including a
  % complete document in each bug report with which we can reproduce the
  % problem.  Patches are, of course, greatly appreciated.
  %
--- 18,39 ----
  % General Public License for more details.
  %
  % You should have received a copy of the GNU General Public License
! % along with this program.  If not, see <https://www.gnu.org/licenses/>.
  %
  % As a special exception, when this file is read by TeX when processing
  % a Texinfo source document, you may use the result without
! % restriction. This Exception is an additional permission under section 7
! % of the GNU General Public License, version 3 ("GPLv3").
  %
  % Please try the latest version of texinfo.tex before submitting bug
  % reports; you can get the latest version from:
! %   https://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
! %   https://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
! %   https://www.gnu.org/software/texinfo/ (the Texinfo home page)
  % The texinfo.tex in any given distribution could well be out
  % of date, so if that's what you're using, please check.
  %
! % Send bug reports to bug-texinfo@gnu.org.  Please include a
  % complete document in each bug report with which we can reproduce the
  % problem.  Patches are, of course, greatly appreciated.
  %
***************
*** 54,60 ****
  % extent.  You can get the existing language-specific files from the
  % full Texinfo distribution.
  %
! % The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
  
  
  \message{Loading texinfo [version \texinfoversion]:}
--- 53,59 ----
  % extent.  You can get the existing language-specific files from the
  % full Texinfo distribution.
  %
! % The GNU Texinfo home page is https://www.gnu.org/software/texinfo.
  
  
  \message{Loading texinfo [version \texinfoversion]:}
***************
*** 65,70 ****
--- 64,73 ----
  \everyjob{\message{[Texinfo version \texinfoversion]}%
    \catcode`+=\active \catcode`\_=\active}
  
+ % LaTeX's \typeout.  This ensures that the messages it is used for
+ % are identical in format to the corresponding ones from latex/pdflatex.
+ \def\typeout{\immediate\write17}%
+ 
  \chardef\other=12
  
  % We never want plain's \outer definition of \+ in Texinfo.
***************
*** 95,101 ****
--- 98,106 ----
  \let\ptexraggedright=\raggedright
  \let\ptexrbrace=\}
  \let\ptexslash=\/
+ \let\ptexsp=\sp
  \let\ptexstar=\*
+ \let\ptexsup=\sup
  \let\ptext=\t
  \let\ptextop=\top
  {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
***************
*** 116,125 ****
  % Set up fixed words for English if not already set.
  \ifx\putwordAppendix\undefined  \gdef\putwordAppendix{Appendix}\fi
  \ifx\putwordChapter\undefined   \gdef\putwordChapter{Chapter}\fi
  \ifx\putwordfile\undefined      \gdef\putwordfile{file}\fi
  \ifx\putwordin\undefined        \gdef\putwordin{in}\fi
! \ifx\putwordIndexIsEmpty\undefined     \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
! \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
  \ifx\putwordInfo\undefined      \gdef\putwordInfo{Info}\fi
  \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
  \ifx\putwordMethodon\undefined  \gdef\putwordMethodon{Method on}\fi
--- 121,131 ----
  % Set up fixed words for English if not already set.
  \ifx\putwordAppendix\undefined  \gdef\putwordAppendix{Appendix}\fi
  \ifx\putwordChapter\undefined   \gdef\putwordChapter{Chapter}\fi
+ \ifx\putworderror\undefined     \gdef\putworderror{error}\fi
  \ifx\putwordfile\undefined      \gdef\putwordfile{file}\fi
  \ifx\putwordin\undefined        \gdef\putwordin{in}\fi
! \ifx\putwordIndexIsEmpty\undefined       \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
! \ifx\putwordIndexNonexistent\undefined   \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
  \ifx\putwordInfo\undefined      \gdef\putwordInfo{Info}\fi
  \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
  \ifx\putwordMethodon\undefined  \gdef\putwordMethodon{Method on}\fi
***************
*** 153,172 ****
  \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}
! 
! % sometimes characters are active, so we need control sequences.
! \chardef\colonChar = `\:
! \chardef\commaChar = `\,
  \chardef\dashChar  = `\-
! \chardef\dotChar   = `\.
! \chardef\exclamChar= `\!
! \chardef\lquoteChar= `\`
! \chardef\questChar = `\?
! \chardef\rquoteChar= `\'
! \chardef\semiChar  = `\;
  \chardef\underChar = `\_
  
  % Ignore a token.
--- 159,172 ----
  \ifx\putwordDefopt\undefined    \gdef\putwordDefopt{User Option}\fi
  \ifx\putwordDeffunc\undefined   \gdef\putwordDeffunc{Function}\fi
  
! % Give the space character the catcode for a space.
! \def\spaceisspace{\catcode`\ =10\relax}
! 
! % Likewise for ^^M, the end of line character.
! \def\endlineisspace{\catcode13=10\relax}
! 
  \chardef\dashChar  = `\-
! \chardef\slashChar = `\/
  \chardef\underChar = `\_
  
  % Ignore a token.
***************
*** 188,204 ****
    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
--- 188,193 ----
***************
*** 215,221 ****
    \tracingmacros2
    \tracingrestores1
    \showboxbreadth\maxdimen \showboxdepth\maxdimen
!   \ifx\eTeXversion\undefined\else % etex gives us more logging
      \tracingscantokens1
      \tracingifs1
      \tracinggroups1
--- 204,210 ----
    \tracingmacros2
    \tracingrestores1
    \showboxbreadth\maxdimen \showboxdepth\maxdimen
!   \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
      \tracingscantokens1
      \tracingifs1
      \tracinggroups1
***************
*** 226,231 ****
--- 215,227 ----
    \errorcontextlines16
  }%
  
+ % @errormsg{MSG}.  Do the index-like expansions on MSG, but if things
+ % aren't perfect, it's not the end of the world, being an error message,
+ % after all.
+ %
+ \def\errormsg{\begingroup \indexnofonts \doerrormsg}
+ \def\doerrormsg#1{\errmessage{#1}}
+ 
  % add check for \lastpenalty to plain's definitions.  If the last thing
  % we did was a \nobreak, we don't want to insert more space.
  %
***************
*** 236,252 ****
  \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
    \removelastskip\penalty-200\bigskip\fi\fi}
  
! % Do @cropmarks to get crop marks.
  %
! \newif\ifcropmarks
! \let\cropmarks = \cropmarkstrue
! %
! % Dimensions to add cropmarks at corners.
! % Added by P. A. MacKay, 12 Nov. 1986
  %
  \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
- \newdimen\cornerlong  \cornerlong=1pc
- \newdimen\cornerthick \cornerthick=.3pt
  \newdimen\topandbottommargin \topandbottommargin=.75in
  
  % Output a mark which sets \thischapter, \thissection and \thiscolor.
--- 232,247 ----
  \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 }
+ 
  \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
  \newdimen\topandbottommargin \topandbottommargin=.75in
  
  % Output a mark which sets \thischapter, \thissection and \thiscolor.
***************
*** 258,356 ****
  %
  % 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...
  \def\domark{%
!   \toks0=\expandafter{\lastchapterdefs}%
!   \toks2=\expandafter{\lastsectiondefs}%
    \toks4=\expandafter{\prevchapterdefs}%
    \toks6=\expandafter{\prevsectiondefs}%
!   \toks8=\expandafter{\lastcolordefs}%
    \mark{%
!                    \the\toks0 \the\toks2
!       \noexpand\or \the\toks4 \the\toks6
!     \noexpand\else \the\toks8
    }%
  }
  % \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.,
  % @setcolor (or @url, or @link, etc.) between @contents and the very
  % first @chapter.
  \def\gettopheadingmarks{%
!   \ifcase0\topmark\fi
    \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
  }
  \def\getbottomheadingmarks{\ifcase1\botmark\fi}
! \def\getcolormarks{\ifcase2\topmark\fi}
  
  % Avoid "undefined control sequence" errors.
! \def\lastchapterdefs{}
! \def\lastsectiondefs{}
  \def\prevchapterdefs{}
  \def\prevsectiondefs{}
! \def\lastcolordefs{}
  
  % 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.
  \def\onepageout#1{%
!   \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
    %
    \ifodd\pageno  \advance\hoffset by \bindingoffset
    \else \advance\hoffset by -\bindingoffset\fi
    %
    % Do this outside of the \shipout so @code etc. will be expanded in
    % the headline as they should be, not taken literally (outputting ''code).
    \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
!   \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
    \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
!   \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
    %
    {%
      % 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.
      %
!     \indexdummies         % don't expand commands in the output.
!     \normalturnoffactive  % \ in index entries must not stay \, e.g., if
!                % the page break happens to be in the middle of an example.
!                % We don't want .vr (or whatever) entries like this:
!                % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}}
!                % "\acronym" won't work when it's read back in;
!                % it needs to be
!                % {\code {{\tt \backslashcurfont }acronym}
      \shipout\vbox{%
        % Do this early so pdf references go to the beginning of the page.
        \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
        %
-       \ifcropmarks \vbox to \outervsize\bgroup
-         \hsize = \outerhsize
-         \vskip-\topandbottommargin
-         \vtop to0pt{%
-           \line{\ewtop\hfil\ewtop}%
-           \nointerlineskip
-           \line{%
-             \vbox{\moveleft\cornerthick\nstop}%
-             \hfill
-             \vbox{\moveright\cornerthick\nstop}%
-           }%
-           \vss}%
-         \vskip\topandbottommargin
-         \line\bgroup
-           \hfil % center the page within the outer (page) hsize.
-           \ifodd\pageno\hskip\bindingoffset\fi
-           \vbox\bgroup
-       \fi
-       %
        \unvbox\headlinebox
        \pagebody{#1}%
        \ifdim\ht\footlinebox > 0pt
--- 253,382 ----
  %
  % 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.
! 
! % \domark is called twice inside \chapmacro, to add one
! % mark before the section break, and one after.
! %   In the second call \prevchapterdefs is the same as \currentchapterdefs,
! % and \prevsectiondefs is the same as \currentsectiondefs.
! %   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{\currentchapterdefs}%
!   \toks2=\expandafter{\currentsectiondefs}%
    \toks4=\expandafter{\prevchapterdefs}%
    \toks6=\expandafter{\prevsectiondefs}%
!   \toks8=\expandafter{\currentcolordefs}%
    \mark{%
!                    \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.,
  % @setcolor (or @url, or @link, etc.) between @contents and the very
  % first @chapter.
  \def\gettopheadingmarks{%
!   \ifcase0\the\savedtopmark\fi
    \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
  }
  \def\getbottomheadingmarks{\ifcase1\botmark\fi}
! \def\getcolormarks{\ifcase2\the\savedtopmark\fi}
  
  % Avoid "undefined control sequence" errors.
! \def\currentchapterdefs{}
! \def\currentsectiondefs{}
! \def\currentsection{}
  \def\prevchapterdefs{}
  \def\prevsectiondefs{}
! \def\currentcolordefs{}
! 
! % Margin to add to right of even pages, to left of odd pages.
! \newdimen\bindingoffset
! \newdimen\normaloffset
! \newdimen\txipagewidth \newdimen\txipageheight
  
  % Main output routine.
+ %
  \chardef\PAGE = 255
! \newtoks\defaultoutput
! \defaultoutput = {\savetopmark\onepageout{\pagecontents\PAGE}}
! \output=\expandafter{\the\defaultoutput}
  
  \newbox\headlinebox
  \newbox\footlinebox
  
! % When outputting the double column layout for indices, an output routine
! % is run several times, which hides the original value of \topmark.  This
! % can lead to a page heading being output and duplicating the chapter heading
! % of the index.  Hence, save the contents of \topmark at the beginning of
! % the output routine.  The saved contents are valid until we actually
! % \shipout a page.
! %
! % (We used to run a short output routine to actually set \topmark and
! % \firstmark to the right values, but if this was called with an empty page
! % containing whatsits for writing index entries, the whatsits would be thrown
! % away and the index auxiliary file would remain empty.)
! %
! \newtoks\savedtopmark
! \newif\iftopmarksaved
! \topmarksavedtrue
! \def\savetopmark{%
!   \iftopmarksaved\else
!     \global\savedtopmark=\expandafter{\topmark}%
!     \global\topmarksavedtrue
!   \fi
! }
! 
! % \onepageout takes a vbox as an argument.
! % \shipout a vbox for a single page, adding an optional header, footer
! % and footnote.  This also causes index entries for this page to be written
! % to the auxiliary files.
! %
  \def\onepageout#1{%
!   \hoffset=\normaloffset
    %
    \ifodd\pageno  \advance\hoffset by \bindingoffset
    \else \advance\hoffset by -\bindingoffset\fi
    %
+   \checkchapterpage
+   %
+   % Retrieve the information for the headings from the marks in the page,
+   % and call Plain TeX's \makeheadline and \makefootline, which use the
+   % values in \headline and \footline.
+   %
+   % Common context changes for both heading and footing.
    % Do this outside of the \shipout so @code etc. will be expanded in
    % the headline as they should be, not taken literally (outputting ''code).
+   \def\commonheadfootline{\let\hsize=\txipagewidth \texinfochars}
+   %
    \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
!   \global\setbox\headlinebox = \vbox{\commonheadfootline \makeheadline}%
    \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
!   \global\setbox\footlinebox = \vbox{\commonheadfootline \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.
      %
!     \atdummies         % don't expand commands in the output.
!     \turnoffactive
      \shipout\vbox{%
        % Do this early so pdf references go to the beginning of the page.
        \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
        %
        \unvbox\headlinebox
        \pagebody{#1}%
        \ifdim\ht\footlinebox > 0pt
***************
*** 361,391 ****
          \unvbox\footlinebox
        \fi
        %
!       \ifcropmarks
!           \egroup % end of \vbox\bgroup
!         \hfil\egroup % end of (centering) \line\bgroup
!         \vskip\topandbottommargin plus1fill minus1fill
!         \boxmaxdepth = \cornerthick
!         \vbox to0pt{\vss
!           \line{%
!             \vbox{\moveleft\cornerthick\nsbot}%
!             \hfill
!             \vbox{\moveright\cornerthick\nsbot}%
!           }%
!           \nointerlineskip
!           \line{\ewbot\hfil\ewbot}%
!         }%
!       \egroup % \vbox from first cropmarks clause
!       \fi
!     }% end of \shipout\vbox
!   }% end of group with \indexdummies
    \advancepageno
    \ifnum\outputpenalty>-20000 \else\dosupereject\fi
  }
  
  \newinsert\margin \dimen\margin=\maxdimen
  
! \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
  {\catcode`\@ =11
  \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  % marginal hacks, juha@viisa.uucp (Juha Takala)
--- 387,403 ----
          \unvbox\footlinebox
        \fi
        %
!     }%
!   }%
!   \global\topmarksavedfalse
    \advancepageno
    \ifnum\outputpenalty>-20000 \else\dosupereject\fi
  }
  
  \newinsert\margin \dimen\margin=\maxdimen
  
! % Main part of page, including any footnotes
! \def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}}
  {\catcode`\@ =11
  \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
  % marginal hacks, juha@viisa.uucp (Juha Takala)
***************
*** 396,415 ****
  \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  }
  
! % Here are the rules for the cropmarks.  Note that they are
! % offset so that the space between them is truly \outerhsize or \outervsize
! % (P. A. MacKay, 12 November, 1986)
! %
! \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
! \def\nstop{\vbox
!   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
! \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
! \def\nsbot{\vbox
!   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
  
  % 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.
  %
  \def\parsearg{\parseargusing{}}
  \def\parseargusing#1#2{%
--- 408,436 ----
  \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
  }
  
! % Check if we are on the first page of a chapter.  Used for printing headings.
! \newif\ifchapterpage
! \def\checkchapterpage{%
!   % Get the chapter that was current at the end of the last page
!   \ifcase1\the\savedtopmark\fi
!   \let\prevchaptername\thischaptername
!   %
!   \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
!   \let\curchaptername\thischaptername
!   %
!   \ifx\curchaptername\prevchaptername
!     \chapterpagefalse
!   \else
!     \chapterpagetrue
!   \fi
! }
! 
! % 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{%
***************
*** 428,434 ****
    }%
  }
  
! % First remove any @comment, then any @c comment.
  \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
  \def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
  
--- 449,456 ----
    }%
  }
  
! % First remove any @comment, then any @c comment.  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}
  
***************
*** 465,478 ****
  %
  \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
  
  % \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%
  }
--- 487,499 ----
  %
  \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{...}
  \def\parseargdef#1{%
    \expandafter \doparseargdef \csname\string#1\endcsname #1%
  }
***************
*** 545,563 ****
  }
  \def\inenvironment#1{%
    \ifx#1\empty
!     out of any environment%
    \else
      in environment \expandafter\string#1%
    \fi
  }
  
! % @end foo executes the definition of \Efoo.
! % But first, it executes a specialized version of \checkenv
! %
  \parseargdef\end{%
    \if 1\csname iscond.#1\endcsname
    \else
!     % The general wording of \badenverr may not be ideal, but... --kasal, 06nov03
      \expandafter\checkenv\csname#1\endcsname
      \csname E#1\endcsname
      \endgroup
--- 566,583 ----
  }
  \def\inenvironment#1{%
    \ifx#1\empty
!     outside of any environment%
    \else
      in environment \expandafter\string#1%
    \fi
  }
  
! 
! % @end foo calls \checkenv and executes the definition of \Efoo.
  \parseargdef\end{%
    \if 1\csname iscond.#1\endcsname
    \else
!     % The general wording of \badenverr may not be ideal.
      \expandafter\checkenv\csname#1\endcsname
      \csname E#1\endcsname
      \endgroup
***************
*** 583,589 ****
  \def\:{\spacefactor=1000 }
  
  % @* forces a line break.
! \def\*{\hfil\break\hbox{}\ignorespaces}
  
  % @/ allows a line break.
  \let\/=\allowbreak
--- 603,609 ----
  \def\:{\spacefactor=1000 }
  
  % @* forces a line break.
! \def\*{\unskip\hfil\break\hbox{}\ignorespaces}
  
  % @/ allows a line break.
  \let\/=\allowbreak
***************
*** 608,614 ****
    \else\ifx\temp\offword \plainnonfrenchspacing
    \else
      \errhelp = \EMsimple
!     \errmessage{Unknown @frenchspacing option `\temp', must be on/off}%
    \fi\fi
  }
  
--- 628,634 ----
    \else\ifx\temp\offword \plainnonfrenchspacing
    \else
      \errhelp = \EMsimple
!     \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
    \fi\fi
  }
  
***************
*** 662,682 ****
      \endgraf % Not \par, as it may have been set to \lisppar.
      \global\dimen1 = \prevdepth
    \egroup           % End the \vtop.
    % \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).
!   \dimen2 = \pageheight   \advance\dimen2 by -\pagetotal
    % if the group doesn't fit on the current page, and it's a big big
    % group, force a page break.
    \ifdim \dimen0 > \dimen2
!     \ifdim \pagetotal < \vfilllimit\pageheight
        \page
      \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 `@group can only ...'.
--- 682,707 ----
      \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).
!   \dimen2 = \txipageheight   \advance\dimen2 by -\pagetotal
    % if the group doesn't fit on the current page, and it's a big big
    % group, force a page break.
    \ifdim \dimen0 > \dimen2
!     \ifdim \pagetotal < \vfilllimit\txipageheight
        \page
      \fi
    \fi
    \box\groupbox
  }
+ 
  %
  % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
  % message, so this ends up printing `@group can only ...'.
***************
*** 690,704 ****
  
  \newdimen\mil  \mil=0.001in
  
- % Old definition--didn't work.
- %\parseargdef\need{\par %
- %% This method tries to make TeX break the page naturally
- %% if the depth of the box does not fit.
- %{\baselineskip=0pt%
- %\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak
- %\prevdepth=-1000pt
- %}}
- 
  \parseargdef\need{%
    % Ensure vertical mode, so we don't make a big box in the middle of a
    % paragraph.
--- 715,720 ----
***************
*** 809,844 ****
    \temp
  }
  
- % @| inserts a changebar to the left of the current line.  It should
- % surround any changed text.  This approach does *not* work if the
- % change spans more than two lines of output.  To handle that, we would
- % have adopt a much more difficult approach (putting marks into the main
- % vertical list for the beginning and end of each change).  This command
- % is not documented, not supported, and doesn't work.
- %
- \def\|{%
-   % \vadjust can only be used in horizontal mode.
-   \leavevmode
-   %
-   % Append this vertical mode material after the current line in the output.
-   \vadjust{%
-     % We want to insert a rule with the height and depth of the current
-     % leading; that is exactly what \strutbox is supposed to record.
-     \vskip-\baselineskip
-     %
-     % \vadjust-items are inserted at the left edge of the type.  So
-     % the \llap here moves out into the left-hand margin.
-     \llap{%
-       %
-       % For a thicker or thinner bar, change the `1pt'.
-       \vrule height\baselineskip width1pt
-       %
-       % This is the space between the bar and the text.
-       \hskip 12pt
-     }%
-   }%
- }
- 
  % @include FILE -- \input text of FILE.
  %
  \def\include{\parseargusing\filenamecatcodes\includezzz}
--- 825,830 ----
***************
*** 885,891 ****
  \def\popthisfilestack{\errthisfilestackempty}
  \def\errthisfilestackempty{\errmessage{Internal error:
    the stack of filenames is empty.}}
! 
  \def\thisfile{}
  
  % @center line
--- 871,877 ----
  \def\popthisfilestack{\errthisfilestackempty}
  \def\errthisfilestackempty{\errmessage{Internal error:
    the stack of filenames is empty.}}
! %
  \def\thisfile{}
  
  % @center line
***************
*** 893,929 ****
  %
  \parseargdef\center{%
    \ifhmode
!     \let\next\centerH
    \else
!     \let\next\centerV
    \fi
!   \next{\hfil \ignorespaces#1\unskip \hfil}%
  }
! \def\centerH#1{%
!   {%
!     \hfil\break
!     \advance\hsize by -\leftskip
!     \advance\hsize by -\rightskip
!     \line{#1}%
!     \break
!   }%
  }
- \def\centerV#1{\line{\kern\leftskip #1\kern\rightskip}}
  
  % @sp n   outputs n lines of vertical space
! 
  \parseargdef\sp{\vskip #1\baselineskip}
  
  % @comment ...line which is ignored...
  % @c is the same as @comment
  % @ignore ... @end ignore  is another way to write a comment
  
- \def\comment{\begingroup \catcode`\^^M=\other%
- \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
- \commentxxx}
- {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
  
! \let\c=\comment
  
  % @paragraphindent NCHARS
  % We'll use ems for NCHARS, close enough.
--- 879,926 ----
  %
  \parseargdef\center{%
    \ifhmode
!     \let\centersub\centerH
    \else
!     \let\centersub\centerV
    \fi
!   \centersub{\hfil \ignorespaces#1\unskip \hfil}%
!   \let\centersub\relax % don't let the definition persist, just in case
  }
! \def\centerH#1{{%
!   \hfil\break
!   \advance\hsize by -\leftskip
!   \advance\hsize by -\rightskip
!   \line{#1}%
!   \break
! }}
! %
! \newcount\centerpenalty
! \def\centerV#1{%
!   % The idea here is the same as in \startdefun, \cartouche, etc.: if
!   % @center is the first thing after a section heading, we need to wipe
!   % out the negative parskip inserted by \sectionheading, but still
!   % prevent a page break here.
!   \centerpenalty = \lastpenalty
!   \ifnum\centerpenalty>10000 \vskip\parskip \fi
!   \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
!   \line{\kern\leftskip #1\kern\rightskip}%
  }
  
  % @sp n   outputs n lines of vertical space
! %
  \parseargdef\sp{\vskip #1\baselineskip}
  
  % @comment ...line which is ignored...
  % @c is the same as @comment
  % @ignore ... @end ignore  is another way to write a comment
  
  
! \def\c{\begingroup \catcode`\^^M=\active%
! \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
! \cxxx}
! {\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}}
! %
! \let\comment\c
  
  % @paragraphindent NCHARS
  % We'll use ems for NCHARS, close enough.
***************
*** 994,1065 ****
  % paragraph.
  %
  \gdef\dosuppressfirstparagraphindent{%
!   \gdef\indent{%
!     \restorefirstparagraphindent
!     \indent
!   }%
!   \gdef\noindent{%
!     \restorefirstparagraphindent
!     \noindent
!   }%
!   \global\everypar = {%
!     \kern -\parindent
!     \restorefirstparagraphindent
!   }%
  }
! 
  \gdef\restorefirstparagraphindent{%
!   \global \let \indent = \ptexindent
!   \global \let \noindent = \ptexnoindent
!   \global \everypar = {}%
  }
  
  
  % @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 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}
  
  
  \message{pdf,}
--- 991,1024 ----
  % paragraph.
  %
  \gdef\dosuppressfirstparagraphindent{%
!   \gdef\indent  {\restorefirstparagraphindent \indent}%
!   \gdef\noindent{\restorefirstparagraphindent \noindent}%
!   \global\everypar = {\kern -\parindent \restorefirstparagraphindent}%
  }
! %
  \gdef\restorefirstparagraphindent{%
!   \global\let\indent = \ptexindent
!   \global\let\noindent = \ptexnoindent
!   \global\everypar = {}%
! }
! 
! % leave vertical mode without cancelling any first paragraph indent
! \gdef\imageindent{%
!   \toks0=\everypar
!   \everypar={}%
!   \ptexnoindent
!   \global\everypar=\toks0
  }
  
  
  % @refill is a no-op.
  \let\refill=\relax
  
! % @setfilename INFO-FILENAME - ignored
! \let\setfilename=\comment
  
  % @bye.
! \outer\def\bye{\chappager\pagelabels\tracingstats=1\ptexend}
  
  
  \message{pdf,}
***************
*** 1074,1087 ****
  \newtoks\toksC
  \newtoks\toksD
  \newbox\boxA
  \newcount\countA
  \newif\ifpdf
  \newif\ifpdfmakepagedest
  
  % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
! % can be set).  So we test for \relax and 0 as well as \undefined,
! % borrowed from ifpdf.sty.
! \ifx\pdfoutput\undefined
  \else
    \ifx\pdfoutput\relax
    \else
--- 1033,1130 ----
  \newtoks\toksC
  \newtoks\toksD
  \newbox\boxA
+ \newbox\boxB
  \newcount\countA
  \newif\ifpdf
  \newif\ifpdfmakepagedest
  
+ %
+ % For LuaTeX
+ %
+ 
+ \newif\iftxiuseunicodedestname
+ \txiuseunicodedestnamefalse % For pdfTeX etc.
+ 
+ \ifx\luatexversion\thisisundefined
+ \else
+   % Use Unicode destination names
+   \txiuseunicodedestnametrue
+   % Escape PDF strings with converting UTF-16 from UTF-8
+   \begingroup
+     \catcode`\%=12
+     \directlua{
+       function UTF16oct(str)
+         tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377')
+         for c in string.utfvalues(str) do
+           if c < 0x10000 then
+             tex.sprint(
+               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
+                             string.char(0x5c) .. string.char(0x25) .. '03o',
+                             math.floor(c / 256), math.floor(c % 256)))
+           else
+             c = c - 0x10000
+             local c_hi = c / 1024 + 0xd800
+             local c_lo = c % 1024 + 0xdc00
+             tex.sprint(
+               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
+                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
+                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
+                             string.char(0x5c) .. string.char(0x25) .. '03o',
+                             math.floor(c_hi / 256), math.floor(c_hi % 256),
+                             math.floor(c_lo / 256), math.floor(c_lo % 256)))
+           end
+         end
+       end
+     }
+   \endgroup
+   \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
+   % Escape PDF strings without converting
+   \begingroup
+     \directlua{
+       function PDFescstr(str)
+         for c in string.bytes(str) do
+           if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then
+             tex.sprint(-2,
+               string.format(string.char(0x5c) .. string.char(0x25) .. '03o',
+                             c))
+           else
+             tex.sprint(-2, string.char(c))
+           end
+         end
+       end
+     }
+     % The -2 in the arguments here gives all the input to TeX catcode 12
+     % (other) or 10 (space), preventing undefined control sequence errors. See
+     % https://lists.gnu.org/archive/html/bug-texinfo/2019-08/msg00031.html
+     %
+   \endgroup
+   \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}}
+   \ifnum\luatexversion>84
+     % For LuaTeX >= 0.85
+     \def\pdfdest{\pdfextension dest}
+     \let\pdfoutput\outputmode
+     \def\pdfliteral{\pdfextension literal}
+     \def\pdfcatalog{\pdfextension catalog}
+     \def\pdftexversion{\numexpr\pdffeedback version\relax}
+     \let\pdfximage\saveimageresource
+     \let\pdfrefximage\useimageresource
+     \let\pdflastximage\lastsavedimageresourceindex
+     \def\pdfendlink{\pdfextension endlink\relax}
+     \def\pdfoutline{\pdfextension outline}
+     \def\pdfstartlink{\pdfextension startlink}
+     \def\pdffontattr{\pdfextension fontattr}
+     \def\pdfobj{\pdfextension obj}
+     \def\pdflastobj{\numexpr\pdffeedback lastobj\relax}
+     \let\pdfpagewidth\pagewidth
+     \let\pdfpageheight\pageheight
+     \edef\pdfhorigin{\pdfvariable horigin}
+     \edef\pdfvorigin{\pdfvariable vorigin}
+   \fi
+ \fi
+ 
  % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
! % can be set).  So we test for \relax and 0 as well as being undefined.
! \ifx\pdfoutput\thisisundefined
  \else
    \ifx\pdfoutput\relax
    \else
***************
*** 1092,1145 ****
    \fi
  \fi
  
  % PDF uses PostScript string constants for the names of xref targets,
  % for display in the outlines, and in other places.  Thus, we have to
  % double any backslashes.  Otherwise, a name like "\node" will be
  % interpreted as a newline (\n), followed by o, d, e.  Not good.
! % http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html
! % (and related messages, the final outcome is that it is up to the TeX
! % user to double the backslashes and otherwise make the string valid, so
! % that's what we do).
! 
! % double active backslashes.
! %
! {\catcode`\@=0 \catcode`\\=\active
!  @gdef@activebackslashdouble{%
!    @catcode`@\=@active
!    @let\=@doublebackslash}
! }
! 
! % To handle parens, we must adopt a different approach, since parens are
! % not active characters.  hyperref.dtx (which has the same problem as
! % us) handles it with this amazing macro to replace tokens, with minor
! % changes for Texinfo.  It is included here under the GPL by permission
! % from the author, Heiko Oberdiek.
! %
! % #1 is the tokens to replace.
! % #2 is the replacement.
! % #3 is the control sequence with the string.
! %
! \def\HyPsdSubst#1#2#3{%
!   \def\HyPsdReplace##1#1##2\END{%
!     ##1%
!     \ifx\\##2\\%
!     \else
!       #2%
!       \HyReturnAfterFi{%
!         \HyPsdReplace##2\END
!       }%
!     \fi
!   }%
!   \xdef#3{\expandafter\HyPsdReplace#3#1\END}%
! }
! \long\def\HyReturnAfterFi#1\fi{\fi#1}
! 
! % #1 is a control sequence in which to do the replacements.
! \def\backslashparens#1{%
!   \xdef#1{#1}% redefine it as its expansion; the definition is simply
!              % \lastnode when called from \setref -> \pdfmkdest.
!   \HyPsdSubst{(}{\realbackslash(}{#1}%
!   \HyPsdSubst{)}{\realbackslash)}{#1}%
  }
  
  \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
--- 1135,1220 ----
    \fi
  \fi
  
+ \newif\ifpdforxetex
+ \pdforxetexfalse
+ \ifpdf
+   \pdforxetextrue
+ \fi
+ \ifx\XeTeXrevision\thisisundefined\else
+   \pdforxetextrue
+ \fi
+ 
+ 
+ % Output page labels information.
+ % See PDF reference v.1.7 p.594, section 8.3.1.
+ \ifpdf
+ \def\pagelabels{%
+   \def\title{0 << /P (T-) /S /D >>}%
+   \edef\roman{\the\romancount << /S /r >>}%
+   \edef\arabic{\the\arabiccount << /S /D >>}%
+   %
+   % Page label ranges must be increasing.  Remove any duplicates.
+   % (There is a slight chance of this being wrong if e.g. there is
+   % a @contents but no @titlepage, etc.)
+   %
+   \ifnum\romancount=0 \def\roman{}\fi
+   \ifnum\arabiccount=0 \def\title{}%
+   \else
+     \ifnum\romancount=\arabiccount \def\roman{}\fi
+   \fi
+   %
+   \ifnum\romancount<\arabiccount
+     \pdfcatalog{/PageLabels << /Nums [\title \roman \arabic ] >> }\relax
+   \else
+     \pdfcatalog{/PageLabels << /Nums [\title \arabic \roman ] >> }\relax
+   \fi
+ }
+ \else
+   \let\pagelabels\relax
+ \fi
+ 
+ \newcount\pagecount \pagecount=0
+ \newcount\romancount \romancount=0
+ \newcount\arabiccount \arabiccount=0
+ \ifpdf
+   \let\ptxadvancepageno\advancepageno
+   \def\advancepageno{%
+     \ptxadvancepageno\global\advance\pagecount by 1
+   }
+ \fi
+ 
+ 
  % PDF uses PostScript string constants for the names of xref targets,
  % for display in the outlines, and in other places.  Thus, we have to
  % double any backslashes.  Otherwise, a name like "\node" will be
  % interpreted as a newline (\n), followed by o, d, e.  Not good.
! %
! % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
! % related messages.  The final outcome is that it is up to the TeX user
! % to double the backslashes and otherwise make the string valid, so
! % that's what we do.  pdftex 1.30.0 (ca.2005) introduced a primitive to
! % do this reliably, so we use it.
! 
! % #1 is a control sequence in which to do the replacements,
! % which we \xdef.
! \def\txiescapepdf#1{%
!   \ifx\pdfescapestring\thisisundefined
!     % No primitive available; should we give a warning or log?
!     % Many times it won't matter.
!     \xdef#1{#1}%
!   \else
!     % The expandable \pdfescapestring primitive escapes parentheses,
!     % backslashes, and other special chars.
!     \xdef#1{\pdfescapestring{#1}}%
!   \fi
! }
! \def\txiescapepdfutfsixteen#1{%
!   \ifx\pdfescapestrutfsixteen\thisisundefined
!     % No UTF-16 converting macro available.
!     \txiescapepdf{#1}%
!   \else
!     \xdef#1{\pdfescapestrutfsixteen{#1}}%
!   \fi
  }
  
  \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
***************
*** 1149,1169 ****
  
  \ifpdf
    %
!   % Color manipulation macros based on pdfcolor.tex,
    % except using rgb instead of cmyk; the latter is said to render as a
    % very dark gray on-screen and a very dark halftone in print, instead
!   % of actual black.
    \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).
    \def\pdfsetcolor#1{\pdfliteral{#1 rg  #1 RG}}
    %
    % Set color, and create a mark which defines \thiscolor accordingly,
    % so that \makeheadline knows which color to restore.
    \def\setcolor#1{%
!     \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
      \domark
      \pdfsetcolor{#1}%
    }
--- 1224,1246 ----
  
  \ifpdf
    %
!   % Color manipulation macros using ideas from pdfcolor.tex,
    % except using rgb instead of cmyk; the latter is said to render as a
    % very dark gray on-screen and a very dark halftone in print, instead
!   % of actual black. The dark red here is dark enough to print on paper as
!   % nearly black, but still distinguishable for online viewing.  We use
!   % black by default, though.
    \def\rgbDarkRed{0.50 0.09 0.12}
    \def\rgbBlack{0 0 0}
    %
!   % 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,
    % so that \makeheadline knows which color to restore.
    \def\setcolor#1{%
!     \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
      \domark
      \pdfsetcolor{#1}%
    }
***************
*** 1171,1177 ****
    \def\maincolor{\rgbBlack}
    \pdfsetcolor{\maincolor}
    \edef\thiscolor{\maincolor}
!   \def\lastcolordefs{}
    %
    \def\makefootline{%
      \baselineskip24pt
--- 1248,1254 ----
    \def\maincolor{\rgbBlack}
    \pdfsetcolor{\maincolor}
    \edef\thiscolor{\maincolor}
!   \def\currentcolordefs{}
    %
    \def\makefootline{%
      \baselineskip24pt
***************
*** 1198,1229 ****
    %
    % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
    \def\dopdfimage#1#2#3{%
!     \def\imagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
!     \def\imageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
      %
!     % pdftex (and the PDF format) support .png, .jpg, .pdf (among
!     % others).  Let's try in that order.
      \let\pdfimgext=\empty
      \begingroup
!       \openin 1 #1.png \ifeof 1
!         \openin 1 #1.jpg \ifeof 1
!           \openin 1 #1.jpeg \ifeof 1
!             \openin 1 #1.JPG \ifeof 1
!               \openin 1 #1.pdf \ifeof 1
!                 \openin 1 #1.PDF \ifeof 1
                    \errhelp = \nopdfimagehelp
                    \errmessage{Could not find image file #1 for pdf}%
!                 \else \gdef\pdfimgext{PDF}%
                  \fi
!               \else \gdef\pdfimgext{pdf}%
                \fi
!             \else \gdef\pdfimgext{JPG}%
              \fi
!           \else \gdef\pdfimgext{jpeg}%
            \fi
!         \else \gdef\pdfimgext{jpg}%
          \fi
!       \else \gdef\pdfimgext{png}%
        \fi
        \closein 1
      \endgroup
--- 1275,1308 ----
    %
    % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
    \def\dopdfimage#1#2#3{%
!     \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
!     \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
      %
!     % pdftex (and the PDF format) support .pdf, .png, .jpg (among
!     % others).  Let's try in that order, PDF first since if
!     % someone has a scalable image, presumably better to use that than a
!     % bitmap.
      \let\pdfimgext=\empty
      \begingroup
!       \openin 1 #1.pdf \ifeof 1
!         \openin 1 #1.PDF \ifeof 1
!           \openin 1 #1.png \ifeof 1
!             \openin 1 #1.jpg \ifeof 1
!               \openin 1 #1.jpeg \ifeof 1
!                 \openin 1 #1.JPG \ifeof 1
                    \errhelp = \nopdfimagehelp
                    \errmessage{Could not find image file #1 for pdf}%
!                 \else \gdef\pdfimgext{JPG}%
                  \fi
!               \else \gdef\pdfimgext{jpeg}%
                \fi
!             \else \gdef\pdfimgext{jpg}%
              \fi
!           \else \gdef\pdfimgext{png}%
            \fi
!         \else \gdef\pdfimgext{PDF}%
          \fi
!       \else \gdef\pdfimgext{pdf}%
        \fi
        \closein 1
      \endgroup
***************
*** 1235,1242 ****
      \else
        \immediate\pdfximage
      \fi
!       \ifdim \wd0 >0pt width \imagewidth \fi
!       \ifdim \wd2 >0pt height \imageheight \fi
        \ifnum\pdftexversion<13
           #1.\pdfimgext
         \else
--- 1314,1321 ----
      \else
        \immediate\pdfximage
      \fi
!       \ifdim \wd0 >0pt width \pdfimagewidth \fi
!       \ifdim \wd2 >0pt height \pdfimageheight \fi
        \ifnum\pdftexversion<13
           #1.\pdfimgext
         \else
***************
*** 1246,1270 ****
        \pdfrefximage \pdflastximage
      \fi}
    %
!   \def\pdfmkdest#1{{%
      % We have to set dummies so commands such as @code, and characters
      % such as \, aren't expanded when present in a section title.
      \indexnofonts
-     \turnoffactive
-     \activebackslashdouble
      \makevalueexpandable
      \def\pdfdestname{#1}%
!     \backslashparens\pdfdestname
!     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
    }}
    %
    % used to mark target names; must be expandable.
    \def\pdfmkpgn#1{#1}
    %
!   % by default, use a color that is dark enough to print on paper as
!   % nearly black, but still distinguishable for online viewing.
!   \def\urlcolor{\rgbDarkRed}
!   \def\linkcolor{\rgbDarkRed}
    \def\endlink{\setcolor{\maincolor}\pdfendlink}
    %
    % Adding outlines to PDF; macros for calculating structure of outlines
--- 1325,1407 ----
        \pdfrefximage \pdflastximage
      \fi}
    %
!   \def\setpdfdestname#1{{%
      % We have to set dummies so commands such as @code, and characters
      % such as \, aren't expanded when present in a section title.
      \indexnofonts
      \makevalueexpandable
+     \turnoffactive
+     \iftxiuseunicodedestname
+       \ifx \declaredencoding \latone
+         % Pass through Latin-1 characters.
+         % LuaTeX with byte wise I/O converts Latin-1 characters to Unicode.
+       \else
+         \ifx \declaredencoding \utfeight
+           % Pass through Unicode characters.
+         \else
+           % Use ASCII approximations in destination names.
+           \passthroughcharsfalse
+         \fi
+       \fi
+     \else
+       % Use ASCII approximations in destination names.
+       \passthroughcharsfalse
+     \fi
      \def\pdfdestname{#1}%
!     \txiescapepdf\pdfdestname
!   }}
!   %
!   \def\setpdfoutlinetext#1{{%
!     \indexnofonts
!     \makevalueexpandable
!     \turnoffactive
!     \ifx \declaredencoding \latone
!       % The PDF format can use an extended form of Latin-1 in bookmark
!       % strings.  See Appendix D of the PDF Reference, Sixth Edition, for
!       % the "PDFDocEncoding".
!       \passthroughcharstrue
!       % Pass through Latin-1 characters.
!       %   LuaTeX: Convert to Unicode
!       %   pdfTeX: Use Latin-1 as PDFDocEncoding
!       \def\pdfoutlinetext{#1}%
!     \else
!       \ifx \declaredencoding \utfeight
!         \ifx\luatexversion\thisisundefined
!           % For pdfTeX  with UTF-8.
!           % TODO: the PDF format can use UTF-16 in bookmark strings,
!           % but the code for this isn't done yet.
!           % Use ASCII approximations.
!           \passthroughcharsfalse
!           \def\pdfoutlinetext{#1}%
!         \else
!           % For LuaTeX with UTF-8.
!           % Pass through Unicode characters for title texts.
!           \passthroughcharstrue
!           \def\pdfoutlinetext{#1}%
!         \fi
!       \else
!         % For non-Latin-1 or non-UTF-8 encodings.
!         % Use ASCII approximations.
!         \passthroughcharsfalse
!         \def\pdfoutlinetext{#1}%
!       \fi
!     \fi
!     % LuaTeX: Convert to UTF-16
!     % pdfTeX: Use Latin-1 as PDFDocEncoding
!     \txiescapepdfutfsixteen\pdfoutlinetext
    }}
    %
+   \def\pdfmkdest#1{%
+     \setpdfdestname{#1}%
+     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
+   }
+   %
    % used to mark target names; must be expandable.
    \def\pdfmkpgn#1{#1}
    %
!   % by default, use black for everything.
!   \def\urlcolor{\rgbBlack}
!   \def\linkcolor{\rgbBlack}
    \def\endlink{\setcolor{\maincolor}\pdfendlink}
    %
    % Adding outlines to PDF; macros for calculating structure of outlines
***************
*** 1286,1313 ****
      % page number.  We could generate a destination for the section
      % text in the case where a section has no node, but it doesn't
      % seem worth the trouble, since most documents are normally structured.
!     \def\pdfoutlinedest{#3}%
!     \ifx\pdfoutlinedest\empty
!       \def\pdfoutlinedest{#4}%
!     \else
!       % Doubled backslashes in the name.
!       {\activebackslashdouble \xdef\pdfoutlinedest{#3}%
!        \backslashparens\pdfoutlinedest}%
      \fi
      %
!     % Also double the backslashes in the display string.
!     {\activebackslashdouble \xdef\pdfoutlinetext{#1}%
!      \backslashparens\pdfoutlinetext}%
!     %
!     \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
    }
    %
    \def\pdfmakeoutlines{%
      \begingroup
-       % Thanh's hack / proper braces in bookmarks
-       \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace
-       \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace
-       %
        % Read toc silently, to get counts of subentries for \pdfoutline.
        \def\partentry##1##2##3##4{}% ignore parts in the outlines
        \def\numchapentry##1##2##3##4{%
--- 1423,1439 ----
      % page number.  We could generate a destination for the section
      % text in the case where a section has no node, but it doesn't
      % seem worth the trouble, since most documents are normally structured.
!     \setpdfoutlinetext{#1}
!     \setpdfdestname{#3}
!     \ifx\pdfdestname\empty
!       \def\pdfdestname{#4}%
      \fi
      %
!     \pdfoutline goto name{\pdfmkpgn{\pdfdestname}}#2{\pdfoutlinetext}%
    }
    %
    \def\pdfmakeoutlines{%
      \begingroup
        % Read toc silently, to get counts of subentries for \pdfoutline.
        \def\partentry##1##2##3##4{}% ignore parts in the outlines
        \def\numchapentry##1##2##3##4{%
***************
*** 1348,1354 ****
--- 1474,1486 ----
        % subentries, which we calculated on our first read of the .toc above.
        %
        % We use the node names as the destinations.
+       %
+       % Currently we prefix the section name with the section number
+       % for chapter and appendix headings only in order to avoid too much
+       % horizontal space being required in the PDF viewer.
        \def\numchapentry##1##2##3##4{%
+         \dopdfoutline{##2 ##1}{count-\expnumber{chap##2}}{##3}{##4}}%
+       \def\unnchapentry##1##2##3##4{%
          \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
        \def\numsecentry##1##2##3##4{%
          \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
***************
*** 1363,1387 ****
        % Latin 2 (0xea) gets translated to a | character.  Info from
        % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
        %
!       % xx to do this right, we have to translate 8-bit characters to
!       % their "best" equivalent, based on the @documentencoding.  Right
!       % now, I guess we'll just let the pdf reader have its way.
        \indexnofonts
        \setupdatafile
        \catcode`\\=\active \otherbackslash
        \input \tocreadfilename
      \endgroup
    }
    %
    \def\skipspaces#1{\def\PP{#1}\def\D{|}%
      \ifx\PP\D\let\nextsp\relax
      \else\let\nextsp\skipspaces
!       \ifx\p\space\else\addtokens{\filename}{\PP}%
!         \advance\filenamelength by 1
!       \fi
      \fi
      \nextsp}
!   \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax}
    \ifnum\pdftexversion < 14
      \let \startlink \pdfannotlink
    \else
--- 1495,1535 ----
        % Latin 2 (0xea) gets translated to a | character.  Info from
        % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
        %
!       % TODO this right, we have to translate 8-bit characters to
!       % their "best" equivalent, based on the @documentencoding.  Too
!       % much work for too little return.  Just use the ASCII equivalents
!       % we use for the index sort strings.
!       %
        \indexnofonts
        \setupdatafile
+       % We can have normal brace characters in the PDF outlines, unlike
+       % Texinfo index files.  So set that up.
+       \def\{{\lbracecharliteral}%
+       \def\}{\rbracecharliteral}%
        \catcode`\\=\active \otherbackslash
        \input \tocreadfilename
      \endgroup
    }
+   {\catcode`[=1 \catcode`]=2
+    \catcode`{=\other \catcode`}=\other
+    \gdef\lbracecharliteral[{]%
+    \gdef\rbracecharliteral[}]%
+   ]
    %
    \def\skipspaces#1{\def\PP{#1}\def\D{|}%
      \ifx\PP\D\let\nextsp\relax
      \else\let\nextsp\skipspaces
!       \addtokens{\filename}{\PP}%
!       \advance\filenamelength by 1
      \fi
      \nextsp}
!   \def\getfilename#1{%
!     \filenamelength=0
!     % If we don't expand the argument now, \skipspaces will get
!     % snagged on things like "@value{foo}".
!     \edef\temp{#1}%
!     \expandafter\skipspaces\temp|\relax
!   }
    \ifnum\pdftexversion < 14
      \let \startlink \pdfannotlink
    \else
***************
*** 1407,1412 ****
--- 1555,1563 ----
        \startlink attr{/Border [0 0 0]}%
          user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
      \endgroup}
+   % \pdfgettoks - Surround page numbers in #1 with @pdflink.  #1 may
+   % be a simple number, or a list of numbers in the case of an index
+   % entry.
    \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
    \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
    \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
***************
*** 1442,1531 ****
    \let\pdfmakeoutlines = \relax
  \fi  % \ifx\pdfoutput
  
- 
- \message{fonts,}
- 
- % Change the current font style to #1, remembering it in \curfontstyle.
- % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
- % italics, not bold italics.
- %
- \def\setfontstyle#1{%
-   \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
-   \csname ten#1\endcsname  % change the current font
- }
- 
- % Select #1 fonts with the current style.
- %
- \def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname}
- 
- \def\rm{\fam=0 \setfontstyle{rm}}
- \def\it{\fam=\itfam \setfontstyle{it}}
- \def\sl{\fam=\slfam \setfontstyle{sl}}
- \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
- \def\tt{\fam=\ttfam \setfontstyle{tt}}
- 
- % Unfortunately, we have to override this for titles and the like, since
- % in those cases "rm" is bold.  Sigh.
- \def\rmisbold{\rm\def\curfontstyle{bf}}
- 
- % Texinfo sort of supports the sans serif font style, which plain TeX does not.
- % So we set up a \sf.
- \newfam\sffam
- \def\sf{\fam=\sffam \setfontstyle{sf}}
- \let\li = \sf % Sometimes we call it \li, not \sf.
- 
- % We don't need math for this font style.
- \def\ttsl{\setfontstyle{ttsl}}
- 
- 
- % Default leading.
- \newdimen\textleading  \textleading = 13.2pt
- 
- % Set the baselineskip to #1, and the lineskip and strut size
- % correspondingly.  There is no deep meaning behind these magic numbers
- % used as factors; they just match (closely enough) what Knuth defined.
- %
- \def\lineskipfactor{.08333}
- \def\strutheightpercent{.70833}
- \def\strutdepthpercent {.29167}
- %
- % can get a sort of poor man's double spacing by redefining this.
- \def\baselinefactor{1}
  %
! \def\setleading#1{%
!   \dimen0 = #1\relax
!   \normalbaselineskip = \baselinefactor\dimen0
!   \normallineskip = \lineskipfactor\normalbaselineskip
!   \normalbaselines
!   \setbox\strutbox =\hbox{%
!     \vrule width0pt height\strutheightpercent\baselineskip
!                     depth \strutdepthpercent \baselineskip
!   }%
! }
! 
! % PDF CMaps.  See also LaTeX's t1.cmap.
  %
! % do nothing with this by default.
! \expandafter\let\csname cmapOT1\endcsname\gobble
! \expandafter\let\csname cmapOT1IT\endcsname\gobble
! \expandafter\let\csname cmapOT1TT\endcsname\gobble
! 
! % if we are producing pdf, and we have \pdffontattr, then define cmaps.
! % (\pdffontattr was introduced many years ago, but people still run
! % older pdftex's; it's easy to conditionalize, so we do.)
! \ifpdf \ifx\pdffontattr\undefined \else
!   \begingroup
!     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
!     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
! %%DocumentNeededResources: ProcSet (CIDInit)
! %%IncludeResource: ProcSet (CIDInit)
! %%BeginResource: CMap (TeX-OT1-0)
! %%Title: (TeX-OT1-0 TeX OT1 0)
! %%Version: 1.000
! %%EndComments
! /CIDInit /ProcSet findresource begin
! 12 dict begin
! begincmap
  /CIDSystemInfo
  << /Registry (TeX)
  /Ordering (OT1)
--- 1593,1945 ----
    \let\pdfmakeoutlines = \relax
  \fi  % \ifx\pdfoutput
  
  %
! % For XeTeX
  %
! \ifx\XeTeXrevision\thisisundefined
! \else
!   %
!   % XeTeX version check
!   %
!   \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99996}>-1
!     % TeX Live 2016 contains XeTeX 0.99996 and xdvipdfmx 20160307.
!     % It can use the `dvipdfmx:config' special (from TeX Live SVN r40941).
!     % For avoiding PDF destination name replacement, we use this special
!     % instead of xdvipdfmx's command line option `-C 0x0010'.
!     \special{dvipdfmx:config C 0x0010}
!     % XeTeX 0.99995+ comes with xdvipdfmx 20160307+.
!     % It can handle Unicode destination names for PDF.
!     \txiuseunicodedestnametrue
!   \else
!     % XeTeX < 0.99996 (TeX Live < 2016) cannot use the
!     % `dvipdfmx:config' special.
!     % So for avoiding PDF destination name replacement,
!     % xdvipdfmx's command line option `-C 0x0010' is necessary.
!     %
!     % XeTeX < 0.99995 can not handle Unicode destination names for PDF
!     % because xdvipdfmx 20150315 has a UTF-16 conversion issue.
!     % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
!     \txiuseunicodedestnamefalse
!   \fi
!   %
!   % Color support
!   %
!   \def\rgbDarkRed{0.50 0.09 0.12}
!   \def\rgbBlack{0 0 0}
!   %
!   \def\pdfsetcolor#1{\special{pdf:scolor [#1]}}
!   %
!   % Set color, and create a mark which defines \thiscolor accordingly,
!   % so that \makeheadline knows which color to restore.
!   \def\setcolor#1{%
!     \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
!     \domark
!     \pdfsetcolor{#1}%
!   }
!   %
!   \def\maincolor{\rgbBlack}
!   \pdfsetcolor{\maincolor}
!   \edef\thiscolor{\maincolor}
!   \def\currentcolordefs{}
!   %
!   \def\makefootline{%
!     \baselineskip24pt
!     \line{\pdfsetcolor{\maincolor}\the\footline}%
!   }
!   %
!   \def\makeheadline{%
!     \vbox to 0pt{%
!       \vskip-22.5pt
!       \line{%
!         \vbox to8.5pt{}%
!         % Extract \thiscolor definition from the marks.
!         \getcolormarks
!         % Typeset the headline with \maincolor, then restore the color.
!         \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
!       }%
!       \vss
!     }%
!     \nointerlineskip
!   }
!   %
!   % PDF outline support
!   %
!   % Emulate pdfTeX primitive
!   \def\pdfdest name#1 xyz{%
!     \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}%
!   }
!   %
!   \def\setpdfdestname#1{{%
!     % We have to set dummies so commands such as @code, and characters
!     % such as \, aren't expanded when present in a section title.
!     \indexnofonts
!     \makevalueexpandable
!     \turnoffactive
!     \iftxiuseunicodedestname
!       % Pass through Unicode characters.
!     \else
!       % Use ASCII approximations in destination names.
!       \passthroughcharsfalse
!     \fi
!     \def\pdfdestname{#1}%
!     \txiescapepdf\pdfdestname
!   }}
!   %
!   \def\setpdfoutlinetext#1{{%
!     \turnoffactive
!     % Always use Unicode characters in title texts.
!     \def\pdfoutlinetext{#1}%
!     % For XeTeX, xdvipdfmx converts to UTF-16.
!     % So we do not convert.
!     \txiescapepdf\pdfoutlinetext
!   }}
!   %
!   \def\pdfmkdest#1{%
!     \setpdfdestname{#1}%
!     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
!   }
!   %
!   % by default, use black for everything.
!   \def\urlcolor{\rgbBlack}
!   \def\linkcolor{\rgbBlack}
!   \def\endlink{\setcolor{\maincolor}\pdfendlink}
!   %
!   \def\dopdfoutline#1#2#3#4{%
!     \setpdfoutlinetext{#1}
!     \setpdfdestname{#3}
!     \ifx\pdfdestname\empty
!       \def\pdfdestname{#4}%
!     \fi
!     %
!     \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A
!       << /S /GoTo /D (\pdfdestname) >> >> }%
!   }
!   %
!   \def\pdfmakeoutlines{%
!     \begingroup
!       %
!       % For XeTeX, counts of subentries are not necessary.
!       % Therefore, we read toc only once.
!       %
!       % We use node names as destinations.
!       %
!       % Currently we prefix the section name with the section number
!       % for chapter and appendix headings only in order to avoid too much
!       % horizontal space being required in the PDF viewer.
!       \def\partentry##1##2##3##4{}% ignore parts in the outlines
!       \def\numchapentry##1##2##3##4{%
!         \dopdfoutline{##2 ##1}{1}{##3}{##4}}%
!       \def\numsecentry##1##2##3##4{%
!         \dopdfoutline{##1}{2}{##3}{##4}}%
!       \def\numsubsecentry##1##2##3##4{%
!         \dopdfoutline{##1}{3}{##3}{##4}}%
!       \def\numsubsubsecentry##1##2##3##4{%
!         \dopdfoutline{##1}{4}{##3}{##4}}%
!       %
!       \let\appentry\numchapentry%
!       \let\appsecentry\numsecentry%
!       \let\appsubsecentry\numsubsecentry%
!       \let\appsubsubsecentry\numsubsubsecentry%
!       \def\unnchapentry##1##2##3##4{%
!         \dopdfoutline{##1}{1}{##3}{##4}}%
!       \let\unnsecentry\numsecentry%
!       \let\unnsubsecentry\numsubsecentry%
!       \let\unnsubsubsecentry\numsubsubsecentry%
!       %
!       % For XeTeX, xdvipdfmx converts strings to UTF-16.
!       % Therefore, the encoding and the language may not be considered.
!       %
!       \indexnofonts
!       \setupdatafile
!       % We can have normal brace characters in the PDF outlines, unlike
!       % Texinfo index files.  So set that up.
!       \def\{{\lbracecharliteral}%
!       \def\}{\rbracecharliteral}%
!       \catcode`\\=\active \otherbackslash
!       \input \tocreadfilename
!     \endgroup
!   }
!   {\catcode`[=1 \catcode`]=2
!    \catcode`{=\other \catcode`}=\other
!    \gdef\lbracecharliteral[{]%
!    \gdef\rbracecharliteral[}]%
!   ]
! 
!   \special{pdf:docview << /PageMode /UseOutlines >> }
!   % ``\special{pdf:tounicode ...}'' is not necessary
!   % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it.
!   % However, due to a UTF-16 conversion issue of xdvipdfmx 20150315,
!   % ``\special{pdf:dest ...}'' cannot handle non-ASCII strings.
!   % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
! %
!   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
!     \ifx\PP\D\let\nextsp\relax
!     \else\let\nextsp\skipspaces
!       \addtokens{\filename}{\PP}%
!       \advance\filenamelength by 1
!     \fi
!     \nextsp}
!   \def\getfilename#1{%
!     \filenamelength=0
!     % If we don't expand the argument now, \skipspaces will get
!     % snagged on things like "@value{foo}".
!     \edef\temp{#1}%
!     \expandafter\skipspaces\temp|\relax
!   }
!   % make a live url in pdf output.
!   \def\pdfurl#1{%
!     \begingroup
!       % it seems we really need yet another set of dummies; have not
!       % tried to figure out what each command should do in the context
!       % of @url.  for now, just make @/ a no-op, that's the only one
!       % people have actually reported a problem with.
!       %
!       \normalturnoffactive
!       \def\@{@}%
!       \let\/=\empty
!       \makevalueexpandable
!       % do we want to go so far as to use \indexnofonts instead of just
!       % special-casing \var here?
!       \def\var##1{##1}%
!       %
!       \leavevmode\setcolor{\urlcolor}%
!       \special{pdf:bann << /Border [0 0 0]
!         /Subtype /Link /A << /S /URI /URI (#1) >> >>}%
!     \endgroup}
!   \def\endlink{\setcolor{\maincolor}\special{pdf:eann}}
!   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
!   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
!   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
!   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
!   \def\maketoks{%
!     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
!     \ifx\first0\adn0
!     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
!     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
!     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
!     \else
!       \ifnum0=\countA\else\makelink\fi
!       \ifx\first.\let\next=\done\else
!         \let\next=\maketoks
!         \addtokens{\toksB}{\the\toksD}
!         \ifx\first,\addtokens{\toksB}{\space}\fi
!       \fi
!     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
!     \next}
!   \def\makelink{\addtokens{\toksB}%
!     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
!   \def\pdflink#1{%
!     \special{pdf:bann << /Border [0 0 0]
!       /Type /Annot /Subtype /Link /A << /S /GoTo /D (#1) >> >>}%
!     \setcolor{\linkcolor}#1\endlink}
!   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
! %
!   %
!   % @image support
!   %
!   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
!   \def\doxeteximage#1#2#3{%
!     \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
!     \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
!     %
!     % XeTeX (and the PDF format) supports .pdf, .png, .jpg (among
!     % others).  Let's try in that order, PDF first since if
!     % someone has a scalable image, presumably better to use that than a
!     % bitmap.
!     \let\xeteximgext=\empty
!     \begingroup
!       \openin 1 #1.pdf \ifeof 1
!         \openin 1 #1.PDF \ifeof 1
!           \openin 1 #1.png \ifeof 1
!             \openin 1 #1.jpg \ifeof 1
!               \openin 1 #1.jpeg \ifeof 1
!                 \openin 1 #1.JPG \ifeof 1
!                   \errmessage{Could not find image file #1 for XeTeX}%
!                 \else \gdef\xeteximgext{JPG}%
!                 \fi
!               \else \gdef\xeteximgext{jpeg}%
!               \fi
!             \else \gdef\xeteximgext{jpg}%
!             \fi
!           \else \gdef\xeteximgext{png}%
!           \fi
!         \else \gdef\xeteximgext{PDF}%
!         \fi
!       \else \gdef\xeteximgext{pdf}%
!       \fi
!       \closein 1
!     \endgroup
!     %
!     % Putting an \hbox around the image can prevent an over-long line
!     % after the image.
!     \hbox\bgroup
!       \def\xetexpdfext{pdf}%
!       \ifx\xeteximgext\xetexpdfext
!         \XeTeXpdffile "#1".\xeteximgext ""
!       \else
!         \def\xetexpdfext{PDF}%
!         \ifx\xeteximgext\xetexpdfext
!           \XeTeXpdffile "#1".\xeteximgext ""
!         \else
!           \XeTeXpicfile "#1".\xeteximgext ""
!         \fi
!       \fi
!       \ifdim \wd0 >0pt width \xeteximagewidth \fi
!       \ifdim \wd2 >0pt height \xeteximageheight \fi \relax
!     \egroup
!   }
! \fi
! 
! 
! %
! \message{fonts,}
! 
! % Set the baselineskip to #1, and the lineskip and strut size
! % correspondingly.  There is no deep meaning behind these magic numbers
! % used as factors; they just match (closely enough) what Knuth defined.
! %
! \def\lineskipfactor{.08333}
! \def\strutheightpercent{.70833}
! \def\strutdepthpercent {.29167}
! %
! % can get a sort of poor man's double spacing by redefining this.
! \def\baselinefactor{1}
! %
! \newdimen\textleading
! \def\setleading#1{%
!   \dimen0 = #1\relax
!   \normalbaselineskip = \baselinefactor\dimen0
!   \normallineskip = \lineskipfactor\normalbaselineskip
!   \normalbaselines
!   \setbox\strutbox =\hbox{%
!     \vrule width0pt height\strutheightpercent\baselineskip
!                     depth \strutdepthpercent \baselineskip
!   }%
! }
! 
! % PDF CMaps.  See also LaTeX's t1.cmap.
! %
! % do nothing with this by default.
! \expandafter\let\csname cmapOT1\endcsname\gobble
! \expandafter\let\csname cmapOT1IT\endcsname\gobble
! \expandafter\let\csname cmapOT1TT\endcsname\gobble
! 
! % if we are producing pdf, and we have \pdffontattr, then define cmaps.
! % (\pdffontattr was introduced many years ago, but people still run
! % older pdftex's; it's easy to conditionalize, so we do.)
! \ifpdf \ifx\pdffontattr\thisisundefined \else
!   \begingroup
!     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
!     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
! %%DocumentNeededResources: ProcSet (CIDInit)
! %%IncludeResource: ProcSet (CIDInit)
! %%BeginResource: CMap (TeX-OT1-0)
! %%Title: (TeX-OT1-0 TeX OT1 0)
! %%Version: 1.000
! %%EndComments
! /CIDInit /ProcSet findresource begin
! 12 dict begin
! begincmap
  /CIDSystemInfo
  << /Registry (TeX)
  /Ordering (OT1)
***************
*** 1764,1791 ****
  \fi\fi
  
  
! % Set the font macro #1 to the font named #2, adding on the
! % specified font prefix (normally `cm').
  % #3 is the font's design size, #4 is a scale factor, #5 is the CMap
! % encoding (currently only OT1, OT1IT and OT1TT are allowed, pass
! % empty to omit).
  \def\setfont#1#2#3#4#5{%
    \font#1=\fontprefix#2#3 scaled #4
    \csname cmap#5\endcsname#1%
  }
  % This is what gets called when #5 of \setfont is empty.
  \let\cmap\gobble
! % emacs-page end of cmaps
  
  % Use cm as the default font prefix.
  % To specify the font prefix, you must define \fontprefix
  % before you read in texinfo.tex.
! \ifx\fontprefix\undefined
  \def\fontprefix{cm}
  \fi
  % Support font families that don't use the same naming scheme as CM.
  \def\rmshape{r}
! \def\rmbshape{bx}               %where the normal face is bold
  \def\bfshape{b}
  \def\bxshape{bx}
  \def\ttshape{tt}
--- 2178,2211 ----
  \fi\fi
  
  
! % Set the font macro #1 to the font named \fontprefix#2.
  % #3 is the font's design size, #4 is a scale factor, #5 is the CMap
! % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
! % Example:
! % #1 = \textrm
! % #2 = \rmshape
! % #3 = 10
! % #4 = \mainmagstep
! % #5 = OT1
! %
  \def\setfont#1#2#3#4#5{%
    \font#1=\fontprefix#2#3 scaled #4
    \csname cmap#5\endcsname#1%
  }
  % This is what gets called when #5 of \setfont is empty.
  \let\cmap\gobble
! %
! % (end of cmaps)
  
  % Use cm as the default font prefix.
  % To specify the font prefix, you must define \fontprefix
  % before you read in texinfo.tex.
! \ifx\fontprefix\thisisundefined
  \def\fontprefix{cm}
  \fi
  % Support font families that don't use the same naming scheme as CM.
  \def\rmshape{r}
! \def\rmbshape{bx}               % where the normal face is bold
  \def\bfshape{b}
  \def\bxshape{bx}
  \def\ttshape{tt}
***************
*** 1800,1807 ****
  \def\scshape{csc}
  \def\scbshape{csc}
  
! % Definitions for a main text size of 11pt.  This is the default in
! % Texinfo.
  %
  \def\definetextfontsizexi{%
  % Text fonts (11.2pt, magstep1).
--- 2220,2226 ----
  \def\scshape{csc}
  \def\scbshape{csc}
  
! % Definitions for a main text size of 11pt.  (The default in Texinfo.)
  %
  \def\definetextfontsizexi{%
  % Text fonts (11.2pt, magstep1).
***************
*** 1822,1829 ****
  % A few fonts for @defun names and args.
  \setfont\defbf\bfshape{10}{\magstep1}{OT1}
  \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
  \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
! \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
  
  % Fonts for indices, footnotes, small examples (9pt).
  \def\smallnominalsize{9pt}
--- 2241,2250 ----
  % A few fonts for @defun names and args.
  \setfont\defbf\bfshape{10}{\magstep1}{OT1}
  \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
+ \setfont\defsl\slshape{10}{\magstep1}{OT1}
  \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
! \def\df{\let\ttfont=\deftt \let\bffont = \defbf
! \let\ttslfont=\defttsl \let\slfont=\defsl \bf}
  
  % Fonts for indices, footnotes, small examples (9pt).
  \def\smallnominalsize{9pt}
***************
*** 1853,1858 ****
--- 2274,2293 ----
  \font\smallersy=cmsy8
  \def\smallerecsize{0800}
  
+ % Fonts for math mode superscripts (7pt).
+ \def\sevennominalsize{7pt}
+ \setfont\sevenrm\rmshape{7}{1000}{OT1}
+ \setfont\seventt\ttshape{10}{700}{OT1TT}
+ \setfont\sevenbf\bfshape{10}{700}{OT1}
+ \setfont\sevenit\itshape{7}{1000}{OT1IT}
+ \setfont\sevensl\slshape{10}{700}{OT1}
+ \setfont\sevensf\sfshape{10}{700}{OT1}
+ \setfont\sevensc\scshape{10}{700}{OT1}
+ \setfont\seventtsl\ttslshape{10}{700}{OT1TT}
+ \font\seveni=cmmi7
+ \font\sevensy=cmsy7
+ \def\sevenecsize{0700}
+ 
  % Fonts for title page (20.4pt):
  \def\titlenominalsize{20pt}
  \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
***************
*** 1884,1889 ****
--- 2319,2325 ----
  % 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}
***************
*** 1909,1915 ****
  \font\ssecsy=cmsy10 scaled 1315
  \def\ssececsize{1200}
  
! % Reduced fonts for @acro in text (10pt).
  \def\reducednominalsize{10pt}
  \setfont\reducedrm\rmshape{10}{1000}{OT1}
  \setfont\reducedtt\ttshape{10}{1000}{OT1TT}
--- 2345,2351 ----
  \font\ssecsy=cmsy10 scaled 1315
  \def\ssececsize{1200}
  
! % Reduced fonts for @acronym in text (10pt).
  \def\reducednominalsize{10pt}
  \setfont\reducedrm\rmshape{10}{1000}{OT1}
  \setfont\reducedtt\ttshape{10}{1000}{OT1TT}
***************
*** 1926,1932 ****
  \textleading = 13.2pt % line spacing for 11pt CM
  \textfonts            % reset the current fonts
  \rm
! } % end of 11pt text font size definitions
  
  
  % Definitions to make the main text be 10pt Computer Modern, with
--- 2362,2368 ----
  \textleading = 13.2pt % line spacing for 11pt CM
  \textfonts            % reset the current fonts
  \rm
! } % end of 11pt text font size definitions, \definetextfontsizexi
  
  
  % Definitions to make the main text be 10pt Computer Modern, with
***************
*** 1953,1960 ****
  % A few fonts for @defun names and args.
  \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
  \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
  \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
! \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
  
  % Fonts for indices, footnotes, small examples (9pt).
  \def\smallnominalsize{9pt}
--- 2389,2398 ----
  % A few fonts for @defun names and args.
  \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
  \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
+ \setfont\defsl\slshape{10}{\magstephalf}{OT1}
  \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
! \def\df{\let\ttfont=\deftt \let\bffont = \defbf
! \let\slfont=\defsl \let\ttslfont=\defttsl \bf}
  
  % Fonts for indices, footnotes, small examples (9pt).
  \def\smallnominalsize{9pt}
***************
*** 1984,1989 ****
--- 2422,2441 ----
  \font\smallersy=cmsy8
  \def\smallerecsize{0800}
  
+ % Fonts for math mode superscripts (7pt).
+ \def\sevennominalsize{7pt}
+ \setfont\sevenrm\rmshape{7}{1000}{OT1}
+ \setfont\seventt\ttshape{10}{700}{OT1TT}
+ \setfont\sevenbf\bfshape{10}{700}{OT1}
+ \setfont\sevenit\itshape{7}{1000}{OT1IT}
+ \setfont\sevensl\slshape{10}{700}{OT1}
+ \setfont\sevensf\sfshape{10}{700}{OT1}
+ \setfont\sevensc\scshape{10}{700}{OT1}
+ \setfont\seventtsl\ttslshape{10}{700}{OT1TT}
+ \font\seveni=cmmi7
+ \font\sevensy=cmsy7
+ \def\sevenecsize{0700}
+ 
  % Fonts for title page (20.4pt):
  \def\titlenominalsize{20pt}
  \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
***************
*** 2040,2046 ****
  \font\ssecsy=cmsy10
  \def\ssececsize{1000}
  
! % Reduced fonts for @acro in text (9pt).
  \def\reducednominalsize{9pt}
  \setfont\reducedrm\rmshape{9}{1000}{OT1}
  \setfont\reducedtt\ttshape{9}{1000}{OT1TT}
--- 2492,2498 ----
  \font\ssecsy=cmsy10
  \def\ssececsize{1000}
  
! % Reduced fonts for @acronym in text (9pt).
  \def\reducednominalsize{9pt}
  \setfont\reducedrm\rmshape{9}{1000}{OT1}
  \setfont\reducedtt\ttshape{9}{1000}{OT1TT}
***************
*** 2058,2064 ****
  \textleading = 12pt   % line spacing for 10pt CM
  \textfonts            % reset the current fonts
  \rm
! } % end of 10pt text font size definitions
  
  
  % We provide the user-level command
--- 2510,2522 ----
  \textleading = 12pt   % line spacing for 10pt CM
  \textfonts            % reset the current fonts
  \rm
! } % end of 10pt text font size definitions, \definetextfontsizex
! 
! % Fonts for short table of contents.
! \setfont\shortcontrm\rmshape{12}{1000}{OT1}
! \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1}  % no cmb12
! \setfont\shortcontsl\slshape{12}{1000}{OT1}
! \setfont\shortconttt\ttshape{12}{1000}{OT1TT}
  
  
  % We provide the user-level command
***************
*** 2086,2187 ****
   \endgroup
  }
  
  
  % In order for the font changes to affect most math symbols and letters,
! % we have to define the \textfont of the standard families.  Since
! % texinfo doesn't allow for producing subscripts and superscripts except
! % in the main text, we don't bother to reset \scriptfont and
! % \scriptscriptfont (which would also require loading a lot more fonts).
  %
  \def\resetmathfonts{%
!   \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy
!   \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf
!   \textfont\ttfam=\tentt \textfont\sffam=\tensf
  }
  
! % The font-changing commands redefine the meanings of \tenSTYLE, instead
! % of just \STYLE.  We do this because \STYLE needs to also set the
! % current \fam for math mode.  Our \STYLE (e.g., \rm) commands hardwire
! % \tenSTYLE to set the current font.
  %
  % Each font-changing command also sets the names \lsize (one size lower)
! % and \lllsize (three sizes lower).  These relative commands are used in
! % the LaTeX logo and acronyms.
  %
  % This all needs generalizing, badly.
  %
- \def\textfonts{%
-   \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
-   \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
-   \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
-   \let\tenttsl=\textttsl
-   \def\curfontsize{text}%
-   \def\lsize{reduced}\def\lllsize{smaller}%
-   \resetmathfonts \setleading{\textleading}}
- \def\titlefonts{%
-   \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
-   \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
-   \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
-   \let\tenttsl=\titlettsl
-   \def\curfontsize{title}%
-   \def\lsize{chap}\def\lllsize{subsec}%
-   \resetmathfonts \setleading{27pt}}
- \def\titlefont#1{{\titlefonts\rmisbold #1}}
- \def\chapfonts{%
-   \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
-   \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
-   \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
-   \let\tenttsl=\chapttsl
-   \def\curfontsize{chap}%
-   \def\lsize{sec}\def\lllsize{text}%
-   \resetmathfonts \setleading{19pt}}
- \def\secfonts{%
-   \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
-   \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
-   \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
-   \let\tenttsl=\secttsl
-   \def\curfontsize{sec}%
-   \def\lsize{subsec}\def\lllsize{reduced}%
-   \resetmathfonts \setleading{16pt}}
- \def\subsecfonts{%
-   \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
-   \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
-   \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
-   \let\tenttsl=\ssecttsl
-   \def\curfontsize{ssec}%
-   \def\lsize{text}\def\lllsize{small}%
-   \resetmathfonts \setleading{15pt}}
- \let\subsubsecfonts = \subsecfonts
- \def\reducedfonts{%
-   \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl
-   \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc
-   \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy
-   \let\tenttsl=\reducedttsl
-   \def\curfontsize{reduced}%
-   \def\lsize{small}\def\lllsize{smaller}%
-   \resetmathfonts \setleading{10.5pt}}
- \def\smallfonts{%
-   \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
-   \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
-   \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
-   \let\tenttsl=\smallttsl
-   \def\curfontsize{small}%
-   \def\lsize{smaller}\def\lllsize{smaller}%
-   \resetmathfonts \setleading{10.5pt}}
- \def\smallerfonts{%
-   \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl
-   \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc
-   \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy
-   \let\tenttsl=\smallerttsl
-   \def\curfontsize{smaller}%
-   \def\lsize{smaller}\def\lllsize{smaller}%
-   \resetmathfonts \setleading{9.5pt}}
  
! % Fonts for short table of contents.
! \setfont\shortcontrm\rmshape{12}{1000}{OT1}
! \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1}  % no cmb12
! \setfont\shortcontsl\slshape{12}{1000}{OT1}
! \setfont\shortconttt\ttshape{12}{1000}{OT1TT}
  
  % Define these just so they can be easily changed for other fonts.
  \def\angleleft{$\langle$}
--- 2544,2664 ----
   \endgroup
  }
  
+ %
+ % Change the current font style to #1, remembering it in \curfontstyle.
+ % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
+ % italics, not bold italics.
+ %
+ \def\setfontstyle#1{%
+   \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
+   \csname #1font\endcsname  % change the current font
+ }
+ 
+ \def\rm{\fam=0 \setfontstyle{rm}}
+ \def\it{\fam=\itfam \setfontstyle{it}}
+ \def\sl{\fam=\slfam \setfontstyle{sl}}
+ \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
+ \def\tt{\fam=\ttfam \setfontstyle{tt}}\def\ttstylename{tt}
+ 
+ % Texinfo sort of supports the sans serif font style, which plain TeX does not.
+ % So we set up a \sf.
+ \newfam\sffam
+ \def\sf{\fam=\sffam \setfontstyle{sf}}
+ 
+ % We don't need math for this font style.
+ \def\ttsl{\setfontstyle{ttsl}}
+ 
  
  % In order for the font changes to affect most math symbols and letters,
! % we have to define the \textfont of the standard families.
! % We don't bother to reset \scriptscriptfont; awaiting user need.
  %
  \def\resetmathfonts{%
!   \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont
!   \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont
!   \textfont\ttfam=\ttfont \textfont\sffam=\sffont
!   %
!   % Fonts for superscript.  Note that the 7pt fonts are used regardless
!   % of the current font size.
!   \scriptfont0=\sevenrm \scriptfont1=\seveni \scriptfont2=\sevensy
!   \scriptfont\itfam=\sevenit \scriptfont\slfam=\sevensl
!   \scriptfont\bffam=\sevenbf \scriptfont\ttfam=\seventt
!   \scriptfont\sffam=\sevensf
  }
  
! %
! 
! % The font-changing commands (all called \...fonts) redefine the meanings
! % of \STYLEfont, instead of just \STYLE.  We do this because \STYLE needs
! % to also set the current \fam for math mode.  Our \STYLE (e.g., \rm)
! % commands hardwire \STYLEfont to set the current font.
! %
! % The fonts used for \ifont are for "math italics"  (\itfont is for italics
! % in regular text).  \syfont is also used in math mode only.
  %
  % Each font-changing command also sets the names \lsize (one size lower)
! % and \lllsize (three sizes lower).  These relative commands are used
! % in, e.g., the LaTeX logo and acronyms.
  %
  % This all needs generalizing, badly.
  %
  
! \def\assignfonts#1{%
!   \expandafter\let\expandafter\rmfont\csname #1rm\endcsname
!   \expandafter\let\expandafter\itfont\csname #1it\endcsname
!   \expandafter\let\expandafter\slfont\csname #1sl\endcsname
!   \expandafter\let\expandafter\bffont\csname #1bf\endcsname
!   \expandafter\let\expandafter\ttfont\csname #1tt\endcsname
!   \expandafter\let\expandafter\smallcaps\csname #1sc\endcsname
!   \expandafter\let\expandafter\sffont  \csname #1sf\endcsname
!   \expandafter\let\expandafter\ifont   \csname #1i\endcsname
!   \expandafter\let\expandafter\syfont  \csname #1sy\endcsname
!   \expandafter\let\expandafter\ttslfont\csname #1ttsl\endcsname
! }
! 
! \newif\ifrmisbold
! 
! % Select smaller font size with the current style.  Used to change font size
! % in, e.g., the LaTeX logo and acronyms.  If we are using bold fonts for
! % normal roman text, also use bold fonts for roman text in the smaller size.
! \def\switchtolllsize{%
!    \expandafter\assignfonts\expandafter{\lllsize}%
!    \ifrmisbold
!      \let\rmfont\bffont
!    \fi
!    \csname\curfontstyle\endcsname
! }%
! 
! \def\switchtolsize{%
!    \expandafter\assignfonts\expandafter{\lsize}%
!    \ifrmisbold
!      \let\rmfont\bffont
!    \fi
!    \csname\curfontstyle\endcsname
! }%
! 
! \def\definefontsetatsize#1#2#3#4#5{%
! \expandafter\def\csname #1fonts\endcsname{%
!   \def\curfontsize{#1}%
!   \def\lsize{#2}\def\lllsize{#3}%
!   \csname rmisbold#5\endcsname
!   \assignfonts{#1}%
!   \resetmathfonts
!   \setleading{#4}%
! }}
! 
! \definefontsetatsize{text}   {reduced}{smaller}{\textleading}{false}
! \definefontsetatsize{title}  {chap}   {subsec} {27pt}  {true}
! \definefontsetatsize{chap}   {sec}    {text}   {19pt}  {true}
! \definefontsetatsize{sec}    {subsec} {reduced}{17pt}  {true}
! \definefontsetatsize{ssec}   {text}   {small}  {15pt}  {true}
! \definefontsetatsize{reduced}{small}  {smaller}{10.5pt}{false}
! \definefontsetatsize{small}  {smaller}{smaller}{10.5pt}{false}
! \definefontsetatsize{smaller}{smaller}{smaller}{9.5pt} {false}
! 
! \def\titlefont#1{{\titlefonts\rm #1}}
! \let\subsecfonts = \ssecfonts
! \let\subsubsecfonts = \ssecfonts
  
  % Define these just so they can be easily changed for other fonts.
  \def\angleleft{$\langle$}
***************
*** 2207,2214 ****
  \definetextfontsizexi
  
  
- \message{markup,}
- 
  % Check if we are currently using a typewriter font.  Since all the
  % Computer Modern typewriter fonts have zero interword stretch (and
  % shrink), and it is reasonable to expect all typewriter fonts to have
--- 2684,2689 ----
***************
*** 2216,2310 ****
  %
  \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
  
- % Markup style infrastructure.  \defmarkupstylesetup\INITMACRO will
- % define and register \INITMACRO to be called on markup style changes.
- % \INITMACRO can check \currentmarkupstyle for the innermost
- % style and the set of \ifmarkupSTYLE switches for all styles
- % currently in effect.
- \newif\ifmarkupvar
- \newif\ifmarkupsamp
- \newif\ifmarkupkey
- %\newif\ifmarkupfile % @file == @samp.
- %\newif\ifmarkupoption % @option == @samp.
- \newif\ifmarkupcode
- \newif\ifmarkupkbd
- %\newif\ifmarkupenv % @env == @code.
- %\newif\ifmarkupcommand % @command == @code.
- \newif\ifmarkuptex % @tex (and part of @math, for now).
- \newif\ifmarkupexample
- \newif\ifmarkupverb
- \newif\ifmarkupverbatim
- 
- \let\currentmarkupstyle\empty
- 
- \def\setupmarkupstyle#1{%
-   \csname markup#1true\endcsname
-   \def\currentmarkupstyle{#1}%
-   \markupstylesetup
- }
- 
- \let\markupstylesetup\empty
- 
- \def\defmarkupstylesetup#1{%
-   \expandafter\def\expandafter\markupstylesetup
-     \expandafter{\markupstylesetup #1}%
-   \def#1%
- }
- 
- % Markup style setup for left and right quotes.
- \defmarkupstylesetup\markupsetuplq{%
-   \expandafter\let\expandafter \temp \csname markupsetuplq\currentmarkupstyle\endcsname
-   \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
- }
- 
- \defmarkupstylesetup\markupsetuprq{%
-   \expandafter\let\expandafter \temp \csname markupsetuprq\currentmarkupstyle\endcsname
-   \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
- }
- 
  {
  \catcode`\'=\active
  \catcode`\`=\active
  
! \gdef\markupsetuplqdefault{\let`\lq}
! \gdef\markupsetuprqdefault{\let'\rq}
! 
! \gdef\markupsetcodequoteleft{\let`\codequoteleft}
! \gdef\markupsetcodequoteright{\let'\codequoteright}
! 
! \gdef\markupsetnoligaturesquoteleft{\let`\noligaturesquoteleft}
  }
  
! \let\markupsetuplqcode \markupsetcodequoteleft
! \let\markupsetuprqcode \markupsetcodequoteright
! %
! \let\markupsetuplqexample \markupsetcodequoteleft
! \let\markupsetuprqexample \markupsetcodequoteright
! %
! \let\markupsetuplqsamp \markupsetcodequoteleft
! \let\markupsetuprqsamp \markupsetcodequoteright
! %
! \let\markupsetuplqverb \markupsetcodequoteleft
! \let\markupsetuprqverb \markupsetcodequoteright
! %
! \let\markupsetuplqverbatim \markupsetcodequoteleft
! \let\markupsetuprqverbatim \markupsetcodequoteright
! 
! \let\markupsetuplqkbd \markupsetnoligaturesquoteleft
! 
! % Allow an option to not replace quotes with a regular directed right
! % quote/apostrophe (char 0x27), but instead use the undirected quote
! % from cmtt (char 0x0d).  The undirected quote is ugly, so don't make it
! % the default, but it works for pasting with more pdf viewers (at least
! % evince), the lilypond developers report.  xpdf does work with the
! % regular 0x27.
  %
  \def\codequoteright{%
!   \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
!     \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
!       '%
      \else \char'15 \fi
!   \else \char'15 \fi
  }
  %
  % and a similar option for the left quote char vs. a grave accent.
--- 2691,2720 ----
  %
  \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
  
  {
  \catcode`\'=\active
  \catcode`\`=\active
  
! \gdef\setcodequotes{\let`\codequoteleft \let'\codequoteright}
! \gdef\setregularquotes{\let`\lq \let'\rq}
  }
  
! % Allow an option to not use regular directed right quote/apostrophe
! % (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
! % The undirected quote is ugly, so don't make it the default, but it
! % works for pasting with more pdf viewers (at least evince), the
! % lilypond developers report.  xpdf does work with the regular 0x27.
  %
  \def\codequoteright{%
!   \ifmonospace
!     \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
!       \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
!         '%
!       \else \char'15 \fi
      \else \char'15 \fi
!    \else
!      '%
!    \fi
  }
  %
  % and a similar option for the left quote char vs. a grave accent.
***************
*** 2312,2324 ****
  % the code environments to do likewise.
  %
  \def\codequoteleft{%
!   \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
!     \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
!       % [Knuth] pp. 380,381,391
!       % \relax disables Spanish ligatures ?` and !` of \tt font.
!       \relax`%
      \else \char'22 \fi
!   \else \char'22 \fi
  }
  
  % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
--- 2722,2768 ----
  % the code environments to do likewise.
  %
  \def\codequoteleft{%
!   \ifmonospace
!     \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
!       \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
!         % [Knuth] pp. 380,381,391
!         % \relax disables Spanish ligatures ?` and !` of \tt font.
!         \relax`%
!       \else \char'22 \fi
      \else \char'22 \fi
!    \else
!      \relax`%
!    \fi
! }
! 
! % Commands to set the quote options.
! %
! \parseargdef\codequoteundirected{%
!   \def\temp{#1}%
!   \ifx\temp\onword
!     \expandafter\let\csname SETtxicodequoteundirected\endcsname
!       = t%
!   \else\ifx\temp\offword
!     \expandafter\let\csname SETtxicodequoteundirected\endcsname
!       = \relax
!   \else
!     \errhelp = \EMsimple
!     \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
!   \fi\fi
! }
! %
! \parseargdef\codequotebacktick{%
!   \def\temp{#1}%
!   \ifx\temp\onword
!     \expandafter\let\csname SETtxicodequotebacktick\endcsname
!       = t%
!   \else\ifx\temp\offword
!     \expandafter\let\csname SETtxicodequotebacktick\endcsname
!       = \relax
!   \else
!     \errhelp = \EMsimple
!     \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
!   \fi\fi
  }
  
  % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
***************
*** 2333,2339 ****
  % If we are in a monospaced environment, however, 1) always use \ttsl,
  % and 2) do not add an italic correction.
  \def\dosmartslant#1#2{%
!   \ifusingtt 
      {{\ttsl #2}\let\next=\relax}%
      {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
    \next
--- 2777,2783 ----
  % If we are in a monospaced environment, however, 1) always use \ttsl,
  % and 2) do not add an italic correction.
  \def\dosmartslant#1#2{%
!   \ifusingtt
      {{\ttsl #2}\let\next=\relax}%
      {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
    \next
***************
*** 2347,2366 ****
    \ifx\next,%
    \else\ifx\next-%
    \else\ifx\next.%
    \else\ptexslash
!   \fi\fi\fi}
  
! % like \smartslanted except unconditionally uses \ttsl, and no ic.
! % @var is set to this for defun arguments.
  \def\ttslanted#1{{\ttsl #1}}
  
  % @cite is like \smartslanted except unconditionally use \sl.  We never want
  % ttsl for book titles, do we?
  \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
  
  \let\i=\smartitalic
  \let\slanted=\smartslanted
- \def\var#1{\smartslanted{#1}}
  \let\dfn=\smartslanted
  \let\emph=\smartitalic
  
--- 2791,2819 ----
    \ifx\next,%
    \else\ifx\next-%
    \else\ifx\next.%
+   \else\ifx\next\.%
+   \else\ifx\next\comma%
    \else\ptexslash
!   \fi\fi\fi\fi\fi
!   \aftersmartic
! }
  
! % Unconditional use \ttsl, and no ic.  @var is set to this for defuns.
  \def\ttslanted#1{{\ttsl #1}}
  
  % @cite is like \smartslanted except unconditionally use \sl.  We never want
  % ttsl for book titles, do we?
  \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
  
+ \def\aftersmartic{}
+ \def\var#1{%
+   \let\saveaftersmartic = \aftersmartic
+   \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
+   \smartslanted{#1}%
+ }
+ 
  \let\i=\smartitalic
  \let\slanted=\smartslanted
  \let\dfn=\smartslanted
  \let\emph=\smartitalic
  
***************
*** 2389,2396 ****
  %
  \catcode`@=11
    \def\plainfrenchspacing{%
!     \sfcode\dotChar  =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m
!     \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m
      \def\endofsentencespacefactor{1000}% for @. and friends
    }
    \def\plainnonfrenchspacing{%
--- 2842,2849 ----
  %
  \catcode`@=11
    \def\plainfrenchspacing{%
!     \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m
!     \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m
      \def\endofsentencespacefactor{1000}% for @. and friends
    }
    \def\plainnonfrenchspacing{%
***************
*** 2403,2443 ****
  
  % @t, explicit typewriter.
  \def\t#1{%
!   {\tt \rawbackslash \plainfrenchspacing #1}%
    \null
  }
  
  % @samp.
! \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
! 
! % definition of @key that produces a lozenge.  Doesn't adjust to text size.
! %\setfont\keyrm\rmshape{8}{1000}{OT1}
! %\font\keysy=cmsy9
! %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
! %  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
! %    \vbox{\hrule\kern-0.4pt
! %     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
! %    \kern-0.4pt\hrule}%
! %  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
! 
! % definition of @key with no lozenge.  If the current font is already
! % monospace, don't change it; that way, we respect @kbdinputstyle.  But
! % if it isn't monospace, then use \tt.
! %
! \def\key#1{{\setupmarkupstyle{key}%
!   \nohyphenation
!   \ifmonospace\else\tt\fi
!   #1}\null}
! 
! % ctrl is no longer a Texinfo command.
! \def\ctrl #1{{\tt \rawbackslash \hat}#1}
  
! % @file, @option are the same as @samp.
! \let\file=\samp
! \let\option=\samp
  
! % @code is a modification of @t,
! % which makes spaces the same size as normal in the surrounding text.
  \def\tclose#1{%
    {%
      % Change normal interword space to be same as for the current font.
--- 2856,2874 ----
  
  % @t, explicit typewriter.
  \def\t#1{%
!   {\tt \plainfrenchspacing #1}%
    \null
  }
  
  % @samp.
! \def\samp#1{{\setcodequotes\lq\tclose{#1}\rq\null}}
  
! % @indicateurl is \samp, that is, with quotes.
! \let\indicateurl=\samp
  
! % @code (and similar) prints in typewriter, but with spaces the same
! % size as normal in the surrounding text, without hyphenation, etc.
! % This is a subroutine for that.
  \def\tclose#1{%
    {%
      % Change normal interword space to be same as for the current font.
***************
*** 2452,2495 ****
      % Turn off hyphenation.
      \nohyphenation
      %
-     \rawbackslash
      \plainfrenchspacing
      #1%
    }%
!   \null
  }
  
  % We *must* turn on hyphenation at `-' and `_' in @code.
  % Otherwise, it is too hard to avoid overfull hboxes
  % in the Emacs manual, the Library manual, etc.
! 
  % Unfortunately, TeX uses one parameter (\hyphenchar) to control
  % both hyphenation at - and hyphenation within words.
  % We must therefore turn them both off (\tclose does that)
! % and arrange explicitly to hyphenate at a dash.
! %  -- rms.
  {
    \catcode`\-=\active \catcode`\_=\active
    \catcode`\'=\active \catcode`\`=\active
    \global\let'=\rq \global\let`=\lq  % default definitions
    %
    \global\def\code{\begingroup
!     \setupmarkupstyle{code}%
!     % The following should really be moved into \setupmarkupstyle handlers.
      \catcode\dashChar=\active  \catcode\underChar=\active
      \ifallowcodebreaks
       \let-\codedash
       \let_\codeunder
      \else
!      \let-\realdash
       \let_\realunder
      \fi
      \codex
    }
  }
  
- \def\realdash{-}
- \def\codedash{-\discretionary{}{}{}}
  \def\codeunder{%
    % this is all so @math{@code{var_name}+1} can work.  In math mode, _
    % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
--- 2883,2947 ----
      % Turn off hyphenation.
      \nohyphenation
      %
      \plainfrenchspacing
      #1%
    }%
!   \null % reset spacefactor to 1000
  }
  
  % We *must* turn on hyphenation at `-' and `_' in @code.
+ % (But see \codedashfinish below.)
  % Otherwise, it is too hard to avoid overfull hboxes
  % in the Emacs manual, the Library manual, etc.
! %
  % Unfortunately, TeX uses one parameter (\hyphenchar) to control
  % both hyphenation at - and hyphenation within words.
  % We must therefore turn them both off (\tclose does that)
! % and arrange explicitly to hyphenate at a dash. -- rms.
  {
    \catcode`\-=\active \catcode`\_=\active
    \catcode`\'=\active \catcode`\`=\active
    \global\let'=\rq \global\let`=\lq  % default definitions
    %
    \global\def\code{\begingroup
!     \setcodequotes
      \catcode\dashChar=\active  \catcode\underChar=\active
      \ifallowcodebreaks
       \let-\codedash
       \let_\codeunder
      \else
!      \let-\normaldash
       \let_\realunder
      \fi
+     % Given -foo (with a single dash), we do not want to allow a break
+     % after the hyphen.
+     \global\let\codedashprev=\codedash
+     %
      \codex
    }
+   %
+   \gdef\codedash{\futurelet\next\codedashfinish}
+   \gdef\codedashfinish{%
+     \normaldash % always output the dash character itself.
+     %
+     % Now, output a discretionary to allow a line break, unless
+     % (a) the next character is a -, or
+     % (b) the preceding character is a -.
+     % E.g., given --posix, we do not want to allow a break after either -.
+     % Given --foo-bar, we do want to allow a break between the - and the b.
+     \ifx\next\codedash \else
+       \ifx\codedashprev\codedash
+       \else \discretionary{}{}{}\fi
+     \fi
+     % we need the space after the = for the case when \next itself is a
+     % space token; it would get swallowed otherwise.  As in @code{- a}.
+     \global\let\codedashprev= \next
+   }
  }
+ \def\normaldash{-}
+ %
+ \def\codex #1{\tclose{#1}\endgroup}
  
  \def\codeunder{%
    % this is all so @math{@code{var_name}+1} can work.  In math mode, _
    % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
***************
*** 2501,2512 ****
               \discretionary{}{}{}}%
              {\_}%
  }
- \def\codex #1{\tclose{#1}\endgroup}
  
  % An additional complication: the above will allow breaks after, e.g.,
! % each of the four underscores in __typeof__.  This is undesirable in
! % some manuals, especially if they don't have long identifiers in
! % general.  @allowcodebreaks provides a way to control this.
  %
  \newif\ifallowcodebreaks  \allowcodebreakstrue
  
--- 2953,2963 ----
               \discretionary{}{}{}}%
              {\_}%
  }
  
  % An additional complication: the above will allow breaks after, e.g.,
! % each of the four underscores in __typeof__.  This is bad.
! % @allowcodebreaks provides a document-level way to turn breaking at -
! % and _ on and off.
  %
  \newif\ifallowcodebreaks  \allowcodebreakstrue
  
***************
*** 2521,2533 ****
      \allowcodebreaksfalse
    \else
      \errhelp = \EMsimple
!     \errmessage{Unknown @allowcodebreaks option `\txiarg'}%
    \fi\fi
  }
  
! % @kbd is like @code, except that if the argument is just one @key command,
! % then @kbd has no effect.
! \def\kbd#1{{\setupmarkupstyle{kbd}\def\look{#1}\expandafter\kbdfoo\look??\par}}
  
  % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
  %   `example' (@kbd uses ttsl only inside of @example and friends),
--- 2972,3152 ----
      \allowcodebreaksfalse
    \else
      \errhelp = \EMsimple
!     \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
    \fi\fi
  }
  
! % For @command, @env, @file, @option quotes seem unnecessary,
! % so use \code rather than \samp.
! \let\command=\code
! \let\env=\code
! \let\file=\code
! \let\option=\code
! 
! % @uref (abbreviation for `urlref') aka @url takes an optional
! % (comma-separated) second argument specifying the text to display and
! % an optional third arg as text to display instead of (rather than in
! % addition to) the url itself.  First (mandatory) arg is the url.
! 
! % TeX-only option to allow changing PDF output to show only the second
! % arg (if given), and not the url (which is then just the link target).
! \newif\ifurefurlonlylink
! 
! % The default \pretolerance setting stops the penalty inserted in
! % \urefallowbreak being a discouragement to line breaking.  Set it to
! % a negative value for this paragraph only.  Hopefully this does not
! % conflict with redefinitions of \par done elsewhere.
! \def\nopretolerance{%
! \pretolerance=-1
! \def\par{\endgraf\pretolerance=100 \let\par\endgraf}%
! }
! 
! % The main macro is \urefbreak, which allows breaking at expected
! % places within the url.
! \def\urefbreak{\nopretolerance \begingroup \urefcatcodes \dourefbreak}
! \let\uref=\urefbreak
! %
! \def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
! \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
!   \unsepspaces
!   \pdfurl{#1}%
!   \setbox0 = \hbox{\ignorespaces #3}%
!   \ifdim\wd0 > 0pt
!     \unhbox0 % third arg given, show only that
!   \else
!     \setbox0 = \hbox{\ignorespaces #2}% look for second arg
!     \ifdim\wd0 > 0pt
!       \ifpdf
!         % For pdfTeX and LuaTeX
!         \ifurefurlonlylink
!           % PDF plus option to not display url, show just arg
!           \unhbox0
!         \else
!           % PDF, normally display both arg and url for consistency,
!           % visibility, if the pdf is eventually used to print, etc.
!           \unhbox0\ (\urefcode{#1})%
!         \fi
!       \else
!         \ifx\XeTeXrevision\thisisundefined
!           \unhbox0\ (\urefcode{#1})% DVI, always show arg and url
!         \else
!           % For XeTeX
!           \ifurefurlonlylink
!             % PDF plus option to not display url, show just arg
!             \unhbox0
!           \else
!             % PDF, normally display both arg and url for consistency,
!             % visibility, if the pdf is eventually used to print, etc.
!             \unhbox0\ (\urefcode{#1})%
!           \fi
!         \fi
!       \fi
!     \else
!       \urefcode{#1}% only url given, so show it
!     \fi
!   \fi
!   \endlink
! \endgroup}
! 
! % Allow line breaks around only a few characters (only).
! \def\urefcatcodes{%
!   \catcode`\&=\active \catcode`\.=\active
!   \catcode`\#=\active \catcode`\?=\active
!   \catcode`\/=\active
! }
! {
!   \urefcatcodes
!   %
!   \global\def\urefcode{\begingroup
!     \setcodequotes
!     \urefcatcodes
!     \let&\urefcodeamp
!     \let.\urefcodedot
!     \let#\urefcodehash
!     \let?\urefcodequest
!     \let/\urefcodeslash
!     \codex
!   }
!   %
!   % By default, they are just regular characters.
!   \global\def&{\normalamp}
!   \global\def.{\normaldot}
!   \global\def#{\normalhash}
!   \global\def?{\normalquest}
!   \global\def/{\normalslash}
! }
! 
! \def\urefcodeamp{\urefprebreak \&\urefpostbreak}
! \def\urefcodedot{\urefprebreak .\urefpostbreak}
! \def\urefcodehash{\urefprebreak \#\urefpostbreak}
! \def\urefcodequest{\urefprebreak ?\urefpostbreak}
! \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
! {
!   \catcode`\/=\active
!   \global\def\urefcodeslashfinish{%
!     \urefprebreak \slashChar
!     % Allow line break only after the final / in a sequence of
!     % slashes, to avoid line break between the slashes in http://.
!     \ifx\next/\else \urefpostbreak \fi
!   }
! }
! 
! % By default we'll break after the special characters, but some people like to
! % break before the special chars, so allow that.  Also allow no breaking at
! % all, for manual control.
! %
! \parseargdef\urefbreakstyle{%
!   \def\txiarg{#1}%
!   \ifx\txiarg\wordnone
!     \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
!   \else\ifx\txiarg\wordbefore
!     \def\urefprebreak{\urefallowbreak}\def\urefpostbreak{\nobreak}
!   \else\ifx\txiarg\wordafter
!     \def\urefprebreak{\nobreak}\def\urefpostbreak{\urefallowbreak}
!   \else
!     \errhelp = \EMsimple
!     \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
!   \fi\fi\fi
! }
! \def\wordafter{after}
! \def\wordbefore{before}
! \def\wordnone{none}
! 
! % Allow a ragged right output to aid breaking long URL's.  There can
! % be a break at the \allowbreak with no extra glue (if the existing stretch in
! % the line is sufficient), a break at the \penalty with extra glue added
! % at the end of the line, or no break at all here.
! %   Changing the value of the penalty and/or the amount of stretch affects how
! % preferable one choice is over the other.
! \def\urefallowbreak{%
!   \penalty0\relax
!   \hskip 0pt plus 2 em\relax
!   \penalty1000\relax
!   \hskip 0pt plus -2 em\relax
! }
! 
! \urefbreakstyle after
! 
! % @url synonym for @uref, since that's how everyone uses it.
! %
! \let\url=\uref
! 
! % rms does not like angle brackets --karl, 17may97.
! % So now @email is just like @uref, unless we are pdf.
! %
! %\def\email#1{\angleleft{\tt #1}\angleright}
! \ifpdforxetex
!   \def\email#1{\doemail#1,,\finish}
!   \def\doemail#1,#2,#3\finish{\begingroup
!     \unsepspaces
!     \pdfurl{mailto:#1}%
!     \setbox0 = \hbox{\ignorespaces #2}%
!     \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
!     \endlink
!   \endgroup}
! \else
!   \let\email=\uref
! \fi
  
  % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
  %   `example' (@kbd uses ttsl only inside of @example and friends),
***************
*** 2542,2548 ****
      \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
    \else
      \errhelp = \EMsimple
!     \errmessage{Unknown @kbdinputstyle option `\txiarg'}%
    \fi\fi\fi
  }
  \def\worddistinct{distinct}
--- 3161,3167 ----
      \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
    \else
      \errhelp = \EMsimple
!     \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
    \fi\fi\fi
  }
  \def\worddistinct{distinct}
***************
*** 2552,2567 ****
  % Default is `distinct'.
  \kbdinputstyle distinct
  
  \def\xkey{\key}
! \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
! \ifx\one\xkey\ifx\threex\three \key{#2}%
! \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
! \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi}
  
! % For @indicateurl, @env, @command quotes seem unnecessary, so use \code.
! \let\indicateurl=\code
! \let\env=\code
! \let\command=\code
  
  % @clicksequence{File @click{} Open ...}
  \def\clicksequence#1{\begingroup #1\endgroup}
--- 3171,3206 ----
  % Default is `distinct'.
  \kbdinputstyle distinct
  
+ % @kbd is like @code, except that if the argument is just one @key command,
+ % then @kbd has no effect.
+ \def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
+ 
  \def\xkey{\key}
! \def\kbdsub#1#2#3\par{%
!   \def\one{#1}\def\three{#3}\def\threex{??}%
!   \ifx\one\xkey\ifx\threex\three \key{#2}%
!   \else{\tclose{\kbdfont\setcodequotes\look}}\fi
!   \else{\tclose{\kbdfont\setcodequotes\look}}\fi
! }
  
! % definition of @key that produces a lozenge.  Doesn't adjust to text size.
! %\setfont\keyrm\rmshape{8}{1000}{OT1}
! %\font\keysy=cmsy9
! %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
! %  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
! %    \vbox{\hrule\kern-0.4pt
! %     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
! %    \kern-0.4pt\hrule}%
! %  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
! 
! % definition of @key with no lozenge.  If the current font is already
! % monospace, don't change it; that way, we respect @kbdinputstyle.  But
! % if it isn't monospace, then use \tt.
! %
! \def\key#1{{\setregularquotes
!   \nohyphenation
!   \ifmonospace\else\tt\fi
!   #1}\null}
  
  % @clicksequence{File @click{} Open ...}
  \def\clicksequence#1{\begingroup #1\endgroup}
***************
*** 2570,2645 ****
  \parseargdef\clickstyle{\def\click{#1}}
  \def\click{\arrow}
  
- % @uref (abbreviation for `urlref') takes an optional (comma-separated)
- % second argument specifying the text to display and an optional third
- % arg as text to display instead of (rather than in addition to) the url
- % itself.  First (mandatory) arg is the url.  Perhaps eventually put in
- % a hypertex \special here.
- %
- \def\uref#1{\douref #1,,,\finish}
- \def\douref#1,#2,#3,#4\finish{\begingroup
-   \unsepspaces
-   \pdfurl{#1}%
-   \setbox0 = \hbox{\ignorespaces #3}%
-   \ifdim\wd0 > 0pt
-     \unhbox0 % third arg given, show only that
-   \else
-     \setbox0 = \hbox{\ignorespaces #2}%
-     \ifdim\wd0 > 0pt
-       \ifpdf
-         \unhbox0             % PDF: 2nd arg given, show only it
-       \else
-         \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url
-       \fi
-     \else
-       \code{#1}% only url given, so show it
-     \fi
-   \fi
-   \endlink
- \endgroup}
- 
- % @url synonym for @uref, since that's how everyone uses it.
- %
- \let\url=\uref
- 
- % rms does not like angle brackets --karl, 17may97.
- % So now @email is just like @uref, unless we are pdf.
- %
- %\def\email#1{\angleleft{\tt #1}\angleright}
- \ifpdf
-   \def\email#1{\doemail#1,,\finish}
-   \def\doemail#1,#2,#3\finish{\begingroup
-     \unsepspaces
-     \pdfurl{mailto:#1}%
-     \setbox0 = \hbox{\ignorespaces #2}%
-     \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
-     \endlink
-   \endgroup}
- \else
-   \let\email=\uref
- \fi
- 
  % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
  % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
  %
  \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.
  %
  \def\acronym#1{\doacronym #1,,\finish}
  \def\doacronym#1,#2,#3\finish{%
!   {\selectfonts\lsize #1}%
    \def\temp{#2}%
    \ifx\temp\empty \else
      \space ({\unsepspaces \ignorespaces \temp \unskip})%
    \fi
  }
  
  % @abbr for "Comput. J." and the like.
--- 3209,3231 ----
  \parseargdef\clickstyle{\def\click{#1}}
  \def\click{\arrow}
  
  % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
  % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
  %
  \def\dmn#1{\thinspace #1}
  
  % @acronym for "FBI", "NATO", and the like.
  % We print this one point size smaller, since it's intended for
  % all-uppercase.
  %
  \def\acronym#1{\doacronym #1,,\finish}
  \def\doacronym#1,#2,#3\finish{%
!   {\switchtolsize #1}%
    \def\temp{#2}%
    \ifx\temp\empty \else
      \space ({\unsepspaces \ignorespaces \temp \unskip})%
    \fi
+   \null % reset \spacefactor=1000
  }
  
  % @abbr for "Comput. J." and the like.
***************
*** 2652,2657 ****
--- 3238,3244 ----
    \ifx\temp\empty \else
      \space ({\unsepspaces \ignorespaces \temp \unskip})%
    \fi
+   \null % reset \spacefactor=1000
  }
  
  % @asis just yields its argument.  Used with @table, for example.
***************
*** 2679,2699 ****
  \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
!   $\finishmath
  }
  \def\finishmath#1{#1$\endgroup}  % Close the group opened by \tex.
  
--- 3266,3289 ----
  \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
  %
  \def\math{%
!   \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.
  
***************
*** 2716,2746 ****
    }
  }
  
  
  \message{glyphs,}
  % and logos.
  
! % @@ prints an @.
  \def\@{\char64 }
  
! % Used to generate quoted braces.  Unless we're in typewriter, use
! % \ecfont because the CM text fonts do not have braces, and we don't
! % want to switch into math.
! \def\mylbrace{{\ifmonospace\else\ecfont\fi \char123}}
! \def\myrbrace{{\ifmonospace\else\ecfont\fi \char125}}
! \let\{=\mylbrace
! \let\}=\myrbrace
! \begingroup
!   % Definitions to produce \{ and \} commands for indices,
!   % and @{ and @} for the aux/toc files.
!   \catcode`\{ = \other \catcode`\} = \other
!   \catcode`\[ = 1 \catcode`\] = 2
!   \catcode`\! = 0 \catcode`\\ = \other
!   !gdef!lbracecmd[\{]%
!   !gdef!rbracecmd[\}]%
!   !gdef!lbraceatcmd[@{]%
!   !gdef!rbraceatcmd[@}]%
! !endgroup
  
  % @comma{} to avoid , parsing problems.
  \let\comma = ,
--- 3306,3412 ----
    }
  }
  
+ % for @sub and @sup, if in math mode, just do a normal sub/superscript.
+ % If in text, use math to place as sub/superscript, but switch
+ % into text mode, with smaller fonts.  This is a different font than the
+ % one used for real math sub/superscripts (8pt vs. 7pt), but let's not
+ % fix it (significant additions to font machinery) until someone notices.
+ %
+ \def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi}
+ \def\finishsub#1{$\sb{\hbox{\switchtolllsize #1}}$}%
+ %
+ \def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
+ \def\finishsup#1{$\ptexsp{\hbox{\switchtolllsize #1}}$}%
+ 
+ % provide this command from LaTeX as it is very common
+ \def\frac#1#2{{{#1}\over{#2}}}
+ 
+ % @displaymath.
+ % \globaldefs is needed to recognize the end lines in \tex and
+ % \end tex.  Set \thisenv as @end displaymath is seen before @end tex.
+ {\obeylines
+ \globaldefs=1
+ \envdef\displaymath{%
+ \tex%
+ \def\thisenv{\displaymath}%
+ \begingroup\let\end\displaymathend%
+ $$%
+ }
+ 
+ \def\displaymathend{$$\endgroup\end}%
+ 
+ \def\Edisplaymath{%
+ \def\thisenv{\tex}%
+ \end tex
+ }}
+ 
+ 
+ % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
+ % Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
+ % except specified as a normal braced arg, so no newlines to worry about.
+ %
+ \def\outfmtnametex{tex}
+ %
+ \long\def\inlinefmt#1{\doinlinefmt #1,\finish}
+ \long\def\doinlinefmt#1,#2,\finish{%
+   \def\inlinefmtname{#1}%
+   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
+ }
+ %
+ % @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
+ % FMTNAME is tex, else ELSE-TEXT.
+ \long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
+ \long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{%
+   \def\inlinefmtname{#1}%
+   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi
+ }
+ %
+ % For raw, must switch into @tex before parsing the argument, to avoid
+ % setting catcodes prematurely.  Doing it this way means that, for
+ % example, @inlineraw{html, foo{bar} gets a parse error instead of being
+ % ignored.  But this isn't important because if people want a literal
+ % *right* brace they would have to use a command anyway, so they may as
+ % well use a command to get a left brace too.  We could re-use the
+ % delimiter character idea from \verb, but it seems like overkill.
+ %
+ \long\def\inlineraw{\tex \doinlineraw}
+ \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
+ \def\doinlinerawtwo#1,#2,\finish{%
+   \def\inlinerawname{#1}%
+   \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
+   \endgroup % close group opened by \tex.
+ }
+ 
+ % @inlineifset{VAR, TEXT} expands TEXT if VAR is @set.
+ %
+ \long\def\inlineifset#1{\doinlineifset #1,\finish}
+ \long\def\doinlineifset#1,#2,\finish{%
+   \def\inlinevarname{#1}%
+   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax
+   \else\ignorespaces#2\fi
+ }
+ 
+ % @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set.
+ %
+ \long\def\inlineifclear#1{\doinlineifclear #1,\finish}
+ \long\def\doinlineifclear#1,#2,\finish{%
+   \def\inlinevarname{#1}%
+   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi
+ }
+ 
  
  \message{glyphs,}
  % and logos.
  
! % @@ prints an @, as does @atchar{}.
  \def\@{\char64 }
+ \let\atchar=\@
  
! % @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
! \def\lbracechar{{\ifmonospace\char123\else\ensuremath\lbrace\fi}}
! \def\rbracechar{{\ifmonospace\char125\else\ensuremath\rbrace\fi}}
! \let\{=\lbracechar
! \let\}=\rbracechar
  
  % @comma{} to avoid , parsing problems.
  \let\comma = ,
***************
*** 2758,2765 ****
  % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
  \def\questiondown{?`}
  \def\exclamdown{!`}
! \def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}}
! \def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}}
  
  % Dotless i and dotless j, used for accents.
  \def\imacro{i}
--- 3424,3431 ----
  % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
  \def\questiondown{?`}
  \def\exclamdown{!`}
! \def\ordf{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{a}}}
! \def\ordm{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{o}}}
  
  % Dotless i and dotless j, used for accents.
  \def\imacro{i}
***************
*** 2788,2799 ****
    {\setbox0=\hbox{T}%
     \vbox to \ht0{\hbox{%
       \ifx\textnominalsize\xwordpt
!        % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX.
         % Revert to plain's \scriptsize, which is 7pt.
         \count255=\the\fam $\fam\count255 \scriptstyle A$%
       \else
         % For 11pt, we can use our lllsize.
!        \selectfonts\lllsize A%
       \fi
       }%
       \vss
--- 3454,3465 ----
    {\setbox0=\hbox{T}%
     \vbox to \ht0{\hbox{%
       \ifx\textnominalsize\xwordpt
!        % for 10pt running text, lllsize (8pt) is too small for the A in LaTeX.
         % Revert to plain's \scriptsize, which is 7pt.
         \count255=\the\fam $\fam\count255 \scriptstyle A$%
       \else
         % For 11pt, we can use our lllsize.
!        \switchtolllsize A%
       \fi
       }%
       \vss
***************
*** 2802,2812 ****
    \TeX
  }
  
! % Some math mode symbols.
! \def\bullet{$\ptexbullet$}
! \def\geq{\ifmmode \ge\else $\ge$\fi}
! \def\leq{\ifmmode \le\else $\le$\fi}
! \def\minus{\ifmmode -\else $-$\fi}
  
  % @dots{} outputs an ellipsis using the current font.
  % We do .5em per period so that it has the same spacing in the cm
--- 3468,3483 ----
    \TeX
  }
  
! % Some math mode symbols.  Define \ensuremath to switch into math mode
! % unless we are already there.  Expansion tricks may not be needed here,
! % but safer, and can't hurt.
! \def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi}
! \def\ensuredmath#1{$\relax#1$}
! %
! \def\bullet{\ensuremath\ptexbullet}
! \def\geq{\ensuremath\ge}
! \def\leq{\ensuremath\le}
! \def\minus{\ensuremath-}
  
  % @dots{} outputs an ellipsis using the current font.
  % We do .5em per period so that it has the same spacing in the cm
***************
*** 2854,2863 ****
  %
  \newbox\errorbox
  %
! {\tentt \global\dimen0 = 3em}% Width of the box.
  \dimen2 = .55pt % Thickness of rules
  % The text. (`r' is open on the right, `e' somewhat less so on the left.)
! \setbox0 = \hbox{\kern-.75pt \reducedsf error\kern-1.5pt}
  %
  \setbox\errorbox=\hbox to \dimen0{\hfil
     \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
--- 3525,3534 ----
  %
  \newbox\errorbox
  %
! {\ttfont \global\dimen0 = 3em}% Width of the box.
  \dimen2 = .55pt % Thickness of rules
  % The text. (`r' is open on the right, `e' somewhat less so on the left.)
! \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
  %
  \setbox\errorbox=\hbox to \dimen0{\hfil
     \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
***************
*** 2874,2880 ****
  
  % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
  %
! \def\pounds{{\it\$}}
  
  % @euro{} comes from a separate font, depending on the current style.
  % We use the free feym* fonts from the eurosym package by Henrik
--- 3545,3551 ----
  
  % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
  %
! \def\pounds{\ifmonospace{\ecfont\char"BF}\else{\it\$}\fi}
  
  % @euro{} comes from a separate font, depending on the current style.
  % We use the free feym* fonts from the eurosym package by Henrik
***************
*** 2970,2989 ****
  \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
  \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
  %
! % Use the ec* fonts (cm-super in outline format) for non-CM glyphs.
! \def\ecfont{%
    % We can't distinguish serif/sans and italic/slanted, but this
    % is used for crude hacks anyway (like adding French and German
    % quotes to documents typeset with CM, where we lose kerning), so
    % hopefully nobody will notice/care.
    \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
    \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
!   \ifx\curfontstyle\bfstylename
!     % bold:
!     \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize
!   \else
!     % regular:
!     \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize
    \fi
    \thisecfont
  }
--- 3641,3672 ----
  \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
  \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
  %
! % Use the European Computer Modern fonts (cm-super in outline format)
! % for non-CM glyphs.  That is ec* for regular text and tc* for the text
! % companion symbols (LaTeX TS1 encoding).  Both are part of the ec
! % package and follow the same conventions.
! %
! \def\ecfont{\etcfont{e}}
! \def\tcfont{\etcfont{t}}
! %
! \def\etcfont#1{%
    % We can't distinguish serif/sans and italic/slanted, but this
    % is used for crude hacks anyway (like adding French and German
    % quotes to documents typeset with CM, where we lose kerning), so
    % hopefully nobody will notice/care.
    \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
    \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
!   \ifmonospace
!     % typewriter:
!     \font\thisecfont = #1ctt\ecsize \space at \nominalsize
!   \else
!     \ifx\curfontstyle\bfstylename
!       % bold:
!       \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize
!     \else
!       % regular:
!       \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize
!     \fi
    \fi
    \thisecfont
  }
***************
*** 2993,2999 ****
  % Adapted from the plain.tex definition of \copyright.
  %
  \def\registeredsymbol{%
!   $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}%
                 \hfil\crcr\Orb}}%
      }$%
  }
--- 3676,3682 ----
  % Adapted from the plain.tex definition of \copyright.
  %
  \def\registeredsymbol{%
!   $^{{\ooalign{\hfil\raise.07ex\hbox{\switchtolllsize R}%
                 \hfil\crcr\Orb}}%
      }$%
  }
***************
*** 3006,3021 ****
  %  Textures 1.7.7 (preloaded format=plain 93.10.14)  (68K)  16 APR 2004 02:38
  % so we'll define it if necessary.
  %
! \ifx\Orb\undefined
  \def\Orb{\mathhexbox20D}
  \fi
  
  % Quotes.
- \chardef\quotedblleft="5C
- \chardef\quotedblright=`\"
  \chardef\quoteleft=`\`
  \chardef\quoteright=`\'
  
  
  \message{page headings,}
  
--- 3689,3712 ----
  %  Textures 1.7.7 (preloaded format=plain 93.10.14)  (68K)  16 APR 2004 02:38
  % so we'll define it if necessary.
  %
! \ifx\Orb\thisisundefined
  \def\Orb{\mathhexbox20D}
  \fi
  
  % Quotes.
  \chardef\quoteleft=`\`
  \chardef\quoteright=`\'
  
+ % only change font for tt for correct kerning and to avoid using
+ % \ecfont unless necessary.
+ \def\quotedblleft{%
+   \ifmonospace{\ecfont\char"10}\else{\char"5C}\fi
+ }
+ 
+ \def\quotedblright{%
+   \ifmonospace{\ecfont\char"11}\else{\char`\"}\fi
+ }
+ 
  
  \message{page headings,}
  
***************
*** 3026,3041 ****
  \newif\ifseenauthor
  \newif\iffinishedtitlepage
  
! % Do an implicit @contents or @shortcontents after @end titlepage if the
! % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage.
! %
! \newif\ifsetcontentsaftertitlepage
!  \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue
! \newif\ifsetshortcontentsaftertitlepage
!  \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
! 
! \parseargdef\shorttitlepage{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
!         \endgroup\page\hbox{}\page}
  
  \envdef\titlepage{%
    % Open one extra group, as we want to close it in the middle of \Etitlepage.
--- 3717,3736 ----
  \newif\ifseenauthor
  \newif\iffinishedtitlepage
  
! % @setcontentsaftertitlepage used to do an implicit @contents or
! % @shortcontents after @end titlepage, but it is now obsolete.
! \def\setcontentsaftertitlepage{%
!   \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo
!               command; move your @contents command if you want the contents
!               after the title page.}}%
! \def\setshortcontentsaftertitlepage{%
!   \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
!               command; move your @shortcontents and @contents commands if you
!               want the contents after the title page.}}%
! 
! \parseargdef\shorttitlepage{%
!   \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
!   \endgroup\page\hbox{}\page}
  
  \envdef\titlepage{%
    % Open one extra group, as we want to close it in the middle of \Etitlepage.
***************
*** 3073,3092 ****
    % Need this before the \...aftertitlepage checks so that if they are
    % in effect the toc pages will come out with page numbers.
    \HEADINGSon
-   %
-   % If they want short, they certainly want long too.
-   \ifsetshortcontentsaftertitlepage
-     \shortcontents
-     \contents
-     \global\let\shortcontents = \relax
-     \global\let\contents = \relax
-   \fi
-   %
-   \ifsetcontentsaftertitlepage
-     \contents
-     \global\let\contents = \relax
-     \global\let\shortcontents = \relax
-   \fi
  }
  
  \def\finishtitlepage{%
--- 3768,3773 ----
***************
*** 3095,3108 ****
    \finishedtitlepagetrue
  }
  
! %%% Macros to be used within @titlepage:
  
! \let\subtitlerm=\tenrm
  \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
  
  \parseargdef\title{%
    \checkenv\titlepage
!   \leftline{\titlefonts\rmisbold #1}
    % print a rule at the page bottom also.
    \finishedtitlepagefalse
    \vskip4pt \hrule height 4pt width \hsize \vskip4pt
--- 3776,3802 ----
    \finishedtitlepagetrue
  }
  
! % Settings used for typesetting titles: no hyphenation, no indentation,
! % don't worry much about spacing, ragged right.  This should be used
! % inside a \vbox, and fonts need to be set appropriately first. \par should
! % be specified before the end of the \vbox, since a vbox is a group.
! %
! \def\raggedtitlesettings{%
!   \rm
!   \hyphenpenalty=10000
!   \parindent=0pt
!   \tolerance=5000
!   \ptexraggedright
! }
! 
! % Macros to be used within @titlepage:
  
! \let\subtitlerm=\rmfont
  \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
  
  \parseargdef\title{%
    \checkenv\titlepage
!   \vbox{\titlefonts \raggedtitlesettings #1\par}%
    % print a rule at the page bottom also.
    \finishedtitlepagefalse
    \vskip4pt \hrule height 4pt width \hsize \vskip4pt
***************
*** 3123,3145 ****
    \else
      \checkenv\titlepage
      \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
!     {\secfonts\rmisbold \leftline{#1}}%
    \fi
  }
  
  
! %%% Set up page headings and footings.
  
  \let\thispage=\folio
  
  \newtoks\evenheadline    % headline on even pages
  \newtoks\oddheadline     % headline on odd pages
  \newtoks\evenfootline    % footline on even pages
  \newtoks\oddfootline     % footline on odd pages
  
! % Now make TeX use those variables
! \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
!                             \else \the\evenheadline \fi}}
  \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
                              \else \the\evenfootline \fi}\HEADINGShook}
  \let\HEADINGShook=\relax
--- 3817,3846 ----
    \else
      \checkenv\titlepage
      \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
!     {\secfonts\rm \leftline{#1}}%
    \fi
  }
  
  
! % Set up page headings and footings.
  
  \let\thispage=\folio
  
  \newtoks\evenheadline    % headline on even pages
  \newtoks\oddheadline     % headline on odd pages
+ \newtoks\evenchapheadline% headline on even pages with a new chapter
+ \newtoks\oddchapheadline % headline on odd pages with a new chapter
  \newtoks\evenfootline    % footline on even pages
  \newtoks\oddfootline     % footline on odd pages
  
! % Now make \makeheadline and \makefootline in Plain TeX use those variables
! \headline={{\textfonts\rm
!             \ifchapterpage
!               \ifodd\pageno\the\oddchapheadline\else\the\evenchapheadline\fi
!             \else
!               \ifodd\pageno\the\oddheadline\else\the\evenheadline\fi
!             \fi}}
! 
  \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
                              \else \the\evenfootline \fi}\HEADINGShook}
  \let\HEADINGShook=\relax
***************
*** 3155,3166 ****
  \def\evenheading{\parsearg\evenheadingxxx}
  \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
  \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
! \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  
  \def\oddheading{\parsearg\oddheadingxxx}
  \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
  \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
! \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
  
  \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
  
--- 3856,3869 ----
  \def\evenheading{\parsearg\evenheadingxxx}
  \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
  \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
!   \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
!   \global\evenchapheadline=\evenheadline}
  
  \def\oddheading{\parsearg\oddheadingxxx}
  \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
  \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
!   \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}%
!   \global\oddchapheadline=\oddheadline}
  
  \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
  
***************
*** 3176,3182 ****
    %
    % Leave some space for the footline.  Hopefully ok to assume
    % @evenfooting will not be used by itself.
!   \global\advance\pageheight by -12pt
    \global\advance\vsize by -12pt
  }
  
--- 3879,3885 ----
    %
    % Leave some space for the footline.  Hopefully ok to assume
    % @evenfooting will not be used by itself.
!   \global\advance\txipageheight by -12pt
    \global\advance\vsize by -12pt
  }
  
***************
*** 3193,3205 ****
  % @everyheadingmarks
  % @everyfootingmarks
  
  \def\evenheadingmarks{\headingmarks{even}{heading}}
  \def\oddheadingmarks{\headingmarks{odd}{heading}}
  \def\evenfootingmarks{\headingmarks{even}{footing}}
  \def\oddfootingmarks{\headingmarks{odd}{footing}}
! \def\everyheadingmarks#1 {\headingmarks{even}{heading}{#1}
                            \headingmarks{odd}{heading}{#1} }
! \def\everyfootingmarks#1 {\headingmarks{even}{footing}{#1}
                            \headingmarks{odd}{footing}{#1} }
  % #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
  \def\headingmarks#1#2#3 {%
--- 3896,3912 ----
  % @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}}
  \def\oddfootingmarks{\headingmarks{odd}{footing}}
! \parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1}
                            \headingmarks{odd}{heading}{#1} }
! \parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1}
                            \headingmarks{odd}{footing}{#1} }
  % #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
  \def\headingmarks#1#2#3 {%
***************
*** 3220,3259 ****
  % By default, they are off at the start of a document,
  % and turned `on' after @end titlepage.
  
! \def\headings #1 {\csname HEADINGS#1\endcsname}
  
  \def\headingsoff{% non-global headings elimination
!   \evenheadline={\hfil}\evenfootline={\hfil}%
!    \oddheadline={\hfil}\oddfootline={\hfil}%
  }
  
  \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
  \HEADINGSoff  % it's the default
  
  % When we turn headings on, set the page number to 1.
  % For double-sided printing, put current file name in lower left corner,
  % chapter name on inside top of right hand pages, document
  % title on inside top of left hand pages, and page numbers on outside top
  % edge of all pages.
  \def\HEADINGSdouble{%
! \global\pageno=1
! \global\evenfootline={\hfil}
! \global\oddfootline={\hfil}
! \global\evenheadline={\line{\folio\hfil\thistitle}}
! \global\oddheadline={\line{\thischapter\hfil\folio}}
! \global\let\contentsalignmacro = \chapoddpage
  }
  \let\contentsalignmacro = \chappager
  
  % For single-sided printing, chapter title goes across top left of page,
  % page number on top right.
  \def\HEADINGSsingle{%
! \global\pageno=1
! \global\evenfootline={\hfil}
! \global\oddfootline={\hfil}
! \global\evenheadline={\line{\thischapter\hfil\folio}}
! \global\oddheadline={\line{\thischapter\hfil\folio}}
! \global\let\contentsalignmacro = \chappager
  }
  \def\HEADINGSon{\HEADINGSdouble}
  
--- 3927,3963 ----
  % By default, they are off at the start of a document,
  % and turned `on' after @end titlepage.
  
! \parseargdef\headings{\csname HEADINGS#1\endcsname}
  
  \def\headingsoff{% non-global headings elimination
!   \evenheadline={\hfil}\evenfootline={\hfil}\evenchapheadline={\hfil}%
!    \oddheadline={\hfil}\oddfootline={\hfil}\oddchapheadline={\hfil}%
  }
  
  \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
  \HEADINGSoff  % it's the default
  
  % When we turn headings on, set the page number to 1.
+ \def\pageone{
+   \global\pageno=1
+   \global\arabiccount = \pagecount
+ }
+ 
  % For double-sided printing, put current file name in lower left corner,
  % chapter name on inside top of right hand pages, document
  % title on inside top of left hand pages, and page numbers on outside top
  % edge of all pages.
  \def\HEADINGSdouble{%
! \pageone
! \HEADINGSdoublex
  }
  \let\contentsalignmacro = \chappager
  
  % For single-sided printing, chapter title goes across top left of page,
  % page number on top right.
  \def\HEADINGSsingle{%
! \pageone
! \HEADINGSsinglex
  }
  \def\HEADINGSon{\HEADINGSdouble}
  
***************
*** 3264,3269 ****
--- 3968,3975 ----
  \global\oddfootline={\hfil}
  \global\evenheadline={\line{\folio\hfil\thistitle}}
  \global\oddheadline={\line{\thischapter\hfil\folio}}
+ \global\evenchapheadline={\line{\folio\hfil}}
+ \global\oddchapheadline={\line{\hfil\folio}}
  \global\let\contentsalignmacro = \chapoddpage
  }
  
***************
*** 3273,3278 ****
--- 3979,3998 ----
  \global\oddfootline={\hfil}
  \global\evenheadline={\line{\thischapter\hfil\folio}}
  \global\oddheadline={\line{\thischapter\hfil\folio}}
+ \global\evenchapheadline={\line{\hfil\folio}}
+ \global\oddchapheadline={\line{\hfil\folio}}
+ \global\let\contentsalignmacro = \chappager
+ }
+ 
+ % for @setchapternewpage off
+ \def\HEADINGSsinglechapoff{%
+ \pageone
+ \global\evenfootline={\hfil}
+ \global\oddfootline={\hfil}
+ \global\evenheadline={\line{\thischapter\hfil\folio}}
+ \global\oddheadline={\line{\thischapter\hfil\folio}}
+ \global\evenchapheadline=\evenheadline
+ \global\oddchapheadline=\oddheadline
  \global\let\contentsalignmacro = \chappager
  }
  
***************
*** 3280,3286 ****
  % This produces Day Month Year style of output.
  % Only define if not already defined, in case a txi-??.tex file has set
  % up a different format (e.g., txi-cs.tex does this).
! \ifx\today\undefined
  \def\today{%
    \number\day\space
    \ifcase\month
--- 4000,4006 ----
  % This produces Day Month Year style of output.
  % Only define if not already defined, in case a txi-??.tex file has set
  % up a different format (e.g., txi-cs.tex does this).
! \ifx\today\thisisundefined
  \def\today{%
    \number\day\space
    \ifcase\month
***************
*** 3450,3456 ****
    \parskip=\smallskipamount
    \ifdim\parskip=0pt \parskip=2pt \fi
    %
!   % Try typesetting the item mark that if the document erroneously says
    % something like @itemize @samp (intending @table), there's an error
    % right away at the @itemize.  It's not the best error message in the
    % world, but it's better than leaving it to the @item.  This means if
--- 4170,4176 ----
    \parskip=\smallskipamount
    \ifdim\parskip=0pt \parskip=2pt \fi
    %
!   % Try typesetting the item mark so that if the document erroneously says
    % something like @itemize @samp (intending @table), there's an error
    % right away at the @itemize.  It's not the best error message in the
    % world, but it's better than leaving it to the @item.  This means if
***************
*** 3482,3488 ****
     \noindent
     \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
     %
!    \vadjust{\penalty 1200}}% not good to break after first line of item.
    \flushcr
  }
  
--- 4202,4213 ----
     \noindent
     \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
     %
!    \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
  }
  
***************
*** 3576,3657 ****
    \doitemize{#1.}\flushcr
  }
  
- % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
- % to @enumerate.
- %
- \def\alphaenumerate{\enumerate{a}}
- \def\capsenumerate{\enumerate{A}}
- \def\Ealphaenumerate{\Eenumerate}
- \def\Ecapsenumerate{\Eenumerate}
- 
  
  % @multitable macros
- % Amy Hendrickson, 8/18/94, 3/6/96
- %
- % @multitable ... @end multitable will make as many columns as desired.
- % Contents of each column will wrap at width given in preamble.  Width
- % can be specified either with sample text given in a template line,
- % or in percent of \hsize, the current width of text on page.
- 
- % Table can continue over pages but will only break between lines.
- 
- % To make preamble:
- %
- % Either define widths of columns in terms of percent of \hsize:
- %   @multitable @columnfractions .25 .3 .45
- %   @item ...
- %
- %   Numbers following @columnfractions are the percent of the total
- %   current hsize to be used for each column. You may use as many
- %   columns as desired.
- 
- 
- % Or use a template:
- %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
- %   @item ...
- %   using the widest term desired in each column.
- 
- % Each new table line starts with @item, each subsequent new column
- % starts with @tab. Empty columns may be produced by supplying @tab's
- % with nothing between them for as many times as empty columns are needed,
- % ie, @tab@tab@tab will produce two empty columns.
- 
- % @item, @tab do not need to be on their own lines, but it will not hurt
- % if they are.
- 
- % Sample multitable:
- 
- %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
- %   @item first col stuff @tab second col stuff @tab third col
- %   @item
- %   first col stuff
- %   @tab
- %   second col stuff
- %   @tab
- %   third col
- %   @item first col stuff @tab second col stuff
- %   @tab Many paragraphs of text may be used in any column.
- %
- %         They will wrap at the width determined by the template.
- %   @item@tab@tab This will be in third column.
- %   @end multitable
- 
- % Default dimensions may be reset by user.
- % @multitableparskip is vertical space between paragraphs in table.
- % @multitableparindent is paragraph indent in table.
- % @multitablecolmargin is horizontal space to be left between columns.
- % @multitablelinespace is space to leave between table items, baseline
- %                                                            to baseline.
- %   0pt means it depends on current normal line spacing.
- %
- \newskip\multitableparskip
- \newskip\multitableparindent
- \newdimen\multitablecolspace
- \newskip\multitablelinespace
- \multitableparskip=0pt
- \multitableparindent=6pt
- \multitablecolspace=12pt
- \multitablelinespace=0pt
  
  % Macros used to set up halign preamble:
  %
--- 4301,4308 ----
***************
*** 3699,3726 ****
    \go
  }
  
! % multitable-only commands.
! %
! % @headitem starts a heading row, which we typeset in bold.
! % Assignments have to be global since we are inside the implicit group
! % of an alignment entry.  \everycr resets \everytab so we don't have to
  % undo it ourselves.
  \def\headitemfont{\b}% for people to use in the template row; not changeable
  \def\headitem{%
    \checkenv\multitable
    \crcr
    \global\everytab={\bf}% can't use \headitemfont since the parsing differs
    \the\everytab % for the first item
  }%
  %
! % A \tab used to include \hskip1sp.  But then the space in a template
! % line is not enough.  That is bad.  So let's go back to just `&' until
! % we again encounter the problem the 1sp was intended to solve.
! %					--karl, nathan@acm.org, 20apr99.
  \def\tab{\checkenv\multitable &\the\everytab}%
  
- % @multitable ... @end multitable definitions:
- %
  \newtoks\everytab  % insert after every tab.
  %
  \envdef\multitable{%
--- 4350,4373 ----
    \go
  }
  
! % @headitem starts a heading row, which we typeset in bold.  Assignments
! % have to be global since we are inside the implicit group of an
! % alignment entry.  \everycr below resets \everytab so we don't have to
  % undo it ourselves.
  \def\headitemfont{\b}% for people to use in the template row; not changeable
  \def\headitem{%
    \checkenv\multitable
    \crcr
+   \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings
    \global\everytab={\bf}% can't use \headitemfont since the parsing differs
    \the\everytab % for the first item
  }%
  %
! % default for tables with no headings.
! \let\headitemcrhook=\relax
! %
  \def\tab{\checkenv\multitable &\the\everytab}%
  
  \newtoks\everytab  % insert after every tab.
  %
  \envdef\multitable{%
***************
*** 3735,3757 ****
    %
    \tolerance=9500
    \hbadness=9500
!   \setmultitablespacing
!   \parskip=\multitableparskip
!   \parindent=\multitableparindent
    \overfullrule=0pt
    \global\colcount=0
    %
    \everycr = {%
      \noalign{%
!       \global\everytab={}%
        \global\colcount=0 % Reset the column counter.
!       % Check for saved footnotes, etc.
        \checkinserts
!       % Keeps underfull box messages off when table breaks over pages.
!       %\filbreak
! 	% Maybe so, but it also creates really weird page breaks when the
! 	% table breaks over pages. Wouldn't \vfil be better?  Wait until the
! 	% problem manifests itself, so it can be fixed for real --karl.
      }%
    }%
    %
--- 4382,4403 ----
    %
    \tolerance=9500
    \hbadness=9500
!   \parskip=0pt
!   \parindent=6pt
    \overfullrule=0pt
    \global\colcount=0
    %
    \everycr = {%
      \noalign{%
!       \global\everytab={}% Reset from possible headitem.
        \global\colcount=0 % Reset the column counter.
!       %
!       % Check for saved footnotes, etc.:
        \checkinserts
!       %
!       % Perhaps a \nobreak, then reset:
!       \headitemcrhook
!       \global\let\headitemcrhook=\relax
      }%
    }%
    %
***************
*** 3767,3813 ****
    % continue for many paragraphs if desired.
    \halign\bgroup &%
      \global\advance\colcount by 1
!     \multistrut
      \vtop{%
!       % Use the current \colcount to find the correct column width:
        \hsize=\expandafter\csname col\the\colcount\endcsname
        %
-       % In order to keep entries from bumping into each other
-       % we will add a \leftskip of \multitablecolspace to all columns after
-       % the first one.
-       %
-       % If a template has been used, we will add \multitablecolspace
-       % to the width of each template entry.
-       %
-       % If the user has set preamble in terms of percent of \hsize we will
-       % use that dimension as the width of the column, and the \leftskip
-       % will keep entries from bumping into each other.  Table will start at
-       % left margin and final column will justify at right margin.
-       %
-       % Make sure we don't inherit \rightskip from the outer environment.
        \rightskip=0pt
        \ifnum\colcount=1
! 	% The first column will be indented with the surrounding text.
! 	\advance\hsize by\leftskip
        \else
! 	\ifsetpercent \else
! 	  % If user has not set preamble in terms of percent of \hsize
! 	  % we will advance \hsize by \multitablecolspace.
! 	  \advance\hsize by \multitablecolspace
! 	\fi
!        % In either case we will make \leftskip=\multitablecolspace:
!       \leftskip=\multitablecolspace
        \fi
!       % Ignoring space at the beginning and end avoids an occasional spurious
!       % blank line, when TeX decides to break the line at the space before the
!       % box from the multistrut, so the strut ends up on a line by itself.
!       % For example:
!       % @multitable @columnfractions .11 .89
!       % @item @code{#}
!       % @tab Legal holiday which is valid in major parts of the whole country.
!       % Is automatically provided with highlighting sequences respectively
!       % marking characters.
!       \noindent\ignorespaces##\unskip\multistrut
      }\cr
  }
  \def\Emultitable{%
--- 4413,4436 ----
    % continue for many paragraphs if desired.
    \halign\bgroup &%
      \global\advance\colcount by 1
!     \strut
      \vtop{%
!       \advance\hsize by -1\leftskip
!       % Find the correct column width
        \hsize=\expandafter\csname col\the\colcount\endcsname
        %
        \rightskip=0pt
        \ifnum\colcount=1
!         \advance\hsize by\leftskip % Add indent of surrounding text
        \else
!         % In order to keep entries from bumping into each other.
!         \leftskip=12pt
!         \ifsetpercent \else
!           % If a template has been used
!           \advance\hsize by \leftskip
!         \fi
        \fi
!       \noindent\ignorespaces##\unskip\strut
      }\cr
  }
  \def\Emultitable{%
***************
*** 3816,3846 ****
    \global\setpercentfalse
  }
  
- \def\setmultitablespacing{%
-   \def\multistrut{\strut}% just use the standard line spacing
-   %
-   % Compute \multitablelinespace (if not defined by user) for use in
-   % \multitableparskip calculation.  We used define \multistrut based on
-   % this, but (ironically) that caused the spacing to be off.
-   % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
- \ifdim\multitablelinespace=0pt
- \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
- \global\advance\multitablelinespace by-\ht0
- \fi
- %% Test to see if parskip is larger than space between lines of
- %% table. If not, do nothing.
- %%        If so, set to same dimension as multitablelinespace.
- \ifdim\multitableparskip>\multitablelinespace
- \global\multitableparskip=\multitablelinespace
- \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
-                                       %% than skip between lines in the table.
- \fi%
- \ifdim\multitableparskip=0pt
- \global\multitableparskip=\multitablelinespace
- \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
-                                       %% than skip between lines in the table.
- \fi}
- 
  
  \message{conditionals,}
  
--- 4439,4444 ----
***************
*** 3990,3996 ****
  \def\value{\begingroup\makevalueexpandable\valuexxx}
  \def\valuexxx#1{\expandablevalue{#1}\endgroup}
  {
!   \catcode`\- = \active \catcode`\_ = \active
    %
    \gdef\makevalueexpandable{%
      \let\value = \expandablevalue
--- 4588,4594 ----
  \def\value{\begingroup\makevalueexpandable\valuexxx}
  \def\valuexxx#1{\expandablevalue{#1}\endgroup}
  {
!   \catcode`\-=\active \catcode`\_=\active
    %
    \gdef\makevalueexpandable{%
      \let\value = \expandablevalue
***************
*** 3999,4016 ****
      % ..., but we might end up with active ones in the argument if
      % we're called from @code, as @code{@value{foo-bar_}}, though.
      % So \let them to their normal equivalents.
!     \let-\realdash \let_\normalunderscore
    }
  }
  
- % We have this subroutine so that we can handle at least some @value's
- % properly in indexes (we call \makevalueexpandable in \indexdummies).
- % The command has to be fully expandable (if the variable is set), since
- % the result winds up in the index file.  This means that if the
- % variable's value contains other Texinfo commands, it's almost certain
- % it will fail (although perhaps we could fix that with sufficient work
- % to do a one-level expansion on the result, instead of complete).
- %
  \def\expandablevalue#1{%
    \expandafter\ifx\csname SET#1\endcsname\relax
      {[No value for ``#1'']}%
--- 4597,4606 ----
      % ..., but we might end up with active ones in the argument if
      % we're called from @code, as @code{@value{foo-bar_}}, though.
      % So \let them to their normal equivalents.
!     \let-\normaldash \let_\normalunderscore
    }
  }
  
  \def\expandablevalue#1{%
    \expandafter\ifx\csname SET#1\endcsname\relax
      {[No value for ``#1'']}%
***************
*** 4020,4029 ****
    \fi
  }
  
  % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
  % with @set.
  %
! % To get special treatment of `@end ifset,' call \makeond and the redefine.
  %
  \makecond{ifset}
  \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
--- 4610,4645 ----
    \fi
  }
  
+ % Like \expandablevalue, but completely expandable (the \message in the
+ % definition above operates at the execution level of TeX).  Used when
+ % writing to auxiliary files, due to the expansion that \write does.
+ % If flag is undefined, pass through an unexpanded @value command: maybe it
+ % will be set by the time it is read back in.
+ %
+ % NB flag names containing - or _ may not work here.
+ \def\dummyvalue#1{%
+   \expandafter\ifx\csname SET#1\endcsname\relax
+     \string\value{#1}%
+   \else
+     \csname SET#1\endcsname
+   \fi
+ }
+ 
+ % Used for @value's in index entries to form the sort key: expand the @value
+ % if possible, otherwise sort late.
+ \def\indexnofontsvalue#1{%
+   \expandafter\ifx\csname SET#1\endcsname\relax
+     ZZZZZZZ%
+   \else
+     \csname SET#1\endcsname
+   \fi
+ }
+ 
  % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
  % with @set.
  %
! % To get the special treatment we need for `@end ifset,' we call
! % \makecond and then redefine.
  %
  \makecond{ifset}
  \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
***************
*** 4039,4045 ****
  }
  \def\ifsetfail{\doignore{ifset}}
  
! % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
  % defined with @set, or has been undefined with @clear.
  %
  % The `\else' inside the `\doifset' parameter is a trick to reuse the
--- 4655,4661 ----
  }
  \def\ifsetfail{\doignore{ifset}}
  
! % @ifclear VAR ... @end executes the `...' iff VAR has never been
  % defined with @set, or has been undefined with @clear.
  %
  % The `\else' inside the `\doifset' parameter is a trick to reuse the
***************
*** 4050,4055 ****
--- 4666,4700 ----
  \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
  \def\ifclearfail{\doignore{ifclear}}
  
+ % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
+ % without the @) is in fact defined.  We can only feasibly check at the
+ % TeX level, so something like `mathcode' is going to considered
+ % defined even though it is not a Texinfo command.
+ %
+ \makecond{ifcommanddefined}
+ \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
+ %
+ \def\doifcmddefined#1#2{{%
+     \makevalueexpandable
+     \let\next=\empty
+     \expandafter\ifx\csname #2\endcsname\relax
+       #1% If not defined, \let\next as above.
+     \fi
+     \expandafter
+   }\next
+ }
+ \def\ifcmddefinedfail{\doignore{ifcommanddefined}}
+ 
+ % @ifcommandnotdefined CMD ... handled similar to @ifclear above.
+ \makecond{ifcommandnotdefined}
+ \def\ifcommandnotdefined{%
+   \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
+ \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
+ 
+ % Set the `txicommandconditionals' variable, so documents have a way to
+ % test if the @ifcommand...defined conditionals are available.
+ \set txicommandconditionals
+ 
  % @dircategory CATEGORY  -- specify a category of the dir file
  % which this file should belong to.  Ignore this in TeX.
  \let\dircategory=\comment
***************
*** 4065,4083 ****
  % 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.
  % 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\xdef\csname#1index\endcsname{%     % Define @#1index
      \noexpand\doindex{#1}}
  }
--- 4710,4725 ----
  % except not \outer, so it can be used within macros and \if's.
  \edef\newwrite{\makecsname{ptexnewwrite}}
  
! % \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{%
!   \expandafter\chardef\csname#1indfile\endcsname=0
    \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
      \noexpand\doindex{#1}}
  }
***************
*** 4091,4104 ****
  \def\defcodeindex{\parsearg\newcodeindex}
  %
  \def\newcodeindex#1{%
!   \iflinks
!     \expandafter\newwrite \csname#1indfile\endcsname
!     \openout \csname#1indfile\endcsname \jobname.#1
!   \fi
    \expandafter\xdef\csname#1index\endcsname{%
      \noexpand\docodeindex{#1}}%
  }
  
  
  % @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.
--- 4733,4751 ----
  \def\defcodeindex{\parsearg\newcodeindex}
  %
  \def\newcodeindex#1{%
!   \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.
***************
*** 4112,4125 ****
  % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
  % #3 the target index (bar).
  \def\dosynindex#1#2#3{%
!   % Only do \closeout if we haven't already done it, else we'll end up
!   % closing the target index.
!   \expandafter \ifx\csname donesynindex#2\endcsname \relax
!     % The \closeout helps reduce unnecessary open files; the limit on the
!     % Acorn RISC OS is a mere 16 files.
!     \expandafter\closeout\csname#2indfile\endcsname
!     \expandafter\let\csname donesynindex#2\endcsname = 1
!   \fi
    % redefine \fooindfile:
    \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
    \expandafter\let\csname#2indfile\endcsname=\temp
--- 4759,4765 ----
  % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
  % #3 the target index (bar).
  \def\dosynindex#1#2#3{%
!   \requireopenindexfile{#3}%
    % redefine \fooindfile:
    \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
    \expandafter\let\csname#2indfile\endcsname=\temp
***************
*** 4127,4234 ****
    \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
  }
  
! % Define \doindex, the driver for all \fooindex macros.
  % Argument #1 is generated by the calling \fooindex macro,
! %  and it is "foo", the 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.
  
! % 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}}}
  
- % 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.
- %
- \def\indexdummies{%
-   \escapechar = `\\     % use backslash in output files.
-   \def\@{@}% change to @@ when we switch to @ as escape char in index files.
-   \def\ {\realbackslash\space }%
-   %
-   % Need these unexpandable (because we define \tt as a dummy)
-   % definitions when @{ or @} appear in index entry text.  Also, more
-   % complicated, when \tex is in effect and \{ is a \delimiter again.
-   % We can't use \lbracecmd and \rbracecmd because texindex assumes
-   % braces and backslashes are used only as delimiters.  Perhaps we
-   % should define @lbrace and @rbrace commands a la @comma.
-   \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
-   %
-   % The above is not enough to reproduce the bug, but it gives the flavor.
-   %
-   % Sample whatsit resulting:
-   % .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}}
-   %
-   % So:
-   \let\endinput = \empty
-   %
-   % Do the redefinitions.
-   \commondummies
- }
  
! % For the aux and toc files, @ is the escape character.  So we want to
! % redefine everything using @ as the escape character (instead of
! % \realbackslash, still used for index files).  When everything uses @,
! % this will be simpler.
  %
  \def\atdummies{%
!   \def\@{@@}%
!   \def\ {@ }%
!   \let\{ = \lbraceatcmd
!   \let\} = \rbraceatcmd
    %
    % Do the redefinitions.
!   \commondummies
    \otherbackslash
  }
  
! % Called from \indexdummies and \atdummies.
! %
! \def\commondummies{%
!   %
!   % \definedummyword defines \#1 as \string\#1\space, thus effectively
!   % preventing its expansion.  This is used only for control words,
!   % not control letters, because the \space would be incorrect for
!   % control characters, but is needed to separate the control word
!   % from whatever follows.
!   %
!   % For control letters, we have \definedummyletter, which omits the
!   % space.
!   %
!   % These can be used both for control words that take an argument and
!   % those that do not.  If it is followed by {arg} in the input, then
!   % that will dutifully get written to the index (or wherever).
!   %
!   \def\definedummyword  ##1{\def##1{\string##1\space}}%
!   \def\definedummyletter##1{\def##1{\string##1}}%
!   \let\definedummyaccent\definedummyletter
!   %
    \commondummiesnofonts
    %
    \definedummyletter\_%
--- 4767,4823 ----
    \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
  }
  
! % Define \doindex, the driver for all index macros.
  % Argument #1 is generated by the calling \fooindex macro,
! % and it is the two-letter name of the index.
  
! \def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
! \def\doindexxxx #1{\doind{\indexname}{#1}}
  
  % like the previous two, but they put @code around the argument.
! \def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
! \def\docodeindexxxx #1{\docind{\indexname}{#1}}
  
  
! % Used for the aux, toc and index files to prevent expansion of Texinfo
! % commands.
  %
  \def\atdummies{%
!   \definedummyletter\@%
!   \definedummyletter\ %
!   \definedummyletter\{%
!   \definedummyletter\}%
!   \definedummyletter\&%
    %
    % Do the redefinitions.
!   \definedummies
    \otherbackslash
  }
  
! % \definedummyword defines \#1 as \string\#1\space, thus effectively
! % preventing its expansion.  This is used only for control words,
! % not control letters, because the \space would be incorrect for
! % control characters, but is needed to separate the control word
! % from whatever follows.
! %
! % These can be used both for control words that take an argument and
! % those that do not.  If it is followed by {arg} in the input, then
! % that will dutifully get written to the index (or wherever).
! %
! % For control letters, we have \definedummyletter, which omits the
! % space.
! %
! \def\definedummyword  #1{\def#1{\string#1\space}}%
! \def\definedummyletter#1{\def#1{\string#1}}%
! \let\definedummyaccent\definedummyletter
! 
! % Called from \atdummies to prevent the expansion of commands.
! %
! \def\definedummies{%
!   %
!   \let\commondummyword\definedummyword
!   \let\commondummyletter\definedummyletter
!   \let\commondummyaccent\definedummyaccent
    \commondummiesnofonts
    %
    \definedummyletter\_%
***************
*** 4269,4275 ****
--- 4858,4867 ----
    \definedummyword\TeX
    %
    % Assorted special characters.
+   \definedummyword\ampchar
+   \definedummyword\atchar
    \definedummyword\arrow
+   \definedummyword\backslashchar
    \definedummyword\bullet
    \definedummyword\comma
    \definedummyword\copyright
***************
*** 4286,4292 ****
--- 4878,4886 ----
    \definedummyword\guillemetright
    \definedummyword\guilsinglleft
    \definedummyword\guilsinglright
+   \definedummyword\lbracechar
    \definedummyword\leq
+   \definedummyword\mathopsup
    \definedummyword\minus
    \definedummyword\ogonek
    \definedummyword\pounds
***************
*** 4298,4382 ****
    \definedummyword\quoteleft
    \definedummyword\quoteright
    \definedummyword\quotesinglbase
    \definedummyword\result
    \definedummyword\textdegree
    %
    % We want to disable all macros so that they are not expanded by \write.
    \macrolist
    %
    \normalturnoffactive
-   %
-   % Handle some cases of @value -- where it does not contain any
-   % (non-fully-expandable) commands.
-   \makevalueexpandable
  }
  
! % \commondummiesnofonts: common to \commondummies and \indexnofonts.
  %
  \def\commondummiesnofonts{%
    % Control letters and accents.
!   \definedummyletter\!%
!   \definedummyaccent\"%
!   \definedummyaccent\'%
!   \definedummyletter\*%
!   \definedummyaccent\,%
!   \definedummyletter\.%
!   \definedummyletter\/%
!   \definedummyletter\:%
!   \definedummyaccent\=%
!   \definedummyletter\?%
!   \definedummyaccent\^%
!   \definedummyaccent\`%
!   \definedummyaccent\~%
!   \definedummyword\u
!   \definedummyword\v
!   \definedummyword\H
!   \definedummyword\dotaccent
!   \definedummyword\ogonek
!   \definedummyword\ringaccent
!   \definedummyword\tieaccent
!   \definedummyword\ubaraccent
!   \definedummyword\udotaccent
!   \definedummyword\dotless
    %
    % Texinfo font commands.
!   \definedummyword\b
!   \definedummyword\i
!   \definedummyword\r
!   \definedummyword\sansserif
!   \definedummyword\sc
!   \definedummyword\slanted
!   \definedummyword\t
    %
    % Commands that take arguments.
!   \definedummyword\acronym
!   \definedummyword\cite
!   \definedummyword\code
!   \definedummyword\command
!   \definedummyword\dfn
!   \definedummyword\dmn
!   \definedummyword\email
!   \definedummyword\emph
!   \definedummyword\env
!   \definedummyword\file
!   \definedummyword\indicateurl
!   \definedummyword\kbd
!   \definedummyword\key
!   \definedummyword\math
!   \definedummyword\option
!   \definedummyword\pxref
!   \definedummyword\ref
!   \definedummyword\samp
!   \definedummyword\strong
!   \definedummyword\tie
!   \definedummyword\uref
!   \definedummyword\url
!   \definedummyword\var
!   \definedummyword\verb
!   \definedummyword\w
!   \definedummyword\xref
  }
  
  % \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
--- 4892,5028 ----
    \definedummyword\quoteleft
    \definedummyword\quoteright
    \definedummyword\quotesinglbase
+   \definedummyword\rbracechar
    \definedummyword\result
+   \definedummyword\sub
+   \definedummyword\sup
    \definedummyword\textdegree
    %
+   \definedummyword\subentry
+   %
    % We want to disable all macros so that they are not expanded by \write.
    \macrolist
+   \let\value\dummyvalue
    %
    \normalturnoffactive
  }
  
! % \commondummiesnofonts: common to \definedummies and \indexnofonts.
! % Define \commondummyletter, \commondummyaccent and \commondummyword before
! % using.  Used for accents, font commands, and various control letters.
  %
  \def\commondummiesnofonts{%
    % Control letters and accents.
!   \commondummyletter\!%
!   \commondummyaccent\"%
!   \commondummyaccent\'%
!   \commondummyletter\*%
!   \commondummyaccent\,%
!   \commondummyletter\.%
!   \commondummyletter\/%
!   \commondummyletter\:%
!   \commondummyaccent\=%
!   \commondummyletter\?%
!   \commondummyaccent\^%
!   \commondummyaccent\`%
!   \commondummyaccent\~%
!   \commondummyword\u
!   \commondummyword\v
!   \commondummyword\H
!   \commondummyword\dotaccent
!   \commondummyword\ogonek
!   \commondummyword\ringaccent
!   \commondummyword\tieaccent
!   \commondummyword\ubaraccent
!   \commondummyword\udotaccent
!   \commondummyword\dotless
    %
    % Texinfo font commands.
!   \commondummyword\b
!   \commondummyword\i
!   \commondummyword\r
!   \commondummyword\sansserif
!   \commondummyword\sc
!   \commondummyword\slanted
!   \commondummyword\t
    %
    % Commands that take arguments.
!   \commondummyword\abbr
!   \commondummyword\acronym
!   \commondummyword\anchor
!   \commondummyword\cite
!   \commondummyword\code
!   \commondummyword\command
!   \commondummyword\dfn
!   \commondummyword\dmn
!   \commondummyword\email
!   \commondummyword\emph
!   \commondummyword\env
!   \commondummyword\file
!   \commondummyword\image
!   \commondummyword\indicateurl
!   \commondummyword\inforef
!   \commondummyword\kbd
!   \commondummyword\key
!   \commondummyword\math
!   \commondummyword\option
!   \commondummyword\pxref
!   \commondummyword\ref
!   \commondummyword\samp
!   \commondummyword\strong
!   \commondummyword\tie
!   \commondummyword\U
!   \commondummyword\uref
!   \commondummyword\url
!   \commondummyword\var
!   \commondummyword\verb
!   \commondummyword\w
!   \commondummyword\xref
! }
! 
! \let\indexlbrace\relax
! \let\indexrbrace\relax
! \let\indexatchar\relax
! \let\indexbackslash\relax
! 
! {\catcode`\@=0
! \catcode`\\=13
!   @gdef@backslashdisappear{@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
!       \def\@{}%
!     \fi
!   }
! 
!   \gdef\indexnonalnumreappear{%
!     \let-\normaldash
!     \let<\normalless
!   }
  }
  
+ 
  % \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
***************
*** 4384,4395 ****
  %
  \def\indexnofonts{%
    % Accent commands should become @asis.
!   \def\definedummyaccent##1{\let##1\asis}%
    % We can just ignore other control letters.
!   \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
--- 5030,5040 ----
  %
  \def\indexnofonts{%
    % Accent commands should become @asis.
!   \def\commondummyaccent##1{\let##1\asis}%
    % We can just ignore other control letters.
!   \def\commondummyletter##1{\let##1\empty}%
    % All control words become @asis by default; overrides below.
!   \let\commondummyword\commondummyaccent
    \commondummiesnofonts
    %
    % Don't no-op \tt, since it isn't a user-level command
***************
*** 4402,4412 ****
    \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 }.
!   \def\{{|a}%
!   \def\}{|b}%
    %
    % Non-English letters.
    \def\AA{AA}%
--- 5047,5056 ----
    \def\_{\normalunderscore}%
    \def\-{}% @- shouldn't affect sorting
    %
!   \uccode`\1=`\{ \uppercase{\def\{{1}}%
!   \uccode`\1=`\} \uppercase{\def\}{1}}%
!   \let\lbracechar\{%
!   \let\rbracechar\}%
    %
    % Non-English letters.
    \def\AA{AA}%
***************
*** 4415,4421 ****
    \def\L{L}%
    \def\OE{OE}%
    \def\O{O}%
!   \def\TH{ZZZ}%
    \def\aa{aa}%
    \def\ae{ae}%
    \def\dh{dzz}%
--- 5059,5065 ----
    \def\L{L}%
    \def\OE{OE}%
    \def\O{O}%
!   \def\TH{TH}%
    \def\aa{aa}%
    \def\ae{ae}%
    \def\dh{dzz}%
***************
*** 4427,4471 ****
    \def\o{o}%
    \def\questiondown{?}%
    \def\ss{ss}%
!   \def\th{zzz}%
    %
!   \def\LaTeX{LaTeX}%
!   \def\TeX{TeX}%
    %
!   % Assorted special characters.
!   % (The following {} will end up in the sort string, but that's ok.)
!   \def\arrow{->}%
!   \def\bullet{bullet}%
!   \def\comma{,}%
!   \def\copyright{copyright}%
!   \def\dots{...}%
!   \def\enddots{...}%
!   \def\equiv{==}%
!   \def\error{error}%
!   \def\euro{euro}%
!   \def\expansion{==>}%
!   \def\geq{>=}%
!   \def\guillemetleft{<<}%
!   \def\guillemetright{>>}%
!   \def\guilsinglleft{<}%
!   \def\guilsinglright{>}%
!   \def\leq{<=}%
!   \def\minus{-}%
!   \def\point{.}%
!   \def\pounds{pounds}%
!   \def\print{-|}%
!   \def\quotedblbase{"}%
!   \def\quotedblleft{"}%
!   \def\quotedblright{"}%
!   \def\quoteleft{`}%
!   \def\quoteright{'}%
!   \def\quotesinglbase{,}%
!   \def\registeredsymbol{R}%
!   \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.
--- 5071,5116 ----
    \def\o{o}%
    \def\questiondown{?}%
    \def\ss{ss}%
!   \def\th{th}%
    %
!   \let\do\indexnofontsdef
    %
!   \do\LaTeX{LaTeX}%
!   \do\TeX{TeX}%
    %
!   % Assorted special characters.
!   \do\atchar{@}%
!   \do\arrow{->}%
!   \do\bullet{bullet}%
!   \do\comma{,}%
!   \do\copyright{copyright}%
!   \do\dots{...}%
!   \do\enddots{...}%
!   \do\equiv{==}%
!   \do\error{error}%
!   \do\euro{euro}%
!   \do\expansion{==>}%
!   \do\geq{>=}%
!   \do\guillemetleft{<<}%
!   \do\guillemetright{>>}%
!   \do\guilsinglleft{<}%
!   \do\guilsinglright{>}%
!   \do\leq{<=}%
!   \do\lbracechar{\{}%
!   \do\minus{-}%
!   \do\point{.}%
!   \do\pounds{pounds}%
!   \do\print{-|}%
!   \do\quotedblbase{"}%
!   \do\quotedblleft{"}%
!   \do\quotedblright{"}%
!   \do\quoteleft{`}%
!   \do\quoteright{'}%
!   \do\quotesinglbase{,}%
!   \do\rbracechar{\}}%
!   \do\registeredsymbol{R}%
!   \do\result{=>}%
!   \do\textdegree{o}%
    %
    % 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.
***************
*** 4478,4552 ****
    % goes to end-of-line is not handled.
    %
    \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.
! % #1 is name of index, #2 is stuff to put there, #3 is subentry --
! % empty if called from \doind, as we usually are (the main exception
! % is with most defuns, which call us directly).
! %
! \def\dosubind#1#2#3{%
    \iflinks
    {%
-     % Store the main index entry text (including the third arg).
-     \toks0 = {#2}%
-     % If third arg is present, precede it with a space.
-     \def\thirdarg{#3}%
-     \ifx\thirdarg\empty \else
-       \toks0 = \expandafter{\the\toks0 \space #3}%
-     \fi
      %
      \edef\writeto{\csname#1indfile\endcsname}%
      %
!     \safewhatsit\dosubindwrite
    }%
    \fi
  }
  
! % Write the entry in \toks0 to the index file:
  %
! \def\dosubindwrite{%
!   % Put the index entry in the margin if desired.
!   \ifx\SETmarginindex\relax\else
!     \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
    \fi
    %
!   % 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.
!   {\indexnofonts
!    \edef\temp{\the\toks0}% need full expansion
!    \xdef\indexsorttmp{\temp}%
!   }%
    %
    % Set up the complete index entry, with both the sort key and
    % the original text, including any font commands.  We write
    % three arguments to \entry to the .?? file (four in the
    % subentry case), texindex reduces to two when writing the .??s
    % sorted result.
    \edef\temp{%
      \write\writeto{%
!       \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}%
    }%
    \temp
  }
  
  % Take care of unwanted page breaks/skips around a whatsit:
  %
  % If a skip is the last thing on the list now, preserve it
--- 5123,5347 ----
    % goes to end-of-line is not handled.
    %
    \macrolist
+   \let\value\indexnofontsvalue
  }
  
! % Give the control sequence a definition that removes the {} that follows
! % its use, e.g. @AA{} -> AA
! \def\indexnofontsdef#1#2{\def#1##1{#2}}%
! 
! 
  
  
  % #1 is the index name, #2 is the entry text.
! \def\doind#1#2{%
!   \iflinks
!   {%
!     %
!     \requireopenindexfile{#1}%
!     \edef\writeto{\csname#1indfile\endcsname}%
!     %
!     \def\indextext{#2}%
!     \safewhatsit\doindwrite
!   }%
!   \fi
! }
  
! % Same as \doind, but for code indices
! \def\docind#1#2{%
    \iflinks
    {%
      %
+     \requireopenindexfile{#1}%
      \edef\writeto{\csname#1indfile\endcsname}%
      %
!     \def\indextext{#2}%
!     \safewhatsit\docindwrite
    }%
    \fi
  }
  
! % 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 above here prevents an object entering into the current
!   % box, which could confound checks such as those in \safewhatsit for
!   % preceding skips.
!   \typeout{Writing index file \jobname.\suffix}%
! \fi}
! \def\indexisfl{fl}
! 
! % Definition for writing index entry sort key.
! {
! \catcode`\-=13
! \gdef\indexwritesortas{%
!   \begingroup
!   \indexnonalnumreappear
!   \indexwritesortasxxx}
! \gdef\indexwritesortasxxx#1{%
!   \xdef\indexsortkey{#1}\endgroup}
! }
! 
! \def\indexwriteseealso#1{
!   \gdef\pagenumbertext{\string\seealso{#1}}%
! }
! \def\indexwriteseeentry#1{
!   \gdef\pagenumbertext{\string\seeentry{#1}}%
! }
! 
! % The default definitions
! \def\sortas#1{}%
! \def\seealso#1{\i{\putwordSeeAlso}\ #1}% for sorted index file only
! \def\putwordSeeAlso{See also}
! \def\seeentry#1{\i{\putwordSee}\ #1}% for sorted index file only
! 
! 
! % Given index entry text like "aaa @subentry bbb @sortas{ZZZ}":
! %   * Set \bracedtext to "{aaa}{bbb}"
! %   * Set \fullindexsortkey to "aaa @subentry ZZZ"
! %   * If @seealso occurs, set \pagenumbertext
  %
! \def\splitindexentry#1{%
!   \gdef\fullindexsortkey{}%
!   \xdef\bracedtext{}%
!   \def\sep{}%
!   \def\seealso##1{}%
!   \def\seeentry##1{}%
!   \expandafter\doindexsegment#1\subentry\finish\subentry
! }
! 
! % append the results from the next segment
! \def\doindexsegment#1\subentry{%
!   \def\segment{#1}%
!   \ifx\segment\isfinish
!   \else
!     %
!     % Fully expand the segment, throwing away any @sortas directives, and
!     % trim spaces.
!     \edef\trimmed{\segment}%
!     \edef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
!     \ifincodeindex
!       \edef\trimmed{\noexpand\code{\trimmed}}%
!     \fi
!     %
!     \xdef\bracedtext{\bracedtext{\trimmed}}%
!     %
!     % Get the string to sort by.  Process the segment with all
!     % font commands turned off.
!     \bgroup
!       \let\sortas\indexwritesortas
!       \let\seealso\indexwriteseealso
!       \let\seeentry\indexwriteseeentry
!       \indexnofonts
!       % The braces around the commands are recognized by texindex.
!       \def\lbracechar{{\string\indexlbrace}}%
!       \def\rbracechar{{\string\indexrbrace}}%
!       \let\{=\lbracechar
!       \let\}=\rbracechar
!       \def\@{{\string\indexatchar}}%
!       \def\atchar##1{\@}%
!       \def\backslashchar{{\string\indexbackslash}}%
!       \uccode`\~=`\\ \uppercase{\let~\backslashchar}%
!       %
!       \let\indexsortkey\empty
!       \global\let\pagenumbertext\empty
!       % Execute the segment and throw away the typeset output.  This executes
!       % any @sortas or @seealso commands in this segment.
!       \setbox\dummybox = \hbox{\segment}%
!       \ifx\indexsortkey\empty{%
!         \indexnonalnumdisappear
!         \xdef\trimmed{\segment}%
!         \xdef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
!         \xdef\indexsortkey{\trimmed}%
!         \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
!       }\fi
!       %
!       % Append to \fullindexsortkey.
!       \edef\tmp{\gdef\noexpand\fullindexsortkey{%
!                   \fullindexsortkey\sep\indexsortkey}}%
!       \tmp
!     \egroup
!     \def\sep{\subentry}%
!     %
!     \expandafter\doindexsegment
!   \fi
! }
! \def\isfinish{\finish}%
! \newbox\dummybox % used above
! 
! \let\subentry\relax
! 
! % Use \ instead of @ in index files.  To support old texi2dvi and texindex.
! % This works without changing the escape character used in the toc or aux
! % files because the index entries are fully expanded here, and \string uses
! % the current value of \escapechar.
! \def\escapeisbackslash{\escapechar=`\\}
! 
! % Use \ in index files by default.  texi2dvi didn't support @ as the escape
! % character (as it checked for "\entry" in the files, and not "@entry").  When
! % the new version of texi2dvi has had a chance to become more prevalent, then
! % the escape character can change back to @ again.  This should be an easy
! % change to make now because both @ and \ are only used as escape characters in
! % index files, never standing for themselves.
! %
! \set txiindexescapeisbackslash
! 
! % Write the entry in \indextext to the index file.
! %
! 
! \newif\ifincodeindex
! \def\doindwrite{\incodeindexfalse\doindwritex}
! \def\docindwrite{\incodeindextrue\doindwritex}
! 
! \def\doindwritex{%
!   \maybemarginindex
!   %
!   \atdummies
!   %
!   \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax\else
!     \escapeisbackslash
    \fi
    %
!   % For texindex which always views { and } as separators.
!   \def\{{\lbracechar{}}%
!   \def\}{\rbracechar{}}%
!   \uccode`\~=`\\ \uppercase{\def~{\backslashchar{}}}%
!   %
!   % Split the entry into primary entry and any subentries, and get the index
!   % sort key.
!   \splitindexentry\indextext
    %
    % Set up the complete index entry, with both the sort key and
    % the original text, including any font commands.  We write
    % three arguments to \entry to the .?? file (four in the
    % subentry case), texindex reduces to two when writing the .??s
    % sorted result.
+   %
    \edef\temp{%
      \write\writeto{%
!       \string\entry{\fullindexsortkey}%
!         {\ifx\pagenumbertext\empty\noexpand\folio\else\pagenumbertext\fi}%
!         \bracedtext}%
    }%
    \temp
  }
  
+ % Put the index entry in the margin if desired (undocumented).
+ \def\maybemarginindex{%
+   \ifx\SETmarginindex\relax\else
+     \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \relax\indextext}}%
+   \fi
+ }
+ \let\SETmarginindex=\relax
+ 
+ 
  % Take care of unwanted page breaks/skips around a whatsit:
  %
  % If a skip is the last thing on the list now, preserve it
***************
*** 4582,4591 ****
  %
  % ..., ready, GO:
  %
! \def\safewhatsit#1{%
! \ifhmode
    #1%
! \else
    % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
    \whatsitskip = \lastskip
    \edef\lastskipmacro{\the\lastskip}%
--- 5377,5385 ----
  %
  % ..., ready, GO:
  %
! \def\safewhatsit#1{\ifhmode
    #1%
!  \else
    % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
    \whatsitskip = \lastskip
    \edef\lastskipmacro{\the\lastskip}%
***************
*** 4609,4615 ****
      % to re-insert the same penalty (values >10000 are used for various
      % signals); since we just inserted a non-discardable item, any
      % following glue (such as a \parskip) would be a breakpoint.  For example:
-     %
      %   @deffn deffn-whatever
      %   @vindex index-whatever
      %   Description.
--- 5403,5408 ----
***************
*** 4622,4629 ****
      % (the whatsit from the \write), so we must insert a \nobreak.
      \nobreak\vskip\whatsitskip
    \fi
! \fi
! }
  
  % The index entry written in the file actually looks like
  %  \entry {sortstring}{page}{topic}
--- 5415,5421 ----
      % (the whatsit from the \write), so we must insert a \nobreak.
      \nobreak\vskip\whatsitskip
    \fi
! \fi}
  
  % The index entry written in the file actually looks like
  %  \entry {sortstring}{page}{topic}
***************
*** 4636,4644 ****
--- 5428,5441 ----
  %  \entry {topic}{pagelist}
  %     for a topic that is used without subtopics
  %  \primary {topic}
+ %  \entry {topic}{}
  %     for the beginning of a topic that is used with subtopics
  %  \secondary {subtopic}{pagelist}
  %     for each subtopic.
+ %  \secondary {subtopic}{}
+ %     for a subtopic with sub-subtopics
+ %  \tertiary {subtopic}{subsubtopic}{pagelist}
+ %     for each sub-subtopic.
  
  % Define the user-accessible indexing commands
  % @findex, @vindex, @kindex, @cindex.
***************
*** 4650,4660 ****
  \def\tindex {\tpindex}
  \def\pindex {\pgindex}
  
- \def\cindexsub {\begingroup\obeylines\cindexsub}
- {\obeylines %
- \gdef\cindexsub "#1" #2^^M{\endgroup %
- \dosubind{cp}{#2}{#1}}}
- 
  % Define the macros used in formatting output of the sorted index material.
  
  % @printindex causes a particular index (the ??s file) to get printed.
--- 5447,5452 ----
***************
*** 4668,4724 ****
    \plainfrenchspacing
    \everypar = {}% don't want the \kern\-parindent from indentation suppression.
    %
    % See if the index file exists and is nonempty.
!   % Change catcode of @ here so that if the index file contains
!   % \initial {@}
!   % as its first line, TeX doesn't complain about mismatched braces
!   % (because it thinks @} is a control sequence).
!   \catcode`\@ = 11
!   \openin 1 \jobname.#1s
    \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
      % index.  The easiest way to prevent this problem is to make sure
      % there is some text.
      \putwordIndexNonexistent
    \else
-     %
      % 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
      \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 = `\\
        \begindoublecolumns
!       \input \jobname.#1s
        \enddoublecolumns
      \fi
    \fi
!   \closein 1
! \endgroup}
  
  % 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
!   %
    % Remove any glue we may have, we'll be inserting our own.
    \removelastskip
    %
    % We like breaks before the index initials, so insert a bonus.
    \nobreak
!   \vskip 0pt plus 3\baselineskip
!   \penalty 0
!   \vskip 0pt plus -3\baselineskip
    %
    % Typeset the initial.  Making this add up to a whole number of
    % baselineskips increases the chance of the dots lining up from column
--- 5460,5586 ----
    \plainfrenchspacing
    \everypar = {}% don't want the \kern\-parindent from indentation suppression.
    %
+   % See comment in \requireopenindexfile.
+   \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
+   %
    % See if the index file exists and is nonempty.
!   \openin 1 \jobname.\indexname s
    \ifeof 1
      % \enddoublecolumns gets confused if there is no text in the index,
      % and it loses the chapter title and the aux file entries for the
      % index.  The easiest way to prevent this problem is to make sure
      % there is some text.
      \putwordIndexNonexistent
+     \typeout{No file \jobname.\indexname s.}%
    \else
      % 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 \thisline
      \ifeof 1
        \putwordIndexIsEmpty
      \else
!       \expandafter\printindexzz\thisline\relax\relax\finish%
!     \fi
!   \fi
!   \closein 1
! \endgroup}
! 
! % If the index file starts with a backslash, forgo reading the index
! % file altogether.  If somebody upgrades texinfo.tex they may still have
! % old index files using \ as the escape character.  Reading this would
! % at best lead to typesetting garbage, at worst a TeX syntax error.
! \def\printindexzz#1#2\finish{%
!   \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax
!     \uccode`\~=`\\ \uppercase{\if\noexpand~}\noexpand#1
!       \expandafter\ifx\csname SETtxiskipindexfileswithbackslash\endcsname\relax
! \errmessage{%
! ERROR: A sorted index file in an obsolete format was skipped.
! To fix this problem, please upgrade your version of 'texi2dvi'
! or 'texi2pdf' to that at <https://ftp.gnu.org/gnu/texinfo>.
! If you are using an old version of 'texindex' (part of the Texinfo
! distribution), you may also need to upgrade to a newer version (at least 6.0).
! You may be able to typeset the index if you run
! 'texindex \jobname.\indexname' yourself.
! You could also try setting the 'txiindexescapeisbackslash' flag by
! running a command like
! 'texi2dvi -t "@set txiindexescapeisbackslash" \jobname.texi'.  If you do
! this, Texinfo will try to use index files in the old format.
! If you continue to have problems, deleting the index files and starting again
! might help (with 'rm \jobname.?? \jobname.??s')%
! }%
!       \else
!         (Skipped sorted index file in obsolete format)
!       \fi
!     \else
        \begindoublecolumns
!       \input \jobname.\indexname s
        \enddoublecolumns
      \fi
+   \else
+     \begindoublecolumns
+     \catcode`\\=0\relax
+     %
+     % Make @ an escape character to give macros a chance to work.  This
+     % should work because we (hopefully) don't otherwise use @ in index files.
+     %\catcode`\@=12\relax
+     \catcode`\@=0\relax
+     \input \jobname.\indexname s
+     \enddoublecolumns
    \fi
! }
  
  % These macros are used by the sorted index file itself.
  % Change them to control the appearance of the index.
  
! {\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
! \catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
! \catcode`\$=3
! \gdef\initialglyphs{%
!   % special control sequences used in the index sort key
!   \let\indexlbrace\{%
!   \let\indexrbrace\}%
!   \let\indexatchar\@%
!   \def\indexbackslash{\math{\backslash}}%
!   %
!   % Some changes for non-alphabetic characters.  Using the glyphs from the
!   % math fonts looks more consistent than the typewriter font used elsewhere
!   % for these characters.
!   \uccode`\~=`\\ \uppercase{\def~{\math{\backslash}}}
!   %
!   % In case @\ is used for backslash
!   \uppercase{\let\\=~}
!   % Can't get bold backslash so don't use bold forward slash
!   \catcode`\/=13
!   \def/{{\secrmnotbold \normalslash}}%
!   \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 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
***************
*** 4726,4749 ****
    % 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}%
    % Do our best not to break after the initial.
    \nobreak
    \vskip .33\baselineskip plus .1\baselineskip
! }}
  
  % \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
      %
--- 5588,5611 ----
    % we need before each entry, but it's better.
    %
    % No shrink because it confuses \balancecolumns.
!   \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.
  %
  \def\entry{%
    \begingroup
      %
***************
*** 4751,4788 ****
      % 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}%
      %
      % Swallow the left brace of the text (first parameter):
      \afterassignment\doentry
--- 5613,5626 ----
      % affect previous text.
      \par
      %
      % No extra space above this paragraph.
      \parskip = 0in
      %
      % 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}% An undocumented command
      %
      % Swallow the left brace of the text (first parameter):
      \afterassignment\doentry
***************
*** 4790,4874 ****
  }
  \def\entrybreak{\unskip\space\ignorespaces}%
  \def\doentry{%
      \bgroup % Instead of the swallowed brace.
        \noindent
        \aftergroup\finishentry
        % And now comes the text of the entry.
  }
! \def\finishentry#1{%
!     % #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
!       \ %
!     \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
        \else
! 	\ #1%
        \fi
      \fi
-     \par
    \endgroup
! }
  
  % Like plain.tex's \dotfill, except uses up at least 1 em.
  \def\indexdotfill{\cleaders
!   \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1fill}
  
  \def\primary #1{\line{#1\hfil}}
  
! \newskip\secondaryindent \secondaryindent=0.5cm
! \def\secondary#1#2{{%
!   \parfillskip=0in
!   \parskip=0in
!   \hangindent=1in
!   \hangafter=1
!   \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
!   \ifpdf
!     \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
!   \else
!     #2
!   \fi
!   \par
! }}
  
  % 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.
! \catcode`\@=11
  
  \newbox\partialpage
  \newdimen\doublecolumnhsize
  
  \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
    % Grab any single-column material above us.
    \output = {%
!     %
!     % Here is a possibility not foreseen in manmac: if we accumulate a
!     % whole lot of material, we might end up calling this \output
!     % routine twice in a row (see the doublecol-lose test, which is
!     % essentially a couple of indexes with @setchapternewpage off).  In
!     % that case we just ship out what is in \partialpage with the normal
!     % output routine.  Generally, \partialpage will be empty when this
!     % runs and this will be a no-op.  See the indexspread.tex test case.
!     \ifvoid\partialpage \else
!       \onepageout{\pagecontents\partialpage}%
!     \fi
      %
      \global\setbox\partialpage = \vbox{%
        % Unvbox the main output page.
--- 5628,5775 ----
  }
  \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.
  }
! {\catcode`\@=11
! \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.
        %
!       % Get the width of the page numbers, and only use
!       % leaders if they are present.
!       \global\setbox\boxB = \hbox{#1}%
!       \ifdim\wd\boxB = 0pt
!         \null\nobreak\hfill\ %
!       \else
!         %
!         \null\nobreak\indexdotfill % Have leaders before the page number.
!         %
!         \ifpdforxetex
!           \pdfgettoks#1.%
!           \hskip\skip\thinshrinkable\the\toksA
!         \else
!           \hskip\skip\thinshrinkable #1%
!         \fi
!       \fi
!     \egroup % end \boxA
!     \ifdim\wd\boxB = 0pt
!       \noindent\unhbox\boxA\par
!       \nobreak
!     \else\bgroup
!       % We want the text of the entries to be aligned to the left, and the
!       % page numbers to be aligned to the right.
!       %
!       \parindent = 0pt
!       \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
!       %
!       \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
!         \dimen@i=2.1em
        \else
!         \dimen@i=0em
        \fi
+       \advance \parfillskip by 0pt minus 1\dimen@i
+       %
+       \dimen@ii = \hsize
+       \advance\dimen@ii by -1\leftskip
+       \advance\dimen@ii by -1\entryrightmargin
+       \advance\dimen@ii by 1\dimen@i
+       \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line
+       \ifdim\dimen@ > 0.8\dimen@ii   % due to long index text
+         % Try to split the text roughly evenly.  \dimen@ will be the length of
+         % the first line.
+         \dimen@ = 0.7\dimen@
+         \dimen@ii = \hsize
+         \ifnum\dimen@>\dimen@ii
+           % If the entry is too long (for example, if it needs more than
+           % two lines), use all the space in the first line.
+           \dimen@ = \dimen@ii
+         \fi
+         \advance\leftskip by 0pt plus 1fill % ragged right
+         \advance \dimen@ by 1\rightskip
+         \parshape = 2 0pt \dimen@ 0em \dimen@ii
+         % Ideally we'd add a finite glue at the end of the first line only,
+         % instead of using \parshape with explicit line lengths, but TeX
+         % doesn't seem to provide a way to do such a thing.
+         %
+         % Indent all lines but the first one.
+         \advance\leftskip by 1em
+         \advance\parindent by -1em
+       \fi\fi
+       \indent % start paragraph
+       \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
! }}
! 
! \newskip\thinshrinkable
! \skip\thinshrinkable=.15em minus .15em
  
  % 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 1filll}
! 
  
  \def\primary #1{\line{#1\hfil}}
  
! \def\secondary{\indententry{0.5cm}}
! \def\tertiary{\indententry{1cm}}
! 
! \def\indententry#1#2#3{%
!   \bgroup
!   \leftskip=#1
!   \entry{#2}{#3}%
!   \egroup
! }
  
  % 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.
! \catcode`\@=11  % private names
  
  \newbox\partialpage
  \newdimen\doublecolumnhsize
  
  \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
+   % If not much space left on page, start a new page.
+   \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
+   %
    % Grab any single-column material above us.
    \output = {%
!     \savetopmark
      %
      \global\setbox\partialpage = \vbox{%
        % Unvbox the main output page.
***************
*** 4902,4928 ****
      \divide\doublecolumnhsize by 2
    \hsize = \doublecolumnhsize
    %
!   % Double the \vsize as well.  (We don't need a separate register here,
!   % since nobody clobbers \vsize.)
    \vsize = 2\vsize
  }
  
  % The double-column output routine for all double-column pages except
! % the last.
  %
  \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
-   % previous page.
    \dimen@ = \vsize
    \divide\dimen@ by 2
-   \advance\dimen@ by -\ht\partialpage
    %
    % box0 will be the left-hand column, box2 the right.
!   \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
!   \onepageout\pagesofar
!   \unvbox255
    \penalty\outputpenalty
  }
  %
--- 5803,5833 ----
      \divide\doublecolumnhsize by 2
    \hsize = \doublecolumnhsize
    %
!   % Get the available space for the double columns -- the normal
!   % (undoubled) page height minus any material left over from the
!   % previous page.
!   \advance\vsize by -\ht\partialpage
    \vsize = 2\vsize
+   %
+   % For the benefit of balancing columns
+   \advance\baselineskip by 0pt plus 0.5pt
  }
  
  % The double-column output routine for all double-column pages except
! % the last, which is done by \balancecolumns.
  %
  \def\doublecolumnout{%
+   %
+   \savetopmark
    \splittopskip=\topskip \splitmaxdepth=\maxdepth
    \dimen@ = \vsize
    \divide\dimen@ by 2
    %
    % box0 will be the left-hand column, box2 the right.
!   \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@
!   \global\advance\vsize by 2\ht\partialpage
!   \onepageout\pagesofar % empty except for the first time we are called
!   \unvbox\PAGE
    \penalty\outputpenalty
  }
  %
***************
*** 4933,4942 ****
    %
    \hsize = \doublecolumnhsize
    \wd0=\hsize \wd2=\hsize
!   \hbox to\pagewidth{\box0\hfil\box2}%
  }
! %
! % All done 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
--- 5838,5848 ----
    %
    \hsize = \doublecolumnhsize
    \wd0=\hsize \wd2=\hsize
!   \hbox to\txipagewidth{\box0\hfil\box2}%
  }
! 
! 
! % Finished 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
***************
*** 4959,4965 ****
    % goal.  When TeX sees \eject from below which follows the final
    % section, it invokes the new output routine that we've set after
    % \balancecolumns below; \onepageout will try to fit the two columns
!   % and the final section into the vbox of \pageheight (see
    % \pagebody), causing an overfull box.
    %
    % Note that glue won't work here, because glue does not exercise the
--- 5865,5871 ----
    % goal.  When TeX sees \eject from below which follows the final
    % section, it invokes the new output routine that we've set after
    % \balancecolumns below; \onepageout will try to fit the two columns
!   % and the final section into the vbox of \txipageheight (see
    % \pagebody), causing an overfull box.
    %
    % Note that glue won't work here, because glue does not exercise the
***************
*** 4967,5019 ****
    \penalty0
    %
    \output = {%
!     % Split the last of the double-column material.  Leave it on the
!     % current page, no automatic page break.
      \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
-     % 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.)
-     \global\output = {\onepageout{\pagecontents\PAGE}}%
    }%
!   \eject
!   \endgroup % started in \begindoublecolumns
!   %
!   % \pagegoal was set to the doubled \vsize above, since we restarted
!   % the current page.  We're now back to normal single-column
!   % typesetting, so reset \pagegoal to the normal \vsize (after the
!   % \endgroup where \vsize got restored).
!   \pagegoal = \vsize
  }
  %
! % Called at the end of the double column material.
  \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, target=\the\dimen@.}%
!   \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 to\dimen@{\unvbox1}%
!   \setbox2=\vbox to\dimen@{\unvbox3}%
    %
-   \pagesofar
  }
  \catcode`\@ = \other
  
--- 5873,5960 ----
    \penalty0
    %
    \output = {%
!     % Split the last of the double-column material.
!     \savetopmark
      \balancecolumns
    }%
!   \eject % call the \output just set
!   \ifdim\pagetotal=0pt
!     % Having called \balancecolumns once, we do not
!     % want to call it again.  Therefore, reset \output to its normal
!     % definition right away.
!     \global\output=\expandafter{\the\defaultoutput}
!     %
!     \endgroup % started in \begindoublecolumns
!     % 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
!     % typesetting, so reset \pagegoal to the normal \vsize.
!     \global\vsize = \txipageheight %
!     \pagegoal = \txipageheight %
!   \else
!     % We had some left-over material.  This might happen when \doublecolumnout
!     % is called in \balancecolumns.  Try again.
!     \expandafter\enddoublecolumns
!   \fi
  }
+ \newbox\balancedcolumns
+ \setbox\balancedcolumns=\vbox{shouldnt see this}%
  %
! % Only called for the last of the double column material.  \doublecolumnout
! % does the others.
  \def\balancecolumns{%
!   \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120.
    \dimen@ = \ht0
!   \ifdim\dimen@<7\baselineskip
!     % Don't split a short final column in two.
!     \setbox2=\vbox{}%
!     \global\setbox\balancedcolumns=\vbox{\pagesofar}%
!   \else
!     % double the leading vertical space
!     \advance\dimen@ by \topskip
!     \advance\dimen@ by-\baselineskip
!     \divide\dimen@ by 2 % target to split to
!     \dimen@ii = \dimen@
!     \splittopskip = \topskip
!     % Loop until left column is at least as high as the right column.
!     {%
!       \vbadness = 10000
!       \loop
!         \global\setbox3 = \copy0
!         \global\setbox1 = \vsplit3 to \dimen@
!       \ifdim\ht1<\ht3
!         \global\advance\dimen@ by 1pt
!       \repeat
!     }%
!     % Now the left column is in box 1, and the right column in box 3.
!     %
!     % Check whether the left column has come out higher than the page itself.
!     % (Note that we have doubled \vsize for the double columns, so
!     % the actual height of the page is 0.5\vsize).
!     \ifdim2\ht1>\vsize
!       % It appears that we have been called upon to balance too much material.
!       % Output some of it with \doublecolumnout, leaving the rest on the page.
!       \setbox\PAGE=\box0
!       \doublecolumnout
!     \else
!       % Compare the heights of the two columns.
!       \ifdim4\ht1>5\ht3
!         % Column heights are too different, so don't make their bottoms
!         % flush with each other.
!         \setbox2=\vbox to \ht1 {\unvbox3\vfill}%
!         \setbox0=\vbox to \ht1 {\unvbox1\vfill}%
!       \else
!         % Make column bottoms flush with each other.
!         \setbox2=\vbox to\ht1{\unvbox3\unskip}%
!         \setbox0=\vbox to\ht1{\unvbox1\unskip}%
!       \fi
!       \global\setbox\balancedcolumns=\vbox{\pagesofar}%
!     \fi
!   \fi
    %
  }
  \catcode`\@ = \other
  
***************
*** 5028,5037 ****
    \null
    \vskip.3\vsize  % move it down on the page a bit
    \begingroup
!     \noindent \titlefonts\rmisbold #1\par % the text
      \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
      \chapoddpage
    \endgroup
  }
--- 5969,5982 ----
    \null
    \vskip.3\vsize  % move it down on the page a bit
    \begingroup
!     \noindent \titlefonts\rm #1\par % the text
      \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
  }
***************
*** 5105,5115 ****
  
  % @raisesections: treat @section as chapter, @subsection as section, etc.
  \def\raisesections{\global\advance\secbase by -1}
- \let\up=\raisesections % original BFox name
  
  % @lowersections: treat @chapter as section, @section as subsection, etc.
  \def\lowersections{\global\advance\secbase by 1}
- \let\down=\lowersections % original BFox name
  
  % we only have subsub.
  \chardef\maxseclevel = 3
--- 6050,6058 ----
***************
*** 5243,5249 ****
    \global\let\subsubsection = \appendixsubsubsec
  }
  
! \outer\parseargdef\unnumbered{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
  \def\unnumberedzzz#1{%
    \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
      \global\advance\unnumberedno by 1
--- 6186,6193 ----
    \global\let\subsubsection = \appendixsubsubsec
  }
  
! % normally unnmhead0 calls unnumberedzzz:
! \outer\parseargdef\unnumbered{\unnmhead0{#1}}
  \def\unnumberedzzz#1{%
    \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
      \global\advance\unnumberedno by 1
***************
*** 5275,5283 ****
  
  % @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
--- 6219,6224 ----
***************
*** 5287,5326 ****
  \let\top\unnumbered
  
  % Sections.
  \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
  \def\seczzz#1{%
    \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
    \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
  }
  
! \outer\parseargdef\appendixsection{\apphead1{#1}} % normally calls appendixsectionzzz
  \def\appendixsectionzzz#1{%
    \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
    \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
  }
  \let\appendixsec\appendixsection
  
! \outer\parseargdef\unnumberedsec{\unnmhead1{#1}} % normally calls unnumberedseczzz
  \def\unnumberedseczzz#1{%
    \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
    \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
  }
  
  % Subsections.
! \outer\parseargdef\numberedsubsec{\numhead2{#1}} % normally calls numberedsubseczzz
  \def\numberedsubseczzz#1{%
    \global\subsubsecno=0  \global\advance\subsecno by 1
    \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
  }
  
! \outer\parseargdef\appendixsubsec{\apphead2{#1}} % normally calls appendixsubseczzz
  \def\appendixsubseczzz#1{%
    \global\subsubsecno=0  \global\advance\subsecno by 1
    \sectionheading{#1}{subsec}{Yappendix}%
                   {\appendixletter.\the\secno.\the\subsecno}%
  }
  
! \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
  \def\unnumberedsubseczzz#1{%
    \global\subsubsecno=0  \global\advance\subsecno by 1
    \sectionheading{#1}{subsec}{Ynothing}%
--- 6228,6274 ----
  \let\top\unnumbered
  
  % Sections.
+ %
  \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
  \def\seczzz#1{%
    \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
    \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
  }
  
! % normally calls appendixsectionzzz:
! \outer\parseargdef\appendixsection{\apphead1{#1}}
  \def\appendixsectionzzz#1{%
    \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
    \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
  }
  \let\appendixsec\appendixsection
  
! % normally calls unnumberedseczzz:
! \outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
  \def\unnumberedseczzz#1{%
    \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
    \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
  }
  
  % Subsections.
! %
! % normally calls numberedsubseczzz:
! \outer\parseargdef\numberedsubsec{\numhead2{#1}}
  \def\numberedsubseczzz#1{%
    \global\subsubsecno=0  \global\advance\subsecno by 1
    \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
  }
  
! % normally calls appendixsubseczzz:
! \outer\parseargdef\appendixsubsec{\apphead2{#1}}
  \def\appendixsubseczzz#1{%
    \global\subsubsecno=0  \global\advance\subsecno by 1
    \sectionheading{#1}{subsec}{Yappendix}%
                   {\appendixletter.\the\secno.\the\subsecno}%
  }
  
! % normally calls unnumberedsubseczzz:
! \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
  \def\unnumberedsubseczzz#1{%
    \global\subsubsecno=0  \global\advance\subsecno by 1
    \sectionheading{#1}{subsec}{Ynothing}%
***************
*** 5328,5348 ****
  }
  
  % Subsubsections.
! \outer\parseargdef\numberedsubsubsec{\numhead3{#1}} % normally numberedsubsubseczzz
  \def\numberedsubsubseczzz#1{%
    \global\advance\subsubsecno by 1
    \sectionheading{#1}{subsubsec}{Ynumbered}%
                   {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
  }
  
! \outer\parseargdef\appendixsubsubsec{\apphead3{#1}} % normally appendixsubsubseczzz
  \def\appendixsubsubseczzz#1{%
    \global\advance\subsubsecno by 1
    \sectionheading{#1}{subsubsec}{Yappendix}%
                   {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
  }
  
! \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
  \def\unnumberedsubsubseczzz#1{%
    \global\advance\subsubsecno by 1
    \sectionheading{#1}{subsubsec}{Ynothing}%
--- 6276,6300 ----
  }
  
  % Subsubsections.
! %
! % normally numberedsubsubseczzz:
! \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
  \def\numberedsubsubseczzz#1{%
    \global\advance\subsubsecno by 1
    \sectionheading{#1}{subsubsec}{Ynumbered}%
                   {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
  }
  
! % normally appendixsubsubseczzz:
! \outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
  \def\appendixsubsubseczzz#1{%
    \global\advance\subsubsecno by 1
    \sectionheading{#1}{subsubsec}{Yappendix}%
                   {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
  }
  
! % normally unnumberedsubsubseczzz:
! \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
  \def\unnumberedsubsubseczzz#1{%
    \global\advance\subsubsecno by 1
    \sectionheading{#1}{subsubsec}{Ynothing}%
***************
*** 5358,5371 ****
  
  % Define @majorheading, @heading and @subheading
  
- % NOTE on use of \vbox for chapter headings, section headings, and such:
- %       1) We use \vbox rather than the earlier \line to permit
- %          overlong headings to fold.
- %       2) \hyphenpenalty is set to 10000 because hyphenation in a
- %          heading is obnoxious; this forbids it.
- %       3) Likewise, headings look best if no \parindent is used, and
- %          if justification is not attempted.  Hence \raggedright.
- 
  \def\majorheading{%
    {\advance\chapheadingskip by 10pt \chapbreak }%
    \parsearg\chapheadingzzz
--- 6310,6315 ----
***************
*** 5373,5382 ****
  
  \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
  \def\chapheadingzzz#1{%
!   {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
!                     \parindent=0pt\ptexraggedright
!                     \rmisbold #1\hfill}}%
!   \bigskip \par\penalty 200\relax
    \suppressfirstparagraphindent
  }
  
--- 6317,6324 ----
  
  \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
  \def\chapheadingzzz#1{%
!   \vbox{\chapfonts \raggedtitlesettings #1\par}%
!   \nobreak\bigskip \nobreak
    \suppressfirstparagraphindent
  }
  
***************
*** 5392,5407 ****
  % (including whitespace, linebreaking, etc. around it),
  % given all the information in convenient, parsed form.
  
! %%% Args are the skip and penalty (usually negative)
  \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
  
- %%% Define plain chapter starts, and page on/off switching for it
  % Parameter controlling skip before chapter headings (if needed)
- 
  \newskip\chapheadingskip
  
  \def\chapbreak{\dobreak \chapheadingskip {-4000}}
  \def\chappager{\par\vfill\supereject}
  % 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.
--- 6334,6352 ----
  % (including whitespace, linebreaking, etc. around it),
  % given all the information in convenient, parsed form.
  
! % Args are the skip and penalty (usually negative)
  \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
  
  % Parameter controlling skip before chapter headings (if needed)
  \newskip\chapheadingskip
  
+ % 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.
***************
*** 5416,5469 ****
    \fi
  }
  
! \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
  
  \def\CHAPPAGoff{%
  \global\let\contentsalignmacro = \chappager
  \global\let\pchapsepmacro=\chapbreak
! \global\let\pagealignmacro=\chappager}
  
  \def\CHAPPAGon{%
  \global\let\contentsalignmacro = \chappager
  \global\let\pchapsepmacro=\chappager
- \global\let\pagealignmacro=\chappager
  \global\def\HEADINGSon{\HEADINGSsingle}}
  
  \def\CHAPPAGodd{%
  \global\let\contentsalignmacro = \chapoddpage
  \global\let\pchapsepmacro=\chapoddpage
- \global\let\pagealignmacro=\chapoddpage
  \global\def\HEADINGSon{\HEADINGSdouble}}
  
  \CHAPPAGon
  
! % Chapter opening.
  %
  % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
  % Yappendix, Yomitfromtoc), #3 the chapter number.
  %
  % To test against our argument.
  \def\Ynothingkeyword{Ynothing}
- \def\Yomitfromtockeyword{Yomitfromtoc}
  \def\Yappendixkeyword{Yappendix}
  %
  \def\chapmacro#1#2#3{%
    % Insert the first mark before the heading break (see notes for \domark).
!   \let\prevchapterdefs=\lastchapterdefs
!   \let\prevsectiondefs=\lastsectiondefs
!   \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
                          \gdef\thissection{}}%
    %
    \def\temptype{#2}%
    \ifx\temptype\Ynothingkeyword
!     \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
                            \gdef\thischapter{\thischaptername}}%
    \else\ifx\temptype\Yomitfromtockeyword
!     \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
                            \gdef\thischapter{}}%
    \else\ifx\temptype\Yappendixkeyword
      \toks0={#1}%
!     \xdef\lastchapterdefs{%
        \gdef\noexpand\thischaptername{\the\toks0}%
        \gdef\noexpand\thischapternum{\appendixletter}%
        % \noexpand\putwordAppendix avoids expanding indigestible
--- 6361,6416 ----
    \fi
  }
  
! \parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname}
  
  \def\CHAPPAGoff{%
  \global\let\contentsalignmacro = \chappager
  \global\let\pchapsepmacro=\chapbreak
! \global\def\HEADINGSon{\HEADINGSsinglechapoff}}
  
  \def\CHAPPAGon{%
  \global\let\contentsalignmacro = \chappager
  \global\let\pchapsepmacro=\chappager
  \global\def\HEADINGSon{\HEADINGSsingle}}
  
  \def\CHAPPAGodd{%
  \global\let\contentsalignmacro = \chapoddpage
  \global\let\pchapsepmacro=\chapoddpage
  \global\def\HEADINGSon{\HEADINGSdouble}}
  
  \CHAPPAGon
  
! % \chapmacro - Chapter opening.
  %
  % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
  % Yappendix, Yomitfromtoc), #3 the chapter number.
+ % Not used for @heading series.
  %
  % To test against our argument.
  \def\Ynothingkeyword{Ynothing}
  \def\Yappendixkeyword{Yappendix}
+ \def\Yomitfromtockeyword{Yomitfromtoc}
  %
  \def\chapmacro#1#2#3{%
+   \expandafter\ifx\thisenv\titlepage\else
+     \checkenv{}% chapters, etc., should not start inside an environment.
+   \fi
    % Insert the first mark before the heading break (see notes for \domark).
!   \let\prevchapterdefs=\currentchapterdefs
!   \let\prevsectiondefs=\currentsectiondefs
!   \gdef\currentsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
                          \gdef\thissection{}}%
    %
    \def\temptype{#2}%
    \ifx\temptype\Ynothingkeyword
!     \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
                            \gdef\thischapter{\thischaptername}}%
    \else\ifx\temptype\Yomitfromtockeyword
!     \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
                            \gdef\thischapter{}}%
    \else\ifx\temptype\Yappendixkeyword
      \toks0={#1}%
!     \xdef\currentchapterdefs{%
        \gdef\noexpand\thischaptername{\the\toks0}%
        \gdef\noexpand\thischapternum{\appendixletter}%
        % \noexpand\putwordAppendix avoids expanding indigestible
***************
*** 5474,5480 ****
      }%
    \else
      \toks0={#1}%
!     \xdef\lastchapterdefs{%
        \gdef\noexpand\thischaptername{\the\toks0}%
        \gdef\noexpand\thischapternum{\the\chapno}%
        % \noexpand\putwordChapter avoids expanding indigestible
--- 6421,6427 ----
      }%
    \else
      \toks0={#1}%
!     \xdef\currentchapterdefs{%
        \gdef\noexpand\thischaptername{\the\toks0}%
        \gdef\noexpand\thischapternum{\the\chapno}%
        % \noexpand\putwordChapter avoids expanding indigestible
***************
*** 5494,5510 ****
    %
    % Now the second mark, after the heading break.  No break points
    % between here and the heading.
!   \let\prevchapterdefs=\lastchapterdefs
!   \let\prevsectiondefs=\lastsectiondefs
    \domark
    %
    {%
!     \chapfonts \rmisbold
      %
!     % Have to define \lastsection before calling \donoderef, because the
      % xref code eventually uses it.  On the other hand, it has to be called
      % after \pchapsepmacro, or the headline will change too soon.
!     \gdef\lastsection{#1}%
      %
      % Only insert the separating space if we have a chapter/appendix
      % number, and don't print the unnumbered ``number''.
--- 6441,6458 ----
    %
    % Now the second mark, after the heading break.  No break points
    % between here and the heading.
!   \let\prevchapterdefs=\currentchapterdefs
!   \let\prevsectiondefs=\currentsectiondefs
    \domark
    %
    {%
!     \chapfonts \rm
!     \let\footnote=\errfootnoteheading % give better error message
      %
!     % Have to define \currentsection before calling \donoderef, because the
      % xref code eventually uses it.  On the other hand, it has to be called
      % after \pchapsepmacro, or the headline will change too soon.
!     \gdef\currentsection{#1}%
      %
      % Only insert the separating space if we have a chapter/appendix
      % number, and don't print the unnumbered ``number''.
***************
*** 5536,5543 ****
      %
      % Typeset the actual heading.
      \nobreak % Avoid page breaks at the interline glue.
!     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
!           \hangindent=\wd0 \centerparametersmaybe
            \unhbox0 #1\par}%
    }%
    \nobreak\bigskip % no page break after a chapter title
--- 6484,6490 ----
      %
      % Typeset the actual heading.
      \nobreak % Avoid page breaks at the interline glue.
!     \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
            \unhbox0 #1\par}%
    }%
    \nobreak\bigskip % no page break after a chapter title
***************
*** 5553,5582 ****
  }
  
  
- % I don't think this chapter style is supported any more, so I'm not
- % updating it with the new noderef stuff.  We'll see.  --karl, 11aug03.
- %
- \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
- %
- \def\unnchfopen #1{%
- \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
-                        \parindent=0pt\ptexraggedright
-                        \rmisbold #1\hfill}}\bigskip \par\nobreak
- }
- \def\chfopen #1#2{\chapoddpage {\chapfonts
- \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
- \par\penalty 5000 %
- }
- \def\centerchfopen #1{%
- \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
-                        \parindent=0pt
-                        \hfill {\rmisbold #1}\hfill}}\bigskip \par\nobreak
- }
- \def\CHAPFopen{%
-   \global\let\chapmacro=\chfopen
-   \global\let\centerchapmacro=\centerchfopen}
- 
- 
  % Section titles.  These macros combine the section number parts and
  % call the generic \sectionheading to do the printing.
  %
--- 6500,6505 ----
***************
*** 5594,5618 ****
  
  % Print any size, any type, section title.
  %
! % #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is
! % the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the
! % section number.
  %
  \def\seckeyword{sec}
  %
  \def\sectionheading#1#2#3#4{%
    {%
-     % Switch to the right set of fonts.
-     \csname #2fonts\endcsname \rmisbold
-     %
      \def\sectionlevel{#2}%
      \def\temptype{#3}%
      %
      % Insert first mark before the heading break (see notes for \domark).
!     \let\prevsectiondefs=\lastsectiondefs
      \ifx\temptype\Ynothingkeyword
        \ifx\sectionlevel\seckeyword
!         \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
                                \gdef\thissection{\thissectionname}}%
        \fi
      \else\ifx\temptype\Yomitfromtockeyword
--- 6517,6550 ----
  
  % Print any size, any type, section title.
  %
! % #1 is the text of the title,
! % #2 is the section level (sec/subsec/subsubsec),
! % #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc),
! % #4 is the section number.
  %
  \def\seckeyword{sec}
  %
  \def\sectionheading#1#2#3#4{%
    {%
      \def\sectionlevel{#2}%
      \def\temptype{#3}%
      %
+     % It is ok for the @heading series commands to appear inside an
+     % environment (it's been historically allowed, though the logic is
+     % dubious), but not the others.
+     \ifx\temptype\Yomitfromtockeyword\else
+       \checkenv{}% non-@*heading should not be in an environment.
+     \fi
+     \let\footnote=\errfootnoteheading
+     %
+     % Switch to the right set of fonts.
+     \csname #2fonts\endcsname \rm
+     %
      % Insert first mark before the heading break (see notes for \domark).
!     \let\prevsectiondefs=\currentsectiondefs
      \ifx\temptype\Ynothingkeyword
        \ifx\sectionlevel\seckeyword
!         \gdef\currentsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
                                \gdef\thissection{\thissectionname}}%
        \fi
      \else\ifx\temptype\Yomitfromtockeyword
***************
*** 5620,5626 ****
      \else\ifx\temptype\Yappendixkeyword
        \ifx\sectionlevel\seckeyword
          \toks0={#1}%
!         \xdef\lastsectiondefs{%
            \gdef\noexpand\thissectionname{\the\toks0}%
            \gdef\noexpand\thissectionnum{#4}%
            % \noexpand\putwordSection avoids expanding indigestible
--- 6552,6558 ----
      \else\ifx\temptype\Yappendixkeyword
        \ifx\sectionlevel\seckeyword
          \toks0={#1}%
!         \xdef\currentsectiondefs{%
            \gdef\noexpand\thissectionname{\the\toks0}%
            \gdef\noexpand\thissectionnum{#4}%
            % \noexpand\putwordSection avoids expanding indigestible
***************
*** 5633,5639 ****
      \else
        \ifx\sectionlevel\seckeyword
          \toks0={#1}%
!         \xdef\lastsectiondefs{%
            \gdef\noexpand\thissectionname{\the\toks0}%
            \gdef\noexpand\thissectionnum{#4}%
            % \noexpand\putwordSection avoids expanding indigestible
--- 6565,6571 ----
      \else
        \ifx\sectionlevel\seckeyword
          \toks0={#1}%
!         \xdef\currentsectiondefs{%
            \gdef\noexpand\thissectionname{\the\toks0}%
            \gdef\noexpand\thissectionnum{#4}%
            % \noexpand\putwordSection avoids expanding indigestible
***************
*** 5659,5686 ****
      %
      % Now the second mark, after the heading break.  No break points
      % between here and the heading.
!     \let\prevsectiondefs=\lastsectiondefs
      \domark
      %
      % Only insert the space after the number if we have a section number.
      \ifx\temptype\Ynothingkeyword
        \setbox0 = \hbox{}%
        \def\toctype{unn}%
!       \gdef\lastsection{#1}%
      \else\ifx\temptype\Yomitfromtockeyword
        % for @headings -- no section number, don't include in toc,
!       % and don't redefine \lastsection.
        \setbox0 = \hbox{}%
        \def\toctype{omit}%
        \let\sectionlevel=\empty
      \else\ifx\temptype\Yappendixkeyword
        \setbox0 = \hbox{#4\enspace}%
        \def\toctype{app}%
!       \gdef\lastsection{#1}%
      \else
        \setbox0 = \hbox{#4\enspace}%
        \def\toctype{num}%
!       \gdef\lastsection{#1}%
      \fi\fi\fi
      %
      % Write the toc entry (before \donoderef).  See comments in \chapmacro.
--- 6591,6618 ----
      %
      % Now the second mark, after the heading break.  No break points
      % between here and the heading.
!     \global\let\prevsectiondefs=\currentsectiondefs
      \domark
      %
      % Only insert the space after the number if we have a section number.
      \ifx\temptype\Ynothingkeyword
        \setbox0 = \hbox{}%
        \def\toctype{unn}%
!       \gdef\currentsection{#1}%
      \else\ifx\temptype\Yomitfromtockeyword
        % for @headings -- no section number, don't include in toc,
!       % and don't redefine \currentsection.
        \setbox0 = \hbox{}%
        \def\toctype{omit}%
        \let\sectionlevel=\empty
      \else\ifx\temptype\Yappendixkeyword
        \setbox0 = \hbox{#4\enspace}%
        \def\toctype{app}%
!       \gdef\currentsection{#1}%
      \else
        \setbox0 = \hbox{#4\enspace}%
        \def\toctype{num}%
!       \gdef\currentsection{#1}%
      \fi\fi\fi
      %
      % Write the toc entry (before \donoderef).  See comments in \chapmacro.
***************
*** 5713,5727 ****
    %
    % We'll almost certainly start a paragraph next, so don't let that
    % glue accumulate.  (Not a breakpoint because it's preceded by a
!   % discardable item.)
    \vskip-\parskip
    %
!   % This is purely so the last item on the list is a known \penalty >
!   % 10000.  This is so \startdefun can avoid allowing breakpoints after
!   % section headings.  Otherwise, it would insert a valid breakpoint between:
!   %
!   %   @section sec-whatever
!   %   @deffn def-whatever
    \penalty 10001
  }
  
--- 6645,6659 ----
    %
    % We'll almost certainly start a paragraph next, so don't let that
    % glue accumulate.  (Not a breakpoint because it's preceded by a
!   % discardable item.)  However, when a paragraph is not started next
!   % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
!   % or the negative glue will cause weirdly wrong output, typically
!   % obscuring the section heading with something else.
    \vskip-\parskip
    %
!   % This is so the last item on the main vertical list is a known
!   % \penalty > 10000, so \startdefun, etc., can recognize the situation
!   % and do the needful.
    \penalty 10001
  }
  
***************
*** 5770,5776 ****
    % 1 and 2 (the page numbers aren't printed), and so are the first
    % two pages of the document.  Thus, we'd have two destinations named
    % `1', and two named `2'.
!   \ifpdf \global\pdfmakepagedesttrue \fi
  }
  
  
--- 6702,6710 ----
    % 1 and 2 (the page numbers aren't printed), and so are the first
    % two pages of the document.  Thus, we'd have two destinations named
    % `1', and two named `2'.
!   \ifpdforxetex
!     \global\pdfmakepagedesttrue
!   \fi
  }
  
  
***************
*** 5806,5814 ****
  %
  \def\startcontents#1{%
    % If @setchapternewpage on, and @headings double, the contents should
!   % start on an odd page, unlike chapters.  Thus, we maintain
!   % \contentsalignmacro in parallel with \pagealignmacro.
!   % From: Torbjorn Granlund <tege@matematik.su.se>
    \contentsalignmacro
    \immediate\closeout\tocfile
    %
--- 6740,6746 ----
  %
  \def\startcontents#1{%
    % If @setchapternewpage on, and @headings double, the contents should
!   % start on an odd page, unlike chapters.
    \contentsalignmacro
    \immediate\closeout\tocfile
    %
***************
*** 5819,5828 ****
    \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.
      %
      % Roman numerals for page numbers.
      \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
  }
  
  % redefined for the two-volume lispref.  We always output on
--- 6751,6763 ----
    \savepageno = \pageno
    \begingroup                  % Set up to handle contents files properly.
      \raggedbottom              % Worry more about breakpoints than the bottom.
!     \entryrightmargin=\contentsrightmargin % Don't use the full line length.
      %
      % Roman numerals for page numbers.
      \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
+     \def\thistitle{}% no title in double-sided headings
+     % Record where the Roman numerals started.
+     \ifnum\romancount=0 \global\romancount=\pagecount \fi
  }
  
  % redefined for the two-volume lispref.  We always output on
***************
*** 5845,5852 ****
      \fi
      \closein 1
    \endgroup
!   \lastnegativepageno = \pageno
!   \global\pageno = \savepageno
  }
  
  % And just the chapters.
--- 6780,6786 ----
      \fi
      \closein 1
    \endgroup
!   \contentsendroman
  }
  
  % And just the chapters.
***************
*** 5881,5890 ****
      \vfill \eject
      \contentsalignmacro % in case @setchapternewpage odd is in effect
    \endgroup
    \lastnegativepageno = \pageno
    \global\pageno = \savepageno
  }
- \let\shortcontents = \summarycontents
  
  % Typeset the label for a chapter or appendix for the short contents.
  % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
--- 6815,6834 ----
      \vfill \eject
      \contentsalignmacro % in case @setchapternewpage odd is in effect
    \endgroup
+   \contentsendroman
+ }
+ \let\shortcontents = \summarycontents
+ 
+ % Get ready to use Arabic numerals again
+ \def\contentsendroman{%
    \lastnegativepageno = \pageno
    \global\pageno = \savepageno
+   %
+   % If \romancount > \arabiccount, the contents are at the end of the
+   % document.  Otherwise, advance where the Arabic numerals start for
+   % the page numbers.
+   \ifnum\romancount>\arabiccount\else\global\arabiccount=\pagecount\fi
  }
  
  % Typeset the label for a chapter or appendix for the short contents.
  % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
***************
*** 5913,5919 ****
  % exist, with an empty box.  Let's hope all the numbers have the same width.
  % Also ignore the page number, which is conventionally not printed.
  \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
! \def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}}
  %
  % Parts, in the short toc.
  \def\shortpartentry#1#2#3#4{%
--- 6857,6871 ----
  % exist, with an empty box.  Let's hope all the numbers have the same width.
  % Also ignore the page number, which is conventionally not printed.
  \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
! \def\partentry#1#2#3#4{%
!   % Add stretch and a bonus for breaking the page before the part heading.
!   % This reduces the chance of the page being broken immediately after the
!   % part heading, before a following chapter heading.
!   \vskip 0pt plus 5\baselineskip
!   \penalty-300
!   \vskip 0pt plus -5\baselineskip
!   \dochapentry{\numeralbox\labelspace#1}{}%
! }
  %
  % Parts, in the short toc.
  \def\shortpartentry#1#2#3#4{%
***************
*** 5924,5930 ****
  
  % 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{%
--- 6876,6882 ----
  
  % 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{%
***************
*** 5939,5945 ****
    \setbox0 = \hbox{\putwordAppendix{} M}%
    \hbox to \wd0{\putwordAppendix{} #1\hss}}
  %
! \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}}
  
  % Unnumbered chapters.
  \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
--- 6891,6897 ----
    \setbox0 = \hbox{\putwordAppendix{} M}%
    \hbox to \wd0{\putwordAppendix{} #1\hss}}
  %
! \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}}
  
  % Unnumbered chapters.
  \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
***************
*** 5972,5977 ****
--- 6924,6931 ----
  \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
***************
*** 6016,6022 ****
  % But \@ or @@ will get a plain @ character.
  
  \envdef\tex{%
!   \setupmarkupstyle{tex}%
    \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
    \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
    \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
--- 6970,6976 ----
  % But \@ or @@ will get a plain @ character.
  
  \envdef\tex{%
!   \setregularquotes
    \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
    \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
    \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
***************
*** 6026,6039 ****
    \catcode `\|=\other
    \catcode `\<=\other
    \catcode `\>=\other
!   \catcode`\`=\other
!   \catcode`\'=\other
!   \escapechar=`\\
    %
    % ' is active in math mode (mathcode"8000).  So reset it, and all our
    % other math active characters (just in case), to plain's definitions.
    \mathactive
    %
    \let\b=\ptexb
    \let\bullet=\ptexbullet
    \let\c=\ptexc
--- 6980,6993 ----
    \catcode `\|=\other
    \catcode `\<=\other
    \catcode `\>=\other
!   \catcode `\`=\other
!   \catcode `\'=\other
    %
    % ' is active in math mode (mathcode"8000).  So reset it, and all our
    % other math active characters (just in case), to plain's definitions.
    \mathactive
    %
+   % Inverse of the list at the beginning of the file.
    \let\b=\ptexb
    \let\bullet=\ptexbullet
    \let\c=\ptexc
***************
*** 6049,6057 ****
    \let\+=\tabalign
    \let\}=\ptexrbrace
    \let\/=\ptexslash
    \let\*=\ptexstar
    \let\t=\ptext
!   \expandafter \let\csname top\endcsname=\ptextop  % outer
    \let\frenchspacing=\plainfrenchspacing
    %
    \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
--- 7003,7013 ----
    \let\+=\tabalign
    \let\}=\ptexrbrace
    \let\/=\ptexslash
+   \let\sp=\ptexsp
    \let\*=\ptexstar
+   %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode
    \let\t=\ptext
!   \expandafter \let\csname top\endcsname=\ptextop  % we've made it outer
    \let\frenchspacing=\plainfrenchspacing
    %
    \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
***************
*** 6088,6093 ****
--- 7044,7067 ----
      \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
***************
*** 6096,6114 ****
    \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
  
  % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
  % environment contents.
! \font\circle=lcircle10
! \newdimen\circthick
! \newdimen\cartouter\newdimen\cartinner
! \newskip\normbskip\newskip\normpskip\newskip\normlskip
! \circthick=\fontdimen8\circle
  %
  \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
  \def\ctr{{\hskip 6pt\circle\char'010}}
--- 7070,7082 ----
    \fi
  }}
  
  % \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
  
  % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
  % environment contents.
! 
  %
  \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
  \def\ctr{{\hskip 6pt\circle\char'010}}
***************
*** 6123,6129 ****
--- 7091,7108 ----
  %
  \newskip\lskip\newskip\rskip
  
+ % only require the font if @cartouche is actually used
+ \def\cartouchefontdefs{%
+   \font\circle=lcircle10\relax
+   \circthick=\fontdimen8\circle
+ }
+ \newdimen\circthick
+ \newdimen\cartouter\newdimen\cartinner
+ \newskip\normbskip\newskip\normpskip\newskip\normlskip
+ 
+ 
  \envdef\cartouche{%
+   \cartouchefontdefs
    \ifhmode\par\fi  % can't be in the midst of a paragraph.
    \startsavinginserts
    \lskip=\leftskip \rskip=\rightskip
***************
*** 6135,6143 ****
  				% side, and for 6pt waste from
  				% each corner char, and rule thickness
    \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
!   % Flag to tell @lisp, etc., not to narrow margin.
!   \let\nonarrowing = t%
!   \vbox\bgroup
        \baselineskip=0pt\parskip=0pt\lineskip=0pt
        \carttop
        \hbox\bgroup
--- 7114,7126 ----
  				% side, and for 6pt waste from
  				% each corner char, and rule thickness
    \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
!   %
!   % If this cartouche directly follows a sectioning command, we need the
!   % \parskip glue (backspaced over by default) or the cartouche can
!   % collide with the section heading.
!   \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
!   %
!   \setbox\groupbox=\vbox\bgroup
        \baselineskip=0pt\parskip=0pt\lineskip=0pt
        \carttop
        \hbox\bgroup
***************
*** 6150,6156 ****
  	      \lineskip=\normlskip
  	      \parskip=\normpskip
  	      \vskip -\parskip
! 	      \comment % For explanation, see the end of \def\group.
  }
  \def\Ecartouche{%
                \ifhmode\par\fi
--- 7133,7139 ----
  	      \lineskip=\normlskip
  	      \parskip=\normpskip
  	      \vskip -\parskip
! 	      \comment % For explanation, see the end of def\group.
  }
  \def\Ecartouche{%
                \ifhmode\par\fi
***************
*** 6161,6166 ****
--- 7144,7150 ----
        \egroup
        \cartbot
    \egroup
+   \addgroupbox
    \checkinserts
  }
  
***************
*** 6170,6176 ****
  \newdimen\nonfillparindent
  \def\nonfillstart{%
    \aboveenvbreak
!   \hfuzz = 12pt % Don't be fussy
    \sepspaces % Make spaces be word-separators rather than space tokens.
    \let\par = \lisppar % don't ignore blank lines
    \obeylines % each line of input is a line of output
--- 7154,7160 ----
  \newdimen\nonfillparindent
  \def\nonfillstart{%
    \aboveenvbreak
!   \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy
    \sepspaces % Make spaces be word-separators rather than space tokens.
    \let\par = \lisppar % don't ignore blank lines
    \obeylines % each line of input is a line of output
***************
*** 6212,6218 ****
  % If you want all examples etc. small: @set dispenvsize small.
  % If you want even small examples the full size: @set dispenvsize nosmall.
  % This affects the following displayed environments:
! %    @example, @display, @format, @lisp
  %
  \def\smallword{small}
  \def\nosmallword{nosmall}
--- 7196,7202 ----
  % If you want all examples etc. small: @set dispenvsize small.
  % If you want even small examples the full size: @set dispenvsize nosmall.
  % This affects the following displayed environments:
! %    @example, @display, @format, @lisp, @verbatim
  %
  \def\smallword{small}
  \def\nosmallword{nosmall}
***************
*** 6258,6266 ****
  %
  \maketwodispenvdef{lisp}{example}{%
    \nonfillstart
!   \tt\setupmarkupstyle{example}%
    \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
!   \gobble % eat return
  }
  % @display/@smalldisplay: same as @lisp except keep current font.
  %
--- 7242,7250 ----
  %
  \maketwodispenvdef{lisp}{example}{%
    \nonfillstart
!   \tt\setcodequotes
    \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
!   \parsearg\gobble
  }
  % @display/@smalldisplay: same as @lisp except keep current font.
  %
***************
*** 6299,6305 ****
  % @raggedright does more-or-less normal line breaking but no right
  % justification.  From plain.tex.
  \envdef\raggedright{%
!   \rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax
  }
  \let\Eraggedright\par
  
--- 7283,7289 ----
  % @raggedright does more-or-less normal line breaking but no right
  % justification.  From plain.tex.
  \envdef\raggedright{%
!   \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
  }
  \let\Eraggedright\par
  
***************
*** 6328,6343 ****
  \makedispenvdef{quotation}{\quotationstart}
  %
  \def\quotationstart{%
!   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
!   \parindent=0pt
!   %
!   % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
    \ifx\nonarrowing\relax
-     \advance\leftskip by \lispnarrowing
      \advance\rightskip by \lispnarrowing
-     \exdentamount = \lispnarrowing
-   \else
-     \let\nonarrowing = \relax
    \fi
    \parsearg\quotationlabel
  }
--- 7312,7320 ----
  \makedispenvdef{quotation}{\quotationstart}
  %
  \def\quotationstart{%
!   \indentedblockstart % same as \indentedblock, but increase right margin too.
    \ifx\nonarrowing\relax
      \advance\rightskip by \lispnarrowing
    \fi
    \parsearg\quotationlabel
  }
***************
*** 6347,6353 ****
  %
  \def\Equotation{%
    \par
!   \ifx\quotationauthor\undefined\else
      % indent a bit.
      \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
    \fi
--- 7324,7330 ----
  %
  \def\Equotation{%
    \par
!   \ifx\quotationauthor\thisisundefined\else
      % indent a bit.
      \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
    \fi
***************
*** 6363,6368 ****
--- 7340,7371 ----
    \fi
  }
  
+ % @indentedblock is like @quotation, but indents only on the left and
+ % has no optional argument.
+ %
+ \makedispenvdef{indentedblock}{\indentedblockstart}
+ %
+ \def\indentedblockstart{%
+   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
+   \parindent=0pt
+   %
+   % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
+   \ifx\nonarrowing\relax
+     \advance\leftskip by \lispnarrowing
+     \exdentamount = \lispnarrowing
+   \else
+     \let\nonarrowing = \relax
+   \fi
+ }
+ 
+ % Keep a nonzero parskip for the environment, since we're doing normal filling.
+ %
+ \def\Eindentedblock{%
+   \par
+   {\parskip=0pt \afterenvbreak}%
+ }
+ \def\Esmallindentedblock{\Eindentedblock}
+ 
  
  % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
  % If we want to allow any <char> as delimiter,
***************
*** 6399,6405 ****
  \def\setupverb{%
    \tt  % easiest (and conventionally used) font for verbatim
    \def\par{\leavevmode\endgraf}%
!   \setupmarkupstyle{verb}%
    \tabeightspaces
    % Respect line breaks,
    % print special symbols as themselves, and
--- 7402,7408 ----
  \def\setupverb{%
    \tt  % easiest (and conventionally used) font for verbatim
    \def\par{\leavevmode\endgraf}%
!   \setcodequotes
    \tabeightspaces
    % Respect line breaks,
    % print special symbols as themselves, and
***************
*** 6414,6426 ****
  \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
  %
  % We typeset each line of the verbatim in an \hbox, so we can handle
! % tabs.  The \global is in case the verbatim line starts with an accent,
! % or some other command that starts with a begin-group.  Otherwise, the
! % entire \verbbox would disappear at the corresponding end-group, before
! % it is typeset.  Meanwhile, we can't have nested verbatim commands
! % (can we?), so the \global won't be overwriting itself.
  \newbox\verbbox
! \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
  %
  \begingroup
    \catcode`\^^I=\active
--- 7417,7425 ----
  \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
  %
  % We typeset each line of the verbatim in an \hbox, so we can handle
! % tabs.
  \newbox\verbbox
! \def\starttabbox{\setbox\verbbox=\hbox\bgroup}
  %
  \begingroup
    \catcode`\^^I=\active
***************
*** 6431,6437 ****
        \divide\dimen\verbbox by\tabw
        \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
        \advance\dimen\verbbox by\tabw  % advance to next multiple of \tabw
!       \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
      }%
    }
  \endgroup
--- 7430,7437 ----
        \divide\dimen\verbbox by\tabw
        \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
        \advance\dimen\verbbox by\tabw  % advance to next multiple of \tabw
!       \wd\verbbox=\dimen\verbbox
!       \leavevmode\box\verbbox \starttabbox
      }%
    }
  \endgroup
***************
*** 6441,6457 ****
    \let\nonarrowing = t%
    \nonfillstart
    \tt % easiest (and conventionally used) font for verbatim
!   % The \leavevmode here is for blank lines.  Otherwise, we would
!   % never \starttabox and the \egroup would end verbatim mode.
!   \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
    \tabexpand
!   \setupmarkupstyle{verbatim}%
    % Respect line breaks,
    % print special symbols as themselves, and
    % make each space count.
    % Must do in this order:
    \obeylines \uncatcodespecials \sepspaces
-   \everypar{\starttabbox}%
  }
  
  % Do the @verb magic: verbatim text is quoted by unique
--- 7441,7454 ----
    \let\nonarrowing = t%
    \nonfillstart
    \tt % easiest (and conventionally used) font for verbatim
!   \def\par{\egroup\leavevmode\box\verbbox\endgraf\starttabbox}%
    \tabexpand
!   \setcodequotes
    % Respect line breaks,
    % print special symbols as themselves, and
    % make each space count.
    % Must do in this order:
    \obeylines \uncatcodespecials \sepspaces
  }
  
  % Do the @verb magic: verbatim text is quoted by unique
***************
*** 6486,6498 ****
    % ignore everything up to the first ^^M, that's the newline at the end
    % of the @verbatim input line itself.  Otherwise we get an extra blank
    % line in the output.
!   \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
    % We really want {...\end verbatim} in the body of the macro, but
    % without the active space; thus we have to use \xdef and \gobble.
  \endgroup
  %
  \envdef\verbatim{%
!     \setupverbatim\doverbatim
  }
  \let\Everbatim = \afterenvbreak
  
--- 7483,7498 ----
    % ignore everything up to the first ^^M, that's the newline at the end
    % of the @verbatim input line itself.  Otherwise we get an extra blank
    % line in the output.
!   \xdef\doverbatim#1^^M#2@end verbatim{%
!     \starttabbox#2\egroup\noexpand\end\gobble verbatim}%
    % We really want {...\end verbatim} in the body of the macro, but
    % without the active space; thus we have to use \xdef and \gobble.
+   % The \egroup ends the \verbbox started at the end of the last line in
+   % the block.
  \endgroup
  %
  \envdef\verbatim{%
!     \setnormaldispenv\setupverbatim\doverbatim
  }
  \let\Everbatim = \afterenvbreak
  
***************
*** 6505,6513 ****
    {%
      \makevalueexpandable
      \setupverbatim
!     \indexnofonts       % Allow `@@' and other weird things in file names.
!     \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
!     \input #1
      \afterenvbreak
    }%
  }
--- 7505,7516 ----
    {%
      \makevalueexpandable
      \setupverbatim
!     {%
!       \indexnofonts       % Allow `@@' and other weird things in file names.
!       \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
!       \edef\tmp{\noexpand\input #1 }
!       \expandafter
!     }\expandafter\starttabbox\tmp\egroup
      \afterenvbreak
    }%
  }
***************
*** 6520,6526 ****
  % typesetting commands (@smallbook, font changes, etc.) have to be done
  % beforehand -- and a) we want @copying to be done first in the source
  % file; b) letting users define the frontmatter in as flexible order as
! % possible is very desirable.
  %
  \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
  \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
--- 7523,7529 ----
  % typesetting commands (@smallbook, font changes, etc.) have to be done
  % beforehand -- and a) we want @copying to be done first in the source
  % file; b) letting users define the frontmatter in as flexible order as
! % possible is desirable.
  %
  \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
  \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
***************
*** 6556,6562 ****
      % commands also insert a nobreak penalty, and we don't want to allow
      % a break between a section heading and a defun.
      %
!     % As a minor refinement, we avoid "club" headers by signalling
      % with penalty of 10003 after the very first @deffn in the
      % sequence (see above), and penalty of 10002 after any following
      % @def command.
--- 7559,7565 ----
      % commands also insert a nobreak penalty, and we don't want to allow
      % a break between a section heading and a defun.
      %
!     % As a further refinement, we avoid "club" headers by signalling
      % with penalty of 10003 after the very first @deffn in the
      % sequence (see above), and penalty of 10002 after any following
      % @def command.
***************
*** 6615,6621 ****
    \temp
  }
  
! % \domakedefun \deffn \deffnx \deffnheader
  %
  % Define \deffn and \deffnx, without parameters.
  % \deffnheader has to be defined explicitly.
--- 7618,7624 ----
    \temp
  }
  
! % \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) }
  %
  % Define \deffn and \deffnx, without parameters.
  % \deffnheader has to be defined explicitly.
***************
*** 6623,6635 ****
  \def\domakedefun#1#2#3{%
    \envdef#1{%
      \startdefun
      \parseargusing\activeparens{\printdefunline#3}%
    }%
    \def#2{\dodefunx#1}%
    \def#3%
  }
  
! %%% Untyped functions:
  
  % @deffn category name args
  \makedefun{deffn}{\deffngeneral{}}
--- 7626,7676 ----
  \def\domakedefun#1#2#3{%
    \envdef#1{%
      \startdefun
+     \doingtypefnfalse    % distinguish typed functions from all else
      \parseargusing\activeparens{\printdefunline#3}%
    }%
    \def#2{\dodefunx#1}%
    \def#3%
  }
  
! \newif\ifdoingtypefn       % doing typed function?
! \newif\ifrettypeownline    % typeset return type on its own line?
! 
! % @deftypefnnewline on|off says whether the return type of typed functions
! % are printed on their own line.  This affects @deftypefn, @deftypefun,
! % @deftypeop, and @deftypemethod.
! %
! \parseargdef\deftypefnnewline{%
!   \def\temp{#1}%
!   \ifx\temp\onword
!     \expandafter\let\csname SETtxideftypefnnl\endcsname
!       = \empty
!   \else\ifx\temp\offword
!     \expandafter\let\csname SETtxideftypefnnl\endcsname
!       = \relax
!   \else
!     \errhelp = \EMsimple
!     \errmessage{Unknown @txideftypefnnl value `\temp',
!                 must be on|off}%
!   \fi\fi
! }
! 
! % \dosubind {index}{topic}{subtopic}
! %
! % If SUBTOPIC is present, precede it with a space, and call \doind.
! % (At some time during the 20th century, this made a two-level entry in an
! % index such as the operation index.  Nobody seemed to notice the change in
! % behaviour though.)
! \def\dosubind#1#2#3{%
!   \def\thirdarg{#3}%
!   \ifx\thirdarg\empty
!     \doind{#1}{#2}%
!   \else
!     \doind{#1}{#2\space#3}%
!   \fi
! }
! 
! % Untyped functions:
  
  % @deffn category name args
  \makedefun{deffn}{\deffngeneral{}}
***************
*** 6643,6654 ****
  % \deffngeneral {subind}category name args
  %
  \def\deffngeneral#1#2 #3 #4\endheader{%
-   % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
    \dosubind{fn}{\code{#3}}{#1}%
    \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
  }
  
! %%% Typed functions:
  
  % @deftypefn category type name args
  \makedefun{deftypefn}{\deftypefngeneral{}}
--- 7684,7694 ----
  % \deffngeneral {subind}category name args
  %
  \def\deffngeneral#1#2 #3 #4\endheader{%
    \dosubind{fn}{\code{#3}}{#1}%
    \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
  }
  
! % Typed functions:
  
  % @deftypefn category type name args
  \makedefun{deftypefn}{\deftypefngeneral{}}
***************
*** 6663,6672 ****
  %
  \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
    \dosubind{fn}{\code{#4}}{#1}%
    \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
  }
  
! %%% Typed variables:
  
  % @deftypevr category type var args
  \makedefun{deftypevr}{\deftypecvgeneral{}}
--- 7703,7713 ----
  %
  \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
    \dosubind{fn}{\code{#4}}{#1}%
+   \doingtypefntrue
    \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
  }
  
! % Typed variables:
  
  % @deftypevr category type var args
  \makedefun{deftypevr}{\deftypecvgeneral{}}
***************
*** 6684,6690 ****
    \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
  }
  
! %%% Untyped variables:
  
  % @defvr category var args
  \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
--- 7725,7731 ----
    \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
  }
  
! % Untyped variables:
  
  % @defvr category var args
  \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
***************
*** 6695,6701 ****
  % \defcvof {category of}class var args
  \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
  
! %%% Type:
  % @deftp category name args
  \makedefun{deftp}#1 #2 #3\endheader{%
    \doind{tp}{\code{#2}}%
--- 7736,7743 ----
  % \defcvof {category of}class var args
  \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
  
! % Types:
! 
  % @deftp category name args
  \makedefun{deftp}#1 #2 #3\endheader{%
    \doind{tp}{\code{#2}}%
***************
*** 6723,6747 ****
  % We are followed by (but not passed) the arguments, if any.
  %
  \def\defname#1#2#3{%
    % Get the values of \leftskip and \rightskip as they were outside the @def...
    \advance\leftskip by -\defbodyindent
    %
!   % How we'll format the type name.  Putting it in brackets helps
    % distinguish it from the body text that may end up on the next line
    % just below it.
    \def\temp{#1}%
    \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
    %
!   % Figure out line sizes for the paragraph shape.
    % The first line needs space for \box0; but if \rightskip is nonzero,
    % we need only space for the part of \box0 which exceeds it:
    \dimen0=\hsize  \advance\dimen0 by -\wd0  \advance\dimen0 by \rightskip
    % The continuations:
    \dimen2=\hsize  \advance\dimen2 by -\defargsindent
-   % (plain.tex says that \dimen1 should be used only as global.)
-   \parshape 2 0in \dimen0 \defargsindent \dimen2
    %
!   % Put the type name to the right margin.
    \noindent
    \hbox to 0pt{%
      \hfil\box0 \kern-\hsize
--- 7765,7813 ----
  % We are followed by (but not passed) the arguments, if any.
  %
  \def\defname#1#2#3{%
+   \par
    % Get the values of \leftskip and \rightskip as they were outside the @def...
    \advance\leftskip by -\defbodyindent
    %
!   % Determine if we are typesetting the return type of a typed function
!   % on a line by itself.
!   \rettypeownlinefalse
!   \ifdoingtypefn  % doing a typed function specifically?
!     % then check user option for putting return type on its own line:
!     \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
!       \rettypeownlinetrue
!     \fi
!   \fi
!   %
!   % How we'll format the category name.  Putting it in brackets helps
    % distinguish it from the body text that may end up on the next line
    % just below it.
    \def\temp{#1}%
    \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
    %
!   % Figure out line sizes for the paragraph shape.  We'll always have at
!   % least two.
!   \tempnum = 2
!   %
    % The first line needs space for \box0; but if \rightskip is nonzero,
    % we need only space for the part of \box0 which exceeds it:
    \dimen0=\hsize  \advance\dimen0 by -\wd0  \advance\dimen0 by \rightskip
+   %
+   % If doing a return type on its own line, we'll have another line.
+   \ifrettypeownline
+     \advance\tempnum by 1
+     \def\maybeshapeline{0in \hsize}%
+   \else
+     \def\maybeshapeline{}%
+   \fi
+   %
    % The continuations:
    \dimen2=\hsize  \advance\dimen2 by -\defargsindent
    %
!   % The final paragraph shape:
!   \parshape \tempnum  0in \dimen0  \maybeshapeline  \defargsindent \dimen2
!   %
!   % Put the category name at the right margin.
    \noindent
    \hbox to 0pt{%
      \hfil\box0 \kern-\hsize
***************
*** 6763,6773 ****
      % . this still does not fix the ?` and !` ligatures, but so far no
      %   one has made identifiers using them :).
      \df \tt
!     \def\temp{#2}% return value type
!     \ifx\temp\empty\else \tclose{\temp} \fi
      #3% output function name
    }%
!   {\rm\enskip}% hskip 0.5 em of \tenrm
    %
    \boldbrax
    % arguments will be output next, if any.
--- 7829,7847 ----
      % . this still does not fix the ?` and !` ligatures, but so far no
      %   one has made identifiers using them :).
      \df \tt
!     \def\temp{#2}% text of the return type
!     \ifx\temp\empty\else
!       \tclose{\temp}% typeset the return type
!       \ifrettypeownline
!         % put return type on its own line; prohibit line break following:
!         \hfil\vadjust{\nobreak}\break
!       \else
!         \space  % type on same line, so just followed by a space
!       \fi
!     \fi           % no return type
      #3% output function name
    }%
!   {\rm\enskip}% hskip 0.5 em of \rmfont
    %
    \boldbrax
    % arguments will be output next, if any.
***************
*** 6784,6791 ****
    \df \sl \hyphenchar\font=0
    %
    % On the other hand, if an argument has two dashes (for instance), we
!   % want a way to get ttsl.  Let's try @var for that.
!   \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
    #1%
    \sl\hyphenchar\font=45
  }
--- 7858,7868 ----
    \df \sl \hyphenchar\font=0
    %
    % On the other hand, if an argument has two dashes (for instance), we
!   % want a way to get ttsl.  We used to recommend @var for that, so
!   % leave the code in, but it's strange for @var to lead to typewriter.
!   % Nowadays we recommend @code, since the difference between a ttsl hyphen
!   % and a tt hyphen is pretty tiny.  @code also disables ?` !`.
!   \def\var##1{{\setregularquotes\ttslanted{##1}}}%
    #1%
    \sl\hyphenchar\font=45
  }
***************
*** 6813,6818 ****
--- 7890,7896 ----
    \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
    \gdef\magicamp{\let&=\amprm}
  }
+ \let\ampchar\&
  
  \newcount\parencount
  
***************
*** 6882,6888 ****
  
  % To do this right we need a feature of e-TeX, \scantokens,
  % which we arrange to emulate with a temporary file in ordinary TeX.
! \ifx\eTeXversion\undefined
    \newwrite\macscribble
    \def\scantokens#1{%
      \toks0={#1}%
--- 7960,7966 ----
  
  % To do this right we need a feature of e-TeX, \scantokens,
  % which we arrange to emulate with a temporary file in ordinary TeX.
! \ifx\eTeXversion\thisisundefined
    \newwrite\macscribble
    \def\scantokens#1{%
      \toks0={#1}%
***************
*** 6893,6924 ****
    }
  \fi
  
! \def\scanmacro#1{\begingroup
    \newlinechar`\^^M
!   \let\xeatspaces\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
!   \catcode`\@=0 \catcode`\\=\active \escapechar=`\@
    %
!   % ... 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.  See the Macro Details node in the manual for the
!   % workaround we currently have to recommend for macros and
!   % line-oriented commands.
!   \scantokens{#1\empty}%
! \endgroup}
  
  \def\scanexp#1{%
!   \edef\temp{\noexpand\scanmacro{#1}}%
!   \temp
  }
  
  \newcount\paramno   % Count of parameters
--- 7971,8000 ----
    }
  \fi
  
! \let\E=\expandafter
! 
! % Used at the time of macro expansion.
! % Argument is macro body with arguments substituted
! \def\scanmacro#1{%
    \newlinechar`\^^M
!   % expand the expansion of \eatleadingcr twice to maybe remove a leading
!   % newline (and \else and \fi tokens), then call \eatspaces on the result.
!   \def\xeatspaces##1{%
!     \E\E\E\E\E\E\E\eatspaces\E\E\E\E\E\E\E{\eatleadingcr##1%
!   }}%
!   \def\xempty##1{}%
    %
!   % Process the macro body under the current catcode regime.
!   \scantokens{#1@comment}%
    %
!   % The \comment is to remove the \newlinechar added by \scantokens, and
!   % can be noticed by \parsearg.  Note \c isn't used because this means cedilla
!   % in math mode.
! }
  
+ % Used for copying and captions
  \def\scanexp#1{%
!   \expandafter\scanmacro\expandafter{#1}%
  }
  
  \newcount\paramno   % Count of parameters
***************
*** 6926,6932 ****
  \newif\ifrecursive  % Is it recursive?
  
  % List of all defined macros in the form
! %    \definedummyword\macro1\definedummyword\macro2...
  % Currently is also contains all @aliases; the list can be split
  % if there is a need.
  \def\macrolist{}
--- 8002,8008 ----
  \newif\ifrecursive  % Is it recursive?
  
  % List of all defined macros in the form
! %    \commondummyword\macro1\commondummyword\macro2...
  % Currently is also contains all @aliases; the list can be split
  % if there is a need.
  \def\macrolist{}
***************
*** 6934,6940 ****
  % Add the macro to \macrolist
  \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
  \def\addtomacrolistxxx#1{%
!      \toks0 = \expandafter{\macrolist\definedummyword#1}%
       \xdef\macrolist{\the\toks0}%
  }
  
--- 8010,8016 ----
  % Add the macro to \macrolist
  \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
  \def\addtomacrolistxxx#1{%
!      \toks0 = \expandafter{\macrolist\commondummyword#1}%
       \xdef\macrolist{\the\toks0}%
  }
  
***************
*** 6959,6964 ****
--- 8035,8045 ----
  \unbrace{\gdef\trim@@@ #1 } #2@{#1}
  }
  
+ {\catcode`\^^M=\other%
+ \gdef\eatleadingcr#1{\if\noexpand#1\noexpand^^M\else\E#1\fi}}%
+ % Warning: this won't work for a delimited argument
+ % or for an empty argument
+ 
  % Trim a single trailing ^^M off a string.
  {\catcode`\^^M=\other \catcode`\Q=3%
  \gdef\eatcr #1{\eatcra #1Q^^MQ}%
***************
*** 6984,7031 ****
    \catcode`\+=\other
    \catcode`\<=\other
    \catcode`\>=\other
-   \catcode`\@=\other
    \catcode`\^=\other
    \catcode`\_=\other
    \catcode`\|=\other
    \catcode`\~=\other
!   \ifx\declaredencoding\ascii \else \setnonasciicharscatcodenonglobal\other \fi
  }
  
  \def\scanargctxt{% used for copying and captions, not macros.
    \scanctxt
    \catcode`\\=\other
    \catcode`\^^M=\other
  }
  
  \def\macrobodyctxt{% used for @macro definitions
    \scanctxt
    \catcode`\{=\other
    \catcode`\}=\other
    \catcode`\^^M=\other
    \usembodybackslash
  }
  
! \def\macroargctxt{% used when scanning invocations
    \scanctxt
!   \catcode`\\=0
  }
- % 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.
  
  
  % \mbodybackslash is the definition of \ in @macro bodies.
  % It maps \foo\ => \csname macarg.foo\endcsname => #N
--- 8065,8111 ----
    \catcode`\+=\other
    \catcode`\<=\other
    \catcode`\>=\other
    \catcode`\^=\other
    \catcode`\_=\other
    \catcode`\|=\other
    \catcode`\~=\other
!   \passthroughcharstrue
  }
  
  \def\scanargctxt{% used for copying and captions, not macros.
    \scanctxt
+   \catcode`\@=\other
    \catcode`\\=\other
    \catcode`\^^M=\other
  }
  
  \def\macrobodyctxt{% used for @macro definitions
    \scanctxt
+   \catcode`\ =\other
+   \catcode`\@=\other
    \catcode`\{=\other
    \catcode`\}=\other
    \catcode`\^^M=\other
    \usembodybackslash
  }
  
! % 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`\ =\active
!   \catcode`\@=\other
!   \catcode`\^^M=\other
!   \catcode`\\=\active
  }
  
+ \def\macrolineargctxt{% used for whole-line arguments without braces
+   \scanctxt
+   \catcode`\@=\other
+   \catcode`\{=\other
+   \catcode`\}=\other
+ }
  
  % \mbodybackslash is the definition of \ in @macro bodies.
  % It maps \foo\ => \csname macarg.foo\endcsname => #N
***************
*** 7047,7055 ****
  \def\macroxxx#1{%
    \getargs{#1}% now \macname is the macname and \argl the arglist
    \ifx\argl\empty       % no arguments
!      \paramno=0
    \else
       \expandafter\parsemargdef \argl;%
    \fi
    \if1\csname ismacro.\the\macname\endcsname
       \message{Warning: redefining \the\macname}%
--- 8127,8141 ----
  \def\macroxxx#1{%
    \getargs{#1}% now \macname is the macname and \argl the arglist
    \ifx\argl\empty       % no arguments
!      \paramno=0\relax
    \else
       \expandafter\parsemargdef \argl;%
+      \if\paramno>256\relax
+        \ifx\eTeXversion\thisisundefined
+          \errhelp = \EMsimple
+          \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
+        \fi
+      \fi
    \fi
    \if1\csname ismacro.\the\macname\endcsname
       \message{Warning: redefining \the\macname}%
***************
*** 7072,7078 ****
      % Remove the macro name from \macrolist:
      \begingroup
        \expandafter\let\csname#1\endcsname \relax
!       \let\definedummyword\unmacrodo
        \xdef\macrolist{\macrolist}%
      \endgroup
    \else
--- 8158,8164 ----
      % Remove the macro name from \macrolist:
      \begingroup
        \expandafter\let\csname#1\endcsname \relax
!       \let\commondummyword\unmacrodo
        \xdef\macrolist{\macrolist}%
      \endgroup
    \else
***************
*** 7087,7215 ****
    \ifx #1\relax
      % remove this
    \else
!     \noexpand\definedummyword \noexpand#1%
    \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.
  \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}}
  
! % 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 be ##N where N is the position in that list.
  % 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.
  %
- % The same technique is used to protect \eatspaces till just before
- % the macro is used.
- 
  \def\parsemargdef#1;{%
    \paramno=0\def\paramlist{}%
    \let\hash\relax
    \let\xeatspaces\relax
    \parsemargdefxxx#1,;,%
  }
  \def\parsemargdefxxx#1,{%
    \if#1;\let\next=\relax
    \else \let\next=\parsemargdefxxx
      \advance\paramno by 1
      \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
!         {\xeatspaces{\hash\the\paramno}}%
      \edef\paramlist{\paramlist\hash\the\paramno,}%
    \fi\next}
  
! % These two commands read recursive and nonrecursive macro bodies.
! % (They're different since rec and nonrec macros end differently.)
  %
! \long\def\parsemacbody#1@end macro%
! {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
! \long\def\parsermacbody#1@end rmacro%
! {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
! 
! % This defines the macro itself. There are six cases: recursive and
! % nonrecursive macros of zero, one, and many arguments.
! % Much magic with \expandafter here.
  % \xdef is used so that macro definitions will survive the file
! % they're defined in; @include reads the file inside a group.
  %
  \def\defmacro{%
    \let\hash=##% convert placeholders to macro parameter chars
!   \ifrecursive
!     \ifcase\paramno
!     % 0
!       \expandafter\xdef\csname\the\macname\endcsname{%
!         \noexpand\scanmacro{\temp}}%
!     \or % 1
!       \expandafter\xdef\csname\the\macname\endcsname{%
!          \bgroup\noexpand\macroargctxt
!          \noexpand\braceorline
!          \expandafter\noexpand\csname\the\macname xxx\endcsname}%
!       \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
!          \egroup\noexpand\scanmacro{\temp}}%
!     \else % many
        \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,}%
        \expandafter\expandafter
        \expandafter\xdef
        \expandafter\expandafter
!         \csname\the\macname xxx\endcsname
!           \paramlist{\egroup\noexpand\scanmacro{\temp}}%
!     \fi
!   \else
!     \ifcase\paramno
!     % 0
!       \expandafter\xdef\csname\the\macname\endcsname{%
!         \noexpand\norecurse{\the\macname}%
!         \noexpand\scanmacro{\temp}\egroup}%
!     \or % 1
        \expandafter\xdef\csname\the\macname\endcsname{%
!          \bgroup\noexpand\macroargctxt
!          \noexpand\braceorline
!          \expandafter\noexpand\csname\the\macname xxx\endcsname}%
!       \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
!         \egroup
!         \noexpand\norecurse{\the\macname}%
!         \noexpand\scanmacro{\temp}\egroup}%
!     \else % many
!       \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,}%
!       \expandafter\expandafter
!       \expandafter\xdef
!       \expandafter\expandafter
!       \csname\the\macname xxx\endcsname
!       \paramlist{%
!           \egroup
!           \noexpand\norecurse{\the\macname}%
!           \noexpand\scanmacro{\temp}\egroup}%
      \fi
    \fi}
  
  \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
  
! % \braceorline decides whether the next nonwhitespace character is a
! % {.  If so it reads up to the closing }, if not, it reads the whole
! % line.  Whatever was read is then fed to the next control sequence
! % as an argument (by \parsebrace or \parsearg).
! % 
  \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
  \def\braceorlinexxx{%
!   \ifx\nchar\bgroup\else
!     \expandafter\parsearg
    \fi \macnamexxx}
  
  
--- 8173,8632 ----
    \ifx #1\relax
      % remove this
    \else
!     \noexpand\commondummyword \noexpand#1%
    \fi
  }
  
! % \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.
  
! % 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).
  %
! % If there are 10 or more arguments, a different technique is used: see
! % \parsemmanyargdef.
  %
  \def\parsemargdef#1;{%
    \paramno=0\def\paramlist{}%
    \let\hash\relax
+   % \hash is redefined to `#' later to get it into definitions
    \let\xeatspaces\relax
+   \let\xempty\relax
    \parsemargdefxxx#1,;,%
+   \ifnum\paramno<10\relax\else
+     \paramno0\relax
+     \parsemmanyargdef@@#1,;,% 10 or more arguments
+   \fi
  }
  \def\parsemargdefxxx#1,{%
    \if#1;\let\next=\relax
    \else \let\next=\parsemargdefxxx
      \advance\paramno by 1
      \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
!         {\xeatspaces{\hash\the\paramno\noexpand\xempty{}}}%
      \edef\paramlist{\paramlist\hash\the\paramno,}%
    \fi\next}
+ % the \xempty{} is to give \eatleadingcr an argument in the case of an
+ % empty macro argument.
+ 
+ % \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`\ =\other\long\gdef\parsemacbody#1@end macro{%
+ \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
+ {\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{%
+ \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
+ 
+ % Make @ a letter, so that we can make private-to-Texinfo macro names.
+ \edef\texiatcatcode{\the\catcode`\@}
+ \catcode `@=11\relax
+ 
+ %%%%%%%%%%%%%% 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
+     \let\next=\parsemmanyargdef@@
+     \edef\tempb{\eatspaces{#1}}%
+     \expandafter\def\expandafter\tempa
+        \expandafter{\csname macarg.\tempb\endcsname}%
+     % Note that we need some extra \noexpand\noexpand, this is because we
+     % don't want \the  to be expanded in the \parsermacbody  as it uses an
+     % \xdef .
+     \expandafter\edef\tempa
+       {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
+     \advance\paramno by 1\relax
+   \fi\next}
+ 
+ 
+ \let\endargs@\relax
+ \let\nil@\relax
+ \def\nilm@{\nil@}%
+ \long\def\nillm@{\nil@}%
+ 
+ % This macro is expanded during the Texinfo macro expansion, not during its
+ % definition.  It gets all the arguments' values and assigns them to macros
+ % macarg.ARGNAME
+ %
+ % #1 is the macro name
+ % #2 is the list of argument names
+ % #3 is the list of argument values
+ \def\getargvals@#1#2#3{%
+   \def\macargdeflist@{}%
+   \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
+   \def\paramlist{#2,\nil@}%
+   \def\macroname{#1}%
+   \begingroup
+   \macroargctxt
+   \def\argvaluelist{#3,\nil@}%
+   \def\@tempa{#3}%
+   \ifx\@tempa\empty
+     \setemptyargvalues@
+   \else
+     \getargvals@@
+   \fi
+ }
+ \def\getargvals@@{%
+   \ifx\paramlist\nilm@
+       % Some sanity check needed here that \argvaluelist is also empty.
+       \ifx\argvaluelist\nillm@
+       \else
+         \errhelp = \EMsimple
+         \errmessage{Too many arguments in macro `\macroname'!}%
+       \fi
+       \let\next\macargexpandinbody@
+   \else
+     \ifx\argvaluelist\nillm@
+        % No more arguments values passed to macro.  Set remaining named-arg
+        % macros to empty.
+        \let\next\setemptyargvalues@
+     \else
+       % pop current arg name into \@tempb
+       \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
+       \expandafter\@tempa\expandafter{\paramlist}%
+        % pop current argument value into \@tempc
+       \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
+       \expandafter\@tempa\expandafter{\argvaluelist}%
+        % Here \@tempb is the current arg name and \@tempc is the current arg value.
+        % First place the new argument macro definition into \@tempd
+        \expandafter\macname\expandafter{\@tempc}%
+        \expandafter\let\csname macarg.\@tempb\endcsname\relax
+        \expandafter\def\expandafter\@tempe\expandafter{%
+          \csname macarg.\@tempb\endcsname}%
+        \edef\@tempd{\long\def\@tempe{\the\macname}}%
+        \push@\@tempd\macargdeflist@
+        \let\next\getargvals@@
+     \fi
+   \fi
+   \next
+ }
+ 
+ \def\push@#1#2{%
+   \expandafter\expandafter\expandafter\def
+   \expandafter\expandafter\expandafter#2%
+   \expandafter\expandafter\expandafter{%
+   \expandafter#1#2}%
+ }
+ 
+ % Replace arguments by their values in the macro body, and place the result
+ % in macro \@tempa.
+ %
+ \def\macvalstoargs@{%
+   %  To do this we use the property that token registers that are \the'ed
+   % within an \edef  expand only once. So we are going to place all argument
+   % values into respective token registers.
+   %
+   % First we save the token context, and initialize argument numbering.
+   \begingroup
+     \paramno0\relax
+     % Then, for each argument number #N, we place the corresponding argument
+     % value into a new token list register \toks#N
+     \expandafter\putargsintokens@\saveparamlist@,;,%
+     % Then, we expand the body so that argument are replaced by their
+     % values. The trick for values not to be expanded themselves is that they
+     % are within tokens and that tokens expand only once in an \edef .
+     \edef\@tempc{\csname mac.\macroname .body\endcsname}%
+     % Now we restore the token stack pointer to free the token list registers
+     % which we have used, but we make sure that expanded body is saved after
+     % group.
+     \expandafter
+   \endgroup
+   \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
+   }
+ 
+ % Define the named-macro outside of this group and then close this group.
+ %
+ \def\macargexpandinbody@{%
+   \expandafter
+   \endgroup
+   \macargdeflist@
+   % First the replace in body the macro arguments by their values, the result
+   % is in \@tempa .
+   \macvalstoargs@
+   % Then we point at the \norecurse or \gobble (for recursive) macro value
+   % with \@tempb .
+   \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
+   % Depending on whether it is recursive or not, we need some tailing
+   % \egroup .
+   \ifx\@tempb\gobble
+      \let\@tempc\relax
+   \else
+      \let\@tempc\egroup
+   \fi
+   % And now we do the real job:
+   \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
+   \@tempd
+ }
+ 
+ \def\putargsintokens@#1,{%
+   \if#1;\let\next\relax
+   \else
+     \let\next\putargsintokens@
+     % First we allocate the new token list register, and give it a temporary
+     % alias \@tempb .
+     \toksdef\@tempb\the\paramno
+     % Then we place the argument value into that token list register.
+     \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
+     \expandafter\@tempb\expandafter{\@tempa}%
+     \advance\paramno by 1\relax
+   \fi
+   \next
+ }
  
! % Trailing missing arguments are set to empty.
  %
! \def\setemptyargvalues@{%
!   \ifx\paramlist\nilm@
!     \let\next\macargexpandinbody@
!   \else
!     \expandafter\setemptyargvaluesparser@\paramlist\endargs@
!     \let\next\setemptyargvalues@
!   \fi
!   \next
! }
! 
! \def\setemptyargvaluesparser@#1,#2\endargs@{%
!   \expandafter\def\expandafter\@tempa\expandafter{%
!     \expandafter\def\csname macarg.#1\endcsname{}}%
!   \push@\@tempa\macargdeflist@
!   \def\paramlist{#2}%
! }
! 
! % #1 is the element target macro
! % #2 is the list macro
! % #3,#4\endargs@ is the list value
! \def\pop@#1#2#3,#4\endargs@{%
!    \def#1{#3}%
!    \def#2{#4}%
! }
! \long\def\longpop@#1#2#3,#4\endargs@{%
!    \long\def#1{#3}%
!    \long\def#2{#4}%
! }
! 
! 
! %%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%%
! 
! 
! % 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 "\xeatspaces{\hash 1}".
! %    \paramno is the number of parameters
! %    \paramlist is a TeX parameter text, e.g. "#1,#2,#3,"
! % There are four cases: 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.
  %
  \def\defmacro{%
    \let\hash=##% convert placeholders to macro parameter chars
!   \ifnum\paramno=1
!     \def\xeatspaces##1{##1}%
!     % 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
!     \let\xeatspaces\relax % suppress expansion
!   \fi
!   \ifcase\paramno
!   % 0
!     \expandafter\xdef\csname\the\macname\endcsname{%
!       \bgroup
!         \noexpand\spaceisspace
!         \noexpand\endlineisspace
!         \noexpand\expandafter % skip any whitespace after the macro name.
!         \expandafter\noexpand\csname\the\macname @@@\endcsname}%
!     \expandafter\xdef\csname\the\macname @@@\endcsname{%
!       \egroup
!       \noexpand\scanmacro{\macrobody}}%
!   \or % 1
!     \expandafter\xdef\csname\the\macname\endcsname{%
!        \bgroup
!        \noexpand\braceorline
!        \expandafter\noexpand\csname\the\macname @@@\endcsname}%
!     \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
!       \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\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 @@@@\endcsname\paramlist{%
!           \egroup\noexpand\scanmacro{\macrobody}}%
!     \else % 10 or more:
        \expandafter\xdef\csname\the\macname\endcsname{%
!         \noexpand\getargvals@{\the\macname}{\argl}%
!       }%
!       \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
!       \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
      \fi
    \fi}
  
+ \catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes
+ 
  \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
  
! 
! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
! %
! {\catcode`\@=0 \catcode`\\=13  % We need to manipulate \ so use @ as escape
! @catcode`@_=11  % private names
! @catcode`@!=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
! 
! @gdef@passargtomacro#1#2{%
!   @add_segment #1!{}@relax#2\@_finish\%
! }
! @gdef@_finish{@_finishx} @global@let@_finishx@relax
! 
! % #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.
! @gdef@look_ahead#1!#2#3#4{%
!   @ifx#4\%
!    @expandafter@gobble_and_check_finish
!   @else
!    @expandafter@add_segment
!   @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.
! @gdef@gobble_and_check_finish#1!#2#3#4#5{%
!   @add_segment#1\!{}#5#5%
! }
! 
! @gdef@is_fi{@fi}
! 
! % #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.
! @gdef@add_segment#1!#2#3#4\{%
! @ifx#3@_finish
!   @call_the_macro#1!%
! @else
!   % append the pending backslash to the result, followed by the next segment
!   @expandafter@is_fi@look_ahead#1#2#4!{\}@fi
!   % this @fi is discarded by @look_ahead.
!   % we can't get rid of it with \expandafter because we don't know how
!   % 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.
! @gdef@call_the_macro#1#2!#3@fi{@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 calls \passargtomacro MAC.
! %
  \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
  \def\braceorlinexxx{%
!   \ifx\nchar\bgroup
!     \macroargctxt
!     \expandafter\passargtomacro
!   \else
!     \macrolineargctxt\expandafter\parsearg
    \fi \macnamexxx}
  
  
***************
*** 7237,7243 ****
  
  % @inforef is relatively simple.
  \def\inforef #1{\inforefzzz #1,,,,**}
! \def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
    node \samp{\ignorespaces#1{}}}
  
  % @node's only job in TeX is to define \lastnode, which is used in
--- 8654,8661 ----
  
  % @inforef is relatively simple.
  \def\inforef #1{\inforefzzz #1,,,,**}
! \def\inforefzzz #1,#2,#3,#4**{%
!   \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
    node \samp{\ignorespaces#1{}}}
  
  % @node's only job in TeX is to define \lastnode, which is used in
***************
*** 7251,7259 ****
  % also remove a trailing comma, in case of something like this:
  % @node Help-Cross,  ,  , Cross-refs
  \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
! \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
  
- \let\nwnode=\node
  \let\lastnode=\empty
  
  % Write a cross-reference definition for the current node.  #1 is the
--- 8669,8697 ----
  % also remove a trailing comma, in case of something like this:
  % @node Help-Cross,  ,  , Cross-refs
  \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
! \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}\omittopnode}
! 
! % Used so that the @top node doesn't have to be wrapped in an @ifnottex
! % conditional.
! % \doignore goes to more effort to skip nested conditionals but we don't need
! % that here.
! \def\omittopnode{%
!    \ifx\lastnode\wordTop
!    \expandafter\ignorenode\fi
! }
! \def\wordTop{Top}
! 
! % Until the next @node or @bye command, divert output to a box that is not
! % output.
! \def\ignorenode{\setbox\dummybox\vbox\bgroup\def\node{\egroup\node}%
! \ignorenodebye
! }
! 
! {\let\bye\relax
! \gdef\ignorenodebye{\let\bye\ignorenodebyedef}
! \gdef\ignorenodebyedef{\egroup(`Top' node ignored)\bye}}
! % The redefinition of \bye here is because it is declared \outer
  
  \let\lastnode=\empty
  
  % Write a cross-reference definition for the current node.  #1 is the
***************
*** 7276,7282 ****
  
  % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
  % anchor), which consists of three parts:
! % 1) NAME-title - the current sectioning name taken from \lastsection,
  %                 or the anchor name.
  % 2) NAME-snt   - section number and type, passed as the SNT arg, or
  %                 empty for anchors.
--- 8714,8720 ----
  
  % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
  % anchor), which consists of three parts:
! % 1) NAME-title - the current sectioning name taken from \currentsection,
  %                 or the anchor name.
  % 2) NAME-snt   - section number and type, passed as the SNT arg, or
  %                 empty for anchors.
***************
*** 7290,7337 ****
    \pdfmkdest{#1}%
    \iflinks
      {%
        \atdummies  % preserve commands, but don't expand them
        \edef\writexrdef##1##2{%
  	\write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
  	  ##1}{##2}}% these are parameters of \writexrdef
        }%
!       \toks0 = \expandafter{\lastsection}%
        \immediate \writexrdef{title}{\the\toks0 }%
        \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
!       \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, during \shipout
      }%
    \fi
  }
  
  % @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
  % the node name, #2 the name of the Info cross-reference, #3 the printed
  % node name, #4 the name of the Info file, #5 the name of the printed
  % 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\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
    \unsepspaces
!   \def\printedmanual{\ignorespaces #5}%
    \def\printedrefname{\ignorespaces #3}%
!   \setbox1=\hbox{\printedmanual\unskip}%
!   \setbox0=\hbox{\printedrefname\unskip}%
!   \ifdim \wd0 = 0pt
      % No printed node name was explicitly given.
!     \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax
!       % Use the node name inside the square brackets.
        \def\printedrefname{\ignorespaces #1}%
      \else
!       % Use the actual chapter/section title appear inside
!       % the square brackets.  Use the real section title if we have it.
!       \ifdim \wd1 > 0pt
!         % It is in another manual, so we don't have it.
          \def\printedrefname{\ignorespaces #1}%
        \else
          \ifhavexrefs
!           % We know the real title if we have the xref values.
!           \def\printedrefname{\refx{#1-title}{}}%
          \else
            % Otherwise just copy the Info node name.
            \def\printedrefname{\ignorespaces #1}%
--- 8728,8817 ----
    \pdfmkdest{#1}%
    \iflinks
      {%
+       \requireauxfile
        \atdummies  % preserve commands, but don't expand them
+       % match definition in \xrdef, \refx, \xrefX.
+       \def\value##1{##1}%
        \edef\writexrdef##1##2{%
  	\write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
  	  ##1}{##2}}% these are parameters of \writexrdef
        }%
!       \toks0 = \expandafter{\currentsection}%
        \immediate \writexrdef{title}{\the\toks0 }%
        \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
!       \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
      }%
    \fi
  }
  
+ % @xrefautosectiontitle on|off says whether @section(ing) names are used
+ % automatically in xrefs, if the third arg is not explicitly specified.
+ % This was provided as a "secret" @set xref-automatic-section-title
+ % variable, now it's official.
+ %
+ \parseargdef\xrefautomaticsectiontitle{%
+   \def\temp{#1}%
+   \ifx\temp\onword
+     \expandafter\let\csname SETxref-automatic-section-title\endcsname
+       = \empty
+   \else\ifx\temp\offword
+     \expandafter\let\csname SETxref-automatic-section-title\endcsname
+       = \relax
+   \else
+     \errhelp = \EMsimple
+     \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
+                 must be on|off}%
+   \fi\fi
+ }
+ 
+ %
  % @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
  % the node name, #2 the name of the Info cross-reference, #3 the printed
  % node name, #4 the name of the Info file, #5 the name of the printed
  % manual.  All but the node name can be omitted.
  %
! \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
! \newbox\infofilenamebox
! \newbox\printedmanualbox
! %
  \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
    \unsepspaces
!   %
!   % Get args without leading/trailing spaces.
    \def\printedrefname{\ignorespaces #3}%
!   \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
!   %
!   \def\infofilename{\ignorespaces #4}%
!   \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
!   %
!   \def\printedmanual{\ignorespaces #5}%
!   \setbox\printedmanualbox  = \hbox{\printedmanual\unskip}%
!   %
!   % If the printed reference name (arg #3) was not explicitly given in
!   % the @xref, figure out what we want to use.
!   \ifdim \wd\printedrefnamebox = 0pt
      % No printed node name was explicitly given.
!     \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
!       % Not auto section-title: use node name inside the square brackets.
        \def\printedrefname{\ignorespaces #1}%
      \else
!       % Auto section-title: use chapter/section title inside
!       % the square brackets if we have it.
!       \ifdim \wd\printedmanualbox > 0pt
!         % It is in another manual, so we don't have it; use node name.
          \def\printedrefname{\ignorespaces #1}%
        \else
          \ifhavexrefs
!           % We (should) know the real title if we have the xref values.
!           \def\printedrefname{\refx{#1-title}}%
          \else
            % Otherwise just copy the Info node name.
            \def\printedrefname{\ignorespaces #1}%
***************
*** 7342,7429 ****
    %
    % Make link in pdf output.
    \ifpdf
      {\indexnofonts
       \turnoffactive
       % This expands tokens, so do it after making catcode changes, so _
!      % etc. don't get their TeX definitions.
       \getfilename{#4}%
       %
!      % See comments at \activebackslashdouble.
!      {\activebackslashdouble \xdef\pdfxrefdest{#1}%
!       \backslashparens\pdfxrefdest}%
       %
       \leavevmode
       \startlink attr{/Border [0 0 0]}%
       \ifnum\filenamelength>0
!        goto file{\the\filename.pdf} name{\pdfxrefdest}%
       \else
!        goto name{\pdfmkpgn{\pdfxrefdest}}%
       \fi
      }%
      \setcolor{\linkcolor}%
    \fi
-   %
-   % Float references are printed completely differently: "Figure 1.2"
-   % instead of "[somenode], p.3".  We distinguish them by the
-   % LABEL-title being set to a magic string.
    {%
      % Have to otherify everything special to allow the \csname to
      % include an _ in the xref name, etc.
      \indexnofonts
      \turnoffactive
      \expandafter\global\expandafter\let\expandafter\Xthisreftitle
        \csname XR#1-title\endcsname
    }%
    \iffloat\Xthisreftitle
      % If the user specified the print name (third arg) to the ref,
      % print it instead of our usual "Figure 1.2".
!     \ifdim\wd0 = 0pt
!       \refx{#1-snt}{}%
      \else
        \printedrefname
      \fi
      %
!     % if the user also gave the printed manual name (fifth arg), append
      % "in MANUALNAME".
!     \ifdim \wd1 > 0pt
        \space \putwordin{} \cite{\printedmanual}%
      \fi
    \else
      % node/anchor (non-float) references.
      %
!     % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
!     % insert empty discretionaries after hyphens, which means that it will
!     % not find a line break at a hyphen in a node names.  Since some manuals
!     % are best written with fairly long node names, containing hyphens, this
!     % is a loss.  Therefore, we give the text of the node name again, so it
!     % is as if TeX is seeing it for the first time.
!     \ifdim \wd1 > 0pt
!       \putwordSection{} ``\printedrefname'' \putwordin{} \cite{\printedmanual}%
      \else
!       % _ (for example) has to be the character _ for the purposes of the
!       % control sequence corresponding to the node, but it has to expand
!       % into the usual \leavevmode...\vrule stuff for purposes of
!       % printing. So we \turnoffactive for the \refx-snt, back on for the
!       % printing, back off for the \refx-pg.
!       {\turnoffactive
!        % Only output a following space if the -snt ref is nonempty; for
!        % @unnumbered and @anchor, it won't be.
!        \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
!        \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
!       }%
!       % output the `[mynode]' via a macro so it can be overridden.
!       \xrefprintnodename\printedrefname
        %
!       % But we always want a comma and a space:
!       ,\space
        %
!       % output the `page 3'.
!       \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
!     \fi
    \fi
    \endlink
  \endgroup}
  
  % This macro is called from \xrefX for the `[nodename]' part of xref
  % output.  It's a separate macro only so it can be changed more easily,
  % since square brackets don't work well in some documents.  Particularly
--- 8822,9000 ----
    %
    % Make link in pdf output.
    \ifpdf
+     % For pdfTeX and LuaTeX
      {\indexnofonts
+      \makevalueexpandable
       \turnoffactive
       % This expands tokens, so do it after making catcode changes, so _
!      % etc. don't get their TeX definitions.  This ignores all spaces in
!      % #4, including (wrongly) those in the middle of the filename.
       \getfilename{#4}%
       %
!      % This (wrongly) does not take account of leading or trailing
!      % spaces in #1, which should be ignored.
!      \setpdfdestname{#1}%
!      %
!      \ifx\pdfdestname\empty
!        \def\pdfdestname{Top}% no empty targets
!      \fi
       %
       \leavevmode
       \startlink attr{/Border [0 0 0]}%
       \ifnum\filenamelength>0
!        goto file{\the\filename.pdf} name{\pdfdestname}%
       \else
!        goto name{\pdfmkpgn{\pdfdestname}}%
       \fi
      }%
      \setcolor{\linkcolor}%
+   \else
+     \ifx\XeTeXrevision\thisisundefined
+     \else
+       % For XeTeX
+       {\indexnofonts
+        \makevalueexpandable
+        \turnoffactive
+        % This expands tokens, so do it after making catcode changes, so _
+        % etc. don't get their TeX definitions.  This ignores all spaces in
+        % #4, including (wrongly) those in the middle of the filename.
+        \getfilename{#4}%
+        %
+        % This (wrongly) does not take account of leading or trailing
+        % spaces in #1, which should be ignored.
+        \setpdfdestname{#1}%
+        %
+        \ifx\pdfdestname\empty
+          \def\pdfdestname{Top}% no empty targets
+        \fi
+        %
+        \leavevmode
+        \ifnum\filenamelength>0
+          % With default settings,
+          % XeTeX (xdvipdfmx) replaces link destination names with integers.
+          % In this case, the replaced destination names of
+          % remote PDFs are no longer known.  In order to avoid a replacement,
+          % you can use xdvipdfmx's command line option `-C 0x0010'.
+          % If you use XeTeX 0.99996+ (TeX Live 2016+),
+          % this command line option is no longer necessary
+          % because we can use the `dvipdfmx:config' special.
+          \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
+            << /S /GoToR /F (\the\filename.pdf) /D (\pdfdestname) >> >>}%
+        \else
+          \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
+            << /S /GoTo /D (\pdfdestname) >> >>}%
+        \fi
+       }%
+       \setcolor{\linkcolor}%
+     \fi
    \fi
    {%
      % Have to otherify everything special to allow the \csname to
      % include an _ in the xref name, etc.
      \indexnofonts
      \turnoffactive
+     \def\value##1{##1}%
      \expandafter\global\expandafter\let\expandafter\Xthisreftitle
        \csname XR#1-title\endcsname
    }%
+   %
+   % Float references are printed completely differently: "Figure 1.2"
+   % instead of "[somenode], p.3".  \iffloat distinguishes them by
+   % \Xthisreftitle being set to a magic string.
    \iffloat\Xthisreftitle
      % If the user specified the print name (third arg) to the ref,
      % print it instead of our usual "Figure 1.2".
!     \ifdim\wd\printedrefnamebox = 0pt
!       \refx{#1-snt}%
      \else
        \printedrefname
      \fi
      %
!     % If the user also gave the printed manual name (fifth arg), append
      % "in MANUALNAME".
!     \ifdim \wd\printedmanualbox > 0pt
        \space \putwordin{} \cite{\printedmanual}%
      \fi
    \else
      % node/anchor (non-float) references.
      %
!     % If we use \unhbox to print the node names, TeX does not insert
!     % empty discretionaries after hyphens, which means that it will not
!     % find a line break at a hyphen in a node names.  Since some manuals
!     % are best written with fairly long node names, containing hyphens,
!     % this is a loss.  Therefore, we give the text of the node name
!     % again, so it is as if TeX is seeing it for the first time.
!     %
!     \ifdim \wd\printedmanualbox > 0pt
!       % Cross-manual reference with a printed manual name.
!       %
!       \crossmanualxref{\cite{\printedmanual\unskip}}%
!     %
!     \else\ifdim \wd\infofilenamebox > 0pt
!       % Cross-manual reference with only an info filename (arg 4), no
!       % printed manual name (arg 5).  This is essentially the same as
!       % the case above; we output the filename, since we have nothing else.
!       %
!       \crossmanualxref{\code{\infofilename\unskip}}%
!     %
      \else
!       % Reference within this manual.
        %
!       % Only output a following space if the -snt ref is nonempty, as the ref
!       % will be empty for @unnumbered and @anchor.
!       \setbox2 = \hbox{\ignorespaces \refx{#1-snt}}%
!       \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
        %
!       % output the `[mynode]' via the macro below so it can be overridden.
!       \xrefprintnodename\printedrefname
!       %
!       \expandafter\ifx\csname SETtxiomitxrefpg\endcsname\relax
!         % But we always want a comma and a space:
!         ,\space
!         %
!         % output the `page 3'.
!         \turnoffactive \putwordpage\tie\refx{#1-pg}%
!         % Add a , if xref followed by a space
!         \if\space\noexpand\tokenafterxref ,%
!         \else\ifx\	\tokenafterxref ,% @TAB
!         \else\ifx\*\tokenafterxref ,%   @*
!         \else\ifx\ \tokenafterxref ,%   @SPACE
!         \else\ifx\
!                   \tokenafterxref ,%    @NL
!         \else\ifx\tie\tokenafterxref ,% @tie
!         \fi\fi\fi\fi\fi\fi
!       \fi
!     \fi\fi
    \fi
    \endlink
  \endgroup}
  
+ % Output a cross-manual xref to #1.  Used just above (twice).
+ %
+ % Only include the text "Section ``foo'' in" if the foo is neither
+ % missing or Top.  Thus, @xref{,,,foo,The Foo Manual} outputs simply
+ % "see The Foo Manual", the idea being to refer to the whole manual.
+ %
+ % But, this being TeX, we can't easily compare our node name against the
+ % string "Top" while ignoring the possible spaces before and after in
+ % the input.  By adding the arbitrary 7sp below, we make it much less
+ % likely that a real node name would have the same width as "Top" (e.g.,
+ % in a monospaced font).  Hopefully it will never happen in practice.
+ %
+ % For the same basic reason, we retypeset the "Top" at every
+ % reference, since the current font is indeterminate.
+ %
+ \def\crossmanualxref#1{%
+   \setbox\toprefbox = \hbox{Top\kern7sp}%
+   \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
+   \ifdim \wd2 > 7sp  % nonempty?
+     \ifdim \wd2 = \wd\toprefbox \else  % same as Top?
+       \putwordSection{} ``\printedrefname'' \putwordin{}\space
+     \fi
+   \fi
+   #1%
+ }
+ 
  % This macro is called from \xrefX for the `[nodename]' part of xref
  % output.  It's a separate macro only so it can be changed more easily,
  % since square brackets don't work well in some documents.  Particularly
***************
*** 7459,7471 ****
    \fi\fi\fi
  }
  
! % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
! % If its value is nonempty, SUFFIX is output afterward.
! %
! \def\refx#1#2{%
    {%
      \indexnofonts
!     \otherbackslash
      \expandafter\global\expandafter\let\expandafter\thisrefX
        \csname XR#1\endcsname
    }%
--- 9030,9042 ----
    \fi\fi\fi
  }
  
! % \refx{NAME} - reference a cross-reference string named NAME.
! \def\refx#1{%
!   \requireauxfile
    {%
      \indexnofonts
!     \turnoffactive
!     \def\value##1{##1}%
      \expandafter\global\expandafter\let\expandafter\thisrefX
        \csname XR#1\endcsname
    }%
***************
*** 7487,7509 ****
      % It's defined, so just use it.
      \thisrefX
    \fi
-   #2% Output the suffix in any case.
  }
  
! % This is the macro invoked by entries in the aux file.  Usually it's
! % just a \def (we prepend XR to the control sequence name to avoid
! % collisions).  But if this is a float type, we have more work to do.
  %
  \def\xrdef#1#2{%
!   {% The node name might contain 8-bit characters, which in our current
!    % implementation are changed to commands like @'e.  Don't let these
!    % mess up the control sequence name.
      \indexnofonts
      \turnoffactive
      \xdef\safexrefname{#1}%
    }%
    %
!   \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref
    %
    % Was that xref control sequence that we just defined for a float?
    \expandafter\iffloat\csname XR\safexrefname\endcsname
--- 9058,9087 ----
      % It's defined, so just use it.
      \thisrefX
    \fi
  }
  
! % This is the macro invoked by entries in the aux file.  Define a control
! % sequence for a cross-reference target (we prepend XR to the control sequence
! % name to avoid collisions).  The value is the page number.  If this is a float
! % type, we have more work to do.
  %
  \def\xrdef#1#2{%
!   {% Expand the node or anchor name to remove control sequences.
!    % \turnoffactive stops 8-bit characters being changed to commands
!    % like @'e.  \refx does the same to retrieve the value in the definition.
      \indexnofonts
      \turnoffactive
+     \def\value##1{##1}%
      \xdef\safexrefname{#1}%
    }%
    %
!   \bgroup
!     \expandafter\gdef\csname XR\safexrefname\endcsname{#2}%
!   \egroup
!   % We put the \gdef inside a group to avoid the definitions building up on
!   % TeX's save stack, which can cause it to run out of space for aux files with
!   % thousands of lines.  \gdef doesn't use the save stack, but \csname does
!   % when it defines an unknown control sequence as \relax.
    %
    % Was that xref control sequence that we just defined for a float?
    \expandafter\iffloat\csname XR\safexrefname\endcsname
***************
*** 7526,7531 ****
--- 9104,9126 ----
    \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{%
***************
*** 7565,7583 ****
    \catcode`\^^]=\other
    \catcode`\^^^=\other
    \catcode`\^^_=\other
-   % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
-   % in xref tags, i.e., node names.  But since ^^e4 notation isn't
-   % supported in the main text, it doesn't seem desirable.  Furthermore,
-   % that is not enough: for node names that actually contain a ^
-   % character, we would end up writing a line like this: 'xrdef {'hat
-   % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
-   % argument, and \hat is not an expandable control sequence.  It could
-   % all be worked out, but why?  Either we support ^^ or we don't.
-   %
-   % The other change necessary for this was to define \auxhat:
-   % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
-   % and then to call \auxhat in \setq.
-   %
    \catcode`\^=\other
    %
    % Special characters.  Should be turned off anyway, but...
--- 9160,9165 ----
***************
*** 7585,7618 ****
    \catcode`\[=\other
    \catcode`\]=\other
    \catcode`\"=\other
!   \catcode`\_=\other
!   \catcode`\|=\other
!   \catcode`\<=\other
!   \catcode`\>=\other
    \catcode`\$=\other
    \catcode`\#=\other
    \catcode`\&=\other
    \catcode`\%=\other
    \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
    %
!   % This is to support \ in node names and titles, since the \
!   % characters end up in a \csname.  It's easier than
!   % leaving it active and making its active definition an actual \
!   % character.  What I don't understand is why it works in the *value*
!   % of the xrdef.  Seems like it should be a catcode12 \, and that
!   % should not typeset properly.  But it works, so I'm moving on for
!   % now.  --karl, 15jan04.
!   \catcode`\\=\other
!   %
!   % Make the characters 128-255 be printing characters.
!   {%
!     \count1=128
!     \def\loop{%
!       \catcode\count1=\other
!       \advance\count1 by 1
!       \ifnum \count1<256 \loop \fi
!     }%
!   }%
    %
    % @ is our escape character in .aux files, and we need braces.
    \catcode`\{=1
--- 9167,9183 ----
    \catcode`\[=\other
    \catcode`\]=\other
    \catcode`\"=\other
!   \catcode`\_=\active
!   \catcode`\|=\active
!   \catcode`\<=\active
!   \catcode`\>=\active
    \catcode`\$=\other
    \catcode`\#=\other
    \catcode`\&=\other
    \catcode`\%=\other
    \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
    %
!   \catcode`\\=\active
    %
    % @ is our escape character in .aux files, and we need braces.
    \catcode`\{=1
***************
*** 7639,7653 ****
  % space to prevent strange expansion errors.)
  \def\supereject{\par\penalty -20000\footnoteno =0 }
  
! % @footnotestyle is meaningful for info output only.
  \let\footnotestyle=\comment
  
  {\catcode `\@=11
  %
  % Auto-number footnotes.  Otherwise like plain.
  \gdef\footnote{%
-   \let\indent=\ptexindent
-   \let\noindent=\ptexnoindent
    \global\advance\footnoteno by \@ne
    \edef\thisfootno{$^{\the\footnoteno}$}%
    %
--- 9204,9216 ----
  % space to prevent strange expansion errors.)
  \def\supereject{\par\penalty -20000\footnoteno =0 }
  
! % @footnotestyle is meaningful for Info output only.
  \let\footnotestyle=\comment
  
  {\catcode `\@=11
  %
  % Auto-number footnotes.  Otherwise like plain.
  \gdef\footnote{%
    \global\advance\footnoteno by \@ne
    \edef\thisfootno{$^{\the\footnoteno}$}%
    %
***************
*** 7671,7680 ****
  %
  \gdef\dofootnote{%
    \insert\footins\bgroup
    % We want to typeset this text as a normal paragraph, even if the
    % footnote reference occurs in (for example) a display environment.
    % So reset some parameters.
!   \hsize=\pagewidth
    \interlinepenalty\interfootnotelinepenalty
    \splittopskip\ht\strutbox % top baseline for broken footnotes
    \splitmaxdepth\dp\strutbox
--- 9234,9248 ----
  %
  \gdef\dofootnote{%
    \insert\footins\bgroup
+   %
+   % Nested footnotes are not supported in TeX, that would take a lot
+   % more work.  (\startsavinginserts does not suffice.)
+   \let\footnote=\errfootnotenest
+   %
    % We want to typeset this text as a normal paragraph, even if the
    % footnote reference occurs in (for example) a display environment.
    % So reset some parameters.
!   \hsize=\txipagewidth
    \interlinepenalty\interfootnotelinepenalty
    \splittopskip\ht\strutbox % top baseline for broken footnotes
    \splitmaxdepth\dp\strutbox
***************
*** 7702,7718 ****
    % expands into a box, it must come within the paragraph, lest it
    % provide a place where TeX can split the footnote.
    \footstrut
    \futurelet\next\fo@t
  }
  }%end \catcode `\@=11
  
  % In case a @footnote appears in a vbox, save the footnote text and create
  % the real \insert just after the vbox finished.  Otherwise, the insertion
  % would be lost.
  % Similarly, if a @footnote appears inside an alignment, save the footnote
  % text to a box and make the \insert when a row of the table is finished.
  % And the same can be done for other insert classes.  --kasal, 16nov03.
! 
  % Replace the \insert primitive by a cheating macro.
  % Deeper inside, just make sure that the saved insertions are not spilled
  % out prematurely.
--- 9270,9299 ----
    % expands into a box, it must come within the paragraph, lest it
    % provide a place where TeX can split the footnote.
    \footstrut
+   %
+   % Invoke rest of plain TeX footnote routine.
    \futurelet\next\fo@t
  }
  }%end \catcode `\@=11
  
+ \def\errfootnotenest{%
+   \errhelp=\EMsimple
+   \errmessage{Nested footnotes not supported in texinfo.tex,
+     even though they work in makeinfo; sorry}
+ }
+ 
+ \def\errfootnoteheading{%
+   \errhelp=\EMsimple
+   \errmessage{Footnotes in chapters, sections, etc., are not supported}
+ }
+ 
  % In case a @footnote appears in a vbox, save the footnote text and create
  % the real \insert just after the vbox finished.  Otherwise, the insertion
  % would be lost.
  % Similarly, if a @footnote appears inside an alignment, save the footnote
  % text to a box and make the \insert when a row of the table is finished.
  % And the same can be done for other insert classes.  --kasal, 16nov03.
! %
  % Replace the \insert primitive by a cheating macro.
  % Deeper inside, just make sure that the saved insertions are not spilled
  % out prematurely.
***************
*** 7786,7795 ****
  \newif\ifwarnednoepsf
  \newhelp\noepsfhelp{epsf.tex must be installed for images to
    work.  It is also included in the Texinfo distribution, or you can get
!   it from ftp://tug.org/tex/epsf.tex.}
  %
  \def\image#1{%
!   \ifx\epsfbox\undefined
      \ifwarnednoepsf \else
        \errhelp = \noepsfhelp
        \errmessage{epsf.tex not found, images will be ignored}%
--- 9367,9376 ----
  \newif\ifwarnednoepsf
  \newhelp\noepsfhelp{epsf.tex must be installed for images to
    work.  It is also included in the Texinfo distribution, or you can get
!   it from https://ctan.org/texarchive/macros/texinfo/texinfo/doc/epsf.tex.}
  %
  \def\image#1{%
!   \ifx\epsfbox\thisisundefined
      \ifwarnednoepsf \else
        \errhelp = \noepsfhelp
        \errmessage{epsf.tex not found, images will be ignored}%
***************
*** 7810,7818 ****
--- 9391,9407 ----
  \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
+   \makevalueexpandable
    % If the image is by itself, center it.
    \ifvmode
      \imagevmodetrue
+   \else \ifx\centersub\centerV
+     % for @center @image, we need a vbox so we can have our vertical space
+     \imagevmodetrue
+     \vbox\bgroup % vbox has better behavior than vtop herev
+   \fi\fi
+   %
+   \ifimagevmode
      \nobreak\medskip
      % Usually we'll have text after the image which will insert
      % \parskip glue, so insert it here too to equalize the space
***************
*** 7822,7842 ****
    \fi
    %
    % Leave vertical mode so that indentation from an enclosing
!   % environment such as @quotation is respected.  On the other hand, if
!   % it's at the top level, we don't want the normal paragraph indentation.
!   \noindent
    %
    % Output the image.
    \ifpdf
      \dopdfimage{#1}{#2}{#3}%
    \else
!     % \epsfbox itself resets \epsf?size at each figure.
!     \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
!     \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
!     \epsfbox{#1.eps}%
    \fi
    %
!   \ifimagevmode \medskip \fi  % space after the standalone image
  \endgroup}
  
  
--- 9411,9447 ----
    \fi
    %
    % Leave vertical mode so that indentation from an enclosing
!   %  environment such as @quotation is respected.
!   % However, if we're at the top level, we don't want the
!   %  normal paragraph indentation.
!   % On the other hand, if we are in the case of @center @image, we don't
!   %  want to start a paragraph, which will create a hsize-width box and
!   %  eradicate the centering.
!   \ifx\centersub\centerV \else \imageindent \fi
    %
    % Output the image.
    \ifpdf
+     % For pdfTeX and LuaTeX <= 0.80
      \dopdfimage{#1}{#2}{#3}%
    \else
!     \ifx\XeTeXrevision\thisisundefined
!       % For epsf.tex
!       % \epsfbox itself resets \epsf?size at each figure.
!       \setbox0 = \hbox{\ignorespaces #2}%
!         \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
!       \setbox0 = \hbox{\ignorespaces #3}%
!         \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
!       \epsfbox{#1.eps}%
!     \else
!       % For XeTeX
!       \doxeteximage{#1}{#2}{#3}%
!     \fi
    \fi
    %
!   \ifimagevmode
!     \medskip  % space after a standalone image
!   \fi
!   \ifx\centersub\centerV \egroup \fi
  \endgroup}
  
  
***************
*** 7903,7915 ****
        \global\advance\floatno by 1
        %
        {%
!         % This magic value for \lastsection is output by \setref as the
          % XREFLABEL-title value.  \xrefX uses it to distinguish float
          % labels (which have a completely different output format) from
          % node and anchor labels.  And \xrdef uses it to construct the
          % lists of floats.
          %
!         \edef\lastsection{\floatmagic=\safefloattype}%
          \setref{\floatlabel}{Yfloat}%
        }%
      \fi
--- 9508,9520 ----
        \global\advance\floatno by 1
        %
        {%
!         % This magic value for \currentsection is output by \setref as the
          % XREFLABEL-title value.  \xrefX uses it to distinguish float
          % labels (which have a completely different output format) from
          % node and anchor labels.  And \xrdef uses it to construct the
          % lists of floats.
          %
!         \edef\currentsection{\floatmagic=\safefloattype}%
          \setref{\floatlabel}{Yfloat}%
        }%
      \fi
***************
*** 7952,7958 ****
      %
      \ifx\thiscaption\empty \else
        \ifx\floatident\empty \else
! 	\appendtomacro\captionline{: }% had ident, so need a colon between
        \fi
        %
        % caption text.
--- 9557,9563 ----
      %
      \ifx\thiscaption\empty \else
        \ifx\floatident\empty \else
!         \appendtomacro\captionline{: }% had ident, so need a colon between
        \fi
        %
        % caption text.
***************
*** 7976,8007 ****
        % \floatlabel-lof.  Besides \floatident, we include the short
        % caption if specified, else the full caption if specified, else nothing.
        {%
          \atdummies
          %
!         % since we read the caption text in the macro world, where ^^M
!         % is turned into a normal character, we have to scan it back, so
!         % we don't write the literal three characters "^^M" into the aux file.
! 	\scanexp{%
! 	  \xdef\noexpand\gtemp{%
! 	    \ifx\thisshortcaption\empty
! 	      \thiscaption
! 	    \else
! 	      \thisshortcaption
! 	    \fi
! 	  }%
! 	}%
          \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
! 	  \ifx\gtemp\empty \else : \gtemp \fi}}%
        }%
      \fi
    \egroup  % end of \vtop
    %
-   % place the captured inserts
-   %
-   % BEWARE: when the floats start floating, we have to issue warning
-   % whenever an insert appears inside a float which could possibly
-   % float. --kasal, 26may04
-   %
    \checkinserts
  }
  
--- 9581,9600 ----
        % \floatlabel-lof.  Besides \floatident, we include the short
        % caption if specified, else the full caption if specified, else nothing.
        {%
+         \requireauxfile
          \atdummies
          %
!         \ifx\thisshortcaption\empty
!           \def\gtemp{\thiscaption}%
!         \else
!           \def\gtemp{\thisshortcaption}%
!         \fi
          \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
!           \ifx\gtemp\empty \else : \gtemp \fi}}%
        }%
      \fi
    \egroup  % end of \vtop
    %
    \checkinserts
  }
  
***************
*** 8044,8050 ****
  
  % #1 is the control sequence we are passed; we expand into a conditional
  % which is true if #1 represents a float ref.  That is, the magic
! % \lastsection value which we \setref above.
  %
  \def\iffloat#1{\expandafter\doiffloat#1==\finish}
  %
--- 9637,9643 ----
  
  % #1 is the control sequence we are passed; we expand into a conditional
  % which is true if #1 represents a float ref.  That is, the magic
! % \currentsection value which we \setref above.
  %
  \def\iffloat#1{\expandafter\doiffloat#1==\finish}
  %
***************
*** 8115,8134 ****
  {
    \catcode`\_ = \active
    \globaldefs=1
! \parseargdef\documentlanguage{\begingroup
!   \let_=\normalunderscore  % normal _ character for filenames
    \tex % read txi-??.tex file in plain TeX.
      % Read the file by the name they passed if it exists.
      \openin 1 txi-#1.tex
      \ifeof 1
!       \documentlanguagetrywithoutunderscore{#1_\finish}%
      \else
        \globaldefs = 1  % everything in the txi-LL files needs to persist
        \input txi-#1.tex
      \fi
      \closein 1
    \endgroup % end raw TeX
! \endgroup}
  %
  % If they passed de_DE, and txi-de_DE.tex doesn't exist,
  % try txi-de.tex.
--- 9708,9727 ----
  {
    \catcode`\_ = \active
    \globaldefs=1
! \parseargdef\documentlanguage{%
    \tex % read txi-??.tex file in plain TeX.
      % Read the file by the name they passed if it exists.
+     \let_ = \normalunderscore  % normal _ character for filename test
      \openin 1 txi-#1.tex
      \ifeof 1
!       \documentlanguagetrywithoutunderscore #1_\finish
      \else
        \globaldefs = 1  % everything in the txi-LL files needs to persist
        \input txi-#1.tex
      \fi
      \closein 1
    \endgroup % end raw TeX
! }
  %
  % If they passed de_DE, and txi-de_DE.tex doesn't exist,
  % try txi-de.tex.
***************
*** 8176,8181 ****
--- 9769,9838 ----
    \global\righthyphenmin = #3\relax
  }
  
+ % XeTeX and LuaTeX can handle Unicode natively.
+ % Their default I/O uses UTF-8 sequences instead of a byte-wise operation.
+ % Other TeX engines' I/O (pdfTeX, etc.) is byte-wise.
+ %
+ \newif\iftxinativeunicodecapable
+ \newif\iftxiusebytewiseio
+ 
+ \ifx\XeTeXrevision\thisisundefined
+   \ifx\luatexversion\thisisundefined
+     \txinativeunicodecapablefalse
+     \txiusebytewiseiotrue
+   \else
+     \txinativeunicodecapabletrue
+     \txiusebytewiseiofalse
+   \fi
+ \else
+   \txinativeunicodecapabletrue
+   \txiusebytewiseiofalse
+ \fi
+ 
+ % Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex
+ % for non-UTF-8 (byte-wise) encodings.
+ %
+ \def\setbytewiseio{%
+   \ifx\XeTeXrevision\thisisundefined
+   \else
+     \XeTeXdefaultencoding "bytes"  % For subsequent files to be read
+     \XeTeXinputencoding "bytes"  % For document root file
+     % Unfortunately, there seems to be no corresponding XeTeX command for
+     % output encoding.  This is a problem for auxiliary index and TOC files.
+     % The only solution would be perhaps to write out @U{...} sequences in
+     % place of non-ASCII characters.
+   \fi
+ 
+   \ifx\luatexversion\thisisundefined
+   \else
+     \directlua{
+     local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub
+     local function convert_char (char)
+       return utf8_char(byte(char))
+     end
+ 
+     local function convert_line (line)
+       return gsub(line, ".", convert_char)
+     end
+ 
+     callback.register("process_input_buffer", convert_line)
+ 
+     local function convert_line_out (line)
+       local line_out = ""
+       for c in string.utfvalues(line) do
+          line_out = line_out .. string.char(c)
+       end
+       return line_out
+     end
+ 
+     callback.register("process_output_buffer", convert_line_out)
+     }
+   \fi
+ 
+   \txiusebytewiseiotrue
+ }
+ 
+ 
  % Helpers for encodings.
  % Set the catcode of characters 128 through 255 to the specified number.
  %
***************
*** 8198,8204 ****
  % @documentencoding sets the definition of non-ASCII characters
  % according to the specified encoding.
  %
! \parseargdef\documentencoding{%
    % Encoding being declared for the document.
    \def\declaredencoding{\csname #1.enc\endcsname}%
    %
--- 9855,9863 ----
  % @documentencoding sets the definition of non-ASCII characters
  % according to the specified encoding.
  %
! \def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
! \def\documentencodingzzz#1{%
!   %
    % Encoding being declared for the document.
    \def\declaredencoding{\csname #1.enc\endcsname}%
    %
***************
*** 8214,8248 ****
       \asciichardefs
    %
    \else \ifx \declaredencoding \lattwo
       \setnonasciicharscatcode\active
       \lattwochardefs
    %
    \else \ifx \declaredencoding \latone
       \setnonasciicharscatcode\active
       \latonechardefs
    %
    \else \ifx \declaredencoding \latnine
       \setnonasciicharscatcode\active
       \latninechardefs
    %
    \else \ifx \declaredencoding \utfeight
!      \setnonasciicharscatcode\active
!      \utfeightchardefs
    %
    \else
!     \message{Unknown document encoding #1, ignoring.}%
    %
    \fi % utfeight
    \fi % latnine
    \fi % latone
    \fi % lattwo
    \fi % ascii
  }
  
  % A message to be logged when using a character that isn't available
  % the default font encoding (OT1).
  %
! \def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}}
  
  % Take account of \c (plain) vs. \, (Texinfo) difference.
  \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
--- 9873,9938 ----
       \asciichardefs
    %
    \else \ifx \declaredencoding \lattwo
+      \iftxinativeunicodecapable
+        \setbytewiseio
+      \fi
       \setnonasciicharscatcode\active
       \lattwochardefs
    %
    \else \ifx \declaredencoding \latone
+      \iftxinativeunicodecapable
+        \setbytewiseio
+      \fi
       \setnonasciicharscatcode\active
       \latonechardefs
    %
    \else \ifx \declaredencoding \latnine
+      \iftxinativeunicodecapable
+        \setbytewiseio
+      \fi
       \setnonasciicharscatcode\active
       \latninechardefs
    %
    \else \ifx \declaredencoding \utfeight
!      \iftxinativeunicodecapable
!        % For native Unicode handling (XeTeX and LuaTeX)
!        \nativeunicodechardefs
!      \else
!        % For treating UTF-8 as byte sequences (TeX, eTeX and pdfTeX)
!        \setnonasciicharscatcode\active
!        % since we already invoked \utfeightchardefs at the top level
!        % (below), do not re-invoke it, otherwise our check for duplicated
!        % definitions gets triggered.  Making non-ascii chars active is
!        % sufficient.
!      \fi
    %
    \else
!     \message{Ignoring unknown document encoding: #1.}%
    %
    \fi % utfeight
    \fi % latnine
    \fi % latone
    \fi % lattwo
    \fi % ascii
+   %
+   \ifx\XeTeXrevision\thisisundefined
+   \else
+     \ifx \declaredencoding \utfeight
+     \else
+       \ifx \declaredencoding \ascii
+       \else
+         \message{Warning: XeTeX with non-UTF-8 encodings cannot handle %
+         non-ASCII characters in auxiliary files.}%
+       \fi
+     \fi
+   \fi
  }
  
+ % emacs-page
  % A message to be logged when using a character that isn't available
  % the default font encoding (OT1).
  %
! \def\missingcharmsg#1{\message{Character missing, sorry: #1.}}
  
  % Take account of \c (plain) vs. \, (Texinfo) difference.
  \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
***************
*** 8252,8362 ****
  % macros containing the character definitions.
  \setnonasciicharscatcode\active
  %
  % Latin1 (ISO-8859-1) character definitions.
  \def\latonechardefs{%
!   \gdef^^a0{~}
!   \gdef^^a1{\exclamdown}
!   \gdef^^a2{\missingcharmsg{CENT SIGN}}
!   \gdef^^a3{{\pounds}}
!   \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
!   \gdef^^a5{\missingcharmsg{YEN SIGN}}
!   \gdef^^a6{\missingcharmsg{BROKEN BAR}}
!   \gdef^^a7{\S}
!   \gdef^^a8{\"{}}
!   \gdef^^a9{\copyright}
!   \gdef^^aa{\ordf}
!   \gdef^^ab{\guillemetleft}
!   \gdef^^ac{$\lnot$}
!   \gdef^^ad{\-}
!   \gdef^^ae{\registeredsymbol}
!   \gdef^^af{\={}}
!   %
!   \gdef^^b0{\textdegree}
!   \gdef^^b1{$\pm$}
!   \gdef^^b2{$^2$}
!   \gdef^^b3{$^3$}
!   \gdef^^b4{\'{}}
!   \gdef^^b5{$\mu$}
!   \gdef^^b6{\P}
!   %
!   \gdef^^b7{$^.$}
!   \gdef^^b8{\cedilla\ }
!   \gdef^^b9{$^1$}
!   \gdef^^ba{\ordm}
!   %
!   \gdef^^bb{\guilletright}
!   \gdef^^bc{$1\over4$}
!   \gdef^^bd{$1\over2$}
!   \gdef^^be{$3\over4$}
!   \gdef^^bf{\questiondown}
!   %
!   \gdef^^c0{\`A}
!   \gdef^^c1{\'A}
!   \gdef^^c2{\^A}
!   \gdef^^c3{\~A}
!   \gdef^^c4{\"A}
!   \gdef^^c5{\ringaccent A}
!   \gdef^^c6{\AE}
!   \gdef^^c7{\cedilla C}
!   \gdef^^c8{\`E}
!   \gdef^^c9{\'E}
!   \gdef^^ca{\^E}
!   \gdef^^cb{\"E}
!   \gdef^^cc{\`I}
!   \gdef^^cd{\'I}
!   \gdef^^ce{\^I}
!   \gdef^^cf{\"I}
!   %
!   \gdef^^d0{\DH}
!   \gdef^^d1{\~N}
!   \gdef^^d2{\`O}
!   \gdef^^d3{\'O}
!   \gdef^^d4{\^O}
!   \gdef^^d5{\~O}
!   \gdef^^d6{\"O}
!   \gdef^^d7{$\times$}
!   \gdef^^d8{\O}
!   \gdef^^d9{\`U}
!   \gdef^^da{\'U}
!   \gdef^^db{\^U}
!   \gdef^^dc{\"U}
!   \gdef^^dd{\'Y}
!   \gdef^^de{\TH}
!   \gdef^^df{\ss}
!   %
!   \gdef^^e0{\`a}
!   \gdef^^e1{\'a}
!   \gdef^^e2{\^a}
!   \gdef^^e3{\~a}
!   \gdef^^e4{\"a}
!   \gdef^^e5{\ringaccent a}
!   \gdef^^e6{\ae}
!   \gdef^^e7{\cedilla c}
!   \gdef^^e8{\`e}
!   \gdef^^e9{\'e}
!   \gdef^^ea{\^e}
!   \gdef^^eb{\"e}
!   \gdef^^ec{\`{\dotless i}}
!   \gdef^^ed{\'{\dotless i}}
!   \gdef^^ee{\^{\dotless i}}
!   \gdef^^ef{\"{\dotless i}}
!   %
!   \gdef^^f0{\dh}
!   \gdef^^f1{\~n}
!   \gdef^^f2{\`o}
!   \gdef^^f3{\'o}
!   \gdef^^f4{\^o}
!   \gdef^^f5{\~o}
!   \gdef^^f6{\"o}
!   \gdef^^f7{$\div$}
!   \gdef^^f8{\o}
!   \gdef^^f9{\`u}
!   \gdef^^fa{\'u}
!   \gdef^^fb{\^u}
!   \gdef^^fc{\"u}
!   \gdef^^fd{\'y}
!   \gdef^^fe{\th}
!   \gdef^^ff{\"y}
  }
  
  % Latin9 (ISO-8859-15) encoding character definitions.
--- 9942,10060 ----
  % macros containing the character definitions.
  \setnonasciicharscatcode\active
  %
+ 
+ \def\gdefchar#1#2{%
+ \gdef#1{%
+    \ifpassthroughchars
+      \string#1%
+    \else
+      #2%
+    \fi
+ }}
+ 
  % Latin1 (ISO-8859-1) character definitions.
  \def\latonechardefs{%
!   \gdefchar^^a0{\tie}
!   \gdefchar^^a1{\exclamdown}
!   \gdefchar^^a2{{\tcfont \char162}} % cent
!   \gdefchar^^a3{\pounds{}}
!   \gdefchar^^a4{{\tcfont \char164}} % currency
!   \gdefchar^^a5{{\tcfont \char165}} % yen
!   \gdefchar^^a6{{\tcfont \char166}} % broken bar
!   \gdefchar^^a7{\S}
!   \gdefchar^^a8{\"{}}
!   \gdefchar^^a9{\copyright{}}
!   \gdefchar^^aa{\ordf}
!   \gdefchar^^ab{\guillemetleft{}}
!   \gdefchar^^ac{\ensuremath\lnot}
!   \gdefchar^^ad{\-}
!   \gdefchar^^ae{\registeredsymbol{}}
!   \gdefchar^^af{\={}}
!   %
!   \gdefchar^^b0{\textdegree}
!   \gdefchar^^b1{$\pm$}
!   \gdefchar^^b2{$^2$}
!   \gdefchar^^b3{$^3$}
!   \gdefchar^^b4{\'{}}
!   \gdefchar^^b5{$\mu$}
!   \gdefchar^^b6{\P}
!   \gdefchar^^b7{\ensuremath\cdot}
!   \gdefchar^^b8{\cedilla\ }
!   \gdefchar^^b9{$^1$}
!   \gdefchar^^ba{\ordm}
!   \gdefchar^^bb{\guillemetright{}}
!   \gdefchar^^bc{$1\over4$}
!   \gdefchar^^bd{$1\over2$}
!   \gdefchar^^be{$3\over4$}
!   \gdefchar^^bf{\questiondown}
!   %
!   \gdefchar^^c0{\`A}
!   \gdefchar^^c1{\'A}
!   \gdefchar^^c2{\^A}
!   \gdefchar^^c3{\~A}
!   \gdefchar^^c4{\"A}
!   \gdefchar^^c5{\ringaccent A}
!   \gdefchar^^c6{\AE}
!   \gdefchar^^c7{\cedilla C}
!   \gdefchar^^c8{\`E}
!   \gdefchar^^c9{\'E}
!   \gdefchar^^ca{\^E}
!   \gdefchar^^cb{\"E}
!   \gdefchar^^cc{\`I}
!   \gdefchar^^cd{\'I}
!   \gdefchar^^ce{\^I}
!   \gdefchar^^cf{\"I}
!   %
!   \gdefchar^^d0{\DH}
!   \gdefchar^^d1{\~N}
!   \gdefchar^^d2{\`O}
!   \gdefchar^^d3{\'O}
!   \gdefchar^^d4{\^O}
!   \gdefchar^^d5{\~O}
!   \gdefchar^^d6{\"O}
!   \gdefchar^^d7{$\times$}
!   \gdefchar^^d8{\O}
!   \gdefchar^^d9{\`U}
!   \gdefchar^^da{\'U}
!   \gdefchar^^db{\^U}
!   \gdefchar^^dc{\"U}
!   \gdefchar^^dd{\'Y}
!   \gdefchar^^de{\TH}
!   \gdefchar^^df{\ss}
!   %
!   \gdefchar^^e0{\`a}
!   \gdefchar^^e1{\'a}
!   \gdefchar^^e2{\^a}
!   \gdefchar^^e3{\~a}
!   \gdefchar^^e4{\"a}
!   \gdefchar^^e5{\ringaccent a}
!   \gdefchar^^e6{\ae}
!   \gdefchar^^e7{\cedilla c}
!   \gdefchar^^e8{\`e}
!   \gdefchar^^e9{\'e}
!   \gdefchar^^ea{\^e}
!   \gdefchar^^eb{\"e}
!   \gdefchar^^ec{\`{\dotless i}}
!   \gdefchar^^ed{\'{\dotless i}}
!   \gdefchar^^ee{\^{\dotless i}}
!   \gdefchar^^ef{\"{\dotless i}}
!   %
!   \gdefchar^^f0{\dh}
!   \gdefchar^^f1{\~n}
!   \gdefchar^^f2{\`o}
!   \gdefchar^^f3{\'o}
!   \gdefchar^^f4{\^o}
!   \gdefchar^^f5{\~o}
!   \gdefchar^^f6{\"o}
!   \gdefchar^^f7{$\div$}
!   \gdefchar^^f8{\o}
!   \gdefchar^^f9{\`u}
!   \gdefchar^^fa{\'u}
!   \gdefchar^^fb{\^u}
!   \gdefchar^^fc{\"u}
!   \gdefchar^^fd{\'y}
!   \gdefchar^^fe{\th}
!   \gdefchar^^ff{\"y}
  }
  
  % Latin9 (ISO-8859-15) encoding character definitions.
***************
*** 8364,8482 ****
    % Encoding is almost identical to Latin1.
    \latonechardefs
    %
!   \gdef^^a4{\euro}
!   \gdef^^a6{\v S}
!   \gdef^^a8{\v s}
!   \gdef^^b4{\v Z}
!   \gdef^^b8{\v z}
!   \gdef^^bc{\OE}
!   \gdef^^bd{\oe}
!   \gdef^^be{\"Y}
  }
  
  % Latin2 (ISO-8859-2) character definitions.
  \def\lattwochardefs{%
!   \gdef^^a0{~}
!   \gdef^^a1{\ogonek{A}}
!   \gdef^^a2{\u{}}
!   \gdef^^a3{\L}
!   \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
!   \gdef^^a5{\v L}
!   \gdef^^a6{\'S}
!   \gdef^^a7{\S}
!   \gdef^^a8{\"{}}
!   \gdef^^a9{\v S}
!   \gdef^^aa{\cedilla S}
!   \gdef^^ab{\v T}
!   \gdef^^ac{\'Z}
!   \gdef^^ad{\-}
!   \gdef^^ae{\v Z}
!   \gdef^^af{\dotaccent Z}
!   %
!   \gdef^^b0{\textdegree}
!   \gdef^^b1{\ogonek{a}}
!   \gdef^^b2{\ogonek{ }}
!   \gdef^^b3{\l}
!   \gdef^^b4{\'{}}
!   \gdef^^b5{\v l}
!   \gdef^^b6{\'s}
!   \gdef^^b7{\v{}}
!   \gdef^^b8{\cedilla\ }
!   \gdef^^b9{\v s}
!   \gdef^^ba{\cedilla s}
!   \gdef^^bb{\v t}
!   \gdef^^bc{\'z}
!   \gdef^^bd{\H{}}
!   \gdef^^be{\v z}
!   \gdef^^bf{\dotaccent z}
!   %
!   \gdef^^c0{\'R}
!   \gdef^^c1{\'A}
!   \gdef^^c2{\^A}
!   \gdef^^c3{\u A}
!   \gdef^^c4{\"A}
!   \gdef^^c5{\'L}
!   \gdef^^c6{\'C}
!   \gdef^^c7{\cedilla C}
!   \gdef^^c8{\v C}
!   \gdef^^c9{\'E}
!   \gdef^^ca{\ogonek{E}}
!   \gdef^^cb{\"E}
!   \gdef^^cc{\v E}
!   \gdef^^cd{\'I}
!   \gdef^^ce{\^I}
!   \gdef^^cf{\v D}
!   %
!   \gdef^^d0{\DH}
!   \gdef^^d1{\'N}
!   \gdef^^d2{\v N}
!   \gdef^^d3{\'O}
!   \gdef^^d4{\^O}
!   \gdef^^d5{\H O}
!   \gdef^^d6{\"O}
!   \gdef^^d7{$\times$}
!   \gdef^^d8{\v R}
!   \gdef^^d9{\ringaccent U}
!   \gdef^^da{\'U}
!   \gdef^^db{\H U}
!   \gdef^^dc{\"U}
!   \gdef^^dd{\'Y}
!   \gdef^^de{\cedilla T}
!   \gdef^^df{\ss}
!   %
!   \gdef^^e0{\'r}
!   \gdef^^e1{\'a}
!   \gdef^^e2{\^a}
!   \gdef^^e3{\u a}
!   \gdef^^e4{\"a}
!   \gdef^^e5{\'l}
!   \gdef^^e6{\'c}
!   \gdef^^e7{\cedilla c}
!   \gdef^^e8{\v c}
!   \gdef^^e9{\'e}
!   \gdef^^ea{\ogonek{e}}
!   \gdef^^eb{\"e}
!   \gdef^^ec{\v e}
!   \gdef^^ed{\'{\dotless{i}}}
!   \gdef^^ee{\^{\dotless{i}}}
!   \gdef^^ef{\v d}
!   %
!   \gdef^^f0{\dh}
!   \gdef^^f1{\'n}
!   \gdef^^f2{\v n}
!   \gdef^^f3{\'o}
!   \gdef^^f4{\^o}
!   \gdef^^f5{\H o}
!   \gdef^^f6{\"o}
!   \gdef^^f7{$\div$}
!   \gdef^^f8{\v r}
!   \gdef^^f9{\ringaccent u}
!   \gdef^^fa{\'u}
!   \gdef^^fb{\H u}
!   \gdef^^fc{\"u}
!   \gdef^^fd{\'y}
!   \gdef^^fe{\cedilla t}
!   \gdef^^ff{\dotaccent{}}
  }
  
  % UTF-8 character definitions.
--- 10062,10180 ----
    % Encoding is almost identical to Latin1.
    \latonechardefs
    %
!   \gdefchar^^a4{\euro{}}
!   \gdefchar^^a6{\v S}
!   \gdefchar^^a8{\v s}
!   \gdefchar^^b4{\v Z}
!   \gdefchar^^b8{\v z}
!   \gdefchar^^bc{\OE}
!   \gdefchar^^bd{\oe}
!   \gdefchar^^be{\"Y}
  }
  
  % Latin2 (ISO-8859-2) character definitions.
  \def\lattwochardefs{%
!   \gdefchar^^a0{\tie}
!   \gdefchar^^a1{\ogonek{A}}
!   \gdefchar^^a2{\u{}}
!   \gdefchar^^a3{\L}
!   \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}}
!   \gdefchar^^a5{\v L}
!   \gdefchar^^a6{\'S}
!   \gdefchar^^a7{\S}
!   \gdefchar^^a8{\"{}}
!   \gdefchar^^a9{\v S}
!   \gdefchar^^aa{\cedilla S}
!   \gdefchar^^ab{\v T}
!   \gdefchar^^ac{\'Z}
!   \gdefchar^^ad{\-}
!   \gdefchar^^ae{\v Z}
!   \gdefchar^^af{\dotaccent Z}
!   %
!   \gdefchar^^b0{\textdegree{}}
!   \gdefchar^^b1{\ogonek{a}}
!   \gdefchar^^b2{\ogonek{ }}
!   \gdefchar^^b3{\l}
!   \gdefchar^^b4{\'{}}
!   \gdefchar^^b5{\v l}
!   \gdefchar^^b6{\'s}
!   \gdefchar^^b7{\v{}}
!   \gdefchar^^b8{\cedilla\ }
!   \gdefchar^^b9{\v s}
!   \gdefchar^^ba{\cedilla s}
!   \gdefchar^^bb{\v t}
!   \gdefchar^^bc{\'z}
!   \gdefchar^^bd{\H{}}
!   \gdefchar^^be{\v z}
!   \gdefchar^^bf{\dotaccent z}
!   %
!   \gdefchar^^c0{\'R}
!   \gdefchar^^c1{\'A}
!   \gdefchar^^c2{\^A}
!   \gdefchar^^c3{\u A}
!   \gdefchar^^c4{\"A}
!   \gdefchar^^c5{\'L}
!   \gdefchar^^c6{\'C}
!   \gdefchar^^c7{\cedilla C}
!   \gdefchar^^c8{\v C}
!   \gdefchar^^c9{\'E}
!   \gdefchar^^ca{\ogonek{E}}
!   \gdefchar^^cb{\"E}
!   \gdefchar^^cc{\v E}
!   \gdefchar^^cd{\'I}
!   \gdefchar^^ce{\^I}
!   \gdefchar^^cf{\v D}
!   %
!   \gdefchar^^d0{\DH}
!   \gdefchar^^d1{\'N}
!   \gdefchar^^d2{\v N}
!   \gdefchar^^d3{\'O}
!   \gdefchar^^d4{\^O}
!   \gdefchar^^d5{\H O}
!   \gdefchar^^d6{\"O}
!   \gdefchar^^d7{$\times$}
!   \gdefchar^^d8{\v R}
!   \gdefchar^^d9{\ringaccent U}
!   \gdefchar^^da{\'U}
!   \gdefchar^^db{\H U}
!   \gdefchar^^dc{\"U}
!   \gdefchar^^dd{\'Y}
!   \gdefchar^^de{\cedilla T}
!   \gdefchar^^df{\ss}
!   %
!   \gdefchar^^e0{\'r}
!   \gdefchar^^e1{\'a}
!   \gdefchar^^e2{\^a}
!   \gdefchar^^e3{\u a}
!   \gdefchar^^e4{\"a}
!   \gdefchar^^e5{\'l}
!   \gdefchar^^e6{\'c}
!   \gdefchar^^e7{\cedilla c}
!   \gdefchar^^e8{\v c}
!   \gdefchar^^e9{\'e}
!   \gdefchar^^ea{\ogonek{e}}
!   \gdefchar^^eb{\"e}
!   \gdefchar^^ec{\v e}
!   \gdefchar^^ed{\'{\dotless{i}}}
!   \gdefchar^^ee{\^{\dotless{i}}}
!   \gdefchar^^ef{\v d}
!   %
!   \gdefchar^^f0{\dh}
!   \gdefchar^^f1{\'n}
!   \gdefchar^^f2{\v n}
!   \gdefchar^^f3{\'o}
!   \gdefchar^^f4{\^o}
!   \gdefchar^^f5{\H o}
!   \gdefchar^^f6{\"o}
!   \gdefchar^^f7{$\div$}
!   \gdefchar^^f8{\v r}
!   \gdefchar^^f9{\ringaccent u}
!   \gdefchar^^fa{\'u}
!   \gdefchar^^fb{\H u}
!   \gdefchar^^fc{\"u}
!   \gdefchar^^fd{\'y}
!   \gdefchar^^fe{\cedilla t}
!   \gdefchar^^ff{\dotaccent{}}
  }
  
  % UTF-8 character definitions.
***************
*** 8506,8543 ****
    \fi
  }
  
  \begingroup
    \catcode`\~13
    \catcode`\"12
  
    \def\UTFviiiLoop{%
      \global\catcode\countUTFx\active
      \uccode`\~\countUTFx
      \uppercase\expandafter{\UTFviiiTmp}%
      \advance\countUTFx by 1
      \ifnum\countUTFx < \countUTFy
        \expandafter\UTFviiiLoop
      \fi}
  
    \countUTFx = "C2
    \countUTFy = "E0
    \def\UTFviiiTmp{%
!     \xdef~{\noexpand\UTFviiiTwoOctets\string~}}
    \UTFviiiLoop
  
    \countUTFx = "E0
    \countUTFy = "F0
    \def\UTFviiiTmp{%
!     \xdef~{\noexpand\UTFviiiThreeOctets\string~}}
    \UTFviiiLoop
  
    \countUTFx = "F0
    \countUTFy = "F4
    \def\UTFviiiTmp{%
!     \xdef~{\noexpand\UTFviiiFourOctets\string~}}
    \UTFviiiLoop
  \endgroup
  
  \begingroup
    \catcode`\"=12
    \catcode`\<=12
--- 10204,10297 ----
    \fi
  }
  
+ % Give non-ASCII bytes the active definitions for processing UTF-8 sequences
  \begingroup
    \catcode`\~13
+   \catcode`\$12
    \catcode`\"12
  
+   % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp
+   % substituting ~ and $ with a character token of that value.
    \def\UTFviiiLoop{%
      \global\catcode\countUTFx\active
      \uccode`\~\countUTFx
+     \uccode`\$\countUTFx
      \uppercase\expandafter{\UTFviiiTmp}%
      \advance\countUTFx by 1
      \ifnum\countUTFx < \countUTFy
        \expandafter\UTFviiiLoop
      \fi}
  
+   % For bytes other than the first in a UTF-8 sequence.  Not expected to
+   % be expanded except when writing to auxiliary files.
+   \countUTFx = "80
+   \countUTFy = "C2
+   \def\UTFviiiTmp{%
+     \gdef~{%
+         \ifpassthroughchars $\fi}}%
+   \UTFviiiLoop
+ 
    \countUTFx = "C2
    \countUTFy = "E0
    \def\UTFviiiTmp{%
!     \gdef~{%
!         \ifpassthroughchars $%
!         \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}%
    \UTFviiiLoop
  
    \countUTFx = "E0
    \countUTFy = "F0
    \def\UTFviiiTmp{%
!     \gdef~{%
!         \ifpassthroughchars $%
!         \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}%
    \UTFviiiLoop
  
    \countUTFx = "F0
    \countUTFy = "F4
    \def\UTFviiiTmp{%
!     \gdef~{%
!         \ifpassthroughchars $%
!         \else\expandafter\UTFviiiFourOctets\expandafter$\fi
!         }}%
    \UTFviiiLoop
  \endgroup
  
+ \def\globallet{\global\let} % save some \expandafter's below
+ 
+ % @U{xxxx} to produce U+xxxx, if we support it.
+ \def\U#1{%
+   \expandafter\ifx\csname uni:#1\endcsname \relax
+     \iftxinativeunicodecapable
+       % All Unicode characters can be used if native Unicode handling is
+       % active.  However, if the font does not have the glyph,
+       % letters are missing.
+       \begingroup
+         \uccode`\.="#1\relax
+         \uppercase{.}
+       \endgroup
+     \else
+       \errhelp = \EMsimple
+       \errmessage{Unicode character U+#1 not supported, sorry}%
+     \fi
+   \else
+     \csname uni:#1\endcsname
+   \fi
+ }
+ 
+ % These macros are used here to construct the name of a control
+ % sequence to be defined.
+ \def\UTFviiiTwoOctetsName#1#2{%
+   \csname u8:#1\string #2\endcsname}%
+ \def\UTFviiiThreeOctetsName#1#2#3{%
+   \csname u8:#1\string #2\string #3\endcsname}%
+ \def\UTFviiiFourOctetsName#1#2#3#4{%
+   \csname u8:#1\string #2\string #3\string #4\endcsname}%
+ 
+ % For UTF-8 byte sequences (TeX, e-TeX and pdfTeX),
+ % provide a definition macro to replace a Unicode character;
+ % this gets used by the @U command
+ %
  \begingroup
    \catcode`\"=12
    \catcode`\<=12
***************
*** 8546,9010 ****
    \catcode`\;=12
    \catcode`\!=12
    \catcode`\~=13
! 
!   \gdef\DeclareUnicodeCharacter#1#2{%
      \countUTFz = "#1\relax
-     %\wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}%
      \begingroup
        \parseXMLCharref
-       \def\UTFviiiTwoOctets##1##2{%
-         \csname u8:##1\string ##2\endcsname}%
-       \def\UTFviiiThreeOctets##1##2##3{%
-         \csname u8:##1\string ##2\string ##3\endcsname}%
-       \def\UTFviiiFourOctets##1##2##3##4{%
-         \csname u8:##1\string ##2\string ##3\string ##4\endcsname}%
-       \expandafter\expandafter\expandafter\expandafter
-        \expandafter\expandafter\expandafter
-        \gdef\UTFviiiTmp{#2}%
-     \endgroup}
  
    \gdef\parseXMLCharref{%
      \ifnum\countUTFz < "A0\relax
        \errhelp = \EMsimple
        \errmessage{Cannot define Unicode char value < 00A0}%
      \else\ifnum\countUTFz < "800\relax
        \parseUTFviiiA,%
!       \parseUTFviiiB C\UTFviiiTwoOctets.,%
      \else\ifnum\countUTFz < "10000\relax
        \parseUTFviiiA;%
        \parseUTFviiiA,%
!       \parseUTFviiiB E\UTFviiiThreeOctets.{,;}%
      \else
        \parseUTFviiiA;%
        \parseUTFviiiA,%
        \parseUTFviiiA!%
!       \parseUTFviiiB F\UTFviiiFourOctets.{!,;}%
      \fi\fi\fi
    }
  
    \gdef\parseUTFviiiA#1{%
      \countUTFx = \countUTFz
      \divide\countUTFz by 64
!     \countUTFy = \countUTFz
      \multiply\countUTFz by 64
      \advance\countUTFx by -\countUTFz
      \advance\countUTFx by 128
      \uccode `#1\countUTFx
      \countUTFz = \countUTFy}
  
    \gdef\parseUTFviiiB#1#2#3#4{%
      \advance\countUTFz by "#10\relax
      \uccode `#3\countUTFz
      \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
  \endgroup
  
  \def\utfeightchardefs{%
!   \DeclareUnicodeCharacter{00A0}{\tie}
!   \DeclareUnicodeCharacter{00A1}{\exclamdown}
!   \DeclareUnicodeCharacter{00A3}{\pounds}
!   \DeclareUnicodeCharacter{00A8}{\"{ }}
!   \DeclareUnicodeCharacter{00A9}{\copyright}
!   \DeclareUnicodeCharacter{00AA}{\ordf}
!   \DeclareUnicodeCharacter{00AB}{\guillemetleft}
!   \DeclareUnicodeCharacter{00AD}{\-}
!   \DeclareUnicodeCharacter{00AE}{\registeredsymbol}
!   \DeclareUnicodeCharacter{00AF}{\={ }}
! 
!   \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}
!   \DeclareUnicodeCharacter{00B4}{\'{ }}
!   \DeclareUnicodeCharacter{00B8}{\cedilla{ }}
!   \DeclareUnicodeCharacter{00BA}{\ordm}
!   \DeclareUnicodeCharacter{00BB}{\guillemetright}
!   \DeclareUnicodeCharacter{00BF}{\questiondown}
! 
!   \DeclareUnicodeCharacter{00C0}{\`A}
!   \DeclareUnicodeCharacter{00C1}{\'A}
!   \DeclareUnicodeCharacter{00C2}{\^A}
!   \DeclareUnicodeCharacter{00C3}{\~A}
!   \DeclareUnicodeCharacter{00C4}{\"A}
!   \DeclareUnicodeCharacter{00C5}{\AA}
!   \DeclareUnicodeCharacter{00C6}{\AE}
!   \DeclareUnicodeCharacter{00C7}{\cedilla{C}}
!   \DeclareUnicodeCharacter{00C8}{\`E}
!   \DeclareUnicodeCharacter{00C9}{\'E}
!   \DeclareUnicodeCharacter{00CA}{\^E}
!   \DeclareUnicodeCharacter{00CB}{\"E}
!   \DeclareUnicodeCharacter{00CC}{\`I}
!   \DeclareUnicodeCharacter{00CD}{\'I}
!   \DeclareUnicodeCharacter{00CE}{\^I}
!   \DeclareUnicodeCharacter{00CF}{\"I}
! 
!   \DeclareUnicodeCharacter{00D0}{\DH}
!   \DeclareUnicodeCharacter{00D1}{\~N}
!   \DeclareUnicodeCharacter{00D2}{\`O}
!   \DeclareUnicodeCharacter{00D3}{\'O}
!   \DeclareUnicodeCharacter{00D4}{\^O}
!   \DeclareUnicodeCharacter{00D5}{\~O}
!   \DeclareUnicodeCharacter{00D6}{\"O}
!   \DeclareUnicodeCharacter{00D8}{\O}
!   \DeclareUnicodeCharacter{00D9}{\`U}
!   \DeclareUnicodeCharacter{00DA}{\'U}
!   \DeclareUnicodeCharacter{00DB}{\^U}
!   \DeclareUnicodeCharacter{00DC}{\"U}
!   \DeclareUnicodeCharacter{00DD}{\'Y}
!   \DeclareUnicodeCharacter{00DE}{\TH}
!   \DeclareUnicodeCharacter{00DF}{\ss}
! 
!   \DeclareUnicodeCharacter{00E0}{\`a}
!   \DeclareUnicodeCharacter{00E1}{\'a}
!   \DeclareUnicodeCharacter{00E2}{\^a}
!   \DeclareUnicodeCharacter{00E3}{\~a}
!   \DeclareUnicodeCharacter{00E4}{\"a}
!   \DeclareUnicodeCharacter{00E5}{\aa}
!   \DeclareUnicodeCharacter{00E6}{\ae}
!   \DeclareUnicodeCharacter{00E7}{\cedilla{c}}
!   \DeclareUnicodeCharacter{00E8}{\`e}
!   \DeclareUnicodeCharacter{00E9}{\'e}
!   \DeclareUnicodeCharacter{00EA}{\^e}
!   \DeclareUnicodeCharacter{00EB}{\"e}
!   \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}
!   \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}
!   \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}
!   \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}
! 
!   \DeclareUnicodeCharacter{00F0}{\dh}
!   \DeclareUnicodeCharacter{00F1}{\~n}
!   \DeclareUnicodeCharacter{00F2}{\`o}
!   \DeclareUnicodeCharacter{00F3}{\'o}
!   \DeclareUnicodeCharacter{00F4}{\^o}
!   \DeclareUnicodeCharacter{00F5}{\~o}
!   \DeclareUnicodeCharacter{00F6}{\"o}
!   \DeclareUnicodeCharacter{00F8}{\o}
!   \DeclareUnicodeCharacter{00F9}{\`u}
!   \DeclareUnicodeCharacter{00FA}{\'u}
!   \DeclareUnicodeCharacter{00FB}{\^u}
!   \DeclareUnicodeCharacter{00FC}{\"u}
!   \DeclareUnicodeCharacter{00FD}{\'y}
!   \DeclareUnicodeCharacter{00FE}{\th}
!   \DeclareUnicodeCharacter{00FF}{\"y}
! 
!   \DeclareUnicodeCharacter{0100}{\=A}
!   \DeclareUnicodeCharacter{0101}{\=a}
!   \DeclareUnicodeCharacter{0102}{\u{A}}
!   \DeclareUnicodeCharacter{0103}{\u{a}}
!   \DeclareUnicodeCharacter{0104}{\ogonek{A}}
!   \DeclareUnicodeCharacter{0105}{\ogonek{a}}
!   \DeclareUnicodeCharacter{0106}{\'C}
!   \DeclareUnicodeCharacter{0107}{\'c}
!   \DeclareUnicodeCharacter{0108}{\^C}
!   \DeclareUnicodeCharacter{0109}{\^c}
!   \DeclareUnicodeCharacter{0118}{\ogonek{E}}
!   \DeclareUnicodeCharacter{0119}{\ogonek{e}}
!   \DeclareUnicodeCharacter{010A}{\dotaccent{C}}
!   \DeclareUnicodeCharacter{010B}{\dotaccent{c}}
!   \DeclareUnicodeCharacter{010C}{\v{C}}
!   \DeclareUnicodeCharacter{010D}{\v{c}}
!   \DeclareUnicodeCharacter{010E}{\v{D}}
! 
!   \DeclareUnicodeCharacter{0112}{\=E}
!   \DeclareUnicodeCharacter{0113}{\=e}
!   \DeclareUnicodeCharacter{0114}{\u{E}}
!   \DeclareUnicodeCharacter{0115}{\u{e}}
!   \DeclareUnicodeCharacter{0116}{\dotaccent{E}}
!   \DeclareUnicodeCharacter{0117}{\dotaccent{e}}
!   \DeclareUnicodeCharacter{011A}{\v{E}}
!   \DeclareUnicodeCharacter{011B}{\v{e}}
!   \DeclareUnicodeCharacter{011C}{\^G}
!   \DeclareUnicodeCharacter{011D}{\^g}
!   \DeclareUnicodeCharacter{011E}{\u{G}}
!   \DeclareUnicodeCharacter{011F}{\u{g}}
! 
!   \DeclareUnicodeCharacter{0120}{\dotaccent{G}}
!   \DeclareUnicodeCharacter{0121}{\dotaccent{g}}
!   \DeclareUnicodeCharacter{0124}{\^H}
!   \DeclareUnicodeCharacter{0125}{\^h}
!   \DeclareUnicodeCharacter{0128}{\~I}
!   \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}
!   \DeclareUnicodeCharacter{012A}{\=I}
!   \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}
!   \DeclareUnicodeCharacter{012C}{\u{I}}
!   \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}
! 
!   \DeclareUnicodeCharacter{0130}{\dotaccent{I}}
!   \DeclareUnicodeCharacter{0131}{\dotless{i}}
!   \DeclareUnicodeCharacter{0132}{IJ}
!   \DeclareUnicodeCharacter{0133}{ij}
!   \DeclareUnicodeCharacter{0134}{\^J}
!   \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}
!   \DeclareUnicodeCharacter{0139}{\'L}
!   \DeclareUnicodeCharacter{013A}{\'l}
! 
!   \DeclareUnicodeCharacter{0141}{\L}
!   \DeclareUnicodeCharacter{0142}{\l}
!   \DeclareUnicodeCharacter{0143}{\'N}
!   \DeclareUnicodeCharacter{0144}{\'n}
!   \DeclareUnicodeCharacter{0147}{\v{N}}
!   \DeclareUnicodeCharacter{0148}{\v{n}}
!   \DeclareUnicodeCharacter{014C}{\=O}
!   \DeclareUnicodeCharacter{014D}{\=o}
!   \DeclareUnicodeCharacter{014E}{\u{O}}
!   \DeclareUnicodeCharacter{014F}{\u{o}}
! 
!   \DeclareUnicodeCharacter{0150}{\H{O}}
!   \DeclareUnicodeCharacter{0151}{\H{o}}
!   \DeclareUnicodeCharacter{0152}{\OE}
!   \DeclareUnicodeCharacter{0153}{\oe}
!   \DeclareUnicodeCharacter{0154}{\'R}
!   \DeclareUnicodeCharacter{0155}{\'r}
!   \DeclareUnicodeCharacter{0158}{\v{R}}
!   \DeclareUnicodeCharacter{0159}{\v{r}}
!   \DeclareUnicodeCharacter{015A}{\'S}
!   \DeclareUnicodeCharacter{015B}{\'s}
!   \DeclareUnicodeCharacter{015C}{\^S}
!   \DeclareUnicodeCharacter{015D}{\^s}
!   \DeclareUnicodeCharacter{015E}{\cedilla{S}}
!   \DeclareUnicodeCharacter{015F}{\cedilla{s}}
! 
!   \DeclareUnicodeCharacter{0160}{\v{S}}
!   \DeclareUnicodeCharacter{0161}{\v{s}}
!   \DeclareUnicodeCharacter{0162}{\cedilla{t}}
!   \DeclareUnicodeCharacter{0163}{\cedilla{T}}
!   \DeclareUnicodeCharacter{0164}{\v{T}}
! 
!   \DeclareUnicodeCharacter{0168}{\~U}
!   \DeclareUnicodeCharacter{0169}{\~u}
!   \DeclareUnicodeCharacter{016A}{\=U}
!   \DeclareUnicodeCharacter{016B}{\=u}
!   \DeclareUnicodeCharacter{016C}{\u{U}}
!   \DeclareUnicodeCharacter{016D}{\u{u}}
!   \DeclareUnicodeCharacter{016E}{\ringaccent{U}}
!   \DeclareUnicodeCharacter{016F}{\ringaccent{u}}
! 
!   \DeclareUnicodeCharacter{0170}{\H{U}}
!   \DeclareUnicodeCharacter{0171}{\H{u}}
!   \DeclareUnicodeCharacter{0174}{\^W}
!   \DeclareUnicodeCharacter{0175}{\^w}
!   \DeclareUnicodeCharacter{0176}{\^Y}
!   \DeclareUnicodeCharacter{0177}{\^y}
!   \DeclareUnicodeCharacter{0178}{\"Y}
!   \DeclareUnicodeCharacter{0179}{\'Z}
!   \DeclareUnicodeCharacter{017A}{\'z}
!   \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}
!   \DeclareUnicodeCharacter{017C}{\dotaccent{z}}
!   \DeclareUnicodeCharacter{017D}{\v{Z}}
!   \DeclareUnicodeCharacter{017E}{\v{z}}
! 
!   \DeclareUnicodeCharacter{01C4}{D\v{Z}}
!   \DeclareUnicodeCharacter{01C5}{D\v{z}}
!   \DeclareUnicodeCharacter{01C6}{d\v{z}}
!   \DeclareUnicodeCharacter{01C7}{LJ}
!   \DeclareUnicodeCharacter{01C8}{Lj}
!   \DeclareUnicodeCharacter{01C9}{lj}
!   \DeclareUnicodeCharacter{01CA}{NJ}
!   \DeclareUnicodeCharacter{01CB}{Nj}
!   \DeclareUnicodeCharacter{01CC}{nj}
!   \DeclareUnicodeCharacter{01CD}{\v{A}}
!   \DeclareUnicodeCharacter{01CE}{\v{a}}
!   \DeclareUnicodeCharacter{01CF}{\v{I}}
! 
!   \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}
!   \DeclareUnicodeCharacter{01D1}{\v{O}}
!   \DeclareUnicodeCharacter{01D2}{\v{o}}
!   \DeclareUnicodeCharacter{01D3}{\v{U}}
!   \DeclareUnicodeCharacter{01D4}{\v{u}}
! 
!   \DeclareUnicodeCharacter{01E2}{\={\AE}}
!   \DeclareUnicodeCharacter{01E3}{\={\ae}}
!   \DeclareUnicodeCharacter{01E6}{\v{G}}
!   \DeclareUnicodeCharacter{01E7}{\v{g}}
!   \DeclareUnicodeCharacter{01E8}{\v{K}}
!   \DeclareUnicodeCharacter{01E9}{\v{k}}
! 
!   \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}
!   \DeclareUnicodeCharacter{01F1}{DZ}
!   \DeclareUnicodeCharacter{01F2}{Dz}
!   \DeclareUnicodeCharacter{01F3}{dz}
!   \DeclareUnicodeCharacter{01F4}{\'G}
!   \DeclareUnicodeCharacter{01F5}{\'g}
!   \DeclareUnicodeCharacter{01F8}{\`N}
!   \DeclareUnicodeCharacter{01F9}{\`n}
!   \DeclareUnicodeCharacter{01FC}{\'{\AE}}
!   \DeclareUnicodeCharacter{01FD}{\'{\ae}}
!   \DeclareUnicodeCharacter{01FE}{\'{\O}}
!   \DeclareUnicodeCharacter{01FF}{\'{\o}}
! 
!   \DeclareUnicodeCharacter{021E}{\v{H}}
!   \DeclareUnicodeCharacter{021F}{\v{h}}
! 
!   \DeclareUnicodeCharacter{0226}{\dotaccent{A}}
!   \DeclareUnicodeCharacter{0227}{\dotaccent{a}}
!   \DeclareUnicodeCharacter{0228}{\cedilla{E}}
!   \DeclareUnicodeCharacter{0229}{\cedilla{e}}
!   \DeclareUnicodeCharacter{022E}{\dotaccent{O}}
!   \DeclareUnicodeCharacter{022F}{\dotaccent{o}}
! 
!   \DeclareUnicodeCharacter{0232}{\=Y}
!   \DeclareUnicodeCharacter{0233}{\=y}
!   \DeclareUnicodeCharacter{0237}{\dotless{j}}
! 
!   \DeclareUnicodeCharacter{02DB}{\ogonek{ }}
! 
!   \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}
!   \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}
!   \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}
!   \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}
!   \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}
!   \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}
!   \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}
!   \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}
!   \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}
!   \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}
!   \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}
!   \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}
! 
!   \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}
!   \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}
! 
!   \DeclareUnicodeCharacter{1E20}{\=G}
!   \DeclareUnicodeCharacter{1E21}{\=g}
!   \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}
!   \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}
!   \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}
!   \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}
!   \DeclareUnicodeCharacter{1E26}{\"H}
!   \DeclareUnicodeCharacter{1E27}{\"h}
! 
!   \DeclareUnicodeCharacter{1E30}{\'K}
!   \DeclareUnicodeCharacter{1E31}{\'k}
!   \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}
!   \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}
!   \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}
!   \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}
!   \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}
!   \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}
!   \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}
!   \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}
!   \DeclareUnicodeCharacter{1E3E}{\'M}
!   \DeclareUnicodeCharacter{1E3F}{\'m}
! 
!   \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}
!   \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}
!   \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}
!   \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}
!   \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}
!   \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}
!   \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}
!   \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}
!   \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}
!   \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}
! 
!   \DeclareUnicodeCharacter{1E54}{\'P}
!   \DeclareUnicodeCharacter{1E55}{\'p}
!   \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}
!   \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}
!   \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}
!   \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}
!   \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}
!   \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}
!   \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}
!   \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}
! 
!   \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}
!   \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}
!   \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}
!   \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}
!   \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}
!   \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}
!   \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}
!   \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}
!   \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}
!   \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}
! 
!   \DeclareUnicodeCharacter{1E7C}{\~V}
!   \DeclareUnicodeCharacter{1E7D}{\~v}
!   \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}
!   \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}
! 
!   \DeclareUnicodeCharacter{1E80}{\`W}
!   \DeclareUnicodeCharacter{1E81}{\`w}
!   \DeclareUnicodeCharacter{1E82}{\'W}
!   \DeclareUnicodeCharacter{1E83}{\'w}
!   \DeclareUnicodeCharacter{1E84}{\"W}
!   \DeclareUnicodeCharacter{1E85}{\"w}
!   \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}
!   \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}
!   \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}
!   \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}
!   \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}
!   \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}
!   \DeclareUnicodeCharacter{1E8C}{\"X}
!   \DeclareUnicodeCharacter{1E8D}{\"x}
!   \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}
!   \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}
! 
!   \DeclareUnicodeCharacter{1E90}{\^Z}
!   \DeclareUnicodeCharacter{1E91}{\^z}
!   \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}
!   \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}
!   \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}
!   \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}
!   \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}
!   \DeclareUnicodeCharacter{1E97}{\"t}
!   \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}
!   \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}
! 
!   \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}
!   \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}
! 
!   \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}
!   \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}
!   \DeclareUnicodeCharacter{1EBC}{\~E}
!   \DeclareUnicodeCharacter{1EBD}{\~e}
! 
!   \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}
!   \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}
!   \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}
!   \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}
! 
!   \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}
!   \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}
! 
!   \DeclareUnicodeCharacter{1EF2}{\`Y}
!   \DeclareUnicodeCharacter{1EF3}{\`y}
!   \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}
! 
!   \DeclareUnicodeCharacter{1EF8}{\~Y}
!   \DeclareUnicodeCharacter{1EF9}{\~y}
! 
!   \DeclareUnicodeCharacter{2013}{--}
!   \DeclareUnicodeCharacter{2014}{---}
!   \DeclareUnicodeCharacter{2018}{\quoteleft}
!   \DeclareUnicodeCharacter{2019}{\quoteright}
!   \DeclareUnicodeCharacter{201A}{\quotesinglbase}
!   \DeclareUnicodeCharacter{201C}{\quotedblleft}
!   \DeclareUnicodeCharacter{201D}{\quotedblright}
!   \DeclareUnicodeCharacter{201E}{\quotedblbase}
!   \DeclareUnicodeCharacter{2022}{\bullet}
!   \DeclareUnicodeCharacter{2026}{\dots}
!   \DeclareUnicodeCharacter{2039}{\guilsinglleft}
!   \DeclareUnicodeCharacter{203A}{\guilsinglright}
!   \DeclareUnicodeCharacter{20AC}{\euro}
! 
!   \DeclareUnicodeCharacter{2192}{\expansion}
!   \DeclareUnicodeCharacter{21D2}{\result}
! 
!   \DeclareUnicodeCharacter{2212}{\minus}
!   \DeclareUnicodeCharacter{2217}{\point}
!   \DeclareUnicodeCharacter{2261}{\equiv}
! }% end of \utfeightchardefs
  
  
  % US-ASCII character definitions.
  \def\asciichardefs{% nothing need be done
     \relax
  }
  
! % Make non-ASCII characters printable again for compatibility with
! % existing Texinfo documents that may use them, even without declaring a
! % document encoding.
! %
! \setnonasciicharscatcode \other
! 
  
  \message{formatting,}
  
--- 10300,11139 ----
    \catcode`\;=12
    \catcode`\!=12
    \catcode`\~=13
!   \gdef\DeclareUnicodeCharacterUTFviii#1#2{%
      \countUTFz = "#1\relax
      \begingroup
        \parseXMLCharref
  
+       % Give \u8:... its definition.  The sequence of seven \expandafter's
+       % expands after the \gdef three times, e.g.
+       %
+       % 1.  \UTFviiTwoOctetsName B1 B2
+       % 2.  \csname u8:B1 \string B2 \endcsname
+       % 3.  \u8: B1 B2  (a single control sequence token)
+       %
+       \expandafter\expandafter
+       \expandafter\expandafter
+       \expandafter\expandafter
+       \expandafter\gdef       \UTFviiiTmp{#2}%
+       %
+       \expandafter\ifx\csname uni:#1\endcsname \relax \else
+        \message{Internal error, already defined: #1}%
+       \fi
+       %
+       % define an additional control sequence for this code point.
+       \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp
+     \endgroup}
+   %
+   % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp
+   % to the corresponding UTF-8 sequence.
    \gdef\parseXMLCharref{%
      \ifnum\countUTFz < "A0\relax
        \errhelp = \EMsimple
        \errmessage{Cannot define Unicode char value < 00A0}%
      \else\ifnum\countUTFz < "800\relax
        \parseUTFviiiA,%
!       \parseUTFviiiB C\UTFviiiTwoOctetsName.,%
      \else\ifnum\countUTFz < "10000\relax
        \parseUTFviiiA;%
        \parseUTFviiiA,%
!       \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}%
      \else
        \parseUTFviiiA;%
        \parseUTFviiiA,%
        \parseUTFviiiA!%
!       \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}%
      \fi\fi\fi
    }
  
+   % Extract a byte from the end of the UTF-8 representation of \countUTFx.
+   % It must be a non-initial byte in the sequence.
+   % Change \uccode of #1 for it to be used in \parseUTFviiiB as one
+   % of the bytes.
    \gdef\parseUTFviiiA#1{%
      \countUTFx = \countUTFz
      \divide\countUTFz by 64
!     \countUTFy = \countUTFz  % Save to be the future value of \countUTFz.
      \multiply\countUTFz by 64
+ 
+     % \countUTFz is now \countUTFx with the last 5 bits cleared.  Subtract
+     % in order to get the last five bits.
      \advance\countUTFx by -\countUTFz
+ 
+     % Convert this to the byte in the UTF-8 sequence.
      \advance\countUTFx by 128
      \uccode `#1\countUTFx
      \countUTFz = \countUTFy}
  
+   % Used to put a UTF-8 byte sequence into \UTFviiiTmp
+   % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8
+   %    sequence.
+   % #2 is one of the \UTFviii*OctetsName macros.
+   % #3 is always a full stop (.)
+   % #4 is a template for the other bytes in the sequence.  The values for these
+   %    bytes is substituted in here with \uppercase using the \uccode's.
    \gdef\parseUTFviiiB#1#2#3#4{%
      \advance\countUTFz by "#10\relax
      \uccode `#3\countUTFz
      \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
  \endgroup
  
+ % For native Unicode handling (XeTeX and LuaTeX),
+ % provide a definition macro that sets a catcode to `other' non-globally
+ %
+ \def\DeclareUnicodeCharacterNativeOther#1#2{%
+   \catcode"#1=\other
+ }
+ 
+ % https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M
+ % U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)
+ % U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
+ % U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
+ % U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
+ %
+ % Many of our renditions are less than wonderful, and all the missing
+ % characters are available somewhere.  Loading the necessary fonts
+ % awaits user request.  We can't truly support Unicode without
+ % reimplementing everything that's been done in LaTeX for many years,
+ % plus probably using luatex or xetex, and who knows what else.
+ % We won't be doing that here in this simple file.  But we can try to at
+ % least make most of the characters not bomb out.
+ %
+ \def\unicodechardefs{%
+   \DeclareUnicodeCharacter{00A0}{\tie}%
+   \DeclareUnicodeCharacter{00A1}{\exclamdown}%
+   \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent
+   \DeclareUnicodeCharacter{00A3}{\pounds{}}%
+   \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency
+   \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen
+   \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar
+   \DeclareUnicodeCharacter{00A7}{\S}%
+   \DeclareUnicodeCharacter{00A8}{\"{ }}%
+   \DeclareUnicodeCharacter{00A9}{\copyright{}}%
+   \DeclareUnicodeCharacter{00AA}{\ordf}%
+   \DeclareUnicodeCharacter{00AB}{\guillemetleft{}}%
+   \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}%
+   \DeclareUnicodeCharacter{00AD}{\-}%
+   \DeclareUnicodeCharacter{00AE}{\registeredsymbol{}}%
+   \DeclareUnicodeCharacter{00AF}{\={ }}%
+   %
+   \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}%
+   \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}%
+   \DeclareUnicodeCharacter{00B2}{$^2$}%
+   \DeclareUnicodeCharacter{00B3}{$^3$}%
+   \DeclareUnicodeCharacter{00B4}{\'{ }}%
+   \DeclareUnicodeCharacter{00B5}{$\mu$}%
+   \DeclareUnicodeCharacter{00B6}{\P}%
+   \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}%
+   \DeclareUnicodeCharacter{00B8}{\cedilla{ }}%
+   \DeclareUnicodeCharacter{00B9}{$^1$}%
+   \DeclareUnicodeCharacter{00BA}{\ordm}%
+   \DeclareUnicodeCharacter{00BB}{\guillemetright{}}%
+   \DeclareUnicodeCharacter{00BC}{$1\over4$}%
+   \DeclareUnicodeCharacter{00BD}{$1\over2$}%
+   \DeclareUnicodeCharacter{00BE}{$3\over4$}%
+   \DeclareUnicodeCharacter{00BF}{\questiondown}%
+   %
+   \DeclareUnicodeCharacter{00C0}{\`A}%
+   \DeclareUnicodeCharacter{00C1}{\'A}%
+   \DeclareUnicodeCharacter{00C2}{\^A}%
+   \DeclareUnicodeCharacter{00C3}{\~A}%
+   \DeclareUnicodeCharacter{00C4}{\"A}%
+   \DeclareUnicodeCharacter{00C5}{\AA}%
+   \DeclareUnicodeCharacter{00C6}{\AE}%
+   \DeclareUnicodeCharacter{00C7}{\cedilla{C}}%
+   \DeclareUnicodeCharacter{00C8}{\`E}%
+   \DeclareUnicodeCharacter{00C9}{\'E}%
+   \DeclareUnicodeCharacter{00CA}{\^E}%
+   \DeclareUnicodeCharacter{00CB}{\"E}%
+   \DeclareUnicodeCharacter{00CC}{\`I}%
+   \DeclareUnicodeCharacter{00CD}{\'I}%
+   \DeclareUnicodeCharacter{00CE}{\^I}%
+   \DeclareUnicodeCharacter{00CF}{\"I}%
+   %
+   \DeclareUnicodeCharacter{00D0}{\DH}%
+   \DeclareUnicodeCharacter{00D1}{\~N}%
+   \DeclareUnicodeCharacter{00D2}{\`O}%
+   \DeclareUnicodeCharacter{00D3}{\'O}%
+   \DeclareUnicodeCharacter{00D4}{\^O}%
+   \DeclareUnicodeCharacter{00D5}{\~O}%
+   \DeclareUnicodeCharacter{00D6}{\"O}%
+   \DeclareUnicodeCharacter{00D7}{\ensuremath\times}%
+   \DeclareUnicodeCharacter{00D8}{\O}%
+   \DeclareUnicodeCharacter{00D9}{\`U}%
+   \DeclareUnicodeCharacter{00DA}{\'U}%
+   \DeclareUnicodeCharacter{00DB}{\^U}%
+   \DeclareUnicodeCharacter{00DC}{\"U}%
+   \DeclareUnicodeCharacter{00DD}{\'Y}%
+   \DeclareUnicodeCharacter{00DE}{\TH}%
+   \DeclareUnicodeCharacter{00DF}{\ss}%
+   %
+   \DeclareUnicodeCharacter{00E0}{\`a}%
+   \DeclareUnicodeCharacter{00E1}{\'a}%
+   \DeclareUnicodeCharacter{00E2}{\^a}%
+   \DeclareUnicodeCharacter{00E3}{\~a}%
+   \DeclareUnicodeCharacter{00E4}{\"a}%
+   \DeclareUnicodeCharacter{00E5}{\aa}%
+   \DeclareUnicodeCharacter{00E6}{\ae}%
+   \DeclareUnicodeCharacter{00E7}{\cedilla{c}}%
+   \DeclareUnicodeCharacter{00E8}{\`e}%
+   \DeclareUnicodeCharacter{00E9}{\'e}%
+   \DeclareUnicodeCharacter{00EA}{\^e}%
+   \DeclareUnicodeCharacter{00EB}{\"e}%
+   \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}%
+   \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}%
+   \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}%
+   \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}%
+   %
+   \DeclareUnicodeCharacter{00F0}{\dh}%
+   \DeclareUnicodeCharacter{00F1}{\~n}%
+   \DeclareUnicodeCharacter{00F2}{\`o}%
+   \DeclareUnicodeCharacter{00F3}{\'o}%
+   \DeclareUnicodeCharacter{00F4}{\^o}%
+   \DeclareUnicodeCharacter{00F5}{\~o}%
+   \DeclareUnicodeCharacter{00F6}{\"o}%
+   \DeclareUnicodeCharacter{00F7}{\ensuremath\div}%
+   \DeclareUnicodeCharacter{00F8}{\o}%
+   \DeclareUnicodeCharacter{00F9}{\`u}%
+   \DeclareUnicodeCharacter{00FA}{\'u}%
+   \DeclareUnicodeCharacter{00FB}{\^u}%
+   \DeclareUnicodeCharacter{00FC}{\"u}%
+   \DeclareUnicodeCharacter{00FD}{\'y}%
+   \DeclareUnicodeCharacter{00FE}{\th}%
+   \DeclareUnicodeCharacter{00FF}{\"y}%
+   %
+   \DeclareUnicodeCharacter{0100}{\=A}%
+   \DeclareUnicodeCharacter{0101}{\=a}%
+   \DeclareUnicodeCharacter{0102}{\u{A}}%
+   \DeclareUnicodeCharacter{0103}{\u{a}}%
+   \DeclareUnicodeCharacter{0104}{\ogonek{A}}%
+   \DeclareUnicodeCharacter{0105}{\ogonek{a}}%
+   \DeclareUnicodeCharacter{0106}{\'C}%
+   \DeclareUnicodeCharacter{0107}{\'c}%
+   \DeclareUnicodeCharacter{0108}{\^C}%
+   \DeclareUnicodeCharacter{0109}{\^c}%
+   \DeclareUnicodeCharacter{010A}{\dotaccent{C}}%
+   \DeclareUnicodeCharacter{010B}{\dotaccent{c}}%
+   \DeclareUnicodeCharacter{010C}{\v{C}}%
+   \DeclareUnicodeCharacter{010D}{\v{c}}%
+   \DeclareUnicodeCharacter{010E}{\v{D}}%
+   \DeclareUnicodeCharacter{010F}{d'}%
+   %
+   \DeclareUnicodeCharacter{0110}{\DH}%
+   \DeclareUnicodeCharacter{0111}{\dh}%
+   \DeclareUnicodeCharacter{0112}{\=E}%
+   \DeclareUnicodeCharacter{0113}{\=e}%
+   \DeclareUnicodeCharacter{0114}{\u{E}}%
+   \DeclareUnicodeCharacter{0115}{\u{e}}%
+   \DeclareUnicodeCharacter{0116}{\dotaccent{E}}%
+   \DeclareUnicodeCharacter{0117}{\dotaccent{e}}%
+   \DeclareUnicodeCharacter{0118}{\ogonek{E}}%
+   \DeclareUnicodeCharacter{0119}{\ogonek{e}}%
+   \DeclareUnicodeCharacter{011A}{\v{E}}%
+   \DeclareUnicodeCharacter{011B}{\v{e}}%
+   \DeclareUnicodeCharacter{011C}{\^G}%
+   \DeclareUnicodeCharacter{011D}{\^g}%
+   \DeclareUnicodeCharacter{011E}{\u{G}}%
+   \DeclareUnicodeCharacter{011F}{\u{g}}%
+   %
+   \DeclareUnicodeCharacter{0120}{\dotaccent{G}}%
+   \DeclareUnicodeCharacter{0121}{\dotaccent{g}}%
+   \DeclareUnicodeCharacter{0122}{\cedilla{G}}%
+   \DeclareUnicodeCharacter{0123}{\cedilla{g}}%
+   \DeclareUnicodeCharacter{0124}{\^H}%
+   \DeclareUnicodeCharacter{0125}{\^h}%
+   \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}%
+   \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}%
+   \DeclareUnicodeCharacter{0128}{\~I}%
+   \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}%
+   \DeclareUnicodeCharacter{012A}{\=I}%
+   \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}%
+   \DeclareUnicodeCharacter{012C}{\u{I}}%
+   \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}%
+   \DeclareUnicodeCharacter{012E}{\ogonek{I}}%
+   \DeclareUnicodeCharacter{012F}{\ogonek{i}}%
+   %
+   \DeclareUnicodeCharacter{0130}{\dotaccent{I}}%
+   \DeclareUnicodeCharacter{0131}{\dotless{i}}%
+   \DeclareUnicodeCharacter{0132}{IJ}%
+   \DeclareUnicodeCharacter{0133}{ij}%
+   \DeclareUnicodeCharacter{0134}{\^J}%
+   \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}%
+   \DeclareUnicodeCharacter{0136}{\cedilla{K}}%
+   \DeclareUnicodeCharacter{0137}{\cedilla{k}}%
+   \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}%
+   \DeclareUnicodeCharacter{0139}{\'L}%
+   \DeclareUnicodeCharacter{013A}{\'l}%
+   \DeclareUnicodeCharacter{013B}{\cedilla{L}}%
+   \DeclareUnicodeCharacter{013C}{\cedilla{l}}%
+   \DeclareUnicodeCharacter{013D}{L'}% should kern
+   \DeclareUnicodeCharacter{013E}{l'}% should kern
+   \DeclareUnicodeCharacter{013F}{L\U{00B7}}%
+   %
+   \DeclareUnicodeCharacter{0140}{l\U{00B7}}%
+   \DeclareUnicodeCharacter{0141}{\L}%
+   \DeclareUnicodeCharacter{0142}{\l}%
+   \DeclareUnicodeCharacter{0143}{\'N}%
+   \DeclareUnicodeCharacter{0144}{\'n}%
+   \DeclareUnicodeCharacter{0145}{\cedilla{N}}%
+   \DeclareUnicodeCharacter{0146}{\cedilla{n}}%
+   \DeclareUnicodeCharacter{0147}{\v{N}}%
+   \DeclareUnicodeCharacter{0148}{\v{n}}%
+   \DeclareUnicodeCharacter{0149}{'n}%
+   \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}%
+   \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}%
+   \DeclareUnicodeCharacter{014C}{\=O}%
+   \DeclareUnicodeCharacter{014D}{\=o}%
+   \DeclareUnicodeCharacter{014E}{\u{O}}%
+   \DeclareUnicodeCharacter{014F}{\u{o}}%
+   %
+   \DeclareUnicodeCharacter{0150}{\H{O}}%
+   \DeclareUnicodeCharacter{0151}{\H{o}}%
+   \DeclareUnicodeCharacter{0152}{\OE}%
+   \DeclareUnicodeCharacter{0153}{\oe}%
+   \DeclareUnicodeCharacter{0154}{\'R}%
+   \DeclareUnicodeCharacter{0155}{\'r}%
+   \DeclareUnicodeCharacter{0156}{\cedilla{R}}%
+   \DeclareUnicodeCharacter{0157}{\cedilla{r}}%
+   \DeclareUnicodeCharacter{0158}{\v{R}}%
+   \DeclareUnicodeCharacter{0159}{\v{r}}%
+   \DeclareUnicodeCharacter{015A}{\'S}%
+   \DeclareUnicodeCharacter{015B}{\'s}%
+   \DeclareUnicodeCharacter{015C}{\^S}%
+   \DeclareUnicodeCharacter{015D}{\^s}%
+   \DeclareUnicodeCharacter{015E}{\cedilla{S}}%
+   \DeclareUnicodeCharacter{015F}{\cedilla{s}}%
+   %
+   \DeclareUnicodeCharacter{0160}{\v{S}}%
+   \DeclareUnicodeCharacter{0161}{\v{s}}%
+   \DeclareUnicodeCharacter{0162}{\cedilla{T}}%
+   \DeclareUnicodeCharacter{0163}{\cedilla{t}}%
+   \DeclareUnicodeCharacter{0164}{\v{T}}%
+   \DeclareUnicodeCharacter{0165}{\v{t}}%
+   \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}%
+   \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}%
+   \DeclareUnicodeCharacter{0168}{\~U}%
+   \DeclareUnicodeCharacter{0169}{\~u}%
+   \DeclareUnicodeCharacter{016A}{\=U}%
+   \DeclareUnicodeCharacter{016B}{\=u}%
+   \DeclareUnicodeCharacter{016C}{\u{U}}%
+   \DeclareUnicodeCharacter{016D}{\u{u}}%
+   \DeclareUnicodeCharacter{016E}{\ringaccent{U}}%
+   \DeclareUnicodeCharacter{016F}{\ringaccent{u}}%
+   %
+   \DeclareUnicodeCharacter{0170}{\H{U}}%
+   \DeclareUnicodeCharacter{0171}{\H{u}}%
+   \DeclareUnicodeCharacter{0172}{\ogonek{U}}%
+   \DeclareUnicodeCharacter{0173}{\ogonek{u}}%
+   \DeclareUnicodeCharacter{0174}{\^W}%
+   \DeclareUnicodeCharacter{0175}{\^w}%
+   \DeclareUnicodeCharacter{0176}{\^Y}%
+   \DeclareUnicodeCharacter{0177}{\^y}%
+   \DeclareUnicodeCharacter{0178}{\"Y}%
+   \DeclareUnicodeCharacter{0179}{\'Z}%
+   \DeclareUnicodeCharacter{017A}{\'z}%
+   \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}%
+   \DeclareUnicodeCharacter{017C}{\dotaccent{z}}%
+   \DeclareUnicodeCharacter{017D}{\v{Z}}%
+   \DeclareUnicodeCharacter{017E}{\v{z}}%
+   \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}%
+   %
+   \DeclareUnicodeCharacter{01C4}{D\v{Z}}%
+   \DeclareUnicodeCharacter{01C5}{D\v{z}}%
+   \DeclareUnicodeCharacter{01C6}{d\v{z}}%
+   \DeclareUnicodeCharacter{01C7}{LJ}%
+   \DeclareUnicodeCharacter{01C8}{Lj}%
+   \DeclareUnicodeCharacter{01C9}{lj}%
+   \DeclareUnicodeCharacter{01CA}{NJ}%
+   \DeclareUnicodeCharacter{01CB}{Nj}%
+   \DeclareUnicodeCharacter{01CC}{nj}%
+   \DeclareUnicodeCharacter{01CD}{\v{A}}%
+   \DeclareUnicodeCharacter{01CE}{\v{a}}%
+   \DeclareUnicodeCharacter{01CF}{\v{I}}%
+   %
+   \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}%
+   \DeclareUnicodeCharacter{01D1}{\v{O}}%
+   \DeclareUnicodeCharacter{01D2}{\v{o}}%
+   \DeclareUnicodeCharacter{01D3}{\v{U}}%
+   \DeclareUnicodeCharacter{01D4}{\v{u}}%
+   %
+   \DeclareUnicodeCharacter{01E2}{\={\AE}}%
+   \DeclareUnicodeCharacter{01E3}{\={\ae}}%
+   \DeclareUnicodeCharacter{01E6}{\v{G}}%
+   \DeclareUnicodeCharacter{01E7}{\v{g}}%
+   \DeclareUnicodeCharacter{01E8}{\v{K}}%
+   \DeclareUnicodeCharacter{01E9}{\v{k}}%
+   %
+   \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}%
+   \DeclareUnicodeCharacter{01F1}{DZ}%
+   \DeclareUnicodeCharacter{01F2}{Dz}%
+   \DeclareUnicodeCharacter{01F3}{dz}%
+   \DeclareUnicodeCharacter{01F4}{\'G}%
+   \DeclareUnicodeCharacter{01F5}{\'g}%
+   \DeclareUnicodeCharacter{01F8}{\`N}%
+   \DeclareUnicodeCharacter{01F9}{\`n}%
+   \DeclareUnicodeCharacter{01FC}{\'{\AE}}%
+   \DeclareUnicodeCharacter{01FD}{\'{\ae}}%
+   \DeclareUnicodeCharacter{01FE}{\'{\O}}%
+   \DeclareUnicodeCharacter{01FF}{\'{\o}}%
+   %
+   \DeclareUnicodeCharacter{021E}{\v{H}}%
+   \DeclareUnicodeCharacter{021F}{\v{h}}%
+   %
+   \DeclareUnicodeCharacter{0226}{\dotaccent{A}}%
+   \DeclareUnicodeCharacter{0227}{\dotaccent{a}}%
+   \DeclareUnicodeCharacter{0228}{\cedilla{E}}%
+   \DeclareUnicodeCharacter{0229}{\cedilla{e}}%
+   \DeclareUnicodeCharacter{022E}{\dotaccent{O}}%
+   \DeclareUnicodeCharacter{022F}{\dotaccent{o}}%
+   %
+   \DeclareUnicodeCharacter{0232}{\=Y}%
+   \DeclareUnicodeCharacter{0233}{\=y}%
+   \DeclareUnicodeCharacter{0237}{\dotless{j}}%
+   %
+   \DeclareUnicodeCharacter{02BC}{'}%
+   %
+   \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}}%
+   \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}%
+   \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}%
+   \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}%
+   \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}%
+   \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}%
+   \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}%
+   \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}%
+   \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}%
+   \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}%
+   %
+   \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}%
+   \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}%
+   %
+   \DeclareUnicodeCharacter{1E20}{\=G}%
+   \DeclareUnicodeCharacter{1E21}{\=g}%
+   \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}%
+   \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}%
+   \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}%
+   \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}%
+   \DeclareUnicodeCharacter{1E26}{\"H}%
+   \DeclareUnicodeCharacter{1E27}{\"h}%
+   %
+   \DeclareUnicodeCharacter{1E30}{\'K}%
+   \DeclareUnicodeCharacter{1E31}{\'k}%
+   \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}%
+   \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}%
+   \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}%
+   \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}%
+   \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}%
+   \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}%
+   \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}%
+   \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}%
+   \DeclareUnicodeCharacter{1E3E}{\'M}%
+   \DeclareUnicodeCharacter{1E3F}{\'m}%
+   %
+   \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}%
+   \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}%
+   \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}%
+   \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}%
+   \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}%
+   \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}%
+   \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}%
+   \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}%
+   \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}%
+   \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}%
+   %
+   \DeclareUnicodeCharacter{1E54}{\'P}%
+   \DeclareUnicodeCharacter{1E55}{\'p}%
+   \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}%
+   \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}%
+   \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}%
+   \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}%
+   \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}%
+   \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}%
+   \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}%
+   \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}%
+   %
+   \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}%
+   \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}%
+   \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}%
+   \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}%
+   \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}%
+   \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}%
+   \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}%
+   \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}%
+   \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}%
+   \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}%
+   %
+   \DeclareUnicodeCharacter{1E7C}{\~V}%
+   \DeclareUnicodeCharacter{1E7D}{\~v}%
+   \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}%
+   \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}%
+   %
+   \DeclareUnicodeCharacter{1E80}{\`W}%
+   \DeclareUnicodeCharacter{1E81}{\`w}%
+   \DeclareUnicodeCharacter{1E82}{\'W}%
+   \DeclareUnicodeCharacter{1E83}{\'w}%
+   \DeclareUnicodeCharacter{1E84}{\"W}%
+   \DeclareUnicodeCharacter{1E85}{\"w}%
+   \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}%
+   \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}%
+   \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}%
+   \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}%
+   \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}%
+   \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}%
+   \DeclareUnicodeCharacter{1E8C}{\"X}%
+   \DeclareUnicodeCharacter{1E8D}{\"x}%
+   \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}%
+   \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}%
+   %
+   \DeclareUnicodeCharacter{1E90}{\^Z}%
+   \DeclareUnicodeCharacter{1E91}{\^z}%
+   \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}%
+   \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}%
+   \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}%
+   \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}%
+   \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}%
+   \DeclareUnicodeCharacter{1E97}{\"t}%
+   \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}%
+   \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}%
+   %
+   \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}%
+   \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}%
+   %
+   \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}%
+   \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}%
+   \DeclareUnicodeCharacter{1EBC}{\~E}%
+   \DeclareUnicodeCharacter{1EBD}{\~e}%
+   %
+   \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}%
+   \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}%
+   \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}%
+   \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}%
+   %
+   \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}%
+   \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}%
+   %
+   \DeclareUnicodeCharacter{1EF2}{\`Y}%
+   \DeclareUnicodeCharacter{1EF3}{\`y}%
+   \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}%
+   %
+   \DeclareUnicodeCharacter{1EF8}{\~Y}%
+   \DeclareUnicodeCharacter{1EF9}{\~y}%
+   %
+   % Punctuation
+   \DeclareUnicodeCharacter{2013}{--}%
+   \DeclareUnicodeCharacter{2014}{---}%
+   \DeclareUnicodeCharacter{2018}{\quoteleft{}}%
+   \DeclareUnicodeCharacter{2019}{\quoteright{}}%
+   \DeclareUnicodeCharacter{201A}{\quotesinglbase{}}%
+   \DeclareUnicodeCharacter{201C}{\quotedblleft{}}%
+   \DeclareUnicodeCharacter{201D}{\quotedblright{}}%
+   \DeclareUnicodeCharacter{201E}{\quotedblbase{}}%
+   \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}{\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{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{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{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{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{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{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{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 \unicodechardefs
+ 
+ % UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command)
+ % It makes the setting that replace UTF-8 byte sequence.
  \def\utfeightchardefs{%
!   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii
!   \unicodechardefs
! }
! 
! % Whether the active definitions of non-ASCII characters expand to
! % non-active tokens with the same character code.  This is used to
! % write characters literally, instead of using active definitions for
! % printing the correct glyphs.
! \newif\ifpassthroughchars
! \passthroughcharsfalse
! 
! % For native Unicode handling (XeTeX and LuaTeX),
! % provide a definition macro to replace/pass-through a Unicode character
! %
! \def\DeclareUnicodeCharacterNative#1#2{%
!   \catcode"#1=\active
!   \def\dodeclareunicodecharacternative##1##2##3{%
!     \begingroup
!       \uccode`\~="##2\relax
!       \uppercase{\gdef~}{%
!         \ifpassthroughchars
!           ##1%
!         \else
!           ##3%
!         \fi
!       }
!     \endgroup
!   }
!   \begingroup
!     \uccode`\.="#1\relax
!     \uppercase{\def\UTFNativeTmp{.}}%
!     \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}%
!   \endgroup
! }
  
+ % Native Unicode handling (XeTeX and LuaTeX) character replacing definition.
+ % It activates the setting that replaces Unicode characters.
+ \def\nativeunicodechardefs{%
+   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative
+   \unicodechardefs
+ }
+ 
+ % For native Unicode handling (XeTeX and LuaTeX),
+ % make the character token expand
+ % to the sequences given in \unicodechardefs for printing.
+ \def\DeclareUnicodeCharacterNativeAtU#1#2{%
+   \def\UTFAtUTmp{#2}
+   \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp
+ }
+ 
+ % @U command definitions for native Unicode handling (XeTeX and LuaTeX).
+ \def\nativeunicodechardefsatu{%
+   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU
+   \unicodechardefs
+ }
  
  % US-ASCII character definitions.
  \def\asciichardefs{% nothing need be done
     \relax
  }
  
! % Define all Unicode characters we know about.  This makes UTF-8 the default
! % input encoding and allows @U to work.
! \iftxinativeunicodecapable
!   \nativeunicodechardefsatu
! \else
!   \utfeightchardefs
! \fi
  
  \message{formatting,}
  
***************
*** 9054,9065 ****
    \advance\vsize by \topskip
    \outervsize = \vsize
    \advance\outervsize by 2\topandbottommargin
!   \pageheight = \vsize
    %
    \hsize = #2\relax
    \outerhsize = \hsize
    \advance\outerhsize by 0.5in
!   \pagewidth = \hsize
    %
    \normaloffset = #4\relax
    \bindingoffset = #5\relax
--- 11183,11194 ----
    \advance\vsize by \topskip
    \outervsize = \vsize
    \advance\outervsize by 2\topandbottommargin
!   \txipageheight = \vsize
    %
    \hsize = #2\relax
    \outerhsize = \hsize
    \advance\outerhsize by 0.5in
!   \txipagewidth = \hsize
    %
    \normaloffset = #4\relax
    \bindingoffset = #5\relax
***************
*** 9071,9076 ****
--- 11200,11213 ----
      % whatever layout pdftex was dumped with.
      \pdfhorigin = 1 true in
      \pdfvorigin = 1 true in
+   \else
+     \ifx\XeTeXrevision\thisisundefined
+       \special{papersize=#8,#7}%
+     \else
+       \pdfpageheight #7\relax
+       \pdfpagewidth #8\relax
+       % XeTeX does not have \pdfhorigin and \pdfvorigin.
+     \fi
    \fi
    %
    \setleading{\textleading}
***************
*** 9103,9109 ****
    %
    \lispnarrowing = 0.3in
    \tolerance = 700
-   \hfuzz = 1pt
    \contentsrightmargin = 0pt
    \defbodyindent = .5cm
  }}
--- 11240,11245 ----
***************
*** 9121,9127 ****
    %
    \lispnarrowing = 0.25in
    \tolerance = 700
-   \hfuzz = 1pt
    \contentsrightmargin = 0pt
    \defbodyindent = .4cm
  }}
--- 11257,11262 ----
***************
*** 9147,9153 ****
                      {297mm}{210mm}%
    %
    \tolerance = 700
-   \hfuzz = 1pt
    \contentsrightmargin = 0pt
    \defbodyindent = 5mm
  }}
--- 11282,11287 ----
***************
*** 9166,9172 ****
    %
    \lispnarrowing = 0.2in
    \tolerance = 800
-   \hfuzz = 1.2pt
    \contentsrightmargin = 0pt
    \defbodyindent = 2mm
    \tableindent = 12mm
--- 11300,11305 ----
***************
*** 9194,9199 ****
--- 11327,11344 ----
    \globaldefs = 0
  }}
  
+ \def\bsixpaper{{\globaldefs = 1
+   \afourpaper
+   \internalpagesizes{140mm}{100mm}%
+                     {-6.35mm}{-12.7mm}%
+                     {\bindingoffset}{14pt}%
+                     {176mm}{125mm}%
+   \let\SETdispenvsize=\smallword
+   \lispnarrowing = 0.2in
+   \globaldefs = 0
+ }}
+ 
+ 
  % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
  % Perhaps we should allow setting the margins, \topskip, \parskip,
  % and/or leading, also. Or perhaps we should compute them somehow.
***************
*** 9207,9216 ****
    \setleading{\textleading}%
    %
    \dimen0 = #1\relax
!   \advance\dimen0 by \voffset
    %
    \dimen2 = \hsize
!   \advance\dimen2 by \normaloffset
    %
    \internalpagesizes{#1}{\hsize}%
                      {\voffset}{\normaloffset}%
--- 11352,11363 ----
    \setleading{\textleading}%
    %
    \dimen0 = #1\relax
!   \advance\dimen0 by 2.5in % default 1in margin above heading line
!                            % and 1.5in to include heading, footing and
!                            % bottom margin
    %
    \dimen2 = \hsize
!   \advance\dimen2 by 2in % default to 1 inch margin on each side
    %
    \internalpagesizes{#1}{\hsize}%
                      {\voffset}{\normaloffset}%
***************
*** 9222,9252 ****
  %
  \letterpaper
  
  
  \message{and turning on texinfo input format.}
  
  % DEL is a comment character, in case @c does not suffice.
  \catcode`\^^? = 14
  
  % Define macros to output various characters with catcode for normal text.
! \catcode`\"=\other
! \catcode`\~=\other
! \catcode`\^=\other
! \catcode`\_=\other
! \catcode`\|=\other
! \catcode`\<=\other
! \catcode`\>=\other
! \catcode`\+=\other
! \catcode`\$=\other
! \def\normaldoublequote{"}
! \def\normaltilde{~}
! \def\normalcaret{^}
! \def\normalunderscore{_}
! \def\normalverticalbar{|}
! \def\normalless{<}
! \def\normalgreater{>}
! \def\normalplus{+}
! \def\normaldollar{$}%$ font-lock fix
  
  % This macro is used to make a character print one way in \tt
  % (where it can probably be output as-is), and another way in other fonts,
--- 11369,11395 ----
  %
  \letterpaper
  
+ % Default value of \hfuzz, for suppressing warnings about overfull hboxes.
+ \hfuzz = 1pt
+ 
  
  \message{and turning on texinfo input format.}
  
+ \def^^L{\par} % remove \outer, so ^L can appear in an @comment
+ 
  % DEL is a comment character, in case @c does not suffice.
  \catcode`\^^? = 14
  
  % Define macros to output various characters with catcode for normal text.
! \catcode`\"=\other \def\normaldoublequote{"}
! \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
! \catcode`\+=\other \def\normalplus{+}
! \catcode`\<=\other \def\normalless{<}
! \catcode`\>=\other \def\normalgreater{>}
! \catcode`\^=\other \def\normalcaret{^}
! \catcode`\_=\other \def\normalunderscore{_}
! \catcode`\|=\other \def\normalverticalbar{|}
! \catcode`\~=\other \def\normaltilde{~}
  
  % This macro is used to make a character print one way in \tt
  % (where it can probably be output as-is), and another way in other fonts,
***************
*** 9265,9308 ****
  % 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).
  % 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~{{\tt\char126}}
! \chardef\hat=`\^
! \catcode`\^=\active
! \def^{{\tt \hat}}
  
  \catcode`\_=\active
  \def_{\ifusingtt\normalunderscore\_}
- \let\realunder=_
- % Subroutine for the previous macro.
  \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
  
- \catcode`\|=\active
- \def|{{\tt\char124}}
  \chardef \less=`\<
! \catcode`\<=\active
! \def<{{\tt \less}}
  \chardef \gtr=`\>
! \catcode`\>=\active
! \def>{{\tt \gtr}}
! \catcode`\+=\active
! \def+{{\tt \char 43}}
! \catcode`\$=\active
! \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
! 
! % 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.
--- 11408,11454 ----
  % this is not a problem.
  \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
  
! % 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\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=_
+ 
+ \catcode`\|=\active \def|{{\tt\char124}}
  
  \chardef \less=`\<
! \catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless
  \chardef \gtr=`\>
! \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{%
!   \let< = \activeless
!   \let> = \activegtr
!   \let~ = \activetilde
!   \let^ = \activehat
!   \setregularquotes
!   \let\b = \strong
!   \let\i = \smartitalic
!   % in principle, all other definitions in \tex have to be undone too.
! }
  
  % Used sometimes to turn off (effectively) the active characters even after
  % parsing them.
***************
*** 9316,9389 ****
  % \backslashcurfont outputs one backslash character in current font,
  % as in \char`\\.
  \global\chardef\backslashcurfont=`\\
- \global\let\rawbackslashxx=\backslashcurfont  % let existing .??s files work
  
! % \realbackslash is an actual character `\' with catcode other, and
! % \doublebackslash is two of them (for the pdf outlines).
! {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
  
! % In texinfo, backslash is an active character; it prints the backslash
  % in fixed width font.
! \catcode`\\=\active
! @def@normalbackslash{{@tt@backslashcurfont}}
! % On startup, @fixbackslash assigns:
! %  @let \ = @normalbackslash
  
- % \rawbackslash defines an active \ to do \backslashcurfont.
  % \otherbackslash defines an active \ to be a literal `\' character with
  % catcode other.
- @gdef@rawbackslash{@let\=@backslashcurfont}
  @gdef@otherbackslash{@let\=@realbackslash}
  
  % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
  % the literal character `\'.
  %
! @def@normalturnoffactive{%
!   @let\=@normalbackslash
!   @let"=@normaldoublequote
!   @let~=@normaltilde
!   @let^=@normalcaret
!   @let_=@normalunderscore
!   @let|=@normalverticalbar
!   @let<=@normalless
!   @let>=@normalgreater
!   @let+=@normalplus
!   @let$=@normaldollar %$ font-lock fix
!   @markupsetuplqdefault
!   @markupsetuprqdefault
!   @unsepspaces
! }
! 
! % Make _ and + \other characters, temporarily.
! % This is canceled by @fixbackslash.
! @otherifyactive
  
  % 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.
! %
! @gdef@eatinput input texinfo{@fixbackslash}
! @global@let\ = @eatinput
  
- % 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.
- %
  @gdef@fixbackslash{%
!   @ifx\@eatinput @let\ = @normalbackslash @fi
    @catcode`+=@active
    @catcode`@_=@active
  }
  
  % Say @foo, not \foo, in error messages.
  @escapechar = `@@
  
  % These look ok in all fonts, so just make them not special.
! @catcode`@& = @other
! @catcode`@# = @other
! @catcode`@% = @other
  
  @c Finally, make ` and ' active, so that txicodequoteundirected and
  @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}.  If we
--- 11462,11594 ----
  % \backslashcurfont outputs one backslash character in current font,
  % as in \char`\\.
  \global\chardef\backslashcurfont=`\\
  
! % \realbackslash is an actual character `\' with catcode other.
! {\catcode`\\=\other @gdef@realbackslash{\}}
  
! % In Texinfo, backslash is an active character; it prints the backslash
  % in fixed width font.
! \catcode`\\=\active  % @ for escape char from now on.
! 
! % 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.
! 
! @def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
! @let@backslashchar = @ttbackslash % @backslashchar{} is for user documents.
  
  % \otherbackslash defines an active \ to be a literal `\' character with
  % catcode other.
  @gdef@otherbackslash{@let\=@realbackslash}
  
  % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
  % the literal character `\'.
  %
! {@catcode`- = @active
!  @gdef@normalturnoffactive{%
!    @passthroughcharstrue
!    @let-=@normaldash
!    @let"=@normaldoublequote
!    @let$=@normaldollar %$ font-lock fix
!    @let+=@normalplus
!    @let<=@normalless
!    @let>=@normalgreater
!    @let^=@normalcaret
!    @let_=@normalunderscore
!    @let|=@normalverticalbar
!    @let~=@normaltilde
!    @let\=@ttbackslash
!    @setregularquotes
!    @unsepspaces
!  }
! }
  
+ % 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.
+ @catcode`+=@other @catcode`@_=@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.
! % 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.
! {
! @catcode`@^=7
! @catcode`@^^M=13@gdef@enablebackslashhack{%
!   @global@let\ = @eatinput%
!   @catcode`@^^M=13%
!   @def@c{@fixbackslash@c}%
!   % Definition for the newline at the end of this file.
!   @def ^^M{@let^^M@secondlinenl}%
!   % Definition for a newline in the main Texinfo file.
!   @gdef @secondlinenl{@fixbackslash}%
!   % In case the first line has a whole-line command on it
!   @let@originalparsearg@parsearg
!   @def@parsearg{@fixbackslash@originalparsearg}
! }}
! 
! {@catcode`@^=7 @catcode`@^^M=13%
! @gdef@eatinput input texinfo#1^^M{@fixbackslash}}
! 
! % Emergency active definition of newline, in case an active newline token
! % appears by mistake.
! {@catcode`@^=7 @catcode13=13%
! @gdef@enableemergencynewline{%
!   @gdef^^M{%
!     @par%
!     %<warning: active newline>@par%
! }}}
! 
  
  @gdef@fixbackslash{%
!   @ifx\@eatinput @let\ = @ttbackslash @fi
!   @catcode13=5 % regular end of line
!   @enableemergencynewline
!   @let@c=@comment
!   @let@parsearg@originalparsearg
!   % Also turn back on active characters that might appear in the input
!   % file name, in case not using a pre-dumped format.
    @catcode`+=@active
    @catcode`@_=@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 = `@@
  
+ % These (along with & and #) are made active for url-breaking, so need
+ % active definitions as the normal characters.
+ @def@normaldot{.}
+ @def@normalquest{?}
+ @def@normalslash{/}
+ 
  % These look ok in all fonts, so just make them not special.
! % @hashchar{} gets its own user-level command, because of #line.
! @catcode`@& = @other @def@normalamp{&}
! @catcode`@# = @other @def@normalhash{#}
! @catcode`@% = @other @def@normalpercent{%}
! 
! @let @hashchar = @normalhash
  
  @c Finally, make ` and ' active, so that txicodequoteundirected and
  @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}.  If we
***************
*** 9391,9402 ****
  @c Do this last of all since we use ` in the previous @catcode assignments.
  @catcode`@'=@active
  @catcode`@`=@active
! @markupsetuplqdefault
! @markupsetuprqdefault
  
  @c Local variables:
! @c eval: (add-hook 'write-file-hooks 'time-stamp)
! @c page-delimiter: "^\\\\message"
  @c time-stamp-start: "def\\\\texinfoversion{"
  @c time-stamp-format: "%:y-%02m-%02d.%02H"
  @c time-stamp-end: "}"
--- 11596,11606 ----
  @c Do this last of all since we use ` in the previous @catcode assignments.
  @catcode`@'=@active
  @catcode`@`=@active
! @setregularquotes
  
  @c Local variables:
! @c eval: (add-hook 'before-save-hook 'time-stamp)
! @c page-delimiter: "^\\\\message\\|emacs-page"
  @c time-stamp-start: "def\\\\texinfoversion{"
  @c time-stamp-format: "%:y-%02m-%02d.%02H"
  @c time-stamp-end: "}"
***************
*** 9404,9409 ****
  
  @c vim:sw=2:
  
! @ignore
!    arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115
! @end ignore
--- 11608,11612 ----
  
  @c vim:sw=2:
  
! @enablebackslashhack
! 
Index: gtags-cscope/command.c
===================================================================
RCS file: /sources/global/global/gtags-cscope/command.c,v
retrieving revision 1.15
diff -c -r1.15 command.c
*** gtags-cscope/command.c	15 Mar 2018 00:44:29 -0000	1.15
--- gtags-cscope/command.c	4 May 2024 18:43:05 -0000
***************
*** 1,7 ****
  /*===========================================================================
!  Copyright (c) 1998-2000, The Santa Cruz Operation 
   All rights reserved.
!  
   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are met:
  
--- 1,7 ----
  /*===========================================================================
!  Copyright (c) 1998-2000, The Santa Cruz Operation
   All rights reserved.
! 
   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are met:
  
***************
*** 14,20 ****
  
   *Neither name of The Santa Cruz Operation nor the names of its contributors
   may be used to endorse or promote products derived from this software
!  without specific prior written permission. 
  
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
   IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
--- 14,20 ----
  
   *Neither name of The Santa Cruz Operation nor the names of its contributors
   may be used to endorse or promote products derived from this software
!  without specific prior written permission.
  
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
   IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
***************
*** 27,33 ****
   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
!  DAMAGE. 
   =========================================================================*/
  
  /*
--- 27,33 ----
   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
!  DAMAGE.
   =========================================================================*/
  
  /*
***************
*** 111,117 ****
  	rebuild();
  	postmsg("");
  	totallines = 0;
! 	disprefs = 0;	
  	topline = nextline = 1;
  	selecting = 0;
  	break;
--- 111,117 ----
  	rebuild();
  	postmsg("");
  	totallines = 0;
! 	disprefs = 0;
  	topline = nextline = 1;
  	selecting = 0;
  	break;
***************
*** 127,133 ****
  	if (p->button == '0') {
  	    scrollbar(p);
  	    break;
! 	} 
  	/* ignore a sweep */
  	if (p->x2 >= 0) {
  	    return(NO);
--- 127,133 ----
  	if (p->button == '0') {
  	    scrollbar(p);
  	    break;
! 	}
  	/* ignore a sweep */
  	if (p->x2 >= 0) {
  	    return(NO);
***************
*** 183,189 ****
      case ctrl('N'):
  #ifdef KEY_DOWN
      case KEY_DOWN:
! #endif		
  #ifdef KEY_RIGHT
      case KEY_RIGHT:
  #endif
--- 183,189 ----
      case ctrl('N'):
  #ifdef KEY_DOWN
      case KEY_DOWN:
! #endif
  #ifdef KEY_RIGHT
      case KEY_RIGHT:
  #endif
***************
*** 206,212 ****
  #ifdef KEY_UP
      case KEY_UP:
  #endif
! #ifdef KEY_LEFT		
      case KEY_LEFT:
  #endif
  	if (selecting) {
--- 206,212 ----
  #ifdef KEY_UP
      case KEY_UP:
  #endif
! #ifdef KEY_LEFT
      case KEY_LEFT:
  #endif
  	if (selecting) {
***************
*** 262,268 ****
  	if (totallines == 0) {
  	    return(NO);
  	}
! 	/* note: seekline() is not used to move to the next 
  	 * page because display() leaves the file pointer at
  	 * the next page to optimize paging forward
  	 */
--- 262,268 ----
  	if (totallines == 0) {
  	    return(NO);
  	}
! 	/* note: seekline() is not used to move to the next
  	 * page because display() leaves the file pointer at
  	 * the next page to optimize paging forward
  	 */
***************
*** 314,320 ****
  		c = '\0';
  		s = "a";
  	    }
! 	    if (c != '\r' && 
  		mygetline("", newpat,
  			  COLS - sizeof(appendprompt), c, NO) > 0
  		) {
--- 314,320 ----
  		c = '\0';
  		s = "a";
  	    }
! 	    if (c != '\r' &&
  		mygetline("", newpat,
  			  COLS - sizeof(appendprompt), c, NO) > 0
  		) {
***************
*** 459,465 ****
  	return(NO);
  
      case '!':	/* shell escape */
! 	execute(shell, shell, NULL);
  	seekline(topline);
  	break;
  
--- 459,465 ----
  	return(NO);
  
      case '!':	/* shell escape */
!         execute(shell, NULL, NULL);
  	seekline(topline);
  	break;
  
***************
*** 577,583 ****
  			return(changestring());
  		    }
  
! 		} else if (field == FILENAME && 
  			   access(newpat, READ) == 0) {
  		    /* try to edit the file anyway */
  		    edit(newpat, "1");
--- 577,583 ----
  			return(changestring());
  		    }
  
! 		} else if (field == FILENAME &&
  			   access(newpat, READ) == 0) {
  		    /* try to edit the file anyway */
  		    edit(newpat, "1");
***************
*** 667,676 ****
  	display();
      same:
  	atchange();
! 		
  	/* get a character from the terminal */
  	if ((c = mygetch()) == EOF
! 	    || c == ctrl('D') 
  	    || c == ctrl('Z')) {
  	    break;	/* change lines */
  	}
--- 667,676 ----
  	display();
      same:
  	atchange();
! 
  	/* get a character from the terminal */
  	if ((c = mygetch()) == EOF
! 	    || c == ctrl('D')
  	    || c == ctrl('Z')) {
  	    break;	/* change lines */
  	}
***************
*** 762,778 ****
      fprintf(script, "ed - <<\\!\n");
      *oldfile = '\0';
      seekline(1);
!     for (i = 0; 
  	 fscanf(refsfound, "%" PATHLEN_STR "s%*s%" NUMLEN_STR "s%*[^\n]", newfile, linenum) == 2;
  	 ++i) {
  	strcpy(newfile, decode_path(newfile));
  	/* see if the line is to be changed */
  	if (change[i] == YES) {
  	    anymarked = YES;
! 		
  	    /* if this is a new file */
  	    if (strcmp(newfile, oldfile) != 0) {
! 				
  		/* make sure it can be changed */
  		if (access(newfile, WRITE) != 0) {
  		    snprintf(msg, sizeof(msg), "Cannot write to file %s", newfile);
--- 762,778 ----
      fprintf(script, "ed - <<\\!\n");
      *oldfile = '\0';
      seekline(1);
!     for (i = 0;
  	 fscanf(refsfound, "%" PATHLEN_STR "s%*s%" NUMLEN_STR "s%*[^\n]", newfile, linenum) == 2;
  	 ++i) {
  	strcpy(newfile, decode_path(newfile));
  	/* see if the line is to be changed */
  	if (change[i] == YES) {
  	    anymarked = YES;
! 
  	    /* if this is a new file */
  	    if (strcmp(newfile, oldfile) != 0) {
! 
  		/* make sure it can be changed */
  		if (access(newfile, WRITE) != 0) {
  		    snprintf(msg, sizeof(msg), "Cannot write to file %s", newfile);
***************
*** 805,811 ****
  			putc(tolower((unsigned char)*s), script);
  		    }
  		    putc(']', script);
! 		} else	
  		    putc(*s, script);
  	    }
  	    putc('/', script);			/* to */
--- 805,811 ----
  			putc(tolower((unsigned char)*s), script);
  		    }
  		    putc(']', script);
! 		} else
  		    putc(*s, script);
  	    }
  	    putc('/', script);			/* to */
***************
*** 823,834 ****
  
      /* if any line was marked */
      if (anymarked == YES) {
! 		
  	/* edit the files */
  	clearprompt();
  	refresh();
  	fprintf(stderr, "Changed lines:\n\r");
! 	execute("sh", "sh", temp2, NULL);
  	askforreturn();
  	seekline(1);
      } else {
--- 823,834 ----
  
      /* if any line was marked */
      if (anymarked == YES) {
! 
  	/* edit the files */
  	clearprompt();
  	refresh();
  	fprintf(stderr, "Changed lines:\n\r");
! 	execute("sh", NULL, temp2, NULL);
  	askforreturn();
  	seekline(1);
      } else {
***************
*** 847,853 ****
  mark(unsigned int i)
  {
      unsigned int j;
! 	
      j = i + topline - 1;
      if (j < totallines) {
  	move(displine[i], 1);
--- 847,853 ----
  mark(unsigned int i)
  {
      unsigned int j;
! 
      j = i + topline - 1;
      if (j < totallines) {
  	move(displine[i], 1);
***************
*** 872,884 ****
  	return;
      }
      switch (p->percent) {
! 		
      case 101: /* scroll down one page */
  	if (nextline + mdisprefs > totallines) {
  	    nextline = totallines - mdisprefs + 1;
  	}
  	break;
! 		
      case 102: /* scroll up one page */
  	nextline = topline - mdisprefs;
  	if (nextline < 1) {
--- 872,884 ----
  	return;
      }
      switch (p->percent) {
! 
      case 101: /* scroll down one page */
  	if (nextline + mdisprefs > totallines) {
  	    nextline = totallines - mdisprefs + 1;
  	}
  	break;
! 
      case 102: /* scroll up one page */
  	nextline = topline - mdisprefs;
  	if (nextline < 1) {
***************
*** 889,895 ****
      case 103: /* scroll down one line */
  	nextline = topline + 1;
  	break;
! 		
      case 104: /* scroll up one line */
  	if (topline > 1) {
  	    nextline = topline - 1;
--- 889,895 ----
      case 103: /* scroll down one line */
  	nextline = topline + 1;
  	break;
! 
      case 104: /* scroll up one line */
  	if (topline > 1) {
  	    nextline = topline - 1;
***************
*** 954,960 ****
      rewind(refsfound);
  
      /* restrict the width of displayed columns */
!     /* HBB FIXME 20060419: magic number alert! */ 
      i = (COLS - 5) / 3;
      if (ogs == YES) {
  	i = (COLS - 7) / 5;
--- 954,960 ----
      rewind(refsfound);
  
      /* restrict the width of displayed columns */
!     /* HBB FIXME 20060419: magic number alert! */
      i = (COLS - 5) / 3;
      if (ogs == YES) {
  	i = (COLS - 7) / 5;
Index: gtags-cscope/edit.c
===================================================================
RCS file: /sources/global/global/gtags-cscope/edit.c,v
retrieving revision 1.10
diff -c -r1.10 edit.c
*** gtags-cscope/edit.c	8 Sep 2015 03:22:52 -0000	1.10
--- gtags-cscope/edit.c	4 May 2024 18:43:05 -0000
***************
*** 1,7 ****
  /*===========================================================================
!  Copyright (c) 1998-2000, The Santa Cruz Operation 
   All rights reserved.
!  
   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are met:
  
--- 1,7 ----
  /*===========================================================================
!  Copyright (c) 1998-2000, The Santa Cruz Operation
   All rights reserved.
! 
   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are met:
  
***************
*** 14,20 ****
  
   *Neither name of The Santa Cruz Operation nor the names of its contributors
   may be used to endorse or promote products derived from this software
!  without specific prior written permission. 
  
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
   IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
--- 14,20 ----
  
   *Neither name of The Santa Cruz Operation nor the names of its contributors
   may be used to endorse or promote products derived from this software
!  without specific prior written permission.
  
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
   IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
***************
*** 27,33 ****
   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
!  DAMAGE. 
   =========================================================================*/
  
  /*
--- 27,33 ----
   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
!  DAMAGE.
   =========================================================================*/
  
  /*
***************
*** 59,65 ****
  	}
  	/* get the selected line */
  	seekline(i + topline);
! 	
  	/* get the file name and line number */
  	if (fscanf(refsfound, "%" PATHLEN_STR "s%*s%" NUMLEN_STR "s", file, linenum) == 2) {
  		edit(decode_path(file), linenum);	/* edit it */
--- 59,65 ----
  	}
  	/* get the selected line */
  	seekline(i + topline);
! 
  	/* get the file name and line number */
  	if (fscanf(refsfound, "%" PATHLEN_STR "s%*s%" NUMLEN_STR "s", file, linenum) == 2) {
  		edit(decode_path(file), linenum);	/* edit it */
***************
*** 82,88 ****
  	}
  	/* get the first line */
  	seekline(1);
! 	
  	/* get each file name and line number */
  	while (fscanf(refsfound, "%" PATHLEN_STR "s%*s%" NUMLEN_STR "s%*[^\n]", file, linenum) == 2) {
  		edit(decode_path(file), linenum);	/* edit it */
--- 82,88 ----
  	}
  	/* get the first line */
  	seekline(1);
! 
  	/* get each file name and line number */
  	while (fscanf(refsfound, "%" PATHLEN_STR "s%*s%" NUMLEN_STR "s%*[^\n]", file, linenum) == 2) {
  		edit(decode_path(file), linenum);	/* edit it */
***************
*** 95,101 ****
  	}
  	seekline(topline);
  }
! 	
  /** call the editor */
  
  void
--- 95,101 ----
  	}
  	seekline(topline);
  }
! 
  /** call the editor */
  
  void
***************
*** 111,126 ****
  	(void) snprintf(plusnum, sizeof(plusnum), lineflag, linenum);
  	/* if this is the more or page commands */
  	if (strcmp(s = mybasename(editor), "more") == 0 || strcmp(s, "page") == 0) {
! 		
  		/* get it to pause after displaying a file smaller than the screen
  		   length */
! 		(void) execute(editor, editor, plusnum, file, NULL_DEVICE, NULL);
! 	}
! 	else if (lineflagafterfile) {
! 		(void) execute(editor, editor, file, plusnum, NULL);
! 	}
! 	else {
! 		(void) execute(editor, editor, plusnum, file, NULL);
  	}
  	clear();	/* redisplay screen */
  }
--- 111,133 ----
  	(void) snprintf(plusnum, sizeof(plusnum), lineflag, linenum);
  	/* if this is the more or page commands */
  	if (strcmp(s = mybasename(editor), "more") == 0 || strcmp(s, "page") == 0) {
! 
  		/* get it to pause after displaying a file smaller than the screen
  		   length */
!             if (editor_options)
! 		(void) execute(editor, editor_options, plusnum, file, NULL_DEVICE, NULL);
!             else
! 		(void) execute(editor, NULL, plusnum, file, NULL_DEVICE, NULL);
! 	} else if (lineflagafterfile) {
!             if (editor_options)
! 		(void) execute(editor, editor_options, file, plusnum, NULL);
!             else
! 		(void) execute(editor, NULL, file, plusnum, NULL);
! 	} else {
!             if (editor_options)
! 		(void) execute(editor, editor_options, plusnum, file, NULL);
!             else
! 		(void) execute(editor, NULL, plusnum, file, NULL);
  	}
  	clear();	/* redisplay screen */
  }
***************
*** 131,137 ****
  filepath(char *file)
  {
  	static	char	path[PATHLEN + 1];
! 	
  	if (prependpath != NULL && *file != '/') {
  		(void) snprintf(path, sizeof(path), "%s/%s", prependpath, file);
  		file = path;
--- 138,144 ----
  filepath(char *file)
  {
  	static	char	path[PATHLEN + 1];
! 
  	if (prependpath != NULL && *file != '/') {
  		(void) snprintf(path, sizeof(path), "%s/%s", prependpath, file);
  		file = path;
Index: gtags-cscope/exec.c
===================================================================
RCS file: /sources/global/global/gtags-cscope/exec.c,v
retrieving revision 1.6
diff -c -r1.6 exec.c
*** gtags-cscope/exec.c	8 Sep 2015 03:22:52 -0000	1.6
--- gtags-cscope/exec.c	4 May 2024 18:43:05 -0000
***************
*** 1,7 ****
  /*===========================================================================
!  Copyright (c) 1998-2000, The Santa Cruz Operation 
   All rights reserved.
!  
   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are met:
  
--- 1,7 ----
  /*===========================================================================
!  Copyright (c) 1998-2000, The Santa Cruz Operation
   All rights reserved.
! 
   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are met:
  
***************
*** 14,20 ****
  
   *Neither name of The Santa Cruz Operation nor the names of its contributors
   may be used to endorse or promote products derived from this software
!  without specific prior written permission. 
  
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
   IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
--- 14,20 ----
  
   *Neither name of The Santa Cruz Operation nor the names of its contributors
   may be used to endorse or promote products derived from this software
!  without specific prior written permission.
  
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
   IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
***************
*** 27,33 ****
   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
!  DAMAGE. 
   =========================================================================*/
  
  /*
--- 27,33 ----
   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
!  DAMAGE.
   =========================================================================*/
  
  /*
***************
*** 72,91 ****
  
  /*VARARGS1*/
  int
! execute(char *a, ...)	/* note: "exec" is already defined on u370 */
  {
  	va_list	ap;
  	int	exitcode = -1;	/* initialize, to avoid warning */
  	char	*argv[BUFSIZ];
! 	pid_t	p;
  
  	/* fork and exec the program or shell script */
  	endwin();	/* restore the terminal modes */
  	mousecleanup();
  	fflush(stdout);
! 	va_start(ap, a);
! 	for (p = 0; (argv[p] = va_arg(ap, char *)) != 0; p++)
! 		;
  #if !HAVE_FORK
  	/* HBB 20010313: in MSDOG, everything is completely different.
  	 * No fork()/exec()/wait(), but rather a single libc call: */
--- 72,99 ----
  
  /*VARARGS1*/
  int
! execute(char *a, char **opts, ...)	/* note: "exec" is already defined on u370 */
  {
  	va_list	ap;
  	int	exitcode = -1;	/* initialize, to avoid warning */
  	char	*argv[BUFSIZ];
! 	pid_t	p = 0;
  
  	/* fork and exec the program or shell script */
  	endwin();	/* restore the terminal modes */
  	mousecleanup();
  	fflush(stdout);
! 	va_start(ap, opts);
!         argv[0] = a; p++; /* the first argument should be the executable's name */
! 
!         if (opts) {
!             for (int i = 0; opts[i] != 0; i++) {
!                 argv[p] = opts[i]; p++;
!             }
!         }
! 
! 	for (; (argv[p] = va_arg(ap, char *)) != 0; p++)
!             ;
  #if !HAVE_FORK
  	/* HBB 20010313: in MSDOG, everything is completely different.
  	 * No fork()/exec()/wait(), but rather a single libc call: */
***************
*** 98,107 ****
  		exitcode = join(p);	/* parent */
  	}
  #endif /* MSDOS */
! 	
  	/* the menu and scrollbar may be changed by the command executed */
  #if UNIXPC || !TERMINFO
! # ifndef __DJGPP__ /* leave CRLF handling as is */      
  	nonl();
  # endif
  	raw();	/* endwin() turns off cbreak mode so restore it */
--- 106,115 ----
  		exitcode = join(p);	/* parent */
  	}
  #endif /* MSDOS */
! 
  	/* the menu and scrollbar may be changed by the command executed */
  #if UNIXPC || !TERMINFO
! # ifndef __DJGPP__ /* leave CRLF handling as is */
  	nonl();
  # endif
  	raw();	/* endwin() turns off cbreak mode so restore it */
***************
*** 122,128 ****
  myexecvp(char *a, char **args)
  {
      char    msg[MSGLEN + 1];
! 	
      /* modify argv[0] to reference the last component of its path name */
      args[0] = mybasename(args[0]);
  
--- 130,136 ----
  myexecvp(char *a, char **args)
  {
      char    msg[MSGLEN + 1];
! 
      /* modify argv[0] to reference the last component of its path name */
      args[0] = mybasename(args[0]);
  
***************
*** 144,157 ****
  	pid_t	p;		/* process number */
  
  	p = fork();
! 	
  	/* the parent ignores the interrupt, quit, and hangup signals */
  	if (p > 0) {
  		oldsigquit = signal(SIGQUIT, SIG_IGN);
  		oldsighup = signal(SIGHUP, SIG_IGN);
! #ifdef SIGTSTP		
  		oldsigtstp = signal(SIGTSTP, SIG_DFL);
! #endif		
  	}
  	/* so they can be used to stop the child */
  	else if (p == 0) {
--- 152,165 ----
  	pid_t	p;		/* process number */
  
  	p = fork();
! 
  	/* the parent ignores the interrupt, quit, and hangup signals */
  	if (p > 0) {
  		oldsigquit = signal(SIGQUIT, SIG_IGN);
  		oldsighup = signal(SIGHUP, SIG_IGN);
! #ifdef SIGTSTP
  		oldsigtstp = signal(SIGTSTP, SIG_DFL);
! #endif
  	}
  	/* so they can be used to stop the child */
  	else if (p == 0) {
***************
*** 160,166 ****
  		signal(SIGHUP, SIG_DFL);
  #ifdef SIGTSTP
  		signal(SIGTSTP, SIG_DFL);
! #endif			
  	}
  	/* check for fork failure */
  	if (p == -1) {
--- 168,174 ----
  		signal(SIGHUP, SIG_DFL);
  #ifdef SIGTSTP
  		signal(SIGTSTP, SIG_DFL);
! #endif
  	}
  	/* check for fork failure */
  	if (p == -1) {
***************
*** 172,180 ****
  /** join is the compliment of fork */
  
  static int
! join(pid_t p) 
  {
! 	int	status;  
  	pid_t	w;
  
  	/* wait for the correct child to exit */
--- 180,188 ----
  /** join is the compliment of fork */
  
  static int
! join(pid_t p)
  {
! 	int	status;
  	pid_t	w;
  
  	/* wait for the correct child to exit */
***************
*** 187,193 ****
  	signal(SIGHUP, oldsighup);
  #ifdef SIGTSTP
  	signal(SIGTSTP, oldsigtstp);
! #endif	
  
  	/* return the child's exit code */
  	return(status >> 8);
--- 195,201 ----
  	signal(SIGHUP, oldsighup);
  #ifdef SIGTSTP
  	signal(SIGTSTP, oldsigtstp);
! #endif
  
  	/* return the child's exit code */
  	return(status >> 8);
Index: gtags-cscope/global-cscope.h
===================================================================
RCS file: /sources/global/global/gtags-cscope/global-cscope.h,v
retrieving revision 1.9
diff -c -r1.9 global-cscope.h
*** gtags-cscope/global-cscope.h	15 May 2019 18:36:51 -0000	1.9
--- gtags-cscope/global-cscope.h	4 May 2024 18:43:05 -0000
***************
*** 1,7 ****
  /*===========================================================================
!  Copyright (c) 1998-2000, The Santa Cruz Operation 
   All rights reserved.
!  
   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are met:
  
--- 1,7 ----
  /*===========================================================================
!  Copyright (c) 1998-2000, The Santa Cruz Operation
   All rights reserved.
! 
   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are met:
  
***************
*** 14,20 ****
  
   *Neither name of The Santa Cruz Operation nor the names of its contributors
   may be used to endorse or promote products derived from this software
!  without specific prior written permission. 
  
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
   IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
--- 14,20 ----
  
   *Neither name of The Santa Cruz Operation nor the names of its contributors
   may be used to endorse or promote products derived from this software
!  without specific prior written permission.
  
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
   IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
***************
*** 27,33 ****
   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
!  DAMAGE. 
   =========================================================================*/
  
  /* $Id: global-cscope.h,v 1.9 2019/05/15 18:36:51 h-iwamoto Exp $ */
--- 27,33 ----
   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
!  DAMAGE.
   =========================================================================*/
  
  /* $Id: global-cscope.h,v 1.9 2019/05/15 18:36:51 h-iwamoto Exp $ */
***************
*** 72,78 ****
  # ifndef HAVE_MEMSET
  #  ifndef HAVE_MEMORY_H
  char	*memset();
! #  else 
  #   include <memory.h>	/* memset */
  #  endif /*V9*/
  # endif /* HAVE_MEMSET */
--- 72,78 ----
  # ifndef HAVE_MEMSET
  #  ifndef HAVE_MEMORY_H
  char	*memset();
! #  else
  #   include <memory.h>	/* memset */
  #  endif /*V9*/
  # endif /* HAVE_MEMSET */
***************
*** 98,106 ****
  #if BSD
  # undef	tolower		/* BSD toupper and tolower don't test the character */
  # undef	toupper
! # define	tolower(c)	(isupper(c) ? (c) - 'A' + 'a' : (c))	
  # define	toupper(c)	(islower(c) ? (c) - 'a' + 'A' : (c))
! # if !sun 
  #  if !__FreeBSD__
  /* in traditional BSD, *printf() doesn't return the number of bytes
   * written */
--- 98,106 ----
  #if BSD
  # undef	tolower		/* BSD toupper and tolower don't test the character */
  # undef	toupper
! # define	tolower(c)	(isupper(c) ? (c) - 'A' + 'a' : (c))
  # define	toupper(c)	(islower(c) ? (c) - 'a' + 'A' : (c))
! # if !sun
  #  if !__FreeBSD__
  /* in traditional BSD, *printf() doesn't return the number of bytes
   * written */
***************
*** 115,121 ****
  /* #define SHORT_NAMES_ONLY */
  
  /* Just in case autoconf didn't correctly flag HAVE_FIXKEYPAD */
! #ifndef HAVE_FIXKEYPAD 
  # if SVR2 && !BSD && !V9 && !u3b2 && !sun
  #  define HAVE_FIXKEYPAD
  # endif
--- 115,121 ----
  /* #define SHORT_NAMES_ONLY */
  
  /* Just in case autoconf didn't correctly flag HAVE_FIXKEYPAD */
! #ifndef HAVE_FIXKEYPAD
  # if SVR2 && !BSD && !V9 && !u3b2 && !sun
  #  define HAVE_FIXKEYPAD
  # endif
***************
*** 143,149 ****
  # else
  #  define O_BINARY 0x00
  # endif
! #endif 
  
  #undef SETMODE
  #if O_BINARY || O_TEXT
--- 143,149 ----
  # else
  #  define O_BINARY 0x00
  # endif
! #endif
  
  #undef SETMODE
  #if O_BINARY || O_TEXT
***************
*** 151,157 ****
   * to actually do something */
  # ifdef HAVE_SETMODE
  #  define SETMODE(fildes, mode) setmode(fildes,mode)
! # else 
  #  ifdef HAVE__SETMODE
  #   define SETMODE(fildes, mode) _setmode(fildes,mode)
  #  endif
--- 151,157 ----
   * to actually do something */
  # ifdef HAVE_SETMODE
  #  define SETMODE(fildes, mode) setmode(fildes,mode)
! # else
  #  ifdef HAVE__SETMODE
  #   define SETMODE(fildes, mode) _setmode(fildes,mode)
  #  endif
***************
*** 163,169 ****
  #ifdef R_OK
  # define	READ	R_OK
  #else
! # define	READ	4	
  #endif
  #ifdef W_OK
  # define	WRITE	W_OK
--- 163,169 ----
  #ifdef R_OK
  # define	READ	R_OK
  #else
! # define	READ	4
  #endif
  #ifdef W_OK
  # define	WRITE	W_OK
***************
*** 216,222 ****
  };
  
  /* main.c global data */
! extern	char	*editor, *home, *shell, *lineflag;	/**< environment variables */
  extern	char	*global_command;			/**< "global" by default */
  extern	char	*gtags_command;				/**< "gtags" by default */
  extern	char	*home;		/**< Home directory */
--- 216,224 ----
  };
  
  /* main.c global data */
! extern	char	*editor, *home, *shell, *lineflag; /**< environment variables */
! extern	char	**editor_options; /** The editor options if any */
! extern  int     options_number;
  extern	char	*global_command;			/**< "global" by default */
  extern	char	*gtags_command;				/**< "gtags" by default */
  extern	char	*home;		/**< Home directory */
***************
*** 274,280 ****
  extern	BOOL	unixpcmouse;		/**< UNIX PC mouse interface */
  #endif
  
! /* cscope functions called from more than one function or between files */ 
  
  char	*filepath(char *file);
  char	*findcalledby(char *pattern);
--- 276,282 ----
  extern	BOOL	unixpcmouse;		/**< UNIX PC mouse interface */
  #endif
  
! /* cscope functions called from more than one function or between files */
  
  char	*filepath(char *file);
  char	*findcalledby(char *pattern);
***************
*** 358,363 ****
  int	egrep(char *file, FILE *output, char *format);
  int	mygetline(char p[], char s[], unsigned size, int firstchar, BOOL iscaseless);
  int	mygetch(void);
! int	execute(char *a, ...);
  
  #endif /* CSCOPE_GLOBAL_H */
--- 360,365 ----
  int	egrep(char *file, FILE *output, char *format);
  int	mygetline(char p[], char s[], unsigned size, int firstchar, BOOL iscaseless);
  int	mygetch(void);
! int	execute(char *a, char **opts, ...);
  
  #endif /* CSCOPE_GLOBAL_H */
Index: gtags-cscope/gtags-cscope.c
===================================================================
RCS file: /sources/global/global/gtags-cscope/gtags-cscope.c,v
retrieving revision 1.34
diff -c -r1.34 gtags-cscope.c
*** gtags-cscope/gtags-cscope.c	12 Jan 2018 00:18:02 -0000	1.34
--- gtags-cscope/gtags-cscope.c	4 May 2024 18:43:05 -0000
***************
*** 1,7 ****
  /*===========================================================================
!  Copyright (c) 1998-2000, The Santa Cruz Operation 
   All rights reserved.
!  
   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are met:
  
--- 1,7 ----
  /*===========================================================================
!  Copyright (c) 1998-2000, The Santa Cruz Operation
   All rights reserved.
! 
   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are met:
  
***************
*** 14,20 ****
  
   *Neither name of The Santa Cruz Operation nor the names of its contributors
   may be used to endorse or promote products derived from this software
!  without specific prior written permission. 
  
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
   IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
--- 14,20 ----
  
   *Neither name of The Santa Cruz Operation nor the names of its contributors
   may be used to endorse or promote products derived from this software
!  without specific prior written permission.
  
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
   IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
***************
*** 27,33 ****
   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
!  DAMAGE. 
   =========================================================================*/
  
  
--- 27,33 ----
   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
!  DAMAGE.
   =========================================================================*/
  
  
***************
*** 42,47 ****
--- 42,48 ----
  #include "strbuf.h"
  #include "build.h"
  #include "version-cscope.h"	/* FILEVERSION and FIXVERSION */
+ #include "alloc.h"
  
  /* for libutil */
  #include "env.h"
***************
*** 88,93 ****
--- 89,96 ----
  #define TMPDIR	"/tmp"
  
  char	*editor, *shell, *lineflag;	/**< environment variables */
+ char    **editor_options = 0;              /** Editor flags if any **/
+ int     options_number = 0;              /** the number of options allocated **/
  char	*global_command;	/**< "global" by default */
  char	*gtags_command;		/**< "gtags" by default */
  char	*home;			/**< Home directory */
***************
*** 110,116 ****
  char	temp1[PATHLEN + 1];	/**< temporary file name */
  char	temp2[PATHLEN + 1];	/**< temporary file name */
  char	tempdirpv[PATHLEN + 1];	/**< private temp directory */
! char	tempstring[TEMPSTRING_LEN + 1]; /**< use this as a buffer, instead of yytext, 
  				 * which had better be left alone */
  char	*tmpdir;		/**< temporary directory */
  
--- 113,119 ----
  char	temp1[PATHLEN + 1];	/**< temporary file name */
  char	temp2[PATHLEN + 1];	/**< temporary file name */
  char	tempdirpv[PATHLEN + 1];	/**< private temp directory */
! char	tempstring[TEMPSTRING_LEN + 1]; /**< use this as a buffer, instead of yytext,
  				 * which had better be left alone */
  char	*tmpdir;		/**< temporary directory */
  
***************
*** 122,133 ****
  static	void	usage(void);
  int	qflag;
  
  #ifdef HAVE_FIXKEYPAD
  void	fixkeypad();
  #endif
- 
  #if defined(KEY_RESIZE) && defined(SIGWINCH)
! void 
  sigwinch_handler(int sig, siginfo_t *info, void *unused)
  {
      (void) sig;
--- 125,138 ----
  static	void	usage(void);
  int	qflag;
  
+ static void get_editor_options(void);
+ static void options_string_to_vector(char * options);
+ 
  #ifdef HAVE_FIXKEYPAD
  void	fixkeypad();
  #endif
  #if defined(KEY_RESIZE) && defined(SIGWINCH)
! void
  sigwinch_handler(int sig, siginfo_t *info, void *unused)
  {
      (void) sig;
***************
*** 149,155 ****
  #if defined(KEY_RESIZE) && defined(SIGWINCH)
      struct sigaction winch_action;
  #endif
! 	
      /* save the command name for messages */
      argv0 = argv[0];
  
--- 154,160 ----
  #if defined(KEY_RESIZE) && defined(SIGWINCH)
      struct sigaction winch_action;
  #endif
! 
      /* save the command name for messages */
      argv0 = argv[0];
  
***************
*** 173,179 ****
  	}
  
  	for (s = argv[0] + 1; *s != '\0'; s++) {
! 			
  	    /* look for an input field number */
  	    if (isdigit((unsigned char) *s)) {
  		field = *s - '0';
--- 178,184 ----
  	}
  
  	for (s = argv[0] + 1; *s != '\0'; s++) {
! 
  	    /* look for an input field number */
  	    if (isdigit((unsigned char) *s)) {
  		field = *s - '0';
***************
*** 261,267 ****
  		    s = *++argv;
  		}
  		if (*s == '\0') {
! 		    fprintf(stderr, "%s: -%c option: missing or empty value\n", 
  			    argv0, c);
  		    goto usage;
  		}
--- 266,272 ----
  		    s = *++argv;
  		}
  		if (*s == '\0') {
! 		    fprintf(stderr, "%s: -%c option: missing or empty value\n",
  			    argv0, c);
  		    goto usage;
  		}
***************
*** 281,287 ****
  		case 'p':	/* file path components to display */
  		    if (*s < '0' || *s > '9' ) {
  			fprintf(stderr, "\
! %s: -p option: missing or invalid numeric value\n", 
  				argv0);
  			goto usage;
  		    }
--- 286,292 ----
  		case 'p':	/* file path components to display */
  		    if (*s < '0' || *s > '9' ) {
  			fprintf(stderr, "\
! %s: -p option: missing or invalid numeric value\n",
  				argv0);
  			goto usage;
  		    }
***************
*** 297,303 ****
  		}
  		goto nextarg;
  	    default:
! 		fprintf(stderr, "%s: unknown option: -%c\n", argv0, 
  			*s);
  	    usage:
  		usage();
--- 302,308 ----
  		}
  		goto nextarg;
  	    default:
! 		fprintf(stderr, "%s: unknown option: -%c\n", argv0,
  			*s);
  	    usage:
  		usage();
***************
*** 305,311 ****
  		myexit(1);
  	    } /* switch(option letter) */
  	} /* for(option) */
!     nextarg:	
  	;
      } /* while(argv) */
  
--- 310,316 ----
  		myexit(1);
  	    } /* switch(option letter) */
  	} /* for(option) */
!     nextarg:
  	;
      } /* while(argv) */
  
***************
*** 314,319 ****
--- 319,325 ----
      editor = mygetenv("EDITOR", EDITOR);
      editor = mygetenv("VIEWER", editor); /* use viewer if set */
      editor = mygetenv("CSCOPE_EDITOR", editor);	/* has last word */
+     get_editor_options(); /* Remove options from editor if any */
      home = mygetenv("HOME", HOME);
      global_command = mygetenv("GTAGSGLOBAL", "global");
      gtags_command = mygetenv("GTAGSGTAGS", "gtags");
***************
*** 332,338 ****
      /* make sure that tmpdir exists */
      if (lstat (tmpdir, &stat_buf)) {
  	fprintf (stderr, "\
! cscope: Temporary directory %s does not exist or cannot be accessed\n", 
  		 tmpdir);
  	fprintf (stderr, "\
  cscope: Please create the directory or set the environment variable\n\
--- 338,344 ----
      /* make sure that tmpdir exists */
      if (lstat (tmpdir, &stat_buf)) {
  	fprintf (stderr, "\
! cscope: Temporary directory %s does not exist or cannot be accessed\n",
  		 tmpdir);
  	fprintf (stderr, "\
  cscope: Please create the directory or set the environment variable\n\
***************
*** 413,419 ****
  	strbuf_close(sb);
      } else {
  	if (linemode == NO || verbosemode == YES)    /* display if verbose as well */
! 	    postmsg("Building cross-reference...");                 
  	rebuild();
  	if (linemode == NO )
              clearmsg(); /* clear any build progress message */
--- 419,425 ----
  	strbuf_close(sb);
      } else {
  	if (linemode == NO || verbosemode == YES)    /* display if verbose as well */
! 	    postmsg("Building cross-reference...");
  	rebuild();
  	if (linemode == NO )
              clearmsg(); /* clear any build progress message */
***************
*** 424,430 ****
  
      /* opendatabase(); */
  
!     /* if using the line oriented user interface so cscope can be a 
         subprocess to emacs or samuel */
      if (linemode == YES) {
  	if (*Pattern != '\0') {		/* do any optional search */
--- 430,436 ----
  
      /* opendatabase(); */
  
!     /* if using the line oriented user interface so cscope can be a
         subprocess to emacs or samuel */
      if (linemode == YES) {
  	if (*Pattern != '\0') {		/* do any optional search */
***************
*** 441,450 ****
  	}
  	if (onesearch == YES)
  	    myexit(0);
! 		
  	for (;;) {
  	    char buf[PATLEN + 2];
! 			
  	    printf(">> ");
  	    fflush(stdout);
  	    if (fgets(buf, sizeof(buf), stdin) == NULL) {
--- 447,456 ----
  	}
  	if (onesearch == YES)
  	    myexit(0);
! 
  	for (;;) {
  	    char buf[PATLEN + 2];
! 
  	    printf(">> ");
  	    fflush(stdout);
  	    if (fgets(buf, sizeof(buf), stdin) == NULL) {
***************
*** 624,630 ****
  	 * about that, but DOS absolutely needs it */
  	if (refsfound != NULL)
  		fclose(refsfound);
! 	
  	/* remove any temporary files */
  	if (temp1[0] != '\0') {
  		unlink(temp1);
--- 630,636 ----
  	 * about that, but DOS absolutely needs it */
  	if (refsfound != NULL)
  		fclose(refsfound);
! 
  	/* remove any temporary files */
  	if (temp1[0] != '\0') {
  		unlink(temp1);
***************
*** 644,646 ****
--- 650,722 ----
  	/* HBB 20000421: be nice: free allocated data */
  	exit(sig);
  }
+ 
+ /* Modifies editor and editor_flags when $EDITOR has options
+    (whitespace separated elements), if there are no options it will not modify
+    any variable and editor_options will be null */
+ static void
+ get_editor_options(void)
+ {
+     int count = 0;
+     char *opts = editor, *_editor;
+ 
+     /* Now opts will point to where the args/opts begin */
+     for (int i = 0; *opts != '\0'; opts++, i++)
+         if (*opts == ' ') { count = i; break; }
+ 
+     /* there were no space separated elements */
+     if (count == 0)
+         return;
+ 
+     /* Move opt to the exact arg position*/
+     for (; *opts != '\0'; opts++)
+         if (*opts != ' ')
+             break;
+ 
+     /* There were spaces, but just that, nothing meaningful */
+     if (*opts == '\0') return;
+ 
+     /* Would it be better to use NAME_MAX or PATH_MAX, or any other portable
+        macro? */
+     _editor = malloc(256);
+     memcpy(_editor, editor, count);
+     _editor[count] = '\0';
+     editor = _editor;
+     options_string_to_vector(opts);
+ }
+ 
+ static void
+ options_string_to_vector(char *opts)
+ {
+   options_number = 8;
+   editor_options = mymalloc(options_number * sizeof(editor_options[0]));
+   int count, pos;
+ 
+   for (pos = 0; ; pos++) {
+     for (; *opts == ' '; opts++) ;
+ 
+     if (*opts == '\0')
+       return;
+ 
+     if (pos > (options_number - 1)) {
+       options_number += 8;
+       editor_options = myrealloc(editor_options, options_number * sizeof(editor_options[0]));
+     }
+ 
+     for (count = 0; ; count++)
+       if (opts[count] == ' ' || opts[count] == '\0')
+         break;
+ 
+     editor_options[pos] = mymalloc(256);
+     memcpy(editor_options[pos], opts, count);
+ 
+     /* just in case any options or argument (or both, like in opt=arg) is bigger
+      that the expected. I have seen some long options used in QEMU */
+     if (count > 255)
+       editor_options[pos][255] = '\0';
+     else
+       editor_options[pos][count] = '\0';
+ 
+     opts += count;
+   }
+ }
