syst-ini.mkiv /size: 44 Kb    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=syst-ini,
3
%D version=2008.11.04, % 2001.11.16, % 1999.03.17, % an oldie: 1995.10.10
4
%D title=\CONTEXT\ System Macros,
5
%D subtitle=Bootstrapping \TEX,
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 We used to load plain \TEX\ in a special way, but redefining a couple of
15
%D primitives so that for instance font loading was ignored. For those interested,
16
%D this loader is found in \type {syst-tex.tex}. Some of the comment's are Don
17
%D Knuths and more of it can be found in the plain \TEX\ format.
18
%D
19
%D Characters can have special states, that can be triggered by setting their
20
%D category coded. Some are preset, others are to be set as soon as possible,
21
%D otherwise we cannot define any useful macros.
22
%D
23
%D First we define a bunch of constants. Normally we would \type {\setconstant}
24
%D but we're prestine and have no macros defined yet. Abstraction also makes it
25
%D possible to avoid the \type {^^} in the input.
26 27
\chardef
\escapecatcode
0
28
\chardef
\begingroupcatcode
1
29
\chardef
\endgroupcatcode
2
30
\chardef
\mathshiftcatcode
3
31
\chardef
\alignmentcatcode
4
32
\chardef
\endoflinecatcode
5
33
\chardef
\parametercatcode
6
34
\chardef
\superscriptcatcode
7
35
\chardef
\subscriptcatcode
8
36
\chardef
\ignorecatcode
9
37
\chardef
\spacecatcode
1
0
38
\chardef
\lettercatcode
1
1
39
\chardef
\othercatcode
1
2
% finally obsolete: \let\other \othercatcode
40
\chardef
\activecatcode
1
3
% finally obsolete: \let\active\activecatcode
41
\chardef
\commentcatcode
1
4
42
\chardef
\invalidcatcode
1
5
43 44
%chardef\zeroasciicode 0
45
\chardef
\tabasciicode
9
46
\chardef
\newlineasciicode
1
0
% don't confuse this one with \endoflineasciicode
47
\chardef
\formfeedasciicode
1
2
48
\chardef
\endoflineasciicode
1
3
% somewhat messy but this can be the active \par
49
\chardef
\endoffileasciicode
2
6
50
\chardef
\spaceasciicode
3
2
51
\chardef
\exclamationmarkasciicode
3
3
% ! used in namespace protection
52
\chardef
\doublequoteasciicode
3
4
% "
53
\chardef
\hashasciicode
3
5
54
\chardef
\dollarasciicode
3
6
55
\chardef
\commentasciicode
3
7
56
\chardef
\ampersandasciicode
3
8
57
\chardef
\singlequoteasciicode
3
9
% '
58
\chardef
\primeasciicode
3
9
% '
59
\chardef
\leftparentasciicode
4
0
60
\chardef
\rightparentasciicode
4
1
61
\chardef
\commaasciicode
4
4
62
\chardef
\hyphenasciicode
4
5
63
\chardef
\periodasciicode
4
6
64
\chardef
\forwardslashasciicode
4
7
% /
65
\chardef
\colonasciicode
5
8
66
\chardef
\lessthanasciicode
6
0
% < used as alternative verbatim {
67
\chardef
\morethanasciicode
6
2
% > used as alternative verbatim }
68
\chardef
\questionmarkasciicode
6
3
% ? used in namespace protection
69
\chardef
\atsignasciicode
6
4
% @ used in namespace protection
70
\chardef
\backslashasciicode
9
2
% `\\
71
\chardef
\circumflexasciicode
9
4
72
\chardef
\underscoreasciicode
9
5
73
\chardef
\leftbraceasciicode
1
2
3
% `\{
74
\chardef
\barasciicode
1
2
4
% `\|
75
\chardef
\rightbraceasciicode
1
2
5
% `\}
76
\chardef
\tildeasciicode
1
2
6
% `\~
77
\chardef
\delasciicode
1
2
7
78 79
%catcode\zeroasciicode \ignorecatcode % `\^^@ ascii null is ignored
80
\catcode
\tabasciicode
\spacecatcode
% `\^^I ascii tab is a blank space
81
\catcode
\formfeedasciicode
\activecatcode
% `\^^L ascii form-feed (active, set later)
82
%catcode\endoflineasciicode \endoflinecatcode % `\^^M ascii return is end-line
83
\catcode
\endoffileasciicode
\ignorecatcode
% `\^^Z endoffile (ignored in ConTeXt)
84
%catcode\spaceasciicode \spacecatcode % `\ ascii space is blank space
85
\catcode
\hashasciicode
\parametercatcode
% `\# hash mark is macro parameter character
86
\catcode
\dollarasciicode
\mathshiftcatcode
% `\$ dollar sign is math shift
87
%catcode\commentasciicode \commentcatcode % `\% percent sign is comment character
88
\catcode
\ampersandasciicode
\alignmentcatcode
% `\& ampersand is alignment tab
89
%catcode\backslashasciicode \escapecatcode % `\\ backslash is TeX escape character
90
\catcode
\circumflexasciicode
\superscriptcatcode
% `\^ circumflex and uparrow are for superscripts
91
\catcode
\underscoreasciicode
\subscriptcatcode
% `\_ underline and downarrow are for subscripts
92
\catcode
\leftbraceasciicode
\begingroupcatcode
% `\{ left brace is begin-group character
93
\catcode
\rightbraceasciicode
\endgroupcatcode
% `\} right brace is end-group character
94
\catcode
\tildeasciicode
\activecatcode
% `\~ tilde is active
95
%catcode\delasciicode \invalidcatcode % `\^^? ascii delete is invalid
96 97
\chardef
\statuswrite
1
2
8
98 99
%D Initialization of primitives.
100 101
\directlua {
102
local
primitives
=
tex
.
extraprimitives
(
"
core
"
,
"
tex
"
,
"
etex
"
,
"
luatex
"
)
103 104
% table.sort(primitives)
105 106
tex
.
enableprimitives
(
"
"
,
primitives
)
107
tex
.
enableprimitives
(
"
normal
"
,
primitives
)
108 109
function
tex
.
enableprimitives
(
)
end
110
}
111 112
\def
\space
{
}
113
\def
\empty
{}
114 115
\letcharcode
\formfeedasciicode
\par
% \def ^^L{\par} formfeed
116
\letcharcode
\tildeasciicode
\
% tilde
117
\letcharcode
\spaceasciicode
\space
% space
118 119
\expandafter\def\csname\Uchar
\tabasciicode
\endcsname
{
\
}
% \def\^^I{\ } tab
120
\expandafter\def\csname\Uchar
\formfeedasciicode
\endcsname
{
\par
}
% \def\^^L{\par} formfeed
121
\expandafter\def\csname\Uchar
\endoflineasciicode
\endcsname
{
\
}
% \def\^^M{\ } return
122 123
%D For now:
124 125
\def
\gobbleoneargument
#
1
{}
% will be defined later on anyway
126 127
%D First we define a simplified version of the \CONTEXT\ protection mechanism.
128
%D Later we will implement a better variant.
129 130
\def
\unprotect
131
{
\edef
\protect
132
{
\catcode
\atsignasciicode
\the\catcode
\atsignasciicode
\relax
133
\catcode
\exclamationmarkasciicode
\the\catcode
\exclamationmarkasciicode
\relax
134
\catcode
\questionmarkasciicode
\the\catcode
\questionmarkasciicode
\relax
135
\catcode
\underscoreasciicode
\the\catcode
\underscoreasciicode
\relax
136
\let
\protect
\relax
}
%
137
\catcode
\atsignasciicode
\lettercatcode
138
\catcode
\exclamationmarkasciicode\lettercatcode
139
\catcode
\questionmarkasciicode
\lettercatcode
140
\catcode
\underscoreasciicode
\lettercatcode
}
141 142
\let
\protect
\relax
143 144
\unprotect
145 146
%D Some pretty important definitions:
147 148
\let
\bgroup
=
{
149
\let
\egroup
=
}
150 151
%D \macros
152
%D {normalbgroup,normalgroup}
153
%D
154
%D No comment.
155 156
%D Allocation of registers is done slightly different than in plain \TEX. First of
157
%D all we use different reserved counters. We also don't implement a family handler
158
%D because users are not supposed to implement their own math. We reserve the lowest
159
%D 31 registers for scratch purposes. Keep in mind that in the core engine some
160
%D registers are reserved: counters 0 upto 9, and counter 255.
161
%D
162
%D As with plain \TEX\ we recommend that macro designers always use \type {\global}
163
%D assignments with respect to registers numbered 1, 3, 5 \unknown\ 31, and always
164
%D non||\type {\global} assignments with respect to registers 0, 2, 4, \unknown\ 30.
165
%D This will prevent \quote {save stack buildup} that might otherwise occur.
166
%D
167
%D We reserve some registers for special (management) purposes:
168 169
% 0 - 20 : scratch
170
% 21 - 127 : internal
171
% 128 - 254 : inserts
172
% 255 : page
173
% 256 - : user
174 175
\countdef
\c_syst_min_allocated_register
=
5
2
\c_syst_min_allocated_register
=
2
5
6
% can change
176
\countdef
\c_syst_max_allocated_register
=
5
3
\c_syst_max_allocated_register
=
3
2
7
6
7
177
\countdef
\c_syst_min_allocated_read
=
5
4
\c_syst_min_allocated_read
=
-
1
178
\countdef
\c_syst_max_allocated_read
=
5
5
\c_syst_max_allocated_read
=
1
6
179
\countdef
\c_syst_min_allocated_language
=
5
6
\c_syst_min_allocated_language
=
0
180
\countdef
\c_syst_max_allocated_language
=
5
7
\c_syst_max_allocated_language
=
2
5
5
181
\countdef
\c_syst_min_allocated_insert
=
5
8
\c_syst_min_allocated_insert
=
1
2
8
182
\countdef
\c_syst_max_allocated_insert
=
5
9
\c_syst_max_allocated_insert
=
2
5
4
183
\countdef
\c_syst_min_allocated_family
=
6
0
\c_syst_min_allocated_family
=
1
2
8
184
\countdef
\c_syst_max_allocated_family
=
6
1
\c_syst_max_allocated_family
=
2
5
5
185
\countdef
\c_syst_min_allocated_attribute
=
6
2
\c_syst_min_allocated_attribute
=
1
0
2
4
% 0-1023 : private
186
\countdef
\c_syst_min_allocated_write
=
6
3
\c_syst_min_allocated_write
=
0
187
\countdef
\c_syst_max_allocated_write
=
6
4
\c_syst_max_allocated_write
=
1
2
7
188 189
\countdef
\c_syst_last_allocated_count
=
3
2
\c_syst_last_allocated_count
=
\c_syst_min_allocated_register
190
\countdef
\c_syst_last_allocated_dimen
=
3
3
\c_syst_last_allocated_dimen
=
\c_syst_min_allocated_register
191
\countdef
\c_syst_last_allocated_skip
=
3
4
\c_syst_last_allocated_skip
=
\c_syst_min_allocated_register
192
\countdef
\c_syst_last_allocated_muskip
=
3
5
\c_syst_last_allocated_muskip
=
\c_syst_min_allocated_register
193
\countdef
\c_syst_last_allocated_box
=
3
6
\c_syst_last_allocated_box
=
\c_syst_min_allocated_register
194
\countdef
\c_syst_last_allocated_toks
=
3
7
\c_syst_last_allocated_toks
=
\c_syst_min_allocated_register
195
\countdef
\c_syst_last_allocated_read
=
3
8
\c_syst_last_allocated_read
=
\c_syst_min_allocated_read
196
\countdef
\c_syst_last_allocated_write
=
3
9
\c_syst_last_allocated_write
=
\c_syst_min_allocated_write
197
\countdef
\c_syst_last_allocated_marks
=
4
0
\c_syst_last_allocated_marks
=
\c_syst_min_allocated_register
198
\countdef
\c_syst_last_allocated_language
=
4
1
\c_syst_last_allocated_language
=
\c_syst_min_allocated_language
% not used in context
199
\countdef
\c_syst_last_allocated_insertion
=
4
2
\c_syst_last_allocated_insertion
=
\c_syst_min_allocated_insert
200
\countdef
\c_syst_last_allocated_family
=
4
3
\c_syst_last_allocated_family
=
\c_syst_min_allocated_family
% not used in context
201
\countdef
\c_syst_last_allocated_attribute
=
4
4
\c_syst_last_allocated_attribute
=
\c_syst_min_allocated_attribute
% not used in context
202 203
\countdef
\c_syst_min_counter_value
=
1
2
5
\c_syst_min_counter_value
=
-
"
7
FFFFFFF
% beware, we use index 125 at the lua end
204
\countdef
\c_syst_max_counter_value
=
1
2
6
\c_syst_max_counter_value
=
"
7
FFFFFFF
% beware, we use index 126 at the lua end
205 206
\countdef
\zerocount
=
1
2
0
\zerocount
=
0
207
\countdef
\plusone
=
1
2
1
\plusone
=
1
208
\countdef
\minusone
=
1
2
2
\minusone
=
-
1
209 210
\countdef
\normalpagebox
=
1
2
7
\normalpagebox
=
2
5
5
% hardcoded in pdftex/xetex
211 212
% Only to be used by developers in very special cases!
213 214
% \def\lastallocatedcount {\the\c_syst_last_allocated_count}
215
% \def\lastallocateddimen {\the\c_syst_last_allocated_dimen}
216
% \def\lastallocatedskip {\the\c_syst_last_allocated_skip}
217
% \def\lastallocatedmuskip {\the\c_syst_last_allocated_muskip}
218
% \def\lastallocatedbox {\the\c_syst_last_allocated_dimen}
219
% \def\lastallocatedtoks {\the\c_syst_last_allocated_toks}
220
% \def\lastallocatedattribute{\the\c_syst_last_allocated_attribute}
221 222
% A few traditional allocations (these might go):
223 224
\countdef
\count@
2
5
5
% hm, used in \newif .. todo: replace it there
225
\dimendef
\dimen@
0
226
\dimendef
\dimen@i
1
% global only
227
\dimendef
\dimen@ii
2
228 229
%D So, effectively we start allocating from 256 and upwards. The inserts sit in the
230
%D range 128 upto 254. Page numbers use the counters 0 upto 9 and the pagebox is
231
%D 255. Users can use the scratch registers upto 31 without problem but all others
232
%D are reserved.
233 234
\let
\wlog
\gobbleoneargument
% Let's get rid of this one.
235 236
%D The allocators share a common helper macro.
237 238
\normalprotected\def
\newcount
{
\syst_basics_allocate
\c_syst_last_allocated_count
\count
\countdef
\c_syst_max_allocated_register
}
239
\normalprotected\def
\newdimen
{
\syst_basics_allocate
\c_syst_last_allocated_dimen
\dimen
\dimendef
\c_syst_max_allocated_register
}
240
\normalprotected\def
\newskip
{
\syst_basics_allocate
\c_syst_last_allocated_skip
\skip
\skipdef
\c_syst_max_allocated_register
}
241
\normalprotected\def
\newmuskip
{
\syst_basics_allocate
\c_syst_last_allocated_muskip
\muskip
\muskipdef
\c_syst_max_allocated_register
}
242
\normalprotected\def
\newbox
{
\syst_basics_allocate
\c_syst_last_allocated_box
\box
\mathchardef
\c_syst_max_allocated_register
}
243
\normalprotected\def
\newtoks
{
\syst_basics_allocate
\c_syst_last_allocated_toks
\toks
\toksdef
\c_syst_max_allocated_register
}
244
\normalprotected\def
\newread
{
\syst_basics_allocate
\c_syst_last_allocated_read
\read
\chardef
\c_syst_max_allocated_read
}
245
\normalprotected\def
\newwrite
{
\syst_basics_allocate
\c_syst_last_allocated_write
\write
\chardef
\c_syst_max_allocated_write
}
246
\normalprotected\def
\newmarks
{
\syst_basics_allocate
\c_syst_last_allocated_marks
\marks
\mathchardef
\c_syst_max_allocated_register
}
247
\normalprotected\def
\newinsert
{
\syst_basics_allocate
\c_syst_last_allocated_insertion
\insert
\chardef
\c_syst_max_allocated_insert
}
248 249
%D We don't need these in \CONTEXT:
250 251
\normalprotected\def
\newlanguage
{
\syst_basics_allocate
\c_syst_last_allocated_language
\language
\chardef
\c_syst_max_allocated_language
}
252
\normalprotected\def
\newfamily
{
\syst_basics_allocate
\c_syst_last_allocated_family
\fam
\chardef
\c_syst_max_allocated_family
}
253 254
\let
\newfam\newfamily
255 256
\firstvalidlanguage
\plusone
257 258
% Watch out, for the moment we disable the check for already being defined
259
% later we will revert this but first all chardefs must be replaced.
260 261
\normalprotected\def
\newconstant
#
1
{
\ifdefined
#
1
\let
#
1
\undefined
\fi
\newcount
#
1
}
262
\normalprotected\def
\setnewconstant
#
1
{
\ifdefined
#
1
\let
#
1
\undefined
\fi
\newcount
#
1
#
1
}
% just a number
263
\normalprotected\def
\setconstant
{}
% dummy, no checking, so it warns
264
\normalprotected\def
\setconstantvalue
#
1
#
2
{
\csname
#
1
\endcsname\numexpr
#
2
\relax
}
265 266
% maybe setconstant with check
267 268
% %D The next definitions are really needed (in \CONTEXT):
269 270
\newlinechar
\newlineasciicode
\edef
\outputnewlinechar
{
\Uchar
\newlineasciicode
}
% {^^J}
271 272
%D One reason to start high with allocation is that it permits us to allocate
273
%D consecutive ranges more easily, for instance if for \MPLIB\ we want to allocate a
274
%D continuous range of boxes. It also permits us to do a proper upward allocation
275
%D for inserts. The current code evolved from code that dealt with older engines but
276
%D as all engines now provide many registers we removed all traces.
277 278
\ifdefined
\writestatus
\else
279
%\normalprotected\def\writestatus#1#2{\immediate\write\statuswrite{#1: #2}}
280
\normalprotected\def
\writestatus
#
1
#
2
{
\message
{
#
1
:
#
2
}}
281
\fi
282 283
\def
\syst_basics_allocate_yes
#
1
#
2
#
3
#
4
#
5
% last class method max name
284
{
\ifnum
#
1
<#
4
\relax
285
\global\advance
#
1
\plusone
286
\global
#
3
#
5
=#
1
\relax
287
\else
288
\writestatus
{
warning
}{
no
room
for
\string
#
2
\space
\string
#
5
\space
(
max
:
\number
#
4
)
}
%
289
\fi
}
290 291
\def
\syst_basics_allocate_nop
#
1
#
2
#
3
#
4
#
5
% last class method max name
292
{
\writestatus
{
warning
}{
\string
#
2
\string
#
5
is
already
defined
(
\string\relax
\space
it
first
)
}}
293 294
\def
\syst_basics_allocate
#
1
#
2
#
3
#
4
#
5
% last class method max name
295
{
\ifx
#
5
\undefined
296
\expandafter
\syst_basics_allocate_yes
297
\else\ifx
#
5
\relax
298
\expandafter\expandafter\expandafter
\syst_basics_allocate_yes
299
\else
300
\expandafter\expandafter\expandafter
\syst_basics_allocate_nop
301
\fi\fi
302
#
1
#
2
#
3
#
4
#
5
}
303 304
%D Since the number of chars exceed 256 now, we can use \type {\chardef} instead of
305
%D the more limited \type {\mathchardef}.
306 307
\normalprotected\def
\newbox
{
\syst_basics_allocate
\c_syst_last_allocated_box
\box
\chardef
\c_syst_max_allocated_register
}
308
\normalprotected\def
\newmarks
{
\syst_basics_allocate
\c_syst_last_allocated_marks
\marks\chardef
\c_syst_max_allocated_register
}
309 310
%D Attributes are something very \LUATEX. In \CONTEXT\ you are not supposed to use
311
%D the attributes directly but always allocate then first. For instance attribute~0
312
%D is reserved for special purposes (this might change). Attributes in the range
313
%D 128-1023 are private and should not be touched.
314 315
\let
\attributeunsetvalue
\c_syst_min_counter_value
% used to be \minusone
316 317
\normalprotected\def
\newattribute
{
\syst_basics_allocate
\c_syst_last_allocated_attribute
\attribute\attributedef
\c_syst_max_allocated_register
}
318 319
%D Not used by \CONTEXT\ but for instance \PICTEX\ needs it. It's a trick to force
320
%D strings instead of tokens that take more memory. It's a trick to trick to force
321
%D strings. This macro is never used in \CONTEXT.
322 323
%normalprotected\def\newhelp#1#2{\newtoks#1#1\expandafter{\csname#2\endcsname}}
324
\normalprotected\def
\newhelp
#
1
#
2
{
\newtoks
#
1
#
1
\expandafter
{
\detokenize
{
#
2
}}}
325 326
%D \macros
327
%D {scratchcounter,
328
%D scratchdimen,scratchskip,scratchmuskip,
329
%D scratchbox,
330
%D scratchtoks}
331
%D
332
%D We now define a few scratch registers, so that successive loads at least have
333
%D some available. The private ones are used in cases where we don't want to
334
%D intrude on normal scratch ones.
335 336
\newcount
\scratchcounter
\newcount
\globalscratchcounter
\newcount
\privatescratchcounter
337
\newdimen
\scratchdimen
\newdimen
\globalscratchdimen
\newdimen
\privatescratchdimen
338
\newskip
\scratchskip
\newskip
\globalscratchskip
\newskip
\privatescratchskip
339
\newmuskip\scratchmuskip
\newmuskip\globalscratchmuskip
\newmuskip\privatescratchmuskip
340
\newtoks
\scratchtoks
\newtoks
\globalscratchtoks
\newtoks
\privatescratchtoks
341
\newbox
\scratchbox
\newbox
\globalscratchbox
\newbox
\privatescratchbox
342 343
\newcount\scratchcounterone
\newcount\scratchcountertwo
\newcount\scratchcounterthree
344
\newdimen
\scratchdimenone
\newdimen
\scratchdimentwo
\newdimen
\scratchdimenthree
345
\newskip
\scratchskipone
\newskip
\scratchskiptwo
\newskip
\scratchskipthree
346
\newmuskip\scratchmuskipone
\newmuskip\scratchmuskiptwo
\newmuskip\scratchmuskipthree
347
\newtoks
\scratchtoksone
\newtoks
\scratchtokstwo
\newtoks
\scratchtoksthree
348
\newbox
\scratchboxone
\newbox
\scratchboxtwo
\newbox
\scratchboxthree
349 350
\newcount\scratchcounterfour
\newcount\scratchcounterfive
\newcount\scratchcountersix
351
\newdimen
\scratchdimenfour
\newdimen
\scratchdimenfive
\newdimen
\scratchdimensix
352
\newskip
\scratchskipfour
\newskip
\scratchskipfive
\newskip
\scratchskipsix
353
\newmuskip\scratchmuskipfour
\newmuskip\scratchmuskipfive
\newmuskip\scratchmuskipsix
354
\newtoks
\scratchtoksfour
\newtoks
\scratchtoksfive
\newtoks
\scratchtokssix
355
\newbox
\scratchboxfour
\newbox
\scratchboxfive
\newbox
\scratchboxsix
356 357
\newcount\globalscratchcounterone
358
\newcount\globalscratchcountertwo
359
\newcount\globalscratchcounterthree
360 361
%D \macros
362
%D {tempstring}
363 364
\let
\tempstring
\empty
365 366
%D \macros
367
%D {scratchwidth, scratchheight, scratchdepth, scratchoffset, scratchdistance}
368
%D
369
%D A few more scratch dimensions:
370 371
\newdimen\scratchwidth
372
\newdimen\scratchheight
373
\newdimen\scratchdepth
374
\newdimen\scratchtotal
375 376
\newdimen\scratchoffset
377
\newdimen\scratchleftoffset
378
\newdimen\scratchrightoffset
379
\newdimen\scratchtopoffset
380
\newdimen\scratchbottomoffset
381 382
\newdimen\scratchdistance
383 384
\newdimen\scratchhsize
385
\newdimen\scratchvsize
386 387
\newdimen\scratchxoffset
388
\newdimen\scratchyoffset
389
\newdimen\scratchhoffset
390
\newdimen\scratchvoffset
391 392
\newdimen\scratchxposition
393
\newdimen\scratchyposition
394 395
\newcount\scratchnx
396
\newcount\scratchny
397 398
\newcount\scratchmx
399
\newcount\scratchmy
400 401
\newcount\scratchmin
402
\newcount\scratchmax
403 404
\newcount\scratchunicode
405 406
\newdimen\scratchleftskip
407
\newdimen\scratchrightskip
408
\newdimen\scratchtopskip
409
\newdimen\scratchbottomskip
410 411
%D More allocations:
412 413
\newskip
\zeroskip
\zeroskip
0
pt
plus
0
pt
minus
0
pt
414
\newdimen
\zeropoint
\zeropoint
0
pt
415
\newdimen
\onepoint
\onepoint
1
pt
416
\newdimen
\halfapoint
\halfapoint
0
.
5
pt
417
\newdimen
\maxdimen
\maxdimen
1
6
3
8
3
.
9
9
9
9
9
pt
% 1073741823sp
418
\newcount
\maxcount
\maxcount
2
1
4
7
4
8
3
6
4
7
419
\newdimen
\onebasepoint
\onebasepoint
1
bp
420
\newdimen
\scaledpoint
\scaledpoint
1
sp
421
\newdimen
\thousandpoint
\thousandpoint
1
0
0
0
pt
422
\newmuskip
\zeromuskip
\zeromuskip
0
mu
423
\newmuskip
\onemuskip
\onemuskip
1
mu
424 425
\newmuskip
\muquad
\muquad
1
8
mu
426 427
\let
\points
\onepoint
428
\let
\halfpoint\halfapoint
429 430
\newtoks
\emptytoks
431 432
%D And even more: (todo: countdefs 60+)
433 434
%newcount\minusone \minusone -1
435
\newcount
\minustwo
\minustwo
-
2
436
%chardef \zerocount 0
437
%chardef \plusone 1
438
\chardef
\plustwo
2
439
\chardef
\plusthree
3
440
\chardef
\plusfour
4
441
\chardef
\plusfive
5
442
\chardef
\plussix
6
443
\chardef
\plusseven
7
444
\chardef
\pluseight
8
445
\chardef
\plusnine
9
446
\chardef
\plusten
1
0
447
\chardef
\plussixteen
1
6
448
\chardef
\plusfifty
5
0
449
\chardef
\plushundred
1
0
0
450
\chardef
\plusonehundred
1
0
0
451
\chardef
\plustwohundred
2
0
0
452
\chardef
\plusfivehundred
5
0
0
453
\chardef
\pluscxxvii
1
2
7
454
\chardef
\pluscxxviii
1
2
8
455
\chardef
\pluscclv
2
5
5
456
\chardef
\pluscclvi
2
5
6
457
\chardef
\plusthousand
1
0
0
0
458
\chardef
\plustenthousand
1
0
0
0
0
459
\chardef
\plustwentythousand
2
0
0
0
0
460
\chardef
\medcard
3
2
7
6
8
461
\chardef
\maxcard
6
5
5
3
6
% pdftex has less mathchars
462
\chardef
\maxcardminusone
6
5
5
3
5
463 464
%D \macros
465
%D {doubleexpandafter,tripleexpandafter,expanded,startexpanded}
466
%D
467
%D A few handy shortcuts
468 469
\let
\singleexpandafter
\expandafter
470
\def
\doubleexpandafter
{
\expandafter\expandafter\expandafter
}
471
\def
\tripleexpandafter
{
\expandafter
\doubleexpandafter
\expandafter
}
472 473
%D We prefer the more readable variant than in plain \TEX. User should only
474
%D use \type {\emptybox}:
475 476
\newbox
\voidbox
% public
477 478
\let\normalhbox\hbox
479
\let\normalvbox\vbox
480 481
\def
\unvoidbox
{
\unhbox
\voidbox
}
482
\def
\emptybox
{
\box
\voidbox
}
% used in initializations so no attributes
483
\def
\emptyvbox
{
\normalvpack
{}}
% no copy as we need to set attributes
484
\def
\emptyhbox
{
\normalhpack
{}}
% no copy as we need to set attributes
485 486
\let
\leavevmode
\unvoidbox
% we prefer to use \dontleavehmode
487 488
%D \macros
489
%D {dontcomplain}
490
%D
491
%D We need this one soon:
492 493
\normalprotected\def
\dontcomplain
494
{
\hbadness
\plustenthousand
495
\vbadness
\plustenthousand
496
\hfuzz
\maxdimen
497
\vfuzz
\maxdimen
}
498 499
%D Some expected plain variants follow. We don't reuse registers because we
500
%D don't want clashes.
501 502
\let
\p@
\onepoint
503
\let
\m@ne
\minusone
504
\let
\z@
\zeropoint
505
\let
\@ne
\plusone
506
\let
\tw@
\plustwo
507
\let
\thr@@
\plusthree
508
\let
\sixt@@n
\plussixteen
509
\let
\@cclv
\pluscclv
510
\let
\@cclvi
\pluscclvi
511
\let
\voidb@x
\voidbox
512
\newtoks
\toks@
% \scratchtoks
513 514
%D We define \type {\newif} a la plain \TEX, but will redefine it later. As
515
%D Knuth says:
516
%D
517
%D \startnarrower
518
%D And here's a different sort of allocation: for example,
519
%D
520
%D \starttyping
521
%D \newif\iffoo
522
%D \stoptyping
523
%D
524
%D creates \type {\footrue}, \type {\foofalse} to go with \type {\iffoo}.
525
%D \stopnarrower
526 527
% \normalprotected\def\newif#1%
528
% {\count@\escapechar
529
% \escapechar\minusone
530
% \expandafter\expandafter\expandafter\def\new_if #1{true}{\let#1\iftrue }%
531
% \expandafter\expandafter\expandafter\def\new_if#1{false}{\let#1\iffalse}%
532
% \new_if#1{false}% the condition starts out false
533
% \escapechar\count@}
534
%
535
% \def\new_if#1#2%
536
% {\csname\expandafter\if@\string#1#2\endcsname}
537
%
538
% \bgroup % `if' is required
539
% \uccode`1=`i \uccode`2=`f \uppercase{\gdef\if@12{}}
540
% \egroup
541 542
% We use \csstring so there is no need to push/pop escapechar.
543
% We use different names so that we get a better error message.
544
%
545
% \normalprotected\def\newif#1%
546
% {\let\new_if_saved\newif
547
% \let\newif\new_if_check
548
% \expandafter\expandafter\expandafter\def\new_if_cs #1{true}{\let#1\iftrue }%
549
% \expandafter\expandafter\expandafter\def\new_if_cs#1{false}{\let#1\iffalse}%
550
% \new_if_cs#1{false}%
551
% \let\newif\new_if_saved}
552
%
553
% \normalprotected\def\new_if_cs#1#2%
554
% {\csname\expandafter\newif\csstring#1#2\endcsname}
555
%
556
% We wrap all into one macro:
557 558
\normalprotected\def
\newif
#
1
%
559
{
\let
\new_if_saved
\newif
560
\let
\newif
\new_if_check
561
\expandafter\def\csname\expandafter
\newif
\csstring
#
1
true
\endcsname
{
\let
#
1
\iftrue
}
%
562
\expandafter\def\csname\expandafter
\newif
\csstring
#
1
false
\endcsname
{
\let
#
1
\iffalse
}
%
563
\csname\expandafter
\newif
\csstring
#
1
false
\endcsname
564
\let
\newif
\new_if_saved
}
565 566
\bgroup
567
\normalexpanded
{
\gdef\noexpand
\new_if_check
\string
i
\string
f
{}}
568
\egroup
569 570
%D Let's test this one:
571 572
\newif
\ifdone
573
\newif
\iffound
574 575
\def
\htdp
#
1
{
\dimexpr\ht
#
1
+
\dp
#
1
\relax
}
576 577
%D A few shortcuts:
578 579
\normalprotected\def
\udef
{
\normalprotected\def
}
580
\normalprotected\def
\ugdef
{
\normalprotected\gdef
}
581
\normalprotected\def
\uedef
{
\normalprotected\edef
}
582
\normalprotected\def
\uxdef
{
\normalprotected\xdef
}
583 584
%D For a while we keep the following, as systems like tikz need it. Best
585
%D not use that one \CONTEXT.
586 587
\let
\active
\activecatcode
588 589
%D Constants to be used with \type {\currentgrouptype}.
590 591
\chardef
\bottomlevelgroupcode
=
0
592
\chardef
\simplegroupcode
=
1
593
\chardef
\hboxgroupcode
=
2
594
\chardef
\adjustedhboxgroupcode
=
3
595
\chardef
\vboxgroupcode
=
4
596
\chardef
\vtopgroupcode
=
5
597
\chardef
\aligngroupcode
=
6
598
\chardef
\noaligngroupcode
=
7
599
\chardef
\outputgroupcode
=
8
600
\chardef
\mathgroupcode
=
9
601
\chardef
\discretionarygroupcode
=
1
0
602
\chardef
\insertgroupcode
=
1
1
603
\chardef
\vcentergroupcode
=
1
2
604
\chardef
\mathchoicegroupcode
=
1
3
605
\chardef
\semisimplegroupcode
=
1
4
606
\chardef
\mathshiftgroupcode
=
1
5
607
\chardef
\mathleftgroupcode
=
1
6
608
\chardef
\vadjustgroupcode
=
\insertgroupcode
609 610
%D Constants to be used with \type {\interactionmode}.
611 612
\chardef
\batchmodecode
=
0
613
\chardef
\nonstopmodecode
=
1
614
\chardef
\scrollmodecode
=
2
615
\chardef
\errorstopmodecode
=
3
616 617
%D Constants to be used with \type {\lastnodetype}. The \type {\lastnodetype}
618
%D primitive is \ETEX\ compliant. The valid range is still -1 .. 15 and glyph nodes
619
%D have number 0 (used to be char node) and ligature nodes are mapped to 7. That way
620
%D macro packages can use the same symbolic names as in traditional \ETEX. Keep in
621
%D mind that the internal node numbers are different and that there are more node
622
%D types that 15. The mode parameter forces \LUAMETATEX\ to use the real node
623
%D numbers.
624 625
\ifdefined
\internalcodesmode
626 627
\internalcodesmode
\plusone
628 629
% \chardef\gluenodecode = 12
630
% \chardef\kernnodecode = 13
631
% \chardef\penaltynodecode = 14
632 633
\else
634 635
% \chardef\charnodecode = 0
636
% \chardef\hlistnodecode = 1
637
% \chardef\vlistnodecode = 2
638
% \chardef\rulenodecode = 3
639
% \chardef\insertnodecode = 4
640
% \chardef\marknodecode = 5
641
% \chardef\adjustnodecode = 6
642
% \chardef\ligaturenodecode = 7
643
% \chardef\discretionarynodecode = 8
644
% \chardef\whatsitnodecode = 9
645
% \chardef\mathnodecode = 10
646
\chardef
\gluenodecode
=
1
1
647
\chardef
\kernnodecode
=
1
2
648
\chardef
\penaltynodecode
=
1
3
649
% \chardef\unsetnodecode = 14
650
% \chardef\mathsnodecode = 15
651 652
\fi
653 654
%D Constants to be used with \type {\currentiftype}. I wonder if we will ever
655
%D use these in \CONTEXT. We have a few more anyway and in \LUAMETATEX\ we
656
%D have different numbers. So for now let's just not define them. The
657
%D previously mentioned mode parameters enables the real numbers (we have
658
%D some more and they are therefore ordered differently).
659 660
% \chardef\charifcode = 1
661
% \chardef\catifcode = 2
662
% \chardef\numifcode = 3
663
% \chardef\dimifcode = 4
664
% \chardef\oddifcode = 5
665
% \chardef\vmodeifcode = 6
666
% \chardef\hmodeifcode = 7
667
% \chardef\mmodeifcode = 8
668
% \chardef\innerifcode = 9
669
% \chardef\voidifcode = 10
670
% \chardef\hboxifcode = 11
671
% \chardef\vboxifcode = 12
672
% \chardef\xifcode = 13
673
% \chardef\eofifcode = 14
674
% \chardef\trueifcode = 15
675
% \chardef\falseifcode = 16
676
% \chardef\caseifcode = 17
677
% \chardef\definedifcode = 18
678
% \chardef\csnameifcode = 19
679
% \chardef\fontcharifcode = 20
680 681
%D Of course we want even bigger log files, so we copied this from the \ETEX\
682
%D source files.
683
%D
684
%D When watching such logs, beware of nasty side effects of \type {\scantokens},
685
%D as in:
686
%D
687
%D \starttyping
688
%D \bgroup
689
%D \lccode`a=12\lowercase{\xdef\whatever{a}}\egroup
690
%D \def\whatever{test \whatever test}
691
%D \scantokens\expandafter{\whatever}
692
%D \egroup
693
%D \stoptyping
694
%D
695
%D In \LUATEX\ we have ways around this.
696 697
% no longer \errorstopmode cf. plain tex 3.141592653
698 699
\normalprotected\def
\tracingall
700
{
\tracingonline
\plusone
701
\tracingcommands
\plusthree
702
\tracingstats
\plustwo
703
\tracingpages
\plusone
704
\tracingoutput
\plusone
705
\tracinglostchars
\plustwo
706
\tracingmacros
\plustwo
707
\tracingparagraphs
\plusone
708
\tracingrestores
\plusone
709
\showboxbreadth
\maxdimen
710
\showboxdepth
\maxdimen
711
\tracinggroups
\plusone
712
\tracingifs
\plusone
713
\tracingscantokens
\plusone
714
\tracingnesting
\plustwo
715
\tracingassigns
\plustwo
}
716 717
\normalprotected\def
\loggingall
718
{
\tracingall
719
\tracingonline
\zerocount
}
720 721
\normalprotected\def
\tracingnone
722
{
\tracingassigns
\zerocount
723
\tracingnesting
\zerocount
724
\tracingscantokens
\zerocount
725
\tracingifs
\zerocount
726
\tracinggroups
\zerocount
727
\showboxdepth
\plusthree
728
\showboxbreadth
\plusfive
729
\tracingrestores
\zerocount
730
\tracingparagraphs
\zerocount
731
\tracingmacros
\zerocount
732
\tracinglostchars
\plusone
733
\tracingoutput
\zerocount
734
\tracingpages
\zerocount
735
\tracingstats
\zerocount
736
\tracingcommands
\zerocount
737
\tracingonline
\zerocount
}
738 739
%D When we want to see a box we can as well show all of it.
740 741
\showboxdepth
\maxdimen
742
\showboxbreadth
\maxdimen
743 744
%D Just for tracing purposes we set:
745 746
\tracingstats
\plusone
747 748
%D Here we also save \type {\input}, more will be saved later.
749 750
\ifdefined
\normalinput
\else
\let\normalinput\input
\fi
751 752
%D We don't like outer commands, and we always want access to the original
753
%D \type {\input} primitive.
754 755
\let\normalouter\outer
\def\outer
{}
% no longer \relax
756 757
%D To circumvent dependencies, we can postpone certain initializations to
758
%D dumping time, by appending them to the \type {\everydump} token register.
759 760
\ifdefined
\normaldump
\else
\let\normaldump\dump
\fi
761 762
\newtoks
\everydump
763 764
\def\dump
{
\the
\everydump
\normaldump
}
765 766
%D The same applies for the startup actions.
767 768
\ifdefined
\normaleveryjob
\else
\let\normaleveryjob\everyjob
\fi
769 770
\let\everyjob\relax
\newtoks
\everyjob
771 772
\normaleveryjob
{
\the\everyjob
}
773 774
%D \macros
775
%D {newconditional,
776
%D settrue, setfalse,
777
%D ifconditional,then}
778
%D
779
%D \TEX's lacks boolean variables, although the \PLAIN\ format implements \type
780
%D {\newif}. The main disadvantage of this scheme is that it takes three hash table
781
%D entries. A more memory saving alternative is presented here. A conditional is
782
%D defined by:
783
%D
784
%D \starttyping
785
%D \newconditional\doublesided
786
%D \setfalse
787
%D \stoptyping
788
%D Setting a conditional is done by \type{\settrue} and
789
%D \type{\setfalse}:
790
%D
791
%D \starttyping
792
%D \settrue\doublesided
793
%D \setfalse
794
%D \stoptyping
795
%D while testing is accomplished by:
796
%D
797
%D \starttyping
798
%D \ifconditional\doublesided ... \else ... \fi
799
%D \setfalse
800
%D \stoptyping
801
%D We cannot use the simple scheme:
802
%D
803
%D \starttyping
804
%D \def\settrue #1{\let#1=\iftrue}
805
%D \def\setfalse#1{\let#1=\iffalse}
806
%D \stoptyping
807
%D
808
%D Such an implementation gives problems with nested conditionals. The next
809
%D implementation is about as fast and just as straightforward:
810 811
\let
\conditionalfalse\plusone
% maybe we will have a dedicated count/chardef
812
\let
\conditionaltrue
\zerocount
% maybe we will have a dedicated count/chardef
813 814
\normalprotected\def
\settrue
#
1
{
\let
#
1
\conditionaltrue
}
815
\normalprotected\def
\setfalse
#
1
{
\let
#
1
\conditionalfalse
}
816 817
\normalprotected\def
\settruevalue
#
1
{
\expandafter\let\csname
#
1
\endcsname
\conditionaltrue
}
818
\normalprotected\def
\setfalsevalue
#
1
{
\expandafter\let\csname
#
1
\endcsname
\conditionalfalse
}
819 820
\let
\newconditional\setfalse
821
\let
\ifconditional
\ifcase
822 823
\let
\then
\relax
% so that we can say: \ifnum1>2\then -)
824 825
\def
\truecondition
{
\iftrue
}
826
\def
\falsecondition
{
\iffalse
}
827 828
%D \macros
829
%D {newmacro,setnewmacro,newfraction}
830
%D
831
%D Let's be complete and also introduce some definers. These are not mandate
832
%D but handy for grepping.
833 834
\normalprotected\def
\newmacro
#
1
{
\let
#
1
\empty
}
835
\normalprotected\def
\setnewmacro
#
1
{
\let
#
1
}
836 837
\def
\!!zerocount
{
0
}
838
\def
\!!plusone
{
1
}
839 840
\normalprotected\def
\newfraction
#
1
{
\let
#
1
\!!plusone
}
841 842
%D It would be handy to have a primitive \type {\unless\ifcase} because then we
843
%D could use nicer values. Anyhow, this conditional code used to be in the \type
844
%D {syst-aux} module but is now promoted to here.
845 846
%D \macros
847
%D {ifzeropt}
848
%D
849
%D The next macro is both cosmetic and byte saving. It is pretty \type
850
%D {\if}||safe too. It can be used in cases like:
851
%D
852
%D \starttyping
853
%D \ifzeropt \somedimen ... \else ... \fi
854
%D \stoptyping
855 856
\let
\ifzeropt\ifcase
857 858
% these token list helpers might move to syst-aux.mkiv
859
%
860
% we assume a \cs. not toks0 or so
861
%
862
% \normalprotected\def\appendtotoks #1#{\def\temp{#1}\afterassignment\doappendtotoks \scratchtoks=}
863
% \normalprotected\def\prependtotoks#1#{\def\temp{#1}\afterassignment\doprependtotoks\scratchtoks=}
864 865
\newtoks
\t_syst_toks_temp
\let
\m_syst_toks_temp
\t_syst_toks_temp
866 867
\normalprotected\def
\appendtotoks
#
1
{
\let
\m_syst_toks_temp
#
1
\afterassignment
\syst_toks_append_l
\t_syst_toks_temp
=
}
868
\normalprotected\def
\prependtotoks
#
1
{
\let
\m_syst_toks_temp
#
1
\afterassignment
\syst_toks_prepend_l
\t_syst_toks_temp
=
}
869 870
% \def\syst_toks_append {\m_syst_toks_temp\expandafter\expandafter\expandafter{\expandafter\the\expandafter\m_syst_toks_temp\the\t_syst_toks_temp}}}
871
% \def\syst_toks_prepend{\m_syst_toks_temp\expandafter\expandafter\expandafter{\expandafter\the\expandafter\t_syst_toks_temp\the\m_syst_toks_temp}}}
872 873
\normalprotected\def
\globalappendtotoks
#
1
{
\let
\m_syst_toks_temp
#
1
\afterassignment
\syst_toks_append_g
\t_syst_toks_temp
=
}
874
\normalprotected\def
\globalprependtotoks
#
1
{
\let
\m_syst_toks_temp
#
1
\afterassignment
\syst_toks_prepend_g
\t_syst_toks_temp
=
}
875 876
\def
\syst_toks_append_l
{
\normalexpanded
{
\m_syst_toks_temp
{
\the
\m_syst_toks_temp
\the
\t_syst_toks_temp
}}}
877
\def
\syst_toks_prepend_l
{
\normalexpanded
{
\m_syst_toks_temp
{
\the
\t_syst_toks_temp
\the
\m_syst_toks_temp
}}}
878 879
\def
\syst_toks_append_g
{
\global
\syst_toks_append_l
}
880
\def
\syst_toks_prepend_g
{
\global
\syst_toks_prepend_l
}
881 882
\normalprotected\def
\addtotoks
#
1
{
\let
\m_syst_toks_temp
#
1
\afterassignment
\syst_toks_add_l
\let
\next
}
883
\normalprotected\def
\globaladdtotoks
#
1
{
\let
\m_syst_toks_temp
#
1
\afterassignment
\syst_toks_add_g
\let
\next
}
884 885
\def
\syst_toks_add_l
{
\m_syst_toks_temp
\expandafter
\bgroup
\the
\m_syst_toks_temp
}
886
\def
\syst_toks_add_g
{
\global
\syst_toks_add_l
}
887 888
\normalprotected\def
\addtotokscs
#
1
#
2
{
#
1
{
\the
#
1
#
2
}}
% saves a few bytes
889
\normalprotected\def
\globaladdtotokscs
#
1
#
2
{
\global
#
1
{
\the
#
1
#
2
}}
% saves a few bytes
890 891
%D \macros
892
%D {begcsname}
893
%D
894
%D Handy for \ETEX-only usage (avoids making \type {\relax}'s:
895 896
% \def\begcsname#1\endcsname{\ifcsname#1\endcsname\csname#1\endcsname\fi}
897 898
\let
\begcsname
\begincsname
899 900
%D Now come a few macros that might be needed in successive loading. We redefine the
901
%D \type {\par} primitive pretty soon so that we get the equivalents right.
902 903
% too tricky: \par is use more often than a par starts so we have too much change
904
% that we get assymetrical behaviour
905
%
906
% \newtoks\everyendpar
907
%
908
% \normalprotected\def\endpar{\the\everyendpar\normalpar}
909
% \normalprotected\def\par {\endpar}
910
%
911
% \normalprotected\def\reseteverypar
912
% {\everypar \emptytoks
913
% \everyendpar\emptytoks}
914 915
\normalprotected\def
\reseteverypar
916
{
\everypar
\emptytoks
}
917 918
\let
\endgraf
\par
919
\let
\endline
\cr
920 921
\normalprotected\def
\null
{
\hpack
{}}
922 923
%D The following two might be overloaded later on but some modules need then
924
%D earlier. These functionality is reflected in the name and will not change.
925 926
% \bgroup
927
% \catcode`\^^M=\activecatcode%
928
% \gdef\obeylines{\catcode`\^^M\activecatcode \let^^M\par}%
929
% \glet^^M\par%
930
% \egroup
931
%
932
% \bgroup
933
% \gdef\obeyspaces{\catcode`\ \activecatcode}%
934
% \obeyspaces\glet =\space%
935
% \egroup
936 937
\def
\obeylines
{
\catcode
\endoflineasciicode\activecatcode
\letcharcode
\endoflineasciicode
\par
}
938
\def
\obeyspaces
{
\catcode
\spaceasciicode
\activecatcode
\letcharcode
\spaceasciicode
\space
}
939 940
% %D A constant:
941
%
942
% \let\endoflinetoken=^^M
943 944
%D Also needed might be a simple loop structure and we borrow plain \TEX's one
945
%D as it is often expected to be present and it is about the fastest you can
946
%D get. Beware: this macro does not support nested loops. We use a namespace
947
%D prefix \type {@@pln}.
948 949
\def
\loop
#
1
\repeat
{
\def
\@@plnbody
{
#
1
}
\@@plniterate
}
% might go
950 951
%D The following makes \type {\loop} \unknown\ \type {\if} \unknown\ \type
952
%D {\repeat} skippable (clever trick):
953 954
\let
\repeat
\fi
% so both \loop and \repeat are reserved words!
955 956
%D The original (no \type {@@pln} there):
957
%D
958
%D \starttyping
959
%D \def\@@plniterate{\@@plnbody\let\next\@@plniterate\else\let\next\relax\fi\next}
960
%D \stoptyping
961
%D
962
%D A more efficient alternative:
963
%D
964
%D \starttyping
965
%D \def\@@plniterate{\@@plnbody\expandafter\@@plniterate\else\expandafter\relax\fi}
966
%D \stoptyping
967
%D
968
%D An even more efficient one:
969 970
\def
\@@plniterate
{
\@@plnbody
\expandafter
\@@plniterate
\else\fi
}
971 972
%D We don't define a real output routine yet but at least get rid of pages:
973 974
\output
{
\shipout\box
\normalpagebox
}
975 976
%D Although we don't add pagenumbers yet we alias the default register used
977
%D for counting pages:
978 979
\countdef
\pageno
\zerocount
\pageno
\plusone
% first page is number 1
980 981
%D Beside the raw counter \type {\pageno} the \type {\folio} macro provides
982
%D the value.
983 984
\def
\folio
{
\the
\pageno
}
% kind of expected and therefore reserved
985 986
%D The following registers are kind of standard and (for the moment) we define
987
%D them here. This might change.
988 989
\newskip
\bigskipamount
\bigskipamount
=
1
2
pt
plus
4
pt
minus
4
pt
990
\newskip
\medskipamount
\medskipamount
=
6
pt
plus
2
pt
minus
2
pt
991
\newskip
\smallskipamount
\smallskipamount
=
3
pt
plus
1
pt
minus
1
pt
992 993
\baselineskip
=
1
2
pt
994
\lineskip
=
1
pt
995
\lineskiplimit
=
0
pt
996 997
%D Sometimes kerns make more sense than glue but we need to be in the
998
%D right mode:
999 1000
\normalprotected\def
\vkern
{
\ifhmode
\par
\fi\kern
}
1001
\normalprotected\def
\hkern
{
\ifvmode
\dontleavehmode
\fi\kern
}
1002 1003
%D Again a few kind-of-extensions the core. These come from plain \TEX\ but
1004
%D are probably not used in \CONTEXT.
1005 1006
\newskip
\hideskip
\hideskip
=
-
1
0
0
0
pt
plus
1
fill
1007
\newskip
\centering
\centering
=
0
pt
plus
1
0
0
0
pt
minus
1
0
0
0
pt
1008 1009
\def
\hidewidth
% for alignment entries that can stick out
1010
{
\hskip
\hideskip
}
1011 1012
\def
\ialign
% initialized \halign
1013
{
\everycr
\emptytoks
1014
\tabskip
\zeroskip
1015
\halign
}
1016 1017
\newcount
\mscount
1018 1019
\def
\spanomit
{
\span\omit
}
% bypass error message
1020 1021
\def
\multispan
#
1
%
1022
{
\omit
1023
\mscount
#
1
\relax
1024
\loop
1025
\ifnum
\mscount
>
\plusone
1026
\spanomit
\advance
\mscount
\minusone
1027
\repeat
}
1028 1029
%D For the \LUATEX\ backend (overloaded anyway):
1030 1031
\ifdefined
\pdfvariable
1032 1033
\pdfvariable
compresslevel
\plusthree
1034
\pdfvariable
objcompresslevel
\plusone
1035
% \pdfvariable recompress \zerocount
1036
\pdfvariable
decimaldigits
\plussix
1037
\pdfvariable
gamma
\plusthousand
1038
\pdfvariable
imageresolution
3
0
0
1039
\pdfvariable
imageapplygamma
\zerocount
1040
\pdfvariable
imagegamma
2
2
0
0
1041
\pdfvariable
imagehicolor
\plusone
1042
\pdfvariable
imageaddfilename
\plusone
1043
\pdfvariable
pkresolution
1
2
0
0
1044
\pdfvariable
inclusioncopyfonts
\plusone
1045
\pdfvariable
inclusionerrorlevel
\zerocount
1046
\pdfvariable
gentounicode
\plusone
1047
\pdfvariable
omitcidset
\plusone
1048
\pdfvariable
omitcharset
\plusone
1049
\pdfvariable
pagebox
\zerocount
1050
% \pdfvariable majorversion % \plusone
1051
\pdfvariable
minorversion
\plusseven
1052
\pdfvariable
uniqueresname
\zerocount
1053
\pdfvariable
horigin
1
in
1054
\pdfvariable
vorigin
1
in
1055
% \pdfvariable linkmargin \zeropoint
1056
% \pdfvariable destmargin \zeropoint
1057
% \pdfvariable threadmargin \zeropoint
1058
% \pdfvariable xformmargin \zeropoint
1059
\pdfvariable
pkfixeddpi
\plusone
1060
\pdfvariable
ignoreunknownimages
\zerocount
1061 1062
\fi
1063 1064
\let
\nopdfcompression
\relax
1065
\let
\onlypdfobjectcompression
\relax
1066
\let
\maximumpdfcompression
\relax
1067
\let
\normalpdfcompression
\relax
1068 1069
\ifdefined
\outputmode
1070
\outputmode
\zerocount
% we generate the format in this mode
1071
\fi
1072 1073
%D Basic status stuff.
1074 1075
\newif
\ifproductionrun
1076 1077
%D For those who expect this \unknown
1078 1079
\ifx
\fmtname
\undefined
\def
\fmtname
{
ConTeXt
Initial
TeX
}
\fi
1080
\ifx
\fmtversion\undefined
\def
\fmtversion
{
3
.
1
4
1
5
9
2
6
}
\fi
1081 1082
%D A few bonus macros:
1083 1084
\def
\modulonumber
#
1
#
2
{
\the\numexpr
#
2
-
((((#
2
+
(#
1
/
2
))
/
#
1
)
-
1
)
*
#
1
)
\relax
}
1085
\def
\dividenumber
#
1
#
2
{
\the\numexpr
(#
2
-
(#
1
/
2
))
/
#
1
\relax
}
1086 1087
\ifdefined
\texenginename
\else
1088
\edef
\texenginename
{
\directlua{
tex
.
print
(
LUATEXENGINE
)
}
}
1089
\fi
1090 1091
\ifdefined
\texengineversion
\else
1092
\edef
\texengineversion
{
\directlua{
tex
.
print
(
LUATEXVERSION
)
}
}
1093
\fi
1094 1095
\ifdefined
\texenginefunctionality
\else
1096
\edef
\texenginefunctionality
{
\directlua{
tex
.
print
(
LUATEXFUNCTIONALITY
)
}
}
1097
\fi
1098 1099
%D We have no reason not to enable this:
1100 1101
\savingvdiscards
\plusone
1102 1103
%D We only can set this one via directives (system.synctex) and we only support
1104
%D the context variant. This will go away completely.
1105 1106
\let
\synctex
\undefined
\newcount
\synctex
\let
\normalsynctex
\synctex
1107 1108
%D We get rid of the funny \TEX\ offset defaults of one inch by setting them to zero.
1109 1110
\voffset
\zeropoint
\let\voffset\relax
\newdimen
\voffset
\let\normalvoffset\voffset
1111
\hoffset
\zeropoint
\let\hoffset\relax
\newdimen
\hoffset
\let\normalhoffset\hoffset
1112 1113
\ifdefined
\pageleftoffset
1114
\let
\pageleftoffset
\hoffset
\let
\normalpageleftoffset
\hoffset
1115
\let
\pagerightoffset
\hoffset
\let
\normalpagerightoffset
\hoffset
1116
\let
\pagetopoffset
\voffset
\let
\normalpagetopoffset
\voffset
1117
\let
\pagebottomoffset
\voffset
\let
\normalpagebottomoffset
\voffset
1118
\fi
1119 1120
%D Handy (this will change, again).
1121 1122
\ifdefined
\suppresslongerror
\suppresslongerror
\plusone
\fi
1123
\ifdefined
\suppressoutererror
\suppressoutererror
\plusone
\fi
1124
\ifdefined
\suppressmathparerror
\suppressmathparerror
\plusone
\fi
1125
\ifdefined
\suppressifcsnameerror
\suppressifcsnameerror
\plusone
\fi
1126
\ifdefined
\suppressfontnotfounderror
\suppressfontnotfounderror
\zerocount
\fi
1127 1128
\let
\suppresslongerror
\relax
1129
\newcount
\suppresslongerror
\let
\normalsuppresslongerror
\suppresslongerror
1130
\let
\suppressoutererror
\suppresslongerror
\let
\normalsuppressoutererror
\suppresslongerror
1131
\let
\suppressmathparerror
\suppresslongerror
\let
\normalsuppressmathparerror
\suppresslongerror
1132
\let
\suppressifcsnameerror
\suppresslongerror
\let
\normalsuppressifcsnameerror
\suppresslongerror
1133
\let
\suppressfontnotfounderror
\suppresslongerror
\let
\normalsuppressfontnotfounderror
\suppresslongerror
1134 1135
\matheqnogapstep
\zerocount
% for now
1136 1137
%D Experiment:
1138 1139
\ifdefined
\frozen
\else
\def\frozen
{}
\let\normalfrozen\frozen
\fi
1140 1141
%D Now we define a few helpers that we need in a very early stage. We have no
1142
%D message system yet but redundant definitions are fatal anyway.
1143 1144
\newcount
\c_syst_helpers_n_of_namespaces
\c_syst_helpers_n_of_namespaces
\pluseight
% 1-8 reserved for catcodes
1145 1146
\def
\v_interfaces_prefix_template_system
{
\number
\c_syst_helpers_n_of_namespaces
>>
}
1147
%def\v_interfaces_prefix_template_system{\characters\c_syst_helpers_n_of_namespaces>>} % no \characters yet
1148 1149
\normalprotected\def
\installsystemnamespace
#
1
%
1150
{
\ifcsname
?
?
#
1
\endcsname
1151
\immediate
\write
\statuswrite
{
fatal
error
:
duplicate
system
namespace
'
#
1
'
}
%
1152
\expandafter\normalend
1153
\else
1154
\global\advance
\c_syst_helpers_n_of_namespaces
\plusone
1155
\expandafter\edef\csname
?
?
#
1
\endcsname
{
\v_interfaces_prefix_template_system
}
%
1156
\fi
}
1157 1158
%D It makes more sense to have these here:
1159 1160
\let
\normalsuperscript
\Usuperscript
1161
\let
\normalsubscript
\Usubscript
1162
\let
\normalnosuperscript
\Unosuperscript
1163
\let
\normalnosubscript
\Unosubscript
1164
\let
\normalstartimath
\Ustartmath
1165
\let
\normalstopimath
\Ustopmath
1166
\let
\normalstartdmath
\Ustartdisplaymath
1167
\let
\normalstopdmath
\Ustopdisplaymath
1168 1169
%D Also better here:
1170 1171
\def
\wildcardsymbol
{
*
}
1172 1173
%D Get rid of this, we don't need it. If we ever need to check the order we will
1174
%D use proper symbolic constants.
1175 1176
\let
\eTeXglueshrinkorder
\undefined
1177
\let
\eTeXgluestretchorder
\undefined
1178 1179
%D Experiment:
1180 1181
\ifdefined
\glyphdimensionsmode
\else
\newcount
\glyphdimensionsmode
\fi
1182 1183
\glyphdimensionsmode
\plusone
1184 1185
\protect
\endinput
1186