| 1 |
%% e-TeX V2.1;0-luatex2 |
| 2 |
%% Revision-date: 16-MAY-2013 18:33:45 |
| 3 |
%% Revision-history: (at-end) |
| 4 |
|
| 5 |
% The version number in the first line is compared with the corresponding |
| 6 |
% element in e-TeX, and an error reported if incompatibility is detected. |
| 7 |
% The cycle and revision numbers (that is, the element(s) following the |
| 8 |
% period) are not used in this comparison, allowing enhancements to be made to |
| 9 |
% this module and recorded in its header without introducing a risk of conflict. |
| 10 |
% |
| 11 |
% This allows to use this file with e-TeX versions 2.0 and 2.1! |
| 12 |
% |
| 13 |
% Other files whose headers must be kept in synch include "etexdefs.lib" and |
| 14 |
% "language.def". |
| 15 |
|
| 16 |
% This is "etex.src", the (e-TeX) source file for the "etex" format file. |
| 17 |
% To build the format from it, use one of the following commands or the |
| 18 |
% local equivalent: |
| 19 |
|
| 20 |
% Generic: einitex *etex.src \dump |
| 21 |
% emTeX: etex -i *etex.src \dump |
| 22 |
% VMS: etex /init /noformat *"etex.src \dump" |
| 23 |
|
| 24 |
% Assume a purely IniTeX environment and set up a minimal \catcode r\'egime |
| 25 |
|
| 26 |
\catcode `\{=1 |
| 27 |
\catcode `\}=2 |
| 28 |
\catcode `\#=6 |
| 29 |
\catcode `\^=7 |
| 30 |
\catcode `\@=\catcode `\A |
| 31 |
|
| 32 |
% Define the basic error-reporting and abort mechanisms: |
| 33 |
|
| 34 |
\def \et@xmsg #1#2% |
| 35 |
{\begingroup |
| 36 |
\def \n {^^J}% |
| 37 |
\def \ { }% |
| 38 |
\newlinechar=\expandafter `\n |
| 39 |
\if E#1% |
| 40 |
\errorcontextlines=0 |
| 41 |
\errmessage {e-TeX error: #2}% |
| 42 |
\else |
| 43 |
\message {\n ! e-TeX \if I#1 message% |
| 44 |
\else \if W#1 warning% |
| 45 |
\else \if F#1 fatal error% |
| 46 |
\else |
| 47 |
\ unknown (#1)% |
| 48 |
\fi |
| 49 |
\fi |
| 50 |
\fi: #2% |
| 51 |
}% |
| 52 |
\fi |
| 53 |
\endgroup |
| 54 |
} |
| 55 |
|
| 56 |
% Note: a future version may report errors in the %<fac>-<s>-<code>[, <text>] |
| 57 |
% format, allowing the more verbose <text>s to be read from file rather than |
| 58 |
% stored in the format. |
| 59 |
|
| 60 |
\def \et@xabort #1% |
| 61 |
{\et@xmsg {F}{#1}% |
| 62 |
\batchmode |
| 63 |
\end |
| 64 |
} |
| 65 |
|
| 66 |
% Make sure this file is being read by e-TeX in extended mode; |
| 67 |
% If it is, prepare to check version/revision compatibility, otherwise abort. |
| 68 |
|
| 69 |
\ifx \undefined \eTeXversion |
| 70 |
\et@xabort {this file can be processed only in extended mode;\n |
| 71 |
\ \ did you perhaps forget the asterisk?% |
| 72 |
}% |
| 73 |
\else |
| 74 |
\begingroup |
| 75 |
\catcode `\%=12 |
| 76 |
\catcode `\?=14 |
| 77 |
\xdef \et@xfilehdr |
| 78 |
{\detokenize {%% e-TeX V}\the \eTeXversion \eTeXrevision}? |
| 79 |
\xdef \et@xlibhdr |
| 80 |
{\detokenize {%% e-TeXlib V}\the \eTeXversion \eTeXrevision}? |
| 81 |
\endgroup |
| 82 |
\fi |
| 83 |
|
| 84 |
% Assume extended mode, but no additional \catcodes/\defs yet; |
| 85 |
% set up a simple e-TeX condition-reporting system: |
| 86 |
|
| 87 |
\def \et@xinf #1{\et@xmsg {I}{#1}} %%% not currently used |
| 88 |
\def \et@xwarn #1{\et@xmsg {W}{#1}} |
| 89 |
\def \et@xerr #1#2{{\errhelp={#2}\et@xmsg {E}{#1}}} |
| 90 |
|
| 91 |
% deactivate the processing of patterns and exceptions; these will be |
| 92 |
% reinstated later, after the \uselanguage mechanism has been defined. |
| 93 |
|
| 94 |
\let \et@xpatterns=\patterns |
| 95 |
\def \patterns |
| 96 |
{\begingroup |
| 97 |
\everyeof={\fi \endgroup}% |
| 98 |
\message {[skipping from \noexpand \patterns to end-of-file...]}% |
| 99 |
\iffalse |
| 100 |
} |
| 101 |
|
| 102 |
% Read "plain.tex" (\patterns & \hyphenation will be skipped) |
| 103 |
|
| 104 |
\input plain |
| 105 |
|
| 106 |
% restore the catcode of commercial-at (@), which will just have been clobbered |
| 107 |
|
| 108 |
\catcode `\@=\catcode `\A |
| 109 |
|
| 110 |
% Assume an extended Plain environment (i.e. there are no longer any |
| 111 |
% restrictions on the coding techniques we can use). First prepare to |
| 112 |
% carry out consistency checks on the file headers and the current e-TeX |
| 113 |
% version/revision levels: |
| 114 |
|
| 115 |
\newread \et@xinput |
| 116 |
|
| 117 |
\def \etexhdrchk #1#2% |
| 118 |
{\openin \et@xinput=#2 |
| 119 |
\ifeof \et@xinput |
| 120 |
\chardef \etexstatus=0 % V1.0-1 |
| 121 |
\else |
| 122 |
\begingroup |
| 123 |
\endlinechar=-1 |
| 124 |
\readline \et@xinput to \et@xbuf |
| 125 |
\closein \et@xinput |
| 126 |
\def \p@rtition ##1.##2\endp@rtition {##1}% V2.1%0 |
| 127 |
\xdef \et@xbuf |
| 128 |
{\expandafter \p@rtition \et@xbuf .\endp@rtition}% V2.1;0 |
| 129 |
\xdef \et@xtmp {\csname et@x#1hdr\endcsname}% |
| 130 |
\xdef \et@xtmp |
| 131 |
{\expandafter \p@rtition \et@xtmp .\endp@rtition}% V2.1;0 |
| 132 |
\endgroup |
| 133 |
\ifx \et@xtmp \et@xbuf |
| 134 |
\chardef \etexstatus=2 % V1.1;4 |
| 135 |
\else |
| 136 |
\chardef \etexstatus=1 % V1.1;4 |
| 137 |
\fi |
| 138 |
\fi |
| 139 |
} |
| 140 |
|
| 141 |
% Check the version number of this file: |
| 142 |
|
| 143 |
\def \et@xfmtsrc {etex.src} |
| 144 |
\etexhdrchk {file} {\et@xfmtsrc} |
| 145 |
\ifcase \etexstatus |
| 146 |
\et@xerr {unable to open format source file "\et@xfmtsrc";} |
| 147 |
{This should not happen; please ensure that your system |
| 148 |
allows a file to be opened for reading more than once |
| 149 |
concurrently.% |
| 150 |
}% |
| 151 |
\or |
| 152 |
\et@xwarn {format source file "\et@xfmtsrc" has wrong header;\n |
| 153 |
\ \ expected: "\et@xfilehdr"; found: "\et@xbuf";% |
| 154 |
}% |
| 155 |
{You are using a version of e-TeX which may be incompatible |
| 156 |
with the source for the format file you are trying to |
| 157 |
compile; please ensure that you have the most recent |
| 158 |
version of each. I will proceed, but you should treat |
| 159 |
the results with caution...% |
| 160 |
}% |
| 161 |
\fi |
| 162 |
|
| 163 |
% Module handling now implemented (V1.0-2) |
| 164 |
|
| 165 |
\def \module #1{\iftrue} |
| 166 |
\let \endmodule=\fi |
| 167 |
|
| 168 |
\newtoks \et@xtoks |
| 169 |
|
| 170 |
\def \et@xl@@d #1 #2\endl@ad %%% the "#1 #2" code avoids trailing spaces |
| 171 |
{\ifcsname module:#1\endcsname |
| 172 |
\et@xwarn {duplicate module name "#1"}% |
| 173 |
\else |
| 174 |
\csname module:#1\endcsname %%% we exploit the side-effect explicitly |
| 175 |
\et@xtoks=\expandafter |
| 176 |
{\the \et@xtoks |
| 177 |
\expandafter \let \csname module:#1\endcsname=\undefined |
| 178 |
}% |
| 179 |
\fi |
| 180 |
} |
| 181 |
|
| 182 |
\def \et@xl@ad #1#2,#3\endl@ad %%% the #1#2 code avoids spurious leading spaces |
| 183 |
{\et@xl@@d #1#2 \endl@ad |
| 184 |
\if *#3* |
| 185 |
\let \n@xt=\relax |
| 186 |
\else |
| 187 |
\def \n@xt {\et@xl@ad #3\endl@ad}% |
| 188 |
\fi |
| 189 |
\n@xt |
| 190 |
} |
| 191 |
|
| 192 |
\def \et@xload #1 %%% needed because of the embedded \ifs... |
| 193 |
{\def \module ##1% |
| 194 |
{\unless |
| 195 |
\ifcsname module:##1\endcsname |
| 196 |
\message {Skipping module "##1";}% |
| 197 |
\else |
| 198 |
\message {Loading module "##1";}% |
| 199 |
}% |
| 200 |
\input #1 |
| 201 |
\def \module ##1{\iftrue}% |
| 202 |
} |
| 203 |
|
| 204 |
\def \load #1 from #2 %%% selective module loading from an e-TeX library file |
| 205 |
{\etexhdrchk {lib} {#2}% |
| 206 |
\ifcase \etexstatus |
| 207 |
\et@xerr {unable to open library file "#2"; load aborted.} |
| 208 |
{I got an <eof> on trying to open your library file; |
| 209 |
please make sure it exists, is readable and is not locked.% |
| 210 |
}% |
| 211 |
\or |
| 212 |
\et@xerr {library file "#2" has wrong header;\n |
| 213 |
\ \ expected: "\et@xlibhdr"; found: "\et@xbuf";\n |
| 214 |
\ \ load aborted.% |
| 215 |
}% |
| 216 |
{The first line of your library does not start with |
| 217 |
the correct e-TeX header; you may need to update the |
| 218 |
file to be compatible with the current version of |
| 219 |
e-TeX, or you may simply have specified the wrong file.% |
| 220 |
}% |
| 221 |
\else |
| 222 |
\et@xtoks={\et@xtoks={}}% |
| 223 |
\et@xl@ad #1,\endl@ad |
| 224 |
\et@xload {#2} |
| 225 |
\the \et@xtoks |
| 226 |
\fi |
| 227 |
} |
| 228 |
|
| 229 |
\load interactionmodes from etexdefs.lib %%% \load <foo>[, <bar>...] from <baz> |
| 230 |
|
| 231 |
\def \@sk #1#2#3% |
| 232 |
{\ifnum \interactionmode=\interactionmodes {errorstop} %%% V2.0;15 |
| 233 |
\def \pr@mpt {\csname #1 \endcsname}% |
| 234 |
\edef \pr@mptloop {{\escapechar=-1 \global \readline 16 to \pr@mpt}}% |
| 235 |
\loop \pr@mptloop |
| 236 |
\ch@ckforyn \pr@mpt {#2}% |
| 237 |
\ifb@dresponse |
| 238 |
\message {Please answer Y[es] or N[o]}% |
| 239 |
\repeat |
| 240 |
\else |
| 241 |
\def \pr@mpt {#3}% |
| 242 |
\ch@ckforyn \pr@mpt {#2}% |
| 243 |
\fi |
| 244 |
} |
| 245 |
|
| 246 |
\def \ch@ckforyn #1#2% Bernd Raichle's improved version, V1.0-1 |
| 247 |
{\edef \@nswer {#1}% |
| 248 |
\def \p@rse ##1##2\endp@rse |
| 249 |
{\lowercase {\if y##1}\b@dresponsefalse \csname #2true\endcsname |
| 250 |
\else \lowercase {\if n##1}\b@dresponsefalse \csname #2false\endcsname |
| 251 |
\else |
| 252 |
\b@dresponsetrue |
| 253 |
\fi |
| 254 |
\fi |
| 255 |
}% |
| 256 |
\expandafter \p@rse \@nswer \endp@rse |
| 257 |
} |
| 258 |
|
| 259 |
\def \usef@llback %%% V1.0-3 |
| 260 |
{\message {Using fallback mode (USenglish)}% |
| 261 |
\addlanguage {USenglish}{hyphen}{}{2}{3}% |
| 262 |
} |
| 263 |
|
| 264 |
% OK, that's all the utilities defined; on with the real work: |
| 265 |
% First, re-instate \patterns: |
| 266 |
|
| 267 |
\let \patterns=\et@xpatterns |
| 268 |
|
| 269 |
% Define the language-handling commands |
| 270 |
|
| 271 |
\def \et@xlang {\csname newlanguage\endcsname} |
| 272 |
|
| 273 |
\def \uselanguage #1% |
| 274 |
{\ifcsname lang@#1\endcsname |
| 275 |
\language=\csname lang@#1\endcsname |
| 276 |
\lefthyphenmin=\csname lhm@#1\endcsname |
| 277 |
\righthyphenmin=\csname rhm@#1\endcsname |
| 278 |
\ifdefined\directlua % V2.1;0-luatex |
| 279 |
\ifcsname lu@texhyphen@loaded@\the\language\endcsname \else |
| 280 |
\global\expandafter\def\csname |
| 281 |
lu@texhyphen@loaded@\the\language\endcsname{}% |
| 282 |
\directlua{ |
| 283 |
if not status.ini_version then |
| 284 |
require("luatex-hyphen") |
| 285 |
luatexhyphen.loadlanguage("\luatexluaescapestring{#1}", |
| 286 |
\the\language) |
| 287 |
end}% |
| 288 |
\fi |
| 289 |
\fi |
| 290 |
\ifdefined \uselanguage@hook % V1.0-1 |
| 291 |
\uselanguage@hook {#1}% % V1.0-1 |
| 292 |
\fi |
| 293 |
\else |
| 294 |
\et@xerr {language #1 undefined.}% |
| 295 |
{You are trying to use a language which has not previously |
| 296 |
been defined; remember that any language you want to use |
| 297 |
will need to have been specified at the time the format |
| 298 |
was created.% |
| 299 |
}% |
| 300 |
\fi |
| 301 |
} |
| 302 |
|
| 303 |
\def \addlanguage #1#2#3#4#5% language patterns exceptions lhm rhm |
| 304 |
{\expandafter \et@xlang \csname lang@#1\endcsname |
| 305 |
\expandafter \chardef \csname lhm@#1\endcsname=#4 % V1.0-1 |
| 306 |
\expandafter \chardef \csname rhm@#1\endcsname=#5 % V1.0-1 |
| 307 |
\ifdefined\directlua % V2.1;0-luatex |
| 308 |
\csname fi\endcsname |
| 309 |
\csname if\directlua{% do we want to skip this language now? |
| 310 |
require("luatex-hyphen") |
| 311 |
if (luatexhyphen.lookupname("\luatexluaescapestring{#1}") == nil) |
| 312 |
or (\number\csname lang@#1\endcsname == 0) then |
| 313 |
tex.sprint("false") % no, load it (execute 'else' part) |
| 314 |
else |
| 315 |
tex.sprint("true") % yes, skip |
| 316 |
end}\endcsname |
| 317 |
\else |
| 318 |
\uselanguage {#1}% |
| 319 |
\input #2 |
| 320 |
\if *#3*\else \input #3 \fi |
| 321 |
\edef \fmtversion {\fmtversion/#1}% |
| 322 |
\fi |
| 323 |
\ifdefined \addlanguage@hook % V1.0-4 |
| 324 |
\addlanguage@hook {#1}% % V1.0-4 |
| 325 |
\fi |
| 326 |
} |
| 327 |
|
| 328 |
% Decrement \count 19, because \newlanguage will increment it again |
| 329 |
|
| 330 |
\advance \count 19 by -1 |
| 331 |
|
| 332 |
% We are about to try to process a user/site-specific file "language.def", |
| 333 |
% which establishes a Babel-like language selection environment. Since |
| 334 |
% there is always a risk of a spurious file of that name being found, |
| 335 |
% we look for an e-TeX header in the first line. If the file can be opened, |
| 336 |
% but doesn't have the right header, we interrogate the user as to whether |
| 337 |
% to use fallback mode; in this mode, we simply establish USenglish as the |
| 338 |
% sole language, with the et@x patterns, exceptions and left- and right- |
| 339 |
% hyphen minima for TeX. If we can't interrogate the user (e.g. not in |
| 340 |
% \errorstopmode), or if the user elects not to use fallback, we abort; |
| 341 |
% if the file can't be found/opened, we use fallback unconditionally. |
| 342 |
|
| 343 |
\newif \ifb@dresponse |
| 344 |
\newif \ifusef@llback |
| 345 |
|
| 346 |
\def \l@ngdefnfile {language.def} |
| 347 |
|
| 348 |
\etexhdrchk {file} {\l@ngdefnfile} |
| 349 |
\ifcase \etexstatus |
| 350 |
\et@xwarn {unable to open file "\l@ngdefnfile";}% |
| 351 |
\usef@llback % unable to open "language.def" |
| 352 |
\or |
| 353 |
\et@xwarn {file "\l@ngdefnfile" has wrong header;\n |
| 354 |
\ \ expected: "\et@xfilehdr"; found: "\et@xbuf";% |
| 355 |
}% |
| 356 |
\@sk {Use fallback?} {usef@llback} {y}% |
| 357 |
\ifusef@llback |
| 358 |
\usef@llback |
| 359 |
\else |
| 360 |
\input \l@ngdefnfile % use "language.def" after warning |
| 361 |
\fi |
| 362 |
\else |
| 363 |
\input \l@ngdefnfile % "language.def" open & valid |
| 364 |
\fi |
| 365 |
|
| 366 |
% All that was just to set up natural language handling... |
| 367 |
% The "real" work of "etex.src", however, is to augment the non-primitives |
| 368 |
% of Plain.TeX to incorporate e-TeX specific features, and to add new |
| 369 |
% non-primitives to simplify access to new e-TeX specific primitives. |
| 370 |
|
| 371 |
\message {Augmenting the Plain TeX definitions:} |
| 372 |
\message {\string \tracingall;} |
| 373 |
|
| 374 |
\def \tracingall |
| 375 |
{\tracingonline=\@ne |
| 376 |
\tracingcommands=\thr@@ % plain.tex has \tw@ |
| 377 |
\tracingstats=\tw@ |
| 378 |
\tracingpages=\@ne |
| 379 |
\tracingoutput=\@ne |
| 380 |
\tracinglostchars=\tw@ % plain.tex has \@ne |
| 381 |
\tracingmacros=\tw@ |
| 382 |
\tracingparagraphs=\@ne |
| 383 |
\tracingrestores=\@ne |
| 384 |
\showboxbreadth=\maxdimen |
| 385 |
\showboxdepth=\maxdimen |
| 386 |
\errorstopmode |
| 387 |
\tracinggroups=\@ne |
| 388 |
\tracingifs=\@ne |
| 389 |
\tracingscantokens=\@ne |
| 390 |
\tracingnesting=\@ne |
| 391 |
\tracingassigns=\tw@ |
| 392 |
} |
| 393 |
|
| 394 |
\message {Adding new e-TeX definitions:} |
| 395 |
|
| 396 |
\message {\string \eTeX,} |
| 397 |
\def \eTeX {$\varepsilon$-\TeX} %%% the simple version, not suitable for maths; |
| 398 |
%%% a more sophisticated one may find its way |
| 399 |
%%% into "etexdefs.lib" in due course. |
| 400 |
|
| 401 |
\message {\string \loggingall,} |
| 402 |
\def \loggingall {\tracingall \tracingonline=\z@} |
| 403 |
|
| 404 |
\message {\string \tracingnone,} |
| 405 |
\def \tracingnone |
| 406 |
{\tracingassigns=\z@ |
| 407 |
\tracingnesting=\z@ |
| 408 |
\tracingscantokens=\z@ |
| 409 |
\tracingifs=\z@ |
| 410 |
\tracinggroups=\z@ |
| 411 |
\showboxdepth=\thr@@ |
| 412 |
\showboxbreadth=5 |
| 413 |
\tracingrestores=\z@ |
| 414 |
\tracingparagraphs=\z@ |
| 415 |
\tracingmacros=\z@ |
| 416 |
\tracinglostchars=\@ne |
| 417 |
\tracingoutput=\z@ |
| 418 |
\tracingpages=\z@ |
| 419 |
\tracingstats=\z@ |
| 420 |
\tracingcommands=\z@ |
| 421 |
\tracingonline=\z@ |
| 422 |
} |
| 423 |
|
| 424 |
\message {register allocation;} |
| 425 |
|
| 426 |
\newcount \et@xins % our insertion counter (\insc@unt is used differently) |
| 427 |
|
| 428 |
% We have to adjust the Plain TeX register allocation counts for our |
| 429 |
% slightly modified book-keeping: |
| 430 |
|
| 431 |
\advance \count 10 by 1 % \count 10=23 % allocates \count registers 23, 24, ... |
| 432 |
\advance \count 11 by 1 % \count 11=10 % allocates \dimen registers 10, 11, ... |
| 433 |
\advance \count 12 by 1 % \count 12=10 % allocates \skip registers 10, 11, ... |
| 434 |
\advance \count 13 by 1 % \count 13=10 % allocates \muskip registers 10, 11, ... |
| 435 |
\advance \count 14 by 1 % \count 14=10 % allocates \box registers 10, 11, ... |
| 436 |
\advance \count 15 by 1 % \count 15=10 % allocates \toks registers 10, 11, ... |
| 437 |
\advance \count 16 by 1 % \count 16=0 % allocates input streams 0, 1, ... |
| 438 |
\advance \count 17 by 1 % \count 17=0 % allocates output streams 0, 1, ... |
| 439 |
\advance \count 18 by 1 % \count 18=4 % allocates math families 4, 5, ... |
| 440 |
\advance \count 19 by 1 % \count 19=0 % allocates \language codes 0, 1, ... |
| 441 |
|
| 442 |
\et@xins=\insc@unt % \et@xins=255 % allocates insertions 254, 253, ... |
| 443 |
|
| 444 |
% We don't change the Plain TeX definitions of \newcount, etc., but the |
| 445 |
% \alloc@ macro doing the actual work is redefined. |
| 446 |
|
| 447 |
% When the normal register pool for \count, \dimen, \skip, \muskip, |
| 448 |
% \box, or \toks registers is exhausted, we switch to the extended pool. |
| 449 |
|
| 450 |
\def \alloc@ #1#2#3#4#5% |
| 451 |
{\ifnum \count 1#1 < #4% make sure there's still room |
| 452 |
\allocationnumber=\count 1#1 |
| 453 |
\global \advance \count 1#1 by \@ne |
| 454 |
\global #3#5=\allocationnumber |
| 455 |
\wlog {\string #5=\string #2\the \allocationnumber}% |
| 456 |
\else \ifnum #1 < 6 |
| 457 |
\begingroup \escapechar=\m@ne |
| 458 |
\expandafter \alloc@@ \expandafter {\string #2}#5% |
| 459 |
\else |
| 460 |
\errmessage {No room for a new #2}% |
| 461 |
\fi |
| 462 |
\fi |
| 463 |
} |
| 464 |
|
| 465 |
% The \expandafter construction used here allows the generation of |
| 466 |
% \newcount and \globcount from #1=count. Moreover (and more important) |
| 467 |
% this construction avoids the appearance of \outer macros inside |
| 468 |
% macro definitions or conditionals. |
| 469 |
|
| 470 |
\def \alloc@@ #1#2% |
| 471 |
{\endgroup % restore \escapechar |
| 472 |
\message {Normal \csname#1\endcsname register pool exhausted, |
| 473 |
switching to extended pool.}% |
| 474 |
\global \expandafter |
| 475 |
\let \csname new#1\expandafter \endcsname \csname glob#1\endcsname |
| 476 |
\csname new#1\endcsname#2% |
| 477 |
} |
| 478 |
|
| 479 |
% We do change the Plain TeX definition of \newinsert |
| 480 |
|
| 481 |
\outer \def \newinsert #1%make sure there's still room for ... |
| 482 |
{\ch@ck 0 \et@xins \count % ... a \count, ... |
| 483 |
{\ch@ck 1 \et@xins \dimen % ... \dimen, ... |
| 484 |
{\ch@ck 2 \et@xins \skip % ... \skip, ... |
| 485 |
{\ch@ck 4 \et@xins \box % ... and \box register |
| 486 |
{\global \advance \et@xins by \m@ne |
| 487 |
\unless |
| 488 |
\ifnum \insc@unt < \et@xins |
| 489 |
\global \insc@unt=\et@xins |
| 490 |
\fi |
| 491 |
\allocationnumber=\et@xins |
| 492 |
\global \chardef #1=\allocationnumber |
| 493 |
\wlog {\string #1=\string \insert \the \allocationnumber}% |
| 494 |
}% |
| 495 |
}% |
| 496 |
}% |
| 497 |
}% |
| 498 |
} |
| 499 |
|
| 500 |
\def \ch@ck #1#2#3#4% |
| 501 |
{\ifnum \count 1#1 < #2#4\else \errmessage {No room for a new #3}\fi} |
| 502 |
|
| 503 |
% And we define \reserveinserts, so that you can say \reserveinserts{17} |
| 504 |
% in order to reserve room for up to 17 additional insertion classes that will |
| 505 |
% not be taken away by \newcount, \newdimen, \newskip, or \newbox. |
| 506 |
|
| 507 |
\outer \def \reserveinserts#1% |
| 508 |
{\global \insc@unt=\numexpr \et@xins \ifnum #1 > \z@ -#1\fi \relax} |
| 509 |
|
| 510 |
\message {extended register allocation;} |
| 511 |
|
| 512 |
% Now, we define \globcount, \globbox, etc., so that you can say |
| 513 |
% \globcount\foo and \foo will be defined (with \countdef) to be the |
| 514 |
% next count register from the vastly larger but somewhat less efficient |
| 515 |
% extended register pool. We also define \loccount, etc., but these |
| 516 |
% register definitions are local to the current group. |
| 517 |
|
| 518 |
\count 260=277 % globally allocates \count registers 277, 278, ... |
| 519 |
\count 261=\@cclvi % globally allocates \dimen registers 256, 257, ... |
| 520 |
\count 262=\@cclvi % globally allocates \skip registers 256, 257, ... |
| 521 |
\count 263=\@cclvi % globally allocates \muskip registers 256, 257, ... |
| 522 |
\count 264=\@cclvi % globally allocates \box registers 256, 257, ... |
| 523 |
\count 265=\@cclvi % globally allocates \toks registers 256, 257, ... |
| 524 |
\count 266=\@ne % globally allocates \marks classes 1, 2, ... |
| 525 |
|
| 526 |
\def \et@xmaxregs {32768} |
| 527 |
|
| 528 |
\count 270=\et@xmaxregs % locally allocates \count registers 32767, 32766, ... |
| 529 |
\count 271=\et@xmaxregs % ditto for \dimen registers |
| 530 |
\count 272=\et@xmaxregs % ditto for \skip registers |
| 531 |
\count 273=\et@xmaxregs % ditto for \muskip registers |
| 532 |
\count 274=\et@xmaxregs % ditto for \box registers |
| 533 |
\count 275=\et@xmaxregs % ditto for \toks registers |
| 534 |
\count 276=\et@xmaxregs % ditto for \marks classes |
| 535 |
|
| 536 |
% \count registers 256-259 and 267-269 are not (yet) used |
| 537 |
|
| 538 |
\outer \def \globcount {\et@xglob 0 \count \countdef} |
| 539 |
\def \loccount {\et@xloc 0 \count \countdef} |
| 540 |
\outer \def \globdimen {\et@xglob 1 \dimen \dimendef} |
| 541 |
\def \locdimen {\et@xloc 1 \dimen \dimendef} |
| 542 |
\outer \def \globskip {\et@xglob 2 \skip \skipdef} |
| 543 |
\def \locskip {\et@xloc 2 \skip \skipdef} |
| 544 |
\outer \def \globmuskip {\et@xglob 3 \muskip \muskipdef} |
| 545 |
\def \locmuskip {\et@xloc 3 \muskip \muskipdef} |
| 546 |
\outer \def \globbox {\et@xglob 4 \box \mathchardef} |
| 547 |
\def \locbox {\et@xloc 4 \box \mathchardef} |
| 548 |
\outer \def \globtoks {\et@xglob 5 \toks \toksdef} |
| 549 |
\def \loctoks {\et@xloc 5 \toks \toksdef} |
| 550 |
\outer \def \globmarks {\et@xglob 6 \marks \mathchardef} |
| 551 |
\def \locmarks {\et@xloc 6 \marks \mathchardef} |
| 552 |
|
| 553 |
\let\newmark=\globmarks %%% 2.0;14 |
| 554 |
\let\newmarks=\globmarks |
| 555 |
|
| 556 |
\def \et@xglob #1#2#3#4% |
| 557 |
{\et@xchk #1#2% make sure there's still room |
| 558 |
{\allocationnumber=\count 26#1 |
| 559 |
\global \advance \count 26#1 by \@ne |
| 560 |
\global #3#4=\allocationnumber |
| 561 |
\wlog {\string #4=\string #2\the \allocationnumber}% |
| 562 |
}% |
| 563 |
} |
| 564 |
|
| 565 |
\def \et@xloc#1#2#3#4% |
| 566 |
{\et@xchk #1#2% make sure there's still room |
| 567 |
{\advance \count 27#1 by \m@ne |
| 568 |
\allocationnumber=\count 27#1 |
| 569 |
#3#4=\allocationnumber |
| 570 |
\wlog {\string #4=\string #2\the \allocationnumber \space (local)}% |
| 571 |
}% |
| 572 |
} |
| 573 |
|
| 574 |
\def \et@xchk #1#2#3% |
| 575 |
{\ifnum \count 26#1 < \count 27#1 |
| 576 |
#3% |
| 577 |
\else |
| 578 |
\errmessage {No room for a new #2}% |
| 579 |
\fi |
| 580 |
} |
| 581 |
|
| 582 |
% Next we define \globcountblk, \loccountblk, etc., so that one can |
| 583 |
% write \globcountblk\foo{17} and \foo will be defined (with \mathchardef) |
| 584 |
% as the first (the zeroth?) of a block of 17 consecutive registers. |
| 585 |
% Thus the user is intended to reference elements <\foo+0> to <\foo+n-1>, |
| 586 |
% where n is the length of the block allocated. |
| 587 |
|
| 588 |
\outer \def \globcountblk {\et@xgblk 0 \count} |
| 589 |
\def \loccountblk {\et@xlblk 0 \count} |
| 590 |
\outer \def \globdimenblk {\et@xgblk 1 \dimen} |
| 591 |
\def \locdimenblk {\et@xlblk 1 \dimen} |
| 592 |
\outer \def \globskipblk {\et@xgblk 2 \skip} |
| 593 |
\def \locskipblk {\et@xlblk 2 \skip} |
| 594 |
\outer \def \globmuskipblk {\et@xgblk 3 \muskip} |
| 595 |
\def \locmuskipblk {\et@xlblk 3 \muskip} |
| 596 |
\outer \def \globboxblk {\et@xgblk 4 \box} |
| 597 |
\def \locboxblk {\et@xlblk 4 \box} |
| 598 |
\outer \def \globtoksblk {\et@xgblk 5 \toks} |
| 599 |
\def \loctoksblk {\et@xlblk 5 \toks} |
| 600 |
\outer \def \globmarksblk {\et@xgblk 6 \marks} |
| 601 |
\def \locmarksblk {\et@xlblk 6 \marks} |
| 602 |
|
| 603 |
% And, both to provide a higher-level interface to the block allocation |
| 604 |
% scheme, and to demonstrate possible applications of the new \...expr |
| 605 |
% primitives, we also define \globcountvector and \loccountvector (etc) |
| 606 |
% which allow the user to access elements with embedded arithmetic, as in |
| 607 |
|
| 608 |
% \globcountvector \foo {12} |
| 609 |
% \foo {\count 0 + 3} = \foo {\count 1 * 2} |
| 610 |
|
| 611 |
\outer \def \globcountvector {\et@xgvec 0 \count} |
| 612 |
\def \loccountvector {\et@xlvec 0 \count} |
| 613 |
\outer \def \globdimenvector {\et@xgvec 1 \dimen} |
| 614 |
\def \locdimenvector {\et@xlvec 1 \dimen} |
| 615 |
\outer \def \globskipvector {\et@xgvec 2 \skip} |
| 616 |
\def \locskipvector {\et@xlvec 2 \skip} |
| 617 |
\outer \def \globmuskipvector {\et@xgvec 3 \muskip} |
| 618 |
\def \locmuskipvector {\et@xlvec 3 \muskip} |
| 619 |
\outer \def \globboxvector {\et@xgvec 4 \box} |
| 620 |
\def \locboxvector {\et@xlvec 4 \box} |
| 621 |
\outer \def \globtoksvector {\et@xgvec 5 \toks} |
| 622 |
\def \loctoksvector {\et@xlvec 5 \toks} |
| 623 |
\outer \def \globmarksvector {\et@xgvec 6 \marks} |
| 624 |
\def \locmarksvector {\et@xlvec 6 \marks} |
| 625 |
|
| 626 |
\def \et@xgblk #1#2#3#4% |
| 627 |
{\et@xchkblk #1#2{#4}% make sure there's still room |
| 628 |
{\allocationnumber=\count 26#1 |
| 629 |
\global \advance \count 26#1 by #4% |
| 630 |
\global \mathchardef #3=\allocationnumber |
| 631 |
\wlog {\string #3=\string #2blk{\number #4} at \the \allocationnumber}% |
| 632 |
}% |
| 633 |
} |
| 634 |
|
| 635 |
\def \et@xlblk #1#2#3#4% |
| 636 |
{\et@xchkblk #1#2{#4}% make sure there's still room |
| 637 |
{\advance \count 27#1 by -#4% |
| 638 |
\allocationnumber=\count 27#1 |
| 639 |
\mathchardef #3=\allocationnumber |
| 640 |
\wlog {\string #3=\string #2blk{\number #4} |
| 641 |
at \the \allocationnumber \space (local)% |
| 642 |
}% |
| 643 |
}% |
| 644 |
} |
| 645 |
|
| 646 |
\begingroup |
| 647 |
\catcode `\# = 12 |
| 648 |
\gdef \et@xhash {#} |
| 649 |
\endgroup |
| 650 |
|
| 651 |
\def \et@xgvec #1#2#3#4% |
| 652 |
{\et@xchkblk #1#2{#4}% make sure there's still room |
| 653 |
{\allocationnumber=\count 26#1 |
| 654 |
\global \advance \count 26#1 by #4% |
| 655 |
\ifx #2\box |
| 656 |
\def \2{}% |
| 657 |
\else \ifx #2\marks |
| 658 |
\def \2{}% |
| 659 |
\else |
| 660 |
\def \2{\string #2}% |
| 661 |
\fi |
| 662 |
\fi |
| 663 |
\xdef #3##1{\2 \noexpand \numexpr \the \allocationnumber+##1\relax}% |
| 664 |
\wlog {\string #3 {\et@xhash 1} = |
| 665 |
\2 {\the \allocationnumber+\et@xhash 1} (global #2 vector)% |
| 666 |
}% |
| 667 |
}% |
| 668 |
} |
| 669 |
|
| 670 |
\def \et@xlvec #1#2#3#4% |
| 671 |
{\et@xchkblk #1#2{#4}% make sure there's still room |
| 672 |
{\advance \count 27#1 by -#4% |
| 673 |
\allocationnumber=\count27#1 |
| 674 |
\mathchardef #3=\allocationnumber |
| 675 |
\ifx #2\box |
| 676 |
\def \2{}% |
| 677 |
\else \ifx #2\marks |
| 678 |
\def \2{}% |
| 679 |
\else |
| 680 |
\def \2{\string #2}% |
| 681 |
\fi |
| 682 |
\fi |
| 683 |
\edef #3##1{\2 \noexpand \numexpr \the \allocationnumber+##1\relax}% |
| 684 |
\wlog {\string #3 {\et@xhash 1} = |
| 685 |
\2 {\the \allocationnumber+\et@xhash 1} (local #2 vector)% |
| 686 |
}% |
| 687 |
}% |
| 688 |
} |
| 689 |
|
| 690 |
\def \et@xchkblk #1#2#3#4% |
| 691 |
{\ifnum #3 < \z@ |
| 692 |
\errmessage {Negative register block size \number #3}% |
| 693 |
\else \ifnum \numexpr \count 26#1+#3 > \count 27#1 |
| 694 |
\errmessage {No room for new #2block of size \number#3}% |
| 695 |
\else |
| 696 |
#4% |
| 697 |
\fi |
| 698 |
\fi |
| 699 |
} |
| 700 |
|
| 701 |
% In an attempt to reduce the overheads of e-TeX, we recycle all possible |
| 702 |
% resources, including (as a penultimate step) the recycler itself... |
| 703 |
% The user can circumvent (or force) this during format creation, |
| 704 |
% by \letting \ifrecycle=\iffalse (or \iftrue, to force it). |
| 705 |
|
| 706 |
% As this file has grown by accretion, it is possible that we are no |
| 707 |
% longer recycling all the resources we could; this will be investigated. |
| 708 |
|
| 709 |
\def \mayber@cycle {\expandafter \ifrecycle} |
| 710 |
\def \forcer@cycle {\expandafter \iftrue} |
| 711 |
|
| 712 |
\ifdefined \ifrecycle |
| 713 |
\mayber@cycle |
| 714 |
\else |
| 715 |
\forcer@cycle |
| 716 |
\fi |
| 717 |
|
| 718 |
% There's a concealed \if... lurking here, which explains the |
| 719 |
% strange indentation of the code that follows (V1.0-1) |
| 720 |
|
| 721 |
\def \r@cycle #1% |
| 722 |
{\ifdefined #1 |
| 723 |
\message {\string #1,}\let #1=\und@fined |
| 724 |
\else |
| 725 |
\message {\string #1 (not defined),} |
| 726 |
\fi |
| 727 |
} |
| 728 |
{\newlinechar=`\! \message {!Recycling:}} |
| 729 |
|
| 730 |
\r@cycle \addlanguage |
| 731 |
\r@cycle \@nswer |
| 732 |
\r@cycle \@sk |
| 733 |
\r@cycle \b@dresponsetrue |
| 734 |
\r@cycle \b@dresponsefalse |
| 735 |
\r@cycle \ch@ckforyn |
| 736 |
\r@cycle \mayber@cycle |
| 737 |
\r@cycle \et@xabort |
| 738 |
\r@cycle \et@xbuf |
| 739 |
\r@cycle \et@xfmtsrc |
| 740 |
\r@cycle \et@xfilehdr |
| 741 |
\r@cycle \et@xinf |
| 742 |
\r@cycle \et@xpatterns |
| 743 |
% \r@cycle \ifb@dresponse |
| 744 |
% \r@cycle \ifusef@llback |
| 745 |
\r@cycle \l@ngdefnfile |
| 746 |
\r@cycle \n@xt |
| 747 |
\r@cycle \p@rse |
| 748 |
\r@cycle \pr@mpt |
| 749 |
\r@cycle \pr@mptloop |
| 750 |
\r@cycle \forcer@cycle |
| 751 |
\r@cycle \usef@llback |
| 752 |
\r@cycle \usef@llbacktrue |
| 753 |
\r@cycle \usef@llbackfalse |
| 754 |
|
| 755 |
% The following are retained, since they may be needed by user code; with a few |
| 756 |
% (regrettable) exceptions, all of these are given the \etex or \et@x prefix, |
| 757 |
% to reduce as far as possible the risk of them clashing with other used-defined |
| 758 |
% names. |
| 759 |
|
| 760 |
% The e-TeX team are willing to change the names of the remaining, at-risk, |
| 761 |
% control sequences if it is demonstrated that the current names cause problems |
| 762 |
% or difficulties. |
| 763 |
|
| 764 |
\def \r@tain #1% |
| 765 |
{\ifdefined #1 |
| 766 |
\message {\string #1,} |
| 767 |
\else |
| 768 |
\message {\string #1 (not defined),} |
| 769 |
\fi |
| 770 |
} |
| 771 |
{\newlinechar=`\! \message {!Retaining:}} |
| 772 |
|
| 773 |
\r@tain \et@xerr |
| 774 |
\r@tain \et@xinput |
| 775 |
\r@tain \et@xlibhdr |
| 776 |
\r@tain \et@xmsg |
| 777 |
\r@tain \et@xtoks |
| 778 |
\r@tain \et@xwarn |
| 779 |
\r@tain \et@xl@@d |
| 780 |
\r@tain \et@xl@ad |
| 781 |
\r@tain \et@xload |
| 782 |
\r@tain \et@xlang |
| 783 |
\r@tain \et@xhash |
| 784 |
\r@tain \eTeX |
| 785 |
\r@tain \etexhdrchk |
| 786 |
% \r@tain \endmodule |
| 787 |
\r@tain \etexstatus |
| 788 |
\r@tain \module |
| 789 |
\r@tain \uselanguage |
| 790 |
|
| 791 |
\r@cycle \r@tain |
| 792 |
\r@cycle \r@cycle |
| 793 |
|
| 794 |
\fi |
| 795 |
|
| 796 |
% And finally re-catcode commercial-at |
| 797 |
|
| 798 |
\catcode `\@=12 |
| 799 |
\endinput |
| 800 |
|
| 801 |
%% Revision-history: |
| 802 |
|
| 803 |
16-MAY-2013: 2.1;0-luatex2 Minor changes for LuaTeX, adapting to new |
| 804 |
luatex-hyphen package. |
| 805 |
|
| 806 |
03-MAY-2010: 2.1;0-luatex With LuaTeX, don't embed hyphenation patterns and |
| 807 |
exceptions in the format, but on-demand at runtime, for faster |
| 808 |
format loading. Use the Lua interface for loading hyphenation |
| 809 |
rules from plain text files according to the new configuration |
| 810 |
file language.lua.dat. Make use of a supporting lua file, |
| 811 |
luatex-hyphen.lua. See also luatex-hyphen.pdf. |
| 812 |
(Manuel Pegourie-Gonnard, Elie Roux and Khaled Hosny) |
| 813 |
|
| 814 |
01-FEB-1999: 2.1;0 Allow file to be used with e-TeX versions 2.0 and 2.1 |
| 815 |
|
| 816 |
25-MAR-1998: 2.0;19 Improved log message for \{glob|loc}{marks|box}vector (PEB) |
| 817 |
|
| 818 |
24-MAR-1998: 2.0;18 Optimisation of one section made (DC & PEB), |
| 819 |
a couple of \if tests made more robust, |
| 820 |
and spacing improved in one macro. |
| 821 |
|
| 822 |
24-MAR-1998: 2.0;17 Coding styles unified and all references to Peter |
| 823 |
Breitenlohner eliminated from main code |
| 824 |
|
| 825 |
23-MAR-1998: 2.0;16 Continued from 2.0;15 |
| 826 |
|
| 827 |
20-MAR-1998: 2.0;15 Changes made here and in "etexdefs.lib" to |
| 828 |
improve compatibility with LaTeX, and |
| 829 |
\{glob,loc}{marks,box}vector re-thought. |
| 830 |
|
| 831 |
11-MAR-1998: 2.0;14 \newmark made synonym for \newmarks / PT |
| 832 |
|
| 833 |
10-MAR-1998: 2.0;13 Missing brace re-inserted in \...lvec /PT |
| 834 |
|
| 835 |
10-MAR-1998: 2.0;12 Typo corrected in Peter's name /PT |
| 836 |
|
| 837 |
10-MAR-1998: 2.0;11 "\...lvec" failed to use \et@xhash; fixed / PT |
| 838 |
|
| 839 |
10-MAR-1998: 2.0;10 \h@sh -> \et@xhash /PT |
| 840 |
|
| 841 |
06-MAR-1998: 2.0;9 Final tweaks by PEB ! |
| 842 |
|
| 843 |
05-MAR-1998: <missing version number> Final tweaks by PT |
| 844 |
|
| 845 |
28-Feb-1998: 2.0;8 Major re-work by PEB |
| 846 |
|
| 847 |
24-Feb-1998: 2.0;7 \tracingnesting -> \tw@ |
| 848 |
|
| 849 |
24-FEB-1998: 2.0;6 version-mismatch reduced in severity; |
| 850 |
\tracingall and ...none improved; |
| 851 |
aesthetic spaces around "=" removed |
| 852 |
|
| 853 |
24-Jan-1998: 2.0;5: block allocation of registers added |
| 854 |
|
| 855 |
21-Jan-1998: 2.0;4: released to e-TeX team for testing/comments |
| 856 |
|
| 857 |
20-Jan-1998: \glob... implemented, and coding simplified by |
| 858 |
the implementation and use of of \max@xpr |
| 859 |
|
| 860 |
06-Jan-1998: Alpha-testing complete of extended and local register allocation. |
| 861 |
|
| 862 |
29-Dec-1997: The "%!" convention replaced by a corresponding "%%": |
| 863 |
this should avoid any inadvertent conflict with Adobe conventions. |
| 864 |
|
| 865 |
\tracingall augmented with |
| 866 |
\tracinglostchars=\tw@ %%% Q -- should this be default? |
| 867 |
\tracingnesting=\@ne |
| 868 |
|
| 869 |
\tracingnone augmented. |
| 870 |
|
| 871 |
05-DEC-1997: A long-standing bug removed: left- and right- hyphenmin |
| 872 |
were transposed in fallback mode :-((((( |
| 873 |
|
| 874 |
24-APR-1997: An interim release, to provide compatibility with Peter's |
| 875 |
naming conventions for beta-test versions of e-TeX V2. |
| 876 |
Consistency checking is now restricted to \eTeXversion, |
| 877 |
and \eTeXrevision is ignored. |
| 878 |
|
| 879 |
01-NOV-1996: V1.1;5: Final stage? Checking that everything possible |
| 880 |
is recycled whilst nothing that is needed is lost. Retained |
| 881 |
names given \etex or \et@x prefix wherever possible. Some |
| 882 |
potentially dangerous cs-names commented out of the recycle/retain |
| 883 |
lists because they were synonyms of members of the if-else-fi set. |
| 884 |
The definition of the e-TeX logo added: this had somehow slipped |
| 885 |
through the net! Intended to be the final revision before public |
| 886 |
release, but awaiting comments from other members of the team. |
| 887 |
|
| 888 |
31-OCT-1996: V1.1;4: errors noticed while proof-reading corrected; far |
| 889 |
greater use made of concealed control sequences with |
| 890 |
commercial-at (@); library file headers differentiated |
| 891 |
from ordinary file headers; return-values for header-check |
| 892 |
altered to allow fall-thru' if ok; fallback-use algorithm |
| 893 |
significantly modified (major semantic shift). |
| 894 |
|
| 895 |
29-OCT-1996: V1.1;3: tidying up prior to release; careful check on |
| 896 |
which control words can be re-cycled; \recycle made more |
| 897 |
robust, to check whether one is trying to re-cycle something |
| 898 |
that was never 'cycled' in the first place (PEB suggestion); |
| 899 |
\et@xmsg re-written to use \message or \errmessage as necessary; |
| 900 |
\errhelps provided for all places they might be referenced. |
| 901 |
|
| 902 |
27-OCT-1996: V1.1;2: minor version numbers re-introduced, using semi-colon |
| 903 |
as delimiter and stopping pattern matching at the semi-colon; |
| 904 |
\et@xfilehdr defined dynamically, based in \eTeXversion and |
| 905 |
\eTeXrevision; \load now uses \etexhdrchk, so library |
| 906 |
files are required to start with an e-TeX header; this will |
| 907 |
have implications when e-TeX -> V2+, so this code should be |
| 908 |
re-considered at this point. |
| 909 |
|
| 910 |
17-OCT-1996: V1.1: minor version numbers eliminated, to reduce the |
| 911 |
need for users to update their "language.def" files. |
| 912 |
|
| 913 |
17-OCT-1996: V1.0-4: \addlanguage@hook added, version history moved to end. |
| 914 |
|
| 915 |
17-OCT-1996: Version 1.0-3 does away with the "fallback" file. |
| 916 |
|
| 917 |
16-OCT-1996: Version 1.0-2 implements module handling, so constant "3" |
| 918 |
no longer used (see below). |
| 919 |
|
| 920 |
13-Oct-1996: Replaced \def by \chardef where possible; |
| 921 |
eliminated dependency on "etexdefs.def", hard-coding |
| 922 |
in the constant "3" (with comment) instead; |
| 923 |
used Bernd's \ch@ckforyn; |
| 924 |
re-catcoded `\@ earlier, to reduce number of \[if]csnames; |
| 925 |
commented the strange indentation of the \recycles at end. |
| 926 |
|
| 927 |
11-Oct-1996: language handling commands modified (V1.0): PT/BR |