summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/syst-aux.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/syst-aux.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/syst-aux.mkiv1503
1 files changed, 895 insertions, 608 deletions
diff --git a/Master/texmf-dist/tex/context/base/syst-aux.mkiv b/Master/texmf-dist/tex/context/base/syst-aux.mkiv
index fcc1ee88f1e..d2bc84ae8bc 100644
--- a/Master/texmf-dist/tex/context/base/syst-aux.mkiv
+++ b/Master/texmf-dist/tex/context/base/syst-aux.mkiv
@@ -1,5 +1,5 @@
%D \module
-%D [ file=syst-gen,
+%D [ file=syst-aux, % merge of syst-gen cum suis
%D version=1996.03.20,
%D title=\CONTEXT\ System Macros,
%D subtitle=General,
@@ -37,7 +37,20 @@
\unprotect
-\let\reportprotectionstate\relax
+%D \macros
+%D {unexpanded}
+%D
+%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\unexpanded\normalprotected
%D \macros
%D {doifolderversionelse}
@@ -46,21 +59,15 @@
%D to use development versions of \MKIV\ for real documents.
%D
%D \starttyping
-%D \doifolderversionelse\contextversion{2001.02.03}{yes}{no}
-%D \doifolderversionelse\contextversion{3001.02.03}{yes}{no}
+%D \doifolderversionelse\contextversion{1010.10.10} {OLDER} {OKAY} => OLDER
+%D \doifolderversionelse\contextversion{2020.20.20} {OLDER} {OKAY} => OKAY
+%D \doifolderversionelse\contextversion{2020} {OLDER} {OKAY} => OKAY
%D \stoptyping
%D
-%D The \type {yyyy.mm.dd} syntax is rather strict.
+%D The version pattern is \type {yyyy.mm.dd} (with mm and dd being optional).
-\def\@@versiontonumber#1.#2.#3#4#5\relax
- {\numexpr#1*\plustenthousand+#2*\plushundred+#3#4\relax}
-
-\def\doifolderversionelse#1#2%
- {\normalexpanded{\noexpand\ifnum\noexpand\@@versiontonumber#1\relax<\noexpand\@@versiontonumber#2\relax}\relax
- \expandafter\firstoftwoarguments
- \else
- \expandafter\secondoftwoarguments
- \fi}
+\def\doifolderversionelse#1#2{\ctxcommand{doifolderversionelse("#1","#2")}}
+\def\doifoldercontextelse #1{\ctxcommand{doifolderversionelse("#1")}}
%D \macros
%D {normalspace}
@@ -107,6 +114,11 @@
\def\!!plustwo {2} % alongside \plustwo
\def\!!plusthree {3} % alongside \plusthree
+\setnewconstant\uprotationangle 0
+\setnewconstant\rightrotatioangle 90
+\setnewconstant\downrotatioangle 180
+\setnewconstant\leftrotatioangle 270
+
\ifdefined\data \else \let\data \relax \fi % dep checker
%D \macros
@@ -156,73 +168,26 @@
%D commalist or when data stored in macros is fed to index of
%D list commands. If needed, one should use \type{\noexpand}
%D inside the argument. Later on we will meet some more clever
-%D alternatives to this command.
+%D alternatives to this command. Beware, only the simple one
+%D has \type {\noexpand} before its argument.
-\long\def\@@expanded{} % always long; global (less restores)
+ \long\def\@@expanded{} % always long; global (less restores)
\long\def\expanded#1%
{\long\xdef\@@expanded{\noexpand#1}\@@expanded}
-%D Beware, the next one has no \type {\noexpand} before its
-%D argument.
-
\long\def\startexpanded#1\stopexpanded % see x-fo for example
{\long\xdef\@@expanded{#1}\@@expanded}
%D Recent \TEX's have a primitive \expanded
-% \long\def\expanded
-% {\normalexpanded\bgroup\noexpand\gobblenexttoken}
-
-%D \macros
-%D {safeexpanded,everysafeexpanded}
-%D
-%D In addition we provide:
-
-\newtoks\everysafeexpanded
-
-\long\def\safeexpanded#1% why the \noexpand
- {\begingroup
- \the\everysafeexpanded\long\xdef\@@expanded{\noexpand#1}%
- \endgroup
- \@@expanded}
-
-\def\safeedef#1#2%
- {\begingroup
- \the\everysafeexpanded\long\xdef\@@expanded{\noexpand#2}%
- \endgroup
- \let#1\@@expanded}
-
-\def\safexdef#1#2%
- {\begingroup
- \the\everysafeexpanded\long\xdef\@@expanded{\noexpand#2}%
- \endgroup
- \global\let#1\@@expanded}
-
-%D You can append protective measures to the token register if
-%D needed, as we will do later.
-
-%D \macros
-%D {expandoneargafter,expandtwoargsafter}
-%D
-%D These two commands make macros more readable by hiding a
-%D lot of \type {\expandafter}'s. They expand the arguments
-%D after the first command.
-%D
-%D \starttyping
-%D \expandoneargafter \command{\abc}
-%D \expandtwoargsafter\command{\abc}{\def}
-%D \stoptyping
-%D
-%D These commands expect the arguments to be macros.
-
-\def\expandoneargafter #1{\@EA#1\@EA}
-\def\expandtwoargsafter#1#2{\@EA\@EA\@EA#1\@EA\@EA\@EA{\@EA#2\@EA}\@EA}
-
-%D These two do a full expansion:
-
-\def\fullexpandoneargafter #1#2{\long\xdef\@@expanded{\noexpand#1{#2}}\@@expanded}
-\def\fullexpandtwoargsafter#1#2#3{\long\xdef\@@expanded{\noexpand#1{#2}{#3}}\@@expanded}
+% not yet as we need to adapt ##'s in calls
+%
+% \long\def\expanded#1%
+% {\normalexpanded{\noexpand#1}}
+%
+% \long\def\startexpanded#1\stopexpanded
+% {\normalexpanded{#1}}
%D \macros
%D {gobbleoneargument,gobble...arguments}
@@ -230,16 +195,22 @@
%D The next set of macros just do nothing, except that they
%D get rid of a number of arguments.
-\long\def\gobbleoneargument #1{}
-\long\def\gobbletwoarguments #1#2{}
-\long\def\gobblethreearguments #1#2#3{}
-\long\def\gobblefourarguments #1#2#3#4{}
-\long\def\gobblefivearguments #1#2#3#4#5{}
-\long\def\gobblesixarguments #1#2#3#4#5#6{}
-\long\def\gobblesevenarguments #1#2#3#4#5#6#7{}
-\long\def\gobbleeightarguments #1#2#3#4#5#6#7#8{}
-\long\def\gobbleninearguments #1#2#3#4#5#6#7#8#9{}
-\long\def\gobbletenarguments #1{\gobbleninearguments}
+\long\def\gobbleoneargument #1{}
+\long\def\gobbletwoarguments #1#2{}
+\long\def\gobblethreearguments#1#2#3{}
+\long\def\gobblefourarguments #1#2#3#4{}
+\long\def\gobblefivearguments #1#2#3#4#5{}
+\long\def\gobblesixarguments #1#2#3#4#5#6{}
+\long\def\gobblesevenarguments#1#2#3#4#5#6#7{}
+\long\def\gobbleeightarguments#1#2#3#4#5#6#7#8{}
+\long\def\gobbleninearguments #1#2#3#4#5#6#7#8#9{}
+\long\def\gobbletenarguments #1{\gobbleninearguments}
+
+\def\gobbleoneoptional [#1]{}
+\def\gobbletwooptionals [#1][#2]{}
+\def\gobblethreeoptionals[#1][#2][#3]{}
+\def\gobblefouroptionals [#1][#2][#3][#4]{}
+\def\gobblefiveoptionals [#1][#2][#3][#4][#5]{}
%D \macros
%D {doifnextcharelse}
@@ -278,6 +249,7 @@
\else
\@EA\inspectnextcharacterindeed
\fi}
+
\def\inspectnextcharacterindeed
{\ifx\nexttoken\charactertoken
\@EA\!!stringa
@@ -291,18 +263,23 @@
%D test in a run. Of course it also is more convenient to read a
%D trace then.
+\newif\ifnextblankspacetoken
+
\let\nextoptionalcharactertoken=[
\long\def\doifnextoptionalelse#1#2%
{\def\nextoptionalcommandyes{#1}%
\def\nextoptionalcommandnop{#2}%
+ \let\ifnextblankspacetoken\iffalse
\futurelet\nexttoken\inspectnextoptionalcharacter}
+
\def\inspectnextoptionalcharacter
{\ifx\nexttoken\blankspace
\@EA\reinspectnextoptionalcharacter
\else
\@EA\inspectnextoptionalcharacterindeed
\fi}
+
\def\inspectnextoptionalcharacterindeed
{\ifx\nexttoken\nextoptionalcharactertoken
\@EA\nextoptionalcommandyes
@@ -315,13 +292,16 @@
\long\def\doifnextbgroupelse#1#2%
{\def\nextbgroupcommandyes{#1}%
\def\nextbgroupcommandnop{#2}%
+ \let\ifnextblankspacetoken\iffalse
\futurelet\nexttoken\inspectnextbgroupcharacter}
+
\def\inspectnextbgroupcharacter
{\ifx\nexttoken\blankspace
\@EA\reinspectnextbgroupcharacter
\else
\@EA\inspectnextbgroupcharacterindeed
\fi}
+
\def\inspectnextbgroupcharacterindeed
{\ifx\nexttoken\nextbgroupcharactertoken
\@EA\nextbgroupcommandyes
@@ -334,13 +314,16 @@
\long\def\doifnextparenthesiselse#1#2%
{\def\nextparenthesiscommandyes{#1}%
\def\nextparenthesiscommandnop{#2}%
+ \let\ifnextblankspacetoken\iffalse
\futurelet\nexttoken\inspectnextparenthesischaracter}
+
\def\inspectnextparenthesischaracter
{\ifx\nexttoken\blankspace
\@EA\reinspectnextparenthesischaracter
\else
\@EA\inspectnextparenthesischaracterindeed
\fi}
+
\def\inspectnextparenthesischaracterindeed
{\ifx\nexttoken\nextparenthesischaractertoken
\@EA\nextparenthesiscommandyes
@@ -353,6 +336,7 @@
\long\def\doiffastoptionalcheckelse#1#2%
{\def\nextoptionalcommandyes{#1}%
\def\nextoptionalcommandnop{#2}%
+ \let\ifnextblankspacetoken\iffalse % not needed
\futurelet\nexttoken\dodoiffastoptionalcheckelse}
\def\dodoiffastoptionalcheckelse
@@ -382,13 +366,13 @@
\def\:{\let\blankspace= } \:
\def\:{\reinspectnextcharacter}
-\expandafter\def\: {\futurelet\nexttoken\inspectnextcharacter}
+\expandafter\def\: {\let\ifnextblankspacetoken\iftrue\futurelet\nexttoken\inspectnextcharacter}
\def\:{\reinspectnextoptionalcharacter}
-\expandafter\def\: {\futurelet\nexttoken\inspectnextoptionalcharacter}
+\expandafter\def\: {\let\ifnextblankspacetoken\iftrue\futurelet\nexttoken\inspectnextoptionalcharacter}
\def\:{\reinspectnextbgroupcharacter}
-\expandafter\def\: {\futurelet\nexttoken\inspectnextbgroupcharacter}
+\expandafter\def\: {\let\ifnextblankspacetoken\iftrue\futurelet\nexttoken\inspectnextbgroupcharacter}
\let\:\next
@@ -444,21 +428,6 @@
\def\globallet{\global\let} \let\glet\globallet
%D \macros
-%D {unexpanded}
-%D
-%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\unexpanded\normalprotected
-
-%D \macros
%D {doifundefined,doifdefined,
%D doifundefinedelse,doifdefinedelse,
%D doifalldefinedelse}
@@ -491,44 +460,10 @@
%D \ifundefined\NameB ... \else ... \fi
%D \stoptyping
-\def\ifundefined#1% ongelukkige naam .. obsolete
- {\unless\ifcsname#1\endcsname}
-
-% \def\p!doifundefined#1%
-% {\edef\p!defined{#1}%
-% \unless\ifcsname\detokenize\@EA{\p!defined}\endcsname}
-
-% \def\doifundefinedelse#1%
-% {\edef\p!defined{#1}%
-% \ifcsname\detokenize\@EA{\p!defined}\endcsname
-% \expandafter\secondoftwoarguments
-% \else
-% \expandafter\firstoftwoarguments
-% \fi}
-
-% \def\doifdefinedelse#1%
-% {\edef\p!defined{#1}%
-% \ifcsname\detokenize\@EA{\p!defined}\endcsname
-% \expandafter\firstoftwoarguments
-% \else
-% \expandafter\secondoftwoarguments
-% \fi}
-
-% \def\doifundefined#1%
-% {\edef\p!defined{#1}%
-% \ifcsname\detokenize\@EA{\p!defined}\endcsname
-% \expandafter\gobbleoneargument
-% \else
-% \expandafter\firstofoneargument
-% \fi}
-
-% \def\doifdefined#1%
-% {\edef\p!defined{#1}%
-% \ifcsname\detokenize\@EA{\p!defined}\endcsname
-% \expandafter\firstofoneargument
-% \else
-% \expandafter\gobbleoneargument
-% \fi}
+% \def\ifundefined#1% obsolete
+% {\unless\ifcsname#1\endcsname}
+%
+% use a real if like \ifcsname#1\endcsname\else instead
\ifdefined\suppressifcsnameerror
@@ -757,6 +692,7 @@
\else
\expandafter\dodoifinsetelse
\fi}
+
\long\def\dodoifinsetelse#1%
{\edef\!!stringb{#1}%
\ifx\!!stringb\empty
@@ -772,6 +708,7 @@
\else
\expandafter\dodoifinset
\fi}
+
\long\def\dodoifinset#1%
{\edef\!!stringb{#1}%
\ifx\!!stringb\empty
@@ -787,6 +724,7 @@
\else
\expandafter\dodoifnotinset
\fi}
+
\long\def\dodoifnotinset#1%
{\edef\!!stringb{#1}%
\ifx\!!stringb\empty
@@ -802,12 +740,14 @@
\else
\expandafter\dodocheckifiteminsetelse
\fi#2}
+
\def\dodocheckifiteminsetelse
{\ifx\!!stringb\rightoptionalbracket
\expandafter\thirdofthreearguments
\else
\expandafter\dododocheckifiteminsetelse
\fi}
+
\def\dododocheckifiteminsetelse
{\ifx\!!stringa\!!stringb
\expandafter\doquitifiteminsetelse
@@ -822,12 +762,14 @@
\else
\expandafter\dodocheckifiteminset
\fi#2}
+
\def\dodocheckifiteminset
{\ifx\!!stringb\rightoptionalbracket
\expandafter\gobbletwoarguments
\else
\expandafter\dododocheckifiteminset
\fi}
+
\def\dododocheckifiteminset
{\ifx\!!stringa\!!stringb
\expandafter\doquitifiteminset
@@ -842,12 +784,14 @@
\else
\expandafter\dodocheckifitemnotinset
\fi#2}
+
\def\dodocheckifitemnotinset
{\ifx\!!stringb\rightoptionalbracket
\expandafter\secondoftwoarguments
\else
\expandafter\dododocheckifitemnotinset
\fi}
+
\def\dododocheckifitemnotinset
{\ifx\!!stringa\!!stringb
\expandafter\doquitifitemnotinset
@@ -883,21 +827,6 @@
% !9yes=\doifcommonelse{,a,}{,,,a,}{yes}{nop}
% !9yes=\doifcommonelse{,,a,}{,,,a,}{yes}{nop}
-% \def\p!doifcommonelse#1#2#3#4%
-% {\donefalse
-% \def\p!docommoncheck##1{\doifinset{##1}{#4}\donetrue\ifdone\quitcommalist\fi}%
-% \processcommalist[#3]\p!docommoncheck
-% \ifdone\expandafter#1\else\expandafter#2\fi}
-%
-% \def\doifcommonelse
-% {\p!doifcommonelse\firstoftwoarguments\secondoftwoarguments}
-%
-% \def\doifcommon
-% {\p!doifcommonelse\firstofoneargument \gobbleoneargument}
-%
-% \def\doifnotcommon
-% {\p!doifcommonelse\gobbleoneargument \firstofoneargument}
-
\long\def\doquitifcommonelse#1],\relax#2],\relax{\firstoftwoarguments}
\long\def\doquitifcommonelsenop{\secondoftwoarguments}
@@ -946,23 +875,6 @@
\fi\fi
#1#2}
-% \def\p!doifcommonelse#1#2#3%
-% {\edef\!!stringa{#3}%
-% \ifx\!!stringa\empty
-% \expandafter\secondofthreearguments
-% \else
-% \expandafter\p!dodoifcommonelse
-% \fi
-% #1#2} % #4
-
-% \def\p!dodoifcommonelse#1#2#3%
-% {\edef\!!stringb{#3}%
-% \ifx\!!stringb\empty
-% \expandafter\secondoftwoarguments
-% \else
-% \expandafter\pp!doifcommonelse
-% \fi#1#2}
-
\def\pp!doifcommonelse
{\def\p!docommoncheck{\expandafter\docheckifcommonelsetwo\!!stringb,],\relax}%
\expandafter\docheckifcommonelseone\!!stringa,],\relax}
@@ -1008,21 +920,13 @@
\def\dododoprocesscommaitem
{\csname\s!next\the\commalevel\endcsname}
-% \def\dodoprocesscommaitem
-% {\ifx\nexttoken\blankspace
-% \@EA\redoprocesscommaitem
-% \else\ifx\nexttoken]%
-% \@EAEAEA\gobbleoneargument
-% \else
-% \@EAEAEA\dododoprocesscommaitem
-% \fi\fi}
-
\def\dodoprocesscommaitem
{\ifx\nexttoken\blankspace
\@EA\redoprocesscommaitem
\else
\@EA\dodoprocesscommaitemindeed
\fi}
+
\def\dodoprocesscommaitemindeed
{\ifx\nexttoken]%
\@EA\gobbleoneargument
@@ -1037,7 +941,7 @@
%D however are treated. We have to check for the special case
%D \type{[{a,b,c}]}.
-\def\processcommalist[%
+\unexpanded\def\processcommalist[%
{\futurelet\nexttoken\docheckcommaitem}
\def\docheckcommaitem
@@ -1108,20 +1012,8 @@
%D Commands that are part of the list are expanded, so the
%D use of this macro has its limits.
-% \def\processcommacommand[#1]%
-% {\expanded{\processcommalist[#1]}}
-
-\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]}
+\unexpanded\def\processcommacommand[#1]%
+ {\normalexpanded{\processcommalist[#1]}}
%D The argument to \type{\command} is not delimited. Because
%D we often use \type{[]} as delimiters, we also have:
@@ -1151,7 +1043,7 @@
\long\unexpanded\def\startprocesscommacommand[#1]#2\stopprocesscommacommand
{\long\def\currentcommalistcommand##1{\def\currentcommalistitem{##1}#2}%
- \normalexpanded{\noexpand\processcommacommand[#1]}\currentcommalistcommand}
+ \normalexpanded{\processcommalist[#1]}\currentcommalistcommand}
%D \macros
%D {processaction,
@@ -1244,7 +1136,7 @@
\fi
\fi}
-\def\processfirstactioninset[#1]%
+\unexpanded\def\processfirstactioninset[#1]%
{\expandedaction\!!stringa{#1}%
\ifx\!!stringa\empty
\expandafter\processaction
@@ -1253,7 +1145,7 @@
\fi
[#1]}
-\def\processfirstactionsinsetindeed[#1]#2[#3]%
+\unexpanded\def\processfirstactionsinsetindeed[#1]#2[#3]%
{\def\p!doprocessaction##1%
{\def\p!dodoprocessaction####1%
{\p!compareprocessactionC[####1][##1]}%
@@ -1279,7 +1171,7 @@
\def\doprocessallactionsinset
{\csname\s!do\the\processlevel\endcsname}
-\def\processallactionsinset[#1]%
+\unexpanded\def\processallactionsinset[#1]%
{\expandedaction\!!stringa{#1}%
\ifx\!!stringa\empty
\expandafter\processaction
@@ -1288,7 +1180,7 @@
\fi
[#1]}
-\def\processallactionsinsetindeed[#1]#2[#3]%
+\unexpanded\def\processallactionsinsetindeed[#1]#2[#3]%
{\advance\processlevel \plusone
\expandafter\def\csname\s!do\the\processlevel\endcsname##1%
{\def\p!dodoprocessaction####1%
@@ -1434,25 +1326,10 @@
% replaces prev
-% \long\def\p!doifinstringelse#1#2% ##2 can be {abc}
-% {\long\@EA\def\@EA\pp!doifinstringelse\@EA##\@EA1#1##2##3\war{\unless\if##2@}% expand #1 here
-% \expanded{\pp!doifinstringelse#2#1}@@\war} % expand #2 here
-
\long\def\p!doifinstringelse#1#2% ##2 can be {abc}
{\long\@EA\def\@EA\pp!doifinstringelse\@EA##\@EA1#1##2##3\war{\unless\if##2@}% expand #1 here
\expandafter\pp!doifinstringelse\normalexpanded{#2#1}@@\war} % expand #2 here
-% faster but at some costs
-%
-% \def\setp!doifinstringelse#1#2% ##2 can be {abc}
-% {\long\expandafter\gdef\csname @diie:#1\@EA\endcsname\@EA##\@EA1#1##2##3\war{\unless\if##2@}}% expand #1 here
-%
-% \long\def\p!doifinstringelse#1#2% ##2 can be {abc}
-% {\ifcsname @diie:#1\endcsname \else
-% \setp!doifinstringelse{#1}{#2}%
-% \fi
-% \csname @diie:#1\expandafter\endcsname\normalexpanded{#2#1}@@\war} % expand #2 here
-
%D The next alternative proved to be upto twice as fast on
%D tasks like checking reserved words in pretty verbatim
%D typesetting! This is mainly due to the fact that passing
@@ -1552,7 +1429,7 @@
\expandafter\rawprocesscommaitem#1,],% \relax
\global\advance\commalevel \minusone }
-\def\rawprocesscommacommand[#1]% not really needed
+\unexpanded\def\rawprocesscommacommand[#1]% not really needed
{\normalexpanded{\rawprocesscommalist[#1]}}
% \def\rawdoifinsetelse#1#2{\doifinstringelse{,#1,}{,#2,}}
@@ -1839,10 +1716,6 @@
\let\p!doassign\p!n!doassign
-% \def\doassign [#1][#2]{\p!doassign\dosetvalue #1\@relax@#2==\empty\@relax@}
-% \def\doeassign [#1][#2]{\p!doassign\dosetevalue #1\@relax@#2==\empty\@relax@}
-% \def\undoassign[#1][#2]{\p!doassign\doresetvalue#1\@relax@#2==\empty\@relax@}
-
\def\doassign [#1][#2]{\let\setsomevalue\dosetvalue \p!doassign#1\@relax@#2==\empty\@relax@}
\def\doeassign [#1][#2]{\let\setsomevalue\dosetevalue \p!doassign#1\@relax@#2==\empty\@relax@}
\def\undoassign[#1][#2]{\let\setsomevalue\doresetvalue\p!doassign#1\@relax@#2==\empty\@relax@}
@@ -1861,12 +1734,12 @@
%D We can optimize this one if needed but it's not a core macro so hardly
%D worth the trouble and tokens.
-\def\processassignmentlist[#1]#2% #2 == \command{key}{value]
+\unexpanded\def\processassignmentlist[#1]#2% #2 == \command{key}{value]
{\def\doprocessassignmententry##1{#2}% {##2}{##3} % namespace is ignored
\dogetparameters\doprocessassignmententry[][#1]}
-\def\processassignmentcommand[#1]%
- {\normalexpanded{\noexpand\processassignmentlist[#1]}}
+\unexpanded\def\processassignmentcommand[#1]%
+ {\normalexpanded{\processassignmentlist[#1]}}
\long\unexpanded\def\startprocessassignmentlist[#1]#2\stopprocessassignmentlist
{\long\def\currentassignmentlistcommand##1##2{\def\currentassignmentlistkey{##1}\def\currentassignmentlistvalue{##2}#2}%
@@ -1874,7 +1747,7 @@
\long\unexpanded\def\startprocessassignmentcommand[#1]#2\stopprocessassignmentcommand
{\long\def\currentassignmentlistcommand##1##2{\def\currentassignmentlistkey{##1}\def\currentassignmentlistvalue{##2}#2}%
- \normalexpanded{\noexpand\processassignmentlist[#1]}\currentassignmentlistcommand}
+ \normalexpanded{\processassignmentlist[#1]}\currentassignmentlistcommand}
%D \macros{currentvalue}
%D
@@ -1913,16 +1786,6 @@
\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\setsomevalue
\let\setsomevalue\dosetevalue
@@ -2055,18 +1918,6 @@
\scratchtoks\expandafter{\expandafter[\commacommand]}%
\expandafter\getcommalistsize\the\scratchtoks }
-% to be tested first
-%
-% \def\getcommacommandsize[#1]%
-% {\expanded{\getcommalistsize[#1]}}
-
-% \def\p!dogetfromcommalist#1%
-% {\advance\commalistcounter \minusone
-% \ifcase\commalistcounter
-% \def\commalistelement{#1}%
-% \begingroup\def\doprocesscommaitem##1]{\endgroup}%
-% \fi}
-
\def\p!dogetfromcommalist#1%
{\advance\commalistcounter \minusone
\ifcase\commalistcounter
@@ -2234,13 +2085,11 @@
%D use the \type{\if...argument} boolean. For novice: watch
%D the stepwise doubling of \type{#}'s
-% idea: \ignorespaces afterwards
-
-\chardef\noexpectedarguments=0
-\chardef\expectedarguments =0
+\setnewconstant\noexpectedarguments\zerocount
+\setnewconstant\expectedarguments \zerocount
\def\showargumenterror#1#2%
- {\writestatus{systems}{\number#1 argument(s) expected in line #2}}
+ {\writestatus{system}{\number#1 argument(s) expected in line #2}}
\def\doshowargumenterror
{\ifnum\expectedarguments>\noexpectedarguments
@@ -2251,163 +2100,668 @@
\def\noshowargumenterror
{\let\expectedarguments\noexpectedarguments}
-\long\def\dogetargument#1#2#3#4%
- {\let\charactertoken=#1%
- \def\!!stringa{\noshowargumenterror#3\dodogetargument}%
- \def\!!stringb{\doshowargumenterror#4\dodogetargument#1#2}%
- \futurelet\nexttoken\inspectnextcharacter}
-
-\def\getsingleempty#1#2#3%
- {\def\dodogetargument%
- {#3}%
- \dogetargument#1#2\firstargumenttrue\firstargumentfalse}
-
-\def\getdoubleempty#1#2#3%
- {\def\dodogetargument#1##1#2%
- {\def\dodogetargument%
- {#3#1{##1}#2}%
- \dogetargument#1#2\secondargumenttrue\secondargumentfalse}%
- \dogetargument#1#2\firstargumenttrue\firstargumentfalse}
-
-\def\gettripleempty#1#2#3%
- {\def\dodogetargument#1##1#2%
- {\def\dodogetargument#1####1#2%
- {\def\dodogetargument%
- {#3#1{##1}#2%
- #1{####1}#2}%
- \dogetargument#1#2\thirdargumenttrue\thirdargumentfalse}%
- \dogetargument#1#2\secondargumenttrue\secondargumentfalse}%
- \dogetargument#1#2\firstargumenttrue\firstargumentfalse}
-
-\def\getquadrupleempty#1#2#3%
- {\def\dodogetargument#1##1#2%
- {\def\dodogetargument#1####1#2%
- {\def\dodogetargument#1########1#2%
- {\def\dodogetargument%
- {#3#1{##1}#2%
- #1{####1}#2%
- #1{########1}#2}%
- \dogetargument#1#2\fourthargumenttrue\fourthargumentfalse}%
- \dogetargument#1#2\thirdargumenttrue\thirdargumentfalse}%
- \dogetargument#1#2\secondargumenttrue\secondargumentfalse}%
- \dogetargument#1#2\firstargumenttrue\firstargumentfalse}
-
-\def\getquintupleempty#1#2#3%
- {\def\dodogetargument#1##1#2%
- {\def\dodogetargument#1####1#2%
- {\def\dodogetargument#1########1#2%
- {\def\dodogetargument#1################1#2%
- {\def\dodogetargument%
- {#3#1{##1}#2%
- #1{####1}#2%
- #1{########1}#2%
- #1{################1}#2}%
- \dogetargument#1#2\fifthargumenttrue\fifthargumentfalse}%
- \dogetargument#1#2\fourthargumenttrue\fourthargumentfalse}%
- \dogetargument#1#2\thirdargumenttrue\thirdargumentfalse}%
- \dogetargument#1#2\secondargumenttrue\secondargumentfalse}%
- \dogetargument#1#2\firstargumenttrue\firstargumentfalse}
-
-\def\getsixtupleempty#1#2#3%
- {\def\dodogetargument#1##1#2%
- {\def\dodogetargument#1####1#2%
- {\def\dodogetargument#1########1#2%
- {\def\dodogetargument#1################1#2%
- {\def\dodogetargument#1################################1#2%
- {\def\dodogetargument%
- {#3#1{##1}#2%
- #1{####1}#2%
- #1{########1}#2%
- #1{################1}#2%
- #1{################################1}#2}%
- \dogetargument#1#2\sixthargumenttrue\sixthargumentfalse}%
- \dogetargument#1#2\fifthargumenttrue\fifthargumentfalse}%
- \dogetargument#1#2\fourthargumenttrue\fourthargumentfalse}%
- \dogetargument#1#2\thirdargumenttrue\thirdargumentfalse}%
- \dogetargument#1#2\secondargumenttrue\secondargumentfalse}%
- \dogetargument#1#2\firstargumenttrue\firstargumentfalse}
-
-\def\getseventupleempty#1#2#3%
- {\def\dodogetargument#1##1#2%
- {\def\dodogetargument#1####1#2%
- {\def\dodogetargument#1########1#2%
- {\def\dodogetargument#1################1#2%
- {\def\dodogetargument#1################################1#2%
- {\def\dodogetargument#1################################%
- ################################1#2%
- {\def\dodogetargument%
- {#3#1{##1}#2%
- #1{####1}#2%
- #1{########1}#2%
- #1{################1}#2%
- #1{################################1}#2%
- #1{################################%
- ################################1}#2}%
- \dogetargument#1#2\seventhargumenttrue\seventhargumentfalse}%
- \dogetargument#1#2\sixthargumenttrue\sixthargumentfalse}%
- \dogetargument#1#2\fifthargumenttrue\fifthargumentfalse}%
- \dogetargument#1#2\fourthargumenttrue\fourthargumentfalse}%
- \dogetargument#1#2\thirdargumenttrue\thirdargumentfalse}%
- \dogetargument#1#2\secondargumenttrue\secondargumentfalse}%
- \dogetargument#1#2\firstargumenttrue\firstargumentfalse}
-
-\def\dosingleempty {\getsingleempty []}
-\def\dodoubleempty {\getdoubleempty []}
-\def\dotripleempty {\gettripleempty []}
-\def\doquadrupleempty {\getquadrupleempty []}
-\def\doquintupleempty {\getquintupleempty []}
-\def\dosixtupleempty {\getsixtupleempty []}
-\def\doseventupleempty{\getseventupleempty[]}
+% \long\def\dogetargument#1#2#3#4%
+% {\let\charactertoken=#1%
+% \def\!!stringa{\noshowargumenterror#3\dodogetargument}%
+% \def\!!stringb{\doshowargumenterror#4\dodogetargument#1#2}%
+% \futurelet\nexttoken\inspectnextcharacter}
+
+% \def\getsingleempty#1#2#3%
+% {\def\dodogetargument%
+% {#3}%
+% \dogetargument#1#2\firstargumenttrue\firstargumentfalse}
+
+% \def\getdoubleempty#1#2#3%
+% {\def\dodogetargument#1##1#2%
+% {\def\dodogetargument%
+% {#3#1{##1}#2}%
+% \dogetargument#1#2\secondargumenttrue\secondargumentfalse}%
+% \dogetargument#1#2\firstargumenttrue\firstargumentfalse}
+
+% \def\gettripleempty#1#2#3%
+% {\def\dodogetargument#1##1#2%
+% {\def\dodogetargument#1####1#2%
+% {\def\dodogetargument%
+% {#3#1{##1}#2%
+% #1{####1}#2}%
+% \dogetargument#1#2\thirdargumenttrue\thirdargumentfalse}%
+% \dogetargument#1#2\secondargumenttrue\secondargumentfalse}%
+% \dogetargument#1#2\firstargumenttrue\firstargumentfalse}
+
+% \def\getquadrupleempty#1#2#3%
+% {\def\dodogetargument#1##1#2%
+% {\def\dodogetargument#1####1#2%
+% {\def\dodogetargument#1########1#2%
+% {\def\dodogetargument%
+% {#3#1{##1}#2%
+% #1{####1}#2%
+% #1{########1}#2}%
+% \dogetargument#1#2\fourthargumenttrue\fourthargumentfalse}%
+% \dogetargument#1#2\thirdargumenttrue\thirdargumentfalse}%
+% \dogetargument#1#2\secondargumenttrue\secondargumentfalse}%
+% \dogetargument#1#2\firstargumenttrue\firstargumentfalse}
+
+% \def\getquintupleempty#1#2#3%
+% {\def\dodogetargument#1##1#2%
+% {\def\dodogetargument#1####1#2%
+% {\def\dodogetargument#1########1#2%
+% {\def\dodogetargument#1################1#2%
+% {\def\dodogetargument%
+% {#3#1{##1}#2%
+% #1{####1}#2%
+% #1{########1}#2%
+% #1{################1}#2}%
+% \dogetargument#1#2\fifthargumenttrue\fifthargumentfalse}%
+% \dogetargument#1#2\fourthargumenttrue\fourthargumentfalse}%
+% \dogetargument#1#2\thirdargumenttrue\thirdargumentfalse}%
+% \dogetargument#1#2\secondargumenttrue\secondargumentfalse}%
+% \dogetargument#1#2\firstargumenttrue\firstargumentfalse}
+
+% \def\getsixtupleempty#1#2#3%
+% {\def\dodogetargument#1##1#2%
+% {\def\dodogetargument#1####1#2%
+% {\def\dodogetargument#1########1#2%
+% {\def\dodogetargument#1################1#2%
+% {\def\dodogetargument#1################################1#2%
+% {\def\dodogetargument%
+% {#3#1{##1}#2%
+% #1{####1}#2%
+% #1{########1}#2%
+% #1{################1}#2%
+% #1{################################1}#2}%
+% \dogetargument#1#2\sixthargumenttrue\sixthargumentfalse}%
+% \dogetargument#1#2\fifthargumenttrue\fifthargumentfalse}%
+% \dogetargument#1#2\fourthargumenttrue\fourthargumentfalse}%
+% \dogetargument#1#2\thirdargumenttrue\thirdargumentfalse}%
+% \dogetargument#1#2\secondargumenttrue\secondargumentfalse}%
+% \dogetargument#1#2\firstargumenttrue\firstargumentfalse}
+
+% \def\getseventupleempty#1#2#3%
+% {\def\dodogetargument#1##1#2%
+% {\def\dodogetargument#1####1#2%
+% {\def\dodogetargument#1########1#2%
+% {\def\dodogetargument#1################1#2%
+% {\def\dodogetargument#1################################1#2%
+% {\def\dodogetargument#1################################%
+% ################################1#2%
+% {\def\dodogetargument%
+% {#3#1{##1}#2%
+% #1{####1}#2%
+% #1{########1}#2%
+% #1{################1}#2%
+% #1{################################1}#2%
+% #1{################################%
+% ################################1}#2}%
+% \dogetargument#1#2\seventhargumenttrue\seventhargumentfalse}%
+% \dogetargument#1#2\sixthargumenttrue\sixthargumentfalse}%
+% \dogetargument#1#2\fifthargumenttrue\fifthargumentfalse}%
+% \dogetargument#1#2\fourthargumenttrue\fourthargumentfalse}%
+% \dogetargument#1#2\thirdargumenttrue\thirdargumentfalse}%
+% \dogetargument#1#2\secondargumenttrue\secondargumentfalse}%
+% \dogetargument#1#2\firstargumenttrue\firstargumentfalse}
+
+% \def\dosingleempty {\getsingleempty []}
+% \def\dodoubleempty {\getdoubleempty []}
+% \def\dotripleempty {\gettripleempty []}
+% \def\doquadrupleempty {\getquadrupleempty []}
+% \def\doquintupleempty {\getquintupleempty []}
+% \def\dosixtupleempty {\getsixtupleempty []}
+% \def\doseventupleempty{\getseventupleempty[]}
%D Because some of these are called quite often, we will now
%D replace the more general version by alternatives tuned for
%D speed.
-\def\dosingleempty#1% we can make dedicated doifnextoptional's
- {\noshowargumenterror % \relax % prevents lookahead, brr
+% \def\dosingleempty#1% we can make dedicated doifnextoptional's
+% {\noshowargumenterror % \relax % prevents lookahead, brr
+% \doifnextoptionalelse
+% {\firstargumenttrue#1}%
+% {\dosinglefakeempty#1}}
+%
+% \def\dosinglefakeempty#1%
+% {\firstargumentfalse#1[]}
+%
+% \def\dodoubleempty#1%
+% {\noshowargumenterror % \relax % prevents lookahead, brr
+% \doifnextoptionalelse
+% {\dodoubletestempty#1}%
+% {\dodoublefakeempty#1}}
+%
+% \def\dodoublefakeempty#1%
+% {\firstargumentfalse\secondargumentfalse#1[][]}
+%
+% \long\def\dodoubletestempty#1[#2]%
+% {\firstargumenttrue
+% \doifnextoptionalelse
+% {\secondargumenttrue #1[{#2}]}%
+% {\secondargumentfalse#1[{#2}][]}}
+%
+% \def\dotripleempty#1%
+% {\noshowargumenterror % \relax % prevents lookahead, brr
+% \doifnextoptionalelse
+% {\dotripletestempty#1}%
+% {\dotriplefakeempty#1}}
+%
+% \def\dotriplefakeempty#1%
+% {\firstargumentfalse\secondargumentfalse\thirdargumentfalse#1[][][]}
+%
+% \long\def\dotripletestempty#1[#2]%
+% {\firstargumenttrue
+% \doifnextoptionalelse
+% {\dotripletestemptyx #1[{#2}]}%
+% {\secondargumentfalse
+% \thirdargumentfalse #1[{#2}][][]}}
+%
+% \long\def\dotripletestemptyx#1[#2][#3]%
+% {\secondargumenttrue
+% \doifnextoptionalelse
+% {\thirdargumenttrue #1[{#2}][{#3}]}%
+% {\thirdargumentfalse#1[{#2}][{#3}][]}}
+
+%D We can obey following spaces with a bit more code.
+
+% 0.172 0.187 new (per 10000)
+% 0.156 0.140 old (per 10000)
+%
+% \def\test[#1]{(#1)}
+%
+% \dosingleempty\test[] xxx\par
+% \dosingleempty\test xxx\par
+%
+% \def\test[#1][#2]{(#1,#2)}
+%
+% \dodoubleempty\test[][] xxx\par
+% \dodoubleempty\test[] xxx\par
+% \dodoubleempty\test xxx\par
+%
+% \def\test[#1][#2][#3]{(#1,#2,#3)}
+%
+% \dotripleempty\test[][][] xxx\par
+% \dotripleempty\test[][] xxx\par
+% \dotripleempty\test[] xxx\par
+% \dotripleempty\test xxx\par
+
+%D Single:
+
+\def\dosingleempty#1%
+ {\noshowargumenterror
\doifnextoptionalelse
{\firstargumenttrue#1}%
- {\dosinglefakeempty#1}}
+ {\dosingleemptyNOPone#1}}
+
+\def\dosingleemptyNOPone#1%
+ {\firstargumentfalse
+ #1[]}
+
+%D Double
\def\dodoubleempty#1%
- {\noshowargumenterror % \relax % prevents lookahead, brr
+ {\noshowargumenterror
\doifnextoptionalelse
- {\dodoubletestempty#1}%
- {\dodoublefakeempty#1}}
+ {\dodoubleemptyYESone#1}%
+ {\dodoubleemptyNOPone#1}}
+
+\long\def\dodoubleemptyYESone#1[#2]%
+ {\firstargumenttrue
+ \doifnextoptionalelse
+ {\secondargumenttrue#1[{#2}]}%
+ {\dodoubleemptyNOPtwo#1{#2}}}
+
+\def\dodoubleemptyNOPone#1%
+ {\firstargumentfalse
+ \secondargumentfalse
+ #1[][]}
+
+\def\dodoubleemptyNOPtwo
+ {\secondargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\dodoubleemptyonespaced
+ \else
+ \expandafter\dodoubleemptyonenormal
+ \fi}
+
+\def\dodoubleemptyonespaced#1#2{#1[{#2}][] }
+\def\dodoubleemptyonenormal#1#2{#1[{#2}][]}
+
+% Three
\def\dotripleempty#1%
- {\noshowargumenterror % \relax % prevents lookahead, brr
+ {\noshowargumenterror
+ \doifnextoptionalelse
+ {\dotripleemptyYESone#1}%
+ {\dotripleemptyNOPone#1}}
+
+\long\def\dotripleemptyYESone#1[#2]%
+ {\firstargumenttrue
\doifnextoptionalelse
- {\dotripletestempty#1}%
- {\dotriplefakeempty#1}}
+ {\dotripleemptyYEStwo#1{#2}}%
+ {\dotripleemptyNOPtwo#1{#2}}}
+
+\long\def\dotripleemptyYEStwo#1#2[#3]%
+ {\secondargumenttrue
+ \doifnextoptionalelse
+ {\thirdargumenttrue#1[{#2}][{#3}]}%
+ {\dotripleemptyNOPthree#1{#2}{#3}}}
+
+\def\dotripleemptyNOPone#1%
+ {\firstargumentfalse
+ \secondargumentfalse
+ \thirdargumentfalse
+ #1[][][]}
+
+\def\dotripleemptyNOPtwo
+ {\secondargumentfalse
+ \thirdargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\dotripleemptytwospaced
+ \else
+ \expandafter\dotripleemptytwonormal
+ \fi}
+
+\def\dotripleemptyNOPthree
+ {\thirdargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\dotripleemptythreespaced
+ \else
+ \expandafter\dotripleemptythreenormal
+ \fi}
-\def\dosinglefakeempty#1%
- {\firstargumentfalse#1[]}
+\def\dotripleemptytwospaced #1#2{#1[{#2}][][] }
+\def\dotripleemptytwonormal #1#2{#1[{#2}][][]}
+\def\dotripleemptythreespaced#1#2#3{#1[{#2}][{#3}][] }
+\def\dotripleemptythreenormal#1#2#3{#1[{#2}][{#3}][]}
-\def\dodoublefakeempty#1%
- {\firstargumentfalse\secondargumentfalse#1[][]}
+%D Four:
-\def\dotriplefakeempty#1%
- {\firstargumentfalse\secondargumentfalse\thirdargumentfalse#1[][][]}
+\def\doquadrupleempty#1%
+ {\noshowargumenterror
+ \doifnextoptionalelse
+ {\doquadrupleemptyYESone#1}%
+ {\doquadrupleemptyNOPone#1}}
-\long\def\dodoubletestempty#1[#2]%
+\long\def\doquadrupleemptyYESone#1[#2]%
{\firstargumenttrue
\doifnextoptionalelse
- {\secondargumenttrue #1[{#2}]}%
- {\secondargumentfalse#1[{#2}][]}}
+ {\doquadrupleemptyYEStwo#1{#2}}%
+ {\doquadrupleemptyNOPtwo#1{#2}}}
+
+\long\def\doquadrupleemptyYEStwo#1#2[#3]%
+ {\secondargumenttrue
+ \doifnextoptionalelse
+ {\doquadrupleemptyYESthree#1{#2}{#3}}%
+ {\doquadrupleemptyNOPthree#1{#2}{#3}}}
-\long\def\dotripletestempty#1[#2]%
+\long\def\doquadrupleemptyYESthree#1#2#3[#4]%
+ {\thirdargumenttrue
+ \doifnextoptionalelse
+ {\fourthargumenttrue#1[{#2}][{#3}][{#4}]}%
+ {\doquadrupleemptyNOPfour#1{#2}{#3}{#4}}}
+
+\def\doquadrupleemptyNOPone#1%
+ {\firstargumentfalse
+ \secondargumentfalse
+ \thirdargumentfalse
+ \fourthargumentfalse
+ #1[][][][]}
+
+\def\doquadrupleemptyNOPtwo
+ {\secondargumentfalse
+ \thirdargumentfalse
+ \fourthargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\doquadrupleemptytwospaced
+ \else
+ \expandafter\doquadrupleemptytwonormal
+ \fi}
+
+\def\doquadrupleemptyNOPthree
+ {\thirdargumentfalse
+ \fourthargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\doquadrupleemptythreespaced
+ \else
+ \expandafter\doquadrupleemptythreenormal
+ \fi}
+
+\def\doquadrupleemptyNOPfour
+ {\fourthargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\doquadrupleemptyfourspaced
+ \else
+ \expandafter\doquadrupleemptyfournormal
+ \fi}
+
+\def\doquadrupleemptytwospaced #1#2{#1[{#2}][][][] }
+\def\doquadrupleemptytwonormal #1#2{#1[{#2}][][][]}
+\def\doquadrupleemptythreespaced #1#2#3{#1[{#2}][{#3}][][] }
+\def\doquadrupleemptythreenormal #1#2#3{#1[{#2}][{#3}][][]}
+\def\doquadrupleemptyfourspaced #1#2#3#4{#1[{#2}][{#3}][{#4}][] }
+\def\doquadrupleemptyfournormal #1#2#3#4{#1[{#2}][{#3}][{#4}][]}
+
+%D Five:
+
+\def\doquintupleempty#1%
+ {\noshowargumenterror
+ \doifnextoptionalelse
+ {\doquintupleemptyYESone#1}%
+ {\doquintupleemptyNOPone#1}}
+
+\long\def\doquintupleemptyYESone#1[#2]%
{\firstargumenttrue
\doifnextoptionalelse
- {\dotripletestemptyx #1[{#2}]}%
- {\secondargumentfalse
- \thirdargumentfalse #1[{#2}][][]}}
+ {\doquintupleemptyYEStwo#1{#2}}%
+ {\doquintupleemptyNOPtwo#1{#2}}}
-\long\def\dotripletestemptyx#1[#2][#3]%
+\long\def\doquintupleemptyYEStwo#1#2[#3]%
{\secondargumenttrue
\doifnextoptionalelse
- {\thirdargumenttrue #1[{#2}][{#3}]}%
- {\thirdargumentfalse#1[{#2}][{#3}][]}}
+ {\doquintupleemptyYESthree#1{#2}{#3}}%
+ {\doquintupleemptyNOPthree#1{#2}{#3}}}
+
+\long\def\doquintupleemptyYESthree#1#2#3[#4]%
+ {\thirdargumenttrue
+ \doifnextoptionalelse
+ {\doquintupleemptyYESfour#1{#2}{#3}{#4}}%
+ {\doquintupleemptyNOPfour#1{#2}{#3}{#4}}}
+
+\long\def\doquintupleemptyYESfour#1#2#3#4[#5]%
+ {\fourthargumenttrue
+ \doifnextoptionalelse
+ {\fifthargumenttrue#1[{#2}][{#3}][{#4}][{#5}]}%
+ {\doquintupleemptyNOPfive#1{#2}{#3}{#4}{#5}}}
+
+\def\doquintupleemptyNOPone#1%
+ {\firstargumentfalse
+ \secondargumentfalse
+ \thirdargumentfalse
+ \fourthargumentfalse
+ \fifthargumentfalse
+ #1[][][][][]}
+
+\def\doquintupleemptyNOPtwo
+ {\secondargumentfalse
+ \thirdargumentfalse
+ \fourthargumentfalse
+ \fifthargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\doquintupleemptytwospaced
+ \else
+ \expandafter\doquintupleemptytwonormal
+ \fi}
+
+\def\doquintupleemptyNOPthree
+ {\thirdargumentfalse
+ \fourthargumentfalse
+ \fifthargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\doquintupleemptythreespaced
+ \else
+ \expandafter\doquintupleemptythreenormal
+ \fi}
+
+\def\doquintupleemptyNOPfour
+ {\fourthargumentfalse
+ \fifthargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\doquintupleemptyfourspaced
+ \else
+ \expandafter\doquintupleemptyfournormal
+ \fi}
+
+\def\doquintupleemptyNOPfive
+ {\fifthargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\doquintupleemptyfivespaced
+ \else
+ \expandafter\doquintupleemptyfivenormal
+ \fi}
+
+\def\doquintupleemptytwospaced #1#2{#1[{#2}][][][][] }
+\def\doquintupleemptytwonormal #1#2{#1[{#2}][][][][]}
+\def\doquintupleemptythreespaced #1#2#3{#1[{#2}][{#3}][][][] }
+\def\doquintupleemptythreenormal #1#2#3{#1[{#2}][{#3}][][][]}
+\def\doquintupleemptyfourspaced #1#2#3#4{#1[{#2}][{#3}][{#4}][][] }
+\def\doquintupleemptyfournormal #1#2#3#4{#1[{#2}][{#3}][{#4}][][]}
+\def\doquintupleemptyfivespaced #1#2#3#4#5{#1[{#2}][{#3}][{#4}][{#5}][] }
+\def\doquintupleemptyfivenormal #1#2#3#4#5{#1[{#2}][{#3}][{#4}][{#5}][]}
+
+%D Six
+
+\def\dosixtupleempty#1%
+ {\noshowargumenterror
+ \doifnextoptionalelse
+ {\dosixtupleemptyYESone#1}
+ {\dosixtupleemptyNOPone#1}}
+
+\long\def\dosixtupleemptyYESone#1[#2]%
+ {\firstargumenttrue
+ \doifnextoptionalelse
+ {\dosixtupleemptyYEStwo#1{#2}}%
+ {\dosixtupleemptyNOPtwo#1{#2}}}
+
+\long\def\dosixtupleemptyYEStwo#1#2[#3]%
+ {\secondargumenttrue
+ \doifnextoptionalelse
+ {\dosixtupleemptyYESthree#1{#2}{#3}}%
+ {\dosixtupleemptyNOPthree#1{#2}{#3}}}
+
+\long\def\dosixtupleemptyYESthree#1#2#3[#4]%
+ {\thirdargumenttrue
+ \doifnextoptionalelse
+ {\dosixtupleemptyYESfour#1{#2}{#3}{#4}}%
+ {\dosixtupleemptyNOPfour#1{#2}{#3}{#4}}}
+
+\long\def\dosixtupleemptyYESfour#1#2#3#4[#5]%
+ {\fourthargumenttrue
+ \doifnextoptionalelse
+ {\dosixtupleemptyYESfive#1{#2}{#3}{#4}{#5}}%
+ {\dosixtupleemptyNOPfive#1{#2}{#3}{#4}{#5}}}
+
+\long\def\dosixtupleemptyYESfive#1#2#3#4#5[#6]%
+ {\fifthargumenttrue
+ \doifnextoptionalelse
+ {\sixthargumenttrue#1[{#2}][{#3}][{#4}][{#5}][{#6}]}%
+ {\dosixtupleemptyNOPsix#1{#2}{#3}{#4}{#5}{#6}}}
+
+\def\dosixemptyNOPone#1%
+ {\firstargumentfalse
+ \secondargumentfalse
+ \thirdargumentfalse
+ \fourthargumentfalse
+ \fifthargumentfalse
+ \sixthargumentfalse
+ #1[][][][][][]}
+
+\def\dosixtupleemptyNOPtwo
+ {\secondargumentfalse
+ \thirdargumentfalse
+ \fourthargumentfalse
+ \fifthargumentfalse
+ \sixthargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\dosixemptytwospaced
+ \else
+ \expandafter\dosixemptytwonormal
+ \fi}
+
+\def\dosixtupleemptyNOPthree
+ {\thirdargumentfalse
+ \fourthargumentfalse
+ \fifthargumentfalse
+ \sixthargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\dosixemptythreespaced
+ \else
+ \expandafter\dosixemptythreenormal
+ \fi}
+
+\def\dosixtupleemptyNOPfour
+ {\fourthargumentfalse
+ \fifthargumentfalse
+ \sixthargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\dosixemptyfourspaced
+ \else
+ \expandafter\dosixemptyfournormal
+ \fi}
+
+\def\dosixtupleemptyNOPfive
+ {\fifthargumentfalse
+ \sixthargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\dosixemptyfivespaced
+ \else
+ \expandafter\dosixemptyfivenormal
+ \fi}
+
+\def\dosixtupleemptyNOPsix
+ {\sixthargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\dosixemptysixspaced
+ \else
+ \expandafter\dosixemptysixnormal
+ \fi}
+
+\def\dosixemptytwospaced #1#2{#1[{#2}][][][][][] }
+\def\dosixemptytwonormal #1#2{#1[{#2}][][][][][]}
+\def\dosixemptythreespaced #1#2#3{#1[{#2}][{#3}][][][][] }
+\def\dosixemptythreenormal #1#2#3{#1[{#2}][{#3}][][][][]}
+\def\dosixemptyfourspaced #1#2#3#4{#1[{#2}][{#3}][{#4}][][][] }
+\def\dosixemptyfournormal #1#2#3#4{#1[{#2}][{#3}][{#4}][][][]}
+\def\dosixemptyfivespaced #1#2#3#4#5{#1[{#2}][{#3}][{#4}][{#5}][][] }
+\def\dosixemptyfivenormal #1#2#3#4#5{#1[{#2}][{#3}][{#4}][{#5}][][]}
+\def\dosixemptysixspaced #1#2#3#4#5#6{#1[{#2}][{#3}][{#4}][{#5}][{#6}][] }
+\def\dosixemptysixnormal #1#2#3#4#5#6{#1[{#2}][{#3}][{#4}][{#5}][{#6}][]}
+
+%D Seven:
+
+\def\doseventupleempty#1%
+ {\noshowargumenterror
+ \doifnextoptionalelse
+ {\doseventupleemptyYESone#1}%
+ {\doseventupleemptyNOPone#1}}
+
+\long\def\doseventupleemptyYESone#1[#2]%
+ {\firstargumenttrue
+ \doifnextoptionalelse
+ {\doseventupleemptyYEStwo#1{#2}}%
+ {\doseventupleemptyNOPtwo#1{#2}}}
+
+\long\def\doseventupleemptyYEStwo#1#2[#3]%
+ {\secondargumenttrue
+ \doifnextoptionalelse
+ {\doseventupleemptyYESthree#1{#2}{#3}}%
+ {\doseventupleemptyNOPthree#1{#2}{#3}}}
+
+\long\def\doseventupleemptyYESthree#1#2#3[#4]%
+ {\thirdargumenttrue
+ \doifnextoptionalelse
+ {\doseventupleemptyYESfour#1{#2}{#3}{#4}}%
+ {\doseventupleemptyNOPfour#1{#2}{#3}{#4}}}
+
+\long\def\doseventupleemptyYESfour#1#2#3#4[#5]%
+ {\fourthargumenttrue
+ \doifnextoptionalelse
+ {\doseventupleemptyYESfive#1{#2}{#3}{#4}{#5}}%
+ {\doseventupleemptyNOPfive#1{#2}{#3}{#4}{#5}}}
+
+\long\def\doseventupleemptyYESfive#1#2#3#4#5[#6]%
+ {\fifthargumenttrue
+ \doifnextoptionalelse
+ {\doseventupleemptyYESsix#1{#2}{#3}{#4}{#5}{#6}}%
+ {\doseventupleemptyNOPsix#1{#2}{#3}{#4}{#5}{#6}}}
+
+\long\def\doseventupleemptyYESsix#1#2#3#4#5#6[#7]%
+ {\sixthargumenttrue
+ \doifnextoptionalelse
+ {\seventhargumenttrue#1[{#2}][{#3}][{#4}][{#5}][{#6}][{#7}]}%
+ {\doseventupleemptyNOPseven#1{#2}{#3}{#4}{#5}{#6}{#7}}}
+
+\def\dosevenemptyNOPone#1%
+ {\firstargumentfalse
+ \secondargumentfalse
+ \thirdargumentfalse
+ \fourthargumentfalse
+ \fifthargumentfalse
+ \sixthargumentfalse
+ \seventhargumentfalse
+ #1[][][][][][][]}
+
+\def\doseventupleemptyNOPtwo
+ {\secondargumentfalse
+ \thirdargumentfalse
+ \fourthargumentfalse
+ \fifthargumentfalse
+ \sixthargumentfalse
+ \seventhargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\dosevenemptytwospaced
+ \else
+ \expandafter\dosevenemptytwonormal
+ \fi}
+
+\def\doseventupleemptyNOPthree
+ {\thirdargumentfalse
+ \fourthargumentfalse
+ \fifthargumentfalse
+ \sixthargumentfalse
+ \seventhargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\dosevenemptythreespaced
+ \else
+ \expandafter\dosevenemptythreenormal
+ \fi}
+
+\def\doseventupleemptyNOPfour
+ {\fourthargumentfalse
+ \fifthargumentfalse
+ \sixthargumentfalse
+ \seventhargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\dosevenemptyfourspaced
+ \else
+ \expandafter\dosevenemptyfournormal
+ \fi}
+
+\def\doseventupleemptyNOPfive
+ {\fifthargumentfalse
+ \sixthargumentfalse
+ \seventhargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\dosevenemptyfivespaced
+ \else
+ \expandafter\dosevenemptyfivenormal
+ \fi}
+
+\def\doseventupleemptyNOPsix
+ {\sixthargumentfalse
+ \seventhargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\dosevenemptysixspaced
+ \else
+ \expandafter\dosevenemptysixnormal
+ \fi}
+
+\def\doseventupleemptyNOPseven
+ {\seventhargumentfalse
+ \ifnextblankspacetoken
+ \expandafter\dosevenemptysevenspaced
+ \else
+ \expandafter\dosevenemptysevennormal
+ \fi}
+
+\def\dosevenemptytwospaced #1#2{#1[{#2}][][][][][][] }
+\def\dosevenemptytwonormal #1#2{#1[{#2}][][][][][][]}
+\def\dosevenemptythreespaced #1#2#3{#1[{#2}][{#3}][][][][][] }
+\def\dosevenemptythreenormal #1#2#3{#1[{#2}][{#3}][][][][][]}
+\def\dosevenemptyfourspaced #1#2#3#4{#1[{#2}][{#3}][{#4}][][][][] }
+\def\dosevenemptyfournormal #1#2#3#4{#1[{#2}][{#3}][{#4}][][][][]}
+\def\dosevenemptyfivespaced #1#2#3#4#5{#1[{#2}][{#3}][{#4}][{#5}][][][] }
+\def\dosevenemptyfivenormal #1#2#3#4#5{#1[{#2}][{#3}][{#4}][{#5}][][][]}
+\def\dosevenemptysixspaced #1#2#3#4#5#6{#1[{#2}][{#3}][{#4}][{#5}][{#6}][][] }
+\def\dosevenemptysixnormal #1#2#3#4#5#6{#1[{#2}][{#3}][{#4}][{#5}][{#6}][][]}
+\def\dosevenemptysevenspaced#1#2#3#4#5#6#7{#1[{#2}][{#3}][{#4}][{#5}][{#6}][{#7}][] }
+\def\dosevenemptysevennormal#1#2#3#4#5#6#7{#1[{#2}][{#3}][{#4}][{#5}][{#6}][{#7}][]}
%D \macros
%D {strippedcsname}
@@ -2545,11 +2899,6 @@
%D potentially being an \type {conditional} token. Okay, these macros
%D are not called that often but it saves crap when tracing.
-% \def\dogetgroupargument#1#2%
-% {\let\dogroupargumentyes#1%
-% \let\dogroupargumentnop#2%
-% \futurelet\nextargument\dodogetgroupargument}
-
\def\dodogetgroupargument
{\ifx\nextargument\bgroup
\expandafter\dodogetgroupargumentA
@@ -2561,20 +2910,6 @@
{\noshowargumenterror
\dogroupargumentyes\dodogetargument}
-% \def\dodogetgroupargumentB
-% {\ifcase\@@permitspacesbetweengroups
-% \expandafter\dodogetgroupargumentC
-% \else
-% \expandafter\dodogetgroupargumentD
-% \fi}
-
-% \def\dodogetgroupargumentC
-% {\ifx\nextargument\lineending
-% \expandafter\dodogetgroupargumentE
-% \else
-% \expandafter\dodogetgroupargumentF
-% \fi}
-
\def\dodogetgroupargumentB
{\ifcase\@@permitspacesbetweengroups
\expandafter\dodogetgroupargumentF
@@ -2586,9 +2921,6 @@
{\doshowargumenterror
\dogroupargumentnop\dodogetargument{}}
-% \def\dodogetgroupargumentE
-% {\begingroup\def\\ {\endgroup\dogetgroupargument\dogroupargumentyes\dogroupargumentnop}\\}
-
\begingroup
\def\\ {\dogetgroupargument\dogroupargumentyes\dogroupargumentnop}
\global\let\dodogetgroupargumentE\\
@@ -2712,7 +3044,9 @@
\long\def\sixthofsixarguments #1#2#3#4#5#6{#6}
%D \macros
-%D {globalletempty,letempty,letvalueempty,letgvalueempty}
+%D {globalletempty,letempty,
+%D letvalueempty,letgvalueempty,
+%D letvaluerelax,letgvaluerelax}
%D
%D Trivial:
@@ -2721,6 +3055,8 @@
\def\letvalueempty #1{\expandafter\let\csname#1\endcsname\empty}
\def\letgvalueempty#1{\global\expandafter\let\csname#1\endcsname\empty}
+\def\letvaluerelax #1{\expandafter\let\csname#1\endcsname\relax}
+\def\letgvalurelax #1{\global\expandafter\let\csname#1\endcsname\relax}
%D \macros
%D {wait}
@@ -2753,8 +3089,8 @@
%D of the identification string with the macro \type
%D {\statuswidth}.
-\chardef\statuswidth=15
-\chardef\statuswrite=16
+\setnewconstant\statuswidth 15
+\setnewconstant\statuswrite 16
\ifdefined\writestring \else
@@ -2781,6 +3117,13 @@
{}
%D \macros
+%D {immediatemessage}
+%D
+%D A fully expandable message:
+
+\def\immediatemessage#1{\ctxlua{logs.status("message","#1")}}
+
+%D \macros
%D {debuggerinfo}
%D
%D For debugging purposes we can enhance macros with the
@@ -2935,7 +3278,7 @@
\dostarttexdefinition}
\gdef\dostarttexdefinition #1
- {\catcode13=\@@ignore%
+ {\catcode\endoflineasciicode\ignorecatcode%
\doifinstringelse\letterhash{\detokenize{#1}}\dodostarttexdefinition\nonostarttexdefinition#1
}
@@ -2944,17 +3287,22 @@
\long\gdef\dododostarttexdefinition#1#2#3\stoptexdefinition%
{\egroup%
- \long\setvalue{#1}#2{#3}}
+ \expandafter\def\csname#1\endcsname#2{#3}}
\long\gdef\nonostarttexdefinition#1
{\nononostarttexdefinition{#1}{}}
\long\gdef\nononostarttexdefinition#1#2#3\stoptexdefinition%
{\egroup%
- \long\setvalue{#1}{#3}}
+ \expandafter\def\csname#1\endcsname{#3}}
\egroup
+% This is a first variant, more might be added:
+
+\def\starttexcode{\unprotect}
+\def\stoptexcode {\protect}
+
%D \macros
%D {newcounter,
%D increment,decrement}
@@ -3068,8 +3416,6 @@
\edef#1{\the\maximumsignal}%
\fi}
-\let\newskimen\newdimen % it's all etex or later now
-
%D \macros
%D {strippedcsname}
%D
@@ -3080,10 +3426,6 @@
%D \csname if\strippedcsname\something\endcsname
%D \stoptyping
-\ifdefined\letterbackslash \else
- {\catcode`.=0 .catcode`.\ 12 .xdef.letterbackslash{.string\}} % hack
-\fi
-
\def\checkedstrippedcsname#1% this permits \strippedcsname{\xxx} and \strippedcsname{xxx}
{\expandafter\docheckedstrippedcsname\string#1}
@@ -3139,8 +3481,7 @@
%D conditionals. The next implementation is abaou as fast
%D and just as straightforward:
-% \def\settrue #1{\chardef#1\zerocount}
-% \def\setfalse#1{\chardef#1\plusone}
+% maybe reserve special zero and plusone
\def\settrue #1{\let#1\zerocount}
\def\setfalse#1{\let#1\plusone}
@@ -3150,6 +3491,15 @@
\let\then\relax % so that we can say: \ifnum1>2\then -)
+% demands that each conditional is defined .. it would be handy to have
+% a primitive \unless\ifcase .. then we could use better values
+%
+% \def\settrue #1{#1\zerocount}
+% \def\setfalse#1{#1\plusone}
+%
+% \def\newconditional#1{\ifdefined#1\else\newcount#1\fi\setfalse#1}
+% \let\ifconditional \ifcase
+
%D \macros
%D {ifzeropt}
%D
@@ -3237,7 +3587,7 @@
\else
\let\nextrecurse\exitstepwiserecurse
\fi
- \fi\normalexpanded{\noexpand\nextrecurse{\number#1}{\number#2}{\number#3}}}
+ \fi\normalexpanded{\nextrecurse{\number#1}{\number#2}{\number#3}}}
\long\def\dodostepwiserecurse#1#2#3% from to step
{\ifnum#1>#2\relax
@@ -3247,21 +3597,13 @@
\@EAEAEA\redostepwiserecurse\@EA
\fi\@EA{\the\numexpr\recurselevel+#3\relax}{#2}{#3}}
-\def\expandrecursecontent
+\unexpanded\def\expandrecursecontent
{\csname\@@arecurse\recursedepth\endcsname}
-\def\redostepwiserecurse
+\unexpanded\def\redostepwiserecurse
{\expandrecursecontent\dodostepwiserecurse}
-\long\def\dodostepwisereverse#1#2#3% from to step
- {\ifnum#1<#2\relax
- \@EA\nodostepwiserecurse
- \else
- \def\recurselevel{#1}%
- \@EAEAEA\redostepwisereverse\@EA
- \fi\@EA{\the\numexpr\recurselevel#3\relax}{#2}{#3}}
-
-\long\def\dodostepwisereverse#1#2#3% from to step
+\long\unexpanded\def\dodostepwisereverse#1#2#3% from to step
{\ifnum#1<#2\relax
\@EA\nodostepwiserecurse
\else
@@ -3271,21 +3613,21 @@
\@EAEAEA\redostepwisereverse\@EA
\fi\@EA{\the\innerrecurse}{#2}{#3}}
-\def\redostepwisereverse
+\unexpanded\def\redostepwisereverse
{\expandrecursecontent\dodostepwisereverse}
-\def\exitstepwiserecurse
+\unexpanded\def\exitstepwiserecurse
{\nodostepwiserecurse\relax}
-\def\nodostepwiserecurse#1#2#3#4%
+\unexpanded\def\nodostepwiserecurse#1#2#3#4%
{\@EA\let\@EA\recurselevel\csname\@@irecurse\recursedepth\endcsname
\global\advance\outerrecurse \minusone}
-\def\nonostepwiserecurse#1#2#3%
+\unexpanded\def\nonostepwiserecurse#1#2#3%
{\@EA\let\@EA\recurselevel\csname\@@irecurse\recursedepth\endcsname
\global\advance\outerrecurse \minusone}
-\def\dorecurse#1%
+\unexpanded\def\dorecurse#1%
{\dostepwiserecurse1{#1}1}
%D As we can see here, the simple command \type{\dorecurse} is
@@ -3307,7 +3649,7 @@
%D Because the simple case is used often, we implement it
%D more efficiently:
-\long\def\dorecurse#1%
+\long\unexpanded\def\dorecurse#1%
{\ifcase#1\relax
\expandafter\gobbletwoarguments
\or
@@ -3316,13 +3658,13 @@
\expandafter\xdorecurse
\fi{#1}}
-\long\def\xdorecurse#1#2%
+\long\unexpanded\def\xdorecurse#1#2%
{\global\advance\outerrecurse \plusone
\long\global\@EA\def\csname\@@arecurse\recursedepth\endcsname{#2}%
\global\@EA\let\csname\@@irecurse\recursedepth\endcsname\recurselevel
\@EA\dodorecurse\@EA1\@EA{\number#1}}
-\long\def\ydorecurse#1#2%
+\long\unexpanded\def\ydorecurse#1#2%
{\global\advance\outerrecurse \plusone
\global\@EA\let\csname\@@irecurse\recursedepth\endcsname\recurselevel
\let\recurselevel\!!plusone
@@ -3330,7 +3672,7 @@
\@EA\let\@EA\recurselevel\csname\@@irecurse\recursedepth\endcsname
\global\advance\outerrecurse \minusone}
-\long\def\dodorecurse#1#2% from to
+\long\unexpanded\def\dodorecurse#1#2% from to
{\ifnum#1>#2\relax
\@EA\nodorecurse
\else
@@ -3338,7 +3680,7 @@
\@EAEAEA\redorecurse
\fi\@EA{\the\numexpr\recurselevel+\plusone\relax}{#2}}
-\long\def\dodorecurse#1#2% from to
+\long\unexpanded\def\dodorecurse#1#2% from to
{\ifnum#1>#2\relax
\@EA\nodorecurse
\else
@@ -3347,10 +3689,10 @@
\@EAEAEA\redorecurse
\fi\@EA{\the\innerrecurse}{#2}}
-\def\redorecurse
+\unexpanded\def\redorecurse
{\expandrecursecontent\dodorecurse}
-\def\nodorecurse#1#2#3%
+\unexpanded\def\nodorecurse#1#2#3%
{\@EA\let\@EA\recurselevel\csname\@@irecurse\recursedepth\endcsname
\global\advance\outerrecurse \minusone }
@@ -3374,29 +3716,29 @@
\let\endofloop\donothing
-\long\def\doloop#1%
+\unexpanded\long\def\doloop#1%
{\global\advance\outerrecurse \plusone
\long\global\@EA\def\csname\@@arecurse\recursedepth\endcsname{#1}%
\global\@EA\let\csname\@@irecurse\recursedepth\endcsname\recurselevel
\let\endofloop\dodoloop
\dodoloop1} % no \plusone else \recurselevel wrong
-\long\def\dodoloop#1%
+\unexpanded\long\def\dodoloop#1%
{\def\recurselevel{#1}%
\@EA\redoloop\@EA{\the\numexpr\recurselevel+\plusone\relax}}
-\def\redoloop
+\unexpanded\def\redoloop
{\expandrecursecontent\endofloop}
-\def\nodoloop#1%
+\unexpanded\def\nodoloop#1%
{\let\endofloop\dodoloop % new, permits nested \doloop's
\@EA\let\@EA\recurselevel\csname\@@irecurse\recursedepth\endcsname
\global\advance\outerrecurse\minusone}
-\def\exitloop % \exitloop quits at end
+\unexpanded\def\exitloop % \exitloop quits at end
{\let\endofloop\nodoloop}
-\long\def\exitloopnow#1\endofloop % \exitloopnow quits directly
+\long\unexpanded\def\exitloopnow#1\endofloop % \exitloopnow quits directly
{\nodoloop}
%D The loop is executed at least once, so beware of situations
@@ -3440,13 +3782,13 @@
\def\expandrecursecontent
{\csname\@@arecurse\recursedepth\@EA\@EA\@EA\endcsname\@EA\@EA\@EA{\@EA\recurselevel\@EA}\@EA{\recursedepth}}
-\long\def\xdorecurse#1#2%
+\long\unexpanded\def\xdorecurse#1#2%
{\global\advance\outerrecurse \plusone
\long\global\@EA\def\csname\@@arecurse\recursedepth\endcsname##1##2{#2}%
\global\@EA\let\csname\@@irecurse\recursedepth\endcsname\recurselevel
\@EA\dodorecurse\@EA1\@EA{\number#1}}
-\long\def\ydorecurse#1#2%
+\long\unexpanded\def\ydorecurse#1#2%
{\global\advance\outerrecurse \plusone
\global\@EA\let\csname\@@irecurse\recursedepth\endcsname\recurselevel
\let\recurselevel\!!plusone
@@ -3455,7 +3797,7 @@
\@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
+\long\unexpanded\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}%
\global\@EA\let\csname\@@irecurse\recursedepth\endcsname\recurselevel
@@ -3475,9 +3817,9 @@
\else
\let\nextrecurse\exitstepwiserecurse
\fi
- \fi\normalexpanded{\noexpand\nextrecurse{\number#1}{\number#2}{\number#3}}}
+ \fi\normalexpanded{\nextrecurse{\number#1}{\number#2}{\number#3}}}
-\long\def\doloop#1%
+\long\unexpanded\def\doloop#1%
{\global\advance\outerrecurse \plusone
\long\global\@EA\def\csname\@@arecurse\recursedepth\endcsname##1##2{#1}%
\global\@EA\let\csname\@@irecurse\recursedepth\endcsname\recurselevel
@@ -3488,7 +3830,7 @@
% faster
-\long\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4
+\long\unexpanded\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}%
\global\@EA\let\csname\@@irecurse\recursedepth\endcsname\recurselevel
@@ -3509,11 +3851,11 @@
\let\nextrecurse\exitstepwiserecurse
\fi
\fi
- \expandafter\nextrecurse\normalexpanded{{\number#1}{\number#2}{\number#3}}}
+ \normalexpanded{\nextrecurse{\number#1}{\number#2}{\number#3}}}
% slightly faster
-\long\def\dostepwiserecurse#1#2#3#4% can be made faster by postponing #4
+\long\unexpanded\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}%
\global\@EA\let\csname\@@irecurse\recursedepth\endcsname\recurselevel
@@ -3529,13 +3871,38 @@
\let\@swrd\dodostepwiserecurse
\let\@swrr\dodostepwisereverse
+% quite okay too, but untested
+%
+% \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}%
+% \global\@EA\let\csname\@@irecurse\recursedepth\endcsname\recurselevel
+% \normalexpanded
+% {\ifnum#3>\zerocount
+% \ifnum#2<#1
+% \exitstepwiserecurse
+% \else
+% \dodostepwiserecurse
+% \fi
+% \else
+% \ifnum#3<\zerocount
+% \ifnum#1<#2
+% \exitstepwiserecurse
+% \else
+% \dodostepwisereverse
+% \fi
+% \else
+% \exitstepwiserecurse
+% \fi
+% \fi{\number#1}{\number#2}{\number#3}}}
+
%D For special purposes:
\newcount\fastrecursecounter
\newcount\lastrecursecounter
\newcount\steprecursecounter
-\def\dofastrecurse#1#2#3#4%
+\unexpanded\def\dofastrecurse#1#2#3#4%
{\def\fastrecursebody{#4}%
\fastrecursecounter#1\relax
\lastrecursecounter#2\relax
@@ -3543,9 +3910,9 @@
\def\recurselevel{\number\fastrecursecounter}%
\dodofastrecurse}
-\def\resetrecurselevel{\let\recurselevel\!!zerocount}
+\unexpanded\def\resetrecurselevel{\let\recurselevel\!!zerocount}
-\def\dodofastrecurse
+\unexpanded\def\dodofastrecurse
{\ifnum\fastrecursecounter>\lastrecursecounter
% \resetrecurselevel % slows down
\else
@@ -3576,11 +3943,11 @@
%D The use of \type{\od} as a dilimiter would have made nested
%D use more problematic.
-%D Don't use this one, it's kind of obsolete.
-
-\def\for#1=#2\to#3\step#4\do#5%
- {\dostepwiserecurse{#2}{#3}{#4}
- {\let#1\recurselevel#5\let#1\recurselevel}}
+% obsolete:
+%
+% \def\for#1=#2\to#3\step#4\do#5%
+% {\dostepwiserecurse{#2}{#3}{#4}
+% {\let#1\recurselevel#5\let#1\recurselevel}}
%D \macros
%D {newevery,everyline,EveryLine,EveryPar}
@@ -3836,70 +4203,14 @@
%D \doifsamestringelse{\jobname}{oeps}{YES}{NO}
%D \stoptyping
-% \def\@@doifsamestringelse#1#2#3#4%
-% {\edef\!!stringa{#3}\convertcommand\!!stringa\to\!!stringa
-% \edef\!!stringb{#4}\convertcommand\!!stringb\to\!!stringb
-% \ifx\!!stringa\!!stringb\expandafter#1\else\expandafter#2\fi}
-
\def\@@doifsamestringelse#1#2#3#4%
{\edef\!!stringa{\detokenize\expandafter{\normalexpanded{#3}}}%
\edef\!!stringb{\detokenize\expandafter{\normalexpanded{#4}}}%
\ifx\!!stringa\!!stringb\expandafter#1\else\expandafter#2\fi}
\def\doifsamestringelse{\@@doifsamestringelse\firstoftwoarguments\secondoftwoarguments}
-\def\doifsamestring {\@@doifsamestringelse\firstofoneargument\gobbleoneargument}
-\def\doifnotsamestring {\@@doifsamestringelse\gobbleoneargument\firstofoneargument}
-
-%D \macros
-%D {ExpandFirstAfter,ExpandSecondAfter,ExpandBothAfter}
-%D
-%D These three commands support expansion of arguments before
-%D executing the commands that uses them. We can best
-%D illustrate this with an example.
-%D
-%D \starttyping
-%D \def\first {alfa,beta,gamma}
-%D \def\second {alfa,epsilon,zeta}
-%D
-%D \ExpandFirstAfter \doifcommon {\first} {alfa} {\message{OK}}
-%D \ExpandSecondAfter \doifcommon {alfa} {\second} {\message{OK}}
-%D \ExpandBothAfter \doifcommon {\first} {\second} {\message{OK}}
-%D
-%D \ExpandFirstAfter\processcommalist[\first]\message
-%D
-%D \ExpandAfter \doifcommon {\first} {alfa} {\message{OK}}
-%D \stoptyping
-%D
-%D The first three calls result in the threefold message
-%D \type{OK}, the fourth one shows the three elements of
-%D \type{\first}. The command \type{\ExpandFirstAfter} takes
-%D care of (first) arguments that are delimited by \type{[ ]},
-%D but the faster \type{\ExpandAfter} does not.
-
-\def\simpleExpandFirstAfter#1%
- {\long\xdef\@@expanded{\noexpand\ExpandCommand{#1}}\@@expanded}
-
-\def\complexExpandFirstAfter[#1]%
- {\long\xdef\@@expanded{\noexpand\ExpandCommand[#1]}\@@expanded}
-
-\def\ExpandFirstAfter#1%
- {\let\ExpandCommand#1%
- \doifnextoptionalelse\complexExpandFirstAfter\simpleExpandFirstAfter}
-
-\def\ExpandSecondAfter#1#2#3%
- {\scratchtoks{#2}%
- \long\xdef\@@expanded{\noexpand#1{\the\scratchtoks}{#3}}\@@expanded}
-
-\def\ExpandBothAfter#1#2#3%
- {\long\xdef\@@expanded{\noexpand#1{#2}{#3}}\@@expanded}
-
-\def\ExpandAfter#1#2%
- {\long\xdef\@@expanded{\noexpand#1{#2}}\@@expanded}
-
-%D Now we can for instance define \type{\ifinstringelse} as:
-
-\def\ifinstringelse
- {\ExpandBothAfter\p!doifinstringelse}
+\def\doifsamestring {\@@doifsamestringelse\firstofoneargument \gobbleoneargument }
+\def\doifnotsamestring {\@@doifsamestringelse\gobbleoneargument \firstofoneargument }
%D \macros
%D {ConvertToConstant,ConvertConstantAfter}
@@ -4221,7 +4532,7 @@
%D \CONTEXT only defines lowcased macros.
\def\showdefinederror#1#2%
- {\writestatus\m!systems{#1 #2 replaces a macro, use CAPITALS!}}
+ {\writestatus\m!system{#1 #2 replaces a macro, use CAPITALS!}}
\def\checkdefined#1#2#3%
{\doifdefined{#3}{\showdefinederror{#2}{#3}}}
@@ -4283,8 +4594,6 @@
\newtoks\BeforePar
\newtoks\AfterPar
-\let\endoflinetoken=^^M
-
\def\redowithpar\par
{\doifnextcharelse\par\redowithpar\dodowithpar}%
@@ -4419,7 +4728,7 @@
{\ifx#2\empty % redundant but gives cleaner extensions
#4{#1}%
\else\ifnum#1<\zerocount
- \normalexpanded{\noexpand\dorecurse{\number-\number#1}}{#4{-#2#3}}%
+ \normalexpanded{\dorecurse{\number-\number#1}}{#4{-#2#3}}%
\else\ifx#2+%
\dorecurse{#1}{#4{#3}}%
\else
@@ -4434,7 +4743,7 @@
%D \starttyping
%D \bgroup
%D
-%D \catcode`\*=\@@superscript
+%D \catcode`\*=\superscriptcatcode
%D
%D \gdef\redorepeatwithcommand[#1]%
%D {\redodorepeatwithcommand#1*\empty*\relax}
@@ -4941,9 +5250,9 @@
%D \PtToCm{dimension}
%D \stoptyping
-{\catcode`\.=\@@other
- \catcode`\p=\@@other
- \catcode`\t=\@@other
+{\catcode`\.=\othercatcode
+ \catcode`\p=\othercatcode
+ \catcode`\t=\othercatcode
\gdef\WITHOUTPT#1pt{#1}}
\def\withoutpt#1%
@@ -4976,18 +5285,16 @@
\def\numberofpoints #1{\the\numexpr\dimexpr#1\relax/\maxcard\relax}
%D \macros
-%D {swapdimens,swapmacros}
+%D {swapdimens,swapcounts,swapmacros}
%D
%D Simple but effective are the next two macros. There name
%D exactly states their purpose. The \type{\scratchdimen} and
%D \type{\!!stringa} can only be swapped when being the first
%D argument.
-\def\swapdimens#1#2%
- {\scratchdimen #1\redoglobal #1#2\dodoglobal #2\scratchdimen}
-
-\def\swapmacros#1#2%
- {\let\!!stringa#1\redoglobal\let#1#2\dodoglobal\let#2\!!stringa}
+\def\swapdimens#1#2{\scratchdimen #1\redoglobal #1#2\dodoglobal #2\scratchdimen}
+\def\swapcounts#1#2{\scratchcounter#1\redoglobal #1#2\dodoglobal #2\scratchcounter}
+\def\swapmacros#1#2{\let\!!stringa #1\redoglobal\let#1#2\dodoglobal\let#2\!!stringa}
%D \macros
%D {pushmacro,popmacro}
@@ -5259,38 +5566,38 @@
%D We have to use a two||step implementation, because the
%D expansion has to take place outside \type{\uppercase}.
-\def\p!DOIF#1#2%
- {\uppercase{\ifinstringelse{$#1$}{$#2$}}%
+\unexpanded\def\DOIF#1#2%
+ {\uppercase{{$#1$}{$#2$}}%
\expandafter\firstofoneargument
\else
\expandafter\gobbleoneargument
\fi}
-\def\p!DOIFNOT#1#2%
- {\uppercase{\ifinstringelse{$#1$}{$#2$}}%
+\unexpanded\def\DOIFNOT#1#2%
+ {\uppercase{{$#1$}{$#2$}}%
\expandafter\gobbleoneargument
\else
\expandafter\firstofoneargument
\fi}
-\def\p!DOIFELSE#1#2%
- {\uppercase{\ifinstringelse{$#1$}{$#2$}}%
+\unexpanded\def\DOIFELSE#1#2%
+ {\uppercase{{$#1$}{$#2$}}%
\expandafter\firstoftwoarguments
\else
\expandafter\secondoftwoarguments
\fi}
-\def\p!DOIFINSTRINGELSE#1#2%
- {\uppercase{\ifinstringelse{#1}{#2}}%
+\unexpanded\def\DOIFINSTRINGELSE#1#2%
+ {\uppercase{{$#1$}{$#2$}}%
\expandafter\firstoftwoarguments
\else
\expandafter\secondoftwoarguments
\fi}
-\def\DOIF {\ExpandBothAfter\p!DOIF}
-\def\DOIFNOT {\ExpandBothAfter\p!DOIFNOT}
-\def\DOIFELSE {\ExpandBothAfter\p!DOIFELSE}
-\def\DOIFINSTRINGELSE {\ExpandBothAfter\p!DOIFINSTRINGELSE}
+\def\DOIF #1#2{\normalexpanded{\p!DOIF {#1}{#2}}}
+\def\DOIFNOT #1#2{\normalexpanded{\p!DOIFNOT {#1}{#2}}}
+\def\DOIFELSE #1#2{\normalexpanded{\p!DOIFELSE {#1}{#2}}}
+\def\DOIFINSTRINGELSE #1#2{\normalexpanded{\p!DOIFINSTRINGELSE{#1}{#2}}}
%D \macros
%D {dosingleargumentwithset,
@@ -5619,8 +5926,8 @@
\def\untexsomething
{\begingroup
- \catcode`\{=\@@ignore
- \catcode`\}=\@@ignore
+ \catcode\leftbraceasciicode \ignorecatcode
+ \catcode\rightbraceasciicode\ignorecatcode
\escapechar\minusone
\dountexsomething}
@@ -5896,8 +6203,18 @@
%D helps a lot. The second boolena can be used to inhibit
%D processing completely.
-\newif\iftrialtypesetting \trialtypesettingfalse
-\newif\ifvisible \visibletrue
+\newif\ifvisible \visibletrue
+
+\newtoks\everysettrialtypesetting
+\newtoks\everyresettrialtypesetting
+
+\unexpanded\def\settrialtypesetting {\the\everysettrialtypesetting } % obeys grouping so
+\unexpanded\def\resettrialtypesetting{\the\everyresettrialtypesetting} % this one is seldom needed
+
+\let\iftrialtypesetting\iffalse % so we have no \trialtypesettingtrue|false in mkiv !
+
+\appendtoks \let\iftrialtypesetting\iftrue \to \everysettrialtypesetting
+\appendtoks \let\iftrialtypesetting\iffalse \to \everyresettrialtypesetting
%D \macros
%D {startlocal, startglobal}
@@ -6403,10 +6720,11 @@
%D
%D This is a dirty one: we simply append a unit and discard it when needed.
-\newdimen\roundingeps \roundingeps=10sp
+\newdimen \roundingeps \roundingeps=10sp
+\newconstant\compresult
\def\comparedimension#1#2%
- {\chardef\compresult
+ {\compresult
\ifdim#1<#2%
\zerocount
\else\ifdim#1<#2%
@@ -6416,7 +6734,7 @@
\fi\fi}
\def\comparedimensioneps#1#2% todo: use eps feature
- {\chardef\compresult
+ {\compresult
\ifdim\dimexpr#1-#2\relax<\roudingeps
\zerocount
\else\ifdim\dimexpr#2-#1\relax<\roudingeps
@@ -6461,9 +6779,10 @@
\dounspaced}
\def\unspaceargument#1\to#2%
- {\scratchcounter\catcode32\relax
- \catcode32\@@ignore\scantextokens{\edef#2{#1}}%
- \catcode32\scratchcounter}
+ {\scratchcounter\catcode\spaceasciicode
+ \catcode\spaceasciicode\ignorecatcode
+ \scantextokens{\edef#2{#1}}%
+ \catcode\spaceasciicode\scratchcounter}
\def\unspaceafter#1#2%
{\unspaceargument#2\to\ascii
@@ -6609,8 +6928,8 @@
% \fi
% \def\elapsedseconds{\expandafter\withoutpt\the\dimexpr\elapsedtime sp\relax}
-\def\resettimer {\ctxlua{commands.resettimer()}}
-\def\elapsedtime {\ctxlua{commands.elapsedtime()}}
+\def\resettimer {\ctxcommand{resettimer()}}
+\def\elapsedtime {\ctxcommand{elapsedtime()}}
\let\elapsedseconds \elapsedtime
\newcount\featuretest
@@ -6624,10 +6943,10 @@
\def\retestfeature % timer support is new per 10/5/2005
{\bgroup
\ifcase\interactionmode\let\wait\relax\fi
- \writestatus\m!systems{starting feature test}\wait
+ \writestatus\m!system{starting feature test}\wait
\resettimer
\featuretest\zerocount \dotestfeature
- \writestatus\m!systems{feature test done (\elapsedseconds s)}%
+ \writestatus\m!system{feature test done (\elapsedseconds s)}%
\wait
\egroup}
@@ -6659,32 +6978,6 @@
\def\negated#1{\if-#1\else-#1\fi} % does only work in macros or text
-% This permits things like ^\index{hans}^, where hans is
-% duplicated in the text.
-
-\newif\ifduplicate
-
-\bgroup
-
-\gdef\checkduplication % in line with Knuth
- {\ifmmode\expandafter^\else\expandafter\startduplication\fi}
-
-\gdef\insideduplication
- {\ifmmode\expandafter^\else\expandafter\egroup\fi}
-
-\catcode`\^=\@@active
-
-\gdef\enableduplication
- {\catcode`\^=\@@active \let^\checkduplication}
-
-\gdef\disableduplication
- {\catcode`\^=\@@superscript}
-
-\gdef\startduplication
- {\bgroup \duplicatetrue \let^\insideduplication}
-
-\egroup
-
\def\gobbleassigndimen#1\\{}
\def\assigndimen#1#2%
@@ -6744,14 +7037,6 @@
\long\def\@@if@@equal@@true #1\@@then#2#3{#2}
\long\def\@@if@@equal@@false#1\@@then#2#3{#3}
-%D new stuff :
-
-\def\partialexpanded#1%
- {\let\@@notexpanded\noexpand
- \long\xdef\@@expanded{\noexpand#1}%
- \let\@@notexpanded\empty
- \@@expanded}
-
\def\appended#1#2#3{\@EA#1\@EA#2\@EA{#2#3}}
\def\appendvalue #1{\@EA\appended\@EA \def\csname#1\endcsname}
\def\appendgvalue#1{\@EA\appended\@EA\gdef\csname#1\endcsname}
@@ -6769,6 +7054,8 @@
%D bibliography module. The numbers compressor converts the
%D list in a list of ranges. The normal compressor remove duplicate
%D and empty entries.
+%D
+%D This is now obsolete (and more a \LUA\ thing anyway).
\def\compresscommalistnrs[#1]%
{\let\compressedlist\empty
@@ -6877,18 +7164,6 @@
%D \stoplines
%D \macros
-%D {stripstring}
-%D
-%D Needed in bookmarks:
-%D
-%D \starttyping
-%D {\sanitizePDFdocencoding test \CONTEXT\ test \to\oeps\stripstring\oeps\tttf[\oeps]}
-%D \stoptyping
-
-\def\stripstring#1% #1 is \cs
- {\edef\cs{\ctxlua{tex.sprint(tex.vrbcatcodes,string.strip(\!!bs\detokenize\expandafter{#1}\!!es))}}}
-
-%D \macros
%D {dowithrange}
%D
%D This one is for Mojca Miklavec, who made me aware of the fact that
@@ -6954,6 +7229,7 @@
\def\doprocesswords#1 #2\od
{\doifsomething{#1}{\processword{#1} \doprocesswords#2 \od}}
+% {\doifsomething{\detokenize{#1}}{\processword{#1} \doprocesswords#2 \od}} % to be tested
\def\processwords#1%
{\doprocesswords#1 \od}% no \unskip
@@ -7012,7 +7288,18 @@
%D A variant for \type {\executeifdefined}:
-\def\expandcheckedcsname#1#2#3%
+% \def\expandcheckedcsname#1#2#3%
+% {\csname#1\ifcsname#1#2\endcsname#2\else#3\fi\endcsname}
+
+\def\expandcheckedcsname#1#2% #2 is often a \xxxparameter so let's expand it once
+ {\normalexpanded{\noexpand\doexpandcheckedcsname{#1}{#2}}}
+
+\def\doexpandcheckedcsname#1#2#3%
{\csname#1\ifcsname#1#2\endcsname#2\else#3\fi\endcsname}
+%D Signal. Some fonts have a char0 rendering so we need to make sure that it
+%D is not set in the font!
+
+\unexpanded\def\signalcharacter{\char\zerocount} % \zwj
+
\protect \endinput