[dev-context] bug in processeparatedlist

Hans Hagen pragma at wxs.nl
Sun Mar 9 19:33:36 CET 2008


Vit Zyka wrote:
> Hi,
> 
> there is a bug in \doprocessseparatedlist (syst-ext.tex). Problem is if 
> a list item starts with a single_char followed by a space. See line 5:
> 
> ----------------------------------------------
> \starttext
> \def\Do#1{(#1)}
>    1\processseparatedlist[{aap noot}]  [ ]\Do \par
>    2\processseparatedlist[{aap} {noot}][ ]\Do \par
>    3\processseparatedlist[aap {noot}]  [ ]\Do \par
>    4\processseparatedlist[aap noot]    [ ]\Do \par
>    5\processseparatedlist[aap;noot;a noot;noot a; noot a noot][;]\Do \par
>    6\processseparatedlist[][;]\Do \par
>    7\processseparatedlist[;][;]\Do \par
> \stoptext
> -------------------------------------------------
> 
> it returns
>    (aap noot)
>    (aap)(noot)
>    (aap)(noot)
>    (aap)(noot)
>    (aap)(noot)noot(a)(noot a)(noot a noot)
>               ^^^^^^^
> 
> Solution:
> \def\doprocessseparatedlist#1]#2[#3]#4%
>    {\def\dodoprocessseparatedlist##1##2#3%
>       {\def\tmp{##2}% ------------------------------- new
>        \if]##1%
>          \let\dodoprocessseparatedlist\relax
>        \else\if]##2%
>          \let\dodoprocessseparatedlist\relax
>        %\else\ifx\blankspace##2%
>        \else\ifx\blankspace\tmp % ------------------- new
>          #4{##1}%
>        \else
>          #4{##1##2}%
>        \fi\fi\fi
>        \dodoprocessseparatedlist}%
>     \@EA\dodoprocessseparatedlist\gobbleoneargument#1#3]#3}
> 

then maybe also better test for the space first

\def\doprocessseparatedlist#1]#2[#3]#4%
    {\def\dodoprocessseparatedlist##1##2#3%
       {\def\!!stringa{##2}% suggested by VZ
        \if]##1%
          \let\dodoprocessseparatedlist\relax
        \else\ifx\blankspace\!!stringa
          #4{##1}%
        \else\if]##2%
          \let\dodoprocessseparatedlist\relax
        \else
          #4{##1##2}%
        \fi\fi\fi
        \dodoprocessseparatedlist}%
     \@EA\dodoprocessseparatedlist\gobbleoneargument#1#3]#3}


-----------------------------------------------------------------
                                           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
-----------------------------------------------------------------


More information about the dev-context mailing list