Hallo all,
I tried to print the GNU smalltalk manual. Though most of the problems
were caused by the gst.txi source, some of them were caused by bugs in the
texinfo.tex file. While reading the file, I found lot of..., well, not
exactly bugs, but things which could have been written in a better style.
The patch is attached to this mail. It's against the newest version
of texinfo.tex found on ftp.gnu.org.
I'd be pleased if you send me back the parts you haven't accepted.
I can think about it again and perhaps send you a more detailed explanation.
Here are my comments to the patch:
1) @set allows - and _ in variable names but @clear, @if{set,clear}
are not prepared to accept such variables. Instead of fixing every
case separately, I propose a rather revolutional approach: make these
characters \other in \parsearg .
Do you know about a thing which might be broken by this?
2) Macro \removeactivespaces doesn't take care of normal spaces, so eg.:
@end tex @c ...
won't work (expands to \csname tex \endcsname). On the other hand, it
also errorneously removes non-trailing active spaces.
I also don't like that \argremovec{,omment} uses \toks since I'm
afraid it slows the processing (and \parsearg is in the heart of whole
texinfo.tex so it should be profiled a bit--even today, when computers
are so fast).
3) We have \other so we should use it. It's both nicer and more effective.
4) The defnition of centerline was broken. I also prefer to have \hfil
instead of \hss in \centerline, what do you think?
5) \readauxfile changed to \tryauxfile and aux file is openes. I think
this way is clearer.
6) two typos
7) @kbdinputstyle should warn you if it doesn't understand it's parameter,
shouldn't it? maybe this should even be an \errormessage!
And there is no problem with calling "\kbdinputstyle distinct" once the macro
@kbdinputstyle was defined.
8) In macro \setuptable: you thought there was a space after the \unskip,
don't you?
9) I have rewritten \doignore to do also nesting, so \nestedignore is not
needed anymore. (The \vbox trick in \nestedignore prevented me from
compiling GNU smalltalk manual, which contains very large @ifset block.)
Also \ignoremorecommands and \ifwarnedobs were removed because of this.
10) I think @value should also warn you when the variable isn't set.
Shouldn't this be \errormessage as well?!
11) If we used the "\expandafter\ifsetfail" trick in @ifset, we could expand
something we don't want to. For example, construction:
@ifset X
@end ifset
would not work.
Thus I use the trick with \let\next here.
12) \conditionalsucceed may be written in the strightforward way because @set
uses \global assignments. (BTW, the old implementation was wrong: no
recursion was there, if you think about it.)
13) I've clean up \indexdummies and \indexnofonts.
14) Why are there awful things like \catcode43 and catcode61? Are these
macros expanded somewhere? If yes there is still good way to write it
(obtain the number during texinfo.tex sourcing).
15) I had problems that \unmacro messed up the \macrolist (it contained
`\do\scanmacro' several times, I think). Even though I had not saved the
situation, you should accept my new implementation. It's more elegant,
at least.
16) \turnoffmacros was called only from \indexdummies and is no longer needed.
17) I've cleaned up things like \setref and \dosetq and moved (without
modification) definition of \Y... macros.
18) Why should we do all the \catcode gymnastics even if .aux file doesn't
exist? And why should opening of new .aux file be responsibility of macro
called \readauxfile?
Yours, Stepan Kasal
--- /usr/share/texmf/tex/texinfo/texinfo.tex Fri Feb 25 09:09:52 2000
+++ ./texinfo.tex Sun Feb 27 12:52:49 2000
@@ -298,6 +298,7 @@
\def\parsearg#1{%
\let\next = #1%
\begingroup
+ \catcode`\-=\other \catcode`\_=\other % Allow - and _ in argument
\obeylines
\futurelet\temp\parseargx
}
@@ -317,48 +318,48 @@
{\obeyspaces %
\gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
-{\obeylines %
- \gdef\parseargline#1^^M{%
- \endgroup % End of the group started in \parsearg.
- %
- % First remove any @c comment, then any @comment.
- % Result of each macro is put in \toks0.
- \argremovec #1\c\relax %
- \expandafter\argremovecomment \the\toks0 \comment\relax %
- %
- % Call the caller's macro, saved as \next in \parsearg.
- \expandafter\next\expandafter{\the\toks0}%
- }%
+{\catcode`@=11
+ {\obeylines %
+ \gdef\parseargline#1^^M{%
+ \endgroup % End of the group started in \parsearg.
+ % remove @c{,omment} and spaces, then call \next{#1}
+ \argremovec #1\c \ST@P%
+ }%
+ }
+ %
+ % Throw away @c{,omment} at the end of line, ...
+ % [\ST@P nor ``letter'' @_11 can appear in texinfo source]
+ \gdef\argremovec #1\c#2\ST@P{\argremovecomment #1\comment\ST@P}
+ \gdef\argremovecomment #1\comment#2\ST@P{\argremoveAS #1@\ST@P}
+ %
+ % ..., as well as all active spaces, ...
+ {\obeyspaces %
+ \gdef\argremoveAS#1@#2\ST@P{\argremoveASxxx#1@ @\ST@P}
+ \gdef\argremoveASxxx#1 @#2\ST@P{\argremoveASyyy{#1}{#2}}
+ }
+ \gdef\argremoveASyyy#1#2{\def\temp{#2}%
+ \ifx\temp\empty % no space was stripped (and #1 ends with @_11)
+ \let\temp\argremoveNS
+ \else
+ \let\temp\argremoveAS
+ \fi
+ % If we call \argremoveAS, we want just to pass our #1
+ % but we do it this way to optimize the critical path
+ % which is to call \argremoveNS.
+ \temp#1@ @\ST@P
+ }
+ %
+ % ... or perhaps a non-active space.
+ \gdef\argremoveNS#1 @#2\ST@P {%
+ % and strip the remaining @'s
+ \argremoveNSxxx#1@\ST@P
+ }
+ \gdef\argremoveNSxxx#1@#2\ST@P {%
+ % Now we are ready to call the callers macro, saved as \next in \parsearg.
+ \next {#1}%
+ }
}
-% Since all \c{,omment} does is throw away the argument, we can let TeX
-% do that for us. The \relax here is matched by the \relax in the call
-% in \parseargline; it could be more or less anything, its purpose is
-% just to delimit the argument to the \c.
-\def\argremovec#1\c#2\relax{\toks0 = {#1}}
-\def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
-
-% \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
-% @end itemize @c foo
-% will have two active spaces as part of the argument with the
-% `itemize'. Here we remove all active spaces from #1, and assign the
-% result to \toks0.
-%
-% This loses if there are any *other* active characters besides spaces
-% in the argument -- _ ^ +, for example -- since they get expanded.
-% Fortunately, Texinfo does not define any such commands. (If it ever
-% does, the catcode of the characters in questionwill have to be changed
-% here.) But this means we cannot call \removeactivespaces as part of
-% \argremovec{,omment}, since @c uses \parsearg, and thus the argument
-% that \parsearg gets might well have any character at all in it.
-%
-\def\removeactivespaces#1{%
- \begingroup
- \ignoreactivespaces
- \edef\temp{#1}%
- \global\toks0 = \expandafter{\temp}%
- \endgroup
-}
% Change the active space to expand to nothing.
%
@@ -367,7 +368,6 @@
\gdef\ignoreactivespaces{\obeyspaces\let =\empty}
\endgroup
-
\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
%% These are used to keep @begin/@end levels from running away
@@ -391,20 +391,17 @@
%
\def\end{\parsearg\endxxx}
\def\endxxx #1{%
- \removeactivespaces{#1}%
- \edef\endthing{\the\toks0}%
- %
- \expandafter\ifx\csname E\endthing\endcsname\relax
- \expandafter\ifx\csname \endthing\endcsname\relax
+ \expandafter\ifx\csname E#1\endcsname\relax
+ \expandafter\ifx\csname #1\endcsname\relax
% There's no \foo, i.e., no ``environment'' foo.
\errhelp = \EMsimple
- \errmessage{Undefined command `@end \endthing'}%
+ \errmessage{Undefined command `@end #1'}%
\else
- \unmatchedenderror\endthing
+ \unmatchedenderror{#1}%
\fi
\else
% Everything's ok; the right environment has been started.
- \csname E\endthing\endcsname
+ \csname E#1\endcsname
\fi
}
@@ -453,9 +450,9 @@
\let\}=\myrbrace
\begingroup
% Definitions to produce actual \{ & \} command in an index.
- \catcode`\{ = 12 \catcode`\} = 12
+ \catcode`\{ = \other \catcode`\} = \other
\catcode`\[ = 1 \catcode`\] = 2
- \catcode`\@ = 0 \catcode`\\ = 12
+ \catcode`\@ = 0 \catcode`\\ = \other
@gdef@lbracecmd[\{]%
@gdef@rbracecmd[\}]%
@endgroup
@@ -701,14 +698,14 @@
% @include file insert text of that file as input.
% Allow normal characters that we make active in the argument (a file name).
\def\include{\begingroup
- \catcode`\\=12
- \catcode`~=12
- \catcode`^=12
- \catcode`_=12
- \catcode`|=12
- \catcode`<=12
- \catcode`>=12
- \catcode`+=12
+ \catcode`\\=\other
+ \catcode`~=\other
+ \catcode`^=\other
+ \catcode`_=\other
+ \catcode`|=\other
+ \catcode`<=\other
+ \catcode`>=\other
+ \catcode`+=\other
\parsearg\includezzz}
% Restore active chars for included file.
\def\includezzz#1{\endgroup\begingroup
@@ -722,9 +719,9 @@
% @center line outputs that line, centered
\def\center{\parsearg\centerzzz}
-\def\centerzzz #1{{\advance\hsize by -\leftskip
-\advance\hsize by -\rightskip
-\centerline{#1}}}
+\def\centerzzz #1{\hbox to\hsize{\hfil plus1fil \kern\leftskip
+ \ignorespaces#1\unskip \hfil plus1fil \kern\rightskip}%
+}
% @sp n outputs n lines of vertical space
@@ -816,7 +813,9 @@
% This makes it possible to make a .fmt file for texinfo.
\def\setfilename{%
\iflinks
- \readauxfile
+ \tryauxfile
+ % Open the new aux file. TeX will close it automatically at exit.
+ \openout\auxfile=\jobname.aux
\fi % \openindices needs to do some work in any case.
\openindices
\fixbackslash % Turn off hack to swallow `\input texinfo'.
@@ -1072,7 +1071,7 @@
\setfont\textrm\rmshape{10}{\mainmagstep}
\setfont\texttt\ttshape{10}{\mainmagstep}
\fi
-% Instead of cmb10, you many want to use cmbx10.
+% Instead of cmb10, you may want to use cmbx10.
% cmbx10 is a prettier font on its own, but cmb10
% looks better when embedded in a line with cmr10.
\setfont\textbf\bfshape{10}{\mainmagstep}
@@ -1306,7 +1305,7 @@
\null
}
-% We *must* turn on hyphenation at `-' and `_' in \code.
+% 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.
@@ -1352,15 +1351,16 @@
\gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
\else\ifx\arg\wordcode
\gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
+ \else
+ \message{[Unknown @kbdinputstyle: \arg.]}%
\fi\fi\fi
}
\def\worddistinct{distinct}
\def\wordexample{example}
\def\wordcode{code}
-% Default is kbdinputdistinct. (Too much of a hassle to call the macro,
-% the catcodes are wrong for parsearg to work.)
-\gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}
+% Default is `distinct.'
+\kbdinputstyle distinct
\def\xkey{\key}
\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
@@ -2086,8 +2086,8 @@
\let\go\pickupwholefraction
\else
\global\advance\colcount by 1
- \setbox0=\hbox{#1\unskip }% Add a normal word space as a separator;
- % typically that is always in the input, anyway.
+ \setbox0=\hbox{#1\unskip\space}% Add a normal word space
+ % as a separator; typically that is always in the input, anyway.
\expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
\fi
\fi
@@ -2241,56 +2241,6 @@
\let\titlepage=\relax
}
-% Used in nested conditionals, where we have to parse the Texinfo source
-% and so want to turn off most commands, in case they are used
-% incorrectly.
-%
-\def\ignoremorecommands{%
- \let\defcodeindex = \relax
- \let\defcv = \relax
- \let\deffn = \relax
- \let\deffnx = \relax
- \let\defindex = \relax
- \let\defivar = \relax
- \let\defmac = \relax
- \let\defmethod = \relax
- \let\defop = \relax
- \let\defopt = \relax
- \let\defspec = \relax
- \let\deftp = \relax
- \let\deftypefn = \relax
- \let\deftypefun = \relax
- \let\deftypeivar = \relax
- \let\deftypeop = \relax
- \let\deftypevar = \relax
- \let\deftypevr = \relax
- \let\defun = \relax
- \let\defvar = \relax
- \let\defvr = \relax
- \let\ref = \relax
- \let\xref = \relax
- \let\printindex = \relax
- \let\pxref = \relax
- \let\settitle = \relax
- \let\setchapternewpage = \relax
- \let\setchapterstyle = \relax
- \let\everyheading = \relax
- \let\evenheading = \relax
- \let\oddheading = \relax
- \let\everyfooting = \relax
- \let\evenfooting = \relax
- \let\oddfooting = \relax
- \let\headings = \relax
- \let\include = \relax
- \let\lowersections = \relax
- \let\down = \relax
- \let\raisesections = \relax
- \let\up = \relax
- \let\set = \relax
- \let\clear = \relax
- \let\item = \relax
-}
-
% Ignore @ignore ... @end ignore.
%
\def\ignore{\doignore{ignore}}
@@ -2308,130 +2258,71 @@
% which this file should belong to. Ignore this in TeX.
\let\dircategory = \comment
-% Ignore text until a line `@end #1'.
+% Ignore text until a line `@end #1' taking care of nested conditionals.
%
+% A count to remember the depth of nesting.
+\newcount\doignorecount \doignorecount = 0
+
\def\doignore#1{\begingroup
% Don't complain about control sequences we have declared \outer.
\ignoresections
%
- % Define a command to swallow text until we reach `@end #1'.
- % This @ is a catcode 12 token (that is the normal catcode of @ in
- % this texinfo.tex file). We change the catcode of @ below to match.
- \long\def\doignoretext##1@end #1{\enddoignore}%
- %
% Make sure that spaces turn into tokens that match what \doignoretext wants.
- \catcode32 = 10
+ \catcode`\ = 10
%
% Ignore braces, too, so mismatched braces don't cause trouble.
\catcode`\{ = 9
\catcode`\} = 9
%
- % We must not have @c interpreted as a control sequence.
- \catcode`\@ = 12
+ \doignorecount = 0
%
- % Make the letter c a comment character so that the rest of the line
- % will be ignored. This way, the document can have (for example)
- % @c @end ifinfo
- % and the @end ifinfo will be properly ignored.
- % (We've just changed @ to catcode 12.)
- \catcode`\c = 14
- %
- % And now expand that command.
- \doignoretext
-}
-
-% What we do to finish off ignored text.
-%
-\def\enddoignore{\endgroup\ignorespaces}%
-
-\newif\ifwarnedobs\warnedobsfalse
-\def\obstexwarn{%
- \ifwarnedobs\relax\else
- % We need to warn folks that they may have trouble with TeX 3.0.
- % This uses \immediate\write16 rather than \message to get newlines.
- \immediate\write16{}
- \immediate\write16{WARNING: for users of Unix TeX 3.0!}
- \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).}
- \immediate\write16{If you are running another version of TeX, relax.}
- \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
- \immediate\write16{ Then upgrade your TeX installation if you can.}
- \immediate\write16{ (See ftp://ftp.gnu.org/pub/gnu/TeX.README.)}
- \immediate\write16{If you are stuck with version 3.0, run the}
- \immediate\write16{ script ``tex3patch'' from the Texinfo distribution}
- \immediate\write16{ to use a workaround.}
- \immediate\write16{}
- \global\warnedobstrue
- \fi
+ % Define a command to swallow text until we reach `@end #1'.
+ \expandafter \doignorexxx \csname #1\endcsname {#1}%
}
-% **In TeX 3.0, setting text in \nullfont hangs tex. For a
-% workaround (which requires the file ``dummy.tfm'' to be installed),
-% uncomment the following line:
-%%%%%\font\nullfont=dummy\let\obstexwarn=\relax
-
-% Ignore text, except that we keep track of conditional commands for
-% purposes of nesting, up to an `@end #1' command.
-%
-\def\nestedignore#1{%
- \obstexwarn
- % We must actually expand the ignored text to look for the @end
- % command, so that nested ignore constructs work. Thus, we put the
- % text into a \vbox and then do nothing with the result. To minimize
- % the change of memory overflow, we follow the approach outlined on
- % page 401 of the TeXbook: make the current font be a dummy font.
- %
- \setbox0 = \vbox\bgroup
- % Don't complain about control sequences we have declared \outer.
- \ignoresections
- %
- % Define `@end #1' to end the box, which will in turn undefine the
- % @end command again.
- \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
- %
- % We are going to be parsing Texinfo commands. Most cause no
- % trouble when they are used incorrectly, but some commands do
- % complicated argument parsing or otherwise get confused, so we
- % undefine them.
- %
- % We can't do anything about stray @-signs, unfortunately;
- % they'll produce `undefined control sequence' errors.
- \ignoremorecommands
- %
- % Set the current font to be \nullfont, a TeX primitive, and define
- % all the font commands to also use \nullfont. We don't use
- % dummy.tfm, as suggested in the TeXbook, because not all sites
- % might have that installed. Therefore, math mode will still
- % produce output, but that should be an extremely small amount of
- % stuff compared to the main input.
- %
- \nullfont
- \let\tenrm=\nullfont \let\tenit=\nullfont \let\tensl=\nullfont
- \let\tenbf=\nullfont \let\tentt=\nullfont \let\smallcaps=\nullfont
- \let\tensf=\nullfont
- % Similarly for index fonts (mostly for their use in smallexample).
- \let\smallrm=\nullfont \let\smallit=\nullfont \let\smallsl=\nullfont
- \let\smallbf=\nullfont \let\smalltt=\nullfont \let\smallsc=\nullfont
- \let\smallsf=\nullfont
- %
- % Don't complain when characters are missing from the fonts.
- \tracinglostchars = 0
- %
- % Don't bother to do space factor calculations.
- \frenchspacing
+{ \catcode`@=11 % We want to use \ST@P which cannot appear in texinfo source.
+ \obeylines %
+ %
+ \gdef\doignorexxx#1#2{%
+ % #1 contains eg. \ifinfo, ie. @ifinfo
+ % #2 contains eg. "ifinfo"
%
- % Don't report underfull hboxes.
- \hbadness = 10000
+ % Find next "@end #2"--it must be on a line by itself.
+ \long\def\doignoretext ##1^^M\end #2{\doignoretextyyy ##1#1\ST@P}%
%
- % Do minimal line-breaking.
- \pretolerance = 10000
+ \long\def\doignoretextyyy ##1#1##2\ST@P {\doignoreyyy {##2}\ST@P}%
%
- % Do not execute instructions in @tex
- \def\tex{\doignore{tex}}%
- % Do not execute macro definitions.
- % `c' is a comment character, so the word `macro' will get cut off.
- \def\macro{\doignore{ma}}%
+ % And now expand that command.
+ \obeylines %
+ \doignoretext ^^M%
+ }%
+}
+
+\def\doignoreyyy #1{\def\temp{#1}%
+ \ifx\temp\empty % Nothing found.
+ \let\next\doignoretextzzz
+ \else % Found a nested condition, ...
+ \advance \doignorecount by 1
+ \let\next\doignoretextyyy % ..., look for another.
+ % Note that in this case #1 ends with \ifinfo (for example).
+ \fi
+ \next #1% the token \ST@P hangs just after this macro.
}
+% We have to swallow the remaining "\ST@P".
+\def\doignoretextzzz#1{%
+ \ifnum \doignorecount = 0 % We have just found the outermost @end.
+ \let\next\enddoignore
+ \else % Still inside a nested condition.
+ \advance \doignorecount by -1
+ \let\next\doignoretext
+ \fi
+ \next
+}
+
+% Finish off ignored text.
+\def\enddoignore{\endgroup\ignorespaces}
+
% @set VAR sets the variable VAR to an empty value.
% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
%
@@ -2442,7 +2333,6 @@
% losing inside @example, for instance.
%
\def\set{\begingroup\catcode` =10
- \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR.
\parsearg\setxxx}
\def\setxxx#1{\setyyy#1 \endsetyyy}
\def\setyyy#1 #2\endsetyyy{%
@@ -2470,7 +2360,7 @@
% we're called from @code, as @code{@value{foo-bar_}}. So \let any
% such active characters to their normal equivalents.
\gdef\value{\begingroup
- \catcode`\-=12 \catcode`\_=12
+ \catcode`\-=\other \catcode`\_=\other
\indexbreaks \let_\normalunderscore
\valuexxx}
}
@@ -2488,6 +2378,7 @@
\def\expandablevalue#1{%
\expandafter\ifx\csname SET#1\endcsname\relax
{[No value for ``#1'']}%
+ \message{[No value for ``#1'']}%
\else
\csname SET#1\endcsname
\fi
@@ -2499,13 +2390,14 @@
\def\ifset{\parsearg\ifsetxxx}
\def\ifsetxxx #1{%
\expandafter\ifx\csname SET#1\endcsname\relax
- \expandafter\ifsetfail
+ \let\next\ifsetfail
\else
- \expandafter\ifsetsucceed
+ \let\next\ifsetsucceed
\fi
+ \next
}
\def\ifsetsucceed{\conditionalsucceed{ifset}}
-\def\ifsetfail{\nestedignore{ifset}}
+\def\ifsetfail{\doignore{ifset}}
\defineunmatchedend{ifset}
% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
@@ -2514,13 +2406,14 @@
\def\ifclear{\parsearg\ifclearxxx}
\def\ifclearxxx #1{%
\expandafter\ifx\csname SET#1\endcsname\relax
- \expandafter\ifclearsucceed
+ \let\next\ifclearsucceed
\else
- \expandafter\ifclearfail
+ \let\next\ifclearfail
\fi
+ \next
}
\def\ifclearsucceed{\conditionalsucceed{ifclear}}
-\def\ifclearfail{\nestedignore{ifclear}}
+\def\ifclearfail{\doignore{ifclear}}
\defineunmatchedend{ifclear}
% @iftex, @ifnothtml, @ifnotinfo always succeed; we read the text
@@ -2534,22 +2427,10 @@
\defineunmatchedend{ifnothtml}
\defineunmatchedend{ifnotinfo}
-% We can't just want to start a group at @iftex (for example) and end it
-% at @end iftex, since then @set commands inside the conditional have no
-% effect (they'd get reverted at the end of the group). So we must
-% define \Eiftex to redefine itself to be its previous value. (We can't
-% just define it to fail again with an ``unmatched end'' error, since
-% the @ifset might be nested.)
-%
-\def\conditionalsucceed#1{%
- \edef\temp{%
- % Remember the current value of \E#1.
- \let\nece{prevE#1} = \nece{E#1}%
- %
- % At the `@end #1', redefine \E#1 to be its previous value.
- \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
- }%
- \temp
+% True condition:
+%
+\def\conditionalsucceed#1{\begingroup
+ \expandafter\def\csname E#1\endcsname{\endgroup}%
}
% We need to expand lots of \csname's, but we don't want to expand the
@@ -2642,95 +2523,66 @@
\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
-\def\indexdummies{%
-\def\ { }%
-% Take care of the plain tex accent commands.
-\def\"{\realbackslash "}%
-\def\`{\realbackslash `}%
-\def\'{\realbackslash '}%
-\def\^{\realbackslash ^}%
-\def\~{\realbackslash ~}%
-\def\={\realbackslash =}%
-\def\b{\realbackslash b}%
-\def\c{\realbackslash c}%
-\def\d{\realbackslash d}%
-\def\u{\realbackslash u}%
-\def\v{\realbackslash v}%
-\def\H{\realbackslash H}%
-% Take care of the plain tex special European modified letters.
-\def\oe{\realbackslash oe}%
-\def\ae{\realbackslash ae}%
-\def\aa{\realbackslash aa}%
-\def\OE{\realbackslash OE}%
-\def\AE{\realbackslash AE}%
-\def\AA{\realbackslash AA}%
-\def\o{\realbackslash o}%
-\def\O{\realbackslash O}%
-\def\l{\realbackslash l}%
-\def\L{\realbackslash L}%
-\def\ss{\realbackslash ss}%
-% Take care of texinfo commands likely to appear in an index entry.
% (Must be a way to avoid doing expansion at all, and thus not have to
% laboriously list every single command here.)
-\def\@{@}% will be @@ when we switch to @ as escape char.
-% Need these in case \tex is in effect and \{ is a \delimiter again.
-% But can't use \lbracecmd and \rbracecmd because texindex assumes
-% braces and backslashes are used only as delimiters.
-\let\{ = \mylbrace
-\let\} = \myrbrace
-\def\_{{\realbackslash _}}%
-\def\w{\realbackslash w }%
-\def\bf{\realbackslash bf }%
-%\def\rm{\realbackslash rm }%
-\def\sl{\realbackslash sl }%
-\def\sf{\realbackslash sf}%
-\def\tt{\realbackslash tt}%
-\def\gtr{\realbackslash gtr}%
-\def\less{\realbackslash less}%
-\def\hat{\realbackslash hat}%
-\def\TeX{\realbackslash TeX}%
-\def\dots{\realbackslash dots }%
-\def\result{\realbackslash result}%
-\def\equiv{\realbackslash equiv}%
-\def\expansion{\realbackslash expansion}%
-\def\print{\realbackslash print}%
-\def\error{\realbackslash error}%
-\def\point{\realbackslash point}%
-\def\copyright{\realbackslash copyright}%
-\def\tclose##1{\realbackslash tclose {##1}}%
-\def\code##1{\realbackslash code {##1}}%
-\def\uref##1{\realbackslash uref {##1}}%
-\def\url##1{\realbackslash url {##1}}%
-\def\env##1{\realbackslash env {##1}}%
-\def\command##1{\realbackslash command {##1}}%
-\def\option##1{\realbackslash option {##1}}%
-\def\dotless##1{\realbackslash dotless {##1}}%
-\def\samp##1{\realbackslash samp {##1}}%
-\def\,##1{\realbackslash ,{##1}}%
-\def\t##1{\realbackslash t {##1}}%
-\def\r##1{\realbackslash r {##1}}%
-\def\i##1{\realbackslash i {##1}}%
-\def\b##1{\realbackslash b {##1}}%
-\def\sc##1{\realbackslash sc {##1}}%
-\def\cite##1{\realbackslash cite {##1}}%
-\def\key##1{\realbackslash key {##1}}%
-\def\file##1{\realbackslash file {##1}}%
-\def\var##1{\realbackslash var {##1}}%
-\def\kbd##1{\realbackslash kbd {##1}}%
-\def\dfn##1{\realbackslash dfn {##1}}%
-\def\emph##1{\realbackslash emph {##1}}%
-\def\acronym##1{\realbackslash acronym {##1}}%
-%
-% Handle some cases of @value -- where the variable name does not
-% contain - or _, and the value does not contain any
-% (non-fully-expandable) commands.
-\let\value = \expandablevalue
-%
-\unsepspaces
-% Turn off macro expansion
-\turnoffmacros
+
+% List for both \indexdummies and \indexnofonts.
+\def\indexlistA {%
+ % Take care of the plain tex accent commands.
+ \do\"\do\`\do\'\do\^\do\~\do\=\do\,%
+ \do\b \do\c \do\d \do\u \do\v \do\H
+ % Other plain TeX commands.
+ \do\copyright
+ \do\bf \do\sl \do\sf
+ % Don't no-op \tt in \indexnofonts, since it's not a user-level command
+ % and is used in the definitions of the active chars like <, >, |...
+ % Take care of texinfo commands likely to appear in an index entry.
+ \do\w \do\t \do\r \do\i \do\b \do\emph \do\strong \do\cite \do\sc
+ \do\var \do\dfn \do\kbd \do\key \do\file \do\samp \do\tclose
+ \do\code \do\uref \do\url \do\acronym \do\env \do\command \do\option
+ \do\point \do\result \do\expansion \do\print \do\equiv \do\error
+ \do\dotless
+}
+
+% List for \indexdummies only.
+\def\indexlistB {%
+ \do\_\do\tt % Don't \do\rm, it might be used in output routine.
+ \do\TeX \do\dots
+ % \do\gtr \do\less \do\hat -- these aren't expandable, so why bother?
+}
+
+% Take care of the plain tex special European modified letters.
+\def\indexlistC {%
+ \do\oe \do\ae \do\aa \do\OE \do\AE \do\AA \do\o \do\O \do\l \do\L \do\ss
+}
+
+% We mant to disable some plain and texinfo comands and all macros durings
+% \shipout and in similar situatoions so that they are not expanded by \write.
+\def\indexdummies{%
+ \let\do\indexdummiesdo
+ \indexlistA \indexlistB \indexlistC \macrolist
+ \let\do\undefined
+ % \write will automatically append space to control words.
+ % So it's important that letters have catcode 11 and non-letters have
+ % a catcode != 11. I hope this is true. If not, fix it here.
+ % (Remember, this code may be called anywhere--via the output routine.)
+ \def\ { }%
+ \unsepspaces
+ \def\@{@}% will be @@ when we switch to @ as escape char.
+ % Need these in case \tex is in effect and \{ is a \delimiter again.
+ % But can't use \lbracecmd and \rbracecmd because texindex assumes
+ % braces and backslashes are used only as delimiters.
+ \let\{ = \mylbrace
+ \let\} = \myrbrace
+ %
+ % Handle some cases of @value -- where the variable name does not
+ % contain - or _, and the value does not contain any
+ % (non-fully-expandable) commands.
+ \let\value = \expandablevalue
}
+\def\indexdummiesdo#1{\let#1\relax}
+
% If an index command is used in an @example environment, any spaces
% therein should become regular spaces in the raw index file, not the
% expansion of \tie (\\leavevmode \penalty \@M \ ).
@@ -2739,68 +2591,22 @@
% \indexnofonts no-ops all font-change commands.
% This is used when outputting the strings to sort the index by.
-\def\indexdummyfont#1{#1}
-\def\indexdummytex{TeX}
-\def\indexdummydots{...}
-
\def\indexnofonts{%
-% Just ignore accents.
-\let\,=\indexdummyfont
-\let\"=\indexdummyfont
-\let\`=\indexdummyfont
-\let\'=\indexdummyfont
-\let\^=\indexdummyfont
-\let\~=\indexdummyfont
-\let\==\indexdummyfont
-\let\b=\indexdummyfont
-\let\c=\indexdummyfont
-\let\d=\indexdummyfont
-\let\u=\indexdummyfont
-\let\v=\indexdummyfont
-\let\H=\indexdummyfont
-\let\dotless=\indexdummyfont
-% Take care of the plain tex special European modified letters.
-\def\oe{oe}%
-\def\ae{ae}%
-\def\aa{aa}%
-\def\OE{OE}%
-\def\AE{AE}%
-\def\AA{AA}%
-\def\o{o}%
-\def\O{O}%
-\def\l{l}%
-\def\L{L}%
-\def\ss{ss}%
-\let\w=\indexdummyfont
-\let\t=\indexdummyfont
-\let\r=\indexdummyfont
-\let\i=\indexdummyfont
-\let\b=\indexdummyfont
-\let\emph=\indexdummyfont
-\let\strong=\indexdummyfont
-\let\cite=\indexdummyfont
-\let\sc=\indexdummyfont
-%Don't no-op \tt, since it isn't a user-level command
-% and is used in the definitions of the active chars like <, >, |...
-%\let\tt=\indexdummyfont
-\let\tclose=\indexdummyfont
-\let\code=\indexdummyfont
-\let\url=\indexdummyfont
-\let\uref=\indexdummyfont
-\let\env=\indexdummyfont
-\let\acronym=\indexdummyfont
-\let\command=\indexdummyfont
-\let\option=\indexdummyfont
-\let\file=\indexdummyfont
-\let\samp=\indexdummyfont
-\let\kbd=\indexdummyfont
-\let\key=\indexdummyfont
-\let\var=\indexdummyfont
-\let\TeX=\indexdummytex
-\let\dots=\indexdummydots
-\def\@{@}%
+ \let\do\indexnofontsdoA
+ \indexlistA
+ % Take care of the plain tex special European modified letters.
+ \let\do\indexnofontsdoC
+ \indexlistC\do\TeX
+ \let\do\undefined
+ \let\dots=\indexdummydots
+ \def\@{@}%
}
+\def\indexnofontsdoA #1{\let#1\indexdummyfont}
+\def\indexnofontsdoC #1{\edef#1{\expandafter\gobble\string#1}}
+\def\indexdummyfont#1{#1}
+\def\indexdummydots{...}
+
% To define \realbackslash, we must make \ not be an escape.
% We must first make another character (@) an escape
% so we do not become unable to do a definition.
@@ -4017,14 +3823,14 @@
\def\tex{\begingroup
\catcode `\\=0 \catcode `\{=1 \catcode `\}=2
\catcode `\$=3 \catcode `\&=4 \catcode `\#=6
- \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
+ \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
\catcode `\%=14
- \catcode 43=12 % plus
- \catcode`\"=12
- \catcode`\==12
- \catcode`\|=12
- \catcode`\<=12
- \catcode`\>=12
+ \catcode `\+=\other
+ \catcode `\"=\other
+ \catcode `\==\other
+ \catcode `\|=\other
+ \catcode `\<=\other
+ \catcode `\>=\other
\escapechar=`\\
%
\let\b=\ptexb
@@ -4350,7 +4156,7 @@
% Active &'s sneak into the index arguments, so make sure it's defined.
{
- \catcode`& = 13
+ \catcode`& = \active
\global\let& = \ampnr
}
@@ -4398,7 +4204,7 @@
\advance\leftskip by \defbodyindent
\exdentamount=\defbodyindent
\begingroup %
-\catcode 61=\active % 61 is `='
+\catcode `\= = \active
\obeylines\activeparens\spacesplit#3}
% #1 is the \E... control sequence to end the definition (which we define).
@@ -4477,7 +4283,7 @@
\advance\leftskip by \defbodyindent
\exdentamount=\defbodyindent
\begingroup %
-\catcode 61=\active %
+\catcode `\= =\active %
\obeylines\spacesplit#3}
% This is used for \def{tp,vr}parsebody. It could probably be used for
@@ -4592,7 +4398,7 @@
\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
-\catcode 61=\other % Turn off change made in \defparsebody
+\catcode `\= = \other % Turn off change made in \defparsebody
}
% @defun == @deffn Function
@@ -4602,7 +4408,7 @@
\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
\begingroup\defname {#1}{\putwordDeffunc}%
\defunargs {#2}\endgroup %
-\catcode 61=\other % Turn off change made in \defparsebody
+\catcode `\= = \other % Turn off change made in \defparsebody
}
% @deftypefun int foobar (int @var{foo}, float @var{bar})
@@ -4854,7 +4660,7 @@
\def\scanmacro#1{%
\begingroup \newlinechar`\^^M
% Undo catcode changes of \startcontents and \doprintindex
- \catcode`\@=0 \catcode`\\=12 \escapechar=`\@
+ \catcode`\@=0 \catcode`\\=\other \escapechar=`\@
% Append \endinput to make sure that TeX does not see the ending newline.
\toks0={#1\endinput}%
\immediate\openout\macscribble=\jobname.tmp
@@ -4868,7 +4674,7 @@
\def\scanmacro#1{%
\begingroup \newlinechar`\^^M
% Undo catcode changes of \startcontents and \doprintindex
-\catcode`\@=0 \catcode`\\=12 \escapechar=`\@
+\catcode`\@=0 \catcode`\\=\other \escapechar=`\@
\let\xeatspaces\eatspaces\scantokens{#1\endinput}\endgroup}
\fi
@@ -4898,7 +4704,7 @@
}
% Trim a single trailing ^^M off a string.
-{\catcode`\^^M=12\catcode`\Q=3%
+{\catcode`\^^M=\other \catcode`\Q=3%
\gdef\eatcr #1{\eatcra #1Q^^MQ}%
\gdef\eatcra#1^^MQ{\eatcrb#1Q}%
\gdef\eatcrb#1Q#2Q{#1}%
@@ -4913,29 +4719,29 @@
% body, and then making it the \newlinechar in \scanmacro.
\def\macrobodyctxt{%
- \catcode`\~=12
- \catcode`\^=12
- \catcode`\_=12
- \catcode`\|=12
- \catcode`\<=12
- \catcode`\>=12
- \catcode`\+=12
- \catcode`\{=12
- \catcode`\}=12
- \catcode`\@=12
- \catcode`\^^M=12
+ \catcode`\~=\other
+ \catcode`\^=\other
+ \catcode`\_=\other
+ \catcode`\|=\other
+ \catcode`\<=\other
+ \catcode`\>=\other
+ \catcode`\+=\other
+ \catcode`\{=\other
+ \catcode`\}=\other
+ \catcode`\@=\other
+ \catcode`\^^M=\other
\usembodybackslash}
\def\macroargctxt{%
- \catcode`\~=12
- \catcode`\^=12
- \catcode`\_=12
- \catcode`\|=12
- \catcode`\<=12
- \catcode`\>=12
- \catcode`\+=12
- \catcode`\@=12
- \catcode`\\=12}
+ \catcode`\~=\other
+ \catcode`\^=\other
+ \catcode`\_=\other
+ \catcode`\|=\other
+ \catcode`\<=\other
+ \catcode`\>=\other
+ \catcode`\+=\other
+ \catcode`\@=\other
+ \catcode`\\=\other}
% \mbodybackslash is the definition of \ in @macro bodies.
% It maps \foo\ => \csname macarg.foo\endcsname => #N
@@ -4983,25 +4789,24 @@
\global\expandafter\let \csname ismacro.#1\endcsname=0%
% Remove the macro name from \macrolist
\begingroup
- \edef\tempa{\expandafter\noexpand\csname#1\endcsname}%
- \def\do##1{%
- \def\tempb{##1}%
- \ifx\tempa\tempb
- % remove this
- \else
- \toks0 = \expandafter{\newmacrolist\do}%
- \edef\newmacrolist{\the\toks0\expandafter\noexpand\tempa}%
- \fi}%
- \def\newmacrolist{}%
- % Execute macro list to define \newmacrolist
- \macrolist
- \global\let\macrolist\newmacrolist
+ \expandafter\let\csname#1\endcsname \relax
+ \let\do\unmacrodo
+ \xdef\macrolist{\macrolist}%
\endgroup
\else
\errmessage{Macro #1 not defined}%
\fi
}
+% unsed in \unmacroxxx
+\def\unmacrodo#1{%
+ \ifx#1\relax
+ % remove this
+ \else
+ \noexpand\do \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.
@@ -5117,12 +4922,6 @@
\expandafter\parsearg
\fi \next}
-% We mant to disable all macros during \shipout so that they are not
-% expanded by \write.
-\def\turnoffmacros{\begingroup \def\do##1{\let\noexpand##1=\relax}%
- \edef\next{\macrolist}\expandafter\endgroup\next}
-
-
% @alias.
% We need some trickery to remove the optional spaces around the equal
% sign. Just make them active and then expand them all to nothing.
@@ -5157,21 +4956,19 @@
% The sectioning commands (@chapter, etc.) call these.
\def\donoderef{%
\ifx\lastnode\relax\else
- \expandafter\expandafter\expandafter\setref{\lastnode}%
- {Ysectionnumberandtype}%
+ \expandafter\setref\expandafter{\lastnode}{sectionnumberandtype}%
\global\let\lastnode=\relax
\fi
}
\def\unnumbnoderef{%
\ifx\lastnode\relax\else
- \expandafter\expandafter\expandafter\setref{\lastnode}{Ynothing}%
+ \expandafter\setref\expandafter{\lastnode}{nothing}%
\global\let\lastnode=\relax
\fi
}
\def\appendixnoderef{%
\ifx\lastnode\relax\else
- \expandafter\expandafter\expandafter\setref{\lastnode}%
- {Yappendixletterandtype}%
+ \expandafter\setref\expandafter{\lastnode}{appendixletterandtype}%
\global\let\lastnode=\relax
\fi
}
@@ -5182,7 +4979,7 @@
\newcount\savesfregister
\gdef\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
\gdef\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
-\gdef\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
+\gdef\anchor#1{\savesf \setref{#1}{nothing}\restoresf \ignorespaces}
% \setref{NAME}{SNT} defines a cross-reference point NAME, namely
% NAME-title, NAME-pg, and NAME-SNT. Called from \foonoderef. We have
@@ -5193,11 +4990,50 @@
\def\setref#1#2{{%
\indexdummies
\pdfmkdest{#1}%
- \dosetq{#1-title}{Ytitle}%
- \dosetq{#1-pg}{Ypagenumber}%
- \dosetq{#1-snt}{#2}%
+ \iflinks
+ {\let\folio=0%
+ % Use \normalturnoffactive so that punctuation chars such as underscore
+ % and backslash work in node names. (\turnoffactive doesn't do \.)
+ \normalturnoffactive
+ \writesetq{#1-title}{title}%
+ \writesetq{#1-pg}{pagenumber}%
+ \writesetq{#1-snt}{#2}%
+ }%
+ \fi
}}
+% \writesetq {foo}{title} writes to \auxfile
+% CHARACTERS 'xrdef {foo}{...expansion of \Ytitle...}
+% When the aux file is read, ' is the escape character
+
+\def\writesetq #1#2{\write\auxfile{'xrdef {#1}{\csname Y#2\endcsname}}}
+
+% Things to be expanded by \writesetq
+
+\def\Ytitle{\thissection}
+\def\Ypagenumber{\folio}
+\def\Ynothing{}
+
+\def\Ysectionnumberandtype{%
+\ifnum\secno=0 \putwordChapter\xreftie\the\chapno %
+\else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno %
+\else \ifnum \subsubsecno=0 %
+\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno %
+\else %
+\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
+\fi \fi \fi }
+
+\def\Yappendixletterandtype{%
+\ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}%
+\else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno %
+\else \ifnum \subsubsecno=0 %
+\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
+\else %
+\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
+%
+\fi \fi \fi }
+
+\gdef\xreftie{'tie}
+
% @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
@@ -5276,54 +5112,6 @@
\endlink
\endgroup}
-% \dosetq is the interface for calls from other macros
-
-% Use \normalturnoffactive so that punctuation chars such as underscore
-% and backslash work in node names. (\turnoffactive doesn't do \.)
-\def\dosetq#1#2{%
- {\let\folio=0%
- \normalturnoffactive
- \edef\next{\write\auxfile{\internalsetq{#1}{#2}}}%
- \iflinks
- \next
- \fi
- }%
-}
-
-% \internalsetq {foo}{page} expands into
-% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
-% When the aux file is read, ' is the escape character
-
-\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
-
-% Things to be expanded by \internalsetq
-
-\def\Ypagenumber{\folio}
-
-\def\Ytitle{\thissection}
-
-\def\Ynothing{}
-
-\def\Ysectionnumberandtype{%
-\ifnum\secno=0 \putwordChapter\xreftie\the\chapno %
-\else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno %
-\else \ifnum \subsubsecno=0 %
-\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno %
-\else %
-\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
-\fi \fi \fi }
-
-\def\Yappendixletterandtype{%
-\ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}%
-\else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno %
-\else \ifnum \subsubsecno=0 %
-\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
-\else %
-\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
%
-\fi \fi \fi }
-
-\gdef\xreftie{'tie}
-
% Use TeX 3.0's \inputlineno to get the line number, for better error
% messages, but if we're using an old version of TeX, don't do anything.
%
@@ -5367,6 +5155,15 @@
}
% Read the last existing aux file, if any. No error if none exists.
+\def\tryauxfile{%
+ \openin 1 \jobname.aux
+ \ifeof 1 \else
+ \closein 1
+ \readauxfile
+ \global\havexrefstrue
+ \fi
+}
+
\def\readauxfile{\begingroup
\catcode`\^^@=\other
\catcode`\^^A=\other
@@ -5443,15 +5240,7 @@
\catcode`\'=0
\catcode`\\=\other
%
- \openin 1 \jobname.aux
- \ifeof 1 \else
- \closein 1
- \input \jobname.aux
- \global\havexrefstrue
- \global\warnedobstrue
- \fi
- % Open the new aux file. TeX will close it automatically at exit.
- \openout\auxfile=\jobname.aux
+ \input \jobname.aux
\endgroup}