On 20-3-2010 17:57, Wolfgang Schuster wrote:
Am 20.03.10 13:13, schrieb Hans van der Meer:
WHAT HAPPENED?
Please don't shout as us, it's also polite to provide a minimal example.
Now to your problem.
Hans added recently a interlinespace key to \setuphead and modified \setupinterlinespace for this, the problem with this is that he need to check wheter the argument is a dimension (e.g. 12pt) or a keyword (e.g. big) but the \doifdimensionelse macro fails in this case.
Till Hans fix this here is a adapted dimen checker from KOMA Script.
\unprotect
\definesystemconstant {pc} \definesystemconstant {cm} \definesystemconstant {dd} \definesystemconstant {cc}
\def\ifdimen#1% {\begingroup\donetrue\let\next\test@posdimen \expandafter\test@dimen#1\next \ifdone \endgroup\expandafter\firstoftwoarguments \else \endgroup\expandafter\secondoftwoarguments \fi}
\def\test@dimen#1% {\ifx-#1\else\ifx +#1\else \def\next{\let\next\test@posdimen\next#1}% \fi\fi \next}
\def\test@posdimen#1% {\ifx\next#1% \donefalse\let\next\relax \else \if.#1\else\if,#1\else \scratchcounter=% \expandafter\expandafter\expandafter\number\expandafter`#1\relax \ifnum\scratchcounter>47 \ifnum\scratchcounter<58 \else\def\next{\test@dimunt#1}\fi \else\def\next{\test@dimunt#1}\fi \fi\fi \fi \next}
\def\test@dimunt#1\next {\expandafter\test@trueunt#1truetrue\test@trueunt}
\def\test@trueunt#1true#2true#3\test@trueunt {\edef\!!stringa{#1}% \ifx\!!stringa\empty \test@@ifdimunt{#2}% \else \test@@ifdimunt{#1}% \fi}
%\def\test@@ifdimunt#1% % {\donefalse % \doifelse{#1}\s!pt\donetrue % {\doifelse{#1}\s!pc\donetrue % {\doifelse{#1}\s!in\donetrue % {\doifelse{#1}\s!bp\donetrue % {\doifelse{#1}\s!cm\donetrue % {\doifelse{#1}\s!mm\donetrue % {\doifelse{#1}\s!dd\donetrue % {\doifelse{#1}\s!cc\donetrue % {\doifelse{#1}\s!sp\donetrue % {\doifelse{#1}\c!ex\donetrue % {\doif{#1}\c!em\donetrue}}}}}}}}}}}
\def\test@@ifdimunt#1% {\edef\!!stringa{#1}% \donefalse \ifx\!!stringa\s!pt\donetrue\else \ifx\!!stringa\s!pc\donetrue\else \ifx\!!stringa\s!in\donetrue\else \ifx\!!stringa\s!bp\donetrue\else \ifx\!!stringa\s!cm\donetrue\else \ifx\!!stringa\s!mm\donetrue\else \ifx\!!stringa\s!dd\donetrue\else \ifx\!!stringa\s!cc\donetrue\else \ifx\!!stringa\s!sp\donetrue\else \ifx\!!stringa\c!ex\donetrue\else \ifx\!!stringa\c!em\donetrue \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
\protect
\starttext
12pt: \ifdimen{12pt}{yes}{no}
big: \ifdimen{big}{yes}{no}
34cm: \ifdimen{34cm}{yes}{no}
\dorecurse{100000}{\ifdimen{34cm}{}{}} % \doifelse: 8.6s, \ifx: 7.7s
\stoptext
\chardef\d!pt\plusone \chardef\d!pc\plusone \chardef\d!in\plusone \chardef\d!bp\plusone \chardef\d!cm\plusone \chardef\d!mm\plusone \chardef\d!dd\plusone \chardef\d!cc\plusone \chardef\d!sp\plusone \chardef\d!ex\plusone \chardef\d!em\plusone \def\test@@ifdimunt#1% {\ifcsname d!#1\endcsname \donetrue \else \donefalse \fi} \testfeatureonce{100000}{\ifdimen{34cm}{}{}} 10% faster ... anyhow, quite ugly code ... i'll have a look at why the normal one fails ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------