1%% TeX macros to handle texinfo files
2
3%   Copyright (C) 1985, 86, 88, 90, 91, 92, 1993 Free Software Foundation, Inc.
4
5%This texinfo.tex file is free software; you can redistribute it and/or
6%modify it under the terms of the GNU General Public License as
7%published by the Free Software Foundation; either version 2, or (at
8%your option) any later version.
9
10%This texinfo.tex file is distributed in the hope that it will be
11%useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12%of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13%General Public License for more details.
14
15%You should have received a copy of the GNU General Public License
16%along with this texinfo.tex file; see the file COPYING.  If not, write
17%to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18%USA.
19
20
21%In other words, you are welcome to use, share and improve this program.
22%You are forbidden to forbid anyone else to use, share and improve
23%what you give them.   Help stamp out software-hoarding!
24
25\def\texinfoversion{2.122}
26\message{Loading texinfo package [Version \texinfoversion]:}
27
28% Print the version number if in a .fmt file.
29\everyjob{\message{[Texinfo version \texinfoversion]}\message{}}
30
31% Save some parts of plain tex whose names we will redefine.
32
33\let\ptexlbrace=\{
34\let\ptexrbrace=\}
35\let\ptexdots=\dots
36\let\ptexdot=\.
37\let\ptexstar=\*
38\let\ptexend=\end
39\let\ptexbullet=\bullet
40\let\ptexb=\b
41\let\ptexc=\c
42\let\ptexi=\i
43\let\ptext=\t
44\let\ptexl=\l
45\let\ptexL=\L
46
47\def\tie{\penalty 10000\ }     % Save plain tex definition of ~.
48
49\message{Basics,}
50\chardef\other=12
51
52% If this character appears in an error message or help string, it
53% starts a new line in the output.
54\newlinechar = `^^J
55
56% Set up fixed words for English.
57\ifx\putwordChapter\undefined{\gdef\putwordChapter{Chapter}}\fi%
58\def\putwordInfo{Info}%
59\ifx\putwordSee\undefined{\gdef\putwordSee{See}}\fi%
60\ifx\putwordsee\undefined{\gdef\putwordsee{see}}\fi%
61\ifx\putwordfile\undefined{\gdef\putwordfile{file}}\fi%
62\ifx\putwordpage\undefined{\gdef\putwordpage{page}}\fi%
63\ifx\putwordsection\undefined{\gdef\putwordsection{section}}\fi%
64\ifx\putwordSection\undefined{\gdef\putwordSection{Section}}\fi%
65\ifx\putwordTableofContents\undefined{\gdef\putwordTableofContents{Table of Contents}}\fi%
66\ifx\putwordShortContents\undefined{\gdef\putwordShortContents{Short Contents}}\fi%
67\ifx\putwordAppendix\undefined{\gdef\putwordAppendix{Appendix}}\fi%
68
69% Ignore a token.
70%
71\def\gobble#1{}
72
73\hyphenation{ap-pen-dix}
74\hyphenation{mini-buf-fer mini-buf-fers}
75\hyphenation{eshell}
76
77% Margin to add to right of even pages, to left of odd pages.
78\newdimen \bindingoffset  \bindingoffset=0pt
79\newdimen \normaloffset   \normaloffset=\hoffset
80\newdimen\pagewidth \newdimen\pageheight
81\pagewidth=\hsize \pageheight=\vsize
82
83% Sometimes it is convenient to have everything in the transcript file
84% and nothing on the terminal.  We don't just call \tracingall here,
85% since that produces some useless output on the terminal.
86%
87\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
88\def\loggingall{\tracingcommands2 \tracingstats2
89   \tracingpages1 \tracingoutput1 \tracinglostchars1
90   \tracingmacros2 \tracingparagraphs1 \tracingrestores1
91   \showboxbreadth\maxdimen\showboxdepth\maxdimen
92}%
93
94%---------------------Begin change-----------------------
95%
96%%%% For @cropmarks command.
97% Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986
98%
99\newdimen\cornerlong \newdimen\cornerthick
100\newdimen \topandbottommargin
101\newdimen \outerhsize \newdimen \outervsize
102\cornerlong=1pc\cornerthick=.3pt	% These set size of cropmarks
103\outerhsize=7in
104%\outervsize=9.5in
105% Alternative @smallbook page size is 9.25in
106\outervsize=9.25in
107\topandbottommargin=.75in
108%
109%---------------------End change-----------------------
110
111% \onepageout takes a vbox as an argument.  Note that \pagecontents
112% does insertions itself, but you have to call it yourself.
113\chardef\PAGE=255  \output={\onepageout{\pagecontents\PAGE}}
114\def\onepageout#1{\hoffset=\normaloffset
115\ifodd\pageno  \advance\hoffset by \bindingoffset
116\else \advance\hoffset by -\bindingoffset\fi
117{\escapechar=`\\\relax % makes sure backslash is used in output files.
118\shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}%
119{\let\hsize=\pagewidth \makefootline}}}%
120\advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
121
122%%%% For @cropmarks command %%%%
123
124% Here is a modification of the main output routine for Near East Publications
125% This provides right-angle cropmarks at all four corners.
126% The contents of the page are centerlined into the cropmarks,
127% and any desired binding offset is added as an \hskip on either
128% site of the centerlined box.  (P. A. MacKay, 12 November, 1986)
129%
130\def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up
131{\escapechar=`\\\relax % makes sure backslash is used in output files.
132		 \shipout
133		 \vbox to \outervsize{\hsize=\outerhsize
134                 \vbox{\line{\ewtop\hfill\ewtop}}
135                 \nointerlineskip
136                 \line{\vbox{\moveleft\cornerthick\nstop}
137                       \hfill
138                       \vbox{\moveright\cornerthick\nstop}}
139                 \vskip \topandbottommargin
140                 \centerline{\ifodd\pageno\hskip\bindingoffset\fi
141			\vbox{
142			{\let\hsize=\pagewidth \makeheadline}
143			\pagebody{#1}
144			{\let\hsize=\pagewidth \makefootline}}
145			\ifodd\pageno\else\hskip\bindingoffset\fi}
146		 \vskip \topandbottommargin plus1fill minus1fill
147                 \boxmaxdepth\cornerthick
148                 \line{\vbox{\moveleft\cornerthick\nsbot}
149                       \hfill
150                       \vbox{\moveright\cornerthick\nsbot}}
151                 \nointerlineskip
152                 \vbox{\line{\ewbot\hfill\ewbot}}
153	}}
154  \advancepageno
155  \ifnum\outputpenalty>-20000 \else\dosupereject\fi}
156%
157% Do @cropmarks to get crop marks
158\def\cropmarks{\let\onepageout=\croppageout }
159
160\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
161{\catcode`\@ =11
162\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
163\dimen@=\dp#1 \unvbox#1
164\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
165\ifr@ggedbottom \kern-\dimen@ \vfil \fi}
166}
167
168%
169% Here are the rules for the cropmarks.  Note that they are
170% offset so that the space between them is truly \outerhsize or \outervsize
171% (P. A. MacKay, 12 November, 1986)
172%
173\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
174\def\nstop{\vbox
175  {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
176\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
177\def\nsbot{\vbox
178  {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
179
180% Parse an argument, then pass it to #1.  The argument is the rest of
181% the input line (except we remove a trailing comment).  #1 should be a
182% macro which expects an ordinary undelimited TeX argument.
183%
184\def\parsearg#1{%
185  \let\next = #1%
186  \begingroup
187    \obeylines
188    \futurelet\temp\parseargx
189}
190
191% If the next token is an obeyed space (from an @example environment or
192% the like), remove it and recurse.  Otherwise, we're done.
193\def\parseargx{%
194  % \obeyedspace is defined far below, after the definition of \sepspaces.
195  \ifx\obeyedspace\temp
196    \expandafter\parseargdiscardspace
197  \else
198    \expandafter\parseargline
199  \fi
200}
201
202% Remove a single space (as the delimiter token to the macro call).
203{\obeyspaces %
204 \gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
205
206{\obeylines %
207  \gdef\parseargline#1^^M{%
208    \endgroup % End of the group started in \parsearg.
209    %
210    % First remove any @c comment, then any @comment.
211    % Result of each macro is put in \toks0.
212    \argremovec #1\c\relax %
213    \expandafter\argremovecomment \the\toks0 \comment\relax %
214    %
215    % Call the caller's macro, saved as \next in \parsearg.
216    \expandafter\next\expandafter{\the\toks0}%
217  }%
218}
219
220% Since all \c{,omment} does is throw away the argument, we can let TeX
221% do that for us.  The \relax here is matched by the \relax in the call
222% in \parseargline; it could be more or less anything, its purpose is
223% just to delimit the argument to the \c.
224\def\argremovec#1\c#2\relax{\toks0 = {#1}}
225\def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
226
227% \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
228%    @end itemize  @c foo
229% will have two active spaces as part of the argument with the
230% `itemize'.  Here we remove all active spaces from #1, and assign the
231% result to \toks0.
232%
233% This loses if there are any *other* active characters besides spaces
234% in the argument -- _ ^ +, for example -- since they get expanded.
235% Fortunately, Texinfo does not define any such commands.  (If it ever
236% does, the catcode of the characters in questionwill have to be changed
237% here.)  But this means we cannot call \removeactivespaces as part of
238% \argremovec{,omment}, since @c uses \parsearg, and thus the argument
239% that \parsearg gets might well have any character at all in it.
240%
241\def\removeactivespaces#1{%
242  \begingroup
243    \ignoreactivespaces
244    \edef\temp{#1}%
245    \global\toks0 = \expandafter{\temp}%
246  \endgroup
247}
248
249% Change the active space to expand to nothing.
250%
251\begingroup
252  \obeyspaces
253  \gdef\ignoreactivespaces{\obeyspaces\let =\empty}
254\endgroup
255
256
257\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
258
259%% These are used to keep @begin/@end levels from running away
260%% Call \inENV within environments (after a \begingroup)
261\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
262\def\ENVcheck{%
263\ifENV\errmessage{Still within an environment.  Type Return to continue.}
264\endgroup\fi} % This is not perfect, but it should reduce lossage
265
266% @begin foo  is the same as @foo, for now.
267\newhelp\EMsimple{Type <Return> to continue.}
268
269\outer\def\begin{\parsearg\beginxxx}
270
271\def\beginxxx #1{%
272\expandafter\ifx\csname #1\endcsname\relax
273{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
274\csname #1\endcsname\fi}
275
276% @end foo executes the definition of \Efoo.
277%
278\def\end{\parsearg\endxxx}
279\def\endxxx #1{%
280  \removeactivespaces{#1}%
281  \edef\endthing{\the\toks0}%
282  %
283  \expandafter\ifx\csname E\endthing\endcsname\relax
284    \expandafter\ifx\csname \endthing\endcsname\relax
285      % There's no \foo, i.e., no ``environment'' foo.
286      \errhelp = \EMsimple
287      \errmessage{Undefined command `@end \endthing'}%
288    \else
289      \unmatchedenderror\endthing
290    \fi
291  \else
292    % Everything's ok; the right environment has been started.
293    \csname E\endthing\endcsname
294  \fi
295}
296
297% There is an environment #1, but it hasn't been started.  Give an error.
298%
299\def\unmatchedenderror#1{%
300  \errhelp = \EMsimple
301  \errmessage{This `@end #1' doesn't have a matching `@#1'}%
302}
303
304% Define the control sequence \E#1 to give an unmatched @end error.
305%
306\def\defineunmatchedend#1{%
307  \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}%
308}
309
310
311% Single-spacing is done by various environments (specifically, in
312% \nonfillstart and \quotations).
313\newskip\singlespaceskip \singlespaceskip = \baselineskip
314\def\singlespace{%
315% Why was this kern here?  It messes up equalizing space above and below
316% environments.  --karl, 6may93
317%{\advance \baselineskip by -\singlespaceskip
318%\kern \baselineskip}%
319\baselineskip=\singlespaceskip
320}
321
322%% Simple single-character @ commands
323
324% @@ prints an @
325% Kludge this until the fonts are right (grr).
326\def\@{{\tt \char '100}}
327
328% This is turned off because it was never documented
329% and you can use @w{...} around a quote to suppress ligatures.
330%% Define @` and @' to be the same as ` and '
331%% but suppressing ligatures.
332%\def\`{{`}}
333%\def\'{{'}}
334
335% Used to generate quoted braces.
336
337\def\mylbrace {{\tt \char '173}}
338\def\myrbrace {{\tt \char '175}}
339\let\{=\mylbrace
340\let\}=\myrbrace
341
342% @: forces normal size whitespace following.
343\def\:{\spacefactor=1000 }
344
345% @* forces a line break.
346\def\*{\hfil\break\hbox{}\ignorespaces}
347
348% @. is an end-of-sentence period.
349\def\.{.\spacefactor=3000 }
350
351% @w prevents a word break.  Without the \leavevmode, @w at the
352% beginning of a paragraph, when TeX is still in vertical mode, would
353% produce a whole line of output instead of starting the paragraph.
354\def\w#1{\leavevmode\hbox{#1}}
355
356% @group ... @end group forces ... to be all on one page, by enclosing
357% it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
358% to keep its height that of a normal line.  According to the rules for
359% \topskip (p.114 of the TeXbook), the glue inserted is
360% max (\topskip - \ht (first item), 0).  If that height is large,
361% therefore, no glue is inserted, and the space between the headline and
362% the text is small, which looks bad.
363%
364\def\group{\begingroup
365  \ifnum\catcode13=\active \else
366    \errhelp = \groupinvalidhelp
367    \errmessage{@group invalid in context where filling is enabled}%
368  \fi
369  %
370  % The \vtop we start below produces a box with normal height and large
371  % depth; thus, TeX puts \baselineskip glue before it, and (when the
372  % next line of text is done) \lineskip glue after it.  (See p.82 of
373  % the TeXbook.)  Thus, space below is not quite equal to space
374  % above.  But it's pretty close.
375  \def\Egroup{%
376    \egroup           % End the \vtop.
377    \endgroup         % End the \group.
378  }%
379  %
380  \vtop\bgroup
381    % We have to put a strut on the last line in case the @group is in
382    % the midst of an example, rather than completely enclosing it.
383    % Otherwise, the interline space between the last line of the group
384    % and the first line afterwards is too small.  But we can't put the
385    % strut in \Egroup, since there it would be on a line by itself.
386    % Hence this just inserts a strut at the beginning of each line.
387    \everypar = {\strut}%
388    %
389    % Since we have a strut on every line, we don't need any of TeX's
390    % normal interline spacing.
391    \offinterlineskip
392    %
393    % OK, but now we have to do something about blank
394    % lines in the input in @example-like environments, which normally
395    % just turn into \lisppar, which will insert no space now that we've
396    % turned off the interline space.  Simplest is to make them be an
397    % empty paragraph.
398    \ifx\par\lisppar
399      \edef\par{\leavevmode \par}%
400      %
401      % Reset ^^M's definition to new definition of \par.
402      \obeylines
403    \fi
404    %
405    % We do @comment here in case we are called inside an environment,
406    % such as @example, where each end-of-line in the input causes an
407    % end-of-line in the output.  We don't want the end-of-line after
408    % the `@group' to put extra space in the output.  Since @group
409    % should appear on a line by itself (according to the Texinfo
410    % manual), we don't worry about eating any user text.
411    \comment
412}
413%
414% TeX puts in an \escapechar (i.e., `@') at the beginning of the help
415% message, so this ends up printing `@group can only ...'.
416%
417\newhelp\groupinvalidhelp{%
418group can only be used in environments such as @example,^^J%
419where each line of input produces a line of output.}
420
421% @need space-in-mils
422% forces a page break if there is not space-in-mils remaining.
423
424\newdimen\mil  \mil=0.001in
425
426\def\need{\parsearg\needx}
427
428% Old definition--didn't work.
429%\def\needx #1{\par %
430%% This method tries to make TeX break the page naturally
431%% if the depth of the box does not fit.
432%{\baselineskip=0pt%
433%\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000
434%\prevdepth=-1000pt
435%}}
436
437\def\needx#1{%
438  % Go into vertical mode, so we don't make a big box in the middle of a
439  % paragraph.
440  \par
441  %
442  % Don't add any leading before our big empty box, but allow a page
443  % break, since the best break might be right here.
444  \allowbreak
445  \nointerlineskip
446  \vtop to #1\mil{\vfil}%
447  %
448  % TeX does not even consider page breaks if a penalty added to the
449  % main vertical list is 10000 or more.  But in order to see if the
450  % empty box we just added fits on the page, we must make it consider
451  % page breaks.  On the other hand, we don't want to actually break the
452  % page after the empty box.  So we use a penalty of 9999.
453  %
454  % There is an extremely small chance that TeX will actually break the
455  % page at this \penalty, if there are no other feasible breakpoints in
456  % sight.  (If the user is using lots of big @group commands, which
457  % almost-but-not-quite fill up a page, TeX will have a hard time doing
458  % good page breaking, for example.)  However, I could not construct an
459  % example where a page broke at this \penalty; if it happens in a real
460  % document, then we can reconsider our strategy.
461  \penalty9999
462  %
463  % Back up by the size of the box, whether we did a page break or not.
464  \kern -#1\mil
465  %
466  % Do not allow a page break right after this kern.
467  \nobreak
468}
469
470% @br   forces paragraph break
471
472\let\br = \par
473
474% @dots{}  output some dots
475
476\def\dots{.$\,$.$\,$.\:}
477
478% @page    forces the start of a new page
479
480\def\page{\par\vfill\supereject}
481
482% @exdent text....
483% outputs text on separate line in roman font, starting at standard page margin
484
485% This records the amount of indent in the innermost environment.
486% That's how much \exdent should take out.
487\newskip\exdentamount
488
489% This defn is used inside fill environments such as @defun.
490\def\exdent{\parsearg\exdentyyy}
491\def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
492
493% This defn is used inside nofill environments such as @example.
494\def\nofillexdent{\parsearg\nofillexdentyyy}
495\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
496\leftline{\hskip\leftskip{\rm#1}}}}
497
498%\hbox{{\rm#1}}\hfil\break}}
499
500% @include file    insert text of that file as input.
501
502\def\include{\parsearg\includezzz}
503%Use \input\thisfile to avoid blank after \input, which may be an active
504%char (in which case the blank would become the \input argument).
505%The grouping keeps the value of \thisfile correct even when @include
506%is nested.
507\def\includezzz #1{\begingroup
508\def\thisfile{#1}\input\thisfile
509\endgroup}
510
511\def\thisfile{}
512
513% @center line   outputs that line, centered
514
515\def\center{\parsearg\centerzzz}
516\def\centerzzz #1{{\advance\hsize by -\leftskip
517\advance\hsize by -\rightskip
518\centerline{#1}}}
519
520% @sp n   outputs n lines of vertical space
521
522\def\sp{\parsearg\spxxx}
523\def\spxxx #1{\par \vskip #1\baselineskip}
524
525% @comment ...line which is ignored...
526% @c is the same as @comment
527% @ignore ... @end ignore  is another way to write a comment
528
529\def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other%
530\parsearg \commentxxx}
531
532\def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 }
533
534\let\c=\comment
535
536% Prevent errors for section commands.
537% Used in @ignore and in failing conditionals.
538\def\ignoresections{%
539\let\chapter=\relax
540\let\unnumbered=\relax
541\let\top=\relax
542\let\unnumberedsec=\relax
543\let\unnumberedsection=\relax
544\let\unnumberedsubsec=\relax
545\let\unnumberedsubsection=\relax
546\let\unnumberedsubsubsec=\relax
547\let\unnumberedsubsubsection=\relax
548\let\section=\relax
549\let\subsec=\relax
550\let\subsubsec=\relax
551\let\subsection=\relax
552\let\subsubsection=\relax
553\let\appendix=\relax
554\let\appendixsec=\relax
555\let\appendixsection=\relax
556\let\appendixsubsec=\relax
557\let\appendixsubsection=\relax
558\let\appendixsubsubsec=\relax
559\let\appendixsubsubsection=\relax
560\let\contents=\relax
561\let\smallbook=\relax
562\let\titlepage=\relax
563}
564
565% Used in nested conditionals, where we have to parse the Texinfo source
566% and so want to turn off most commands, in case they are used
567% incorrectly.
568%
569\def\ignoremorecommands{%
570  \let\defcv = \relax
571  \let\deffn = \relax
572  \let\deffnx = \relax
573  \let\defindex = \relax
574  \let\defivar = \relax
575  \let\defmac = \relax
576  \let\defmethod = \relax
577  \let\defop = \relax
578  \let\defopt = \relax
579  \let\defspec = \relax
580  \let\deftp = \relax
581  \let\deftypefn = \relax
582  \let\deftypefun = \relax
583  \let\deftypevar = \relax
584  \let\deftypevr = \relax
585  \let\defun = \relax
586  \let\defvar = \relax
587  \let\defvr = \relax
588  \let\ref = \relax
589  \let\xref = \relax
590  \let\printindex = \relax
591  \let\pxref = \relax
592  \let\settitle = \relax
593  \let\include = \relax
594  \let\lowersections = \relax
595  \let\down = \relax
596  \let\raisesections = \relax
597  \let\up = \relax
598  \let\set = \relax
599  \let\clear = \relax
600  \let\item = \relax
601  \let\message = \relax
602}
603
604% Ignore @ignore ... @end ignore.
605%
606\def\ignore{\doignore{ignore}}
607
608% Also ignore @ifinfo, @menu, and @direntry text.
609%
610\def\ifinfo{\doignore{ifinfo}}
611\def\menu{\doignore{menu}}
612\def\direntry{\doignore{direntry}}
613
614% Ignore text until a line `@end #1'.
615%
616\def\doignore#1{\begingroup
617  % Don't complain about control sequences we have declared \outer.
618  \ignoresections
619  %
620  % Define a command to swallow text until we reach `@end #1'.
621  \long\def\doignoretext##1\end #1{\enddoignore}%
622  %
623  % Make sure that spaces turn into tokens that match what \doignoretext wants.
624  \catcode32 = 10
625  %
626  % And now expand that command.
627  \doignoretext
628}
629
630% What we do to finish off ignored text.
631%
632\def\enddoignore{\endgroup\ignorespaces}%
633
634\newif\ifwarnedobs\warnedobsfalse
635\def\obstexwarn{%
636  \ifwarnedobs\relax\else
637  % We need to warn folks that they may have trouble with TeX 3.0.
638  % This uses \immediate\write16 rather than \message to get newlines.
639    \immediate\write16{}
640    \immediate\write16{***WARNING*** for users of Unix TeX 3.0!}
641    \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).}
642    \immediate\write16{If you are running another version of TeX, relax.}
643    \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
644    \immediate\write16{  Then upgrade your TeX installation if you can.}
645    \immediate\write16{If you are stuck with version 3.0, run the}
646    \immediate\write16{  script ``tex3patch'' from the Texinfo distribution}
647    \immediate\write16{  to use a workaround.}
648    \immediate\write16{}
649    \warnedobstrue
650    \fi
651}
652
653% **In TeX 3.0, setting text in \nullfont hangs tex.  For a
654% workaround (which requires the file ``dummy.tfm'' to be installed),
655% uncomment the following line:
656%%%%%\font\nullfont=dummy\let\obstexwarn=\relax
657
658% Ignore text, except that we keep track of conditional commands for
659% purposes of nesting, up to an `@end #1' command.
660%
661\def\nestedignore#1{%
662  \obstexwarn
663  % We must actually expand the ignored text to look for the @end
664  % command, so that nested ignore constructs work.  Thus, we put the
665  % text into a \vbox and then do nothing with the result.  To minimize
666  % the change of memory overflow, we follow the approach outlined on
667  % page 401 of the TeXbook: make the current font be a dummy font.
668  %
669  \setbox0 = \vbox\bgroup
670    % Don't complain about control sequences we have declared \outer.
671    \ignoresections
672    %
673    % Define `@end #1' to end the box, which will in turn undefine the
674    % @end command again.
675    \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
676    %
677    % We are going to be parsing Texinfo commands.  Most cause no
678    % trouble when they are used incorrectly, but some commands do
679    % complicated argument parsing or otherwise get confused, so we
680    % undefine them.
681    %
682    % We can't do anything about stray @-signs, unfortunately;
683    % they'll produce `undefined control sequence' errors.
684    \ignoremorecommands
685    %
686    % Set the current font to be \nullfont, a TeX primitive, and define
687    % all the font commands to also use \nullfont.  We don't use
688    % dummy.tfm, as suggested in the TeXbook, because not all sites
689    % might have that installed.  Therefore, math mode will still
690    % produce output, but that should be an extremely small amount of
691    % stuff compared to the main input.
692    %
693    \nullfont
694    \let\tenrm = \nullfont  \let\tenit = \nullfont  \let\tensl = \nullfont
695    \let\tenbf = \nullfont  \let\tentt = \nullfont  \let\smallcaps = \nullfont
696    \let\tensf = \nullfont
697    % Similarly for index fonts (mostly for their use in
698    % smallexample)
699    \let\indrm = \nullfont  \let\indit = \nullfont  \let\indsl = \nullfont
700    \let\indbf = \nullfont  \let\indtt = \nullfont  \let\indsc = \nullfont
701    \let\indsf = \nullfont
702    %
703    % Don't complain when characters are missing from the fonts.
704    \tracinglostchars = 0
705    %
706    % Don't bother to do space factor calculations.
707    \frenchspacing
708    %
709    % Don't report underfull hboxes.
710    \hbadness = 10000
711    %
712    % Do minimal line-breaking.
713    \pretolerance = 10000
714    %
715    % Do not execute instructions in @tex
716    \def\tex{\doignore{tex}}
717}
718
719% @set VAR sets the variable VAR to an empty value.
720% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
721%
722% Since we want to separate VAR from REST-OF-LINE (which might be
723% empty), we can't just use \parsearg; we have to insert a space of our
724% own to delimit the rest of the line, and then take it out again if we
725% didn't need it.
726%
727\def\set{\parsearg\setxxx}
728\def\setxxx#1{\setyyy#1 \endsetyyy}
729\def\setyyy#1 #2\endsetyyy{%
730  \def\temp{#2}%
731  \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty
732  \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted.
733  \fi
734}
735\def\setzzz#1#2 \endsetzzz{\expandafter\xdef\csname SET#1\endcsname{#2}}
736
737% @clear VAR clears (i.e., unsets) the variable VAR.
738%
739\def\clear{\parsearg\clearxxx}
740\def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax}
741
742% @value{foo} gets the text saved in variable foo.
743%
744\def\value#1{\expandafter
745		\ifx\csname SET#1\endcsname\relax
746			{\{No value for ``#1''\}}
747		\else \csname SET#1\endcsname \fi}
748
749% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
750% with @set.
751%
752\def\ifset{\parsearg\ifsetxxx}
753\def\ifsetxxx #1{%
754  \expandafter\ifx\csname SET#1\endcsname\relax
755    \expandafter\ifsetfail
756  \else
757    \expandafter\ifsetsucceed
758  \fi
759}
760\def\ifsetsucceed{\conditionalsucceed{ifset}}
761\def\ifsetfail{\nestedignore{ifset}}
762\defineunmatchedend{ifset}
763
764% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
765% defined with @set, or has been undefined with @clear.
766%
767\def\ifclear{\parsearg\ifclearxxx}
768\def\ifclearxxx #1{%
769  \expandafter\ifx\csname SET#1\endcsname\relax
770    \expandafter\ifclearsucceed
771  \else
772    \expandafter\ifclearfail
773  \fi
774}
775\def\ifclearsucceed{\conditionalsucceed{ifclear}}
776\def\ifclearfail{\nestedignore{ifclear}}
777\defineunmatchedend{ifclear}
778
779% @iftex always succeeds; we read the text following, through @end
780% iftex).  But `@end iftex' should be valid only after an @iftex.
781%
782\def\iftex{\conditionalsucceed{iftex}}
783\defineunmatchedend{iftex}
784
785% We can't just want to start a group at @iftex (for example) and end it
786% at @end iftex, since then @set commands inside the conditional have no
787% effect (they'd get reverted at the end of the group).  So we must
788% define \Eiftex to redefine itself to be its previous value.  (We can't
789% just define it to fail again with an ``unmatched end'' error, since
790% the @ifset might be nested.)
791%
792\def\conditionalsucceed#1{%
793  \edef\temp{%
794    % Remember the current value of \E#1.
795    \let\nece{prevE#1} = \nece{E#1}%
796    %
797    % At the `@end #1', redefine \E#1 to be its previous value.
798    \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
799  }%
800  \temp
801}
802
803% We need to expand lots of \csname's, but we don't want to expand the
804% control sequences after we've constructed them.
805%
806\def\nece#1{\expandafter\noexpand\csname#1\endcsname}
807
808% @asis just yields its argument.  Used with @table, for example.
809%
810\def\asis#1{#1}
811
812% @math means output in math mode.
813% We don't use $'s directly in the definition of \math because control
814% sequences like \math are expanded when the toc file is written.  Then,
815% we read the toc file back, the $'s will be normal characters (as they
816% should be, according to the definition of Texinfo).  So we must use a
817% control sequence to switch into and out of math mode.
818%
819% This isn't quite enough for @math to work properly in indices, but it
820% seems unlikely it will ever be needed there.
821%
822\let\implicitmath = $
823\def\math#1{\implicitmath #1\implicitmath}
824
825% @bullet and @minus need the same treatment as @math, just above.
826\def\bullet{\implicitmath\ptexbullet\implicitmath}
827\def\minus{\implicitmath-\implicitmath}
828
829\def\node{\ENVcheck\parsearg\nodezzz}
830\def\nodezzz#1{\nodexxx [#1,]}
831\def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
832\let\nwnode=\node
833\let\lastnode=\relax
834
835\def\donoderef{\ifx\lastnode\relax\else
836\expandafter\expandafter\expandafter\setref{\lastnode}\fi
837\let\lastnode=\relax}
838
839\def\unnumbnoderef{\ifx\lastnode\relax\else
840\expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi
841\let\lastnode=\relax}
842
843\def\appendixnoderef{\ifx\lastnode\relax\else
844\expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi
845\let\lastnode=\relax}
846
847\let\refill=\relax
848
849% @setfilename is done at the beginning of every texinfo file.
850% So open here the files we need to have open while reading the input.
851% This makes it possible to make a .fmt file for texinfo.
852\def\setfilename{%
853   \readauxfile
854   \opencontents
855   \openindices
856   \fixbackslash  % Turn off hack to swallow `\input texinfo'.
857   \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
858   \comment % Ignore the actual filename.
859}
860
861\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
862
863\def\inforef #1{\inforefzzz #1,,,,**}
864\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
865  node \samp{\ignorespaces#1{}}}
866
867\message{fonts,}
868
869% Font-change commands.
870
871% Texinfo supports the sans serif font style, which plain TeX does not.
872% So we set up a \sf analogous to plain's \rm, etc.
873\newfam\sffam
874\def\sf{\fam=\sffam \tensf}
875\let\li = \sf % Sometimes we call it \li, not \sf.
876
877%% Try out Computer Modern fonts at \magstephalf
878\let\mainmagstep=\magstephalf
879
880\ifx\bigger\relax
881\let\mainmagstep=\magstep1
882\font\textrm=cmr12
883\font\texttt=cmtt12
884\else
885\font\textrm=cmr10 scaled \mainmagstep
886\font\texttt=cmtt10 scaled \mainmagstep
887\fi
888% Instead of cmb10, you many want to use cmbx10.
889% cmbx10 is a prettier font on its own, but cmb10
890% looks better when embedded in a line with cmr10.
891\font\textbf=cmb10 scaled \mainmagstep
892\font\textit=cmti10 scaled \mainmagstep
893\font\textsl=cmsl10 scaled \mainmagstep
894\font\textsf=cmss10 scaled \mainmagstep
895\font\textsc=cmcsc10 scaled \mainmagstep
896\font\texti=cmmi10 scaled \mainmagstep
897\font\textsy=cmsy10 scaled \mainmagstep
898
899% A few fonts for @defun, etc.
900\font\defbf=cmbx10 scaled \magstep1 %was 1314
901\font\deftt=cmtt10 scaled \magstep1
902\def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
903
904% Fonts for indices and small examples.
905% We actually use the slanted font rather than the italic,
906% because texinfo normally uses the slanted fonts for that.
907% Do not make many font distinctions in general in the index, since they
908% aren't very useful.
909\font\ninett=cmtt9
910\font\indrm=cmr9
911\font\indit=cmsl9
912\let\indsl=\indit
913\let\indtt=\ninett
914\let\indsf=\indrm
915\let\indbf=\indrm
916\let\indsc=\indrm
917\font\indi=cmmi9
918\font\indsy=cmsy9
919
920% Fonts for headings
921\font\chaprm=cmbx12 scaled \magstep2
922\font\chapit=cmti12 scaled \magstep2
923\font\chapsl=cmsl12 scaled \magstep2
924\font\chaptt=cmtt12 scaled \magstep2
925\font\chapsf=cmss12 scaled \magstep2
926\let\chapbf=\chaprm
927\font\chapsc=cmcsc10 scaled\magstep3
928\font\chapi=cmmi12 scaled \magstep2
929\font\chapsy=cmsy10 scaled \magstep3
930
931\font\secrm=cmbx12 scaled \magstep1
932\font\secit=cmti12 scaled \magstep1
933\font\secsl=cmsl12 scaled \magstep1
934\font\sectt=cmtt12 scaled \magstep1
935\font\secsf=cmss12 scaled \magstep1
936\font\secbf=cmbx12 scaled \magstep1
937\font\secsc=cmcsc10 scaled\magstep2
938\font\seci=cmmi12 scaled \magstep1
939\font\secsy=cmsy10 scaled \magstep2
940
941% \font\ssecrm=cmbx10 scaled \magstep1    % This size an font looked bad.
942% \font\ssecit=cmti10 scaled \magstep1    % The letters were too crowded.
943% \font\ssecsl=cmsl10 scaled \magstep1
944% \font\ssectt=cmtt10 scaled \magstep1
945% \font\ssecsf=cmss10 scaled \magstep1
946
947%\font\ssecrm=cmb10 scaled 1315	% Note the use of cmb rather than cmbx.
948%\font\ssecit=cmti10 scaled 1315	% Also, the size is a little larger than
949%\font\ssecsl=cmsl10 scaled 1315	% being scaled magstep1.
950%\font\ssectt=cmtt10 scaled 1315
951%\font\ssecsf=cmss10 scaled 1315
952
953%\let\ssecbf=\ssecrm
954
955\font\ssecrm=cmbx12 scaled \magstephalf
956\font\ssecit=cmti12 scaled \magstephalf
957\font\ssecsl=cmsl12 scaled \magstephalf
958\font\ssectt=cmtt12 scaled \magstephalf
959\font\ssecsf=cmss12 scaled \magstephalf
960\font\ssecbf=cmbx12 scaled \magstephalf
961\font\ssecsc=cmcsc10 scaled \magstep1
962\font\sseci=cmmi12 scaled \magstephalf
963\font\ssecsy=cmsy10 scaled \magstep1
964% The smallcaps and symbol fonts should actually be scaled \magstep1.5,
965% but that is not a standard magnification.
966
967% Fonts for title page:
968\font\titlerm = cmbx12 scaled \magstep3
969\let\authorrm = \secrm
970
971% In order for the font changes to affect most math symbols and letters,
972% we have to define the \textfont of the standard families.  Since
973% texinfo doesn't allow for producing subscripts and superscripts, we
974% don't bother to reset \scriptfont and \scriptscriptfont (which would
975% also require loading a lot more fonts).
976%
977\def\resetmathfonts{%
978  \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy
979  \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf
980  \textfont\ttfam = \tentt \textfont\sffam = \tensf
981}
982
983
984% The font-changing commands redefine the meanings of \tenSTYLE, instead
985% of just \STYLE.  We do this so that font changes will continue to work
986% in math mode, where it is the current \fam that is relevant in most
987% cases, not the current.  Plain TeX does, for example,
988% \def\bf{\fam=\bffam \tenbf}  By redefining \tenbf, we obviate the need
989% to redefine \bf itself.
990\def\textfonts{%
991  \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
992  \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
993  \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
994  \resetmathfonts}
995\def\chapfonts{%
996  \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
997  \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
998  \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
999  \resetmathfonts}
1000\def\secfonts{%
1001  \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
1002  \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
1003  \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
1004  \resetmathfonts}
1005\def\subsecfonts{%
1006  \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
1007  \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
1008  \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
1009  \resetmathfonts}
1010\def\indexfonts{%
1011  \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl
1012  \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc
1013  \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy
1014  \resetmathfonts}
1015
1016% Set up the default fonts, so we can use them for creating boxes.
1017%
1018\textfonts
1019
1020% Count depth in font-changes, for error checks
1021\newcount\fontdepth \fontdepth=0
1022
1023% Fonts for short table of contents.
1024\font\shortcontrm=cmr12
1025\font\shortcontbf=cmbx12
1026\font\shortcontsl=cmsl12
1027
1028%% Add scribe-like font environments, plus @l for inline lisp (usually sans
1029%% serif) and @ii for TeX italic
1030
1031% \smartitalic{ARG} outputs arg in italics, followed by an italic correction
1032% unless the following character is such as not to need one.
1033\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
1034\def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx}
1035
1036\let\i=\smartitalic
1037\let\var=\smartitalic
1038\let\dfn=\smartitalic
1039\let\emph=\smartitalic
1040\let\cite=\smartitalic
1041
1042\def\b#1{{\bf #1}}
1043\let\strong=\b
1044
1045% We can't just use \exhyphenpenalty, because that only has effect at
1046% the end of a paragraph.  Restore normal hyphenation at the end of the
1047% group within which \nohyphenation is presumably called.
1048%
1049\def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
1050\def\restorehyphenation{\hyphenchar\font = `- }
1051
1052\def\t#1{%
1053  {\tt \nohyphenation \rawbackslash \frenchspacing #1}%
1054  \null
1055}
1056\let\ttfont = \t
1057%\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null}
1058\def\samp #1{`\tclose{#1}'\null}
1059\def\key #1{{\tt \nohyphenation \uppercase{#1}}\null}
1060\def\ctrl #1{{\tt \rawbackslash \hat}#1}
1061
1062\let\file=\samp
1063
1064% @code is a modification of @t,
1065% which makes spaces the same size as normal in the surrounding text.
1066\def\tclose#1{%
1067  {%
1068    % Change normal interword space to be same as for the current font.
1069    \spaceskip = \fontdimen2\font
1070    %
1071    % Switch to typewriter.
1072    \tt
1073    %
1074    % But `\ ' produces the large typewriter interword space.
1075    \def\ {{\spaceskip = 0pt{} }}%
1076    %
1077    % Turn off hyphenation.
1078    \nohyphenation
1079    %
1080    \rawbackslash
1081    \frenchspacing
1082    #1%
1083  }%
1084  \null
1085}
1086
1087% We *must* turn on hyphenation at `-' and `_' in \code.
1088% Otherwise, it is too hard to avoid overful hboxes
1089% in the Emacs manual, the Library manual, etc.
1090
1091% Unfortunately, TeX uses one parameter (\hyphenchar) to control
1092% both hyphenation at - and hyphenation within words.
1093% We must therefore turn them both off (\tclose does that)
1094% and arrange explicitly to hyphenate an a dash.
1095%  -- rms.
1096{
1097\catcode`\-=\active
1098\catcode`\_=\active
1099\global\def\code{\begingroup \catcode`\-=\active \let-\codedash \catcode`\_=\active \let_\codeunder \codex}
1100% The following is used by \doprintindex to insure that long function names
1101% wrap around.  It is necessary for - and _ to be active before the index is
1102% read from the file, as \entry parses the arguments long before \code is
1103% ever called.  -- mycroft
1104\global\def\indexbreaks{\catcode`\-=\active \let-\realdash \catcode`\_=\active \let_\realunder}
1105}
1106\def\realdash{-}
1107\def\realunder{_}
1108\def\codedash{-\discretionary{}{}{}}
1109\def\codeunder{\normalunderscore\discretionary{}{}{}}
1110\def\codex #1{\tclose{#1}\endgroup}
1111
1112%\let\exp=\tclose  %Was temporary
1113
1114% @kbd is like @code, except that if the argument is just one @key command,
1115% then @kbd has no effect.
1116
1117\def\xkey{\key}
1118\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
1119\ifx\one\xkey\ifx\threex\three \key{#2}%
1120\else\tclose{\look}\fi
1121\else\tclose{\look}\fi}
1122
1123% Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
1124% argument is to make the input look right: @dmn{pt} instead of
1125% @dmn{}pt.
1126%
1127\def\dmn#1{\thinspace #1}
1128
1129\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
1130
1131\def\l#1{{\li #1}\null}		%
1132
1133\def\r#1{{\rm #1}}		% roman font
1134% Use of \lowercase was suggested.
1135\def\sc#1{{\smallcaps#1}}	% smallcaps font
1136\def\ii#1{{\it #1}}		% italic font
1137
1138\message{page headings,}
1139
1140\newskip\titlepagetopglue \titlepagetopglue = 1.5in
1141\newskip\titlepagebottomglue \titlepagebottomglue = 2pc
1142
1143% First the title page.  Must do @settitle before @titlepage.
1144\def\titlefont#1{{\titlerm #1}}
1145
1146\newif\ifseenauthor
1147\newif\iffinishedtitlepage
1148
1149\def\shorttitlepage{\parsearg\shorttitlepagezzz}
1150\def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
1151	\endgroup\page\hbox{}\page}
1152
1153\def\titlepage{\begingroup \parindent=0pt \textfonts
1154   \let\subtitlerm=\tenrm
1155% I deinstalled the following change because \cmr12 is undefined.
1156% This change was not in the ChangeLog anyway.  --rms.
1157%   \let\subtitlerm=\cmr12
1158   \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
1159   %
1160   \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
1161   %
1162   % Leave some space at the very top of the page.
1163   \vglue\titlepagetopglue
1164   %
1165   % Now you can print the title using @title.
1166   \def\title{\parsearg\titlezzz}%
1167   \def\titlezzz##1{\leftline{\titlefont{##1}}
1168		    % print a rule at the page bottom also.
1169		    \finishedtitlepagefalse
1170		    \vskip4pt \hrule height 4pt width \hsize \vskip4pt}%
1171   % No rule at page bottom unless we print one at the top with @title.
1172   \finishedtitlepagetrue
1173   %
1174   % Now you can put text using @subtitle.
1175   \def\subtitle{\parsearg\subtitlezzz}%
1176   \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
1177   %
1178   % @author should come last, but may come many times.
1179   \def\author{\parsearg\authorzzz}%
1180   \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
1181      {\authorfont \leftline{##1}}}%
1182   %
1183   % Most title ``pages'' are actually two pages long, with space
1184   % at the top of the second.  We don't want the ragged left on the second.
1185   \let\oldpage = \page
1186   \def\page{%
1187      \iffinishedtitlepage\else
1188	 \finishtitlepage
1189      \fi
1190      \oldpage
1191      \let\page = \oldpage
1192      \hbox{}}%
1193%   \def\page{\oldpage \hbox{}}
1194}
1195
1196\def\Etitlepage{%
1197   \iffinishedtitlepage\else
1198      \finishtitlepage
1199   \fi
1200   % It is important to do the page break before ending the group,
1201   % because the headline and footline are only empty inside the group.
1202   % If we use the new definition of \page, we always get a blank page
1203   % after the title page, which we certainly don't want.
1204   \oldpage
1205   \endgroup
1206   \HEADINGSon
1207}
1208
1209\def\finishtitlepage{%
1210   \vskip4pt \hrule height 2pt width \hsize
1211   \vskip\titlepagebottomglue
1212   \finishedtitlepagetrue
1213}
1214
1215%%% Set up page headings and footings.
1216
1217\let\thispage=\folio
1218
1219\newtoks \evenheadline    % Token sequence for heading line of even pages
1220\newtoks \oddheadline     % Token sequence for heading line of odd pages
1221\newtoks \evenfootline    % Token sequence for footing line of even pages
1222\newtoks \oddfootline     % Token sequence for footing line of odd pages
1223
1224% Now make Tex use those variables
1225\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
1226                            \else \the\evenheadline \fi}}
1227\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
1228                            \else \the\evenfootline \fi}\HEADINGShook}
1229\let\HEADINGShook=\relax
1230
1231% Commands to set those variables.
1232% For example, this is what  @headings on  does
1233% @evenheading @thistitle|@thispage|@thischapter
1234% @oddheading @thischapter|@thispage|@thistitle
1235% @evenfooting @thisfile||
1236% @oddfooting ||@thisfile
1237
1238\def\evenheading{\parsearg\evenheadingxxx}
1239\def\oddheading{\parsearg\oddheadingxxx}
1240\def\everyheading{\parsearg\everyheadingxxx}
1241
1242\def\evenfooting{\parsearg\evenfootingxxx}
1243\def\oddfooting{\parsearg\oddfootingxxx}
1244\def\everyfooting{\parsearg\everyfootingxxx}
1245
1246{\catcode`\@=0 %
1247
1248\gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
1249\gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
1250\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1251
1252\gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
1253\gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
1254\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1255
1256\gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish}
1257\gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{%
1258\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
1259\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1260
1261\gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
1262\gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
1263\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1264
1265\gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
1266\gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
1267\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1268
1269\gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish}
1270\gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{%
1271\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
1272\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1273%
1274}% unbind the catcode of @.
1275
1276% @headings double	turns headings on for double-sided printing.
1277% @headings single	turns headings on for single-sided printing.
1278% @headings off		turns them off.
1279% @headings on		same as @headings double, retained for compatibility.
1280% @headings after	turns on double-sided headings after this page.
1281% @headings doubleafter	turns on double-sided headings after this page.
1282% @headings singleafter turns on single-sided headings after this page.
1283% By default, they are off.
1284
1285\def\headings #1 {\csname HEADINGS#1\endcsname}
1286
1287\def\HEADINGSoff{
1288\global\evenheadline={\hfil} \global\evenfootline={\hfil}
1289\global\oddheadline={\hfil} \global\oddfootline={\hfil}}
1290\HEADINGSoff
1291% When we turn headings on, set the page number to 1.
1292% For double-sided printing, put current file name in lower left corner,
1293% chapter name on inside top of right hand pages, document
1294% title on inside top of left hand pages, and page numbers on outside top
1295% edge of all pages.
1296\def\HEADINGSdouble{
1297%\pagealignmacro
1298\global\pageno=1
1299\global\evenfootline={\hfil}
1300\global\oddfootline={\hfil}
1301\global\evenheadline={\line{\folio\hfil\thistitle}}
1302\global\oddheadline={\line{\thischapter\hfil\folio}}
1303}
1304% For single-sided printing, chapter title goes across top left of page,
1305% page number on top right.
1306\def\HEADINGSsingle{
1307%\pagealignmacro
1308\global\pageno=1
1309\global\evenfootline={\hfil}
1310\global\oddfootline={\hfil}
1311\global\evenheadline={\line{\thischapter\hfil\folio}}
1312\global\oddheadline={\line{\thischapter\hfil\folio}}
1313}
1314\def\HEADINGSon{\HEADINGSdouble}
1315
1316\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
1317\let\HEADINGSdoubleafter=\HEADINGSafter
1318\def\HEADINGSdoublex{%
1319\global\evenfootline={\hfil}
1320\global\oddfootline={\hfil}
1321\global\evenheadline={\line{\folio\hfil\thistitle}}
1322\global\oddheadline={\line{\thischapter\hfil\folio}}
1323}
1324
1325\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
1326\def\HEADINGSsinglex{%
1327\global\evenfootline={\hfil}
1328\global\oddfootline={\hfil}
1329\global\evenheadline={\line{\thischapter\hfil\folio}}
1330\global\oddheadline={\line{\thischapter\hfil\folio}}
1331}
1332
1333% Subroutines used in generating headings
1334% Produces Day Month Year style of output.
1335\def\today{\number\day\space
1336\ifcase\month\or
1337January\or February\or March\or April\or May\or June\or
1338July\or August\or September\or October\or November\or December\fi
1339\space\number\year}
1340
1341% Use this if you want the Month Day, Year style of output.
1342%\def\today{\ifcase\month\or
1343%January\or February\or March\or April\or May\or June\or
1344%July\or August\or September\or October\or November\or December\fi
1345%\space\number\day, \number\year}
1346
1347% @settitle line...  specifies the title of the document, for headings
1348% It generates no output of its own
1349
1350\def\thistitle{No Title}
1351\def\settitle{\parsearg\settitlezzz}
1352\def\settitlezzz #1{\gdef\thistitle{#1}}
1353
1354\message{tables,}
1355
1356% @tabs -- simple alignment
1357
1358% These don't work.  For one thing, \+ is defined as outer.
1359% So these macros cannot even be defined.
1360
1361%\def\tabs{\parsearg\tabszzz}
1362%\def\tabszzz #1{\settabs\+#1\cr}
1363%\def\tabline{\parsearg\tablinezzz}
1364%\def\tablinezzz #1{\+#1\cr}
1365%\def\&{&}
1366
1367% Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x).
1368
1369% default indentation of table text
1370\newdimen\tableindent \tableindent=.8in
1371% default indentation of @itemize and @enumerate text
1372\newdimen\itemindent  \itemindent=.3in
1373% margin between end of table item and start of table text.
1374\newdimen\itemmargin  \itemmargin=.1in
1375
1376% used internally for \itemindent minus \itemmargin
1377\newdimen\itemmax
1378
1379% Note @table, @vtable, and @vtable define @item, @itemx, etc., with
1380% these defs.
1381% They also define \itemindex
1382% to index the item name in whatever manner is desired (perhaps none).
1383
1384\newif\ifitemxneedsnegativevskip
1385
1386\def\itemxpar{\par\ifitemxneedsnegativevskip\vskip-\parskip\nobreak\fi}
1387
1388\def\internalBitem{\smallbreak \parsearg\itemzzz}
1389\def\internalBitemx{\itemxpar \parsearg\itemzzz}
1390
1391\def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
1392\def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz}
1393
1394\def\internalBkitem{\smallbreak \parsearg\kitemzzz}
1395\def\internalBkitemx{\itemxpar \parsearg\kitemzzz}
1396
1397\def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
1398                 \itemzzz {#1}}
1399
1400\def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
1401                 \itemzzz {#1}}
1402
1403\def\itemzzz #1{\begingroup %
1404  \advance\hsize by -\rightskip
1405  \advance\hsize by -\tableindent
1406  \setbox0=\hbox{\itemfont{#1}}%
1407  \itemindex{#1}%
1408  \nobreak % This prevents a break before @itemx.
1409  %
1410  % Be sure we are not still in the middle of a paragraph.
1411  %{\parskip = 0in
1412  %\par
1413  %}%
1414  %
1415  % If the item text does not fit in the space we have, put it on a line
1416  % by itself, and do not allow a page break either before or after that
1417  % line.  We do not start a paragraph here because then if the next
1418  % command is, e.g., @kindex, the whatsit would get put into the
1419  % horizontal list on a line by itself, resulting in extra blank space.
1420  \ifdim \wd0>\itemmax
1421    %
1422    % Make this a paragraph so we get the \parskip glue and wrapping,
1423    % but leave it ragged-right.
1424    \begingroup
1425      \advance\leftskip by-\tableindent
1426      \advance\hsize by\tableindent
1427      \advance\rightskip by0pt plus1fil
1428      \leavevmode\unhbox0\par
1429    \endgroup
1430    %
1431    % We're going to be starting a paragraph, but we don't want the
1432    % \parskip glue -- logically it's part of the @item we just started.
1433    \nobreak \vskip-\parskip
1434    %
1435    % Stop a page break at the \parskip glue coming up.  Unfortunately
1436    % we can't prevent a possible page break at the following
1437    % \baselineskip glue.
1438    \nobreak
1439    \endgroup
1440    \itemxneedsnegativevskipfalse
1441  \else
1442    % The item text fits into the space.  Start a paragraph, so that the
1443    % following text (if any) will end up on the same line.  Since that
1444    % text will be indented by \tableindent, we make the item text be in
1445    % a zero-width box.
1446    \noindent
1447    \rlap{\hskip -\tableindent\box0}\ignorespaces%
1448    \endgroup%
1449    \itemxneedsnegativevskiptrue%
1450  \fi
1451}
1452
1453\def\item{\errmessage{@item while not in a table}}
1454\def\itemx{\errmessage{@itemx while not in a table}}
1455\def\kitem{\errmessage{@kitem while not in a table}}
1456\def\kitemx{\errmessage{@kitemx while not in a table}}
1457\def\xitem{\errmessage{@xitem while not in a table}}
1458\def\xitemx{\errmessage{@xitemx while not in a table}}
1459
1460%% Contains a kludge to get @end[description] to work
1461\def\description{\tablez{\dontindex}{1}{}{}{}{}}
1462
1463\def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
1464{\obeylines\obeyspaces%
1465\gdef\tablex #1^^M{%
1466\tabley\dontindex#1        \endtabley}}
1467
1468\def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
1469{\obeylines\obeyspaces%
1470\gdef\ftablex #1^^M{%
1471\tabley\fnitemindex#1        \endtabley
1472\def\Eftable{\endgraf\afterenvbreak\endgroup}%
1473\let\Etable=\relax}}
1474
1475\def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex}
1476{\obeylines\obeyspaces%
1477\gdef\vtablex #1^^M{%
1478\tabley\vritemindex#1        \endtabley
1479\def\Evtable{\endgraf\afterenvbreak\endgroup}%
1480\let\Etable=\relax}}
1481
1482\def\dontindex #1{}
1483\def\fnitemindex #1{\doind {fn}{\code{#1}}}%
1484\def\vritemindex #1{\doind {vr}{\code{#1}}}%
1485
1486{\obeyspaces %
1487\gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
1488\tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
1489
1490\def\tablez #1#2#3#4#5#6{%
1491\aboveenvbreak %
1492\begingroup %
1493\def\Edescription{\Etable}% Neccessary kludge.
1494\let\itemindex=#1%
1495\ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
1496\ifnum 0#4>0 \tableindent=#4\mil \fi %
1497\ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
1498\def\itemfont{#2}%
1499\itemmax=\tableindent %
1500\advance \itemmax by -\itemmargin %
1501\advance \leftskip by \tableindent %
1502\exdentamount=\tableindent
1503\parindent = 0pt
1504\parskip = \smallskipamount
1505\ifdim \parskip=0pt \parskip=2pt \fi%
1506\def\Etable{\endgraf\afterenvbreak\endgroup}%
1507\let\item = \internalBitem %
1508\let\itemx = \internalBitemx %
1509\let\kitem = \internalBkitem %
1510\let\kitemx = \internalBkitemx %
1511\let\xitem = \internalBxitem %
1512\let\xitemx = \internalBxitemx %
1513}
1514
1515% This is the counter used by @enumerate, which is really @itemize
1516
1517\newcount \itemno
1518
1519\def\itemize{\parsearg\itemizezzz}
1520
1521\def\itemizezzz #1{%
1522  \begingroup % ended by the @end itemsize
1523  \itemizey {#1}{\Eitemize}
1524}
1525
1526\def\itemizey #1#2{%
1527\aboveenvbreak %
1528\itemmax=\itemindent %
1529\advance \itemmax by -\itemmargin %
1530\advance \leftskip by \itemindent %
1531\exdentamount=\itemindent
1532\parindent = 0pt %
1533\parskip = \smallskipamount %
1534\ifdim \parskip=0pt \parskip=2pt \fi%
1535\def#2{\endgraf\afterenvbreak\endgroup}%
1536\def\itemcontents{#1}%
1537\let\item=\itemizeitem}
1538
1539% Set sfcode to normal for the chars that usually have another value.
1540% These are `.?!:;,'
1541\def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
1542  \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
1543
1544% \splitoff TOKENS\endmark defines \first to be the first token in
1545% TOKENS, and \rest to be the remainder.
1546%
1547\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
1548
1549% Allow an optional argument of an uppercase letter, lowercase letter,
1550% or number, to specify the first label in the enumerated list.  No
1551% argument is the same as `1'.
1552%
1553\def\enumerate{\parsearg\enumeratezzz}
1554\def\enumeratezzz #1{\enumeratey #1  \endenumeratey}
1555\def\enumeratey #1 #2\endenumeratey{%
1556  \begingroup % ended by the @end enumerate
1557  %
1558  % If we were given no argument, pretend we were given `1'.
1559  \def\thearg{#1}%
1560  \ifx\thearg\empty \def\thearg{1}\fi
1561  %
1562  % Detect if the argument is a single token.  If so, it might be a
1563  % letter.  Otherwise, the only valid thing it can be is a number.
1564  % (We will always have one token, because of the test we just made.
1565  % This is a good thing, since \splitoff doesn't work given nothing at
1566  % all -- the first parameter is undelimited.)
1567  \expandafter\splitoff\thearg\endmark
1568  \ifx\rest\empty
1569    % Only one token in the argument.  It could still be anything.
1570    % A ``lowercase letter'' is one whose \lccode is nonzero.
1571    % An ``uppercase letter'' is one whose \lccode is both nonzero, and
1572    %   not equal to itself.
1573    % Otherwise, we assume it's a number.
1574    %
1575    % We need the \relax at the end of the \ifnum lines to stop TeX from
1576    % continuing to look for a <number>.
1577    %
1578    \ifnum\lccode\expandafter`\thearg=0\relax
1579      \numericenumerate % a number (we hope)
1580    \else
1581      % It's a letter.
1582      \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
1583        \lowercaseenumerate % lowercase letter
1584      \else
1585        \uppercaseenumerate % uppercase letter
1586      \fi
1587    \fi
1588  \else
1589    % Multiple tokens in the argument.  We hope it's a number.
1590    \numericenumerate
1591  \fi
1592}
1593
1594% An @enumerate whose labels are integers.  The starting integer is
1595% given in \thearg.
1596%
1597\def\numericenumerate{%
1598  \itemno = \thearg
1599  \startenumeration{\the\itemno}%
1600}
1601
1602% The starting (lowercase) letter is in \thearg.
1603\def\lowercaseenumerate{%
1604  \itemno = \expandafter`\thearg
1605  \startenumeration{%
1606    % Be sure we're not beyond the end of the alphabet.
1607    \ifnum\itemno=0
1608      \errmessage{No more lowercase letters in @enumerate; get a bigger
1609                  alphabet}%
1610    \fi
1611    \char\lccode\itemno
1612  }%
1613}
1614
1615% The starting (uppercase) letter is in \thearg.
1616\def\uppercaseenumerate{%
1617  \itemno = \expandafter`\thearg
1618  \startenumeration{%
1619    % Be sure we're not beyond the end of the alphabet.
1620    \ifnum\itemno=0
1621      \errmessage{No more uppercase letters in @enumerate; get a bigger
1622                  alphabet}
1623    \fi
1624    \char\uccode\itemno
1625  }%
1626}
1627
1628% Call itemizey, adding a period to the first argument and supplying the
1629% common last two arguments.  Also subtract one from the initial value in
1630% \itemno, since @item increments \itemno.
1631%
1632\def\startenumeration#1{%
1633  \advance\itemno by -1
1634  \itemizey{#1.}\Eenumerate\flushcr
1635}
1636
1637% @alphaenumerate and @capsenumerate are abbreviations for giving an arg
1638% to @enumerate.
1639%
1640\def\alphaenumerate{\enumerate{a}}
1641\def\capsenumerate{\enumerate{A}}
1642\def\Ealphaenumerate{\Eenumerate}
1643\def\Ecapsenumerate{\Eenumerate}
1644
1645% Definition of @item while inside @itemize.
1646
1647\def\itemizeitem{%
1648\advance\itemno by 1
1649{\let\par=\endgraf \smallbreak}%
1650\ifhmode \errmessage{\in hmode at itemizeitem}\fi
1651{\parskip=0in \hskip 0pt
1652\hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
1653\vadjust{\penalty 1200}}%
1654\flushcr}
1655
1656\message{indexing,}
1657% Index generation facilities
1658
1659% Define \newwrite to be identical to plain tex's \newwrite
1660% except not \outer, so it can be used within \newindex.
1661{\catcode`\@=11
1662\gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
1663
1664% \newindex {foo} defines an index named foo.
1665% It automatically defines \fooindex such that
1666% \fooindex ...rest of line... puts an entry in the index foo.
1667% It also defines \fooindfile to be the number of the output channel for
1668% the file that	accumulates this index.  The file's extension is foo.
1669% The name of an index should be no more than 2 characters long
1670% for the sake of vms.
1671
1672\def\newindex #1{
1673\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
1674\openout \csname#1indfile\endcsname \jobname.#1	% Open the file
1675\expandafter\xdef\csname#1index\endcsname{%	% Define \xxxindex
1676\noexpand\doindex {#1}}
1677}
1678
1679% @defindex foo  ==  \newindex{foo}
1680
1681\def\defindex{\parsearg\newindex}
1682
1683% Define @defcodeindex, like @defindex except put all entries in @code.
1684
1685\def\newcodeindex #1{
1686\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file
1687\openout \csname#1indfile\endcsname \jobname.#1	% Open the file
1688\expandafter\xdef\csname#1index\endcsname{%	% Define \xxxindex
1689\noexpand\docodeindex {#1}}
1690}
1691
1692\def\defcodeindex{\parsearg\newcodeindex}
1693
1694% @synindex foo bar    makes index foo feed into index bar.
1695% Do this instead of @defindex foo if you don't want it as a separate index.
1696\def\synindex #1 #2 {%
1697\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
1698\expandafter\let\csname#1indfile\endcsname=\synindexfoo
1699\expandafter\xdef\csname#1index\endcsname{%	% Define \xxxindex
1700\noexpand\doindex {#2}}%
1701}
1702
1703% @syncodeindex foo bar   similar, but put all entries made for index foo
1704% inside @code.
1705\def\syncodeindex #1 #2 {%
1706\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname
1707\expandafter\let\csname#1indfile\endcsname=\synindexfoo
1708\expandafter\xdef\csname#1index\endcsname{%	% Define \xxxindex
1709\noexpand\docodeindex {#2}}%
1710}
1711
1712% Define \doindex, the driver for all \fooindex macros.
1713% Argument #1 is generated by the calling \fooindex macro,
1714%  and it is "foo", the name of the index.
1715
1716% \doindex just uses \parsearg; it calls \doind for the actual work.
1717% This is because \doind is more useful to call from other macros.
1718
1719% There is also \dosubind {index}{topic}{subtopic}
1720% which makes an entry in a two-level index such as the operation index.
1721
1722\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
1723\def\singleindexer #1{\doind{\indexname}{#1}}
1724
1725% like the previous two, but they put @code around the argument.
1726\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
1727\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
1728
1729\def\indexdummies{%
1730% Take care of the plain tex accent commands.
1731\def\"{\realbackslash "}%
1732\def\`{\realbackslash `}%
1733\def\'{\realbackslash '}%
1734\def\^{\realbackslash ^}%
1735\def\~{\realbackslash ~}%
1736\def\={\realbackslash =}%
1737\def\b{\realbackslash b}%
1738\def\c{\realbackslash c}%
1739\def\d{\realbackslash d}%
1740\def\u{\realbackslash u}%
1741\def\v{\realbackslash v}%
1742\def\H{\realbackslash H}%
1743% Take care of the plain tex special European modified letters.
1744\def\oe{\realbackslash oe}%
1745\def\ae{\realbackslash ae}%
1746\def\aa{\realbackslash aa}%
1747\def\OE{\realbackslash OE}%
1748\def\AE{\realbackslash AE}%
1749\def\AA{\realbackslash AA}%
1750\def\o{\realbackslash o}%
1751\def\O{\realbackslash O}%
1752\def\l{\realbackslash l}%
1753\def\L{\realbackslash L}%
1754\def\ss{\realbackslash ss}%
1755% Take care of texinfo commands likely to appear in an index entry.
1756\def\_{{\realbackslash _}}%
1757\def\w{\realbackslash w }%
1758\def\bf{\realbackslash bf }%
1759\def\rm{\realbackslash rm }%
1760\def\sl{\realbackslash sl }%
1761\def\sf{\realbackslash sf}%
1762\def\tt{\realbackslash tt}%
1763\def\gtr{\realbackslash gtr}%
1764\def\less{\realbackslash less}%
1765\def\hat{\realbackslash hat}%
1766\def\char{\realbackslash char}%
1767\def\TeX{\realbackslash TeX}%
1768\def\dots{\realbackslash dots }%
1769\def\copyright{\realbackslash copyright }%
1770\def\tclose##1{\realbackslash tclose {##1}}%
1771\def\code##1{\realbackslash code {##1}}%
1772\def\samp##1{\realbackslash samp {##1}}%
1773\def\t##1{\realbackslash r {##1}}%
1774\def\r##1{\realbackslash r {##1}}%
1775\def\i##1{\realbackslash i {##1}}%
1776\def\b##1{\realbackslash b {##1}}%
1777\def\cite##1{\realbackslash cite {##1}}%
1778\def\key##1{\realbackslash key {##1}}%
1779\def\file##1{\realbackslash file {##1}}%
1780\def\var##1{\realbackslash var {##1}}%
1781\def\kbd##1{\realbackslash kbd {##1}}%
1782\def\dfn##1{\realbackslash dfn {##1}}%
1783\def\emph##1{\realbackslash emph {##1}}%
1784}
1785
1786% \indexnofonts no-ops all font-change commands.
1787% This is used when outputting the strings to sort the index by.
1788\def\indexdummyfont#1{#1}
1789\def\indexdummytex{TeX}
1790\def\indexdummydots{...}
1791
1792\def\indexnofonts{%
1793% Just ignore accents.
1794\let\"=\indexdummyfont
1795\let\`=\indexdummyfont
1796\let\'=\indexdummyfont
1797\let\^=\indexdummyfont
1798\let\~=\indexdummyfont
1799\let\==\indexdummyfont
1800\let\b=\indexdummyfont
1801\let\c=\indexdummyfont
1802\let\d=\indexdummyfont
1803\let\u=\indexdummyfont
1804\let\v=\indexdummyfont
1805\let\H=\indexdummyfont
1806% Take care of the plain tex special European modified letters.
1807\def\oe{oe}
1808\def\ae{ae}
1809\def\aa{aa}
1810\def\OE{OE}
1811\def\AE{AE}
1812\def\AA{AA}
1813\def\o{o}
1814\def\O{O}
1815\def\l{l}
1816\def\L{L}
1817\def\ss{ss}
1818\let\w=\indexdummyfont
1819\let\t=\indexdummyfont
1820\let\r=\indexdummyfont
1821\let\i=\indexdummyfont
1822\let\b=\indexdummyfont
1823\let\emph=\indexdummyfont
1824\let\strong=\indexdummyfont
1825\let\cite=\indexdummyfont
1826\let\sc=\indexdummyfont
1827%Don't no-op \tt, since it isn't a user-level command
1828% and is used in the definitions of the active chars like <, >, |...
1829%\let\tt=\indexdummyfont
1830\let\tclose=\indexdummyfont
1831\let\code=\indexdummyfont
1832\let\file=\indexdummyfont
1833\let\samp=\indexdummyfont
1834\let\kbd=\indexdummyfont
1835\let\key=\indexdummyfont
1836\let\var=\indexdummyfont
1837\let\TeX=\indexdummytex
1838\let\dots=\indexdummydots
1839}
1840
1841% To define \realbackslash, we must make \ not be an escape.
1842% We must first make another character (@) an escape
1843% so we do not become unable to do a definition.
1844
1845{\catcode`\@=0 \catcode`\\=\other
1846@gdef@realbackslash{\}}
1847
1848\let\indexbackslash=0  %overridden during \printindex.
1849
1850\def\doind #1#2{%
1851{\count10=\lastpenalty %
1852{\indexdummies % Must do this here, since \bf, etc expand at this stage
1853\escapechar=`\\%
1854{\let\folio=0% Expand all macros now EXCEPT \folio
1855\def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
1856% so it will be output as is; and it will print as backslash in the indx.
1857%
1858% Now process the index-string once, with all font commands turned off,
1859% to get the string to sort the index by.
1860{\indexnofonts
1861\xdef\temp1{#2}%
1862}%
1863% Now produce the complete index entry.  We process the index-string again,
1864% this time with font commands expanded, to get what to print in the index.
1865\edef\temp{%
1866\write \csname#1indfile\endcsname{%
1867\realbackslash entry {\temp1}{\folio}{#2}}}%
1868\temp }%
1869}\penalty\count10}}
1870
1871\def\dosubind #1#2#3{%
1872{\count10=\lastpenalty %
1873{\indexdummies % Must do this here, since \bf, etc expand at this stage
1874\escapechar=`\\%
1875{\let\folio=0%
1876\def\rawbackslashxx{\indexbackslash}%
1877%
1878% Now process the index-string once, with all font commands turned off,
1879% to get the string to sort the index by.
1880{\indexnofonts
1881\xdef\temp1{#2 #3}%
1882}%
1883% Now produce the complete index entry.  We process the index-string again,
1884% this time with font commands expanded, to get what to print in the index.
1885\edef\temp{%
1886\write \csname#1indfile\endcsname{%
1887\realbackslash entry {\temp1}{\folio}{#2}{#3}}}%
1888\temp }%
1889}\penalty\count10}}
1890
1891% The index entry written in the file actually looks like
1892%  \entry {sortstring}{page}{topic}
1893% or
1894%  \entry {sortstring}{page}{topic}{subtopic}
1895% The texindex program reads in these files and writes files
1896% containing these kinds of lines:
1897%  \initial {c}
1898%     before the first topic whose initial is c
1899%  \entry {topic}{pagelist}
1900%     for a topic that is used without subtopics
1901%  \primary {topic}
1902%     for the beginning of a topic that is used with subtopics
1903%  \secondary {subtopic}{pagelist}
1904%     for each subtopic.
1905
1906% Define the user-accessible indexing commands
1907% @findex, @vindex, @kindex, @cindex.
1908
1909\def\findex {\fnindex}
1910\def\kindex {\kyindex}
1911\def\cindex {\cpindex}
1912\def\vindex {\vrindex}
1913\def\tindex {\tpindex}
1914\def\pindex {\pgindex}
1915
1916\def\cindexsub {\begingroup\obeylines\cindexsub}
1917{\obeylines %
1918\gdef\cindexsub "#1" #2^^M{\endgroup %
1919\dosubind{cp}{#2}{#1}}}
1920
1921% Define the macros used in formatting output of the sorted index material.
1922
1923% This is what you call to cause a particular index to get printed.
1924% Write
1925% @unnumbered Function Index
1926% @printindex fn
1927
1928\def\printindex{\parsearg\doprintindex}
1929
1930\def\doprintindex#1{%
1931  \tex
1932  \dobreak \chapheadingskip {10000}
1933  \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other
1934  \catcode`\$=\other
1935  \catcode`\~=\other
1936  \indexbreaks
1937  %
1938  % The following don't help, since the chars were translated
1939  % when the raw index was written, and their fonts were discarded
1940  % due to \indexnofonts.
1941  %\catcode`\"=\active
1942  %\catcode`\^=\active
1943  %\catcode`\_=\active
1944  %\catcode`\|=\active
1945  %\catcode`\<=\active
1946  %\catcode`\>=\active
1947  % %
1948  \def\indexbackslash{\rawbackslashxx}
1949  \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt
1950  \begindoublecolumns
1951  %
1952  % See if the index file exists and is nonempty.
1953  \openin 1 \jobname.#1s
1954  \ifeof 1
1955    % \enddoublecolumns gets confused if there is no text in the index,
1956    % and it loses the chapter title and the aux file entries for the
1957    % index.  The easiest way to prevent this problem is to make sure
1958    % there is some text.
1959    (Index is nonexistent)
1960    \else
1961    %
1962    % If the index file exists but is empty, then \openin leaves \ifeof
1963    % false.  We have to make TeX try to read something from the file, so
1964    % it can discover if there is anything in it.
1965    \read 1 to \temp
1966    \ifeof 1
1967      (Index is empty)
1968    \else
1969      \input \jobname.#1s
1970    \fi
1971  \fi
1972  \closein 1
1973  \enddoublecolumns
1974  \Etex
1975}
1976
1977% These macros are used by the sorted index file itself.
1978% Change them to control the appearance of the index.
1979
1980% Same as \bigskipamount except no shrink.
1981% \balancecolumns gets confused if there is any shrink.
1982\newskip\initialskipamount \initialskipamount 12pt plus4pt
1983
1984\def\initial #1{%
1985{\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
1986\ifdim\lastskip<\initialskipamount
1987\removelastskip \penalty-200 \vskip \initialskipamount\fi
1988\line{\secbf#1\hfill}\kern 2pt\penalty10000}}
1989
1990% This typesets a paragraph consisting of #1, dot leaders, and then #2
1991% flush to the right margin.  It is used for index and table of contents
1992% entries.  The paragraph is indented by \leftskip.
1993%
1994\def\entry #1#2{\begingroup
1995  %
1996  % Start a new paragraph if necessary, so our assignments below can't
1997  % affect previous text.
1998  \par
1999  %
2000  % Do not fill out the last line with white space.
2001  \parfillskip = 0in
2002  %
2003  % No extra space above this paragraph.
2004  \parskip = 0in
2005  %
2006  % Do not prefer a separate line ending with a hyphen to fewer lines.
2007  \finalhyphendemerits = 0
2008  %
2009  % \hangindent is only relevant when the entry text and page number
2010  % don't both fit on one line.  In that case, bob suggests starting the
2011  % dots pretty far over on the line.  Unfortunately, a large
2012  % indentation looks wrong when the entry text itself is broken across
2013  % lines.  So we use a small indentation and put up with long leaders.
2014  %
2015  % \hangafter is reset to 1 (which is the value we want) at the start
2016  % of each paragraph, so we need not do anything with that.
2017  \hangindent=2em
2018  %
2019  % When the entry text needs to be broken, just fill out the first line
2020  % with blank space.
2021  \rightskip = 0pt plus1fil
2022  %
2023  % Start a ``paragraph'' for the index entry so the line breaking
2024  % parameters we've set above will have an effect.
2025  \noindent
2026  %
2027  % Insert the text of the index entry.  TeX will do line-breaking on it.
2028  #1%
2029  % The following is kluged to not output a line of dots in the index if
2030  % there are no page numbers.  The next person who breaks this will be
2031  % cursed by a Unix daemon.
2032  \def\tempa{{\rm }}%
2033  \def\tempb{#2}%
2034  \edef\tempc{\tempa}%
2035  \edef\tempd{\tempb}%
2036  \ifx\tempc\tempd\ \else%
2037    %
2038    % If we must, put the page number on a line of its own, and fill out
2039    % this line with blank space.  (The \hfil is overwhelmed with the
2040    % fill leaders glue in \indexdotfill if the page number does fit.)
2041    \hfil\penalty50
2042    \null\nobreak\indexdotfill % Have leaders before the page number.
2043    %
2044    % The `\ ' here is removed by the implicit \unskip that TeX does as
2045    % part of (the primitive) \par.  Without it, a spurious underfull
2046    % \hbox ensues.
2047    \ #2% The page number ends the paragraph.
2048  \fi%
2049  \par
2050\endgroup}
2051
2052% Like \dotfill except takes at least 1 em.
2053\def\indexdotfill{\cleaders
2054  \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill}
2055
2056\def\primary #1{\line{#1\hfil}}
2057
2058\newskip\secondaryindent \secondaryindent=0.5cm
2059
2060\def\secondary #1#2{
2061{\parfillskip=0in \parskip=0in
2062\hangindent =1in \hangafter=1
2063\noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
2064}}
2065
2066%% Define two-column mode, which is used in indexes.
2067%% Adapted from the TeXbook, page 416.
2068\catcode `\@=11
2069
2070\newbox\partialpage
2071
2072\newdimen\doublecolumnhsize
2073
2074\def\begindoublecolumns{\begingroup
2075  % Grab any single-column material above us.
2076  \output = {\global\setbox\partialpage
2077    =\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}%
2078  \eject
2079  %
2080  % Now switch to the double-column output routine.
2081  \output={\doublecolumnout}%
2082  %
2083  % Change the page size parameters.  We could do this once outside this
2084  % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
2085  % format, but then we repeat the same computation.  Repeating a couple
2086  % of assignments once per index is clearly meaningless for the
2087  % execution time, so we may as well do it once.
2088  %
2089  % First we halve the line length, less a little for the gutter between
2090  % the columns.  We compute the gutter based on the line length, so it
2091  % changes automatically with the paper format.  The magic constant
2092  % below is chosen so that the gutter has the same value (well, +- <
2093  % 1pt) as it did when we hard-coded it.
2094  %
2095  % We put the result in a separate register, \doublecolumhsize, so we
2096  % can restore it in \pagesofar, after \hsize itself has (potentially)
2097  % been clobbered.
2098  %
2099  \doublecolumnhsize = \hsize
2100    \advance\doublecolumnhsize by -.04154\hsize
2101    \divide\doublecolumnhsize by 2
2102  \hsize = \doublecolumnhsize
2103  %
2104  % Double the \vsize as well.  (We don't need a separate register here,
2105  % since nobody clobbers \vsize.)
2106  \vsize = 2\vsize
2107  \doublecolumnpagegoal
2108}
2109
2110\def\enddoublecolumns{\eject \endgroup \pagegoal=\vsize \unvbox\partialpage}
2111
2112\def\doublecolumnsplit{\splittopskip=\topskip \splitmaxdepth=\maxdepth
2113  \global\dimen@=\pageheight \global\advance\dimen@ by-\ht\partialpage
2114  \global\setbox1=\vsplit255 to\dimen@ \global\setbox0=\vbox{\unvbox1}
2115  \global\setbox3=\vsplit255 to\dimen@ \global\setbox2=\vbox{\unvbox3}
2116  \ifdim\ht0>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi
2117  \ifdim\ht2>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi
2118}
2119\def\doublecolumnpagegoal{%
2120  \dimen@=\vsize \advance\dimen@ by-2\ht\partialpage \global\pagegoal=\dimen@
2121}
2122\def\pagesofar{\unvbox\partialpage %
2123  \hsize=\doublecolumnhsize % have to restore this since output routine
2124  \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}}
2125\def\doublecolumnout{%
2126  \setbox5=\copy255
2127  {\vbadness=10000 \doublecolumnsplit}
2128  \ifvbox255
2129    \setbox0=\vtop to\dimen@{\unvbox0}
2130    \setbox2=\vtop to\dimen@{\unvbox2}
2131    \onepageout\pagesofar \unvbox255 \penalty\outputpenalty
2132  \else
2133    \setbox0=\vbox{\unvbox5}
2134    \ifvbox0
2135      \dimen@=\ht0 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip
2136      \divide\dimen@ by2 \splittopskip=\topskip \splitmaxdepth=\maxdepth
2137      {\vbadness=10000
2138	\loop \global\setbox5=\copy0
2139          \setbox1=\vsplit5 to\dimen@
2140          \setbox3=\vsplit5 to\dimen@
2141          \ifvbox5 \global\advance\dimen@ by1pt \repeat
2142        \setbox0=\vbox to\dimen@{\unvbox1}
2143        \setbox2=\vbox to\dimen@{\unvbox3}
2144        \global\setbox\partialpage=\vbox{\pagesofar}
2145        \doublecolumnpagegoal
2146      }
2147    \fi
2148  \fi
2149}
2150
2151\catcode `\@=\other
2152\message{sectioning,}
2153% Define chapters, sections, etc.
2154
2155\newcount \chapno
2156\newcount \secno        \secno=0
2157\newcount \subsecno     \subsecno=0
2158\newcount \subsubsecno  \subsubsecno=0
2159
2160% This counter is funny since it counts through charcodes of letters A, B, ...
2161\newcount \appendixno  \appendixno = `\@
2162\def\appendixletter{\char\the\appendixno}
2163
2164\newwrite \contentsfile
2165% This is called from \setfilename.
2166\def\opencontents{\openout \contentsfile = \jobname.toc}
2167
2168% Each @chapter defines this as the name of the chapter.
2169% page headings and footings can use it.  @section does likewise
2170
2171\def\thischapter{} \def\thissection{}
2172\def\seccheck#1{\if \pageno<0 %
2173\errmessage{@#1 not allowed after generating table of contents}\fi
2174%
2175}
2176
2177\def\chapternofonts{%
2178\let\rawbackslash=\relax%
2179\let\frenchspacing=\relax%
2180\def\result{\realbackslash result}
2181\def\equiv{\realbackslash equiv}
2182\def\expansion{\realbackslash expansion}
2183\def\print{\realbackslash print}
2184\def\TeX{\realbackslash TeX}
2185\def\dots{\realbackslash dots}
2186\def\copyright{\realbackslash copyright}
2187\def\tt{\realbackslash tt}
2188\def\bf{\realbackslash bf }
2189\def\w{\realbackslash w}
2190\def\less{\realbackslash less}
2191\def\gtr{\realbackslash gtr}
2192\def\hat{\realbackslash hat}
2193\def\char{\realbackslash char}
2194\def\tclose##1{\realbackslash tclose {##1}}
2195\def\code##1{\realbackslash code {##1}}
2196\def\samp##1{\realbackslash samp {##1}}
2197\def\r##1{\realbackslash r {##1}}
2198\def\b##1{\realbackslash b {##1}}
2199\def\key##1{\realbackslash key {##1}}
2200\def\file##1{\realbackslash file {##1}}
2201\def\kbd##1{\realbackslash kbd {##1}}
2202% These are redefined because @smartitalic wouldn't work inside xdef.
2203\def\i##1{\realbackslash i {##1}}
2204\def\cite##1{\realbackslash cite {##1}}
2205\def\var##1{\realbackslash var {##1}}
2206\def\emph##1{\realbackslash emph {##1}}
2207\def\dfn##1{\realbackslash dfn {##1}}
2208}
2209
2210\newcount\absseclevel % used to calculate proper heading level
2211\newcount\secbase\secbase=0 % @raise/lowersections modify this count
2212
2213% @raisesections: treat @section as chapter, @subsection as section, etc.
2214\def\raisesections{\global\advance\secbase by -1}
2215\let\up=\raisesections % original BFox name
2216
2217% @lowersections: treat @chapter as section, @section as subsection, etc.
2218\def\lowersections{\global\advance\secbase by 1}
2219\let\down=\lowersections % original BFox name
2220
2221% Choose a numbered-heading macro
2222% #1 is heading level if unmodified by @raisesections or @lowersections
2223% #2 is text for heading
2224\def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
2225\ifcase\absseclevel
2226  \chapterzzz{#2}
2227\or
2228  \seczzz{#2}
2229\or
2230  \numberedsubseczzz{#2}
2231\or
2232  \numberedsubsubseczzz{#2}
2233\else
2234  \ifnum \absseclevel<0
2235    \chapterzzz{#2}
2236  \else
2237    \numberedsubsubseczzz{#2}
2238  \fi
2239\fi
2240}
2241
2242% like \numhead, but chooses appendix heading levels
2243\def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
2244\ifcase\absseclevel
2245  \appendixzzz{#2}
2246\or
2247  \appendixsectionzzz{#2}
2248\or
2249  \appendixsubseczzz{#2}
2250\or
2251  \appendixsubsubseczzz{#2}
2252\else
2253  \ifnum \absseclevel<0
2254    \appendixzzz{#2}
2255  \else
2256    \appendixsubsubseczzz{#2}
2257  \fi
2258\fi
2259}
2260
2261% like \numhead, but chooses numberless heading levels
2262\def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
2263\ifcase\absseclevel
2264  \unnumberedzzz{#2}
2265\or
2266  \unnumberedseczzz{#2}
2267\or
2268  \unnumberedsubseczzz{#2}
2269\or
2270  \unnumberedsubsubseczzz{#2}
2271\else
2272  \ifnum \absseclevel<0
2273    \unnumberedzzz{#2}
2274  \else
2275    \unnumberedsubsubseczzz{#2}
2276  \fi
2277\fi
2278}
2279
2280
2281\def\thischaptername{No Chapter Title}
2282\outer\def\chapter{\parsearg\chapteryyy}
2283\def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz
2284\def\chapterzzz #1{\seccheck{chapter}%
2285\secno=0 \subsecno=0 \subsubsecno=0
2286\global\advance \chapno by 1 \message{Chapter \the\chapno}%
2287\chapmacro {#1}{\the\chapno}%
2288\gdef\thissection{#1}%
2289\gdef\thischaptername{#1}%
2290% We don't substitute the actual chapter name into \thischapter
2291% because we don't want its macros evaluated now.
2292\xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}%
2293{\chapternofonts%
2294\edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}%
2295\escapechar=`\\%
2296\write \contentsfile \temp  %
2297\donoderef %
2298\global\let\section = \numberedsec
2299\global\let\subsection = \numberedsubsec
2300\global\let\subsubsection = \numberedsubsubsec
2301}}
2302
2303\outer\def\appendix{\parsearg\appendixyyy}
2304\def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz
2305\def\appendixzzz #1{\seccheck{appendix}%
2306\secno=0 \subsecno=0 \subsubsecno=0
2307\global\advance \appendixno by 1 \message{Appendix \appendixletter}%
2308\chapmacro {#1}{\putwordAppendix{} \appendixletter}%
2309\gdef\thissection{#1}%
2310\gdef\thischaptername{#1}%
2311\xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
2312{\chapternofonts%
2313\edef\temp{{\realbackslash chapentry
2314  {#1}{\putwordAppendix{} \appendixletter}{\noexpand\folio}}}%
2315\escapechar=`\\%
2316\write \contentsfile \temp  %
2317\appendixnoderef %
2318\global\let\section = \appendixsec
2319\global\let\subsection = \appendixsubsec
2320\global\let\subsubsection = \appendixsubsubsec
2321}}
2322
2323\outer\def\top{\parsearg\unnumberedyyy}
2324\outer\def\unnumbered{\parsearg\unnumberedyyy}
2325\def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
2326\def\unnumberedzzz #1{\seccheck{unnumbered}%
2327\secno=0 \subsecno=0 \subsubsecno=0
2328%
2329% This used to be simply \message{#1}, but TeX fully expands the
2330% argument to \message.  Therefore, if #1 contained @-commands, TeX
2331% expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
2332% expanded @cite (which turns out to cause errors because \cite is meant
2333% to be executed, not expanded).
2334%
2335% Anyway, we don't want the fully-expanded definition of @cite to appear
2336% as a result of the \message, we just want `@cite' itself.  We use
2337% \the<toks register> to achieve this: TeX expands \the<toks> only once,
2338% simply yielding the contents of the <toks register>.
2339\toks0 = {#1}\message{(\the\toks0)}%
2340%
2341\unnumbchapmacro {#1}%
2342\gdef\thischapter{#1}\gdef\thissection{#1}%
2343{\chapternofonts%
2344\edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}%
2345\escapechar=`\\%
2346\write \contentsfile \temp  %
2347\unnumbnoderef %
2348\global\let\section = \unnumberedsec
2349\global\let\subsection = \unnumberedsubsec
2350\global\let\subsubsection = \unnumberedsubsubsec
2351}}
2352
2353\outer\def\numberedsec{\parsearg\secyyy}
2354\def\secyyy #1{\numhead1{#1}} % normally calls seczzz
2355\def\seczzz #1{\seccheck{section}%
2356\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
2357\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
2358{\chapternofonts%
2359\edef\temp{{\realbackslash secentry %
2360{#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}%
2361\escapechar=`\\%
2362\write \contentsfile \temp %
2363\donoderef %
2364\penalty 10000 %
2365}}
2366
2367\outer\def\appenixsection{\parsearg\appendixsecyyy}
2368\outer\def\appendixsec{\parsearg\appendixsecyyy}
2369\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz
2370\def\appendixsectionzzz #1{\seccheck{appendixsection}%
2371\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
2372\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
2373{\chapternofonts%
2374\edef\temp{{\realbackslash secentry %
2375{#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}%
2376\escapechar=`\\%
2377\write \contentsfile \temp %
2378\appendixnoderef %
2379\penalty 10000 %
2380}}
2381
2382\outer\def\unnumberedsec{\parsearg\unnumberedsecyyy}
2383\def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz
2384\def\unnumberedseczzz #1{\seccheck{unnumberedsec}%
2385\plainsecheading {#1}\gdef\thissection{#1}%
2386{\chapternofonts%
2387\edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}%
2388\escapechar=`\\%
2389\write \contentsfile \temp %
2390\unnumbnoderef %
2391\penalty 10000 %
2392}}
2393
2394\outer\def\numberedsubsec{\parsearg\numberedsubsecyyy}
2395\def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz
2396\def\numberedsubseczzz #1{\seccheck{subsection}%
2397\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
2398\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
2399{\chapternofonts%
2400\edef\temp{{\realbackslash subsecentry %
2401{#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
2402\escapechar=`\\%
2403\write \contentsfile \temp %
2404\donoderef %
2405\penalty 10000 %
2406}}
2407
2408\outer\def\appendixsubsec{\parsearg\appendixsubsecyyy}
2409\def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz
2410\def\appendixsubseczzz #1{\seccheck{appendixsubsec}%
2411\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
2412\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
2413{\chapternofonts%
2414\edef\temp{{\realbackslash subsecentry %
2415{#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}%
2416\escapechar=`\\%
2417\write \contentsfile \temp %
2418\appendixnoderef %
2419\penalty 10000 %
2420}}
2421
2422\outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy}
2423\def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
2424\def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}%
2425\plainsecheading {#1}\gdef\thissection{#1}%
2426{\chapternofonts%
2427\edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}%
2428\escapechar=`\\%
2429\write \contentsfile \temp %
2430\unnumbnoderef %
2431\penalty 10000 %
2432}}
2433
2434\outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy}
2435\def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz
2436\def\numberedsubsubseczzz #1{\seccheck{subsubsection}%
2437\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
2438\subsubsecheading {#1}
2439  {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
2440{\chapternofonts%
2441\edef\temp{{\realbackslash subsubsecentry %
2442  {#1}
2443  {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}
2444  {\noexpand\folio}}}%
2445\escapechar=`\\%
2446\write \contentsfile \temp %
2447\donoderef %
2448\penalty 10000 %
2449}}
2450
2451\outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy}
2452\def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz
2453\def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}%
2454\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
2455\subsubsecheading {#1}
2456  {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
2457{\chapternofonts%
2458\edef\temp{{\realbackslash subsubsecentry{#1}%
2459  {\appendixletter}
2460  {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}%
2461\escapechar=`\\%
2462\write \contentsfile \temp %
2463\appendixnoderef %
2464\penalty 10000 %
2465}}
2466
2467\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy}
2468\def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
2469\def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}%
2470\plainsecheading {#1}\gdef\thissection{#1}%
2471{\chapternofonts%
2472\edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}%
2473\escapechar=`\\%
2474\write \contentsfile \temp %
2475\unnumbnoderef %
2476\penalty 10000 %
2477}}
2478
2479% These are variants which are not "outer", so they can appear in @ifinfo.
2480% Actually, they should now be obsolete; ordinary section commands should work.
2481\def\infotop{\parsearg\unnumberedzzz}
2482\def\infounnumbered{\parsearg\unnumberedzzz}
2483\def\infounnumberedsec{\parsearg\unnumberedseczzz}
2484\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
2485\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
2486
2487\def\infoappendix{\parsearg\appendixzzz}
2488\def\infoappendixsec{\parsearg\appendixseczzz}
2489\def\infoappendixsubsec{\parsearg\appendixsubseczzz}
2490\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
2491
2492\def\infochapter{\parsearg\chapterzzz}
2493\def\infosection{\parsearg\sectionzzz}
2494\def\infosubsection{\parsearg\subsectionzzz}
2495\def\infosubsubsection{\parsearg\subsubsectionzzz}
2496
2497% These macros control what the section commands do, according
2498% to what kind of chapter we are in (ordinary, appendix, or unnumbered).
2499% Define them by default for a numbered chapter.
2500\global\let\section = \numberedsec
2501\global\let\subsection = \numberedsubsec
2502\global\let\subsubsection = \numberedsubsubsec
2503
2504% Define @majorheading, @heading and @subheading
2505
2506% NOTE on use of \vbox for chapter headings, section headings, and
2507% such:
2508%	1) We use \vbox rather than the earlier \line to permit
2509%	   overlong headings to fold.
2510%	2) \hyphenpenalty is set to 10000 because hyphenation in a
2511%	   heading is obnoxious; this forbids it.
2512%       3) Likewise, headings look best if no \parindent is used, and
2513%          if justification is not attempted.  Hence \raggedright.
2514
2515
2516\def\majorheading{\parsearg\majorheadingzzz}
2517\def\majorheadingzzz #1{%
2518{\advance\chapheadingskip by 10pt \chapbreak }%
2519{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
2520                  \parindent=0pt\raggedright
2521                  \rm #1\hfill}}\bigskip \par\penalty 200}
2522
2523\def\chapheading{\parsearg\chapheadingzzz}
2524\def\chapheadingzzz #1{\chapbreak %
2525{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
2526                  \parindent=0pt\raggedright
2527                  \rm #1\hfill}}\bigskip \par\penalty 200}
2528
2529\def\heading{\parsearg\secheadingi}
2530
2531\def\subheading{\parsearg\subsecheadingi}
2532
2533\def\subsubheading{\parsearg\subsubsecheadingi}
2534
2535% These macros generate a chapter, section, etc. heading only
2536% (including whitespace, linebreaking, etc. around it),
2537% given all the information in convenient, parsed form.
2538
2539%%% Args are the skip and penalty (usually negative)
2540\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
2541
2542\def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
2543
2544%%% Define plain chapter starts, and page on/off switching for it
2545% Parameter controlling skip before chapter headings (if needed)
2546
2547\newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt
2548
2549\def\chapbreak{\dobreak \chapheadingskip {-4000}}
2550\def\chappager{\par\vfill\supereject}
2551\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
2552
2553\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
2554
2555\def\CHAPPAGoff{
2556\global\let\pchapsepmacro=\chapbreak
2557\global\let\pagealignmacro=\chappager}
2558
2559\def\CHAPPAGon{
2560\global\let\pchapsepmacro=\chappager
2561\global\let\pagealignmacro=\chappager
2562\global\def\HEADINGSon{\HEADINGSsingle}}
2563
2564\def\CHAPPAGodd{
2565\global\let\pchapsepmacro=\chapoddpage
2566\global\let\pagealignmacro=\chapoddpage
2567\global\def\HEADINGSon{\HEADINGSdouble}}
2568
2569\CHAPPAGon
2570
2571\def\CHAPFplain{
2572\global\let\chapmacro=\chfplain
2573\global\let\unnumbchapmacro=\unnchfplain}
2574
2575\def\chfplain #1#2{%
2576  \pchapsepmacro
2577  {%
2578    \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
2579                     \parindent=0pt\raggedright
2580                     \rm #2\enspace #1}%
2581  }%
2582  \bigskip
2583  \penalty5000
2584}
2585
2586\def\unnchfplain #1{%
2587\pchapsepmacro %
2588{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
2589                  \parindent=0pt\raggedright
2590                  \rm #1\hfill}}\bigskip \par\penalty 10000 %
2591}
2592\CHAPFplain % The default
2593
2594\def\unnchfopen #1{%
2595\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
2596                       \parindent=0pt\raggedright
2597                       \rm #1\hfill}}\bigskip \par\penalty 10000 %
2598}
2599
2600\def\chfopen #1#2{\chapoddpage {\chapfonts
2601\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
2602\par\penalty 5000 %
2603}
2604
2605\def\CHAPFopen{
2606\global\let\chapmacro=\chfopen
2607\global\let\unnumbchapmacro=\unnchfopen}
2608
2609% Parameter controlling skip before section headings.
2610
2611\newskip \subsecheadingskip  \subsecheadingskip = 17pt plus 8pt minus 4pt
2612\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
2613
2614\newskip \secheadingskip  \secheadingskip = 21pt plus 8pt minus 4pt
2615\def\secheadingbreak{\dobreak \secheadingskip {-1000}}
2616
2617% @paragraphindent  is defined for the Info formatting commands only.
2618\let\paragraphindent=\comment
2619
2620% Section fonts are the base font at magstep2, which produces
2621% a size a bit more than 14 points in the default situation.
2622
2623\def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}}
2624\def\plainsecheading #1{\secheadingi {#1}}
2625\def\secheadingi #1{{\advance \secheadingskip by \parskip %
2626\secheadingbreak}%
2627{\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000
2628                 \parindent=0pt\raggedright
2629                 \rm #1\hfill}}%
2630\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
2631
2632
2633% Subsection fonts are the base font at magstep1,
2634% which produces a size of 12 points.
2635
2636\def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}}
2637\def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip %
2638\subsecheadingbreak}%
2639{\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
2640                     \parindent=0pt\raggedright
2641                     \rm #1\hfill}}%
2642\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 }
2643
2644\def\subsubsecfonts{\subsecfonts} % Maybe this should change:
2645				  % Perhaps make sssec fonts scaled
2646				  % magstep half
2647\def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}}
2648\def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip %
2649\subsecheadingbreak}%
2650{\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000
2651                       \parindent=0pt\raggedright
2652                       \rm #1\hfill}}%
2653\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000}
2654
2655
2656\message{toc printing,}
2657
2658% Finish up the main text and prepare to read what we've written
2659% to \contentsfile.
2660
2661\newskip\contentsrightmargin \contentsrightmargin=1in
2662\def\startcontents#1{%
2663   \pagealignmacro
2664   \immediate\closeout \contentsfile
2665   \ifnum \pageno>0
2666      \pageno = -1		% Request roman numbered pages.
2667   \fi
2668   % Don't need to put `Contents' or `Short Contents' in the headline.
2669   % It is abundantly clear what they are.
2670   \unnumbchapmacro{#1}\def\thischapter{}%
2671   \begingroup   		% Set up to handle contents files properly.
2672      \catcode`\\=0  \catcode`\{=1  \catcode`\}=2  \catcode`\@=11
2673      \raggedbottom             % Worry more about breakpoints than the bottom.
2674      \advance\hsize by -\contentsrightmargin % Don't use the full line length.
2675}
2676
2677
2678% Normal (long) toc.
2679\outer\def\contents{%
2680   \startcontents{\putwordTableofContents}%
2681      \input \jobname.toc
2682   \endgroup
2683   \vfill \eject
2684}
2685
2686% And just the chapters.
2687\outer\def\summarycontents{%
2688   \startcontents{\putwordShortContents}%
2689      %
2690      \let\chapentry = \shortchapentry
2691      \let\unnumbchapentry = \shortunnumberedentry
2692      % We want a true roman here for the page numbers.
2693      \secfonts
2694      \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
2695      \rm
2696      \advance\baselineskip by 1pt % Open it up a little.
2697      \def\secentry ##1##2##3##4{}
2698      \def\unnumbsecentry ##1##2{}
2699      \def\subsecentry ##1##2##3##4##5{}
2700      \def\unnumbsubsecentry ##1##2{}
2701      \def\subsubsecentry ##1##2##3##4##5##6{}
2702      \def\unnumbsubsubsecentry ##1##2{}
2703      \input \jobname.toc
2704   \endgroup
2705   \vfill \eject
2706}
2707\let\shortcontents = \summarycontents
2708
2709% These macros generate individual entries in the table of contents.
2710% The first argument is the chapter or section name.
2711% The last argument is the page number.
2712% The arguments in between are the chapter number, section number, ...
2713
2714% Chapter-level things, for both the long and short contents.
2715\def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
2716
2717% See comments in \dochapentry re vbox and related settings
2718\def\shortchapentry#1#2#3{%
2719  \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}%
2720}
2721
2722% Typeset the label for a chapter or appendix for the short contents.
2723% The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter.
2724% We could simplify the code here by writing out an \appendixentry
2725% command in the toc file for appendices, instead of using \chapentry
2726% for both, but it doesn't seem worth it.
2727\setbox0 = \hbox{\shortcontrm \putwordAppendix }
2728\newdimen\shortappendixwidth \shortappendixwidth = \wd0
2729
2730\def\shortchaplabel#1{%
2731  % We typeset #1 in a box of constant width, regardless of the text of
2732  % #1, so the chapter titles will come out aligned.
2733  \setbox0 = \hbox{#1}%
2734  \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi
2735  %
2736  % This space should be plenty, since a single number is .5em, and the
2737  % widest letter (M) is 1em, at least in the Computer Modern fonts.
2738  % (This space doesn't include the extra space that gets added after
2739  % the label; that gets put in in \shortchapentry above.)
2740  \advance\dimen0 by 1.1em
2741  \hbox to \dimen0{#1\hfil}%
2742}
2743
2744\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
2745\def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}}
2746
2747% Sections.
2748\def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
2749\def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
2750
2751% Subsections.
2752\def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
2753\def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
2754
2755% And subsubsections.
2756\def\subsubsecentry#1#2#3#4#5#6{%
2757  \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
2758\def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
2759
2760
2761% This parameter controls the indentation of the various levels.
2762\newdimen\tocindent \tocindent = 3pc
2763
2764% Now for the actual typesetting. In all these, #1 is the text and #2 is the
2765% page number.
2766%
2767% If the toc has to be broken over pages, we would want to be at chapters
2768% if at all possible; hence the \penalty.
2769\def\dochapentry#1#2{%
2770   \penalty-300 \vskip\baselineskip
2771   \begingroup
2772     \chapentryfonts
2773     \tocentry{#1}{\dopageno{#2}}%
2774   \endgroup
2775   \nobreak\vskip .25\baselineskip
2776}
2777
2778\def\dosecentry#1#2{\begingroup
2779  \secentryfonts \leftskip=\tocindent
2780  \tocentry{#1}{\dopageno{#2}}%
2781\endgroup}
2782
2783\def\dosubsecentry#1#2{\begingroup
2784  \subsecentryfonts \leftskip=2\tocindent
2785  \tocentry{#1}{\dopageno{#2}}%
2786\endgroup}
2787
2788\def\dosubsubsecentry#1#2{\begingroup
2789  \subsubsecentryfonts \leftskip=3\tocindent
2790  \tocentry{#1}{\dopageno{#2}}%
2791\endgroup}
2792
2793% Final typesetting of a toc entry; we use the same \entry macro as for
2794% the index entries, but we want to suppress hyphenation here.  (We
2795% can't do that in the \entry macro, since index entries might consist
2796% of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.)
2797%
2798\def\tocentry#1#2{\begingroup
2799  \hyphenpenalty = 10000
2800  \entry{#1}{#2}%
2801\endgroup}
2802
2803% Space between chapter (or whatever) number and the title.
2804\def\labelspace{\hskip1em \relax}
2805
2806\def\dopageno#1{{\rm #1}}
2807\def\doshortpageno#1{{\rm #1}}
2808
2809\def\chapentryfonts{\secfonts \rm}
2810\def\secentryfonts{\textfonts}
2811\let\subsecentryfonts = \textfonts
2812\let\subsubsecentryfonts = \textfonts
2813
2814
2815\message{environments,}
2816
2817% Since these characters are used in examples, it should be an even number of
2818% \tt widths. Each \tt character is 1en, so two makes it 1em.
2819% Furthermore, these definitions must come after we define our fonts.
2820\newbox\dblarrowbox    \newbox\longdblarrowbox
2821\newbox\pushcharbox    \newbox\bullbox
2822\newbox\equivbox       \newbox\errorbox
2823
2824\let\ptexequiv = \equiv
2825
2826%{\tentt
2827%\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
2828%\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
2829%\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
2830%\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
2831% Adapted from the manmac format (p.420 of TeXbook)
2832%\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
2833%                                      depth .1ex\hfil}
2834%}
2835
2836\def\point{$\star$}
2837
2838\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
2839\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
2840\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
2841
2842\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
2843
2844% Adapted from the TeXbook's \boxit.
2845{\tentt \global\dimen0 = 3em}% Width of the box.
2846\dimen2 = .55pt % Thickness of rules
2847% The text. (`r' is open on the right, `e' somewhat less so on the left.)
2848\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
2849
2850\global\setbox\errorbox=\hbox to \dimen0{\hfil
2851   \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
2852   \advance\hsize by -2\dimen2 % Rules.
2853   \vbox{
2854      \hrule height\dimen2
2855      \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
2856         \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
2857         \kern3pt\vrule width\dimen2}% Space to right.
2858      \hrule height\dimen2}
2859    \hfil}
2860
2861% The @error{} command.
2862\def\error{\leavevmode\lower.7ex\copy\errorbox}
2863
2864% @tex ... @end tex    escapes into raw Tex temporarily.
2865% One exception: @ is still an escape character, so that @end tex works.
2866% But \@ or @@ will get a plain tex @ character.
2867
2868\def\tex{\begingroup
2869\catcode `\\=0 \catcode `\{=1 \catcode `\}=2
2870\catcode `\$=3 \catcode `\&=4 \catcode `\#=6
2871\catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
2872\catcode `\%=14
2873\catcode 43=12
2874\catcode`\"=12
2875\catcode`\==12
2876\catcode`\|=12
2877\catcode`\<=12
2878\catcode`\>=12
2879\escapechar=`\\
2880%
2881\let\{=\ptexlbrace
2882\let\}=\ptexrbrace
2883\let\.=\ptexdot
2884\let\*=\ptexstar
2885\let\dots=\ptexdots
2886\def\@{@}%
2887\let\bullet=\ptexbullet
2888\let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl
2889\let\L=\ptexL
2890%
2891\let\Etex=\endgroup}
2892
2893% Define @lisp ... @endlisp.
2894% @lisp does a \begingroup so it can rebind things,
2895% including the definition of @endlisp (which normally is erroneous).
2896
2897% Amount to narrow the margins by for @lisp.
2898\newskip\lispnarrowing \lispnarrowing=0.4in
2899
2900% This is the definition that ^^M gets inside @lisp, @example, and other
2901% such environments.  \null is better than a space, since it doesn't
2902% have any width.
2903\def\lisppar{\null\endgraf}
2904
2905% Make each space character in the input produce a normal interword
2906% space in the output.  Don't allow a line break at this space, as this
2907% is used only in environments like @example, where each line of input
2908% should produce a line of output anyway.
2909%
2910{\obeyspaces %
2911\gdef\sepspaces{\obeyspaces\let =\tie}}
2912
2913% Define \obeyedspace to be our active space, whatever it is.  This is
2914% for use in \parsearg.
2915{\sepspaces%
2916\global\let\obeyedspace= }
2917
2918% This space is always present above and below environments.
2919\newskip\envskipamount \envskipamount = 0pt
2920
2921% Make spacing and below environment symmetrical.  We use \parskip here
2922% to help in doing that, since in @example-like environments \parskip
2923% is reset to zero; thus the \afterenvbreak inserts no space -- but the
2924% start of the next paragraph will insert \parskip
2925%
2926\def\aboveenvbreak{{\advance\envskipamount by \parskip
2927\endgraf \ifdim\lastskip<\envskipamount
2928\removelastskip \penalty-50 \vskip\envskipamount \fi}}
2929
2930\let\afterenvbreak = \aboveenvbreak
2931
2932% \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins.
2933\let\nonarrowing=\relax
2934
2935%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2936% \cartouche: draw rectangle w/rounded corners around argument
2937\font\circle=lcircle10
2938\newdimen\circthick
2939\newdimen\cartouter\newdimen\cartinner
2940\newskip\normbskip\newskip\normpskip\newskip\normlskip
2941\circthick=\fontdimen8\circle
2942%
2943\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
2944\def\ctr{{\hskip 6pt\circle\char'010}}
2945\def\cbl{{\circle\char'012\hskip -6pt}}
2946\def\cbr{{\hskip 6pt\circle\char'011}}
2947\def\carttop{\hbox to \cartouter{\hskip\lskip
2948	\ctl\leaders\hrule height\circthick\hfil\ctr
2949	\hskip\rskip}}
2950\def\cartbot{\hbox to \cartouter{\hskip\lskip
2951	\cbl\leaders\hrule height\circthick\hfil\cbr
2952	\hskip\rskip}}
2953%
2954\newskip\lskip\newskip\rskip
2955
2956\long\def\cartouche{%
2957\begingroup
2958	\lskip=\leftskip \rskip=\rightskip
2959	\leftskip=0pt\rightskip=0pt %we want these *outside*.
2960	\cartinner=\hsize \advance\cartinner by-\lskip
2961		 	  \advance\cartinner by-\rskip
2962	\cartouter=\hsize
2963	\advance\cartouter by 18pt % allow for 3pt kerns on either
2964%				     side, and for 6pt waste from
2965%				     each corner char
2966	\normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
2967	% Flag to tell @lisp, etc., not to narrow margin.
2968	\let\nonarrowing=\comment
2969	\vbox\bgroup
2970		\baselineskip=0pt\parskip=0pt\lineskip=0pt
2971		\carttop
2972		\hbox\bgroup
2973			\hskip\lskip
2974			\vrule\kern3pt
2975			\vbox\bgroup
2976				\hsize=\cartinner
2977				\kern3pt
2978				\begingroup
2979					\baselineskip=\normbskip
2980					\lineskip=\normlskip
2981					\parskip=\normpskip
2982					\vskip -\parskip
2983\def\Ecartouche{%
2984				\endgroup
2985				\kern3pt
2986			\egroup
2987			\kern3pt\vrule
2988			\hskip\rskip
2989		\egroup
2990		\cartbot
2991	\egroup
2992\endgroup
2993}}
2994
2995
2996% This macro is called at the beginning of all the @example variants,
2997% inside a group.
2998\def\nonfillstart{%
2999  \aboveenvbreak
3000  \inENV % This group ends at the end of the body
3001  \hfuzz = 12pt % Don't be fussy
3002  \sepspaces % Make spaces be word-separators rather than space tokens.
3003  \singlespace
3004  \let\par = \lisppar % don't ignore blank lines
3005  \obeylines % each line of input is a line of output
3006  \parskip = 0pt
3007  \parindent = 0pt
3008  \emergencystretch = 0pt % don't try to avoid overfull boxes
3009  % @cartouche defines \nonarrowing to inhibit narrowing
3010  % at next level down.
3011  \ifx\nonarrowing\relax
3012    \advance \leftskip by \lispnarrowing
3013    \exdentamount=\lispnarrowing
3014    \let\exdent=\nofillexdent
3015    \let\nonarrowing=\relax
3016  \fi
3017}
3018
3019% To ending an @example-like environment, we first end the paragraph
3020% (via \afterenvbreak's vertical glue), and then the group.  That way we
3021% keep the zero \parskip that the environments set -- \parskip glue
3022% will be inserted at the beginning of the next paragraph in the
3023% document, after the environment.
3024%
3025\def\nonfillfinish{\afterenvbreak\endgroup}%
3026
3027% This macro is
3028\def\lisp{\begingroup
3029  \nonfillstart
3030  \let\Elisp = \nonfillfinish
3031  \tt
3032  \rawbackslash % have \ input char produce \ char from current font
3033  \gobble
3034}
3035
3036% Define the \E... control sequence only if we are inside the
3037% environment, so the error checking in \end will work.
3038%
3039% We must call \lisp last in the definition, since it reads the
3040% return following the @example (or whatever) command.
3041%
3042\def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp}
3043\def\smallexample{\begingroup \def\Esmallexample{\nonfillfinish\endgroup}\lisp}
3044\def\smalllisp{\begingroup \def\Esmalllisp{\nonfillfinish\endgroup}\lisp}
3045
3046% @smallexample and @smalllisp.  This is not used unless the @smallbook
3047% command is given.  Originally contributed by Pavel@xerox.
3048%
3049\def\smalllispx{\begingroup
3050  \nonfillstart
3051  \let\Esmalllisp = \nonfillfinish
3052  \let\Esmallexample = \nonfillfinish
3053  %
3054  % Smaller interline space and fonts for small examples.
3055  \baselineskip 10pt
3056  \indexfonts \tt
3057  \rawbackslash % output the \ character from the current font
3058  \gobble
3059}
3060
3061% This is @display; same as @lisp except use roman font.
3062%
3063\def\display{\begingroup
3064  \nonfillstart
3065  \let\Edisplay = \nonfillfinish
3066  \gobble
3067}
3068
3069% This is @format; same as @display except don't narrow margins.
3070%
3071\def\format{\begingroup
3072  \let\nonarrowing = t
3073  \nonfillstart
3074  \let\Eformat = \nonfillfinish
3075  \gobble
3076}
3077
3078% @flushleft (same as @format) and @flushright.
3079%
3080\def\flushleft{\begingroup
3081  \let\nonarrowing = t
3082  \nonfillstart
3083  \let\Eflushleft = \nonfillfinish
3084  \gobble
3085}
3086\def\flushright{\begingroup
3087  \let\nonarrowing = t
3088  \nonfillstart
3089  \let\Eflushright = \nonfillfinish
3090  \advance\leftskip by 0pt plus 1fill
3091  \gobble}
3092
3093% @quotation does normal linebreaking and narrows the margins.
3094%
3095\def\quotation{%
3096\begingroup\inENV %This group ends at the end of the @quotation body
3097{\parskip=0pt  % because we will skip by \parskip too, later
3098\aboveenvbreak}%
3099\singlespace
3100\parindent=0pt
3101\let\Equotation = \nonfillfinish
3102% @cartouche defines \nonarrowing to inhibit narrowing
3103% at next level down.
3104\ifx\nonarrowing\relax
3105\advance \leftskip by \lispnarrowing
3106\advance \rightskip by \lispnarrowing
3107\exdentamount=\lispnarrowing
3108\let\nonarrowing=\relax
3109\fi}
3110
3111\message{defuns,}
3112% Define formatter for defuns
3113% First, allow user to change definition object font (\df) internally
3114\def\setdeffont #1 {\csname DEF#1\endcsname}
3115
3116\newskip\defbodyindent \defbodyindent=.4in
3117\newskip\defargsindent \defargsindent=50pt
3118\newskip\deftypemargin \deftypemargin=12pt
3119\newskip\deflastargmargin \deflastargmargin=18pt
3120
3121\newcount\parencount
3122% define \functionparens, which makes ( and ) and & do special things.
3123% \functionparens affects the group it is contained in.
3124\def\activeparens{%
3125\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
3126\catcode`\[=\active \catcode`\]=\active}
3127
3128% Make control sequences which act like normal parenthesis chars.
3129\let\lparen = ( \let\rparen = )
3130
3131{\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
3132
3133% Be sure that we always have a definition for `(', etc.  For example,
3134% if the fn name has parens in it, \boldbrax will not be in effect yet,
3135% so TeX would otherwise complain about undefined control sequence.
3136\global\let(=\lparen \global\let)=\rparen
3137\global\let[=\lbrack \global\let]=\rbrack
3138
3139\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
3140\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
3141
3142% Definitions of (, ) and & used in args for functions.
3143% This is the definition of ( outside of all parentheses.
3144\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested %
3145\global\advance\parencount by 1 }
3146%
3147% This is the definition of ( when already inside a level of parens.
3148\gdef\opnested{\char`\(\global\advance\parencount by 1 }
3149%
3150\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
3151% also in that case restore the outer-level definition of (.
3152\ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
3153\global\advance \parencount by -1 }
3154% If we encounter &foo, then turn on ()-hacking afterwards
3155\gdef\amprm#1 {{\rm\&#1}\let(=\oprm \let)=\clrm\ }
3156%
3157\gdef\normalparens{\boldbrax\let&=\ampnr}
3158} % End of definition inside \activeparens
3159%% These parens (in \boldbrax) actually are a little bolder than the
3160%% contained text.  This is especially needed for [ and ]
3161\def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&}
3162\def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}}
3163
3164% First, defname, which formats the header line itself.
3165% #1 should be the function name.
3166% #2 should be the type of definition, such as "Function".
3167
3168\def\defname #1#2{%
3169% Get the values of \leftskip and \rightskip as they were
3170% outside the @def...
3171\dimen2=\leftskip
3172\advance\dimen2 by -\defbodyindent
3173\dimen3=\rightskip
3174\advance\dimen3 by -\defbodyindent
3175\noindent        %
3176\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
3177\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
3178\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
3179\parshape 2 0in \dimen0 \defargsindent \dimen1     %
3180% Now output arg 2 ("Function" or some such)
3181% ending at \deftypemargin from the right margin,
3182% but stuck inside a box of width 0 so it does not interfere with linebreaking
3183{% Adjust \hsize to exclude the ambient margins,
3184% so that \rightline will obey them.
3185\advance \hsize by -\dimen2 \advance \hsize by -\dimen3
3186\rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}%
3187% Make all lines underfull and no complaints:
3188\tolerance=10000 \hbadness=10000
3189\advance\leftskip by -\defbodyindent
3190\exdentamount=\defbodyindent
3191{\df #1}\enskip        % Generate function name
3192}
3193
3194% Actually process the body of a definition
3195% #1 should be the terminating control sequence, such as \Edefun.
3196% #2 should be the "another name" control sequence, such as \defunx.
3197% #3 should be the control sequence that actually processes the header,
3198%    such as \defunheader.
3199
3200\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
3201\medbreak %
3202% Define the end token that this defining construct specifies
3203% so that it will exit this group.
3204\def#1{\endgraf\endgroup\medbreak}%
3205\def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
3206\parindent=0in
3207\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
3208\exdentamount=\defbodyindent
3209\begingroup %
3210\catcode 61=\active % 61 is `='
3211\obeylines\activeparens\spacesplit#3}
3212
3213\def\defmethparsebody #1#2#3#4 {\begingroup\inENV %
3214\medbreak %
3215% Define the end token that this defining construct specifies
3216% so that it will exit this group.
3217\def#1{\endgraf\endgroup\medbreak}%
3218\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
3219\parindent=0in
3220\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
3221\exdentamount=\defbodyindent
3222\begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
3223
3224\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
3225\medbreak %
3226% Define the end token that this defining construct specifies
3227% so that it will exit this group.
3228\def#1{\endgraf\endgroup\medbreak}%
3229\def#2##1 ##2 {\def#4{##1}%
3230\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
3231\parindent=0in
3232\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
3233\exdentamount=\defbodyindent
3234\begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
3235
3236% These parsing functions are similar to the preceding ones
3237% except that they do not make parens into active characters.
3238% These are used for "variables" since they have no arguments.
3239
3240\def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
3241\medbreak %
3242% Define the end token that this defining construct specifies
3243% so that it will exit this group.
3244\def#1{\endgraf\endgroup\medbreak}%
3245\def#2{\begingroup\obeylines\spacesplit#3}%
3246\parindent=0in
3247\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
3248\exdentamount=\defbodyindent
3249\begingroup %
3250\catcode 61=\active %
3251\obeylines\spacesplit#3}
3252
3253% This is used for \def{tp,vr}parsebody.  It could probably be used for
3254% some of the others, too, with some judicious conditionals.
3255%
3256\def\parsebodycommon#1#2#3{%
3257  \begingroup\inENV %
3258  \medbreak %
3259  % Define the end token that this defining construct specifies
3260  % so that it will exit this group.
3261  \def#1{\endgraf\endgroup\medbreak}%
3262  \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
3263  \parindent=0in
3264  \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
3265  \exdentamount=\defbodyindent
3266  \begingroup\obeylines
3267}
3268
3269\def\defvrparsebody#1#2#3#4 {%
3270  \parsebodycommon{#1}{#2}{#3}%
3271  \spacesplit{#3{#4}}%
3272}
3273
3274% This loses on `@deftp {Data Type} {struct termios}' -- it thinks the
3275% type is just `struct', because we lose the braces in `{struct
3276% termios}' when \spacesplit reads its undelimited argument.  Sigh.
3277% \let\deftpparsebody=\defvrparsebody
3278%
3279% So, to get around this, we put \empty in with the type name.  That
3280% way, TeX won't find exactly `{...}' as an undelimited argument, and
3281% won't strip off the braces.
3282%
3283\def\deftpparsebody #1#2#3#4 {%
3284  \parsebodycommon{#1}{#2}{#3}%
3285  \spacesplit{\parsetpheaderline{#3{#4}}}\empty
3286}
3287
3288% Fine, but then we have to eventually remove the \empty *and* the
3289% braces (if any).  That's what this does, putting the result in \tptemp.
3290%
3291\def\removeemptybraces\empty#1\relax{\def\tptemp{#1}}%
3292
3293% After \spacesplit has done its work, this is called -- #1 is the final
3294% thing to call, #2 the type name (which starts with \empty), and #3
3295% (which might be empty) the arguments.
3296%
3297\def\parsetpheaderline#1#2#3{%
3298  \removeemptybraces#2\relax
3299  #1{\tptemp}{#3}%
3300}%
3301
3302\def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
3303\medbreak %
3304% Define the end token that this defining construct specifies
3305% so that it will exit this group.
3306\def#1{\endgraf\endgroup\medbreak}%
3307\def#2##1 ##2 {\def#4{##1}%
3308\begingroup\obeylines\spacesplit{#3{##2}}}%
3309\parindent=0in
3310\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent
3311\exdentamount=\defbodyindent
3312\begingroup\obeylines\spacesplit{#3{#5}}}
3313
3314% Split up #2 at the first space token.
3315% call #1 with two arguments:
3316%  the first is all of #2 before the space token,
3317%  the second is all of #2 after that space token.
3318% If #2 contains no space token, all of it is passed as the first arg
3319% and the second is passed as empty.
3320
3321{\obeylines
3322\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
3323\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
3324\ifx\relax #3%
3325#1{#2}{}\else #1{#2}{#3#4}\fi}}
3326
3327% So much for the things common to all kinds of definitions.
3328
3329% Define @defun.
3330
3331% First, define the processing that is wanted for arguments of \defun
3332% Use this to expand the args and terminate the paragraph they make up
3333
3334\def\defunargs #1{\functionparens \sl
3335% Expand, preventing hyphenation at `-' chars.
3336% Note that groups don't affect changes in \hyphenchar.
3337\hyphenchar\tensl=0
3338#1%
3339\hyphenchar\tensl=45
3340\ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi%
3341\interlinepenalty=10000
3342\advance\rightskip by 0pt plus 1fil
3343\endgraf\penalty 10000\vskip -\parskip\penalty 10000%
3344}
3345
3346\def\deftypefunargs #1{%
3347% Expand, preventing hyphenation at `-' chars.
3348% Note that groups don't affect changes in \hyphenchar.
3349\functionparens
3350\tclose{#1}% avoid \code because of side effects on active chars
3351\interlinepenalty=10000
3352\advance\rightskip by 0pt plus 1fil
3353\endgraf\penalty 10000\vskip -\parskip\penalty 10000%
3354}
3355
3356% Do complete processing of one @defun or @defunx line already parsed.
3357
3358% @deffn Command forward-char nchars
3359
3360\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
3361
3362\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
3363\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
3364\catcode 61=\other % Turn off change made in \defparsebody
3365}
3366
3367% @defun == @deffn Function
3368
3369\def\defun{\defparsebody\Edefun\defunx\defunheader}
3370
3371\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
3372\begingroup\defname {#1}{Function}%
3373\defunargs {#2}\endgroup %
3374\catcode 61=\other % Turn off change made in \defparsebody
3375}
3376
3377% @deftypefun int foobar (int @var{foo}, float @var{bar})
3378
3379\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
3380
3381% #1 is the data type.  #2 is the name and args.
3382\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
3383% #1 is the data type, #2 the name, #3 the args.
3384\def\deftypefunheaderx #1#2 #3\relax{%
3385\doind {fn}{\code{#2}}% Make entry in function index
3386\begingroup\defname {\code{#1} #2}{Function}%
3387\deftypefunargs {#3}\endgroup %
3388\catcode 61=\other % Turn off change made in \defparsebody
3389}
3390
3391% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
3392
3393\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
3394
3395% #1 is the classification.  #2 is the data type.  #3 is the name and args.
3396\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
3397% #1 is the classification, #2 the data type, #3 the name, #4 the args.
3398\def\deftypefnheaderx #1#2#3 #4\relax{%
3399\doind {fn}{\code{#3}}% Make entry in function index
3400\begingroup
3401\normalparens % notably, turn off `&' magic, which prevents
3402%               at least some C++ text from working
3403\defname {\code{#2} #3}{#1}%
3404\deftypefunargs {#4}\endgroup %
3405\catcode 61=\other % Turn off change made in \defparsebody
3406}
3407
3408% @defmac == @deffn Macro
3409
3410\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
3411
3412\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
3413\begingroup\defname {#1}{Macro}%
3414\defunargs {#2}\endgroup %
3415\catcode 61=\other % Turn off change made in \defparsebody
3416}
3417
3418% @defspec == @deffn Special Form
3419
3420\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
3421
3422\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
3423\begingroup\defname {#1}{Special Form}%
3424\defunargs {#2}\endgroup %
3425\catcode 61=\other % Turn off change made in \defparsebody
3426}
3427
3428% This definition is run if you use @defunx
3429% anywhere other than immediately after a @defun or @defunx.
3430
3431\def\deffnx #1 {\errmessage{@deffnx in invalid context}}
3432\def\defunx #1 {\errmessage{@defunx in invalid context}}
3433\def\defmacx #1 {\errmessage{@defmacx in invalid context}}
3434\def\defspecx #1 {\errmessage{@defspecx in invalid context}}
3435\def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}}
3436\def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}}
3437
3438% @defmethod, and so on
3439
3440% @defop {Funny Method} foo-class frobnicate argument
3441
3442\def\defop #1 {\def\defoptype{#1}%
3443\defopparsebody\Edefop\defopx\defopheader\defoptype}
3444
3445\def\defopheader #1#2#3{%
3446\dosubind {fn}{\code{#2}}{on #1}% Make entry in function index
3447\begingroup\defname {#2}{\defoptype{} on #1}%
3448\defunargs {#3}\endgroup %
3449}
3450
3451% @defmethod == @defop Method
3452
3453\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
3454
3455\def\defmethodheader #1#2#3{%
3456\dosubind {fn}{\code{#2}}{on #1}% entry in function index
3457\begingroup\defname {#2}{Method on #1}%
3458\defunargs {#3}\endgroup %
3459}
3460
3461% @defcv {Class Option} foo-class foo-flag
3462
3463\def\defcv #1 {\def\defcvtype{#1}%
3464\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
3465
3466\def\defcvarheader #1#2#3{%
3467\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
3468\begingroup\defname {#2}{\defcvtype{} of #1}%
3469\defvarargs {#3}\endgroup %
3470}
3471
3472% @defivar == @defcv {Instance Variable}
3473
3474\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
3475
3476\def\defivarheader #1#2#3{%
3477\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index
3478\begingroup\defname {#2}{Instance Variable of #1}%
3479\defvarargs {#3}\endgroup %
3480}
3481
3482% These definitions are run if you use @defmethodx, etc.,
3483% anywhere other than immediately after a @defmethod, etc.
3484
3485\def\defopx #1 {\errmessage{@defopx in invalid context}}
3486\def\defmethodx #1 {\errmessage{@defmethodx in invalid context}}
3487\def\defcvx #1 {\errmessage{@defcvx in invalid context}}
3488\def\defivarx #1 {\errmessage{@defivarx in invalid context}}
3489
3490% Now @defvar
3491
3492% First, define the processing that is wanted for arguments of @defvar.
3493% This is actually simple: just print them in roman.
3494% This must expand the args and terminate the paragraph they make up
3495\def\defvarargs #1{\normalparens #1%
3496\interlinepenalty=10000
3497\endgraf\penalty 10000\vskip -\parskip\penalty 10000}
3498
3499% @defvr Counter foo-count
3500
3501\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
3502
3503\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
3504\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
3505
3506% @defvar == @defvr Variable
3507
3508\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
3509
3510\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
3511\begingroup\defname {#1}{Variable}%
3512\defvarargs {#2}\endgroup %
3513}
3514
3515% @defopt == @defvr {User Option}
3516
3517\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
3518
3519\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
3520\begingroup\defname {#1}{User Option}%
3521\defvarargs {#2}\endgroup %
3522}
3523
3524% @deftypevar int foobar
3525
3526\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
3527
3528% #1 is the data type.  #2 is the name.
3529\def\deftypevarheader #1#2{%
3530\doind {vr}{\code{#2}}% Make entry in variables index
3531\begingroup\defname {\code{#1} #2}{Variable}%
3532\interlinepenalty=10000
3533\endgraf\penalty 10000\vskip -\parskip\penalty 10000
3534\endgroup}
3535
3536% @deftypevr {Global Flag} int enable
3537
3538\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
3539
3540\def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}%
3541\begingroup\defname {\code{#2} #3}{#1}
3542\interlinepenalty=10000
3543\endgraf\penalty 10000\vskip -\parskip\penalty 10000
3544\endgroup}
3545
3546% This definition is run if you use @defvarx
3547% anywhere other than immediately after a @defvar or @defvarx.
3548
3549\def\defvrx #1 {\errmessage{@defvrx in invalid context}}
3550\def\defvarx #1 {\errmessage{@defvarx in invalid context}}
3551\def\defoptx #1 {\errmessage{@defoptx in invalid context}}
3552\def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}}
3553\def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}}
3554
3555% Now define @deftp
3556% Args are printed in bold, a slight difference from @defvar.
3557
3558\def\deftpargs #1{\bf \defvarargs{#1}}
3559
3560% @deftp Class window height width ...
3561
3562\def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
3563
3564\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
3565\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
3566
3567% This definition is run if you use @deftpx, etc
3568% anywhere other than immediately after a @deftp, etc.
3569
3570\def\deftpx #1 {\errmessage{@deftpx in invalid context}}
3571
3572\message{cross reference,}
3573% Define cross-reference macros
3574\newwrite \auxfile
3575
3576\newif\ifhavexrefs  % True if xref values are known.
3577\newif\ifwarnedxrefs  % True if we warned once that they aren't known.
3578
3579% \setref{foo} defines a cross-reference point named foo.
3580
3581\def\setref#1{%
3582\dosetq{#1-title}{Ytitle}%
3583\dosetq{#1-pg}{Ypagenumber}%
3584\dosetq{#1-snt}{Ysectionnumberandtype}}
3585
3586\def\unnumbsetref#1{%
3587\dosetq{#1-title}{Ytitle}%
3588\dosetq{#1-pg}{Ypagenumber}%
3589\dosetq{#1-snt}{Ynothing}}
3590
3591\def\appendixsetref#1{%
3592\dosetq{#1-title}{Ytitle}%
3593\dosetq{#1-pg}{Ypagenumber}%
3594\dosetq{#1-snt}{Yappendixletterandtype}}
3595
3596% \xref, \pxref, and \ref generate cross-references to specified points.
3597% For \xrefX, #1 is the node name, #2 the name of the Info
3598% cross-reference, #3 the printed node name, #4 the name of the Info
3599% file, #5 the name of the printed manual.  All but the node name can be
3600% omitted.
3601%
3602\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
3603\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
3604\def\ref#1{\xrefX[#1,,,,,,,]}
3605\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup%
3606\def\printedmanual{\ignorespaces #5}%
3607\def\printednodename{\ignorespaces #3}%
3608%
3609\setbox1=\hbox{\printedmanual}%
3610\setbox0=\hbox{\printednodename}%
3611\ifdim \wd0=0pt%
3612% No printed node name was explicitly given.
3613\ifx SETxref-automatic-section-title %
3614% This line should make the actual chapter or section title appear inside
3615% the square brackets.  Use the real section title if we have it.
3616\ifdim \wd1>0pt%
3617% It is in another manual, so we don't have it.
3618\def\printednodename{\ignorespaces #1} \else%
3619% We know the real title if we have the xref values.
3620\ifhavexrefs \def\printednodename{\refx{#1-title}}%
3621% Otherwise just copy the Info node name.
3622\else \def\printednodename{\ignorespaces #1} \fi%
3623\fi\def\printednodename{#1-title}%
3624\else% This line just uses the node name.
3625\def\printednodename{\ignorespaces #1}%
3626\fi% ends \ifx SETxref-automatic-section-title
3627\fi% ends \ifdim \wd0
3628%
3629%
3630% If we use \unhbox0 and \unhbox1 to print the node names, TeX does
3631% not insert empty discretionaries after hyphens, which means that it
3632% will not find a line break at a hyphen in a node names.  Since some
3633% manuals are best written with fairly long node names, containing
3634% hyphens, this is a loss.  Therefore, we simply give the text of
3635% the node name again, so it is as if TeX is seeing it for the first
3636% time.
3637\ifdim \wd1>0pt
3638\putwordsection{} ``\printednodename'' in \cite{\printedmanual}%
3639\else%
3640\turnoffactive%
3641\refx{#1-snt}{} [\printednodename], \putwordpage\tie\refx{#1-pg}{}%
3642\fi
3643\endgroup}
3644
3645% \dosetq is the interface for calls from other macros
3646
3647% Use \turnoffactive so that punctuation chars such as underscore
3648% work in node names.
3649\def\dosetq #1#2{{\let\folio=0 \turnoffactive%
3650\edef\next{\write\auxfile{\internalsetq {#1}{#2}}}%
3651\next}}
3652
3653% \internalsetq {foo}{page} expands into
3654% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
3655% When the aux file is read, ' is the escape character
3656
3657\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
3658
3659% Things to be expanded by \internalsetq
3660
3661\def\Ypagenumber{\folio}
3662
3663\def\Ytitle{\thissection}
3664
3665\def\Ynothing{}
3666
3667\def\Ysectionnumberandtype{%
3668\ifnum\secno=0 \putwordChapter\xreftie\the\chapno %
3669\else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno %
3670\else \ifnum \subsubsecno=0 %
3671\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno %
3672\else %
3673\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
3674\fi \fi \fi }
3675
3676\def\Yappendixletterandtype{%
3677\ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}%
3678\else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno %
3679\else \ifnum \subsubsecno=0 %
3680\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
3681\else %
3682\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
3683\fi \fi \fi }
3684
3685\gdef\xreftie{'tie}
3686
3687% Use TeX 3.0's \inputlineno to get the line number, for better error
3688% messages, but if we're using an old version of TeX, don't do anything.
3689%
3690\ifx\inputlineno\thisisundefined
3691  \let\linenumber = \empty % Non-3.0.
3692\else
3693  \def\linenumber{\the\inputlineno:\space}
3694\fi
3695
3696% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
3697% If its value is nonempty, SUFFIX is output afterward.
3698
3699\def\refx#1#2{%
3700  \expandafter\ifx\csname X#1\endcsname\relax
3701    % If not defined, say something at least.
3702    $\langle$un\-de\-fined$\rangle$%
3703    \ifhavexrefs
3704      \message{\linenumber Undefined cross reference `#1'.}%
3705    \else
3706      \ifwarnedxrefs\else
3707        \global\warnedxrefstrue
3708        \message{Cross reference values unknown; you must run TeX again.}%
3709      \fi
3710    \fi
3711  \else
3712    % It's defined, so just use it.
3713    \csname X#1\endcsname
3714  \fi
3715  #2% Output the suffix in any case.
3716}
3717
3718% Read the last existing aux file, if any.  No error if none exists.
3719
3720% This is the macro invoked by entries in the aux file.
3721\def\xrdef #1#2{
3722{\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}}
3723
3724\def\readauxfile{%
3725\begingroup
3726\catcode `\^^@=\other
3727\catcode `\=\other
3728\catcode `\=\other
3729\catcode `\^^C=\other
3730\catcode `\^^D=\other
3731\catcode `\^^E=\other
3732\catcode `\^^F=\other
3733\catcode `\^^G=\other
3734\catcode `\^^H=\other
3735\catcode `\=\other
3736\catcode `\^^L=\other
3737\catcode `\=\other
3738\catcode `\=\other
3739\catcode `\=\other
3740\catcode `\=\other
3741\catcode `\=\other
3742\catcode `\=\other
3743\catcode `\=\other
3744\catcode `\=\other
3745\catcode `\=\other
3746\catcode `\=\other
3747\catcode `\=\other
3748\catcode `\=\other
3749\catcode 26=\other
3750\catcode `\^^[=\other
3751\catcode `\^^\=\other
3752\catcode `\^^]=\other
3753\catcode `\^^^=\other
3754\catcode `\^^_=\other
3755\catcode `\@=\other
3756\catcode `\^=\other
3757\catcode `\~=\other
3758\catcode `\[=\other
3759\catcode `\]=\other
3760\catcode`\"=\other
3761\catcode`\_=\other
3762\catcode`\|=\other
3763\catcode`\<=\other
3764\catcode`\>=\other
3765\catcode `\$=\other
3766\catcode `\#=\other
3767\catcode `\&=\other
3768% `\+ does not work, so use 43.
3769\catcode 43=\other
3770% the aux file uses ' as the escape.
3771% Turn off \ as an escape so we do not lose on
3772% entries which were dumped with control sequences in their names.
3773% For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
3774% Reference to such entries still does not work the way one would wish,
3775% but at least they do not bomb out when the aux file is read in.
3776\catcode `\{=1 \catcode `\}=2
3777\catcode `\%=\other
3778\catcode `\'=0
3779\catcode `\\=\other
3780\openin 1 \jobname.aux
3781\ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue
3782\global\warnedobstrue
3783\fi
3784% Open the new aux file.  Tex will close it automatically at exit.
3785\openout \auxfile=\jobname.aux
3786\endgroup}
3787
3788
3789% Footnotes.
3790
3791\newcount \footnoteno
3792
3793% The trailing space in the following definition for supereject is
3794% vital for proper filling; pages come out unaligned when you do a
3795% pagealignmacro call if that space before the closing brace is
3796% removed.
3797\def\supereject{\par\penalty -20000\footnoteno =0 }
3798
3799% @footnotestyle is meaningful for info output only..
3800\let\footnotestyle=\comment
3801
3802\let\ptexfootnote=\footnote
3803
3804{\catcode `\@=11
3805%
3806% Auto-number footnotes.  Otherwise like plain.
3807\gdef\footnote{%
3808  \global\advance\footnoteno by \@ne
3809  \edef\thisfootno{$^{\the\footnoteno}$}%
3810  %
3811  % In case the footnote comes at the end of a sentence, preserve the
3812  % extra spacing after we do the footnote number.
3813  \let\@sf\empty
3814  \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
3815  %
3816  % Remove inadvertent blank space before typesetting the footnote number.
3817  \unskip
3818  \thisfootno\@sf
3819  \footnotezzz
3820}%
3821
3822% Don't bother with the trickery in plain.tex to not require the
3823% footnote text as a parameter.  Our footnotes don't need to be so general.
3824%
3825\long\gdef\footnotezzz#1{\insert\footins{%
3826  % We want to typeset this text as a normal paragraph, even if the
3827  % footnote reference occurs in (for example) a display environment.
3828  % So reset some parameters.
3829  \interlinepenalty\interfootnotelinepenalty
3830  \splittopskip\ht\strutbox % top baseline for broken footnotes
3831  \splitmaxdepth\dp\strutbox
3832  \floatingpenalty\@MM
3833  \leftskip\z@skip
3834  \rightskip\z@skip
3835  \spaceskip\z@skip
3836  \xspaceskip\z@skip
3837  \parindent\defaultparindent
3838  %
3839  % Hang the footnote text off the number.
3840  \hang
3841  \textindent{\thisfootno}%
3842  %
3843  % Don't crash into the line above the footnote text.  Since this
3844  % expands into a box, it must come within the paragraph, lest it
3845  % provide a place where TeX can split the footnote.
3846  \footstrut
3847  #1\strut}%
3848}
3849
3850}%end \catcode `\@=11
3851
3852% Set the baselineskip to #1, and the lineskip and strut size
3853% correspondingly.  There is no deep meaning behind these magic numbers
3854% used as factors; they just match (closely enough) what Knuth defined.
3855%
3856\def\lineskipfactor{.08333}
3857\def\strutheightpercent{.70833}
3858\def\strutdepthpercent {.29167}
3859%
3860\def\setleading#1{%
3861  \normalbaselineskip = #1\relax
3862  \normallineskip = \lineskipfactor\normalbaselineskip
3863  \normalbaselines
3864  \setbox\strutbox =\hbox{%
3865    \vrule width0pt height\strutheightpercent\baselineskip
3866                    depth \strutdepthpercent \baselineskip
3867  }%
3868}
3869
3870% @| inserts a changebar to the left of the current line.  It should
3871% surround any changed text.  This approach does *not* work if the
3872% change spans more than two lines of output.  To handle that, we would
3873% have adopt a much more difficult approach (putting marks into the main
3874% vertical list for the beginning and end of each change).
3875%
3876\def\|{%
3877  % \vadjust can only be used in horizontal mode.
3878  \leavevmode
3879  %
3880  % Append this vertical mode material after the current line in the output.
3881  \vadjust{%
3882    % We want to insert a rule with the height and depth of the current
3883    % leading; that is exactly what \strutbox is supposed to record.
3884    \vskip-\baselineskip
3885    %
3886    % \vadjust-items are inserted at the left edge of the type.  So
3887    % the \llap here moves out into the left-hand margin.
3888    \llap{%
3889      %
3890      % For a thicker or thinner bar, change the `1pt'.
3891      \vrule height\baselineskip width1pt
3892      %
3893      % This is the space between the bar and the text.
3894      \hskip 12pt
3895    }%
3896  }%
3897}
3898
3899% For a final copy, take out the rectangles
3900% that mark overfull boxes (in case you have decided
3901% that the text looks ok even though it passes the margin).
3902%
3903\def\finalout{\overfullrule=0pt}
3904
3905
3906% End of control word definitions.
3907
3908\message{and turning on texinfo input format.}
3909
3910\def\openindices{%
3911   \newindex{cp}%
3912   \newcodeindex{fn}%
3913   \newcodeindex{vr}%
3914   \newcodeindex{tp}%
3915   \newcodeindex{ky}%
3916   \newcodeindex{pg}%
3917}
3918
3919% Set some numeric style parameters, for 8.5 x 11 format.
3920
3921%\hsize = 6.5in
3922\newdimen\defaultparindent \defaultparindent = 15pt
3923\parindent = \defaultparindent
3924\parskip 18pt plus 1pt
3925\setleading{15pt}
3926\advance\topskip by 1.2cm
3927
3928% Prevent underfull vbox error messages.
3929\vbadness=10000
3930
3931% Following George Bush, just get rid of widows and orphans.
3932\widowpenalty=10000
3933\clubpenalty=10000
3934
3935% Use TeX 3.0's \emergencystretch to help line breaking, but if we're
3936% using an old version of TeX, don't do anything.  We want the amount of
3937% stretch added to depend on the line length, hence the dependence on
3938% \hsize.  This makes it come to about 9pt for the 8.5x11 format.
3939%
3940\ifx\emergencystretch\thisisundefined
3941  % Allow us to assign to \emergencystretch anyway.
3942  \def\emergencystretch{\dimen0}%
3943\else
3944  \emergencystretch = \hsize
3945  \divide\emergencystretch by 45
3946\fi
3947
3948% Use @smallbook to reset parameters for 7x9.5 format  (or else 7x9.25)
3949\def\smallbook{
3950
3951% These values for secheadingskip and subsecheadingskip are
3952% experiments.  RJC 7 Aug 1992
3953\global\secheadingskip = 17pt plus 6pt minus 3pt
3954\global\subsecheadingskip = 14pt plus 6pt minus 3pt
3955
3956\global\lispnarrowing = 0.3in
3957\setleading{12pt}
3958\advance\topskip by -1cm
3959\global\parskip 3pt plus 1pt
3960\global\hsize = 5in
3961\global\vsize=7.5in
3962\global\tolerance=700
3963\global\hfuzz=1pt
3964\global\contentsrightmargin=0pt
3965
3966\global\pagewidth=\hsize
3967\global\pageheight=\vsize
3968
3969\global\let\smalllisp=\smalllispx
3970\global\let\smallexample=\smalllispx
3971\global\def\Esmallexample{\Esmalllisp}
3972}
3973
3974% Use @afourpaper to print on European A4 paper.
3975\def\afourpaper{
3976\global\tolerance=700
3977\global\hfuzz=1pt
3978\setleading{12pt}
3979\global\parskip 15pt plus 1pt
3980
3981\global\vsize= 53\baselineskip
3982\advance\vsize by \topskip
3983%\global\hsize=   5.85in     % A4 wide 10pt
3984\global\hsize=  6.5in
3985\global\outerhsize=\hsize
3986\global\advance\outerhsize by 0.5in
3987\global\outervsize=\vsize
3988\global\advance\outervsize by 0.6in
3989
3990\global\pagewidth=\hsize
3991\global\pageheight=\vsize
3992}
3993
3994% Define macros to output various characters with catcode for normal text.
3995\catcode`\"=\other
3996\catcode`\~=\other
3997\catcode`\^=\other
3998\catcode`\_=\other
3999\catcode`\|=\other
4000\catcode`\<=\other
4001\catcode`\>=\other
4002\catcode`\+=\other
4003\def\normaldoublequote{"}
4004\def\normaltilde{~}
4005\def\normalcaret{^}
4006\def\normalunderscore{_}
4007\def\normalverticalbar{|}
4008\def\normalless{<}
4009\def\normalgreater{>}
4010\def\normalplus{+}
4011
4012% This macro is used to make a character print one way in ttfont
4013% where it can probably just be output, and another way in other fonts,
4014% where something hairier probably needs to be done.
4015%
4016% #1 is what to print if we are indeed using \tt; #2 is what to print
4017% otherwise.  Since all the Computer Modern typewriter fonts have zero
4018% interword stretch (and shrink), and it is reasonable to expect all
4019% typewriter fonts to have this, we can check that font parameter.
4020%
4021\def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi}
4022
4023% Turn off all special characters except @
4024% (and those which the user can use as if they were ordinary).
4025% Most of these we simply print from the \tt font, but for some, we can
4026% use math or other variants that look better in normal text.
4027
4028\catcode`\"=\active
4029\def\activedoublequote{{\tt \char '042}}
4030\let"=\activedoublequote
4031\catcode`\~=\active
4032\def~{{\tt \char '176}}
4033\chardef\hat=`\^
4034\catcode`\^=\active
4035\def^{{\tt \hat}}
4036
4037\catcode`\_=\active
4038\def_{\ifusingtt\normalunderscore\_}
4039% Subroutine for the previous macro.
4040\def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}}
4041
4042% \lvvmode is equivalent in function to \leavevmode.
4043% Using \leavevmode runs into trouble when written out to
4044% an index file due to the expansion of \leavevmode into ``\unhbox
4045% \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our
4046% magic tricks with @.
4047\def\lvvmode{\vbox to 0pt{}}
4048
4049\catcode`\|=\active
4050\def|{{\tt \char '174}}
4051\chardef \less=`\<
4052\catcode`\<=\active
4053\def<{{\tt \less}}
4054\chardef \gtr=`\>
4055\catcode`\>=\active
4056\def>{{\tt \gtr}}
4057\catcode`\+=\active
4058\def+{{\tt \char 43}}
4059%\catcode 27=\active
4060%\def^^[{$\diamondsuit$}
4061
4062% Used sometimes to turn off (effectively) the active characters
4063% even after parsing them.
4064\def\turnoffactive{\let"=\normaldoublequote
4065\let~=\normaltilde
4066\let^=\normalcaret
4067\let_=\normalunderscore
4068\let|=\normalverticalbar
4069\let<=\normalless
4070\let>=\normalgreater
4071\let+=\normalplus}
4072
4073% Set up an active definition for =, but don't enable it most of the time.
4074{\catcode`\==\active
4075\global\def={{\tt \char 61}}}
4076
4077\catcode`\@=0
4078
4079% \rawbackslashxx output one backslash character in current font
4080\global\chardef\rawbackslashxx=`\\
4081%{\catcode`\\=\other
4082%@gdef@rawbackslashxx{\}}
4083
4084% \rawbackslash redefines \ as input to do \rawbackslashxx.
4085{\catcode`\\=\active
4086@gdef@rawbackslash{@let\=@rawbackslashxx }}
4087
4088% \normalbackslash outputs one backslash in fixed width font.
4089\def\normalbackslash{{\tt\rawbackslashxx}}
4090
4091% Say @foo, not \foo, in error messages.
4092\escapechar=`\@
4093
4094% \catcode 17=0   % Define control-q
4095\catcode`\\=\active
4096
4097% If a .fmt file is being used, we don't want the `\input texinfo' to show up.
4098% That is what \eatinput is for; after that, the `\' should revert to printing
4099% a backslash.
4100%
4101@gdef@eatinput input texinfo{@fixbackslash}
4102@global@let\ = @eatinput
4103
4104% On the other hand, perhaps the file did not have a `\input texinfo'. Then
4105% the first `\{ in the file would cause an error. This macro tries to fix
4106% that, assuming it is called before the first `\' could plausibly occur.
4107%
4108@gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi}
4109
4110%% These look ok in all fonts, so just make them not special.  The @rm below
4111%% makes sure that the current font starts out as the newly loaded cmr10
4112@catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other
4113
4114@textfonts
4115@rm
4116
4117@c Local variables:
4118@c page-delimiter: "^\\\\message"
4119@c End:
4120