@z --- fwebmac.web ---
$Id: fwebmac.web,v 1.53.1.13 1996/09/14 12:43:41 krommes Exp krommes $
$Revision: 1.53.1.13 $

Copyright (C) 1987 Princeton University

Original authors:  D. Knuth, S. Levy

Upgraded by J.A. Krommes for FWEB.

@x-----------------------------------------------------------------------------

\Title{fwebmac-1.60}
\author{John A. Krommes\\(after D. Knuth and S. Levy)}
\date{December 31, 1996}

\numberdefsfalse
\numbercodefalse

@Lx

@* INTRODUCTION.  These are the standard macros for \FWEB\ (v.~1.60)
listings (in addition to those of \.{PLAIN.TEX} and/or \LaTeX).  Beginning
with v.~1.50, \LaTeXe\ is supported.

WARNING: Some of these macros are not independent of stuff hard-coded
into \FWEAVE. In other words, if you change something here, you may also need
to recompile \FWEAVE. So caution!

@ Print a comment at the beginning of the \.{.sty} file that is created.
@A
% --- THIS IS fwebmac.sty ---

% DO NOT EDIT THIS FILE; it is generated automatically from fwebmac.web.
% This file must be included into all .tex files produced by FWEAVE. 
% You can weave fwebmac.web to see discussions of the fwebmac.sty logic.

% ---------------------------------------------------------------------------

@ First, we have a flag |\FWEBisloaded| that prevents \.{fwebmac.sty} from
being loaded twice.  For the use of this flag, see the Dirty Tricks
appendix of the \TeX book. 

@A
% If it's not defined yet, load in the macros.
\ifx\FWEBisloaded\relax\endinput\else\let\FWEBisloaded\relax\fi

@ \FWEB\ can be run either in stand-alone mode (the usual application), or
\FWEAVE\ output can be incorporated into a \LaTeX\ document.  To
distinguish, we need a flag, |\FWEBstandalone|.  This is true by default;
however, it is made false when the package \.{fwebinsert} is invoked.

@A
\newif\ifFWEBstandalone
\FWEBstandalonetrue

@ We need to refer to various internal macros, so we make '\.{@@}' an
ordinary letter.
@f `\@@ 11
@A
\catcode`\@@=11

@ Here's something for trickery with catcodes.
@A
\chardef\other=12

@ One can comment stuff out by bracketing it with |\comment...\endcomment|.
@A
\long\def\comment#1\endcomment{}

@*1 The current version.
Various things need to know the current version number and date. 
@A
\def\FWEBversion{$REVISION}
\def\FWEBdate{September 23, 1995}

@*1 Defining robust macros.
Robust commands are useful; we provide our own version if the \LaTeXe\
|\DeclareRobustCommand| isn't available.  (However, at present our own
version just defines a macro with $n$~arguments; it doesn't actually make
it robust for \TeX\ or ordinary \LaTeX.)

@A
\newcount\W@@count
\newcount\W@@counta
\newtoks\W@@tk

\ifx\DeclareRobustCommand\undefined

	\def\DeclareRobustCommand#1{\@@ifnextchar[%
{\W@@argdef#1}{\W@@argdef#1[0]}}

	\def\W@@argdef#1[#2]{\W@@tk={}%
	\W@@count=0
	\loop
	\ifnum\W@@count<#2
		\advance\W@@count by1
		\edef\next{\W@@tk={\the\W@@tk########\the\W@@count}}\next
	\repeat
	\edef\next{\def\noexpand#1\the\W@@tk}\next}

\fi

\ifx\@@ifnextchar\undefined

	\def\@@ifnextchar#1#2#3{\let\@@tempe#1
	\def\@@tempa{#2}%
	\def\@@tempb{#3}%
	\futurelet\@@tempc\@@ifnch}

	\def\@@ifnch{\ifx\@@tempc\@@sptoken
		\let\@@tempd\@@xifnch
	\else
		\ifx\@@tempc\@@tempe
			\let\@@tempd\@@tempa
		\else
			\let\@@tempd\@@tempb
		\fi
	\fi
	\@@tempd
	}

	{\def\:{\global\let\@@sptoken= } \: }

	\def\@@xifnch{\futurelet\@@tempc\@@ifnch}

\fi


\let\DRC\DeclareRobustCommand

@*1 Printing ``\TeX'' and ``\LaTeX'', and distinguishing between them.
\FWEB\ now offers full \LaTeX\ support.  Here's how to refer to it.
[Note the use of |\W@@t| (defined in \WEBsection{syn} below) rather than
|\@@|; the latter is used for other things in \FWEB.]
@A
\def\TeX{T\kern-0.1667em\lower0.5ex\hbox{E}\kern-0.125emX\W@@t}

\ifx\LaTeX\undefined
	\def\LaTeX{L\kern-0.36em\raise0.3ex\hbox{\Csc a}\kern-0.15em\TeX}
\fi

\newif\ifnoLaTeXe% By default, we have \LaTeXe.

\ifx\LaTeXe\undefined
	\noLaTeXetrue
	\def\LaTeXe{\LaTeX 2$_\varepsilon$}
\fi

@ One needs to distinguish whether or not \LaTeX\ is loaded.  Assuming that
only \TeX\ or \LaTeX\ will be used, one way of doing this is to
discriminate on whether |\pageno| is defined.  

@A
\newif\ifLaTeXisloaded

\ifx\pageno\undefined
	\LaTeXisloadedtrue
\fi

\ifLaTeXisloaded
 \def\W@@stop{}
\else
 \def\W@@stop{
  \message{Please use LaTeX.  Plain TeX is no longer supported.  ABORTING!}
  \end
  }
\fi

\W@@stop

@ We also attempt to support \REVTeX.  This is annoying, because it doesn't
work properly with |\documentclass| yet.

@A
\newif\ifuseREVTeX
%\useREVTeXtrue

@ In two cases, we must use |\documentstyle| rather than |\documentclass|:
if we're not using \LaTeXe, or if we're using \REVTeX.  (The last ought to
be fixed by the \REVTeX\ people.)

@A
\newif\ifusedocumentstyle

\ifnoLaTeXe
	\usedocumentstyletrue
\fi

\ifuseREVTeX
	\usedocumentstyletrue
\fi


@*1 Convenience macros such as \.{\\FWEAVE} or \.{\\Fortran}.
Here's how to refer to the individual processors.  The user may wish to
redefine these.  Note that we use the primitive |\Wtypewriter|, since the
user can change the usual typewriter macro ``|\.|'' to something else.

@A
\DRC\WEB{\Wtypewriter{WEB}}
\DRC\FWEB{\Wtypewriter{FWEB}}
\DRC\CWEB{\Wtypewriter{CWEB}}
\DRC\TANGLE{\Wtypewriter{TANGLE}}	\let\Tangle\TANGLE
\DRC\WEAVE{\Wtypewriter{WEAVE}}		\let\Weave\WEAVE
\DRC\FTANGLE{\Wtypewriter{FTANGLE}}
\DRC\FWEAVE{\Wtypewriter{FWEAVE}}

@ Here's how one can refer to the individual languages.  The user may also wish
to redefine these.
@A
\DRC\C{C\W@@t}
\DRC\Cpp{\C{\tt ++}}
\DRC\FORTRAN{{\Csc Fortran}}	\let\Fortran\FORTRAN
\DRC\MAKE{{\tt MAKE}}		\let\Make\MAKE
\DRC\RATFOR{{\Csc Ratfor}}	\let\Ratfor\RATFOR
\DRC\UNIX{{\SC UNIX}}		\let\Unix\UNIX


@*1 Synonyms for macros such as \.{\\@@} usurped by \FWEB.
\modlabel{syn}
Now define a few things not known to \TeX, and remember some Plain \TeX\
stuff used for other purposes by \FWEB. 

@A
\ifLaTeXisloaded
\else
	\let\@@\relax
	\let\\\relax
	\let\protect\relax
\fi

\let\amp\&
\let\at\@@ 
\let\bslash\\
\let\caret\^
\let\dollar\$
\let\dstar\*
\let\equals\=
\let\period\.
\let\textcolon:
\let\leftbrace\{
\let\rightbrace\}
\let\vertbar|
\let\PM\#
\let\PC\%

@
@A
\let\W@@t\@@
\let\W@@S\S

@ (The following was for Plain \TeX, and is probably obsolete.) 
Additionally, the TeXbook manual macro package \.{manmac} redefines the
following stuff: 

 |\iftitle \titlefont \rhead \pagewidth \pageheight \output|

\noindent If you want to include \.{manmac.tex} to get various macro
definitions, the best scheme is to use the `\.{-w}'~command-line option to
prevent \FWEAVE\ from outputting |\input fwebmac.sty| as the first output line.
Then include both files explicitly, in this order:

	|\input manmac|
	|\input fwebmac.sty|

\noindent You can do this by defining the first limbo text command as
follows:

 |@@l "\\input manmac \\input fwebmac.sty"|

@*1 Paragraph skip and indentation for \TeX\ text.

@A
\dimen0=\normalbaselineskip
\parskip=\dimen0 plus 1pt minus 6pt

% If you don't like spaces between paragraphs, change |\pardimen| to |0pt|.
\newskip\pardimen
\pardimen=\parskip 

%\pardimen 0pt% No stretch between paragraphs

% Indentation for the \TeX\ part is handled in a separate variable
% |\TeXindent| (the style-file parameter \.{indent.TeX}) from the variable
% |\notch| (the style-file parameter \.{indent.code}) used for
% definition and code parts.  
\newdimen\TeXindent
\TeXindent 1em% For paragraphs in the \TeX\ part.

@*1 Page numbering.
If \LaTeX\ is loaded, we equate |\pageno| to \LaTeX's counter so that the
|\label| macro works correctly.  

@A 
\ifLaTeXisloaded
	\let\pageno\c@@page% \WEB\ has its own name for the page number.
\fi

@* FONTS. Several fonts have been declared in addition to the standard ones of
\.{PLAIN} format:
$$\vbox{\halign{\.{\\#}\quad\hfil&---\quad#\hfil\cr
titlefont&\titlefont Title.\cr
ttitlefont&\ttitlefont Title.\cr
SC&\SC SMALL CAPS.\cr
Csc&\Csc CAPS/Small caps.\cr
tentex&\tentex \TeX\ extended character set, including~'\.{\ }'.\cr
bfit&\bfit Bold-faced italic.\cr
}}$$
The main font used for text is called |\mainfont|, which is |\let| to |\tenrm|.
The font used for comments is called |\cmntfont|.  By default, this is
|\let| to |\mainfont|.

@A
\ifnoLaTeXe
	\ifx\tenrm\undefined
		\font\tenrm=cmr10
	\fi
	\ifx\itfam\undefined
		\chardef\itfam4
	\fi
	\ifx\small\undefined
		\let\small\relax
	\fi
	\let\mainfont\tenrm \let\cmntfont\tenrm
	\font\eightrm=cmr8 \let\SC\eightrm 

	\font\titlefont=cmssbx10 scaled \magstep2% Sans serif
	\font\ttitlefont=cmtt10 scaled\magstep2% Typewriter type

	\font\tentex=cmtex10 % \TeX\ \.{extended char.\ set} (used in strings)
	\let\extendedtex\tentex
	\font\Csc=cmcsc10 % Caps/small caps.
	\font\tenbfit=cmbxti10 % \&{Intrinsic functions}
	\let\bfit\tenbfit % Doesn't work right in titles.

% Used for module-number subscript:
	\font\seventi=cmti7
	\font\sevenrm=cmr7
	\font\sevenbf=cmbx7

% For special handling of array indices:
	\font\sevenit=cmti7
	\scriptfont\itfam=\sevenit

@%\font\fiveit=cmti5
@%\scriptscriptfont\itfam=\fiveit
	\scriptscriptfont\itfam=\sevenit

	\def\mathrm#1{{\rm #1}}
	\def\mathit#1{{\it #1}}

\else % \LaTeXe
	\def\mainfont{\normalsize\usefont{OT1}{\rmdefault}{m}{n}}
	\let\cmntfont\mainfont

	\def\eightrm{\footnotesize\usefont{OT1}{\rmdefault}{m}{n}}
	\let\SC\eightrm

	\def\titlefont{\Large\usefont{OT1}{\sfdefault}{\bfdefault}{n}}
	\def\ttitlefont{\Large\usefont{OT1}{\ttdefault}{m}{n}}

	\def\extendedtex{\usefont{OT1}{\ttdefault}{m}{n}}
	\def\tentex{\normalsize\extendedtex}

	\def\Csc{\usefont{OT1}{\rmdefault}{m}{\scdefault}}

	\def\bfit{\usefont{OT1}{\rmdefault}{\bfdefault}{\itdefault}}
	\def\tenbfit{\normalsize\bfit}

	\def\seventi{\scriptsize\usefont{OT1}{\rmdefault}{m}{\itdefault}}
	\def\sevenrm{\scriptsize\usefont{OT1}{\rmdefault}{m}{n}}
	\def\sevenbf{\scriptsize\usefont{OT1}{\rmdefault}{\bfdefault}{n}}

	\def\fiveti{\tiny\usefont{OT1}{\rmdefault}{m}{\itdefault}}
	\def\fiverm{\tiny\usefont{OT1}{\rmdefault}{m}{n}}
	\def\fivebf{\tiny\usefont{OT1}{\rmdefault}{\bfdefault}{n}}

	\def\tensy{\normalsize\usefont{OT1}{cmsy}{m}{n}}

%	\def\pbf{\fontfamily{\rmdefault}\fontseries{\bfdefault}\fontshape{n}%
%		\selectfont}
%	\def\ptt{\fontfamily{\ttdefault}\fontseries{m}\fontshape{n}\selectfont}
\fi

@* HIGHLIGHTING MACROS.  
These are used for displaying identifiers, reserved words, intrinsic
functions, etc.  

@*1 The primitive highlighting macros.
Typically the user (or \FWEB\ automatically) does not
actually type these macros directly.  Instead of saying ``|\Wshort{x}|'',
one says ``|\|x|''.  The associations between the short-hand convenience
macros such as `|\||', `|\&|', etc.\ are made by an equating procedure
carried out by the |\Wbegin| macro (see \WEBsection{Wbegin} below).  The
short-hand names are style-file 
parameters that can be changed by the user.  For more information, consult
the on-line documentation, menu item |fwebmac params|.

@A
\DRC\Wshort[1]{\leavevmode\hbox{$#1$}}% One-letter identifiers such
	% as~\Wshort{x} look better this way.

\DRC\Wid[1]{\leavevmode\hbox{\it#1\/\kern.05em}}% Italic type for ordinary
	% identifiers such as \Wid{test}.

\DRC\WID[1]{\leavevmode\hbox{\small\it#1\/\kern.05em}}% For all \WID{UPPERCASE}.

% By default, macros are formatted the same way as ordinary identifiers.
% However, one can change the following definitions to get special effects.
% Either make your own version of |fwebmac.sty| (use a change file with
% |fwebmac.web|), or redefine |\WidD| and/or |\WidM| with an \.{@@l} command.
\let\WidD\Wid % Outer macro
\let\WIDD\WID % Upper-case outer macro

\let\WidM\Wid % FWEB macro
\let\WIDM\WID % Upper-case FWEB macro

\DRC\Wreserved[1]{\leavevmode\hbox{\def\\{\tt\WBS}\bf#1\/}}% Boldface type
	% for reserved words such as \Wreserved{int}.

\DRC\WRESERVED[1]{\leavevmode\hbox{\def\\{\tt\WBS}\small\bf#1\/}}% Boldface type
	% for upper-case reserved words such as \WRESERVED{INTEGER}.


\DRC\Wintrinsic[1]{\leavevmode\hbox{\def\\{\tt\WBS}\bfit#1\/\kern.05em}}%
	% Library/intrinsic function name such as \@@{sin}.

@*1 Equating abbreviations to the primitive highlighting macros.
In the following, we use |\gdef| instead of |\global\let| because we
might want to change the definition of, e.g., |\WidM| with an \.{@@l}
command, which comes {\it after} the |\Wbegin| statement.

@A
\def\W@@twodef#1#2#3#4{\gdef#1{#3}\gdef#2{#4}}

\def\Wequate#1#2#3#4#5#6#7#8#9{%
	\W@@twodef#1\Wreserved\WRESERVED% |\&| by default.
	\gdef#2{\Wshort}% |\|| by default.
% Don't reorder the following four statements! In case arguments 3--6 are
% identical, one wants the ordinary identifier to win.
	\W@@twodef#5\WidM\WIDM% |\\| by default.
	\W@@twodef#4\WidD\WIDD% |\\| by default.
	\W@@twodef#3\Wid\WID% |\\| by default.
	\gdef#6{\Wintrinsic}% |\@@| by default.
	\W@@twodef#7\Wkeyword\WKEYWORD% |\.| by default.
	\gdef#8{\Wtypewriter}% |\.| by default.
	% \#9 is for future use.
	}

@ Identifiers that are recognized as function or macro names are followed
by the construction\hfil\break
\.{\\WIN\{{\it name}\_{\it type}\}\{{\it module}\_{\it number}\}}.  The
cases for the first argument correspond to 
$$\vbox{\halign{#\hfil&\ ---\ #\hfil\cr
0&Generic name, defined by \.{@@[}.\cr
1&Function name.\cr
2&\WEB\ macro (\.{@@m}).\cr
3&Outer macro (\.{@@d}).\cr
4&Reserved name defined with~\.{@@`}.\cr
5&|@c typedef| name.\cr
}}$$
If the name was defined in the current module, the second argument will be
zero; otherwise it will be the section number in which the name was
defined.  The macro shows how to display the 0~state differently (here with
a bullet).   Also, note how combinations of underlining and fonts are used
to distinguish the various kinds of identifiers.

@A
\def\W@@zero{0}% For the comparison in |\WIN| below.

\DRC\WIN[2]{\ifmmode\def\ZZ{}\else\def\ZZ{\null$\null}\fi
	\ZZ_{\def\W@@rg{#2}\ifx\W@@rg\W@@zero{\bullet}\else\W@@IN{#1}{#2}\fi}\ZZ}


% Format the module-number subscript.
\gdef\W@@IN#1#2{%
	\ifcase#1
	 \underline{\hbox{\sevenrm\Wmodtrans{#2}}}% Generic name (\.{@@[}). [0]
	\or\hbox{\sevenrm\Wmodtrans{#2}}% Function name. [1]
	\or\underline{\hbox{\seventi\Wmodtrans{#2}}}% WEB macro. [2]
	\or\hbox{\seventi\Wmodtrans{#2}}% Outer macro. [3]
	\or\underline{\hbox{\sevenbf\Wmodtrans{#2}}}% \.{@@`}. [4]
	\or\hbox{\sevenbf\Wmodtrans{#2}}% \&{typedef}. [5]
	\else{\Wmodtrans{#2}}% Error trap.
	\fi
	}


@* STRINGS. Strings are indicated by ``\.{\\.\{\dots\}}''.  You can also
use this for typewriter type; remember to escape the appropriate symbols:
``\.{\ \\\#\%\$\^\_\{\}\~\&}''.  The string macro itself does not surround
its contents with an |\hbox|, in order that long strings can be broken by
discretionaries (done automatically by \FWEAVE).

@A
\DRC\Wtypewriter[1]{\relax\ifmmode\gdef\YY{\null$\null}\else\gdef\YY{}\fi
	\YY{\leavevmode\W@@INITSTR#1}\YY}

% The following are for certain \Fortran\ keywords.
\let\Wkeyword\Wtypewriter
\let\WKEYWORD\Wtypewriter

\let\.\Wtypewriter

@*1 Nucleus for the string macro.
Here is the nucleus for the string macro~|\.| (more precisely, for
|\Wtypewriter|).

@A
\def\W@@INITSTR{%
	\extendedtex % Typewriter type for strings.  (We don't say
%|\tentex| here so the font can grow in a title.)
	\let\\=\WBS % Backslash in a string: '\.\\'.
	\let\'=\WRQ % Right quote in a string: '\.\''.
	\let\`=\WLQ % Left quote in a string: '\.\`'.
	\let\{=\WLB % Left brace in a string: '\.\WLB'.
	\let\}=\WRB % Right brace in a string: '\.\WRB'.
	\let\~=\WTL % Tilde in a string: '\.\~'.
	\let\ =\WSP % Space in a string: '\.\ '.
	\let\_=\WUL % Underline in a string: '\.\_'.
	\let\&=\WAM % Ampersand in a string: '\.\&'.
	\def\0{\discretionary{\WBS}{}{}}% \FWEB\ inserts this automatically every
	  % so often so very long strings will break. Broken strings will
	  % be marked by a backslash.
	\def\1{,\0}% \FWEB\ replaces commas in strings by this, so strings
		% tend to break after commas.
	\let\2\space % Ordinary space after control sequences in \TeX.
	\def\3{\space\space}% Translation of a tab in \TeX.
	}

@*1 Characters for strings.
@A
\DRC\#{\hbox{\tt\char35}}% Parameter sign: '\#'.
\DRC\${\hbox{\tt\char36}}% Dollar sign: '\$'.
\DRC\%{\hbox{\tt\char37}}% Percent sign: '\%'.
\DRC\^{\ifmmode\raise0.45ex\hbox{$\,\scriptstyle\mathchar"25E\,$}%
	\else\char`^ \fi}% Pointer or 
	% hat: '\^'. 
	% Circumflex accents can be obtained from |\^^D| instead of |\^|.
\let\Caret\^% For proper indexing of |@c++ operator ^|.
\def\AT!{@@}% Knuth's abbreviation for the at sign for control text: '\AT!'

@ The following funny business about asterisks is in case one wants to be
clever and make~`\.*' an active character (for example, for complex
conjugation).  (Actually, the |\ast| definition appears to be both
unnecessary and incorrect.  The braces kill the binary nature.  Also,
\FWEB\ emits |\ast| in place of |@n *|, and because the ilk of |@n *| is |@c
binop|, this should always be in math mode.)

@A
\chardef\asterisk=`\*
%\DRC\ast{\ifmmode{\displaystyle\mathchar"2203}\else\asterisk\fi} 

@ More stuff for strings.
@A
\chardef\WAM=`\&% Ampersand character in a string: '\.\&'.
\chardef\WBS=`\\% Backslash in a string: '\.\\'.
\DRC\WttBS{{\tt\WBS}}% Literal backslash: '\WttBS'.
\chardef\WLB=`\{% Left brace in a string: '\.\WLB'.
\DRC\WLQ{{\tt\char'22}}% Left quote in a string: '\.\`'.
\chardef\WRB=`\}% Right brace in a string: '\.\WRB'.
\DRC\WRQ{{\tt\char'23}}% Right quote in a string: '\.\''.
\DRC\WSP{{\tt\char`\ }}% (Visible) space in a string: '\.\ '.
\chardef\WTL=`\~% Tilde in a string: '\.\~'.
\chardef\WUL=`\_% Underline character in a string: '\.\_'.

@ Left quote outside a string:
@A
\DRC\WLQx{\hbox{\WLQ}}

@* INDENTATION, LINEBREAKS, etc{.}.  These commands are mostly handled by the
macros~|\1| to~|\8|.

@*1 Demonstration of the indentation scheme.
First, here are some macros to draw vertical lines to show off the indentation
scheme.

@A
\newbox\rulebox
\newcount\ruleno

\def\rules#1{\leavevmode
	\ruleno=0
	\rlap{\vtop to 0pt{\null
		\def\R{\setbox0=\hbox{\the\ruleno}%
			\rlap{\vrule height0pt depth#1}%
			\kern-0.5\wd0\copy0\kern-0.5\wd0
			\advance\ruleno by1
			\hskip1em}
		\rlap{\R\R\R\R\R\R\R}
		\vss}}}

@ The indentation scheme is as follows.  The unit of indentation is
|\notch|.
@A
\newdimen\notch

@ Here is typical output.

\setbox\rulebox\vtop{\null
\ifnoLaTeXe
\else
	\let\\\>
\fi
\WY $\WP\WE{if}\WO{1}{}$\par
\WP\WMd$\@|A\WIN2{0}$\5
$\WO{2}{}$\par
\WP\WE{endif}\par
\WP\WMD$\\{ALPHA}$\5
$\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+%
\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+%
\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+%
\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+%
\\{xxx}+\\{yyy}+\\{xxx}{}$\par
\WY\WP$\\{main}(\,)$\1\1\6
\&{int} \1\\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, %
\\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, %
\\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, \\{abcde}, \\{abcde};\2%
\2\2\1\6
$\{{}$\6
\WE{if}$\WO{1111}+\WO{2222}+\WO{1111}+\WO{2222}+\WO{1111}+\WO{2222}+\WO{1111}+%
\WO{2222}+\WO{1111}+\WO{2222}+\\{aaaa}+\\{bbbb}+\WO{1111}+\WO{2222}+\WO{1111}+%
\WO{2222}+\WO{1111}+\WO{2222}+\WO{1111}+\WO{2222}+\WO{1111}+\WO{2222}$\WPs\7
$\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+%
\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+%
\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\{yyy}+\\{xxx}+\\z;{}$%
\7
\WE{endif}\WPs\6
$\}$\2\WY\par
}

\vbox{\noindent\rules{\dp\rulebox}\box\rulebox}

@*1 Indentation conventions.
Preprocessor commands in the definition part are far left, definition-part
commands such  
as~\.{@@m} are indented one notch, function names are at two notches, and
the body of functions is at three notches.  This distance is given the
special name |\W@@globalindent|:

@A
\newcount\W@@globalindent
\W@@globalindent=3 % Global indentation in notches.

@ The current indentation is called |\W@@ind|.  One also sometimes needs to save
and restore that.
@A
\newcount\W@@ind % Current indentation in notches.
\newcount\W@@lastind % Used for preprocessor commands.
\def\W@@saveind{\global\W@@lastind=\W@@ind}

@*1 Backspacing.
Each output line of code is a separate paragraph.  The scheme proceeds by
first setting |\W@@ind|~to the appropriate hanging indentation, then
backspacing appropriately.  Here are the backspace quantities.  Note that
one can't initialize the boxes here, because the value of |\notch| isn't
known until after |\Wbegin| (it's the style-file parameter \.{indent.code}).

@A
\newbox\b@@k  
\newbox\b@@kk 

\def\W@@setboxes#1{\notch=#1
	\setbox\b@@k=\hbox to -\notch{}% Backspace one notch.
	\setbox\b@@kk=\hbox to -2\notch{}% Backspace two notches.
	}

@ In order to implement the line-break macro |@@/| appropriately, the
|\WBK| macro is emitted.  This must deal with the fact that sometimes, but
not always, the hanging indentation is changed in the middle of the line
(as in a variable declaration like `|@c int i,j;|'.  Therefore, |\WBK|
computes the proper indentation at the point of its first occurence in the
line, and uses that for all subsequent instances of |\WBK| within that same
line.

@A
\newif\ifW@@firstbreak

\newcount\W@@nBK

\def\WBKo{}% NOT FINISHED YET!

\def\WBK{\WBK@@{0}}

\def\WBK@@#1{\hfil\break
\ifW@@firstbreak
	\W@@nBK=\W@@ind
	\advance\W@@nBK by -#1 % Compensate for glob's outdented by 1 from body.
	\W@@firstbreakfalse % Reset by |\6|.
\fi
\hangindent\W@@nBK\notch
\ignorespaces}

@*1 The macros |\1| to |\8|.
When there's the possibility that a line of code may be continued, we
advance the indentation and set |\hangindent|.
@A
\def\1{\global\advance\W@@ind by1\hangindent\W@@ind\notch}% Indent one more notch

@ Here we cancel the above.  One doesn't need to reset |\hangindent| because
this will always be followed by a~|\6| or~|\7|, which already does that.
@A
\def\2{\global\advance\W@@ind by-1{}}% Indent one less notch

@ Now we provide for an optional break within a statement.  (Note that the
argument is multiplied by~10.)
@A
\def\3#1{\hfil\penalty#10\hfilneg}% Optional break within a statement.

@ A simple command to backspace one notch.
@A
\def\4{\copy\b@@k \ignorespaces}% Backspace one notch

@ Optional break (the |\yskipfalse| may be obsolete).
@A
\def\5{\hfil\penalty-1\hfilneg \kern2.5\notch\copy\b@@kk
	\yskipfalse\ignorespaces}

@ The next command forces a line break.
@A
\def\6{\ifmmode\else\par
	\hangindent\W@@ind\notch \noindent \kern\W@@ind\notch \copy\b@@kk \ignorespaces\fi}

@ This also forces a line break, but also adds some extra vertical space.
@A
\def\7{\WY\6}% Forced break and a little extra space.

@ No indentation.
@A
\def\8{\hskip-\W@@ind\notch \hskip 2\notch}

@
@A
\newif\ifyskip
\def\yskip{\medskip}

@* PREPROCESSOR COMMANDS.  The preprocessor commands are built out of the
previous ones.

First, we define a guaranteed space.
@A
\def\W@@Hspace{\hbox{ }}

@ Start a preprocessor command such as \.{@@\#if}.  When these are issued
in the code section (rather than in the definition section), one must
remember the present level of indentation.  That's restored with~|\WPs|.

@A
\DRC\WPR[1]{\copy\b@@kk \W@@saveind%	|\global\advance\W@@ind by 2|
	\1\Wreserved{@@#1}\W@@Hspace}

\DRC\WPs{\global\W@@ind=\W@@lastind}

@ The definition commands such as~\.{@@m} are similar, except that they
also take a language argument.
@A
\def\W@@point{!}

\def\W@@defin#1#2{\4\W@@saveind
	\1\Wreserved{#1}%
	\def\W@@temp{#2}%
	\ifx\W@@temp\ast \ast
	\else\ifx\W@@temp\W@@point \W@@point
	\else\hbox{$^{\mathrm{#2}}$}%
	\fi\fi
	\W@@Hspace}% Begin @@d, @@m, or @@f.

@* VARIOUS NUCLEII.
Here are some miscellaneous macros used by the innards of this macro package.

@A
\def\note#1#2.{\WY\noindent{\hangindent2em\baselineskip10pt\footnotesize
#1 #2.\par}}

@*1 Star macros.
@A
\def\W@@lapstar{\rlap{*}}

\newif\ifW@@modchanged

\def\W@@checkstar{\edef\W@@temp{\noexpand\W@@isstar\modstar\noexpand\*\relax}%
\W@@temp}

\def\W@@isstar#1\*#2\relax{\ifx#2\*\W@@modchangedtrue\else\W@@modchangedfalse\fi}

@*1 Printing the current include file.
If there's a current include file, it's printed at the start of each
section.  The macro |\WIF| is emitted by \FWEAVE\ and stores the current
include-file name into |\W@@includefile|.  |\WIF@@name| actually prints it,
according to the macro |\WIFfmt|.

@A
\def\W@@includefile{}

\def\WIF#1{\gdef\W@@includefile{#1}}

\def\WIF@@name{\ifx\W@@includefile\empty
	\else
		\W@@prninclude
	\fi}

\def\W@@prninclude{\ifLaTeXisloaded\else\ \fi
		\WIFfmt{\W@@includefile} }

\def\WIFfmt#1{[{\tt#1}]}

\def\W@@startsection{\WQ
	\W@@checkstar
	{\let\*=\W@@lapstar
	\ifLaTeXisloaded
		\leavevmode
	\else
		\noindent
		\bf\modstar.%
	\fi
	\WIF@@name% Print name of current include file, if there is one.
	\ifLaTeXisloaded\else\quad\fi
	}}

@* HARD-CODED MACROS.  
We now describe various macros hard-coded into \FWEAVE, and their support macros.

@*1 Comments.
Comments are C-style.  The long comment construction `|/* ...*/|' 
is output as `|\WC{ ... }|'; the short comment is output as `|\Wc{ ...}|'. 
The |\WC| and~|\Wc| macros aren't simply defined with an argument
whose text would be the comment because one wants the comment to be a group
and the user might be wanting to change catcodes inside that group; the
argument form would absorb catcodes before they were changed.

@A
\def\W@@skipbrace#1{\catcode`\{=1 }

\DRC\WC{\W@@cmnt{/\ast}{\W@@finishcomment}}% Long comment.
\DRC\Wc{\W@@cmnt{//}{\XX}}% Short comment.
\DRC\Wci{\W@@cmnt{}{\XX}}% No comment symbol at all; for special effects.

\def\W@@cmnt#1#2{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi% C-style cmnt
	\XX\hfil\penalty-1\hfilneg
	\ifyskip\else\quad\fi$#1\,$%
	\bgroup\cmntfont % The user can redefine the comment font |\cmntfont|.
		\aftergroup#2%
		\catcode`\{=\other\W@@skipbrace}

\def\W@@finishcomment{$\,\ast/$\XX}

\def\Wx#1{\kern-0.5\notch\hbox{\tt\%}}

@ Compiler directives are essentially comments, but are formatted more like
preprocessor commands.
@A
\def\WCDIR#1{\WPR?\Wtypewriter{#1}\WPs}

@*1 Code mode.  Code mode is entered by vertical bars, giving an effect
such as |@c x=y|.  Because we make |\WCD| a robust command, code mode may
be used inside the names of starred sections (\LaTeXe\ only).

@A
\DRC\WCD[1]{\ifmmode\hbox\fi{\ignorespaces#1}}

@*1 Definitions. Various definition section stuff.
@A
\def\WD#1{\W@@defin{@@D}{#1}}% Outer macro definition: `\.{@@D}' 
\def\Wd#1{\W@@defin{@@d}{#1}}% Outer macro definition: `\.{@@d}' 
\def\WUd#1{\W@@defin{@@u}{#1}}% Undef outer macro: `\.{@@u}'.
\def\WMD{\W@@defin{@@M}}% WEB macro definition: `\.{@@M}'.  Second argument
			% supplied by \FWEAVE.
\def\WMd{\W@@defin{@@m}}% WEB macro definition: `\.{@@m}'.  As above.
\def\WE#1{\WPR{\##1}}% WEB preprocessor command: `\.{@@\#if\dots}'.

\def\Wf#1{\W@@defin{@@f}{#1}}% Format definition: `\.{@@f}'.
\def\WF#1{\W@@defin{@@F}{#1}}% Format definition: `\.{@@F}'.

\def\Wl#1{\W@@defin{@@l}{#1}}% Limbo text definition: `\.{@@l}'.
\def\Wv#1{\W@@defin{@@v}{#1}}% Operator overloading: `\.{@@v}'.
\def\WWW#1{\W@@defin{@@W}{#1}}% Identifier overloading:  `\.{@@W}'.
\def\Ww#1{\W@@defin{@@w}{#1}}% Identifier overloading:  `\.{@@w}'.

@*1 Sections.  
\FWEB\ supports both page number or section-number references.
The style-file entry \.{encap.prefix} defines a \TeX\ macro---empty by
default for TeX, ``|\M|'' by default for \LaTeX.  When this macro is
non-empty, it encloses the integer section numbers that are spit out by \FWEAVE.
The |\Wbegin| macro uses |\W@@modequate| to define this macro to
|\Wmodtrans|, which is the primitive that actually interprets the section
number.  For \TeX, |\Wmodtrans| is just the identity, so one gets ordinary
section numbers.  For \LaTeX, |\Wmodtrans| converts into either page or
section numbers, depending on the setting of |\ifpagerefs|.  

@*2 Customizing the referencing style.
(As an example, the current document is produced with the non-default
settings |\numberdefsfalse| and |\numbercodefalse|.)
@A
\newif\ifpagerefs% Page references or module-number references?
\pagerefsfalse

\newif\ifnumberTeX% Do we start the \TeX\ part of unnamed sections with
% a section number? 
\numberTeXfalse

\newif\ifnumberdefs% As above, but for the definition part.
\numberdefstrue

\newif\ifnumbercode% As above, but for the code part.
\numbercodetrue

% The following works in conjunction with the \LaTeXe\ package |fwebnum|.
\newif\ifnumberunnamed% Number unnamed section?
\numberunnamedfalse

\newskip\Wuparindent
\let\Wrefstepcounter\refstepcounter

% The following flag is explained in \WEBsection{strip}.
\newif\ifstripzeros

\ifuseREVTeX
	\stripzerosfalse
\else
	\stripzerostrue % By default, we're bold.
\fi

\def\W@@modequate#1{\def\W@@temp{#1}%
\ifx\W@@temp\empty\else
	\gdef#1{\Wmodtrans}%
\fi}

@*2 Sectioning commands.  
When LaTeX is selected with ``\.{-PL}'' (this is now the default), we use
LaTeX's sectioning commands.  The |\W@@depth| macro is defined at the
bottom of the \.{aux} file to be the maximum depth of the \.{@@*}$n$
commands, plus~1.  In other words, it's the effective level of the unnamed
sections.

@A
\newcount\W@@ssmax% Maximum depth of the \.{@@*}$n$ commands.
\newcount\W@@lsmax% Max. local (per section) depth of the \.{@@*}$n$ commands.

\def\W@@maxdepth#1{{\count0=#1 
	\advance\count0 by\W@@ssmin%
	\xdef\W@@depth{\the\count0}}%
	\ifFWEBstandalone\else
		\immediate\write\@@auxout{\string\@@writefile{toc}%
			{\string\setcounter{tocdepth}{\W@@depth}}}%
	\fi
	}

\def\Wunnamed#1#2{\csname ifnumber#1\endcsname
	\gdef\Wnewoutname{#2}%
	\ifx\Woutname\Wnewoutname\else
		\8\Wtypewriter{"#2"} \Wscrap ${}\equiv{}$\6%
		\global\let\Woutname\Wnewoutname
	\fi\fi}

@ The |\W@@Lvmode| macro is basically a redefinition of \LaTeX's |\addpenalty|
command to include the |\vfil| and |\vfilneg| commands.  This is supposed
to encourage it to break between sections.

When |\secpenalty| is non-negative, however, |\addpenalty| is not
redefined, and breaking at sections is not encouraged.  The tricky thing is
to set |\secpenalty| at the appropriate place.  The solution is to use the
style-file and say ``\.{doc.preamble "\\secpenalty0"}''.  This is executed
just before the |\W@@raggedbottom| command during |\Wbegin|.

@A
\newcount\secpenalty
\secpenalty=-500 % Strongly encourage breaks at sections.

% Although the following is used only in \LaTeX, don't put it inside the
% |\ifLaTeXisloaded| because of \TeX's |\if| parsing.
\def\W@@Lvmode#1{%
\if@@minipage\else
\if@@nobreak\else
\ifdim\lastskip=\z@@
	\vfil
	\penalty#1\relax
	\vfilneg
\else
	\@@tempskipb\lastskip
	\vskip-\lastskip
	\vfil
	\penalty#1
	\vfilneg
	\vskip\@@tempskipb
\fi\fi\fi}

\ifLaTeXisloaded

	\def\W@@raggedbottom{\def\@@textbottom{\vskip\z@@ \vfil}%
		\let\@@texttop\relax
% Very strongly encourage to break at beginning of sections.
		\@@secpenalty=\secpenalty
		\ifnum\secpenalty<0
			\def\addpenalty##1{%
				\ifvmode
					\W@@Lvmode{##1}%
				\else
					\@@noitemerr
				\fi}
		\fi
		}

@ The deepest named section is \.{1.1.1}, corresponding to a
sub-sub-section.  The associated unnamed section will then be a
sub-sub-sub-section, which we must declare.
@A
	\newcounter{subsubsubsection}

	\gdef\thesubsubsubsection{\thesubsubsection.\arabic{subsubsubsection}}

	\gdef\cl@@subsubsubsection{\@@elt{paragraph}}
	\gdef\l@@subsubsubsection{\@@dottedtocline{4}{3.8em}{3.2em}}
	\gdef\subsubsubsectionmark#1{}

 \ifnoLaTeXe
	\gdef\paragraph{\@@startsection{paragraph}{5}{\z@@}{3.25ex plus1ex
minus.2ex}{-1em}{\reset@@font\normalsize\bf}}
 \fi

% After the \.{aux} file is read, we must set things up based on the depth
% parameter |\W@@depth|. 
	\gdef\W@@setsecdepth{%
		\@@ifundefined{W@@depth}{\gdef\W@@depth{1}}{}%
		\setcounter{secnumdepth}{\W@@depth}%
		\setcounter{tocdepth}{\W@@depth}%
% Redefine appropriate section heading to begin the unnamed section.
% At the moment, this only works right if the major sections don't go down
% any deeper than 1.1.1.
		\ifnumberunnamed
			\Wuparindent0pt
			\addtocounter{secnumdepth}{1}%
			\gdef\WRefstepcounter##1{}%
		\else
			\Wuparindent-\TeXindent
			\global\let\WRefstepcounter\Wrefstepcounter
		\fi
		\ifcase\W@@depth % Level 0; should never happen.
		\or % Level 1
			\def\subsection{\WRefstepcounter{subsection}%
\@@startsection{subsection}{2}{\z@@}{-3.25ex plus-1ex minus-.2ex}{\Wuparindent}
{\reset@@font \normalsize \bf}}%
			\let\Wunnamedsect\subsection
			\def\W@@subsect{subsection}%
		\or % Level 2
			\def\subsubsection{\WRefstepcounter{subsubsection}%
\@@startsection{subsubsection}{3}{\z@@}{-3.25ex plus-1ex minus-.2ex}
{\Wuparindent}{\reset@@font \normalsize \bf}}%
			\let\Wunnamedsect\subsubsection
			\def\W@@subsect{subsubsection}%
		\or % Level 3
			\def\subsubsubsection{%
\WRefstepcounter{subsubsubsection}%
\@@startsection{subsubsubsection}{4}{\z@@}{-3.25ex plus-1ex minus-.2ex}
{\Wuparindent}{\reset@@font \normalsize \bf}}%
			\let\Wunnamedsect\subsubsubsection
			\def\W@@subsect{subsubsubsection}%
		\else
			\let\Wunnamedsect\paragraph
			\def\W@@subsect{}%
		\fi
		}

@*2 Converting module numbers into section or page numbers.
Here is the primitive macro |\Wmodtrans| that converts a module number into
\LaTeX's section number or page number.  This works by label information
written to the \.{aux} file by the \FWEAVE\ section macros |\WM| (unnamed
section) and |\WN| (named section).

In the following, the first |\expandafter| creates a \LaTeX\ referencing
macro such as |\r@@1|.  Then the remaining |\expandafter| expands that
@A
	\gdef\Wmodtrans#1{\@@ifundefined{r@@#1}
		{\W@@split{\##1}{\##1}{0}{0}}
		{\expandafter\expandafter\expandafter
			\W@@split\csname r@@#1\endcsname{#1}}%
		}

@ Here we convert the \.{aux} label info into a page or section number.
Pages are not too complicated.  The real problem comes with ensuring that
the unnamed sections are numbered at the deepest depth of the file, but
only for the particular section.  Because the mechanism is complicated, we
introduce a flag |\stripzeros| that can turn it off if it doesn't work.
\modlabel{strip}
@A
% #1---\LaTeX\ section number
% #2---page number
% #3---bottom section number
% #4---\Fweb\ module  number (argument to |\Wmodtrans|).
	\gdef\W@@split#1#2#3#4{%
		\ifpagerefs
			#2% Just extract the page number.
			% Add a letter subscript if more than 1 sec. per page.
			\@@ifundefined{W@@#3}%
				{\setcounter{W@@tempcounter}{#4}%
				\addtocounter{W@@tempcounter}{-#3}%
\ifnum\value{W@@tempcounter}>25 \setcounter{W@@tempcounter}{25}\fi
				\hbox{\alph{W@@tempcounter}}}
				{}%
		\else % Section-number references (the default).
			\ifstripzeros
				\W@@strip#1.,%
			\else
				#1% If we gave up and said |\stripzerosfalse|.
			\fi
		\fi
		}

@ In order to know how to strip, each major section at level 0 writes out
to the \.{aux} file a line of the form |\Lastdepth{lastsect}{maxdepth}|.
When the \.{aux} file is read in,  |\Lastdepth| defines macros of the form
|\l@@lastsect|. These can then be used to control the zero stripping.

For example, the raw section number might be \S4.0.0.1, because the
maximum depth |\W@@depth| for some section (not necessarily \S4) was 3.
However, if \S4 had no subsections at all (a last depth of 1), we can
number the unnamed section \S4.1---i.e., we want to strip off $3 - 1 = 2$
units of `\.{.0}'.  This is what |\W@@STRIP| does.  The intermediate macros
beginning with |\W@@strip| take care of various subsidiary annoyances.

|\W@@strip| picks off the level-0 section number from its argument.  It
must also watch out for an argument of the form |\#5|, which arises when
the \LaTeX\ section number is undefined.
@A

% #1---level-0 section number---i.e., 1 in \.{1.2.3}.
% #2---minor section number---i.e., 2.3 in the above example.
	\def\W@@strip#1.#2,{\W@@first#1\relax \W@@tempc{#1}{#2}}

	\def\W@@first#1#2\relax{%
		\ifx#1\#%
			\def\W@@tempc##1##2{##1}%
		\else
			\def\W@@tempc##1##2{%
				\W@@Strip{##1.##2}%
				{
				\@@ifundefined{l@@##1}%
					{0}%
					{\csname l@@##1\endcsname}%
				}%
				}%
		\fi
		}

@ |\W@@Strip| gets two arguments: the first of the form `\.{4.0.0.1.}'; the
second, the last maximum depth.
@A
	\def\W@@Strip#1#2{\W@@STRIP#1\relax{#2}}

@ |\W@@STRIP| kills off the final dot, figures out how many zeros to strip,
constructs a macro definition with the appropriate template, then applies
it to the section number.
@A
	\def\W@@STRIP#1.\relax#2{{%
\W@@tk={}\W@@count=0
\W@@counta=\W@@depth
\advance\W@@counta by-#2 % How many zeros to strip.
\loop
\ifnum\W@@count<\W@@counta
	\advance\W@@count by1
	\edef\next{\W@@tk={\the\W@@tk.0}}\next % Build template `\.{.0.0\dots}'.
\repeat
% We must worry about the possibility that there are no zeros at all.
\let\eat\let
\edef\next{\def\noexpand\reduce####1\the\W@@tk####2\eat####3\eat
{\noexpand\W@@preface{####1}####2}}%
\next
\edef\next{\noexpand\reduce#1\eat\the\W@@tk\eat\eat\relax}%
\def\eat##1{}%
\next}}

	\global\let\modno\empty
	\global\let\W@@name\empty

% For stand-alone operation, |\W@@preface| is the identity.  In insert
% mode, it prepends the section number of the section into which the file
% is being inserted.
	\def\W@@preface#1{#1}% Redefined to |\W@@getsection| in fwebinsert.sty.

% The next macro is used only in \.{fwebinsert.sty}.
	\def\W@@getsection#1{%
		\let\W@@Preface\empty% Just in case.
		\ifcase\W@@ssmin\relax
% |\relax| terminates expansion of |\W@@ssmin|
			\W@@xsection#1.\relax
			\def\W@@Preface{\thesection}% Level 0
		\or
			\def\W@@Preface{\thesection.#1}% Level 1
		\or
			\def\W@@Preface{\thesubsection.#1}% Level 2
		\or
			\def\W@@Preface{\thesubsubsection.#1}% Level 3
		\fi
		\W@@Preface
		}

% Extract just the left-most \LaTeX\ section number.  (\Wb@@se is defined in
% fwebinsert.sty; it is set to the section number in effect at the time the
% file was inserted.)  The |\advance| thus redefines the section number in
% the inserted file to be relative to that in the including file.
	\def\W@@xsection#1.#2\relax{\c@@section=\Wb@@se
		\advance\c@@section by#1}


@*2 Beginning of unnamed section is signified by |\WM|.
@A
	\def\WM#1.{\WMN#1.%
		\W@@mark{{\oldmodno}{\oldWname}}{{\modno}{\W@@name}}%
		\ifon
			\advance\W@@ss by10 %
			\W@@start{\ifnumberTeX\Wmodtrans{\modno}\fi}% ????
			\advance\W@@ss by-10 %
			\ignorespaces}
\else % No \LaTeX; for \TeX, one just gets module numbers.
	\def\Wmodtrans#1{#1}

	\outer\def\WM#1.{\WMN#1.\W@@mark\ifon\Wskip\W@@startsection\ignorespaces}
\fi % End of no \LaTeX.

@*2 Beginning of starred section.
Starred sections  (begun with~`\.{@@*}')
have associated level numbers, where 0~denotes the most significant level,
1~denotes a subsection, 2~denotes a subsubsection, and so on.  One can
indicate the level number in several ways.  By default, one can say
``\.{@@*3\ Section name.}'' or equivalently ``\.{@@*...\ Section name.}''
to set the level number to~3.  Alternatively, if one replaces the line below
``\.{\\W@@dotsafterfalse}'' with ``\.{\\W@@dotsaftertrue}'', one can instead say
``\.{@@*\ Section name....}'' (but don't do it).

\begin{itemize}
\item
For \TeX:  By default, major sections get a page break;
subsections don't.  Sections and subsections can be formatted in different
ways in the table of contents by enhancing the definition of~|\WZ|
(inside~|\Wcon|) to include an |\ifcase| construction.  

\item
For \LaTeX:  The appropriate \LaTeX\ section command is used.

\end{itemize}

@A
\newcount\W@@ss % Counter for the dots.
\newcount\W@@lastsect % Level number of section immediately above.

\newif\ifW@@dotsafter % Do subsection dots come after or before the section name?
\W@@dotsafterfalse

\ifW@@dotsafter % ``@@* NAME...''
	\def\W@@before/#1.{\W@@defname{#1}\W@@dot}%
	\def\W@@fter{\W@@Nss}%
\else % ``@@*.. NAME.'' or ``@@*2 NAME.''
	\def\W@@before/ {\futurelet\next\W@@check}%
	\def\W@@fter#1.{\W@@defname{#1}\W@@Nss}% Done after figuring out level.
	\def\W@@fter@@#1#2.{\W@@defname{#2}\W@@Nss}% |#1| eats the sectionnum.
\fi

\def\W@@check{\ifx\next.\def\next{\W@@dot.}% Count arbitrary dots.
	\else\ifx\next0\W@@sectionnum{0}%
	\else\ifx\next1\W@@sectionnum{1}%
	\else\ifx\next2\W@@sectionnum{2}% Highest numerical level (subsubsect.)
	\else\ifx\next3\W@@badlevel{3}%
	\else\ifx\next4\W@@badlevel{4}%
	\else\ifx\next5\W@@badlevel{5}%
	\else\ifx\next6\W@@badlevel{6}%
	\else\ifx\next7\W@@badlevel{7}%
	\else\ifx\next8\W@@badlevel{8}%
	\else\ifx\next9\W@@badlevel{9}%
	\else\let\next\W@@fter
	\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
	\next}%

\def\W@@badlevel#1{\errhelp=\b@@dlevelhelp
\errmessage{FWEBMAC WARNING: @@*#1 changed to @@*2}%
\W@@sectionnum{2}}

\newhelp\b@@dlevelhelp{Only the major-section (table-of-contents)
commands @@* (section), @@*1 (subsection), and @@*2 (subsubsection) are
allowed.}

% Assign numerical section number.
\def\W@@sectionnum#1{\W@@ss#1%
	\advance\W@@ss by\W@@ssmin
	\let\next\W@@fter@@}

@ By default, the full section name is used as a headline.  Sometimes that
might be too long.  To deal with that, an optional argument may be used, as
follows:
\begin{verbatim}
	@@* [Short headline]Full section name.
\end{verbatim}
Then the optional argument will be used instead.  (There should be no
brace-protected periods inside the optional argument, because the whole
construction up to the final period is absorbed at once.)
@A
\def\W@@defname#1{\@@ifnextchar[{\W@@getname}{\W@@getname[#1]}#1.}

\def\W@@getname[#1]#2.{\gdef\W@@name{#1}% Running headline (short name).
	\gdef\W@@longname{#2}}% Remember name of section (used in |\W@@start|).

\def\W@@ssmin{0}% The lowest (top) level.

\def\WN#1.{\WMN#1.\W@@ss=\W@@ssmin \W@@before/}% Begin a starred section.

@ Here we set up to output the maximum local section depth to the table of
contents.  For more explanation, see \WEBsection{strip}.
@A
% Put this here, not inside |\ifLaTeXisloaded|.
\def\W@@outlsmax#1{\if@@filesw
	{%
% The following doesn't work if one uses something like |\Roman| for
% |\thesection|.  If we only used LaTeX, it would be trivial to fix by
% replacing |\@@currentlabel| by |\c@@section| (I think).
	\ifLaTeXisloaded
		\expandafter\W@@major\c@@section.\relax
	\else
		\expandafter\W@@major\@@currentlabel.\relax
	\fi
% |\W@@count| now has major section number.
	\advance\W@@count by#1
	\advance\W@@count by-1
	\advance\W@@lsmax by1
	\edef\@@tempa{\ifFWEBstandalone
		\write\@@auxout{\string\Lastdepth{\the\W@@count}%
		{\the\W@@lsmax}}%
		\fi}% 
	\expandafter}\@@tempa
	\fi
	\W@@lsmax=0
	}

\ifLaTeXisloaded

	\def\W@@major#1.#2\relax{\W@@count=#1}% Get the major section.

% #1---Last major (level-) section
% #2---Maximum depth of that section
	\def\Lastdepth#1#2{%
		\edef\@@tempc{\gdef\expandafter\noexpand
			\csname l@@#1\endcsname{#2}}%
		\@@tempc% Define something like |\l@@1| to be last max depth.
		}

\else
	\def\W@@outlsmax#1{}
\fi

@ Here we count the periods before or after the section name.
@A
\def\W@@dot{\futurelet\next\W@@Ns}

\def\W@@Ns{\ifx\next.%
	\advance\W@@ss by 1
	\let\next\W@@next
\else
	\let\next\W@@fter
\fi
\next}

\def\W@@next#1{\W@@dot}

@ Now actually begin the section.  Note the use of~|\ifcase| to
conditionally format the sections and subsections.  Also, the construction
|\ifon...\fi| brackets the section to conditionally suppress printing.
Finally, we make an entry in the table of contents for all starred names.
The first argument of the \.{\\WZ}~macro is the level number for this
section.  This can be used to format the table of contents in various ways.

The order of expansion is an issue in the~|\write| to the table of contents
file~|\W@@cont|.  One wants the macro~|\WZ| to be sent unexpanded, so we
|\let|~it equal to a primitive.  Also, it's possible that a~|\WIN| will
appear inside of~|\W@@name| (if the user included certain kind of code inside
the section name).  This shouldn't be expanded until later, so we turn that
into the temporarily unexpandable macro~|\WIM|.  (This is presumably
unnecessary for \LaTeXe, since |\WIN| is made robust.)

@A
% Page break for major sections.
\ifLaTeXisloaded
	\let\Wsectionbreak\relax
\else
	\def\Wsectionbreak{\ifcase\W@@ss\vfil\eject\fi}
\fi

% Running headline.
\def\rhead{\ifcase\W@@ss
		\uppercase{\ignorespaces\W@@name}%
	\else
		\ignorespaces\W@@name%
	\fi}% Define running headline.

\let\WZ\let % Now one can |\send| the control sequence |\WZ|
\let\WIM\let % This macro is made temporarily unexpandable; see |\WZ|.

\def\W@@Llabel#1{\@@bsphack
	\if@@filesw
		{\let\thepage\relax
		\let\W@@botmodno\relax
		\def\protect{\noexpand\noexpand\noexpand}%
		\edef\@@tempa{\ifFWEBstandalone
			\write\@@auxout{\string\Newlabel{#1}%
			{{\@@currentlabel}{\thepage}}{\W@@botmodno}}%
			\fi}%
		\expandafter}\@@tempa
		\if@@nobreak
			\ifvmode
				\nobreak
			\fi
		\fi
	\fi
	\@@esphack}

\ifLaTeXisloaded
	\gdef\NoIndex{NoIndex}% Written as arg to |\Wbegin| by \.{-xi}.

	\gdef\W@@Nss{%
		{\let\protect\noexpand \xdef\Wupn@@me{\W@@name}}%
		\ifx\Wupn@@me\INDEX
			\ifx\INDEX\NoIndex
				\onfalse% Don't print section heading.
			\else
		      \W@@mark{{\oldmodno}{\oldWname}}{{\oldmodno}{\oldWname}}%
			\fi
		\else% Emit mark before section break.
			\W@@mark{{\oldmodno}{\oldWname}}{{\modno}{\W@@name}}%
		\fi
% Can't put this in |\WMN| since |\rhead| must be defined first. 
		\message{*\modno}% Progress report to the terminal.
		\ifon% Start output of named section; explicit |\fi|
%				written by \FWEAVE.
			\ifnum\W@@ss>\W@@ssmax
				\global\W@@ssmax=\W@@ss% Track max depth.
			\fi
			\ifnum\W@@ss>\W@@lsmax
				\global\W@@lsmax=\W@@ss% Maximum local depth.
			\fi
			\W@@start{\W@@longname}%
			\ignorespaces
		}

	\def\steppagemodule{\noexpand\expandafter\expandafter\expandafter
{\addtocounter{pagemodule}{1}}\thepagemodule}

	\let\Wlabel\W@@Llabel

@ If the section name is exactly ``\.{INDEX}'' (or more precisely the
 contents of the style-file parameter |index.name|), we	issue the
|\beforeindex| command.  By default, this is defined as follows:  If
\.{multicol.sty} is not loaded, we switch into 
|\twocolumn| mode, thereby starting the index on a new page.  If it is
loaded, we just issue a |\newpage| command.  Later, after the beginning of
the \.{INDEX} section is executed, the |\startsection| command will begin
the multi-column mode.
@A
	\gdef\beforeindex{%
		\ifx\multicols\undefined
			\twocolumn
		\else
			\ifFWEBstandalone
				\newpage
			\fi
		\fi
		}

	\gdef\W@@start#1{%
		{\let\protect\noexpand \xdef\Wupn@@me{\W@@name}}%
		\ifx\Wupn@@me\INDEX\beforeindex\fi
% Select the appropriate \LaTeX\ section command.
		\ifcase\W@@ss
			\let\Wsect\section % Level 0
			\W@@lastsect\W@@ss
		\or
			\let\Wsect\subsection % Level 1
			\W@@lastsect\W@@ss
		\or
			\let\Wsect\subsubsection % Level 2
			\W@@lastsect\W@@ss
		\else
			\let\Wsect\Wunnamedsect
		\fi
%		{
		\ifnum\W@@lastsect>2
			\W@@setU
		\fi
		\Wsect{#1}% Execute LaTeX section heading.
%		}
		\ifnum\W@@ss=0 % Check if major section.
			\W@@outlsmax{0}% If so, write out |\Lastdepth| command.
		\fi
% Emit mark after section break.
		\W@@mark{{\modno}{\W@@name}}{{\modno}{\W@@name}}%
		\Wlabel{\modno}% Section number to aux file.
		\@@ifundefined{r@@\modno}
			{\expandafter\xdef\csname r@@\modno\endcsname
				{{\@@currentlabel}{\thepage}{-1}}}
			{}% For present run.
%	\message{modno=\modno [\csname r@@\modno\endcsname]} % Debugging.
		\W@@startsection
		}
\else % No \LaTeX

\def\W@@Nss{%
	\let\protect\noexpand
	\W@@mark%Can't put this in |\WMN| since |\rhead| must be defined first. 
	\Wsectionbreak % Typeset the break between sections.
	\message{*\modno}% Progress report to the terminal.
	\ifon
		\ifcase\W@@ss\else\Wskip\fi
		\W@@startsection{\bf\ignorespaces\W@@name.\quad}%
		{\def\WIN{\WIM}%
		\edef\next{\write\W@@cont{\WZ{\the\W@@ss}{\W@@name}%
		{\modno}{\noexpand\the\pageno}}}\next}%
			% To contents file |CONTENTS.tex|.
		\ignorespaces}
\fi

@
@A
\ifuseREVTeX

  \def\W@@setu#1{\expandafter\def\csname p@@\W@@subsect\endcsname{#1}
	\expandafter\def\csname the\W@@subsect\endcsname{\arabic{\W@@subsect}}}

  \def\W@@setU{
	\ifcase\lastsect
		\W@@setu{\thesection.}%
	\or
		\W@@setu{\thesection\,\thesubsection.}%
	\or
		\W@@setu{\thesection\,\thesubsection\,\thesubsubsection.}%
	\fi
	}
\else
	\def\W@@setU{}
\fi

@ The marks that are emitted just before |\Wsectionbreak| are of the form
``{\it modno}|\else|{\it section name}''.  (See the discussion just before
Ex.~23.5 of the \textsl{\TeX book}.)  Both  parts are used in the
page headers.  In handling the section name, one must take care to avoid
expanding the macro~|\WIN| prematurely.  This is done just as in~|\W@@Nss|
above. 

@A
\def\W@@markN{\def\W@@mark{{\def\WIN{\WIM}%
		\mark{\modno\noexpand\else\rhead}}}}

\ifx\selectfont\undefined
	\W@@markN
\else
	\def\W@@mark{{\def\WIN{\WIM}\let\protect\noexpand
		\mark{\modno\noexpand\else\rhead}}}
\fi

\def\Wmodno{\iftrue\topmark\fi}% Extracts the left-hand part of the mark.

\def\Whead{{\let\WIM\WIN
	\expandafter\iffalse\topmark\fi}}% Extracts the right-hand part.

@ Common code for |\WM|, |\WN|.  
@A
\def\WMN#1.{\par
	\parskip=\pardimen % Reset to \TeX\ spacing
	\parindent=\TeXindent
	{\ifLaTeXisloaded
		\global\let\oldmodno\modno
		\global\let\oldWname\W@@name
		\xdef\@@currentlabel{\modno}%
		\global\let\Woutname\empty
		\addtocounter{pagemodule}{1}%
	\fi
	\xdef\modstar{#1}%
	\let\*=\empty
	\xdef\modno{#1}%
	}%
	\ifx\modno\modstar 
		\global\onmaybe% For conditional listing of changed secs. 
	\else
		\global\ontrue% Print this section.
	\fi
	}

%\let\MN\WMN % Backward compatibility.  Commented out for v1.60.

@*1 Nuweb mode.
When the `N' mode is in effect, code to be transcribed verbatim will be
bracketed by |\WBM|\dots|\WEM|.

@A
\def\Wscrap{{\footnotesize\Wmodtrans{\modno}%
	\ifW@@modchanged*\fi}}

{\gdef\@@verbatim{\if@@minipage \else \vskip \parskip \fi
\leftskip 
 \@@totalleftmargin \rightskip \z@@ \parindent \z@@ \parfillskip \@@flushglue
\parskip \z@@ \@@@@par \@@tempswafalse \def \par {\if@@tempswa \hbox {}\fi
\@@tempswatrue  
\@@@@par \penalty \interlinepenalty }\obeylines \tt \catcode ``=13
\@@noligs \let \do \@@makeother \dospecials}}

{\catcode`/=0 /catcode`/\=12 /catcode`/^^I=13 
/gdef/WBM{%/8/kern/notch
/begingroup
/parindent/W@@globalindent/notch /advance/parindent by-1/notch
/def/par{/endgraf/leavevmode}%
/catcode`^^I=13 /def^^I{/leavevmode/penalty10000/ / / / / / / / }%
/catcode``=13 /@@noligs /tt 
/let/do/@@makeother /dospecials 
/@@vobeyspaces/frenchspacing/obeylines 
/W@@M}
/gdef/W@@M#1\WEM{#1/endgroup}}

@*1 Constants.  Various kinds of constants are handled:  decimal~(|@c 10|),
hexadecimal~(|@c 0xA|), octal~(|@c 012|), boolean~(|@c 0b1010|), 
floating-point (|@c 1.5e-35|), double-precision (|@n @e3.2d100|),
long (|@c 99999L|), unsigned (|@c 99999U|),
unsigned long (|@c 999999UL|), and Hollerith (|@r 3Habc|).

\Forran-90 also introduces kind parameters.  These are basically subscripts
on constants, as in |@n9 12_34| or |@n9 1.2e34_high|.  Presently, if a kind
parameter is recognized, the basic number is enclosed in a group; otherwise
exponents get subscripted instead of the whole number, because of the
trickery with |\aftergroup|.  This isn't quite ideal, because the subscript
doesn't get tucked far enough to the left.  This needs more work with the
definition for \.{\\\^}.

@A
\def\WDP#1{\ifx E#1\else{\tt#1}\fi}% Used in the exponent macro below.

\DRC\WO[1]{%
	{% Make the next definitions local.
	\let\-\_%
	\let\d\$%
	\def\\{\let\_\-\let\$\d}%
	\def\?{\kern.2em}%
	\let\{\bgroup% Braces are inserted in \Fortran-90 by kind parameter.
	\let\}\egroup
	\def\###1{\kern0.1em{\tt \ifcase##1F\or L\or U\or UL\else?\fi}}%C~constant. 
	\def\^##1{\cdot 10^{\aftergroup}\aftergroup\WDP\aftergroup##1}% Power of ten
	\def\_{_{\\\rm\aftergroup}}% Fortran-90 kind parameter.
	\def\%{{\rm H}\hbox{\aftergroup}\Wtypewriter{\aftergroup}}% Hollerith constant
	\def\&{0{\tt b}}% Binary constant.
	\def\~{\hbox{\rm\char'23\kern-.2em\it\aftergroup\?\aftergroup}}% Octal
	\def\`{\hbox{\rm\char"7D\tt\aftergroup}}% Double quotes for hex constant
	#1}}

@ In \Fortran-90, character constants may be preceded by a kind parameter.
For output, we invert the order and use the parameter as a subscript on the
string.

@A
\def\WKINDCHAR#1\.#2{%
	\hbox{\Wtypewriter{#2}}_{\Wkindids \rm #1}}

\DRC\Wkindids{\def\Wshort##1{##1}%
	\def\Wid##1{##1}%
	\def\WID##1{##1}}

@*1 Code mode.  Either begin the code section, or a preprocessor or
definition command.

The following command sets up~|\W@@ind|.  This somewhat peculiar construction
is for historical reasons.  Again, the global indentation is for the body
of functions.  The natural hanging indentation for continued lines is one
more notch; hence the |\1|.

@A
\def\WPr{\global\W@@ind=\W@@globalindent \1}

@ Now enter code mode.  Note that |\leavevmode| starts a new indented
paragraph; we then move in one more notch.
@A
\def\WP{\parskip=0pt \parindent=\notch
	\rightskip=0pt plus 100pt minus 10pt 
	\sfcode`;=3000
	\pretolerance 10000
@#if 0
	\hyphenpenalty 10000 \exhyphenpenalty 10000 % If one turns these on, the
	% discretionary breaks in strings won't work!
	\global\W@@ind=\W@@globalindent \1\ \unskip}
@#endif
	\WPr
	\W@@firstbreaktrue % Reset to true by |\6|.
	\leavevmode\kern\notch}

@ Here we leave code mode.  The |\Wend| macros can be redefined for special
effects at the end of a code or definition part.

@A
\def\WQ{\rightskip=0pt
	\sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50 }

\def\Wendd{\par}% End of definition part.
\def\Wendc{\par}% End of code part.

@* MISCELLANEOUS OPERATORS.
Most of these are also hard-coded into \FWEAVE, and emitted automatically.
@A
\def\WA{\note{See also}}% Cross-reference for multiply defined section names.
	% English!

\def\Wauto[#1]{\Wtypewriter{[#1]}\ }

\DRC\WB{\mathopen{\Wtypewriter{@@/\ast}}}% Begin controlled comment.

\let\WG\ge % Greater than or equal sign: '$\WG$'.

\DRC\WI{\neq}% Unequal sign: '$\WI$'.  (Better reserve |\ne| for the
		% electron density~$n_e$.) 

\DRC\WJ{\Wtypewriter{@@\&}}% TANGLE's join operation: '\WJ'.

\let\WK\gets % Left arrow: '$\WK$'.

% The next one is used for statement labels in \Fortran\ and \Ratfor.
\let\Wlbl\llap

% The above puts the label on the same line as the things it's labeling. 
% Some other choices, courtesy of Bart Childs, are

% \def\Wlbl{\hskip-\notch} % jut into the left white space
% \def\Wlbl{} % Maintains indentation.

% To put the statement label on the previous line, use the `|-n:|' option.

\let\WL\le % Less than or equal sign: '$\WL$'.

\let\WLA\langle % Opening of template:  '$\WLA$'.
\let\WRA\rangle % Closing of template:  '$\WRA$'.

\DRC\WTLD{\Wtypewriter{@@\~}}

\def\Wskip{\vfil\penalty-100\vfilneg \vskip12ptminus3pt}% See |\WM|, etc.

\def\Wskipped#1{\8\mathhexbox278.\quad\Wtypewriter{@@I "#1"}\ \ {\it Section(s)
skipped}\dots\WP} 

\let\WPtr\Rightarrow % Fortran's stupid pointer assignment statement:
		% '$\WPtr$'. 

\let\WR=\lnot % Logical not: '$\WR$'.

\let\WS=\equiv % Equivalence sign: '$\WS$'.
\let\WSQ=\equiv % This symbol is used when defining a section name.

\DRC\WSl{\ifmmode\mathbin{/}\else/\fi}% Division

\DRC\WT{\mathclose{\Wtypewriter{@@\ast/}}}% Terminate controlled comment.

\def\WU{\note{This code is used in}}% Cross-reference for uses of sections.
	% English!

\let\WV\lor % Logical or: '$\WV$'.

\let\WW=\land % Logical and: '$\WW$'.

@*1 Formatting a section name.
Here's how to format a section name. Argument~1 is the name, argument~2
is the section number, and argument~3 is the language symbol.
@A
\ifLaTeXisloaded
\else
	\let\footnotesize\eightrm
\fi

\def\WX#1#2\X#3\X{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi
	\XX$\langle\,$#2{\footnotesize\kern.5em#1}%
$\,\rangle^{\mathrm{#3}}$\XX}

@
@A
\def\WY{\par
	\yskip
	\parskip=0pt} 

@
The following were for Pascal.
@<Unused@>=

\def\){\hbox{\Wtypewriter{@@\$}}}% sign for string pool check sum
\def\]{\hbox{\Wtypewriter{@@\\}}}% sign for forced line break

@*1 Questions and colons.
For C's construction `|@c x ? 1 : 0|'.
@A
\DRC\?{\mathrel?}

@ Colons have several uses.
@A
\DRC\Colon{\ifmmode\colon\else\textcolon\fi}

\DRC\WCC{\mathord{::}}% For C:  '$x\WCC y$'.
\DRC\WCF{{}\mathbin{::}{}}% For \Fortran:  '$x\WCF y$'.


@*1 Verbatim strings.
Verbatim strings are boxed for emphasis, like this:  \Wequals{This is a
verbatim string.}

@A
\DRC\=[1]{\kern2pt\hbox{\vrule\vtop{\vbox{\hrule
	\hbox{\strut\kern2pt\Wtypewriter{#1}\kern2pt}}
	\hrule}\vrule}\kern2pt}

\let\Wequals\=

@ 
@A
\let\~=\ignorespaces
\let\*=*

@*1 Accreting to modules.
The following symbol is used to denote accretions to already-existing
modules. 
@A
\def\WPQ{\mathrel{+\mathord\equiv}}% '$\WPQ$'.

@*1 Exponentiation.
The exponentiation macros strip away outer parentheses from the argument,
turning ``|x^(a+b)|'' into ``|@n x^(a+b)|''.
@A
\def\W@@LP{(}% Must be |\def|, not |\let|.
\def\W@@ISL#1#2]{\def\next{#1}}
\DRC\WEE[1]{\W@@ISL#1]\ifx\next\W@@LP\WEXP[#1]\else\WEXP[(#1)]\fi}
\def\WEXP[(#1)]{^{#1}}

@#if 0
\def\WEE{\mathord{\hbox{\tt\^}}}% Poor-man's exponentiation; above is better.
@#endif

@*1 \Fortran.
@A
\DRC\WCMN[2]{\Wtypewriter{/#2/}}

\let\WSlSl\parallel% Concatenation: '$\WSlSl$'.

\DRC\WEQV{\mathrel{?{=}}}% `$x\WEQV y$'.
\DRC\WNEQV{\not\equiv}% `$x\WNEQV y$'.

@ For \Fortran--90's `|@n9 (/a,b,c/)|'.
@A
\DRC\WLS{\mathopen{({/}\,}}
\DRC\WSR{\mathclose{\,{/})}}

@ The standard \Fortran\ \.{.FALSE.} and \.{.TRUE.} operators.
@A
\DRC\WFALSE{{\cal F}}% '$\WFALSE$'.
\DRC\WTRUE{{\cal T}}% '$\WTRUE$'.

@ Block/loop numbers in \Fortran.  {\it Note:  One can't replace the
|\bgroup| and |\egroup| by braces because of peculiarities of~|\Wc|.  Also,
if one puts an explicit comment on a line that will be labelled by
|\Wblock|, with the following definition one will get two comments side by
side.  However, this could be modified by setting a counter to the block
number and making a fancier definition of~|\WC| and~|\Wc|.}
@A
\def\Wblock#1{\Wc\bgroup\ Block #1\egroup}% `\Wblock{99}'

@*1 Macro tokens.
@A
\def\WNN{\hbox{\#\#}}% '\WNN'.
\def\WNP{\hbox{\#!}}% '\WNP'.
\def\WNC{\hbox{\#:}}% '\WNC'.
\def\WND{\hbox{\#.}}% '\WND'.
\def\WNq{\hbox{\#\tt'}}% '\WNq'.
\def\WNQ{\hbox{\#\tt"}}% '\WNQ'.

@*1 C operators.
@A
\mathchardef\TLD="0218 % '$\TLD$'.

\DRC\WPP{\mathord{++}}% '$\WPP$'.
\DRC\WMM{\mathord{--}}% '$\WMM$'.

\DRC\WMG{\mathord{\to}}% '$\WMG$'.

\DRC\Wcp{\mathrel{+{=}}} \let\PE\Wcp % `$x\PE y$'.
\DRC\Wcm{\mathrel{-{=}}} \let\ME\Wcm % `$x\ME y$'.
\DRC\Wcs{\mathrel{\ast{=}}} \let\TE\Wcs % `$x\Wcs y$'.
\DRC\Wcv{\mathrel{/{=}}} \let\FE\Wcv % `$x\FE y$'.
\DRC\Wcd{\mathrel{\%{=}}} \let\CE\Wcd % `$x\Wcd y$'.
\DRC\Wcx{\mathrel{\^\!{=}}}% `$x\Wcx y$'.
\DRC\Wca{\mathrel{\amp{=}}}% `$x\Wca y$'.
\DRC\Wco{\mathrel{\WOR{=}}}% `$x\Wco y$'.
\DRC\Wcg{\mathrel{\WGG\!{=}}}% `$x\Wcg y$'.
\DRC\Wcl{\mathrel{\WLL\!{=}}}% `$x\Wcl y$'.

@ More C operators.
@A
\DRC\WMOD{\mathrel{\%}}% `$x\WMOD y$'.
\DRC\WOR{{\,|\,}}% `$x\WOR y$'.
\DRC\WAND{{\,\amp\,}}% `$x\WAND y$.

\DRC\WGG{\mathrel{>\!>}}% `$x\WGG y$'.
\DRC\WLL{\mathrel{<\!<}}% `$x\WLL y$'.

\DRC\WHE{\mathrel{\uparrow=}}% `$x\WHE y$'.

\DRC\Woperator[1]{\Wreserved{operator}~\hbox{$#1$}\ignorespaces}
\DRC\Woperatoro{\Wreserved{operator}~\ignorespaces}

@*1 Braces.
We allow braces to be easily displayed outside of math mode.
@A
\let\openbraces=\{
\let\closebraces=\}
\def\{{\ifmmode\openbraces\else$\openbraces$\fi}
\def\}{\ifmmode\closebraces\else$\closebraces$\fi}

@*1 Metacomments.
@A
% Print the meta-comment symbols.
%\def\WBM{\6\8\Wreserved{@@(}}
%\def\WEM{\6\8\Wreserved{@@)}}

% Don't print the meta-comment symbols.
%\def\WBM{}
%\def\WEM{}

@* OVERLOADING OPERATORS.  Operator overloading is annoying because several
languages may be in use simultaneously.  Therefore, when we define an
overloaded  macro name, we append to it the language symbol, creating
macros such as |\op_C|.  These macros are typically defined automatically
at the beginning of the output file from information contained in
\.{@@v}~commands. 

@A
\newif\ifop
\newbox\dotbox

\def\Wunknown#1{\={??#1??}}% For unknown dot constant.

{\catcode`\_=11

\gdef\newop#1#2#3{%
	\edef\next{\def\expandafter\noexpand\csname _#1_#2\endcsname}%
	\next{#3}}

\gdef\newbinop#1#2#3{%
	\edef\next{\def\expandafter\noexpand\csname _#1_#2\endcsname}%
	\next{\mathrel{#3}}}

\gdef\newunop#1#2#3{%
	\edef\next{\def\expandafter\noexpand\csname _#1_#2\endcsname}%
	\next{\mathbin{#3}}}

\gdef\Wop#1#2{\setbox\dotbox\hbox{\tt .#1.}%
	\edef\nxt{\expandafter\noexpand\csname _#1_#2\endcsname}%
	\edef\ifnxt{\noexpand\ifx\expandafter\noexpand\csname _#1_#2\endcsname}%
	\ifnxt\empty
		\def\next{\box\dotbox}% Macro not defined; just use \.{.NAME.}.
	\else
		\def\next{\futurelet\nextchar\W@@q}% Be careful about |\WEE|.
	\fi
	\next}%
}

\global\let\Wb\Wop
\global\let\Wu\Wop

\let\Lbrace{

\def\W@@q{\ifx\nextchar\Lbrace
		\let\next\nxt % There's an argument coming up.
	\else
		\ifop
			\def\next{\nxt{}\equiv\box\dotbox}%
		\else
			\let\next\nxt
		\fi
	\fi
	\opfalse
	\next}

@ The following macro translates overloaded identifiers into their \TeX\
equivalents.
@A
\DRC\WTeX[1]{\ [{\ifmmode\def\XX{}\else\def\XX{\null$\null}\fi
\XX#1\XX}]\ }

@* ACTIVE ARRAY INDICES.
The following is for special handling of array indices, when the |-W[|
option is used.
@A
\newtoks\W@@ARRAYarga
\newtoks\W@@ARRAYargb

\DRC\WXA[1]{\begingroup
% We don't want the identifiers to be in hboxes, because we want to get
% |\scriptstyle| for subscripts.  (One should always be in math mode here.)
	\def\Wshort##1{##1}%
	\def\Wid##1{\mathit{##1\/\kern.05em}}%
	\global\W@@ARRAYarga{#1}%
	\futurelet\W@@next\WARRAYm}

\def\WARRAYm{\ifx\W@@next\WXA
		\global\let\W@@next\WARRAYn% Multiple indices in C:  a[i][j][k]
	\else
		\global\let\W@@next\relax
		\WARRAY{\the\W@@ARRAYarga}% Typeset the accumulated indices.
	\fi
	\endgroup
	\W@@next}

\def\WARRAYn#1#2{\W@@ARRAYargb{#2}%
	\edef\W@@next{\noexpand\WXA{\the\W@@ARRAYarga,\the\W@@ARRAYargb}}%Concatenate
	\W@@next}

% Change the following definition---e.g., |\let\WARRAY\WSUB|---to get
% indices printed in interesting ways. 
\DRC\WARRAY[1]{[#1]}% Default definition.
\DRC\WSUB[1]{_{\scriptstyle#1}}% E.g., subscript indices.

@* MISCELLANEOUS MACROS.
@*1 Handle the \.{@@o}~command.
@A
\def\Wouto#1#2{\Wreserved{@@#1}\W@@Hspace\Wtypewriter{#2}}
\def\Wout#1{\Wouto{o}{#1}}
\def\WOut#1{\Wouto{O}{#1}}

@*1 RCS-like keyword.
@A
\def\WRCS#1#2{\langle\!\langle\,\Wtypewriter{#2}\,\rangle\!\rangle
	\ifnum#1=0 _{0}\fi}

@*1 Symbolic labels.
Assign a symbolic name to a module.  This scheme has no forward
referencing at present for plain \TeX, although this could easily be
extended.  For \LaTeX, forward referencing works because the \.{aux}~file
is used.
@A
% Label a section with an identifying name.
\def\modlabel#1{%
	\ifLaTeXisloaded
		\label{MOD#1}%
	\else
		\edef\next{\gdef\expandafter\noexpand\csname MOD#1\endcsname{\modno}}%
		\next
	\fi}

% Print the number of a labelled section.
\def\Wmodule#1{\ifLaTeXisloaded
		\ref{MOD#1}%
	\else
		\csname MOD#1\endcsname
	\fi} 

% Examples of references to sections.  
\def\WEBsection#1{section~\Wmodule{#1}}% |\section| is used by \LaTeX.
\def\WEBmodule#1{module~\Wmodule{#1}}
\let\module\WEBmodule% For backward compatibility.

@*1 Language commands.
 Language commands are printed in the left margin, following Knuth's
solution in Appendix~A of the \TeX book.  They are actually printed one
line down, because the language command is gobbled up before the line break
is emitted.

@A
\def\strutdepth{\dp\strutbox}

\def\W@@marginal#1{\strut\vadjust{\kern-\strutdepth\W@@specialmargin{#1}}}

\def\W@@specialmargin#1{\vtop to\strutdepth{
	\baselineskip\strutdepth
	\vss\llap{#1 }\null}}

\def\LANGUAGE#1{\W@@marginal{\smash{\vtop{\hbox{%
	\hbox{\tt @@L\lowercase{#1}\textcolon\enspace}}\null}}}\ignorespaces}

% Use the next one if you don't want language changes to be printed.
@#if 0
	\def\LANGUAGE#1{\relax\ignorespaces}
@#endif


@* PAGE FORMAT.
Now we deal with the overall page format.

@*1 Listing the changed modules.
If you want to list only the modules that have changed,
together with the index, put the command `|\let\maybe=\iffalse|' in
the limbo section before the first module of the \.{WEB} file. It's
customary to make this the first change in the change file.

@A
\newif\ifon 
\def\onmaybe{\let\ifon=\maybe} \let\maybe=\iftrue

@ Some flags, and the number of the table of contents.
@A
\newif\iftitle \newif\ifpagesaved

\newcount\contentspageno

@*1 Headers.
The scheme for using |\mark| is that for Knuth's \textsl{The Art of
Computer Programming}, as described in \textsl{The \TeX book}, just before
Exercise 23.5.  It requires emitting |\mark| commands just before and just
after the section breaks.

@A
\def\Wmodhd#1{ [#1]}

\newif\ifW@@headers
\W@@headerstrue% Stand-alone setting (might be changed in fwebinsert.sty).

\def\W@@seczero{0}

\def\WsetLmarks{
	\def\Wsecrange##1##2{%
		\def\W@@tempa{##1}\def\W@@tempb{##2}%
		\ifx\W@@tempa\W@@tempb% Equal sec.\ nums; just print one.
			\W@@S\Wmodtrans{##1}\Wmodhd{\###1}%
		\else\ifx\W@@tempb\W@@seczero
			\W@@S\Wmodtrans{##1}\Wmodhd{\###1}%
		\else
		    \W@@S\Wmodtrans{##1}--\W@@S\Wmodtrans{##2}%
\Wmodhd{\###1--\###2}%
		\fi\fi}

	\gdef\@@leftmark##1##2##3##4{%
		\let\protect\relax
		\let\\\ %
		\qquad\mainfont##2
		\hfill
		\Wtitle\qquad
		\ifnum##1>0%
		  \mainfont\Wsecrange{##1}{##3}% 
		\fi
		}

	\gdef\@@rightmark##1##2##3##4{%
		\let\protect\relax
		\let\\\ %
		\ifnum##1>0
			\mainfont\Wsecrange{##1}{##3}\qquad%
		\fi
		\mainfont\Wtitle
		\hfill 
		\mainfont##4\qquad
		}

	\gdef\leftmark{%
\ifnoLaTeXe
\else
	\let\protect\@@unexpandable@@protect
\fi
\edef\W@@tempb{\expandafter\iftrue\botmark\fi}%
\edef\W@@tempa{\expandafter\iffalse\topmark\fi}%
\expandafter\expandafter\expandafter\@@leftmark\expandafter\W@@tempa\W@@tempb{}{}}

	\gdef\rightmark{%
\ifnoLaTeXe
\else
	\let\protect\@@unexpandable@@protect
\fi
\edef\W@@tempb{\expandafter\iftrue\botmark\fi}%
\edef\W@@tempa{\expandafter\iffalse\topmark\fi}%
\expandafter\expandafter\expandafter\@@rightmark\expandafter\W@@tempa\W@@tempb{}{}}

	\gdef\W@@markN{\gdef\W@@mark####1####2{{\def\WIN{\WIM}%
		\mark{####1\noexpand\else####2}}}}

	\ifx\selectfont\undefined
		\W@@markN
	\else
		\gdef\W@@mark##1##2{{%\def\WIN{\WIM}%
			\let\protect\@@unexpandable@@protect
			\mark{##1\noexpand\else##2}}}
	\fi
}

\ifLaTeXisloaded
\else
\def\lheader{\mainfont\the\pageno\eightrm\qquad\Whead\hfill\Wtitle\qquad
	\ifnum\pageno=\contentspageno\else
		\W@@S\mainfont\Wmodno
	\fi}

\def\rheader{\ifnum\pageno=\contentspageno\else
		\W@@S\mainfont\Wmodno
	\fi
	\eightrm\qquad\Wtitle\hfill\Whead
	\qquad\mainfont\the\pageno}
\fi

@*1 Page dimensions.
Here are the page dimensions (in inches).
@A
\def\pagewidtho{6.5}% The width of each page
\def\pageheighto{8.7}% The height of each page
\def\fullpageheighto{9}% Page height including headlines

\newdimen\pagewidth \pagewidth\pagewidtho in
\newdimen\pageheight \pageheight\pageheighto in
\newdimen\fullpageheight \fullpageheight\fullpageheighto in

\newdimen\pageshift \pageshift=0in% Shift righthand pages wrt lefthand ones

% Use after changing page size.
\def\setpage{\hsize\pagewidth 
	\vsize\pageheight
	\ifLaTeXisloaded
		\oddsidemargin=0pt
		\evensidemargin=0pt
		\topmargin=0pt
% Mods due to Bart Childs:
		\setlength{\linewidth}{\pagewidth}
		\setlength{\textwidth}{\pagewidth}
		\setlength{\textheight}{\pageheight}
	\fi
	}
	
\ifLaTeXisloaded
\else
\def\magnify#1{\mag=#1
	\pagewidth\pagewidtho truein
	\pageheight\pageheighto truein
	\fullpageheight\fullpageheighto truein
	\setpage}

\fi

@*1 Plain \TeX\ output routine.
Here is the output routine for plain \TeX.  (For \LaTeX, we use its own
routine.) 
@A
\def\page{\box255 }

\newif\ifidenticalpageheads

\def\normaloutput#1#2#3{
	\ifodd\pageno\hoffset=\pageshift\fi
	\shipout\vbox
		{
		\vbox to\fullpageheight
			{
			\iftitle\global\titlefalse
			\else \hbox to\pagewidth
				{\vbox to10pt{}%
				\ifidenticalpageheads#2\else
				\ifodd\pageno
					#3% Pg nos alternate left \& right.
				\else#2\fi
				\fi
				}%	
			\fi
			\vfill#1% Parameter |#1| is the page itself.
			}
		}
	\global\advance\pageno by1}

\def\W@@name{{FWEB} OUTPUT}% This section name is reset by starred sections.

@ Here we provide a storage place for |\output|. If one includes a macro
package, such as \.{manmac}, that overrides the definition of |\output|
{\it after} \.{fwebmac.sty},  one can get back the \.{fwebmac.sty} definition by
saying 
		|\input manmac|
		|\output\Woutput|
@A
\newtoks\Woutput
\Woutput\output% Remember \FWEB's definition.


@*1 Time and date.
It's very useful to know exactly when one made the run.
@A
\newcount\minutes
\newcount\hours

\hours=\time
\divide\hours by 60
\multiply\hours by 60
\minutes=\time
\advance\minutes by -\hours
\divide\hours by 60

\def\Time{\the\hours\textcolon\ifnum\minutes<10 0\fi\the\minutes}

\def\Date{\ifcase\month\or
	January\or February\or March\or April\or May\or June\or
	July\or August\or September\or October\or November\or December\fi
	\space\number\day, \number\year}


@*1 Optional title for the code.
An optional title can be defined by the user in his limbo section.  The
syntax is `|\Title[short]{long}|', where the optional short argument is for
the running heads in the document and is by default prefaced with
|\large\tt|; the required long argument is for the 
title page and is by defualt prefaced with |\ttitlefont|.

@A
\def\Wtitle{}% Short title for running heads.  Can redefine after |\Title|.j

\def\Title{\@@ifnextchar[\W@@@@Title\W@@Title}
\def\W@@Title#1{\W@@@@Title[#1]{#1}}
\def\W@@@@Title[#1]#2{\gdef\Wtitle{{\large\tt#1}}\title{{\ttitlefont#2}}}


@* TABLE OF CONTENTS. An entry is made in the table of contents for each
starred section.  

@*1 |\topofcontents| and |\botofcontents|.
One can customize things with |\topofcontents| and
|botofcontents|.  For more information, see the on-line documentation, menu
item ``Table of contents''.

@A
\ifLaTeXisloaded
	\def\topofcontents{}% We use \LaTeX's defaults.
\else
	\def\topofcontents{\centerline{\titlefont\Wtitle}
	  \vfill} % This is the default.
\fi

@ End the table of contents page:
@A
@#if 0
\def\botofcontents{\vfill}% This makes the bottom of the contents page empty.
@#endif

\ifLaTeXisloaded
	\def\botofcontents{}
\else
\def\botofcontents{\vfill
@#if 0
	\rightline{My Name}% You can personalize your output here, for example.
@#endif
	\rightline{\Date}
	\rightline{\Time}}
\fi

\ifLaTeXisloaded
	\contentspageno=1
	\pageno=\contentspageno
\else
	\contentspageno=0% Default page number for table of contents
\fi

@*1 Opening the contents file; the |\Wbegin| macro.
\modlabel{Wbegin}
Here we actually open up the contents file, which is the argument to
|\Wbegin|.  The |\Wbegin| macro is issued automatically just before the
stuff for the first module.  Also, \LaTeX\ does its own thing with the
|\end| command, so we redefine it.  To finish up the document, we write to
the \.{aux} file ``|\W@@maxdepth{|$n$|}|'', where $n$~is the maximum
section depth that was achieved.

Whereas \LaTeX\ writes a |\newlabel| line to the table of contents in
response to a |\label| command, we write a |\Newlabel| command for every
section.  That macro is patterned after |\newlabel|, but has an extra
argument that is |\W@@botmodno|.  The |\Newlabel| information is read both by
the \FWEB\ processors (to correlate \LaTeX\ section numbers with integer
module numbers) and by |\FWEBend| to check whether labels have changed.
@A 
\newwrite\W@@cont % For the table of contents.

\ifLaTeXisloaded
	\def\Wfirst#1#2#3#4#5{#1}

	\def\W@@output{\setcounter{pagemodule}{0}%
		\xdef\W@@botmodno{\expandafter\Wfirst\botmark}}

	\def\W@@botmodno{0}

% #1---\Fweb\ module number
% #2---{\LaTeX\ section number}{page number}
% #3---module number of last section on page.
	\def\Newlabel#1#2#3{%
		\ifFWEBstandalone
			\@@ifundefined{r@@#1}{}%
				{\@@warning {Label `#1' multiply defined}}
		\fi
		\global\@@namedef{r@@#1}{#2{#3}}% |\@@namedef| is from \LaTeX.
		\global\W@@lpha=#3
		\ifnum\W@@lpha=\W@@ref\global\advance\W@@pmcount by1
		\else
			\ifnum\W@@pmcount=1
			\edef\next{\gdef\csname W@@\the\W@@ref\endcsname{}}\next
			\fi
			\W@@ref=\W@@lpha
			\W@@pmcount=1
		\fi}
\fi

@ The arguments to |\Wbegin| are various style-file parameters, as follows:
$$\vbox{\halign{{\tt \##}\hfil& --- \vtop{\hsize0.75\hsize \noindent
\strut\tt #\strut}\hfil\cr 
1&LaTeX.class.options;LaTeX.package.options\cr
2&LaTeX.class;LaTeX.package\cr
3&indent.TeX\cr
4&indent.code\cr
5&contents.TeX\cr
6&\{format.reserved format.RESERVED\} \{format.short\_id\} \{format.id
format.ID\} \{format.outer\_macro format.OUTER\_MACRO\} \{format.WEB\_macro
format.WEB\_MACRO\} \{format.intrinsic\} \{format.keyword format.KEYWORD\}
\{format.typewriter\}\cr
7&encap.prefix\cr
8&\{doc.preamble;doc.postamble\}\cr
9&index.name\cr
}}$$

@A
\newcount\W@@ref
\W@@ref=-1

\newcount\W@@lpha

\newcount\W@@pmcount
\W@@pmcount=1

\outer\def\Wbegin[#1]#2#3#4#5#6#7#8#9{\edef\contentsfile{#5}%
	\def\readcontents{\input\contentsfile}%

	\Wequate#6
	\W@@modequate{#7}%
	\edef\INDEX{#9}%
	\def\W@@splitprms##1##2[##3;##4]{\def##1{##3}\def##2{##4}}%
	\W@@splitprms\W@@preamble\W@@postamble[#8]%
	\ifLaTeXisloaded
		  \ifFWEBstandalone
		\def\FWEBend{% \LaTeX\ redefines |\end|.
			\W@@outlsmax{1}% The `1' is because sec. # 
				% isn't incremented for the module list.
			  \global\advance\W@@ssmax by1
	  \immediate\write\@@auxout{\string\W@@maxdepth{\the\W@@ssmax}}%
			  \W@@postamble
			  \W@@makeatend% Override |\makeatletter|
			  \end{document}%
			}%
			\def\W@@ssmin{0}
		\else% Insert mode; not stand-alone.
			\def\FWEBend{}
			% |\W@@ssmin| isn't defined; it's set by |\fweblevel|.
		  \fi
		\W@@splitprms\W@@prma\W@@prmb[#1]%
		\W@@splitprms\W@@prmc\W@@prmd[#2]%
		\ifusedocumentstyle
		   \edef\W@@temp{\noexpand\documentstyle[\W@@prma]{\W@@prmc}}%
			\W@@temp
		\else
			\ifFWEBstandalone
				\documentclass[\W@@prma]{\W@@prmc}%
				\usepackage[\W@@prmb]{\W@@prmd}%
			\fi
		\fi
% Set up defaults.
		\ifFWEBstandalone
			\textwidth\pagewidth
			\textheight\pageheight
		\fi
		\TeXindent#3
		\title{}%
		\author{}%
		\date{\today\\[3pt]\Time}%
		\pagestyle{myheadings}%
% |\Wbegin| might be called more than once if one is using package
% \.{fwebinsert}. 
		\ifx\c@@pagemodule\undefined
			\newcounter{pagemodule}%
			\newcounter{W@@tempcounter}%
		\fi
		\gdef\cl@@section{\@@elt{subsection}\cl@@subsection}
		\gdef\cl@@subsection{\@@elt{subsubsection}\cl@@subsubsection}
		\gdef\cl@@subsubsection{\@@elt{subsubsubsection}}
		\xdef\normaloutput##1##2##3{\the\output \noexpand\W@@output}%
		\ifW@@headers
			\WsetLmarks
		\else
			\def\W@@markN{}%
			\def\W@@mark##1##2{}%
		\fi
		\W@@preamble
		\W@@raggedbottom
		\ifFWEBstandalone
			\begin{document}
		\else
			\begingroup
			\makeatletter
			\@@input{\jobname.aux}
				%|\jobname| is redefined in \.{fwebinsert.sty}.
			\endgroup
		\fi
		\W@@setsecdepth
	\else % Plain \TeX.
		\immediate\openout\W@@cont=\contentsfile
		\def\FWEBend{\W@@postamble\end}
		\TeXindent#3
		\W@@preamble
	\fi
	\W@@setboxes{#4}% Set dimensions of backspace boxes.
% Here we print out a garbage page, so that the first |\topmark| won't be null.
	\ifFWEBstandalone
		\output
			{\setbox0=\page% The first page is garbage
			\global\output{\normaloutput\page\lheader\rheader}%
			}%
		\setpage
		\vbox to \vsize{}
	\fi
	}

@ We need to insert an extra test for changed labels that depends on the
|\Newlabel| information in the \.{.aux} file.  Now the \.{.aux} file is
read by the \.{\\end\{document\}} command; the reading is immediately
preceded by ``|\makeatletter|''.  To insert the new test, we augment that
command to include the appropriate redefinition of |\Newlabel|.  We must
also provide a cousin |\W@@testdef| to |\@@testdef| that recognizes the
extended name definitions (including |\W@@botmodno|) that we use for the
\FWEB\ section. 
@A
\def\W@@makeatend{\let\W@@makeatletter\makeatletter
	\def\makeatletter{\def\Newlabel{\W@@testdef r}%
	\W@@makeatletter}}

\def\W@@testdef#1#2#3#4{\def\reserved@@a{#3{#4}}%
\expandafter\ifx\csname#1@@#2\endcsname
		\reserved@@a
	\else
		\@@tempswatrue
	\fi
}

@
@A
\def\Wch{\note{The following sections were changed by the change file:}
	\let\*=\relax}% English!

@* MACROS for the INDEX.
The index is written by default into \.{INDEX.tex}, but that
name can be overridden with the style-file parameter \.{index.tex}.

@*1 Beginning the index.
Here we begin the index.  In \LaTeX, if \.{multicol.sty} is not loaded, by
this time we should be in |\twocolumn| mode (from the |\beforeindex|
command).  If it is loaded, we begin multi-columns.  It's ended with the
|\Wfin| command.
@A
% The following two lines are for \TeX\ only.
\newbox\Sbox % Saved box preceding the index
\newbox\Lbox % Lefthand column in the index

\ifLaTeXisloaded
	\def\startindex{\ifx\multicols\undefined
				\medskip
			\else
				\begin{multicols}{2}%
			\fi
			}
\else
	\def\startindex{\par\vskip6pt plus 1fil}
\fi

@ The name of the |\Winx| macro is really the style-file parameter
 \.{index.preamble}. 
@A
\def\Winx{\startindex
\ifLaTeXisloaded
\else
	\write\W@@cont{ }% Ensure that the contents file isn't empty
	\closeout\W@@cont % The contents information has been fully gathered
	\output{\ifpagesaved\normaloutput{\box\Sbox}\lheader\rheader\fi
		\global\setbox\Sbox=\page \global\pagesavedtrue}
	\pagesavedfalse \eject % Eject the page-so-far and predecessors
	\setbox\Sbox\vbox{\unvbox\Sbox}% Take it out of its box
	\vsize=\pageheight \advance\vsize by -\ht\Sbox % The remaining height
	\hsize=.5\pagewidth \advance\hsize by -10pt
		% Column width for the index (20pt between cols)
	\parfillskip 0pt plus .6\hsize % Try to avoid almost empty lines
	\def\lr{L}% This tells whether the left or right column is next
	\output{\if L\lr\global\setbox\Lbox=\page \gdef\lr{R}
		\else\normaloutput{\vbox to\pageheight{\box\Sbox\vss
		\hbox to\pagewidth{\box\Lbox\hfil\page}}}\lheader\rheader
		\global\vsize\pageheight\gdef\lr{L}\global\pagesavedfalse\fi}
%	\message{Index:}
\fi
	\outer\def\:##1, {\par\hangindent2em\noindent##1\textcolon\kern1em}% Index entry
	\def\[##1]{$\underline{##1}$}% Underlined index item
	\def\(##1){$^{\rm ##1}$}% Language marker
	\let\Windexspace\medskip % Spacing between letter groups in index.
	\rm 
	{\ifFWEBstandalone\let\glbl\global\else\let\glbl\empty\fi
	\glbl\parskip 0pt plus .5pt
	\glbl\rightskip0pt plus 2.5em 
	\glbl\tolerance 10000
	\glbl\let\*=\W@@lapstar
	\glbl\hyphenpenalty 10000 
	\glbl\parindent0pt
	}
	}

@*1 Ending the index.  
The name of the |\Wfin| macro is the style-file parameter \.{index.postamble}.
@A
\ifLaTeXisloaded
	\def\Wfin{\ifx\multicols\undefined\else\end{multicols}\fi}
\else
	\let\Wfin\relax
\fi

@ If we haven't loaded the \.{multicol} package, then the conventional
\LaTeX\ commands |\twocolumn| has been used before the index starts.  If
the module list is omitted via \.{-xi}, then things will be left in
two-column mode.  This is an issue if we're inserting into another
document.  Thus, we need a command to bring it back to one column.  (But we
want to avoid |\onecolumn| if possible, because that starts a new page.)

@A
\def\W@@onecolumn{%
	\ifx\multicols\undefined
		\onecolumn% In case of insertions & no module list.
	\fi
	}

@*1 Using |makeindex|.  
The |\pg| macro (more generally, the name given by the style-file entry
\.{makeindex.page}) is used in the |.idx| file written in response to the
`|-XI|' option.  The first argument is either empty or an integer file id
filled in by \.{idxmerge}; the second is a possible macro that should act
on the third argument, which is the page number itself.  This example uses
the macro the macro |\pgfmt| to turn the integer id into an uppercase Roman
numeral.  For more information about the use of |\pg|, see the info
documentation, menu item \.{Using makeindex}.

@A
\def\pgfmt#1{\uppercase\expandafter{\romannumeral#1}}

\def\pg#1#2#3{\def\temp{#1}%
\ifx\temp\empty% For the case where \.{idxmerge} hasn't been run.
\else
	\pgfmt{#1}.%
\fi
#2{#3}%
}

@ The macros |\topofindex| and |\botofindex| are used in the preamble and
postamble of the \.{.ind} file constructed by \.{makeindex}.  A sample
that reads in the list of names written out by \.{idxmerge} can be found in
\.{/fweb/manual/idx.tex}.

@A
\def\topofindex{}
\def\botofindex{}


@* MACROS for the MODULE LIST.

@*1 Beginning the module list. This is the style file entry
\.{modules.preamble}. 
@A
\def\Wmods{%
	\def\W@@name{Names of the Modules}%
\ifLaTeXisloaded
	\W@@outlsmax{1}% The `1' is because sec. # hasn't been incremented
%		for the module list.
	\edef\next{\noexpand\W@@mark{{0}{\INDEX}}
		{{0}{\W@@name}}}\next
	\onecolumn% This also starts a new page.
	\edef\next{\noexpand\W@@mark{{0}{\W@@name}}{{0}{\W@@name}}}\next
	\parfillskip 0pt plus 1fil
\else
	\par\vfill\eject 
	\ifpagesaved\null\vfill\eject\fi % Output a null index column
	\if L\lr\else\null\vfill\eject\fi % Finish the current page
	\parfillskip 0pt plus 1fil
	\edef\rhead{\W@@name}%
	\output{\normaloutput\page\lheader\rheader}
	\setpage
\fi
	\def\note##1##2.{\quad{\footnotesize##1 ##2.}}
	\def\WU{\note{Used in}}% Cross-reference for uses of sections. English!
	\def\:{\par\hangindent 2em}\let\*=*%
	}


@* TERMINATION.

@*1 Miscellaneous run info.  
The |\Winfo| command is issued after the List of Modules is processed via
|\Wmods|. 

@A
\def\Winfo#1#2#3#4{%
	\bigskip
	\:{{\bf COMMAND LINE\textcolon}\ \ \Wtypewriter{#1}.}\smallskip
	\:{{\bf WEB FILE\textcolon}\ \ \Wtypewriter{#2}.}\smallskip
	\:{{\bf CHANGE FILE\textcolon}\ \ \Wtypewriter{#3}.}\smallskip
	\:{{\bf GLOBAL LANGUAGE\textcolon}\ \ {\rm #4}.}\bigskip
	}

\def\Wkwds{\:{\leavevmode{\bf Global RCS-like keywords\textcolon}}\medskip}
\def\Wkwd#1#2{\:{\leavevmode\quad{\bf \dollar#1\textcolon}\ \ \Wtypewriter{"#2"}}}

@*1 Finish the section names,  do the table of contents, and terminate.
@A
\ifLaTeXisloaded
	\def\W@@settoc#1{}%

	\def\Wtoc#1{\begingroup
		\W@@settoc{#1}%
		\def\Newlabel##1##2##3{}%
		\setcounter{tocdepth}{\W@@depth}%
		\thispagestyle{empty}%
		\def\W@@name{Table of Contents}% English!
		\edef\next{\noexpand\W@@mark{{0}{\W@@name}}{{0}{\W@@name}}}%
		\next%
		\pagenumbering{roman}%
		\maketitle
		\topofcontents
		\tableofcontents
		\botofcontents
% Force a |\mark| command just before the page break after TOC, using an
% empty new section name (we don't know that yet!).  If we don't do this,
% the first page after TOC picks up ``Table of Contents'' as a header.
		\edef\next{\noexpand\W@@mark{{1}{\W@@name}}{{1}{}}}\next
		\gdef\W@@name{}%
		\newpage% Break after TOC.
		\endgroup
		\pagenumbering{arabic}%
		\pageno=1
		}

	\def\Wcon#1{\newpage
		\let\WIM\WIN % Restore the proper definition.
		\pageno=\contentspageno 
		\Wtoc{#1}%
		}

% Put the |\FWEBtoc| command into \.{limbo.end} to have the Table of
% Contents appear at the beginning.  (This is the default.)
	\def\FWEBtoc{%
		\ifFWEBstandalone
			\Wtoc{}% No toc for insertions.
		\fi
		\gdef\Wcon##1{% Redefinition!
			\W@@onecolumn
			}%
		}
\else
\def\Wcon#1{\par\vfill\eject
	\rightskip 0pt \hyphenpenalty 50 \tolerance 200
	\setpage
	\output{\normaloutput\page\lheader\rheader}
	\titletrue % Prepare to output the table of contents
	\pageno=\contentspageno 
	\def\rhead{Table of Contents}% English!
	\topofcontents
	\catcode`\@@=11
	\hbox to\hsize{\hfil Section\hbox to3em{\hss Page}}
	\def\WZ##1##2##3##4{\hbox to\hsize{\kern##1em\ignorespaces##2
		\leaders\hbox to .5em{.\hfil}\hfil\ ##3\hbox to3em{\hss##4}}}
	\let\WIM\WIN % Restore the proper definition.
	\readcontents\relax % Read the contents info.
	\botofcontents 
	}

\def\FWEBtoc{\message{! Front Table of Contents is only supported with LaTeX.}}
\fi


@ The |\begintt| and |\endtt| verbatim constructions, borrowed from \TeX.
@A
\newskip\ttglue

\ttglue=0.5em plus 0.25em minus 0.15em

\def\ttother{\catcode`\\=\other \catcode`\{=\other \catcode`\}=\other
	\catcode`\$=\other \catcode`\&=\other \catcode`\#=\other
	\catcode`\%=\other \catcode`\~=\other \catcode`\_=\other
	\catcode`\^=\other}

\def\ttverbatim{\begingroup \ttother \obeyspaces \obeylines \tt}

{\obeyspaces\gdef {\ }}

\def\begintt{$$\let\par=\endgraf
	\ttverbatim
	\parskip=0pt
	\rightskip=-\parindent
	\ttfinish}

\def\Begintt{\bgroup
	\let\par=\endgraf
	\ttverbatim
	\parskip=0pt
	\rightskip=-\parindent
	\ttFinish}

{\catcode`\|=0
	|catcode`|\=\other
	|obeylines%
	|gdef|ttfinish#1^^M#2\endtt{#1|vbox{#2}|endgroup$$}%
	|gdef|ttFinish#1\Endtt{#1|endgroup|egroup}}

\let\verticalbar|

\def\activebar{\catcode`\|=\active}

{\activebar
\gdef\normalbar{\activebar
	\let|\verticalbar}}

%\activebar

{\obeylines%
\gdef\ttbar{\activebar%
	{\obeylines\gdef|{\ttverbatim%
		\spaceskip=\ttglue%
		\let^^M=\ \let|=\endgroup}}}}

\let\WCX\Begintt

@
@A
\catcode`\@@=12

@* \INDEX.
