In an ancient message, Pavel Aksonov wrote:
> Could you help me?
> ================================================
> define(_if,`<if cond="$1">$2<else/>$3</if>')dnl
> define(_goto,`<goto next="#$1"/>')dnl
> define(_if_goto,`_if($1,`_goto($1)',`_goto($2)')')dnl
> _if_goto(a, b, c)
> ================================================
> Why this cod gives:
> <if cond="a"><goto next="#a"/><else/>_goto(b)</if>
>
> instead of
>
> <if cond="a"><goto next="#a"/><else/><goto next="#b"/></if>
Just incase you didn't figure this out by other means, the reason is that
`#' is the m4 comment start character, and rescanning stops when it sees
an unquoted comment start. The following all work correctly:
$ m4
define(`_if', `<if cond="$1">$2<else/>$3</if>')dnl
define(`_goto', `<goto next="$1"/>')dnl
define(`_if_goto', `_if($1,`_goto($1)',`_goto($2)')')dnl
_if_goto(a, b, c)
<if cond="a"><goto next="a"/><else/><goto next="b"/></if>
define(`_goto', `<goto next="`#'$1"/>')dnl
_if_goto(a, b, c)
<if cond="a"><goto next="#a"/><else/><goto next="#b"/></if>
define(`_goto', `<goto next="#$1"/>')dnl
changecom(`', `')dnl
_if_goto(a, b, c)
<if cond="a"><goto next="#a"/><else/><goto next="#b"/></if>
Cheers,
Gary.
--
())_. Gary V. Vaughan gary@(oranda.demon.co.uk|gnu.org)
( '/ Research Scientist http://www.oranda.demon.co.uk ,_())____
/ )= GNU Hacker http://www.gnu.org/software/libtool \' `&
`(_~)_ Tech' Author http://sources.redhat.com/autobook =`---d__/
_______________________________________________
Bug-m4 mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-m4