diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/syst-ini.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/syst-ini.mkiv | 340 |
1 files changed, 196 insertions, 144 deletions
diff --git a/Master/texmf-dist/tex/context/base/syst-ini.mkiv b/Master/texmf-dist/tex/context/base/syst-ini.mkiv index 983bedc52a7..59313ba494c 100644 --- a/Master/texmf-dist/tex/context/base/syst-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/syst-ini.mkiv @@ -11,16 +11,14 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -%D We used to load plain \TEX\ in a special way, but redefining -%D a couple of primitives so that for instance font loading was -%D ignored. For those interested, this loader is found in -%D \type {syst-tex.tex}. Some of the comment's are Don Knuth's -%D and more of it can be found in the plain \TEX\ format. - -%D Characters can have special states, that can be triggered -%D by setting their category coded. Some are preset, others -%D are to be set as soon as possible, otherwise we cannot -%D define any useful macros. +%D We used to load plain \TEX\ in a special way, but redefining a couple of +%D primitives so that for instance font loading was ignored. For those interested, +%D this loader is found in \type {syst-tex.tex}. Some of the comment's are Don +%D Knuths and more of it can be found in the plain \TEX\ format. +%D +%D Characters can have special states, that can be triggered by setting their +%D category coded. Some are preset, others are to be set as soon as possible, +%D otherwise we cannot define any useful macros. %catcode`\^^@ = 9 % ascii null is ignored %catcode`\\ = 0 % backslash is TeX escape character @@ -58,8 +56,7 @@ \catcode`\^^Z=9 -%D It makes sense to know what engine we're running so let's -%D try to deduce it. +%D It makes sense to know what engine we're running so let's try to deduce it. \chardef\unknownengine = 0 \chardef\pdftexengine = 1 @@ -117,16 +114,15 @@ } \fi -%D \ETEX\ has a not so handy way of telling you the version number, -%D i.e. the revision number has a period in it: +%D \ETEX\ has a not so handy way of telling you the version number, i.e. the revision +%D number has a period in it: \long\def\gobbleoneargument#1{} % will be defined later on anyway \mathchardef\etexversion = \numexpr\eTeXversion*100+\expandafter\gobbleoneargument\eTeXrevision\relax -%D First we define a simplified version of the \CONTEXT\ -%D protection mechanism. Later we will implement a better -%D variant. +%D First we define a simplified version of the \CONTEXT\ protection mechanism. +%D Later we will implement a better variant. \def\unprotect {\edef\protect @@ -149,18 +145,21 @@ \let\bgroup={ \let\egroup=} -%D Allocation of registers is done slightly different than in plain -%D \TEX. First of all we use different reserved counters. We also -%D don't implement a family handler because users are not supposed -%D to implement their own math. We reserve the lowest 31 registers -%D for scratch purposes. Keep in mind that in the core engine -%D some registers are reserved: counters 0 upto 9, and counter 255. +%D \macros +%D {normalbgroup,normalgroup} %D -%D As with plain \TEX\ we recommend that macro designers always use -%D \type {\global} assignments with respect to registers numbered 1, -%D 3, 5 \unknown\ 31, and always non||\type {\global} assignments -%D with respect to registers 0, 2, 4, \unknown\ 30. This will prevent -%D \quote {save stack buildup} that might otherwise occur. +%D No comment. + +%D Allocation of registers is done slightly different than in plain \TEX. First of +%D all we use different reserved counters. We also don't implement a family handler +%D because users are not supposed to implement their own math. We reserve the lowest +%D 31 registers for scratch purposes. Keep in mind that in the core engine some +%D registers are reserved: counters 0 upto 9, and counter 255. +%D +%D As with plain \TEX\ we recommend that macro designers always use \type {\global} +%D assignments with respect to registers numbered 1, 3, 5 \unknown\ 31, and always +%D non||\type {\global} assignments with respect to registers 0, 2, 4, \unknown\ 30. +%D This will prevent \quote {save stack buildup} that might otherwise occur. %D %D We reserve some registers for special (management) purposes: @@ -212,11 +211,10 @@ \dimendef \dimen@i = 1 % global only \dimendef \dimen@ii = 2 -%D So, effectively we start allocating from 256 and upwards. The -%D inserts sit in the range 128 upto 254. Page numbers use the -%D counters 0 upto 9 and the pagebox is 255. Users can use the -%D scratch registers upto 31 without problem but all others are -%D reserved. +%D So, effectively we start allocating from 256 and upwards. The inserts sit in the +%D range 128 upto 254. Page numbers use the counters 0 upto 9 and the pagebox is +%D 255. Users can use the scratch registers upto 31 without problem but all others +%D are reserved. \let\wlog\gobbleoneargument % Let's get rid of this one. @@ -254,12 +252,11 @@ %newlinechar=10 \def\outputnewlinechar{\rawcharacter{10}} \newlinechar=10 \edef\outputnewlinechar{^^J} -%D One reason to start high with allocation is that it permits us to -%D allocate consecutive ranges more easily, for instance if for \MPLIB\ -%D we want to allocate a continuous range of boxes. It also permits us -%D to do a proper upward allocation for inserts. The current code -%D evolved from code that dealt with older engines but as all engines -%D now provide many registers we removed all traces. +%D One reason to start high with allocation is that it permits us to allocate +%D consecutive ranges more easily, for instance if for \MPLIB\ we want to allocate a +%D continuous range of boxes. It also permits us to do a proper upward allocation +%D for inserts. The current code evolved from code that dealt with older engines but +%D as all engines now provide many registers we removed all traces. \ifdefined\writestatus \else \normalprotected\def\writestatus#1#2{\immediate\write16{#1: #2}} @@ -286,29 +283,27 @@ \fi\fi #1#2#3#4#5} -%D Since the number of chars exceed 256 now, we can use \type -%D {\chardef} instead of the more limited \type {\mathchardef}. +%D Since the number of chars exceed 256 now, we can use \type {\chardef} instead of +%D the more limited \type {\mathchardef}. \ifnum\texengine>\pdftexengine \normalprotected\def\newbox {\syst_basics_allocate\c_syst_last_allocated_box \box \chardef\c_syst_max_allocated_register} \normalprotected\def\newmarks{\syst_basics_allocate\c_syst_last_allocated_marks\marks\chardef\c_syst_max_allocated_register} \fi -%D Attributes are something very \LUATEX. In \CONTEXT\ you are not -%D supposed to use the attributes directly but always allocate then -%D first. For instance attribute~0 is reserved for special purposes -%D (this might change). Attributes in the range 128-1023 are private -%D and should not be touched. +%D Attributes are something very \LUATEX. In \CONTEXT\ you are not supposed to use +%D the attributes directly but always allocate then first. For instance attribute~0 +%D is reserved for special purposes (this might change). Attributes in the range +%D 128-1023 are private and should not be touched. \ifnum\texengine=\luatexengine \let\attributeunsetvalue\c_syst_min_counter_value % used to be \minusone \normalprotected\def\newattribute{\syst_basics_allocate\c_syst_min_allocated_attribute\attribute\attributedef\c_syst_max_allocated_register} \fi -%D Not used by \CONTEXT\ but for instance \PICTEX\ needs it. It's a -%D trick to force strings instead of tokens that take more memory. -%D It's a trick to trick to force strings. This macro is never used -%D in \CONTEXT. +%D Not used by \CONTEXT\ but for instance \PICTEX\ needs it. It's a trick to force +%D strings instead of tokens that take more memory. It's a trick to trick to force +%D strings. This macro is never used in \CONTEXT. \normalprotected\def\newhelp#1#2{\newtoks#1#1\expandafter{\csname#2\endcsname}} @@ -318,8 +313,8 @@ %D scratchbox, %D scratchtoks} %D -%D We now define a few scratch registers, so that successive -%D loads at least have some available. +%D We now define a few scratch registers, so that successive loads at least have +%D some available. \newcount \scratchcounter \newcount \globalscratchcounter \newdimen \scratchdimen \newdimen \globalscratchdimen @@ -343,21 +338,51 @@ \newdimen\scratchwidth \newdimen\scratchheight \newdimen\scratchdepth + \newdimen\scratchoffset +\newdimen\scratchleftoffset +\newdimen\scratchrightoffset +\newdimen\scratchtopoffset +\newdimen\scratchbottomoffset + \newdimen\scratchdistance + \newdimen\scratchhsize \newdimen\scratchvsize +\newdimen\scratchxoffset +\newdimen\scratchyoffset +\newdimen\scratchhoffset +\newdimen\scratchvoffset + +\newdimen\scratchxposition +\newdimen\scratchyposition + +\newcount\scratchnx +\newcount\scratchny + +\newcount\scratchmx +\newcount\scratchmy + +\newcount\scratchunicode + +\newdimen\scratchleftskip +\newdimen\scratchrightskip +\newdimen\scratchtopskip +\newdimen\scratchbottomskip + %D More allocations: -\newskip \zeroskip \zeroskip = 0pt plus 0pt minus 0pt -\newdimen\zeropoint \zeropoint = 0pt -\newdimen\onepoint \onepoint = 1pt -\newdimen\halfapoint \halfapoint = 0.5pt -\newdimen\maxdimen \maxdimen = 16383.99999pt -\newdimen\onebasepoint \onebasepoint = 1bp -\newdimen\scaledpoint \scaledpoint = 1sp -\newdimen\thousandpoint \thousandpoint = 1000pt +\newskip \zeroskip \zeroskip = 0pt plus 0pt minus 0pt +\newdimen \zeropoint \zeropoint = 0pt +\newdimen \onepoint \onepoint = 1pt +\newdimen \halfapoint \halfapoint = 0.5pt +\newdimen \maxdimen \maxdimen = 16383.99999pt +\newdimen \onebasepoint \onebasepoint = 1bp +\newdimen \scaledpoint \scaledpoint = 1sp +\newdimen \thousandpoint \thousandpoint = 1000pt +\newmuskip\zeromuskip \zeromuskip = 0mu +\newmuskip\onemuskip \onemuskip = 1mu \let\points \onepoint \let\halfpoint\halfapoint @@ -410,8 +435,8 @@ \def\doubleexpandafter{\expandafter\expandafter\expandafter} \def\tripleexpandafter{\expandafter\doubleexpandafter\expandafter} -%D We prefer the more readable variant than in plain -%D \TEX. User should only use \type {\emptybox}: +%D We prefer the more readable variant than in plain \TEX. User should only +%D use \type {\emptybox}: \newbox\voidbox % public @@ -425,8 +450,19 @@ \let\leavevmode\unvoidbox % we prefer to use \dontleavehmode -%D Some expected plain variants follow. We don't reuse registers -%D because we don't want clashes. +%D \macros +%D {dontcomplain} +%D +%D We need this one soon: + +\normalprotected\def\dontcomplain + {\hbadness\plustenthousand + \vbadness\plustenthousand + \hfuzz \maxdimen + \vfuzz \maxdimen} + +%D Some expected plain variants follow. We don't reuse registers because we +%D don't want clashes. \newdimen\p@ \p@ \onepoint \newcount\m@ne \m@ne \minusone @@ -440,8 +476,8 @@ \newbox \voidb@x \newtoks \toks@ -%D We define \type {\newif} a la plain \TEX, but will -%D redefine it later. As Knuth says: +%D We define \type {\newif} a la plain \TEX, but will redefine it later. As +%D Knuth says: %D %D \startnarrower %D And here's a different sort of allocation: for example, @@ -450,8 +486,7 @@ %D \newif\iffoo %D \stoptyping %D -%D creates \type {\footrue}, \type {\foofalse} to go -%D with \type {\iffoo}. +%D creates \type {\footrue}, \type {\foofalse} to go with \type {\iffoo}. %D \stopnarrower \normalprotected\def\newif#1% @@ -479,8 +514,16 @@ \ifdefined\htdp \else \def\htdp#1{\dimexpr\ht#1+\dp#1\relax} \fi -%D The catcode constants will be redefined in later catcode -%D related modules but they can be used in the same way. +%D A few shortcuts: + +\normalprotected\def\glet {\global \let } +\normalprotected\def\udef {\normalprotected\def } +\normalprotected\def\ugdef{\normalprotected\gdef} +\normalprotected\def\uedef{\normalprotected\edef} +\normalprotected\def\uxdef{\normalprotected\xdef} + +%D The catcode constants will be redefined in later catcode related modules +%D but they can be used in the same way. \chardef\escapecatcode = 0 \chardef\begingroupcatcode = 1 @@ -499,6 +542,11 @@ \chardef\commentcatcode = 14 \chardef\invalidcatcode = 15 +%D For a while we keep the following, as systems like tikz need it. Best +%D not use that one \CONTEXT. + +\let\active\activecatcode + %D Constants to be used with \type {\currentgrouptype}. \chardef\bottomlevelgroupcode = 0 @@ -527,13 +575,12 @@ \chardef\scrollmodecode = 2 \chardef\errorstopmodecode = 3 -%D Constants to be used with \type {\lastnodetype}. The \type -%D {\lastnodetype} primitive is \ETEX\ compliant. The valid range is -%D still -1 .. 15 and glyph nodes have number 0 (used to be char -%D node) and ligature nodes are mapped to 7. That way macro packages -%D can use the same symbolic names as in traditional \ETEX. Keep in -%D mind that the internal node numbers are different and that there -%D are more node types that 15. +%D Constants to be used with \type {\lastnodetype}. The \type {\lastnodetype} +%D primitive is \ETEX\ compliant. The valid range is still -1 .. 15 and glyph nodes +%D have number 0 (used to be char node) and ligature nodes are mapped to 7. That way +%D macro packages can use the same symbolic names as in traditional \ETEX. Keep in +%D mind that the internal node numbers are different and that there are more node +%D types that 15. \chardef\charnodecode = 0 \chardef\hlistnodecode = 1 @@ -552,8 +599,8 @@ \chardef\unsetnodecode = 14 \chardef\mathsnodecode = 15 -%D Constants to be used with \type {\currentiftype}. I wonder if -%D we will ever use these in \CONTEXT. +%D Constants to be used with \type {\currentiftype}. I wonder if we will ever +%D use these in \CONTEXT. \chardef\charifcode = 1 \chardef\catifcode = 2 @@ -576,11 +623,11 @@ \chardef\csnameifcode = 19 \chardef\fontcharifcode = 20 -%D Of course we want even bigger log files, so we copied this -%D from the \ETEX\ source files. +%D Of course we want even bigger log files, so we copied this from the \ETEX\ +%D source files. %D -%D When watching such logs, beware of nasty side effects of -%D \type {\scantokens}, as in: +%D When watching such logs, beware of nasty side effects of \type {\scantokens}, +%D as in: %D %D \starttyping %D \bgroup @@ -641,14 +688,13 @@ \ifdefined\normalinput \else \let\normalinput\input \fi -%D We don't like outer commands, and we always want access -%D to the original \type {\input} primitive. +%D We don't like outer commands, and we always want access to the original +%D \type {\input} primitive. \let\normalouter\outer \def\outer{} % no longer \relax -%D To circumvent dependencies, we can postpone certain -%D initializations to dumping time, by appending them to the -%D \type {\everydump} token register. +%D To circumvent dependencies, we can postpone certain initializations to +%D dumping time, by appending them to the \type {\everydump} token register. \ifdefined\normaldump \else \let\normaldump\dump \fi @@ -669,11 +715,10 @@ %D settrue, setfalse, %D ifconditional,then} %D -%D \TEX's lacks boolean variables, although the \PLAIN\ format -%D implements \type{\newif}. The main disadvantage of this -%D scheme is that it takes three hash table entries. A more -%D memory saving alternative is presented here. A conditional -%D is defined by: +%D \TEX's lacks boolean variables, although the \PLAIN\ format implements \type +%D {\newif}. The main disadvantage of this scheme is that it takes three hash table +%D entries. A more memory saving alternative is presented here. A conditional is +%D defined by: %D %D \starttyping %D \newconditional\doublesided @@ -699,9 +744,8 @@ %D \def\setfalse#1{\let#1=\iffalse} %D \stoptyping %D -%D Such an implementation gives problems with nested -%D conditionals. The next implementation is about as fast -%D and just as straightforward: +%D Such an implementation gives problems with nested conditionals. The next +%D implementation is about as fast and just as straightforward: \let\conditionalfalse\plusone % maybe we will have a dedicated count/chardef \let\conditionaltrue \zerocount % maybe we will have a dedicated count/chardef @@ -717,8 +761,8 @@ %D \macros %D {newmacro,setnewmacro,newfraction} %D -%D Let's be complete and also introduce some definers. These are -%D not mandate but handy for grepping. +%D Let's be complete and also introduce some definers. These are not mandate +%D but handy for grepping. \normalprotected\def\newmacro #1{\let#1\empty} \normalprotected\def\setnewmacro#1{\let#1} @@ -727,17 +771,15 @@ \normalprotected\def\newfraction#1{\let#1\!!plusone} -%D It would be handy to have a primitive \unless\ifcase because -%D then we could use nicer values. Anyhow, this conditional code -%D used to be in the \type {syst-aux} module but is now promoted -%D to here. +%D It would be handy to have a primitive \unless\ifcase because then we could +%D use nicer values. Anyhow, this conditional code used to be in the \type +%D {syst-aux} module but is now promoted to here. %D \macros %D {ifzeropt} %D -%D The next macro is both cosmetic and byte saving. It is -%D pretty \type{\if}||safe too. It can be used in cases -%D like: +%D The next macro is both cosmetic and byte saving. It is pretty \type +%D {\if}||safe too. It can be used in cases like: %D %D \starttyping %D \ifzeropt \somedimen ... \else ... \fi @@ -785,7 +827,23 @@ \def\begcsname#1\endcsname{\ifcsname#1\endcsname\csname#1\endcsname\fi} -%D Now come a few macros that might be needed in successive loading: +%D Now come a few macros that might be needed in successive loading. We redefine the +%D \type {\par} primitive pretty soon so that we get the equivalents right. + +% too tricky: \par is use more often than a par starts so we have too much change +% that we get assymetrical behaviour +% +% \newtoks\everyendpar +% +% \normalprotected\def\endpar{\the\everyendpar\normalpar} +% \normalprotected\def\par {\endpar} +% +% \normalprotected\def\reseteverypar +% {\everypar \emptytoks +% \everyendpar\emptytoks} + +\normalprotected\def\reseteverypar + {\everypar\emptytoks} \let\endgraf\par \let\endline\cr @@ -794,9 +852,8 @@ \def\empty{} \def\null {\hbox{}} -%D The following two might be overloaded later on but some modules need -%D then earlier. These functionality is reflected in the name and will not -%D change. +%D The following two might be overloaded later on but some modules need then +%D earlier. These functionality is reflected in the name and will not change. \bgroup \catcode`\^^M=\activecatcode% @@ -813,16 +870,15 @@ \let\endoflinetoken=^^M -%D Also needed might be a simple loop structure and we borrow -%D plain \TEX's one as it is often expected to be present and -%D it is about the fastest you can get. Beware: this macro -%D does not support nested loops. We use a namespace prefix -%D \type {@@pln}. +%D Also needed might be a simple loop structure and we borrow plain \TEX's one +%D as it is often expected to be present and it is about the fastest you can +%D get. Beware: this macro does not support nested loops. We use a namespace +%D prefix \type {@@pln}. \long\def\loop#1\repeat{\long\def\@@plnbody{#1}\@@plniterate} % might go -%D The following makes \type {\loop} \unknown\ \type {\if} -%D \unknown\ \type {\repeat} skippable (clever trick): +%D The following makes \type {\loop} \unknown\ \type {\if} \unknown\ \type +%D {\repeat} skippable (clever trick): \let\repeat\fi % so both \loop and \repeat are reserved words! @@ -842,23 +898,22 @@ \def\@@plniterate{\@@plnbody\expandafter\@@plniterate\else\fi} -%D We don't define a real output routine yet but at least get rid -%D of pages: +%D We don't define a real output routine yet but at least get rid of pages: \output{\shipout\box\normalpagebox} -%D Although we don't add pagenumbers yet we alias the default -%D register used for counting pages: +%D Although we don't add pagenumbers yet we alias the default register used +%D for counting pages: \countdef\pageno=0 \pageno=1 % first page is number 1 -%D Beside the raw counter \type {\pageno} the \type {\folio} -%D macro provides the value. +%D Beside the raw counter \type {\pageno} the \type {\folio} macro provides +%D the value. \def\folio{\the\pageno} % kind of expected and therefore reserved -%D The following registers are kind of standard and (for the moment) -%D we define them here. This might change. +%D The following registers are kind of standard and (for the moment) we define +%D them here. This might change. \newskip \bigskipamount \bigskipamount = 12pt plus 4pt minus 4pt \newskip \medskipamount \medskipamount = 6pt plus 2pt minus 2pt @@ -893,9 +948,8 @@ \spanomit \advance\mscount\minusone \repeat} -%D The next section deals with selective definitions in -%D later modules. One can of course use the \type {\texengine} -%D number that we defined earlier instead. +%D The next section deals with selective definitions in later modules. One can of +%D course use the \type {\texengine} number that we defined earlier instead. \bgroup \obeylines \gdef\pickupSOMETEX#1% @@ -927,19 +981,19 @@ \fi %D \macros -%D {bindprimitive} +%D {bindprimitive} %D -%D We can remap primitives (which is needed because of changes in -%D for instance \PDFTEX). +%D We can remap primitives (which is needed because of changes in for instance +%D \PDFTEX). \def\bindprimitive#1 #2 % new old {\ifcsname#1\endcsname \else \ifcsname#2\endcsname \expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname \fi \fi} -%D Because \XETEX\ also implements some \PDFTEX\ functionality, we take -%D care of this here instead of a dedicated module. Later modules need -%D to handle the undefined cases. +%D Because \XETEX\ also implements some \PDFTEX\ functionality, we take care of this +%D here instead of a dedicated module. Later modules need to handle the undefined +%D cases. %D These messy checks will disappear. @@ -997,8 +1051,8 @@ \newif\ifproductionrun -%D We need to make sure that we start up in \DVI\ mode, so, -%D after testing for running \PDFTEX, we default to \DVI. +%D We need to make sure that we start up in \DVI\ mode, so, after testing for running +%D \PDFTEX, we default to \DVI. \ifx\pdftexversion\undefined \newcount\pdfoutput \fi \pdfoutput=0 @@ -1044,15 +1098,14 @@ \let\synctex\undefined \newcount\synctex -%D We get rid of the funny \TEX\ offset defaults of one -%D inch by setting them to zero. +%D We get rid of the funny \TEX\ offset defaults of one inch by setting them to zero. -\voffset \zeropoint \newdimen\voffset % prevent messing up -\hoffset \zeropoint \newdimen\hoffset % prevent messing up +\voffset\zeropoint \let\voffset\relax \newdimen\voffset % prevent messing up +\hoffset\zeropoint \let\hoffset\relax \newdimen\hoffset % prevent messing up -%D While cleaning this code up a bit I was listening to Heather -%D Nova's \CD\ Redbird. The first song on that \CD\ ends with -%D a few lines suitable for ending this initialization module: +%D While cleaning this code up a bit I was listening to Heather Nova's \CD\ Redbird. +%D The first song on that \CD\ ends with a few lines suitable for ending this +%D initialization module: %D %D \startlines %D And there's so much I can do for you @@ -1065,7 +1118,6 @@ %D Come inside %D \stoplines %D -%D So let's see what \TEX\ can do now that we've opened up -%D the basic machinery. +%D So let's see what \TEX\ can do now that we've opened up the basic machinery. \protect \endinput |