summaryrefslogtreecommitdiff
path: root/tex/context/base/syst-new.tex
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/syst-new.tex')
-rw-r--r--tex/context/base/syst-new.tex118
1 files changed, 96 insertions, 22 deletions
diff --git a/tex/context/base/syst-new.tex b/tex/context/base/syst-new.tex
index 5fd8eaaa9..ba6e0bc46 100644
--- a/tex/context/base/syst-new.tex
+++ b/tex/context/base/syst-new.tex
@@ -16,15 +16,19 @@
\unprotect
+% moved from core-ntb
+
+\def\v!oddeven#1{\ifodd#1\v!oneven\else\v!even\fi}
+
% For myself
\newcount\nofprofiled
\def\profilemacro#1%
- {\nofprofiled=0
+ {\nofprofiled\zerocount
\letvalue{\string#1\string#1}#1%
\appendtoks
- \writestatus{\m!systems}{profile \string#1: \number\nofprofiled}%
+ \writestatus\m!systems{profile \string#1: \number\nofprofiled}%
\to \everystoptext
\unexpanded\def#1%
{\global\advance\nofprofiled\plusone
@@ -82,12 +86,12 @@
\the\withlowercharacters
\ifeightbitcharacters\the\withuppercharacters\fi}
-\def\makeallother%
+\def\makeallother
{\doassigncatcodes\@@other}
\chardef\obeyedlccode=`. % so <32 and >127 chars become .
-%\def\obeylccodes%
+%\def\obeylccodes
% {\def\withcharacter##1{\lccode##1##1}%
% \the\withlowercharacters
% \def\withcharacter##1{\lccode##1\obeyedlccode}%
@@ -97,7 +101,7 @@
\def\setownlccode #1{\lccode#1#1}
\def\setobeyedlccode#1{\lccode#1\obeyedlccode}
-\def\obeylccodes%
+\def\obeylccodes
{\let\withcharacter\setownlccode
\the\withlowercharacters
\let\withcharacter\setobeyedlccode
@@ -137,10 +141,10 @@
\def\@flg@{@flg@}
\def\setflag#1%
- {\@EA\dodoglobal\@EA\chardef\csname\@flg@#1\endcsname=0 }
+ {\@EA\dodoglobal\@EA\chardef\csname\@flg@#1\endcsname\zerocount}
\def\resetflag#1%
- {\@EA\dodoglobal\@EA\chardef\csname\@flg@#1\endcsname=1 }
+ {\@EA\dodoglobal\@EA\chardef\csname\@flg@#1\endcsname\plusone}
\let\ifflagged\ifcase
@@ -289,10 +293,10 @@
\def\DoMod#1by#2to#3{\dosetmodulo {#1}{#2}{#3}}
\def\DoDiv#1by#2to#3{\dosetdivision{#1}{#2}{#3}}
-\def\dounprotected#1\par%
+\def\dounprotected#1\par
{#1\protect}
-\def\unprotected%
+\def\unprotected
{\unprotect\dounprotected}
%D Standaard kan een spatie (zoals ~) uitrekken. Dit is in
@@ -349,7 +353,7 @@
\def\testfeature#1#2%
{\def\dotestfeature
- {\advance\featuretest 1
+ {\advance\featuretest \plusone
\ifnum\featuretest<#1\relax#2\expandafter\dotestfeature\fi}%
\retestfeature}
@@ -378,12 +382,12 @@
\newdimen\dimentoaddto
-\def\adddimenregister#1\to#2%
+\def\adddimenregister#1\to#2% will be obsolete once full etex
{\begingroup
#2=\zeropoint
\dimentoaddto\zeropoint
\def\docommando%
- {\advance#2 by \dimentoaddto
+ {\advance#2 \dimentoaddto
\futurelet\next\dodocommando}%
\def\dodocommando%
{\ifx\next\relax
@@ -420,14 +424,14 @@
% \def\rawrecurselevel{\the\rawrecursecounter}%
%
% \def\dorawrecurse#1#2%
-% {\rawrecursecounter=1\relax
+% {\rawrecursecounter\plusone
% \let\oldrecurselevel\recurselevel
% \let\recurselevel\rawrecurselevel
-% \def\dodorawrecurse%
+% \def\dodorawrecurse
% {\ifnum\rawrecursecounter>#1\relax
% \let\recurselevel\oldrecurselevel
% \else
-% #2\advance\rawrecursecounter by 1
+% #2\advance\rawrecursecounter \plusone
% \expandafter\dodorawrecurse
% \fi}%
% \dodorawrecurse}
@@ -439,21 +443,21 @@
\bgroup
-\gdef\checkduplication% in line with Knuth
+\gdef\checkduplication % in line with Knuth
{\ifmmode\expandafter^\else\expandafter\startduplication\fi}
-\gdef\insideduplication%
+\gdef\insideduplication
{\ifmmode\expandafter^\else\expandafter\egroup\fi}
\catcode`\^=\@@active
-\gdef\enableduplication%
+\gdef\enableduplication
{\catcode`\^=\@@active \let^\checkduplication}
-\gdef\disableduplication%
+\gdef\disableduplication
{\catcode`\^=\@@superscript}
-\gdef\startduplication%
+\gdef\startduplication
{\bgroup \duplicatetrue \let^\insideduplication}
\egroup
@@ -499,20 +503,57 @@
\def\dowithstringed#1#2#3#4% " ' space
{\if#4"\@EA#1\else\if#4'\@EAEAEA#2\else\@EAEAEA#3\fi\fi#4}
-\def\unstringed%
+\def\unstringed
{\dowithstringed\unstringdouble\unstringsingle\unstringnothing}
\def\unstringdouble"#1"{#1}
\def\unstringsingle'#1'{#1}
\def\unstringspaced #1 {#1}
-\def\grabstring%
+\def\grabstring
{\dowithstringed\grabstringdouble\grabstringsingle\grabstringspaced}
+\def\dowithgrabbedstring#1%
+ {\def\@@dowithgrabbedstring{#1}%
+ \afterassignment\@@dowithgrabbedstring\grabstring}
+
\def\grabstringdouble"#1"{\scratchtoks{#1}}
\def\grabstringsingle'#1'{\scratchtoks{#1}}
\def\grabstringspaced #1 {\scratchtoks{#1}}
+\def\expifequalelse#1#2%
+ {\@@ifequal#1\relax\relax\@@and#2\relax\relax\@@then}
+
+\def\@@ifequal#1#2\@@and#3%
+ {\ifx#1\relax
+ \ifx#3\relax
+ \@EAEAEA\@@if@@equal@@true
+ \else
+ \@EAEAEA\@@if@@equal@@false
+ \fi
+ \else
+ \ifx#3\relax
+ \@EAEAEAEAEAEA\@@if@@equal@@false
+ \else\ifx#1#3%
+ % go on
+ \else
+ \@EAEAEAEAEAEA\@@if@@equal@@false
+ \fi\fi
+ \fi
+ \@@ifequal#2\@@and}
+
+\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\doifdimensionelse#1%
% {\afterassignment\dodoifdimensionelse\scratchdimen=#1pt\relax\empty\empty\empty\empty}
%
@@ -523,4 +564,37 @@
% \expandafter\secondoftwoarguments
% \fi}
+% for Simon ; watch how we make them fully expandable (i.e.
+% no \type {\relax}es) popping up
+
+\def\@@dothenumber#1\relax#2\end{#1}
+
+\def\@@thenumber#1{\@EA\@@dothenumber\number#1\relax\end}
+
+\def\doifnum#1#2%
+ {\ifnum#1=\@@thenumber{#2} % space needed
+ \expandafter\firstofoneargument
+ \else
+ \expandafter\gobbleoneargument
+ \fi}
+
+\def\doifnotnum#1#2%
+ {\ifnum#1=\@@thenumber{#2} % space needed
+ \expandafter\gobbleoneargument
+ \else
+ \expandafter\firstofoneargument
+ \fi}
+
+\def\doifelsenum#1#2%
+ {\ifnum#1=\@@thenumber{#2} % space needed
+ \expandafter\firstoftwoarguments
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+% \edef\xxxx{\doifnum{1}{2}{no}} \show \xxxx
+% \edef\xxxx{\doifnum{2}{2}{yes}} \show \xxxx
+% \scratchcounter0 \edef\xxxx{\doifnum{1}{\scratchcounter}{no}} \show \xxxx
+% \scratchcounter1 \edef\xxxx{\doifnum{1}{\scratchcounter}{yes}} \show \xxxx
+
\protect \endinput