autoconf-patches
[Top][All Lists]
Advanced

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

Re: faster m4_divert*,m4_cond


From: Ralf Wildenhues
Subject: Re: faster m4_divert*,m4_cond
Date: Tue, 12 Aug 2008 05:34:06 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

Hi Eric,

* Eric Blake wrote on Wed, Aug 06, 2008 at 05:55:46PM CEST:
> Then, I finally figured out how to make m4_cond linear for m4 1.4.x, as well 
> as 
> making it use fewer macro expansions for m4 1.6.

>  2008-08-06  Eric Blake  <address@hidden>
>  
> +     Add linear m4_cond for m4 1.4.x.
> +     * lib/m4sugar/m4sugar.m4 (m4_cond): Split into...
> +     (_m4_cond): ...this, for fewer macros per iteration.
> +     * lib/m4sugar/foreach.m4 (_m4_cond): New implementation.
> +     * tests/m4sugar.at (recursion): Test it.
> +     * NEWS: Document the linear guarantee.
> +

> --- a/lib/m4sugar/m4sugar.m4
> +++ b/lib/m4sugar/m4sugar.m4
> @@ -449,8 +449,14 @@ m4_define([_m4_cdr],
>  m4_define([m4_cond],
>  [m4_if([$#], [0], [m4_fatal([$0: cannot be called without arguments])],
>         [$#], [1], [$1],
> -       [$#], [2], [m4_fatal([$0: missing an argument])],
> -       [m4_if($1, [$2], [$3], [$0(m4_shift3($@))])])])
> +       m4_eval([$# % 3]), [2], [m4_fatal([$0: missing an argument])],
> +       [_$0($@)])])
> +
> +m4_define([_m4_cond],
> +[m4_if(($1), [($2)], [$3],
> +       [$#], [3], [],
> +       [$#], [4], [$4],
> +       [$0(m4_shift3($@))])])

Sorry, but I fail to understand this.  Why does the first line of the
m4_if put its arguments in parentheses, and why is the first argument
not bracket-quoted?  The added test doesn't seem to expose this need.

Thanks,
Ralf




reply via email to

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