On 2010-11-04 22:28 +0100, Stefano Lattarini wrote:
> On Thursday 04 November 2010, Nick Bowler wrote:
> > On 2010-11-04 20:47 +0100, Stefano Lattarini wrote:
> > > +AC_DEFUN([MY_DEFUN], [m4_apply([AC_DEFUN], [$1], [$2])])
> > 
> > This is insufficiently quoted, it should be:
> >                         [m4_apply([AC_DEFUN], [[$1], [$2]])]
> I'm not an m4 quoting guru, but I think that one single level of quotes
> is sufficient to avoid *spurious* expansions.  Do you have any reason or
> example showing that two levels of quotes are indeed needed?

"Insufficient quoting" was probably the wrong term to use here -- you
are right that spurious expansion is avoided.   The problem is the use
of m4_apply, which takes two arguments: the first is the (quoted) name
of the macro, and the second is the (quoted) list of arguments.  So in
effect, this MY_DEFUN macro will only ever call AC_DEFUN with one
argument (because the third argument to m4_apply is discarded).

For a specific example, try running the configure script generated by
the following configure.ac:

  AC_INIT([test], [1.0])
  
  AC_DEFUN([DEFONE], [m4_apply([AC_DEFUN], [$1], [$2])])
  AC_DEFUN([DEFTWO], [m4_apply([AC_DEFUN], [[$1], [$2]])])
  
  DEFONE([HELLO], [echo "Hello, World"])
  DEFTWO([GOODBYE], [echo "Goodbye, World"])
  
  HELLO
  GOODBYE

  AC_OUTPUT

-- 
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)

Reply via email to