Re: Fix LT_WITH_LTDL: AU_ALIAS bug

2005-11-09 Thread Paul Eggert
Thanks, Ralf; can you please install those two patches?




Re: Fix LT_WITH_LTDL: AU_ALIAS bug

2005-11-04 Thread Ralf Wildenhues
Hello again,

* Ralf Wildenhues wrote on Mon, Oct 24, 2005 at 05:56:41PM CEST:
 * Stepan Kasal wrote on Thu, Oct 20, 2005 at 10:19:24AM CEST:
  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 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([]).
 
  We should autotest this with AC_STDC_HEADERS.
 
 Below is a test suggestion that includes above checking and
 AC_HEADER_STDC.

And here is an updated test, including a couple of suggestions Stepan
made off-list.  Also, a bug fix for this test:
|   10: tools.at:497   autoupdate

which fails otherwise, when Stepan's fix is applied.  It would be useful
to apply this patch along with it.

Cheers,
Ralf

* tests/tools.at (autoupdating AU_ALIAS): New test for AU_ALIAS
`$#' bug.
(autoupdate): Updated to match AU_ALIAS fix.

Index: tests/tools.at
===
RCS file: /cvsroot/autoconf/autoconf/tests/tools.at,v
retrieving revision 1.78
diff -u -r1.78 tools.at
--- tests/tools.at  25 Jul 2005 18:10:25 -  1.78
+++ tests/tools.at  5 Nov 2005 06:38:31 -
@@ -506,7 +506,7 @@
 
 AT_DATA([expout],
 [[AC_INIT([Test],[1.0])
-AC_CANONICAL_TARGET([])
+AC_CANONICAL_TARGET
 # The doc says 27 is a valid fubar.
 fubar=27
 AC_CONFIG_FILES([Makefile])
@@ -568,5 +568,29 @@
 
 AT_CHECK([echo AC_PREREQ(999.99) | autoupdate -],
 63, [], [ignore])
+
+AT_CLEANUP
+
+
+# autoupdating AU_ALIAS
+# -
+AT_SETUP([autoupdating AU_ALIAS])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_DEFUN([FOO], [$#])
+AU_ALIAS([BAZ],[FOO])
+test FOO:FOO():FOO(x) BAZ:BAZ():BAZ(x) = 0:1:1 0:1:1 || exit 1
+AC_PROG_CC
+AC_STDC_HEADERS
+AC_OUTPUT
+]])
+
+# Checking `autoupdate'.
+AT_CHECK_AUTOUPDATE
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+AT_CHECK([grep 'AC_HEADER_STDC(' configure.ac], 1, [ignore], [ignore])
+AT_CHECK([grep 'AC_HEADER_STDC' configure.ac], 0, [ignore], [ignore])
 
 AT_CLEANUP




Re: Fix LT_WITH_LTDL: AU_ALIAS bug

2005-10-27 Thread Ralf Wildenhues
Hi Stepan,

* Stepan Kasal wrote on Tue, Oct 25, 2005 at 01:16:06PM CEST:
 On Sat, Sep 10, 2005 at 04:17:52PM +0100, Gary V. Vaughan wrote:
  :-(  Can you document in HACKING that because of our use of AU_ALIAS to
  maintain backwards compatibility with earlier libtool interfaces we must
  not use $# in m4.
 
 actually, I'd prefer if you could put it this way:
*snip*

Can the Autoconf manual also please _explicitly_ *warn* against using
`$#' at all in macros?

 [ put in public domain, in case you want to paste it somewhere ;-) ]

FYI, public domain is not the same thing as copyright assignment;
disclaimer is ok, though.

Also FYI: I have applied the patch below to Libtool CVS HEAD.

Cheers,
Ralf

2005-10-27  Stepan Kasal  [EMAIL PROTECTED]

* HACKING: Update note about use of `$#' in m4 macros.

Index: HACKING
===
RCS file: /cvsroot/libtool/libtool/HACKING,v
retrieving revision 1.21
diff -u -r1.21 HACKING
--- HACKING 26 Sep 2005 12:21:53 -  1.21
+++ HACKING 27 Oct 2005 13:23:13 -
@@ -241,8 +241,11 @@
$ECHO ..  for strings without leading hyphen,
$ECHO X.. | $Xsed otherwise.
 
-* Do not use the number of macro arguments `$#' in public macros;
-  AU_ALIAS may change it.
+* The Autoconf manual says that giving an empty parameter is equivalent
+  to not giving it at all.  (In particular, the Autoconf manual doesn't
+  explain that FOO() is calling macro FOO with one empty parameter.)
+  To prevent misunderstanding, we should use m4_ifval to check whether
+  a parameter is empty, and not $# to check for the number of parameters.
 
 
 9. Abstraction layers in libltdl




Re: Fix LT_WITH_LTDL: AU_ALIAS bug

2005-10-25 Thread Stepan Kasal
Hello,

On Sat, Sep 10, 2005 at 04:17:52PM +0100, Gary V. Vaughan wrote:
 :-(  Can you document in HACKING that because of our use of AU_ALIAS to
 maintain backwards compatibility with earlier libtool interfaces we must
 not use $# in m4.

actually, I'd prefer if you could put it this way:

The Autoconf manual says that giving an empty parameter is equivalent
to not giving it at all.
(In particular, the Autoconf manual doesn't explain that
FOO() is calling macro FOO with one empty parameter.)
To prevent misunderstanding, we should use m4_ifval to check whether
a parameter is empty, and not $# to check for the number of parameters.

[ put in public domain, in case you want to paste it somewhere ;-) ]

Have a nice day,
Stepan




Re: Fix LT_WITH_LTDL: AU_ALIAS bug

2005-10-24 Thread Ralf Wildenhues
Hi Stepan,

Sorry for the delay.

* Stepan Kasal wrote on Thu, Oct 20, 2005 at 10:19:24AM CEST:
 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:
*snip* (see in patch below)

 leads to:
 
 foo: 0
 foo: 1
 foo: 1
 ==
 foo: 1
 foo: 1
 foo: 2

Weird. Over here, it leads to:
foo: 0
foo: 1
foo: 1
==
foo: 1
foo: 1
foo: 1

with both autoconf-2.59 and CVS HEAD.  It's also what I reported
earlier.  Typo?

 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([]).

 We should autotest this with AC_STDC_HEADERS.

Below is a test suggestion that includes above checking and
AC_HEADER_STDC.

Cheers,
Ralf

* tests/autoupdate.at: New file; test for AU_ALIAS `$#' bug.
* tests/Makefile.am, tests/suite.at: Updated.

Index: tests/Makefile.am
===
RCS file: /cvsroot/autoconf/autoconf/tests/Makefile.am,v
retrieving revision 1.97
diff -u -r1.97 Makefile.am
--- tests/Makefile.am   15 Aug 2005 23:47:57 -  1.97
+++ tests/Makefile.am   24 Oct 2005 14:34:32 -
@@ -92,6 +92,7 @@
compile.at c.at fortran.at \
semantics.at \
autoscan.at \
+   autoupdate.at \
foreign.at
 
 TESTSUITE_AT = $(TESTSUITE_GENERATED_AT) $(TESTSUITE_HAND_AT)
Index: tests/suite.at
===
RCS file: /cvsroot/autoconf/autoconf/tests/suite.at,v
retrieving revision 1.33
diff -u -r1.33 suite.at
--- tests/suite.at  16 Aug 2005 08:18:04 -  1.33
+++ tests/suite.at  24 Oct 2005 14:34:32 -
@@ -75,3 +75,6 @@
 
 # Autoscan test
 m4_include([autoscan.at])
+
+# Autoupdate test
+m4_include([autoupdate.at])
--- /dev/null   2005-08-03 12:45:51.659987528 +0200
+++ tests/autoupdate.at 2005-10-24 16:28:45.0 +0200
@@ -0,0 +1,45 @@
+#  -*- Autotest -*-
+
+AT_BANNER([Autoupdate.])
+
+# Copyright (C) 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+AT_SETUP([AU_ALIAS])
+
+AT_DATA([configure.ac],
+[[AC_INIT
+AC_DEFUN([FOO], [echo $#])
+AU_ALIAS([BAZ],[FOO])
+test `FOO`-eq 0 || exit 1
+test `FOO()`  -eq 1 || exit 1
+test `FOO(1)` -eq 1 || exit 1
+test `BAZ`-eq 0 || exit 1
+test `BAZ()`  -eq 1 || exit 1
+test `BAZ(1)` -eq 1 || exit 1
+AC_PROG_CC
+AC_STDC_HEADERS
+AC_OUTPUT
+]])
+
+AT_CHECK_AUTOCONF
+AT_CHECK_CONFIGURE
+AT_CHECK_AUTOUPDATE
+AT_CHECK([grep 'AC_HEADER_STDC(' configure.ac], 1, [ignore], [ignore])
+AT_CHECK([grep 'AC_HEADER_STDC' configure.ac], 0, [ignore], [ignore])
+
+AT_CLEANUP




Re: Fix LT_WITH_LTDL: AU_ALIAS bug

2005-10-20 Thread Stepan Kasal
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 -  1.55
+++ bin/autoupdate.in   20 Oct 2005 07:59:18 -
@@ -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 -  1.930
+++ doc/autoconf.texi   20 Oct 2005 07:59:19 -
@@ -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 -  1.10
+++ lib/autoconf/autoupdate.m4  20 Oct 2005 07:59:19 -
@@ -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@)])]])


Re: Fix LT_WITH_LTDL: AU_ALIAS bug

2005-09-10 Thread Gary V. Vaughan
Hallo Ralf,

Ralf Wildenhues wrote:
 Hunting down bugs in m4 macros sucks.  Using $# in macros sucks, too.

:-(  Can you document in HACKING that because of our use of AU_ALIAS to
maintain backwards compatibility with earlier libtool interfaces we must
not use $# in m4.

Also, we could do with an m4.test to catch violations of our m4 style
guidelines -- much as we have sh.test to catch shell style violations.
Can you add a TODO item for that too please?

 First: LT_WITH_LTDL needs to be documented correctly.  Its predecessor
 AC_WITH_LTDL needed documentation as well.  I accept patches.  :)

I've been working on this for almost 2 weeks now.  The whole thing is
almost hopelessly broken.  Now that I've started using quilt I'll start
posting the patches in small bits as soon as I have the damn thing
working.

 Anyway, I consider testing against $# error-prone, and bad for forward
 compatibility anyway (when the possible number of arguments could be
 greater than one),

ACK.

 so I would like to apply this patch, which uses
 m4_default instead.  OK for HEAD?

Okay.

 * libltdl/m4/ltdl.m4 (LT_WITH_LTDL, LTDL_CONVENIENCE)
 (LTDL_INSTALLABLE): Use m4_default instead of m4_if, to cope
 with empty macro arguments.  Use less quoting for expanded
 LIBLTDL, LTDLINCL

Cheers,
Gary
-- 
Gary V. Vaughan  ())_.  [EMAIL PROTECTED],gnu.org}
Research Scientist   ( '/   http://tkd.kicks-ass.net
GNU Hacker   / )=   http://www.gnu.org/software/libtool
Technical Author   `(_~)_   http://sources.redhat.com/autobook


signature.asc
Description: OpenPGP digital signature


Fix LT_WITH_LTDL: AU_ALIAS bug

2005-09-09 Thread Ralf Wildenhues
Hunting down bugs in m4 macros sucks.  Using $# in macros sucks, too.
Sorry for the cross-post.

First: LT_WITH_LTDL needs to be documented correctly.  Its predecessor
AC_WITH_LTDL needed documentation as well.  I accept patches.  :)


Second: Autoconf bug: AU_ALIAS mumbles with the number of arguments:
cat configure.ac \EOF
AC_INIT
AC_DEFUN([FOO],
 [echo foo: $#])
AU_DEFUN([BAR],[FOO])
AU_ALIAS([BAZ],[FOO])
FOO
FOO(1)
FOO(1,2)
BAR
BAR(1)
BAR(1,2)
BAZ
BAZ(1)
BAZ(1,2)
AC_OUTPUT
EOF
autoconf
./configure

leads to:

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

We knew about AU_DEFUN, but AU_ALIAS sucks here.  (No, AU_ALIAS is not
documented; but I have a promise from 2005-01-03 to use it in Libtool
as if it were documented!  Since there is no documentation, I assumed
it would just work the way I thought it would :)


Third: In light of this, calling (from within AC_WITH_LTDL, AU_ALIASed
to LT_WITH_LTDL):

  LTDL_CONVENIENCE([$1])

and in LTDL_CONVENIENCE, testing $# is bound to lead to failure.
Example:

AC_INIT([foo], [0.1], [devnull])
AC_CONFIG_AUX_DIR([libltdl/config])
AC_CONFIG_MACRO_DIR([libltdl/m4])
AM_INIT_AUTOMAKE([foreign])
AC_PROG_CC
AC_WITH_LTDL
AC_LIBLTDL_CONVENIENCE
AC_LIBTOOL_DLOPEN
AC_PROG_LIBTOOL
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

will break, because the configure script will contain something like
| LIBLTDL='${top_builddir}/'/libltdlc.la

instead of
| LIBLTDL='${top_builddir}/''libltdl'/libltdlc.la

from the expansion of LTDL_CONVENIENCE from withtin AC_WITH_LTDL, which
is obviously wrong.  The second expansion (directly from configure.ac)
contains this same error, but I haven't found the reason (does AU_ALIAS
mess with the number of macro arguments or something?).

Anyway, I consider testing against $# error-prone, and bad for forward
compatibility anyway (when the possible number of arguments could be
greater than one), so I would like to apply this patch, which uses
m4_default instead.  OK for HEAD?  Note that I also removed the extra
single quotes around the default argument.

(part of this situation is in branch-1-5 as well, but I don't want
change there unless someone tells me it is necessary.)

Cheers,
Ralf

* libltdl/m4/ltdl.m4 (LT_WITH_LTDL, LTDL_CONVENIENCE)
(LTDL_INSTALLABLE): Use m4_default instead of m4_if, to cope
with empty macro arguments.  Use less quoting for expanded
LIBLTDL, LTDLINCL

Index: libltdl/m4/ltdl.m4
===
RCS file: /cvsroot/libtool/libtool/libltdl/m4/ltdl.m4,v
retrieving revision 1.6
diff -u -r1.6 ltdl.m4
--- libltdl/m4/ltdl.m4  29 Aug 2005 10:47:41 -  1.6
+++ libltdl/m4/ltdl.m4  9 Sep 2005 11:39:27 -
@@ -33,7 +33,7 @@
 if test x$enable_ltdl_install != xyes; then
   # If the user did not specify an installable libltdl, then default
   # to a convenience lib.
-  LTDL_CONVENIENCE([$1])
+  LTDL_CONVENIENCE(m4_default([$1], [libltdl]))
 fi
 
 if test x$with_included_ltdl = xno; then
@@ -48,7 +48,7 @@
 AC_MSG_CHECKING([whether to use included libltdl])
 AC_MSG_RESULT([$with_included_ltdl])
 
-AC_CONFIG_SUBDIRS(m4_if($#, 1, [$1], [libltdl]))
+AC_CONFIG_SUBDIRS(m4_default([$1], [libltdl]))
 ])# LT_WITH_LTDL
 
 # Old name:
@@ -74,8 +74,8 @@
   ) enable_ltdl_convenience=yes
   ac_configure_args=$ac_configure_args --enable-ltdl-convenience ;;
   esac
-LIBLTDL='${top_builddir}/'m4_if($#, 1, [$1], ['libltdl'])/libltdlc.la
-LTDLINCL='-I${top_srcdir}/'m4_if($#, 1, [$1], ['libltdl'])
+LIBLTDL='${top_builddir}/'m4_default([$1], [libltdl])/libltdlc.la
+LTDLINCL='-I${top_srcdir}/'m4_default([$1], [libltdl])
 
 AC_SUBST([LIBLTDL])
 AC_SUBST([LTDLINCL])
@@ -114,8 +114,8 @@
   ])
 if test x$enable_ltdl_install = xyes; then
   ac_configure_args=$ac_configure_args --enable-ltdl-install
-  LIBLTDL='${top_builddir}/'m4_if($#, 1, [$1], ['libltdl'])/libltdl.la
-  LTDLINCL='-I${top_srcdir}/'m4_if($#, 1, [$1], ['libltdl'])
+  LIBLTDL='${top_builddir}/'m4_default([$1], [libltdl])/libltdl.la
+  LTDLINCL='-I${top_srcdir}/'m4_default([$1], [libltdl])
 else
   ac_configure_args=$ac_configure_args --enable-ltdl-install=no
   LIBLTDL=-lltdl