From 15995e10bfc68edf79970c4ea4fbb6678566c46e Mon Sep 17 00:00:00 2001 From: Mojca Miklavec Date: Mon, 14 May 2012 17:38:55 +0000 Subject: ConTeXt 2012.05.14 16:00 git-svn-id: svn://tug.org/texlive/trunk@26371 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/context/base/syst-ini.mkiv | 598 ++++++++++++++--------- 1 file changed, 368 insertions(+), 230 deletions(-) (limited to 'Master/texmf-dist/tex/context/base/syst-ini.mkiv') diff --git a/Master/texmf-dist/tex/context/base/syst-ini.mkiv b/Master/texmf-dist/tex/context/base/syst-ini.mkiv index 18388fa2100..983bedc52a7 100644 --- a/Master/texmf-dist/tex/context/base/syst-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/syst-ini.mkiv @@ -5,7 +5,7 @@ %D subtitle=Bootstrapping \TEX, %D author=Hans Hagen, %D date=\currentdate, -%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] %C %C This module is part of the \CONTEXT\ macro||package and is %C therefore copyrighted by \PRAGMA. See mreadme.pdf for @@ -50,8 +50,6 @@ %....... %catcode`\z = 11 -\chardef\activecatcode = 13 % later this will become a counter - \def ^^L{\par} \def\^^M{\ } % control = control \def\^^I{\ } % same for @@ -92,8 +90,6 @@ \expandafter\end \fi -% todo: pdfsave pdfrestore pdfcolor... don't initialize them - \ifnum\texengine=\luatexengine \directlua 0 { % this info is stored in the format lua.name[0] = "main ctx instance" @@ -126,14 +122,25 @@ \long\def\gobbleoneargument#1{} % will be defined later on anyway -\mathchardef\etexversion = - \numexpr\eTeXversion*100+\expandafter\gobbleoneargument\eTeXrevision\relax +\mathchardef\etexversion = \numexpr\eTeXversion*100+\expandafter\gobbleoneargument\eTeXrevision\relax %D First we define a simplified version of the \CONTEXT\ -%D protection mechanism. - -\def\unprotect{\catcode`@=11 } -\def\protect {\catcode`@=12 } +%D protection mechanism. Later we will implement a better +%D variant. + +\def\unprotect + {\edef\protect + {\catcode`@=\the\catcode`@\relax + \catcode`?=\the\catcode`?\relax + \catcode`!=\the\catcode`!\relax + \catcode`_=\the\catcode`_\relax + \let\protect\relax}% + \catcode`@=11 + \catcode`?=11 + \catcode`!=11 + \catcode`_=11 } + +\let\protect\relax \unprotect @@ -163,52 +170,47 @@ % 255 : page % 256 - : user -\countdef \minallocatedregister = 52 \minallocatedregister = 256 % can change -\countdef \maxallocatedregister = 53 \maxallocatedregister = 32767 -\countdef \minallocatediochannel = 54 \minallocatediochannel = -1 -\countdef \maxallocatediochannel = 55 \maxallocatediochannel = 16 -\countdef \minallocatedlanguage = 56 \minallocatedlanguage = 0 -\countdef \maxallocatedlanguage = 57 \maxallocatedlanguage = 255 -\countdef \maxallocatedinsert = 58 \maxallocatedinsert = 254 -\countdef \minallocatedinsert = 59 \minallocatedinsert = 128 -\countdef \minallocatedfamily = 60 \minallocatedfamily = 128 -\countdef \maxallocatedfamily = 61 \maxallocatedfamily = 255 -\countdef \minallocatedattribute = 62 \minallocatedattribute = 1024 % 127-1023 : private - -\countdef \lastallocatedcount = 32 \lastallocatedcount = \minallocatedregister -\countdef \lastallocateddimen = 33 \lastallocateddimen = \minallocatedregister -\countdef \lastallocatedskip = 34 \lastallocatedskip = \minallocatedregister -\countdef \lastallocatedmuskip = 35 \lastallocatedmuskip = \minallocatedregister -\countdef \lastallocatedbox = 36 \lastallocatedbox = \minallocatedregister -\countdef \lastallocatedtoks = 37 \lastallocatedtoks = \minallocatedregister -\countdef \lastallocatedread = 38 \lastallocatedread = \minallocatediochannel -\countdef \lastallocatedwrite = 39 \lastallocatedwrite = \minallocatediochannel -\countdef \lastallocatedmarks = 40 \lastallocatedmarks = \minallocatedregister -\countdef \lastallocatedlanguage = 41 \lastallocatedlanguage = \minallocatedlanguage % not used in context -\countdef \lastallocatedinsertion = 42 \lastallocatedinsertion = \minallocatedinsert -\countdef \lastallocatedfamily = 43 \lastallocatedfamily = \minallocatedfamily % not used in context -\countdef \lastallocatedattribute = 44 \lastallocatedattribute = \minallocatedattribute - -\countdef \mincountervalue = 125 \mincountervalue = -"7FFFFFFF % beware, we use index 125 at the lua end -\countdef \maxcountervalue = 126 \maxcountervalue = "7FFFFFFF % beware, we use index 126 at the lua end - -%countdef \minusone = 127 \minusone = -1 -%chardef \zerocount = 0 -%chardef \plusone = 1 - -\countdef \zerocount = 120 \zerocount = 0 -\countdef \plusone = 121 \plusone = 1 -\countdef \minusone = 122 \minusone = -1 - -%chardef \normalpagebox = 255 -\countdef \normalpagebox = 127 \normalpagebox = 255 % hardcoded in pdftex/xetex - -% A few traditional allocations: - -\countdef \count@ = 255 % hm, used in \newif .. todo: replace it there -\dimendef \dimen@ = 0 -\dimendef \dimen@i = 1 % global only -\dimendef \dimen@ii = 2 +\countdef \c_syst_min_allocated_register = 52 \c_syst_min_allocated_register = 256 % can change +\countdef \c_syst_max_allocated_register = 53 \c_syst_max_allocated_register = 32767 +\countdef \c_syst_min_allocated_iochannel = 54 \c_syst_min_allocated_iochannel = -1 +\countdef \c_syst_max_allocated_iochannel = 55 \c_syst_max_allocated_iochannel = 16 +\countdef \c_syst_min_allocated_language = 56 \c_syst_min_allocated_language = 0 +\countdef \c_syst_max_allocated_language = 57 \c_syst_max_allocated_language = 255 +\countdef \c_syst_max_allocated_insert = 58 \c_syst_max_allocated_insert = 254 +\countdef \c_syst_min_allocated_insert = 59 \c_syst_min_allocated_insert = 128 +\countdef \c_syst_min_allocated_family = 60 \c_syst_min_allocated_family = 128 +\countdef \c_syst_max_allocated_family = 61 \c_syst_max_allocated_family = 255 +\countdef \c_syst_min_allocated_attribute = 62 \c_syst_min_allocated_attribute = 1024 % 127-1023 : private + +\countdef \c_syst_last_allocated_count = 32 \c_syst_last_allocated_count = \c_syst_min_allocated_register +\countdef \c_syst_last_allocated_dimen = 33 \c_syst_last_allocated_dimen = \c_syst_min_allocated_register +\countdef \c_syst_last_allocated_skip = 34 \c_syst_last_allocated_skip = \c_syst_min_allocated_register +\countdef \c_syst_last_allocated_muskip = 35 \c_syst_last_allocated_muskip = \c_syst_min_allocated_register +\countdef \c_syst_last_allocated_box = 36 \c_syst_last_allocated_box = \c_syst_min_allocated_register +\countdef \c_syst_last_allocated_toks = 37 \c_syst_last_allocated_toks = \c_syst_min_allocated_register +\countdef \c_syst_last_allocated_read = 38 \c_syst_last_allocated_read = \c_syst_min_allocated_iochannel +\countdef \c_syst_last_allocated_write = 39 \c_syst_last_allocated_write = \c_syst_min_allocated_iochannel +\countdef \c_syst_last_allocated_marks = 40 \c_syst_last_allocated_marks = \c_syst_min_allocated_register +\countdef \c_syst_last_allocated_language = 41 \c_syst_last_allocated_language = \c_syst_min_allocated_language % not used in context +\countdef \c_syst_last_allocated_insertion = 42 \c_syst_last_allocated_insertion = \c_syst_min_allocated_insert +\countdef \c_syst_last_allocated_family = 43 \c_syst_last_allocated_family = \c_syst_min_allocated_family % not used in context +\countdef \c_syst_last_allocated_attribute = 44 \c_syst_last_allocated_attribute = \c_syst_min_allocated_attribute + +\countdef \c_syst_min_counter_value = 125 \c_syst_min_counter_value = -"7FFFFFFF % beware, we use index 125 at the lua end +\countdef \c_syst_max_counter_value = 126 \c_syst_max_counter_value = "7FFFFFFF % beware, we use index 126 at the lua end + +\countdef \zerocount = 120 \zerocount = 0 +\countdef \plusone = 121 \plusone = 1 +\countdef \minusone = 122 \minusone = -1 + +\countdef \normalpagebox = 127 \normalpagebox = 255 % hardcoded in pdftex/xetex + +% A few traditional allocations (these might go): + +\countdef \count@ = 255 % hm, used in \newif .. todo: replace it there +\dimendef \dimen@ = 0 +\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 @@ -216,33 +218,34 @@ %D scratch registers upto 31 without problem but all others are %D reserved. -\def\wlog#1{} % \def\wlog{\immediate\write\minusone} % write on log file (only) +\let\wlog\gobbleoneargument % Let's get rid of this one. %D The allocators share a common helper macro. -\def\newcount {\allocateregister\lastallocatedcount \count \countdef \maxallocatedregister} -\def\newdimen {\allocateregister\lastallocateddimen \dimen \dimendef \maxallocatedregister} -\def\newskip {\allocateregister\lastallocatedskip \skip \skipdef \maxallocatedregister} -\def\newmuskip {\allocateregister\lastallocatedmuskip \muskip \muskipdef \maxallocatedregister} -\def\newbox {\allocateregister\lastallocatedbox \box \mathchardef\maxallocatedregister} -\def\newtoks {\allocateregister\lastallocatedtoks \toks \toksdef \maxallocatedregister} -\def\newread {\allocateregister\lastallocatedread \read \chardef \maxallocatediochannel} -\def\newwrite {\allocateregister\lastallocatedwrite \write \chardef \maxallocatediochannel} -\def\newmarks {\allocateregister\lastallocatedmarks \marks \mathchardef\maxallocatedregister} -\def\newinsert {\allocateregister\lastallocatedinsertion\insert \chardef \maxallocatedinsert} +\normalprotected\def\newcount {\syst_basics_allocate\c_syst_last_allocated_count \count \countdef \c_syst_max_allocated_register} +\normalprotected\def\newdimen {\syst_basics_allocate\c_syst_last_allocated_dimen \dimen \dimendef \c_syst_max_allocated_register} +\normalprotected\def\newskip {\syst_basics_allocate\c_syst_last_allocated_skip \skip \skipdef \c_syst_max_allocated_register} +\normalprotected\def\newmuskip {\syst_basics_allocate\c_syst_last_allocated_muskip \muskip \muskipdef \c_syst_max_allocated_register} +\normalprotected\def\newbox {\syst_basics_allocate\c_syst_last_allocated_box \box \mathchardef\c_syst_max_allocated_register} +\normalprotected\def\newtoks {\syst_basics_allocate\c_syst_last_allocated_toks \toks \toksdef \c_syst_max_allocated_register} +\normalprotected\def\newread {\syst_basics_allocate\c_syst_last_allocated_read \read \chardef \c_syst_max_allocated_iochannel} +\normalprotected\def\newwrite {\syst_basics_allocate\c_syst_last_allocated_write \write \chardef \c_syst_max_allocated_iochannel} +\normalprotected\def\newmarks {\syst_basics_allocate\c_syst_last_allocated_marks \marks \mathchardef\c_syst_max_allocated_register} +\normalprotected\def\newinsert {\syst_basics_allocate\c_syst_last_allocated_insertion\insert \chardef \c_syst_max_allocated_insert} %D We don't need these in \CONTEXT: -\def\newlanguage{\allocateregister\lastallocatedlanguage \language\chardef \maxallocatedlanguage} -\def\newfamily {\allocateregister\lastallocatedfamily \fam \chardef \maxallocatedfamily} +\normalprotected\def\newlanguage{\syst_basics_allocate\c_syst_last_allocated_language \language\chardef \c_syst_max_allocated_language} +\normalprotected\def\newfamily {\syst_basics_allocate\c_syst_last_allocated_family \fam \chardef \c_syst_max_allocated_family} \let\newfam\newfamily % Watch out, for the moment we disable the check for already being defined % later we will revert this but first all chardefs must be replaced. -\def\newconstant #1{\ifdefined#1\let#1\undefined\fi\newcount#1} -\def\setnewconstant#1{\ifdefined#1\let#1\undefined\fi\newcount#1#1} % just a number +\normalprotected\def\newconstant #1{\ifdefined#1\let#1\undefined\fi\newcount#1} +\normalprotected\def\setnewconstant#1{\ifdefined#1\let#1\undefined\fi\newcount#1#1} % just a number +\normalprotected\def\setconstant {} % dummy, no checking, so it warns % maybe setconstant with check @@ -259,10 +262,10 @@ %D now provide many registers we removed all traces. \ifdefined\writestatus \else - \def\writestatus#1#2{\immediate\write16{#1: #2}} + \normalprotected\def\writestatus#1#2{\immediate\write16{#1: #2}} \fi -\def\allocateregisteryes#1#2#3#4#5% last class method max name +\def\syst_basics_allocate_yes#1#2#3#4#5% last class method max name {\ifnum#1<#4\relax \global\advance#1\plusone \global#3#5=#1\relax @@ -270,16 +273,16 @@ \writestatus{warning}{no room for \string#2\space \string#5\space (max: \number#4)}% \fi} -\def\allocateregisternop#1#2#3#4#5% last class method max name +\def\syst_basics_allocate_nop#1#2#3#4#5% last class method max name {\writestatus{warning}{\string#2 \string#5 is already defined (\string\relax\space it first)}} -\def\allocateregister#1#2#3#4#5% last class method max name +\def\syst_basics_allocate#1#2#3#4#5% last class method max name {\ifx#5\undefined - \expandafter\allocateregisteryes + \expandafter\syst_basics_allocate_yes \else\ifx#5\relax - \expandafter\expandafter\expandafter\allocateregisteryes + \expandafter\expandafter\expandafter\syst_basics_allocate_yes \else - \expandafter\expandafter\expandafter\allocateregisternop + \expandafter\expandafter\expandafter\syst_basics_allocate_nop \fi\fi #1#2#3#4#5} @@ -287,8 +290,8 @@ %D {\chardef} instead of the more limited \type {\mathchardef}. \ifnum\texengine>\pdftexengine - \def\newbox {\allocateregister\lastallocatedbox \box \chardef\maxallocatedregister} - \def\newmarks{\allocateregister\lastallocatedmarks\marks\chardef\maxallocatedregister} + \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 @@ -298,15 +301,16 @@ %D and should not be touched. \ifnum\texengine=\luatexengine - \let\attributeunsetvalue\mincountervalue % used to be \minusone - \def\newattribute{\allocateregister\minallocatedattribute\attribute\attributedef\maxallocatedregister} + \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. +%D It's a trick to trick to force strings. This macro is never used +%D in \CONTEXT. -\def\newhelp#1#2{\newtoks#1#1\expandafter{\csname#2\endcsname}} +\normalprotected\def\newhelp#1#2{\newtoks#1#1\expandafter{\csname#2\endcsname}} %D \macros %D {scratchcounter, @@ -317,12 +321,12 @@ %D We now define a few scratch registers, so that successive %D loads at least have some available. -\newcount \scratchcounter \newcount \globalscratchcounter -\newdimen \scratchdimen \newdimen \globalscratchdimen -\newskip \scratchskip \newskip \globalscratchskip -\newmuskip \scratchmuskip \newmuskip \globalscratchmuskip -\newtoks \scratchtoks \newtoks \globalscratchtoks -\newbox \scratchbox \newbox \globalscratchbox +\newcount \scratchcounter \newcount \globalscratchcounter +\newdimen \scratchdimen \newdimen \globalscratchdimen +\newskip \scratchskip \newskip \globalscratchskip +\newmuskip\scratchmuskip \newmuskip\globalscratchmuskip +\newtoks \scratchtoks \newtoks \globalscratchtoks +\newbox \scratchbox \newbox \globalscratchbox \newcount\scratchcounterone \newcount\scratchcountertwo \newcount\scratchcounterthree \newdimen \scratchdimenone \newdimen \scratchdimentwo \newdimen \scratchdimenthree @@ -331,17 +335,32 @@ \newtoks \scratchtoksone \newtoks \scratchtokstwo \newtoks \scratchtoksthree \newbox \scratchboxone \newbox \scratchboxtwo \newbox \scratchboxthree +%D \macros +%D {scratchwidth, scratchheight, scratchdepth, scratchoffset, scratchdistance} +%D +%D A few more scratch dimensions: + +\newdimen\scratchwidth +\newdimen\scratchheight +\newdimen\scratchdepth +\newdimen\scratchoffset +\newdimen\scratchdistance +\newdimen\scratchhsize +\newdimen\scratchvsize + %D More allocations: -\newskip \zeroskip \zeroskip = 0pt plus 0pt minus 0pt -\newdimen\zeropoint \zeropoint = 0pt -\newdimen\onepoint \onepoint = 1pt -\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 -\let\points\onepoint +\let\points \onepoint +\let\halfpoint\halfapoint \newtoks \emptytoks @@ -382,6 +401,15 @@ \newcount \maxcard \maxcard = 65536 % pdftex has less mathchars \fi +%D \macros +%D {doubleexpandafter,tripleexpandafter,expanded,startexpanded} +%D +%D A few handy shortcuts + +\let\singleexpandafter \expandafter +\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}: @@ -406,7 +434,7 @@ \let \@ne \plusone \let \tw@ \plustwo \let \thr@@ \plusthree -\let \sixt@@n \sixteen +\let \sixt@@n \plussixteen \let \@cclv \pluscclv \let \@cclvi \pluscclvi \newbox \voidb@x @@ -426,7 +454,7 @@ %D with \type {\iffoo}. %D \stopnarrower -\def\newif#1% +\normalprotected\def\newif#1% {\count@\escapechar \escapechar\minusone \expandafter\expandafter\expandafter\def\@if #1{true}{\let#1\iftrue }% @@ -451,62 +479,53 @@ \ifdefined\htdp \else \def\htdp#1{\dimexpr\ht#1+\dp#1\relax} \fi -%D \macros -%D {@@escape,@@begingroup,@@endgroup,@@mathshift,@@alignment, -%D @@endofline,@@parameter,@@superscript,@@subscript, -%D @@ignore,@@space,@@letter,@@other,@@active,@@comment} -%D -%D In \CONTEXT\ we sometimes manipulate the \CATCODES\ of certain -%D characters. Because we are not that good at remembering numbers, -%D we introduce some symbolic names. - -%D As we now have catc-* files, we also have more readable names but -%D We will keep the following around for a while. - -\chardef\@@escape = 0 -\chardef\@@begingroup = 1 -\chardef\@@endgroup = 2 -\chardef\@@mathshift = 3 -\chardef\@@alignment = 4 -\chardef\@@endofline = 5 -\chardef\@@parameter = 6 -\chardef\@@superscript = 7 -\chardef\@@subscript = 8 -\chardef\@@ignore = 9 -\chardef\@@space = 10 -\chardef\@@letter = 11 -\chardef\@@other = 12 -\chardef\@@active = 13 -\chardef\@@comment = 14 +%D The catcode constants will be redefined in later catcode +%D related modules but they can be used in the same way. + +\chardef\escapecatcode = 0 +\chardef\begingroupcatcode = 1 +\chardef\endgroupcatcode = 2 +\chardef\mathshiftcatcode = 3 +\chardef\alignmentcatcode = 4 +\chardef\endoflinecatcode = 5 +\chardef\parametercatcode = 6 +\chardef\superscriptcatcode = 7 +\chardef\subscriptcatcode = 8 +\chardef\ignorecatcode = 9 +\chardef\spacecatcode = 10 +\chardef\lettercatcode = 11 +\chardef\othercatcode = 12 +\chardef\activecatcode = 13 +\chardef\commentcatcode = 14 +\chardef\invalidcatcode = 15 %D Constants to be used with \type {\currentgrouptype}. -\chardef\@@bottomlevelgroup = 0 -\chardef\@@simplegroup = 1 -\chardef\@@hboxgroup = 2 -\chardef\@@adjustedhboxgroup = 3 -\chardef\@@vboxgroup = 4 -\chardef\@@vtopgroup = 5 -\chardef\@@aligngroup = 6 -\chardef\@@noaligngroup = 7 -\chardef\@@outputgroup = 8 -\chardef\@@mathgroup = 9 -\chardef\@@discretionarygroup = 10 -\chardef\@@insertgroup = 11 -\chardef\@@vcentergroup = 12 -\chardef\@@mathchoicegroup = 13 -\chardef\@@semisimplegroup = 14 -\chardef\@@mathshiftgroup = 15 -\chardef\@@mathleftgroup = 16 - -\chardef\@@vadjustgroup = \@@insertgroup +\chardef\bottomlevelgroupcode = 0 +\chardef\simplegroupcode = 1 +\chardef\hboxgroupcode = 2 +\chardef\adjustedhboxgroupcode = 3 +\chardef\vboxgroupcode = 4 +\chardef\vtopgroupcode = 5 +\chardef\aligngroupcode = 6 +\chardef\noaligngroupcode = 7 +\chardef\outputgroupcode = 8 +\chardef\mathgroupcode = 9 +\chardef\discretionarygroupcode = 10 +\chardef\insertgroupcode = 11 +\chardef\vcentergroupcode = 12 +\chardef\mathchoicegroupcode = 13 +\chardef\semisimplegroupcode = 14 +\chardef\mathshiftgroupcode = 15 +\chardef\mathleftgroupcode = 16 +\chardef\vadjustgroupcode = \insertgroupcode %D Constants to be used with \type {\interactionmode}. -\chardef\@@batchmode = 0 -\chardef\@@nonstopmode = 1 -\chardef\@@scrollmode = 2 -\chardef\@@errorstopmode = 3 +\chardef\batchmodecode = 0 +\chardef\nonstopmodecode = 1 +\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 @@ -516,45 +535,46 @@ %D mind that the internal node numbers are different and that there %D are more node types that 15. -\chardef\@@charnode = 0 -\chardef\@@hlistnode = 1 -\chardef\@@vlistnode = 2 -\chardef\@@rulenode = 3 -\chardef\@@insertnode = 4 -\chardef\@@marknode = 5 -\chardef\@@adjustnode = 6 -\chardef\@@ligaturenode = 7 -\chardef\@@discretionarynode = 8 -\chardef\@@whatsitnode = 9 -\chardef\@@mathnode = 10 -\chardef\@@gluenode = 11 -\chardef\@@kernnode = 12 -\chardef\@@penaltynode = 13 -\chardef\@@unsetnode = 14 -\chardef\@@mathsnode = 15 - -%D Constants to be used with \type {\currentiftype}. - -\chardef\@@charif = 1 -\chardef\@@catif = 2 -\chardef\@@numif = 3 -\chardef\@@dimif = 4 -\chardef\@@oddif = 5 -\chardef\@@vmodeif = 6 -\chardef\@@hmodeif = 7 -\chardef\@@mmodeif = 8 -\chardef\@@innerif = 9 -\chardef\@@voidif = 10 -\chardef\@@hboxif = 11 -\chardef\@@vboxif = 12 -\chardef\@@xif = 13 -\chardef\@@eofif = 14 -\chardef\@@trueif = 15 -\chardef\@@falseif = 16 -\chardef\@@caseif = 17 -\chardef\@@definedif = 18 -\chardef\@@csnameif = 19 -\chardef\@@fontcharif = 20 +\chardef\charnodecode = 0 +\chardef\hlistnodecode = 1 +\chardef\vlistnodecode = 2 +\chardef\rulenodecode = 3 +\chardef\insertnodecode = 4 +\chardef\marknodecode = 5 +\chardef\adjustnodecode = 6 +\chardef\ligaturenodecode = 7 +\chardef\discretionarynodecode = 8 +\chardef\whatsitnodecode = 9 +\chardef\mathnodecode = 10 +\chardef\gluenodecode = 11 +\chardef\kernnodecode = 12 +\chardef\penaltynodecode = 13 +\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. + +\chardef\charifcode = 1 +\chardef\catifcode = 2 +\chardef\numifcode = 3 +\chardef\dimifcode = 4 +\chardef\oddifcode = 5 +\chardef\vmodeifcode = 6 +\chardef\hmodeifcode = 7 +\chardef\mmodeifcode = 8 +\chardef\innerifcode = 9 +\chardef\voidifcode = 10 +\chardef\hboxifcode = 11 +\chardef\vboxifcode = 12 +\chardef\xifcode = 13 +\chardef\eofifcode = 14 +\chardef\trueifcode = 15 +\chardef\falseifcode = 16 +\chardef\caseifcode = 17 +\chardef\definedifcode = 18 +\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. @@ -572,7 +592,7 @@ %D %D In \LUATEX\ we have ways around this. -\def\tracingall +\normalprotected\def\tracingall {\tracingonline \plusone \tracingcommands \plusthree \tracingstats \plustwo @@ -591,11 +611,11 @@ \tracingassigns \plustwo \errorstopmode} -\def\loggingall +\normalprotected\def\loggingall {\tracingall \tracingonline \zerocount} -\def\tracingnone +\normalprotected\def\tracingnone {\tracingassigns \zerocount \tracingnesting \zerocount \tracingscantokens\zerocount @@ -644,11 +664,119 @@ \normaleveryjob{\the\everyjob} -\def\appendtotoks #1{\def\temp{#1}\afterassignment\doappendtotoks \scratchtoks=} -\def\prependtotoks#1{\def\temp{#1}\afterassignment\doprependtotoks\scratchtoks=} +%D \macros +%D {newconditional, +%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 +%D \starttyping +%D \newconditional\doublesided +%D \setfalse +%D \stoptyping +%D Setting a conditional is done by \type{\settrue} and +%D \type{\setfalse}: +%D +%D \starttyping +%D \settrue\doublesided +%D \setfalse +%D \stoptyping +%D while testing is accomplished by: +%D +%D \starttyping +%D \ifconditional\doublesided ... \else ... \fi +%D \setfalse +%D \stoptyping +%D We cannot use the simple scheme: +%D +%D \starttyping +%D \def\settrue #1{\let#1=\iftrue} +%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: + +\let\conditionalfalse\plusone % maybe we will have a dedicated count/chardef +\let\conditionaltrue \zerocount % maybe we will have a dedicated count/chardef + +\normalprotected\def\settrue #1{\let#1\conditionaltrue } +\normalprotected\def\setfalse#1{\let#1\conditionalfalse} -\def\doappendtotoks {\expandafter\expandafter\expandafter{\expandafter\the\expandafter\temp\the\scratchtoks}} -\def\doprependtotoks{\expandafter\expandafter\expandafter{\expandafter\the\expandafter\scratchtoks\the\temp}} +\let\newconditional\setfalse +\let\ifconditional \ifcase + +\let\then\relax % so that we can say: \ifnum1>2\then -) + +%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. + +\normalprotected\def\newmacro #1{\let#1\empty} +\normalprotected\def\setnewmacro#1{\let#1} + +\def\!!plusone{1} + +\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 \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 +%D \starttyping +%D \ifzeropt \somedimen ... \else ... \fi +%D \stoptyping + +\let\ifzeropt\ifcase + +% these token list helpers might move to syst-aux.mkiv +% +% we assume a \cs. not toks0 or so +% +% \normalprotected\def\appendtotoks #1#{\def\temp{#1}\afterassignment\doappendtotoks \scratchtoks=} +% \normalprotected\def\prependtotoks#1#{\def\temp{#1}\afterassignment\doprependtotoks\scratchtoks=} + +\newtoks\t_syst_toks_temp \let\m_syst_toks_temp\t_syst_toks_temp + +\normalprotected\def\appendtotoks #1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_append_l \t_syst_toks_temp=} +\normalprotected\def\prependtotoks#1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_prepend_l\t_syst_toks_temp=} + +% \def\syst_toks_append {\m_syst_toks_temp\expandafter\expandafter\expandafter{\expandafter\the\expandafter\m_syst_toks_temp\the\t_syst_toks_temp}}} +% \def\syst_toks_prepend{\m_syst_toks_temp\expandafter\expandafter\expandafter{\expandafter\the\expandafter\t_syst_toks_temp\the\m_syst_toks_temp}}} + +\normalprotected\def\globalappendtotoks #1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_append_g \t_syst_toks_temp=} +\normalprotected\def\globalprependtotoks#1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_prepend_g\t_syst_toks_temp=} + +\def\syst_toks_append_l {\normalexpanded{\m_syst_toks_temp{\the\m_syst_toks_temp\the\t_syst_toks_temp}}} +\def\syst_toks_prepend_l{\normalexpanded{\m_syst_toks_temp{\the\t_syst_toks_temp\the\m_syst_toks_temp}}} + +\def\syst_toks_append_g {\global\syst_toks_append_l } +\def\syst_toks_prepend_g{\global\syst_toks_prepend_l} + +\normalprotected\def\addtotoks #1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_add_l\let\next} +\normalprotected\def\globaladdtotoks#1{\let\m_syst_toks_temp#1\afterassignment\syst_toks_add_g\let\next} + +\def\syst_toks_add_l{\m_syst_toks_temp\expandafter\bgroup\the\m_syst_toks_temp} +\def\syst_toks_add_g{\global\syst_toks_add_l} + +\normalprotected\def\addtotokscs #1#2{#1{\the#1#2}} % saves a few bytes +\normalprotected\def\globaladdtotokscs#1#2{\global#1{\the#1#2}} % saves a few bytes %D \macros %D {begcsname} @@ -691,7 +819,7 @@ %D does not support nested loops. We use a namespace prefix %D \type {@@pln}. -\long\def\loop#1\repeat{\long\def\@@plnbody{#1}\@@plniterate} +\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): @@ -732,15 +860,15 @@ %D The following registers are kind of standard and (for the moment) %D we define them here. This might change. -\newskip \bigskipamount \bigskipamount = 12pt plus 4pt minus 4pt -\newskip \medskipamount \medskipamount = 6pt plus 2pt minus 2pt -\newskip \smallskipamount \smallskipamount = 3pt plus 1pt minus 1pt +\newskip \bigskipamount \bigskipamount = 12pt plus 4pt minus 4pt +\newskip \medskipamount \medskipamount = 6pt plus 2pt minus 2pt +\newskip \smallskipamount \smallskipamount = 3pt plus 1pt minus 1pt \baselineskip = 12pt \lineskip = 1pt \lineskiplimit = 0pt -%D Again a few kind-of-extensions the core: +%D Again a few kind-of-extensions the core: (might go away) \newskip \hideskip \hideskip = -1000pt plus 1fill \newskip \centering \centering = 0pt plus 1000pt minus 1000pt @@ -749,7 +877,7 @@ {\hskip\hideskip} \def\ialign % initialized \halign - {\everycr{}% + {\everycr\emptytoks \tabskip\zeroskip \halign} @@ -817,25 +945,25 @@ % new after 1.10, watch the change in prefix -\bindprimitive quitvmode ptexquitvmode -\bindprimitive noligatures ptexnoligatures -\bindprimitive setrandomseed ptexsetrandomseed -\bindprimitive uniformdeviate ptexuniformdeviate +% \bindprimitive quitvmode ptexquitvmode +% \bindprimitive noligatures ptexnoligatures +% \bindprimitive setrandomseed ptexsetrandomseed +% \bindprimitive uniformdeviate ptexuniformdeviate -\bindprimitive quitvmode pdfquitvmode -\bindprimitive noligatures pdfnoligatures -\bindprimitive setrandomseed pdfsetrandomseed -\bindprimitive uniformdeviate pdfuniformdeviate +% \bindprimitive quitvmode pdfquitvmode +% \bindprimitive noligatures pdfnoligatures +% \bindprimitive setrandomseed pdfsetrandomseed +% \bindprimitive uniformdeviate pdfuniformdeviate -\bindprimitive resettimer pdfresettimer -\bindprimitive elapsedtime pdfelapsedtime +% \bindprimitive resettimer pdfresettimer +% \bindprimitive elapsedtime pdfelapsedtime % new per 1.40 -\bindprimitive ifprimitive ifpdfprimitive -\bindprimitive primitive pdfprimitive -\bindprimitive ifabsdim ifpdfabsdim -\bindprimitive ifabsnum ifpdfabsnum +% \bindprimitive ifprimitive ifpdfprimitive +% \bindprimitive primitive pdfprimitive +% \bindprimitive ifabsdim ifpdfabsdim +% \bindprimitive ifabsnum ifpdfabsnum \ifnum\texengine=\xetexengine \else % this test might disappear some day @@ -846,9 +974,9 @@ \ifdefined\pdfgentounicode \else \newcount\pdfgentounicode \fi \pdfgentounicode \plusone \ifdefined\pdfinclusioncopyfonts\else \newcount\pdfinclusioncopyfonts \fi \pdfinclusioncopyfonts\plusone - \def\nopdfcompression {\pdfobjcompresslevel\zerocount \pdfcompresslevel\zerocount} - \def\maximumpdfcompression{\pdfobjcompresslevel\plusnine \pdfcompresslevel\plusnine } - \def\normalpdfcompression {\pdfobjcompresslevel\plusthree \pdfcompresslevel\plusthree} + \normalprotected\def\nopdfcompression {\pdfobjcompresslevel\zerocount \pdfcompresslevel\zerocount} + \normalprotected\def\maximumpdfcompression{\pdfobjcompresslevel\plusnine \pdfcompresslevel\plusnine } + \normalprotected\def\normalpdfcompression {\pdfobjcompresslevel\plusthree \pdfcompresslevel\plusthree} \normalpdfcompression @@ -879,12 +1007,12 @@ \ifx\fmtname \undefined \def\fmtname {ConTeXt Minimized Plain TeX} \fi \ifx\fmtversion\undefined \def\fmtversion{3.1415926} \fi -\let\normalfmtversion\fmtversion +\let\normalfmtversion\fmtversion % still needed ? %D A few bonus macros: \def\modulonumber#1#2{\the\numexpr#2-((((#2+(#1/2))/#1)-1)*#1)\relax} -\def\dividonumber#1#2{\the\numexpr(#2-(#1/2))/#1\relax} +\def\dividenumber#1#2{\the\numexpr(#2-(#1/2))/#1\relax} \ifnum\texengine=\xetexengine \edef\xetexversion {\numexpr\XeTeXversion*100+(\expandafter\gobbleoneargument\XeTeXrevision-5)/10\relax} @@ -892,26 +1020,36 @@ \fi \ifcase\texengine - \def\texenginename {impossible} + \def \texenginename {impossible} \edef\texengineversion{0} \or - \def\texenginename {pdfTeX} - \edef\texengineversion{\dividonumber{100}\pdftexversion.\modulonumber{100}\pdftexversion.\pdftexrevision} + \def \texenginename {pdfTeX} + \edef\texengineversion{\dividenumber{100}\pdftexversion.\modulonumber{100}\pdftexversion.\pdftexrevision} \or - \def\texenginename {XeTeX} - \edef\texengineversion{\dividonumber{100}\xetexversion .\modulonumber{100}\xetexversion .\xetexrevision} + \def \texenginename {XeTeX} + \edef\texengineversion{\dividenumber{100}\xetexversion .\modulonumber{100}\xetexversion .\xetexrevision} \or - \def\texenginename {LuaTeX} - \edef\texengineversion{\dividonumber{100}\luatexversion.\modulonumber{100}\luatexversion.\luatexrevision} + \def \texenginename {LuaTeX} + \edef\texengineversion{\dividenumber{100}\luatexversion.\modulonumber{100}\luatexversion.\luatexrevision} \else - \def\texenginename {impossible} + \def \texenginename {impossible} \edef\texengineversion{0} \fi +%D We have no reason not to enable this: + +\savingvdiscards\plusone + %D We only can set this one via directives (system.synctex). \let\synctex\undefined \newcount\synctex +%D We get rid of the funny \TEX\ offset defaults of one +%D inch by setting them to zero. + +\voffset \zeropoint \newdimen\voffset % prevent messing up +\hoffset \zeropoint \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: -- cgit v1.2.3