diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/syst-aux.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/syst-aux.mkiv | 246 |
1 files changed, 175 insertions, 71 deletions
diff --git a/Master/texmf-dist/tex/context/base/syst-aux.mkiv b/Master/texmf-dist/tex/context/base/syst-aux.mkiv index 995a0cb6e02..fcc1ee88f1e 100644 --- a/Master/texmf-dist/tex/context/base/syst-aux.mkiv +++ b/Master/texmf-dist/tex/context/base/syst-aux.mkiv @@ -428,6 +428,11 @@ \def\undefinevalue#1{\expandafter\let\csname#1\endcsname\undefined} \def\ignorevalue#1#2{\expandafter\let\csname#1\endcsname\empty} +\def\setuvalue #1{\normalprotected\expandafter \def\csname#1\endcsname} +\def\setuevalue #1{\normalprotected\expandafter\edef\csname#1\endcsname} +\def\setugvalue #1{\normalprotected\expandafter\gdef\csname#1\endcsname} +\def\setuxvalue #1{\normalprotected\expandafter\xdef\csname#1\endcsname} + %D \macros %D {globallet,glet} %D @@ -439,26 +444,19 @@ \def\globallet{\global\let} \let\glet\globallet %D \macros -%D {donottest,unexpanded} -%D -%D When expansion of a macro gives problems, we can precede it -%D by \type{\donottest}. It seems that protection is one of the -%D burdens of developers of packages, so maybe that's why in -%D \ETEX\ protection is solved in a more robust way. +%D {unexpanded} %D -%D Because we use thi smodule onl in \MKIV, we have removed the +%D Because we use this module only in \MKIV, we have removed the %D old protection code. %D %D \starttyping %D \unexpanded\def\somecommand{... ... ...} %D \stoptyping +%D +%D This overloads the \ETEX\ primitive but as we already had an \MKII\ +%D solution we keep the same name for a similar mechanism. -\let \donottest \firstofoneargument % we need to weed -\let \honorunexpanded \empty % we need to weed -\let \forceunexpanded \empty % we need to weed -\let \resetunexpanded \empty % we need to weed - -\let \unexpanded \normalprotected +\let\unexpanded\normalprotected %D \macros %D {doifundefined,doifdefined, @@ -623,8 +621,7 @@ \fi} %D \macros -%D {doif,doifelse,doifnot, -%D donottest} +%D {doif,doifelse,doifnot} %D %D Programming in \TEX\ differs from programming in procedural %D languages like \MODULA. This means that one --- well, let me @@ -641,9 +638,6 @@ %D \doifnot {string1} {string2} {...} %D \doifelse {string1} {string2} {then ...}{else ...} %D \stoptyping -%D -%D When expansion gives problems, we can precede the -%D troublemaker with \type{\donottest}. \long\def\doif#1#2% {\edef\!!stringa{#1}\edef\!!stringb{#2}% @@ -1120,6 +1114,15 @@ \def\processcommacommand[#1]% {\expandafter\processcommalist\expandafter[\normalexpanded{#1}]} +% \def\processcommacommand[#1]% +% {\edef\expandedcommacommand{#1% +% \ifx\expandedcommacommand\empty\else +% \doprocesscommacommand +% \fi} +% +% \def\doprocesscommacommand +% {\expandafter\processcommalist\expandafter[\expandedcommacommand]} + %D The argument to \type{\command} is not delimited. Because %D we often use \type{[]} as delimiters, we also have: %D @@ -1142,11 +1145,11 @@ %D %D Two more: -\long\def\startprocesscommalist[#1]#2\stopprocesscommalist +\long\unexpanded\def\startprocesscommalist[#1]#2\stopprocesscommalist {\long\def\currentcommalistcommand##1{\def\currentcommalistitem{##1}#2}% \processcommalist[#1]\currentcommalistcommand} -\long\def\startprocesscommacommand[#1]#2\stopprocesscommacommand +\long\unexpanded\def\startprocesscommacommand[#1]#2\stopprocesscommacommand {\long\def\currentcommalistcommand##1{\def\currentcommalistitem{##1}#2}% \normalexpanded{\noexpand\processcommacommand[#1]}\currentcommalistcommand} @@ -1779,6 +1782,7 @@ \def\getparameters {\dogetparameters\dosetvalue} \def\geteparameters {\dogetparameters\dosetevalue} \def\getgparameters {\dogetparameters\dosetgvalue} +\def\getxparameters {\dogetparameters\dosetxvalue} \def\forgetparameters{\dogetparameters\doignorevalue} \let\getexpandedparameters=\geteparameters @@ -1864,11 +1868,11 @@ \def\processassignmentcommand[#1]% {\normalexpanded{\noexpand\processassignmentlist[#1]}} -\long\def\startprocessassignmentlist[#1]#2\stopprocessassignmentlist +\long\unexpanded\def\startprocessassignmentlist[#1]#2\stopprocessassignmentlist {\long\def\currentassignmentlistcommand##1##2{\def\currentassignmentlistkey{##1}\def\currentassignmentlistvalue{##2}#2}% \processassignmentlist[#1]\currentassignmentlistcommand} -\long\def\startprocessassignmentcommand[#1]#2\stopprocessassignmentcommand +\long\unexpanded\def\startprocessassignmentcommand[#1]#2\stopprocessassignmentcommand {\long\def\currentassignmentlistcommand##1##2{\def\currentassignmentlistkey{##1}\def\currentassignmentlistvalue{##2}#2}% \normalexpanded{\noexpand\processassignmentlist[#1]}\currentassignmentlistcommand} @@ -1909,13 +1913,24 @@ \def\xdoget@n@parameters#1]% {\xprocesscommaitem#1,],\@relax@} +% \def\xdoget@e@parameters#1]% +% {\let\dosetnvalue\dosetvalue +% \let\dosetvalue\dosetevalue +% \let\p!doassign\p!e!doassign +% \xprocesscommaitem#1,],\@relax@ +% \let\p!doassign\p!n!doassign +% \let\dosetvalue\dosetnvalue +% \let\xdogetparameters\xdoget@n@parameters +% \let\currentvalue\empty} + \def\xdoget@e@parameters#1]% - {\let\dosetnvalue\dosetvalue - \let\dosetvalue\dosetevalue + {\let\dosetnvalue\setsomevalue + \let\setsomevalue\dosetevalue \let\p!doassign\p!e!doassign + \let\setsomevalue\dosetevalue \xprocesscommaitem#1,],\@relax@ \let\p!doassign\p!n!doassign - \let\dosetvalue\dosetnvalue + \let\setsomevalue\dosetnvalue \let\xdogetparameters\xdoget@n@parameters \let\currentvalue\empty} @@ -2137,7 +2152,7 @@ %D \def\dosetupsomething[#1][#2]% %D {... #1 ... #2 ...} %D -%D \def\setupsomething +%D \unexpanded\def\setupsomething %D {\dodoubleargument\dosetupsomething} %D \stoptyping %D @@ -2475,13 +2490,13 @@ \def\docomplexorsimpleempty#1% {\doifnextoptionalelse{\firstargumenttrue#1}{\firstargumentfalse#1[]}} -\def\definecomplexorsimple#1% +\unexpanded\def\definecomplexorsimple#1% {\unexpanded\edef#1% {\noexpand\docomplexorsimple \@EA\noexpand\csname\s!complex\strippedcsname#1\endcsname \@EA\noexpand\csname\s!simple \strippedcsname#1\endcsname}} -\def\definecomplexorsimpleempty#1% +\unexpanded\def\definecomplexorsimpleempty#1% {\unexpanded\edef#1% {\noexpand\docomplexorsimpleempty \@EA\noexpand\csname\s!complex\strippedcsname#1\endcsname}} @@ -2876,7 +2891,7 @@ %D Also new: -\def\define#1% +\unexpanded\def\define#1% {\ifdefined#1% \message{[\noexpand#1is already defined]}% \expandafter\def\expandafter\gobbleddefinition @@ -3116,8 +3131,8 @@ %D We cannot use the simple scheme: %D %D \starttyping -%D \def\settrue#1{\let#1=\iftrue} -%D \def\settrue#1{\let#1=\iffalse} +%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 @@ -3403,7 +3418,7 @@ %D for conditional errors. %D Krzysztof Leszczynski suggested to provide access to the level by -%D means of a \type {#1}. I decided to pass the more frquently used +%D means of a \type {#1}. I decided to pass the more frequently used %D level as \type {#1} and the less favoured depth as \type {#2}. The %D intended usage is: %D @@ -3431,6 +3446,15 @@ \global\@EA\let\csname\@@irecurse\recursedepth\endcsname\recurselevel \@EA\dodorecurse\@EA1\@EA{\number#1}} +\long\def\ydorecurse#1#2% + {\global\advance\outerrecurse \plusone + \global\@EA\let\csname\@@irecurse\recursedepth\endcsname\recurselevel + \let\recurselevel\!!plusone + \long\global\@EA\def\csname\@@arecurse\recursedepth\endcsname##1##2{#2}% + \expandrecursecontent + \@EA\let\@EA\recurselevel\csname\@@irecurse\recursedepth\endcsname + \global\advance\outerrecurse \minusone} + \long\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4 {\global\advance\outerrecurse \plusone \long\global\@EA\def\csname\@@arecurse\recursedepth\endcsname##1##2{#4}% @@ -3519,13 +3543,21 @@ \def\recurselevel{\number\fastrecursecounter}% \dodofastrecurse} +\def\resetrecurselevel{\let\recurselevel\!!zerocount} + \def\dodofastrecurse - {\ifnum\fastrecursecounter>\lastrecursecounter\else + {\ifnum\fastrecursecounter>\lastrecursecounter + % \resetrecurselevel % slows down + \else \fastrecursebody \advance\fastrecursecounter\steprecursecounter \expandafter\dodofastrecurse \fi} +% \appendtoks \resetrecurselevel \to \everydump + +\everydump\expandafter{\the\everydump\resetrecurselevel} + %D This alternative looks a bit different and uses a %D pseudo counter. When this macro is nested, we have to use %D different counters. This time we use keywords. @@ -3583,7 +3615,7 @@ \csname t\strippedcsname#1\endcsname} \def\newevery#1#2% - {\newtoks#1% we test for redefinition elsewhere + {\ifx#1\everypar\else\newtoks#1\fi% we test for redefinition elsewhere \ifx#2\relax\else\ifdefined#2\else \expandafter\newtoks\csname t\strippedcsname#1\endcsname \def#2{\dowithevery#1}% @@ -3965,7 +3997,7 @@ %D hard coded delimiter like in: %D %D \starttyping -%D \def\startcommand#1\stopcommand% +%D \unexpanded\def\startcommand#1\stopcommand% %D {... #1 ...} %D \stoptyping %D @@ -3986,7 +4018,7 @@ %D This means that: %D %D \starttyping -%D \def\starthello% +%D \unexpanded\def\starthello% %D {\grabuntil{stophello}\message} %D %D \starthello Hello world!\stophello @@ -4123,7 +4155,22 @@ \afterassignment\BeforeGroup \let\next=} -\long\def\HandleNoGroup#1#2% +% \long\def\HandleNoGroup#1#2% +% {\long\def\AfterGroup{#2\egroup}% +% \bgroup\aftergroup\AfterGroup#1} + +\def\HandleNoGroup % retrofit into mkii + {\ifnum\currentgrouptype=\@@semisimplegroup + \expandafter\HandleNoGroupA + \else + \expandafter\HandleNoGroupB + \fi} + +\long\def\HandleNoGroupA#1#2% + {\long\def\AfterGroup{#2\endgroup}% + \begingroup\aftergroup\AfterGroup#1} + +\long\def\HandleNoGroupB#1#2% {\long\def\AfterGroup{#2\egroup}% \bgroup\aftergroup\AfterGroup#1} @@ -4362,19 +4409,6 @@ %D a row. In both commands, the \type{n*} is optional. When this %D specification is missing, the command executes once. -% this one is obsolete: - -\def\dorepeat[#1]% - {\dodorepeat#1*\empty*\relax} - -\long\def\dodorepeat#1*#2#3*#4\relax - {\ifx#2\empty#1\else\dorecurse{#1}{#2#3}\fi} - -\def\repeater - {\recurselevel} - -% this one will be kept - \def\dorepeatwithcommand[#1]% {\dodorepeatwithcommand#1*\empty*\relax} @@ -4385,8 +4419,7 @@ {\ifx#2\empty % redundant but gives cleaner extensions #4{#1}% \else\ifnum#1<\zerocount - \bgroup\scratchcounter#1% - \normalexpanded{\egroup\noexpand\dorecurse{\number-\scratchcounter}}{#4{-#2#3}}% + \normalexpanded{\noexpand\dorecurse{\number-\number#1}}{#4{-#2#3}}% \else\ifx#2+% \dorecurse{#1}{#4{#3}}% \else @@ -5284,7 +5317,7 @@ %D \def\dodefinesomething[#1][#2]% %D {\getparameters[\??xx#1][#2]} %D -%D \def\definesomething% +%D \unexpanded\def\definesomething% %D {\dodoubleargumentwithset\dodefinesomething} %D \stoptyping %D @@ -5896,10 +5929,10 @@ \def\dostopglobaldefs {\globaldefs\ifcsname @gd@\the\globaldefs\endcsname\zerocount} -\def\startlocal {\dostartglobaldefs>-} -\def\stoplocal {\dostopglobaldefs} -\def\startglobal {\dostartglobaldefs<+} -\def\stopglobal {\dostopglobaldefs} +\unexpanded\def\startlocal {\dostartglobaldefs>-} +\unexpanded\def\stoplocal {\dostopglobaldefs} +\unexpanded\def\startglobal {\dostartglobaldefs<+} +\unexpanded\def\stopglobal {\dostopglobaldefs} %D \macros %D {twodigitrounding} @@ -5931,7 +5964,7 @@ %D Beware of verbatim, i.e. catcode changes. %D %D \starttyping -%D \def\starthans% +%D \unexpanded\def\starthans% %D {\processcontent{stophans}\test{\message{\test}\wait}} %D \stoptyping %D @@ -6118,12 +6151,16 @@ % better: push/pop -\def\startstrictinspectnextcharacter +\unexpanded\def\startstrictinspectnextcharacter {\let\inspectnextcharacter\strictinspectnextcharacter} -\def\stopstrictinspectnextcharacter +\unexpanded\def\stopstrictinspectnextcharacter {\let\inspectnextcharacter\normalinspectnextcharacter} +\def\strictdoifnextoptionalelse#1#2% + {\startstrictinspectnextcharacter + \doifnextcharelse[{\stopstrictinspectnextcharacter#1}{\stopstrictinspectnextcharacter#2}} + %D \macros %D {gobblespacetokens} %D @@ -6261,7 +6298,7 @@ \def\??dm{@@dm} % brrr -\def\definemeasure +\unexpanded\def\definemeasure {\dodoubleargument\dodefinemeasure} \def\dodefinemeasure[#1][#2]% @@ -6296,6 +6333,71 @@ \expandafter\thirdoffourarguments \fi} +%D Ok, here's another one, slower but seldom used. This one scans the text. +%D +%D \starttabulate[|Tc|Tc|] +%D \NC pt \NC \doifdimenstringelse {pt}{yes}{no} \NC \NR +%D \NC 12pt \NC \doifdimenstringelse {-12pt}{yes}{no} \NC \NR +%D \NC 1pt \NC \doifdimenstringelse {1pt}{yes}{no} \NC \NR +%D \NC 12pt \NC \doifdimenstringelse {12pt}{yes}{no} \NC \NR +%D \NC 12.0pt \NC \doifdimenstringelse {12.0pt}{yes}{no} \NC \NR +%D \NC -.12pt \NC \doifdimenstringelse {-.12pt}{yes}{no} \NC \NR +%D \NC .12pt \NC \doifdimenstringelse {.12pt}{yes}{no} \NC \NR +%D \NC -12pt \NC \doifdimenstringelse {-12pt}{yes}{no} \NC \NR +%D \NC -12.0pt \NC \doifdimenstringelse{-12.0pt}{yes}{no} \NC \NR +%D \NC big \NC \doifdimenstringelse {big}{yes}{no} \NC \NR +%D \NC 10 \NC \doifdimenstringelse {10}{yes}{no} \NC \NR +%D \NC 1 \NC \doifdimenstringelse {1}{yes}{no} \NC \NR +%D \stoptabulate + +\def\doifdimenstringelse#1{\normalexpanded{\noexpand\dodimenteststageone#1}\empty\empty]} + +\def\dodimenteststageone #1#2{\csname d!1!\ifcsname d!1!#2\endcsname#2\else x\fi\endcsname#2} +\def\dodimenteststagetwo #1#2{\csname d!2!\ifcsname d!2!#2\endcsname#2\else x\fi\endcsname#2} +\def\dodimenteststagethree #1]{\csname d!3!\ifcsname d!3!#1\endcsname#1\else x\fi\endcsname} + +\expandafter\let\csname d!1!x\endcsname\dodimenteststagethree +\expandafter\let\csname d!2!x\endcsname\dodimenteststagethree +\expandafter\let\csname d!3!x\endcsname\secondoftwoarguments + +\expandafter\let\csname d!1!.\endcsname\dodimenteststagetwo +\expandafter\let\csname d!1!,\endcsname\dodimenteststagetwo +\expandafter\let\csname d!1!1\endcsname\dodimenteststageone +\expandafter\let\csname d!1!2\endcsname\dodimenteststageone +\expandafter\let\csname d!1!3\endcsname\dodimenteststageone +\expandafter\let\csname d!1!4\endcsname\dodimenteststageone +\expandafter\let\csname d!1!5\endcsname\dodimenteststageone +\expandafter\let\csname d!1!6\endcsname\dodimenteststageone +\expandafter\let\csname d!1!7\endcsname\dodimenteststageone +\expandafter\let\csname d!1!8\endcsname\dodimenteststageone +\expandafter\let\csname d!1!9\endcsname\dodimenteststageone +\expandafter\let\csname d!1!0\endcsname\dodimenteststageone + +\expandafter\let\csname d!2!1\endcsname\dodimenteststagetwo +\expandafter\let\csname d!2!2\endcsname\dodimenteststagetwo +\expandafter\let\csname d!2!3\endcsname\dodimenteststagetwo +\expandafter\let\csname d!2!4\endcsname\dodimenteststagetwo +\expandafter\let\csname d!2!5\endcsname\dodimenteststagetwo +\expandafter\let\csname d!2!6\endcsname\dodimenteststagetwo +\expandafter\let\csname d!2!7\endcsname\dodimenteststagetwo +\expandafter\let\csname d!2!8\endcsname\dodimenteststagetwo +\expandafter\let\csname d!2!9\endcsname\dodimenteststagetwo +\expandafter\let\csname d!2!0\endcsname\dodimenteststagetwo + +\expandafter\let\csname d!3!pt\endcsname\firstoftwoarguments +\expandafter\let\csname d!3!pc\endcsname\firstoftwoarguments +\expandafter\let\csname d!3!in\endcsname\firstoftwoarguments +\expandafter\let\csname d!3!bp\endcsname\firstoftwoarguments +\expandafter\let\csname d!3!cm\endcsname\firstoftwoarguments +\expandafter\let\csname d!3!mm\endcsname\firstoftwoarguments +\expandafter\let\csname d!3!dd\endcsname\firstoftwoarguments +\expandafter\let\csname d!3!cc\endcsname\firstoftwoarguments +\expandafter\let\csname d!3!sp\endcsname\firstoftwoarguments +\expandafter\let\csname d!3!ex\endcsname\firstoftwoarguments +\expandafter\let\csname d!3!em\endcsname\firstoftwoarguments +\expandafter\let\csname d!3!nd\endcsname\firstoftwoarguments +\expandafter\let\csname d!3!nc\endcsname\firstoftwoarguments + %D \macros %D {comparedimension,comparedimensioneps} %D @@ -6501,10 +6603,15 @@ % awaiting the definitive implementation -\ifdefined\resettimer \else - \let\resettimer \relax - \newcount\elapsedtime -\fi +% \ifdefined\resettimer \else +% \let\resettimer \relax +% \newcount\elapsedtime +% \fi +% \def\elapsedseconds{\expandafter\withoutpt\the\dimexpr\elapsedtime sp\relax} + +\def\resettimer {\ctxlua{commands.resettimer()}} +\def\elapsedtime {\ctxlua{commands.elapsedtime()}} +\let\elapsedseconds \elapsedtime \newcount\featuretest @@ -6524,8 +6631,6 @@ \wait \egroup} -\def\elapsedseconds{\expandafter\withoutpt\the\dimexpr\elapsedtime sp\relax} - \def\showtimer#1% {\writestatus{runtime}{\elapsedseconds\space s / #1}} @@ -6781,8 +6886,7 @@ %D \stoptyping \def\stripstring#1% #1 is \cs - {\edef\cs{\ctxlua - {tex.sprint(tex.vrbcatcodes,string.strip(\!!bs\detokenize\expandafter{#1}\!!es))}}} + {\edef\cs{\ctxlua{tex.sprint(tex.vrbcatcodes,string.strip(\!!bs\detokenize\expandafter{#1}\!!es))}}} %D \macros %D {dowithrange} @@ -6864,11 +6968,11 @@ \newbox\nointerferencebox -\def\startnointerference % not even grouped ! +\unexpanded\def\startnointerference % not even grouped ! {\setbox\nointerferencebox\vbox \bgroup} -\def\stopnointerference +\unexpanded\def\stopnointerference {\egroup \setbox\nointerferencebox\emptybox} |