| 1 |
%D \module |
| 2 |
%D [ file=syst-tex, |
| 3 |
%D version=1999.03.17, % an oldie: 1995.10.10 |
| 4 |
%D title=\CONTEXT\ System Macros, |
| 5 |
%D subtitle=Efficient \PLAIN\ \TEX\ loading, |
| 6 |
%D author=Hans Hagen, |
| 7 |
%D date=\currentdate, |
| 8 |
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] |
| 9 |
%C |
| 10 |
%C This module is part of the \CONTEXT\ macro||package and is |
| 11 |
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for |
| 12 |
%C details. |
| 13 |
|
| 14 |
%D This file is used by mptopdf. |
| 15 |
|
| 16 |
%D We've build \CONTEXT\ on top of \PLAIN\ \TEX. Because we |
| 17 |
%D want to make the format file as independant as possible of |
| 18 |
%D machine dependant font encodings, we have to bypass the |
| 19 |
%D loading of fonts. |
| 20 |
%D |
| 21 |
%D Let's start at the beginning. Because \PLAIN\ is not yet |
| 22 |
%D loaded we have to define some \CATCODES\ ourselves. |
| 23 |
|
| 24 |
\catcode`\{=1 % left brace is begin-group character |
| 25 |
\catcode`\}=2 % right brace is end-group character |
| 26 |
\catcode`\#=6 % hash mark is macro parameter character |
| 27 |
\catcode`\^=7 % circumflex is for superscripts |
| 28 |
|
| 29 |
%D To prevent all kind of end||of||file problems, for the |
| 30 |
%D moment we simply ignore the Control~Z token. |
| 31 |
|
| 32 |
\catcode`\^^Z=9 |
| 33 |
|
| 34 |
%D We are going to report to the user what we are skipping. |
| 35 |
|
| 36 |
\def\skipmessage#1{\immediate\write16{skipping #1 in plain}} |
| 37 |
|
| 38 |
%D We want to be able to use the \type{\newsomething} |
| 39 |
%D declarations not only on the \type{\outer} level. This can |
| 40 |
%D be done by redefining \type{\outer} so we have to save its |
| 41 |
%D original meaning. |
| 42 |
|
| 43 |
\let\normalouter = \outer |
| 44 |
\let\outer = \relax |
| 45 |
|
| 46 |
%D We also want to postpone the loading of hyphenation patters, |
| 47 |
%D so we redefine and therefore save \type{\input}. |
| 48 |
|
| 49 |
\let\normalinput = \input |
| 50 |
\def\input #1 {\skipmessage{\string\input}} |
| 51 |
|
| 52 |
%D Finaly are going to we redefine some font specification |
| 53 |
%D commands and that's why we save them too. The redefinitions |
| 54 |
%D are straightforward because the macros have to do nothing |
| 55 |
%D but skipping. |
| 56 |
|
| 57 |
\let\normalskewchar = \skewchar |
| 58 |
\def\skewchar #1=#2 {\skipmessage{\string\skewchar}} |
| 59 |
|
| 60 |
\let\normaltextfont = \textfont |
| 61 |
\let\normalscriptfont = \scriptfont |
| 62 |
\let\normalscriptscriptfont = \scriptscriptfont |
| 63 |
|
| 64 |
\def\textfont #1=#2{\skipmessage{\string\textfont}} |
| 65 |
\def\scriptfont #1=#2{\skipmessage{\string\scriptfont}} |
| 66 |
\def\scriptscriptfont #1=#2{\skipmessage{\string\scriptscriptfont}} |
| 67 |
|
| 68 |
%D The redefinition of \type{\font} is a bit more complicated, |
| 69 |
%D because in version 3.14159 a scaled specification was |
| 70 |
%D introduced. |
| 71 |
|
| 72 |
\let\normalfont = \font |
| 73 |
|
| 74 |
\def\skipscaled scaled #1 {} |
| 75 |
|
| 76 |
\long\def\font#1=#2 #3% |
| 77 |
{\ifx#3s% |
| 78 |
\skipmessage{scaled \string\font}% |
| 79 |
\let\next\skipscaled |
| 80 |
\else |
| 81 |
\skipmessage{\string\font}% |
| 82 |
\let\next\relax |
| 83 |
\fi |
| 84 |
\next#3} |
| 85 |
|
| 86 |
% or: |
| 87 |
% |
| 88 |
% \long\def\font#1=#2 #3% |
| 89 |
% {\ifx#3s% |
| 90 |
% \skipmessage{scaled \string\font}% |
| 91 |
% \expandafter\skipscaled |
| 92 |
% \else |
| 93 |
% \skipmessage{\string\font}% |
| 94 |
% \fi |
| 95 |
% #3} |
| 96 |
|
| 97 |
%D Relaxing some font switching macros is needed because we |
| 98 |
%D don't want any error messages during loading. These |
| 99 |
%D unharmfull messages could be ingored. |
| 100 |
%D |
| 101 |
%D The next substitution is needed for determining |
| 102 |
%D \type{\p@renwd} in the macro \type{\bordermatrix}. |
| 103 |
|
| 104 |
\def\tenex#1% |
| 105 |
{\skipmessage{used \string\tenex}\hskip8.75002pt} |
| 106 |
|
| 107 |
%D We need to define \type{\tenrm} for switching to |
| 108 |
%D \type{\rm}. |
| 109 |
|
| 110 |
\def\tenrm% |
| 111 |
{\skipmessage{\string\tenrm}} |
| 112 |
|
| 113 |
%D In \CONTEXT\ all \PLAIN\ \TEX\ fonts are available, just |
| 114 |
%D like \type{\p@renwd}. We only postpone loading them until |
| 115 |
%D they are actually needed. |
| 116 |
|
| 117 |
%D By bypassing fonts, some definitions become less valid so |
| 118 |
%D we have to redefine them afterwards. |
| 119 |
%D |
| 120 |
%D \starttyping |
| 121 |
%D \let\normalbordermatrix=\bordermatrix |
| 122 |
%D |
| 123 |
%D \def\bordermatrix% |
| 124 |
%D {\bgroup |
| 125 |
%D \setbox0=\hbox{\getvalue{\textface\c!mm\c!ex}B}% |
| 126 |
%D \global\p@renwd=\wd0\relax |
| 127 |
%D \egroup |
| 128 |
%D \normalbordermatrix} |
| 129 |
%D \stoptyping |
| 130 |
|
| 131 |
%D Now we are ready for loading \PLAIN\ \TEX. Of couse we use |
| 132 |
%D \type{\normalinput} and not \type{\input}. |
| 133 |
|
| 134 |
\normalinput plain.tex \let\normalfmtversion\fmtversion |
| 135 |
|
| 136 |
%D We have to take care of unwanted \PDFTEX\ |
| 137 |
%D initializations. We just want to default to \DVI\ output. |
| 138 |
|
| 139 |
\ifx\pdftexversion\undefined |
| 140 |
\chardef\pdfoutput=0 |
| 141 |
\else |
| 142 |
\pdfoutput=0 |
| 143 |
\fi |
| 144 |
|
| 145 |
%D When applicable, we also load the \ETEX\ source and |
| 146 |
%D definition files. |
| 147 |
|
| 148 |
\bgroup \obeylines |
| 149 |
|
| 150 |
\ifx\eTeXversion\undefined |
| 151 |
|
| 152 |
\long\gdef\beginETEX#1\endETEX% |
| 153 |
{} |
| 154 |
|
| 155 |
\gdef\beginTEX% |
| 156 |
{\bgroup\obeylines\dobeginTEX} |
| 157 |
|
| 158 |
\gdef\dobeginTEX#1 |
| 159 |
{\egroup} |
| 160 |
|
| 161 |
\global\let\endTEX\relax |
| 162 |
|
| 163 |
\else |
| 164 |
|
| 165 |
\long\gdef\beginTEX#1\endTEX% |
| 166 |
{} |
| 167 |
|
| 168 |
\gdef\beginETEX% |
| 169 |
{\bgroup\obeylines\dobeginETEX} |
| 170 |
|
| 171 |
% \gdef\dobeginETEX#1 |
| 172 |
% {\egroup\immediate\write16% |
| 173 |
% {system (E-TEX) : [line \the\inputlineno] \detokenize{#1}}} |
| 174 |
|
| 175 |
\gdef\dobeginETEX#1 |
| 176 |
{\egroup} |
| 177 |
|
| 178 |
\global\let\endETEX\relax |
| 179 |
|
| 180 |
\fi |
| 181 |
|
| 182 |
\egroup |
| 183 |
|
| 184 |
% \ifx\eTeXversion\undefined |
| 185 |
% \long\def\onlyTEX #1{#1} |
| 186 |
% \long\def\onlyETEX#1{} |
| 187 |
% \else |
| 188 |
% \long\def\only TEX#1{} |
| 189 |
% \long\def\onlyETEX#1{#1} |
| 190 |
% \fi |
| 191 |
|
| 192 |
%D Well, this redefintion of \type {\input} fails on \ETEX, |
| 193 |
%D because of some \type {\cs\fi} constructs. So now we use: |
| 194 |
|
| 195 |
% \beginETEX etex.src etexdefs.lib |
| 196 |
% |
| 197 |
% \def\input#1% |
| 198 |
% {\bgroup |
| 199 |
% \skipmessage{\string\input}% |
| 200 |
% \expandafter\ifx\expandafter#1\csname l@ngdefnfile\endcsname |
| 201 |
% \let\input\egroup |
| 202 |
% \else |
| 203 |
% \def\input##1 {\egroup}% |
| 204 |
% \fi |
| 205 |
% \input} |
| 206 |
% |
| 207 |
% \normalinput etex.src \relax |
| 208 |
% \normalinput etexdefs.lib \relax |
| 209 |
% |
| 210 |
% \let\fmtversion\normalfmtversion |
| 211 |
% |
| 212 |
% \savinghyphcodes=1 |
| 213 |
% |
| 214 |
% \endETEX |
| 215 |
% |
| 216 |
% \ifx\normalprotected \undefined \let\normalprotected \protected \fi |
| 217 |
% \ifx\normalunexpanded\undefined \let\normalunexpanded\unexpanded \fi |
| 218 |
% \ifx\normalexpanded \undefined \let\normalexpanded \expanded \fi |
| 219 |
|
| 220 |
\beginETEX \savinghyphcodes |
| 221 |
|
| 222 |
\savinghyphcodes=1 |
| 223 |
|
| 224 |
\endETEX |
| 225 |
|
| 226 |
%D We restore some redefined primitives to their old meaning. |
| 227 |
|
| 228 |
\let\font = \normalfont |
| 229 |
\let\skewchar = \normalskewchar |
| 230 |
\let\textfont = \normaltextfont |
| 231 |
\let\scriptfont = \normalscriptfont |
| 232 |
\let\scriptscriptfont = \normalscriptscriptfont |
| 233 |
\let\input = \normalinput |
| 234 |
\let\outer = \normalouter |
| 235 |
|
| 236 |
%D We reset some of the used auxiliary macro's to |
| 237 |
%D \type{\undefined}. One never knows what testing on them is |
| 238 |
%D done elsewhere. |
| 239 |
|
| 240 |
\let\skipmessage = \undefined |
| 241 |
\let\skipscaled = \undefined |
| 242 |
\let\normalfont = \undefined |
| 243 |
\let\normalskewchar = \undefined |
| 244 |
\let\normaltextfont = \undefined |
| 245 |
\let\normalscriptfont = \undefined |
| 246 |
\let\normalscriptscriptfont = \undefined |
| 247 |
|
| 248 |
% \let\normalinput = \undefined |
| 249 |
% \let\normalouter = \undefined |
| 250 |
|
| 251 |
%D We want a bit more statistics and some less logging info |
| 252 |
%D in the \type{log} file. |
| 253 |
|
| 254 |
\def\wlog#1{} |
| 255 |
|
| 256 |
% \let\normalwlog\wlog |
| 257 |
% |
| 258 |
% \def\wlog#1{\normalwlog{system (\string\wlog) : #1}} |
| 259 |
|
| 260 |
%D To prevent clashes, we slightly redefine the phantom |
| 261 |
%D macros: we let them hide their behaviour by grouping. |
| 262 |
|
| 263 |
\catcode`@=11 |
| 264 |
|
| 265 |
%D Somehow this one does not work ok in math mode: |
| 266 |
|
| 267 |
\def\ph@nt% |
| 268 |
{\bgroup |
| 269 |
\ifmmode |
| 270 |
\expandafter\mathpalette\expandafter\mathph@nt |
| 271 |
\else |
| 272 |
\expandafter\makeph@nt |
| 273 |
\fi} |
| 274 |
|
| 275 |
\def\finph@nt% |
| 276 |
{\setbox\tw@\null |
| 277 |
\ifv@ \ht\tw@\ht\z@ \dp\tw@\dp\z@ \fi |
| 278 |
\ifh@ \wd\tw@\wd\z@ \fi |
| 279 |
\box\tw@ |
| 280 |
\egroup} |
| 281 |
|
| 282 |
%D But this one does work. |
| 283 |
|
| 284 |
\def\ph@nt% |
| 285 |
{\ifmmode |
| 286 |
\expandafter\mathpalette\expandafter\mathph@nt |
| 287 |
\else |
| 288 |
\bgroup\expandafter\makeph@nt |
| 289 |
\fi} |
| 290 |
|
| 291 |
\def\finph@nt% |
| 292 |
{\setbox\tw@\null |
| 293 |
\ifv@ \ht\tw@\ht\z@ \dp\tw@\dp\z@ \fi |
| 294 |
\ifh@ \wd\tw@\wd\z@ \fi |
| 295 |
\box\tw@ |
| 296 |
\ifmmode\else\egroup\fi} |
| 297 |
|
| 298 |
\catcode`@=12 |
| 299 |
|
| 300 |
%D Just for tracing purposes wet set: |
| 301 |
|
| 302 |
\tracingstats=1 |
| 303 |
|
| 304 |
%D To circumvent dependencies, we can postpone certain |
| 305 |
%D initializations to dumping time, by appending them to the |
| 306 |
%D \type {\everydump} token register. |
| 307 |
|
| 308 |
\newtoks \everydump |
| 309 |
|
| 310 |
\let\normaldump \dump |
| 311 |
|
| 312 |
\def\dump{\the\everydump\normaldump} |
| 313 |
|
| 314 |
\endinput |