summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/syst-ext.tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-11-16 01:02:47 +0000
committerKarl Berry <karl@freefriends.org>2006-11-16 01:02:47 +0000
commit3c85b55e2f245fb7edac7e445f107e6d0bb423ae (patch)
treec62b7f80edafe0455310d08e09f4218127bf9e87 /Master/texmf-dist/tex/context/base/syst-ext.tex
parente5ecff27a26ef59e1dbe9702677687fd7107be3a (diff)
context update
git-svn-id: svn://tug.org/texlive/trunk@2444 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/syst-ext.tex')
-rw-r--r--Master/texmf-dist/tex/context/base/syst-ext.tex211
1 files changed, 152 insertions, 59 deletions
diff --git a/Master/texmf-dist/tex/context/base/syst-ext.tex b/Master/texmf-dist/tex/context/base/syst-ext.tex
index 51376ce78c7..82e6bc2e77c 100644
--- a/Master/texmf-dist/tex/context/base/syst-ext.tex
+++ b/Master/texmf-dist/tex/context/base/syst-ext.tex
@@ -394,9 +394,21 @@
%D \stoptyping
%D
%D This expands to \type{\ifsomething}.
+%D
+%D \starttyping
+%D \def\strippedcsname
+%D {\expandafter\gobbleoneargument\string}
+%D \stoptyping
+%D
+%D Slower but better:
+
+{\catcode`.=\@@escape .catcode`.\ 12 .xdef.letterbackslash{.string\}} % hack
\def\strippedcsname
- {\expandafter\gobbleoneargument\string}
+ {\expandafter\dostrippedcsname\string}
+
+\def\dostrippedcsname#1%
+ {\if\noexpand#1\letterbackslash\else#1\fi}
%D \macros
%D {savenormalmeaning}
@@ -1139,11 +1151,35 @@
\long\def\convertcommand#1\to#2%
{\dodoglobal\edef#2{\convertedcommand#1}}
+\long\def\defconvertedargument#1#2% less sensitive for \to
+ {\long\def#1{#2}% saves a restore
+ \dodoglobal\edef#1{\convertedcommand#1}}
+
+\long\def\defconvertedcommand#1#2% less sensitive for \to
+ {\dodoglobal\edef#1{\convertedcommand#2}}
+
\endTEX
\def\convertvalue#1\to
{\expandafter\convertcommand\csname#1\endcsname\to}
+\def\defconvertvalue#1#2% less sensitive for \to
+ {\@EA\defconvertcommand\@EA#1\csname#2\endcsname}
+
+%D \macros
+%D {convertasciiafter}
+%D
+%D Sometimes we need to convert an argument to a string (letters
+%D only), for instance when we compare it with another string:
+%D
+%D \starttyping
+%D \convertasciiafter\doifinstringelse{em}{\ascii}{...}
+%D \stoptyping
+
+\def\convertasciiafter#1#2%
+ {\convertargument#2\to\asciiafter
+ \@EA#1\@EA{\asciiafter}}
+
%D In \ETEX\ we can use \type {\detokenize} and gain some
%D speed, but in general far less that 1\% for \type
%D {\convertargument} and nil for \type {\convertcommand}.
@@ -1160,7 +1196,13 @@
% {\@EA\dodoglobal\@EA\edef\@EA#2\@EA{\@EA\detokenize\@EA{#1}}}
\long\def\convertcommand#1\to#2%
- {\dodoglobal\edef#2{\@EA\detokenize\@EA{#1}}}
+ {\dodoglobal\edef#2{\@EA\detokenize\@EA{#1}}} % hm, only second is also ok
+
+\long\def\defconvertedargument#1#2% less sensitive for \to
+ {\dodoglobal\edef#1{\detokenize{#2}}}
+
+\long\def\defconvertedcommand#1#2% less sensitive for \to
+ {\dodoglobal\edef#1{\detokenize\@EA{#2}}}
\endETEX
@@ -1619,6 +1661,14 @@
\afterassignment\BeforeGroup
\let\next=}
+\long\def\HandleSimpleGroup#1#2% no inner group (so no kerning interference)
+ {\bgroup
+ \long\def\BeforeGroup{\bgroup#1\aftergroup\AfterGroup}% interferes
+ \long\def\BeforeGroup{\bgroup\aftergroup\AfterGroup#1}%
+ \long\def\AfterGroup {#2\egroup}%
+ \afterassignment\BeforeGroup
+ \let\next=}
+
\long\def\HandleNoGroup#1#2%
{\long\def\AfterGroup{#2\egroup}%
\bgroup\aftergroup\AfterGroup#1}
@@ -1670,6 +1720,10 @@
{\doifnextcharelse\bgroup
{\HandleGroup{#1}{#2}}{\HandleNoGroup{#1}{#2}}}
+\long\unexpanded\def\simplegroupedcommand#1#2%
+ {\doifnextcharelse\bgroup
+ {\HandleSimpleGroup{#1}{#2}}{\HandleNoGroup{#1}{#2}}}
+
%D Users should be aware of the fact that grouping can
%D interfere with ones paragraph settings that are executed
%D after the paragraph is closed. One should therefore
@@ -2352,7 +2406,7 @@
\def\resetcounter#1%
{\letgvalue{#1}\zerocountervalue}
-\def\setcounter#1#2%
+\def\setcounter#1#2% or: \setxvalue{#1}{\number#2}
{\scratchcounter#2%
\setxvalue{#1}{\the\scratchcounter}}
@@ -2546,7 +2600,7 @@
%D A first application of the two routines defined above is:
%D
%D \starttyping
-%D \removesubstringtest-\from first-last\to\nothyphenated
+%D \removesubstring-\from first-last\to\nothyphenated
%D \stoptyping
%D
%D Which in terms of \TEX\ looks like:
@@ -2677,6 +2731,19 @@
{\rawdoifinsetelse{#1}#2\resetglobal
{\dodoglobal\edef#2{#1\ifx#2\empty\else,#2\fi}}}
+\def\robustdoifinsetelse#1#2%
+ {\expanded{\convertargument#1}\to\!!stringa
+ \expanded{\convertargument#2}\to\!!stringb
+ \rawdoifinsetelse\!!stringa\!!stringb}
+
+\def\robustaddtocommalist#1#2% {item} \cs
+ {\robustdoifinsetelse{#1}#2\resetglobal
+ {\dodoglobal\edef#2{\ifx#2\empty\else#2,\fi#1}}}
+
+\def\robustpretocommalist#1#2% {item} \cs
+ {\robustdoifinsetelse{#1}#2\resetglobal
+ {\dodoglobal\edef#2{#1\ifx#2\empty\else,#2\fi}}}
+
\def\xsplitstring#1#2% \cs {str}
{\def\dosplitstring##1,#2,##2,#2,##3\\%
{\edef\!!stringa{\bcleanedupcommalist##1\empty\empty\relax}%
@@ -3428,6 +3495,19 @@
%D As we can see below, spaces following a control sequence are
%D to enclosed in \type{{}}.
+% keep this one:
+%
+% \def\stripcharacter#1\from#2\to#3%
+% {\def\dostripcharacter##1#1##2\end
+% {\edef\!!strippedstring{\!!strippedstring##1}%
+% \doifnotempty{##2}{\dostripcharacter##2\end}}%
+% \let\!!strippedstring\empty
+% \edef\!!stringa{#2}%
+% \@EA\dostripcharacter\!!stringa#1\end
+% \dodoglobal\let#3\!!strippedstring}
+%
+% the following is better (comes from syst-loc):
+
\def\stripcharacter#1\from#2\to#3%
{\def\dostripcharacter##1#1##2\end
{\edef\!!strippedstring{\!!strippedstring##1}%
@@ -3725,18 +3805,16 @@
%D \processlist(){=>}\docommando(a=>b=>c=>d)
%D \stoptyping
-\def\processlist#1#2#3#4%
+\long\def\processlist#1#2#3#4% no blank skipping !
{\def\doprocesslist##1#2%
{\def\dodoprocesslist####1####2#3%
{\ifx#2####1%
\let\dodoprocesslist\relax
\else\ifx#2####2%
\let\dodoprocesslist\relax
- \else\ifx\blankspace####2%
- #4{####1}%
\else
#4{####1####2}%
- \fi\fi\fi
+ \fi\fi
\dodoprocesslist}%
\expandafter\dodoprocesslist\gobbleoneargument##1#3#2#3}%
\def\dodoprocesslist#1%
@@ -3952,6 +4030,15 @@
\setbox\@@dlhbox\hbox{\mathsurround\zeropoint\everymath\emptytoks$ $}\unhbox\@@dlhbox
\fi \fi}
+% Also ok, but more sensitive to lookahead expansion is:
+%
+% \def\dontleavehmode{\ifvmode \indent \fi}
+%
+% which assumes indent is kept unchanged. Protecting the macro is only
+% possible in etex (watch out: \unexpanded in context is eq to \protected).
+%
+% \unexpanded \def\dontleavehmode{\ifvmode \indent \fi} % functional spec TH
+
%D But, if you run a recent version of \TEX, we can use the new
%D primitive:
@@ -4626,65 +4713,71 @@
%D I'll implement this when I'm in \quotation {writing dirty
%D macros mood}.
+\def\dofilterfromstr#1#2% max n
+ {\ifcase#1\or
+ \ifcase#2\or
+ \strippedcsname\firstofoneargument
+ \else
+ \strippedcsname\gobbleoneargument
+ \fi
+ \or
+ \ifcase#2\or
+ \strippedcsname\firstoftwoarguments
+ \or
+ \strippedcsname\secondoftwoarguments
+ \else
+ \strippedcsname\gobbletwoarguments
+ \fi
+ \or
+ \ifcase#2\or
+ \strippedcsname\firstofthreearguments
+ \or
+ \strippedcsname\secondofthreearguments
+ \or
+ \strippedcsname\thirdofthreearguments
+ \else
+ \strippedcsname\gobblethreearguments
+ \fi
+ \or
+ \ifcase#2\or
+ \strippedcsname\firstoffourarguments
+ \or
+ \strippedcsname\secondoffourarguments
+ \or
+ \strippedcsname\thirdoffourarguments
+ \or
+ \strippedcsname\fourthoffourarguments
+ \else
+ \strippedcsname\gobblefourarguments
+ \fi
+ \or
+ \ifcase#2\or
+ \strippedcsname\firstoffivearguments
+ \or
+ \strippedcsname\secondoffivearguments
+ \or
+ \strippedcsname\thirdoffivearguments
+ \or
+ \strippedcsname\fourthoffivearguments
+ \or
+ \strippedcsname\fifthoffivearguments
+ \else
+ \strippedcsname\gobblefivearguments
+ \fi
+ \fi}
+
\def\filterfromvalue#1#2#3% value max n
{\@EA\@EAEAEA\csname % we use the fact that an
\@EA\ifx\csname#1\endcsname\relax % undefined cs has become \relax
\strippedcsname\gobbleoneargument % which we then gobble here
\else
- \ifcase#2\or
- \ifcase#3\or
- \strippedcsname\firstofoneargument
- \else
- \strippedcsname\gobbleoneargument
- \fi
- \or
- \ifcase#3\or
- \strippedcsname\firstoftwoarguments
- \or
- \strippedcsname\secondoftwoarguments
- \else
- \strippedcsname\gobbletwoarguments
- \fi
- \or
- \ifcase#3\or
- \strippedcsname\firstofthreearguments
- \or
- \strippedcsname\secondofthreearguments
- \or
- \strippedcsname\thirdofthreearguments
- \else
- \strippedcsname\gobblethreearguments
- \fi
- \or
- \ifcase#3\or
- \strippedcsname\firstoffourarguments
- \or
- \strippedcsname\secondoffourarguments
- \or
- \strippedcsname\thirdoffourarguments
- \or
- \strippedcsname\fourthoffourarguments
- \else
- \strippedcsname\gobblefourarguments
- \fi
- \or
- \ifcase#3\or
- \strippedcsname\firstoffivearguments
- \or
- \strippedcsname\secondoffivearguments
- \or
- \strippedcsname\thirdoffivearguments
- \or
- \strippedcsname\fourthoffivearguments
- \or
- \strippedcsname\fifthoffivearguments
- \else
- \strippedcsname\gobblefivearguments
- \fi
- \fi
+ \dofilterfromstr{#2}{#3}%
\fi
\endcsname\csname#1\endcsname}
+\def\filterfromnext#1#2% max n {..}{..}{..}{..}
+ {\csname\dofilterfromstr{#1}{#2}\endcsname}
+
%D \macros
%D {definemeasure}
%D