Hello,

On Fri, Sep 09, 2005 at 02:09:01PM +0200, Ralf Wildenhues wrote:
> Second: Autoconf bug: AU_ALIAS mumbles with the number of arguments:

A modified version of Ralf's example:

cat >configure.ac <<\EOF
AC_INIT
AC_DEFUN([FOO],
         [echo foo: $#])
AU_ALIAS([BAZ],[FOO])
FOO
FOO()
FOO(1)
echo ==
BAZ
BAZ()
BAZ(1)
AC_OUTPUT
EOF
autoconf
./configure

leads to:

foo: 0
foo: 1
foo: 1
==
foo: 1
foo: 1
foo: 2

Attached please find a patch which fixes that.

A test has to be written, to make sure that "AC_STDC_HEADERS" is
indeed autoupdated to "AC_HEADER_STDC", and not to "AC_HEADER_STDC([])".

Ralf, would you volunteer to write the test?

Have a nice day,
        Stepan
We should autotest this with AC_STDC_HEADERS.

Index: bin/autoupdate.in
===================================================================
RCS file: /cvsroot/autoconf/autoconf/bin/autoupdate.in,v
retrieving revision 1.55
diff -u -r1.55 autoupdate.in
--- bin/autoupdate.in   14 May 2005 07:00:39 -0000      1.55
+++ bin/autoupdate.in   20 Oct 2005 07:59:18 -0000
@@ -227,7 +227,7 @@
   print $unac_m4 "# unac.m4 -- undefine the AC macros.\n";
   foreach (sort grep { $ac_macros{$_} ne 'm4sugar' } keys %ac_macros)
     {
-      print $ac_m4   "_au_define([$_], [[\$0(\$\@)]])\n";
+      print $ac_m4   "_au_define([$_], [m4_if(\$#, 0, [[\$0]], 
[[\$0(\$\@)]])])\n";
       print $unac_m4 "_au_undefine([$_])\n";
     }
 }
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.930
diff -u -r1.930 autoconf.texi
--- doc/autoconf.texi   19 Oct 2005 22:35:51 -0000      1.930
+++ doc/autoconf.texi   20 Oct 2005 07:59:19 -0000
@@ -9494,6 +9494,12 @@
 in the updated @file{configure.ac} file.
 @end defmac
 
[EMAIL PROTECTED] AU_ALIAS (@var{old-name}, @var{new-name})
[EMAIL PROTECTED]
+Used if the @var{old-name} is to be replaced by a call to @var{new-macro}
+with the same parameters.  This happens for example if the macro was renamed.
[EMAIL PROTECTED] defmac
+
 @node Coding Style
 @section Coding Style
 @cindex Coding style
Index: lib/autoconf/autoupdate.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/autoupdate.m4,v
retrieving revision 1.10
diff -u -r1.10 autoupdate.m4
--- lib/autoconf/autoupdate.m4  14 May 2005 07:00:39 -0000      1.10
+++ lib/autoconf/autoupdate.m4  20 Oct 2005 07:59:19 -0000
@@ -2,7 +2,7 @@
 # Interface with autoupdate.
 
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2003, 2004 Free Software Foundation, Inc.
+# 2003, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -115,5 +115,16 @@
 #
 # Do not use `defn' since then autoupdate would replace an old macro
 # call with the new macro body instead of the new macro call.
+#
+# Moreover, we have to take care that calls without parameters are
+# expanded to calls without parameters, not with one empty parameter.
+# This is not only an aesthetical improvement of autoupdate, it also
+# matters with poorly written macros which test for $# = 0.
+#
 m4_define([AU_ALIAS],
-[AU_DEFUN([$1], [$2($][@)])])
+[AU_DEFUN([$1], _AU_ALIAS_BODY([$], [$2]))])
+
+# The body for the AU_DEFUN above should look like:
+#      [m4_if($#, 0, [NEW-NAME], [NEW-NAME($@)])]
+# Thus the helper macro is:
+m4_define([_AU_ALIAS_BODY], [[m4_if($1#, 0, [$2], [$2($1@)])]])

Reply via email to