% The version number in the first line is compared with the corresponding
% element in e-TeX, and an error reported if incompatibility is detected.
% The cycle and revision numbers (that is, the element(s) following the
% period) are not used in this comparison, allowing enhancements to be made to
% this module and recorded in its header without introducing a risk of conflict.
%
% This allows to use this file with e-TeX versions 2.0 and 2.1!
%
% Other files whose headers must be kept in synch include "etexdefs.lib" and
% "language.def".
% This is "etex.src", the (e-TeX) source file for the "etex" format file.
% To build the format from it, use one of the following commands or the
% local equivalent:
% Note: a future version may report errors in the %<fac>-<s>-<code>[, <text>]
% format, allowing the more verbose <text>s to be read from file rather than
% stored in the format.
% Make sure this file is being read by e-TeX in extended mode;
% If it is, prepare to check version/revision compatibility, otherwise abort.
\ifx \undefined \eTeXversion
\et@xabort {this file can be processed only in extended mode;\n
\ \ did you perhaps forget the asterisk?%
}%
\else
\begingroup
\catcode `\%=12
\catcode `\?=14
\xdef \et@xfilehdr
{\detokenize {%% e-TeX V}\the \eTeXversion \eTeXrevision}?
\xdef \et@xlibhdr
{\detokenize {%% e-TeXlib V}\the \eTeXversion \eTeXrevision}?
\endgroup
\fi
% Assume extended mode, but no additional \catcodes/\defs yet;
% set up a simple e-TeX condition-reporting system:
\def \et@xinf #1{\et@xmsg {I}{#1}} %%% not currently used
\def \et@xwarn #1{\et@xmsg {W}{#1}}
\def \et@xerr #1#2{{\errhelp={#2}\et@xmsg {E}{#1}}}
% deactivate the processing of patterns and exceptions; these will be
% reinstated later, after the \uselanguage mechanism has been defined.
\let \et@xpatterns=\patterns
\def \patterns
{\begingroup
\everyeof={\fi \endgroup}%
\message {[skipping from \noexpand \patterns to end-of-file...]}%
\iffalse
}
% Read "plain.tex" (\patterns & \hyphenation will be skipped)
\input plain
% restore the catcode of commercial-at (@), which will just have been clobbered
\catcode `\@=\catcode `\A
% Assume an extended Plain environment (i.e. there are no longer any
% restrictions on the coding techniques we can use). First prepare to
% carry out consistency checks on the file headers and the current e-TeX
% version/revision levels:
\def \et@xfmtsrc {etex.src}
\etexhdrchk {file} {\et@xfmtsrc}
\ifcase \etexstatus
\et@xerr {unable to open format source file "\et@xfmtsrc";}
{This should not happen; please ensure that your system
allows a file to be opened for reading more than once
concurrently.%
}%
\or
\et@xwarn {format source file "\et@xfmtsrc" has wrong header;\n
\ \ expected: "\et@xfilehdr"; found: "\et@xbuf";%
}%
{You are using a version of e-TeX which may be incompatible
with the source for the format file you are trying to
compile; please ensure that you have the most recent
version of each. I will proceed, but you should treat
the results with caution...%
}%
\fi
% Module handling now implemented (V1.0-2)
\def \module #1{\iftrue}
\let \endmodule=\fi
\newtoks \et@xtoks
\def \et@xl@@d #1 #2\endl@ad %%% the "#1 #2" code avoids trailing spaces
{\ifcsname module:#1\endcsname
\et@xwarn {duplicate module name "#1"}%
\else
\csname module:#1\endcsname %%% we exploit the side-effect explicitly
\et@xtoks=\expandafter
{\the \et@xtoks
\expandafter \let \csname module:#1\endcsname=\undefined
}%
\fi
}
\def \load #1 from #2 %%% selective module loading from an e-TeX library file
{\etexhdrchk {lib} {#2}%
\ifcase \etexstatus
\et@xerr {unable to open library file "#2"; load aborted.}
{I got an <eof> on trying to open your library file;
please make sure it exists, is readable and is not locked.%
}%
\or
\et@xerr {library file "#2" has wrong header;\n
\ \ expected: "\et@xlibhdr"; found: "\et@xbuf";\n
\ \ load aborted.%
}%
{The first line of your library does not start with
the correct e-TeX header; you may need to update the
file to be compatible with the current version of
e-TeX, or you may simply have specified the wrong file.%
}%
\else
\et@xtoks={\et@xtoks={}}%
\et@xl@ad #1,\endl@ad
\et@xload {#2}
\the \et@xtoks
\fi
}
\load interactionmodes from etexdefs.lib %%% \load <foo>[, <bar>...] from <baz>
% OK, that's all the utilities defined; on with the real work:
% First, re-instate \patterns:
\let \patterns=\et@xpatterns
% Define the language-handling commands
\def \et@xlang {\csname newlanguage\endcsname}
\def \uselanguage #1%
{\ifcsname lang@#1\endcsname
\language=\csname lang@#1\endcsname
\lefthyphenmin=\csname lhm@#1\endcsname
\righthyphenmin=\csname rhm@#1\endcsname
\ifdefined \uselanguage@hook % V1.0-1
\uselanguage@hook {#1}% % V1.0-1
\fi
\else
\et@xerr {language #1 undefined.}%
{You are trying to use a language which has not previously
been defined; remember that any language you want to use
will need to have been specified at the time the format
was created.%
}%
\fi
}
% Decrement \count 19, because \newlanguage will increment it again
\advance \count 19 by -1
% We are about to try to process a user/site-specific file "language.def",
% which establishes a Babel-like language selection environment. Since
% there is always a risk of a spurious file of that name being found,
% we look for an e-TeX header in the first line. If the file can be opened,
% but doesn't have the right header, we interrogate the user as to whether
% to use fallback mode; in this mode, we simply establish USenglish as the
% sole language, with the et@x patterns, exceptions and left- and right-
% hyphen minima for TeX. If we can't interrogate the user (e.g. not in
% \errorstopmode), or if the user elects not to use fallback, we abort;
% if the file can't be found/opened, we use fallback unconditionally.
\newif \ifb@dresponse
\newif \ifusef@llback
\def \l@ngdefnfile {language.def}
\etexhdrchk {file} {\l@ngdefnfile}
\ifcase \etexstatus
\et@xwarn {unable to open file "\l@ngdefnfile";}%
\usef@llback % unable to open "language.def"
\or
\et@xwarn {file "\l@ngdefnfile" has wrong header;\n
\ \ expected: "\et@xfilehdr"; found: "\et@xbuf";%
}%
\@sk {Use fallback?} {usef@llback} {y}%
\ifusef@llback
\usef@llback
\else
\input \l@ngdefnfile % use "language.def" after warning
\fi
\else
\input \l@ngdefnfile % "language.def" open & valid
\fi
% All that was just to set up natural language handling...
% The "real" work of "etex.src", however, is to augment the non-primitives
% of Plain.TeX to incorporate e-TeX specific features, and to add new
% non-primitives to simplify access to new e-TeX specific primitives.
\message {Augmenting the Plain TeX definitions:}
\message {\string \tracingall;}
\message {\string \eTeX,}
\def \eTeX {$\varepsilon$-\TeX} %%% the simple version, not suitable for maths;
%%% a more sophisticated one may find its way
%%% into "etexdefs.lib" in due course.
% We don't change the Plain TeX definitions of \newcount, etc., but the
% \alloc@ macro doing the actual work is redefined.
% When the normal register pool for \count, \dimen, \skip, \muskip,
% \box, or \toks registers is exhausted, we switch to the extended pool.
\def \alloc@ #1#2#3#4#5%
{\ifnum \count 1#1 < #4% make sure there's still room
\allocationnumber=\count 1#1
\global \advance \count 1#1 by \@ne
\global #3#5=\allocationnumber
\wlog {\string #5=\string #2\the \allocationnumber}%
\else \ifnum #1 < 6
\begingroup \escapechar=\m@ne
\expandafter \alloc@@ \expandafter {\string #2}#5%
\else
\errmessage {No room for a new #2}%
\fi
\fi
}
% The \expandafter construction used here allows the generation of
% \newcount and \globcount from #1=count. Moreover (and more important)
% this construction avoids the appearance of \outer macros inside
% macro definitions or conditionals.
\def \ch@ck #1#2#3#4%
{\ifnum \count 1#1 < #2#4\else \errmessage {No room for a new #3}\fi}
% And we define \reserveinserts, so that you can say \reserveinserts{17}
% in order to reserve room for up to 17 additional insertion classes that will
% not be taken away by \newcount, \newdimen, \newskip, or \newbox.
% Now, we define \globcount, \globbox, etc., so that you can say
% \globcount\foo and \foo will be defined (with \countdef) to be the
% next count register from the vastly larger but somewhat less efficient
% extended register pool. We also define \loccount, etc., but these
% register definitions are local to the current group.
\def \et@xglob #1#2#3#4%
{\et@xchk #1#2% make sure there's still room
{\allocationnumber=\count 26#1
\global \advance \count 26#1 by \@ne
\global #3#4=\allocationnumber
\wlog {\string #4=\string #2\the \allocationnumber}%
}%
}
\def \et@xloc#1#2#3#4%
{\et@xchk #1#2% make sure there's still room
{\advance \count 27#1 by \m@ne
\allocationnumber=\count 27#1
#3#4=\allocationnumber
\wlog {\string #4=\string #2\the \allocationnumber \space (local)}%
}%
}
\def \et@xchk #1#2#3%
{\ifnum \count 26#1 < \count 27#1
#3%
\else
\errmessage {No room for a new #2}%
\fi
}
% Next we define \globcountblk, \loccountblk, etc., so that one can
% write \globcountblk\foo{17} and \foo will be defined (with \mathchardef)
% as the first (the zeroth?) of a block of 17 consecutive registers.
% Thus the user is intended to reference elements <\foo+0> to <\foo+n-1>,
% where n is the length of the block allocated.
% And, both to provide a higher-level interface to the block allocation
% scheme, and to demonstrate possible applications of the new \...expr
% primitives, we also define \globcountvector and \loccountvector (etc)
% which allow the user to access elements with embedded arithmetic, as in
% In an attempt to reduce the overheads of e-TeX, we recycle all possible
% resources, including (as a penultimate step) the recycler itself...
% The user can circumvent (or force) this during format creation,
% by \letting \ifrecycle=\iffalse (or \iftrue, to force it).
% As this file has grown by accretion, it is possible that we are no
% longer recycling all the resources we could; this will be investigated.
% The following are retained, since they may be needed by user code; with a few
% (regrettable) exceptions, all of these are given the \etex or \et@x prefix,
% to reduce as far as possible the risk of them clashing with other used-defined
% names.
% The e-TeX team are willing to change the names of the remaining, at-risk,
% control sequences if it is demonstrated that the current names cause problems
% or difficulties.
01-FEB-1999: 2.1;0 Allow file to be used with e-TeX versions 2.0 and 2.1
25-MAR-1998: 2.0;19 Improved log message for \{glob|loc}{marks|box}vector (PEB)
24-MAR-1998: 2.0;18 Optimisation of one section made (DC & PEB),
a couple of \if tests made more robust,
and spacing improved in one macro.
24-MAR-1998: 2.0;17 Coding styles unified and all references to Peter
Breitenlohner eliminated from main code
23-MAR-1998: 2.0;16 Continued from 2.0;15
20-MAR-1998: 2.0;15 Changes made here and in "etexdefs.lib" to
improve compatibility with LaTeX, and
\{glob,loc}{marks,box}vector re-thought.
11-MAR-1998: 2.0;14 \newmark made synonym for \newmarks / PT
10-MAR-1998: 2.0;13 Missing brace re-inserted in \...lvec /PT
10-MAR-1998: 2.0;12 Typo corrected in Peter's name /PT
10-MAR-1998: 2.0;11 "\...lvec" failed to use \et@xhash; fixed / PT
10-MAR-1998: 2.0;10 \h@sh -> \et@xhash /PT
06-MAR-1998: 2.0;9 Final tweaks by PEB !
05-MAR-1998: <missing version number> Final tweaks by PT
28-Feb-1998: 2.0;8 Major re-work by PEB
24-Feb-1998: 2.0;7 \tracingnesting -> \tw@
24-FEB-1998: 2.0;6 version-mismatch reduced in severity;
\tracingall and ...none improved;
aesthetic spaces around "=" removed
24-Jan-1998: 2.0;5: block allocation of registers added
21-Jan-1998: 2.0;4: released to e-TeX team for testing/comments
20-Jan-1998: \glob... implemented, and coding simplified by
the implementation and use of of \max@xpr
06-Jan-1998: Alpha-testing complete of extended and local register allocation.
29-Dec-1997: The "%!" convention replaced by a corresponding "%%":
this should avoid any inadvertent conflict with Adobe conventions.
\tracingall augmented with
\tracinglostchars=\tw@ %%% Q -- should this be default?
\tracingnesting=\@ne
\tracingnone augmented.
05-DEC-1997: A long-standing bug removed: left- and right- hyphenmin
were transposed in fallback mode :-(((((
24-APR-1997: An interim release, to provide compatibility with Peter's
naming conventions for beta-test versions of e-TeX V2.
Consistency checking is now restricted to \eTeXversion,
and \eTeXrevision is ignored.
01-NOV-1996: V1.1;5: Final stage? Checking that everything possible
is recycled whilst nothing that is needed is lost. Retained
names given \etex or \et@x prefix wherever possible. Some
potentially dangerous cs-names commented out of the recycle/retain
lists because they were synonyms of members of the if-else-fi set.
The definition of the e-TeX logo added: this had somehow slipped
through the net! Intended to be the final revision before public
release, but awaiting comments from other members of the team.
31-OCT-1996: V1.1;4: errors noticed while proof-reading corrected; far
greater use made of concealed control sequences with
commercial-at (@); library file headers differentiated
from ordinary file headers; return-values for header-check
altered to allow fall-thru' if ok; fallback-use algorithm
significantly modified (major semantic shift).
29-OCT-1996: V1.1;3: tidying up prior to release; careful check on
which control words can be re-cycled; \recycle made more
robust, to check whether one is trying to re-cycle something
that was never 'cycled' in the first place (PEB suggestion);
\et@xmsg re-written to use \message or \errmessage as necessary;
\errhelps provided for all places they might be referenced.
27-OCT-1996: V1.1;2: minor version numbers re-introduced, using semi-colon
as delimiter and stopping pattern matching at the semi-colon;
\et@xfilehdr defined dynamically, based in \eTeXversion and
\eTeXrevision; \load now uses \etexhdrchk, so library
files are required to start with an e-TeX header; this will
have implications when e-TeX -> V2+, so this code should be
re-considered at this point.
17-OCT-1996: V1.1: minor version numbers eliminated, to reduce the
need for users to update their "language.def" files.
17-OCT-1996: V1.0-4: \addlanguage@hook added, version history moved to end.
17-OCT-1996: Version 1.0-3 does away with the "fallback" file.
16-OCT-1996: Version 1.0-2 implements module handling, so constant "3"
no longer used (see below).
13-Oct-1996: Replaced \def by \chardef where possible;
eliminated dependency on "etexdefs.def", hard-coding
in the constant "3" (with comment) instead;
used Bernd's \ch@ckforyn;
re-catcoded `\@ earlier, to reduce number of \[if]csnames;
commented the strange indentation of the \recycles at end.
11-Oct-1996: language handling commands modified (V1.0): PT/BR