m4-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: protect my comma


From: Stepan Kasal
Subject: Re: protect my comma
Date: Sun, 8 Jan 2006 15:12:14 +0100
User-agent: Mutt/1.4.1i

Hello Marc,

> define(`LISTITEM', `ifelse($1,`',,`<li>$1</li>
> LISTITEM(shift($*))')')dnl
> define(UL,`<ul>
> LISTITEM($@)</ul>')dnl

> UL(sed, awk, ``m4, first experience'')

the first obvious bug here is the $* on the second line.
You should use $@ to pass the argument list to `shift.'

Change that, and your example will work as expected.

Second, you should quote the first argument of ifelse.  (Remember,
the parameter replacement heppens independently on quoting.)
This problem will manifest itself if the argument with comma were
not double quoted.

Observe:

define(`LISTITEM', `ifelse(`$1',`',,`<li>$1</li>
LISTITEM(shift($@))')')dnl
define(UL,`<ul>
LISTITEM($@)</ul>')dnl

UL(sed, awk, ``m4, first experience'')

define(`SECOND', ``second experience'')
UL(sed, awk, `m4, SECOND')

Have a nice day,
        Stepan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]