Re: gcc -Wall warning for minmax.h

2005-06-10 Thread Derek Price
Stepan Kasal wrote:

After that fix, we could also remove the AS_LITERAL_IF with m4_fatal.
  


I'm not sure what you were referring to here so I've attached a patch to
document AS_LITERAL_IF as you requested a few days ago.  I will commit
it in a few days if there are no objections.  It looks like m4_fatal and
friends are going to require their own section and I don't have time for
that, so I did not try.

If gl_CACHE_VAR expanded to

   `echo xyz-xyz | sed ...`

then you get something like:

eval test \\${gl_CACHE_VAR+set}\ = set

eval test \\${`echo xyz-xyz | sed ...`+set}\ = set

And this construct is not portable, see the first paragraph of node
Shell Substitutions.

This can be fixed: AS_VAR_TEST_SET could in this case expand to
   as_var=`echo xyz-xyz | sed ...`
   eval test \\${$as_var+set}\ = set
  


I've attached a patch to fix this, but I'm not sure I completely
understood your problem, so it still requires tests.  It is passing the
existing tests here.  I'm not going to try to commit this, but anyone
with time to write the tests is welcome to commit it themselves, as far
as I am concerned.

Cheers,

Derek
Index: doc/autoconf.texi
===
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.910
diff -u -p -r1.910 autoconf.texi
--- doc/autoconf.texi   8 Jun 2005 20:27:20 -   1.910
+++ doc/autoconf.texi   10 Jun 2005 15:39:22 -
@@ -8954,6 +8954,18 @@ RUN-IF-TRUE, else run shell code RUN-IF-
 RUN-IF-TRUE or RUN-IF-FALSE is empty.
 @end defmac
 
[EMAIL PROTECTED] AS_LITERAL_IF (@var{expression}, @ovar{RUN-IF-LIT}, 
@ovar{RUN-IF-NOT})
[EMAIL PROTECTED]
+If @var{expression} is a shell literal, expand to @ovar{RUN-IF-LIT}, otherwise,
+when @var{expression} contains shell metacharacters, expand to
[EMAIL PROTECTED]  For example:
+
[EMAIL PROTECTED]
+AS_LITERAL_IF(MACRO, m4_translit(MACRO, [[a-f]], [[A-F]]),
+  [`echo MACRO |sed 'y/abcdef/ABCDEF/'`])
[EMAIL PROTECTED] example
[EMAIL PROTECTED] defmac
+
 @defmac AS_MKDIR_P (@var{file-name})
 @asindex{MKDIR_P}
 Make the directory @var{file-name}, including intervening directories
Index: lib/m4sugar/m4sh.m4
===
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v
retrieving revision 1.144
diff -u -p -r1.144 m4sh.m4
--- lib/m4sugar/m4sh.m4 27 May 2005 22:21:44 -  1.144
+++ lib/m4sugar/m4sh.m4 10 Jun 2005 16:11:00 -
@@ -1210,8 +1210,8 @@ m4_define([AS_VAR_GET],
 # is set.  Polymorphic.  Should be dnl'ed.
 m4_define([AS_VAR_TEST_SET],
 [AS_LITERAL_IF([$1],
-  [test ${$1+set} = set],
-  [eval test \\${$1+set}\ = set])])
+   [test ${$1+set} = set],
+   [{ as_var=$1; eval test \\${$as_var+set}\ = set; }])])
 
 
 # AS_VAR_SET_IF(VARIABLE, IF-TRUE, IF-FALSE)
___
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib


Re: gcc -Wall warning for minmax.h

2005-06-10 Thread Derek Price
Paul Eggert wrote:

I'm not sure about the documentation change.  It's not yet clear to me
that we want to document AS_LITERAL_IF (the above example being one of
the gotchas).  If we do want to document it we probably need to be
more systematic about it and its friends.  So I left that alone for
now.
  


Okay.  I'll leave it alone then too.  I just did it because it was
requested and it was easy to do while I was in there.

Thanks,

Derek



___
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib


Re: gcc -Wall warning for minmax.h

2005-06-10 Thread Paul Eggert
Derek Price [EMAIL PROTECTED] writes:

 +   [test ${$1+set} = set],
 +   [{ as_var=$1; eval test \\${$as_var+set}\ = set; }])])

That change looks like it can do only good, so I installed it into
Autoconf.  Thanks.

I'm not sure about the documentation change.  It's not yet clear to me
that we want to document AS_LITERAL_IF (the above example being one of
the gotchas).  If we do want to document it we probably need to be
more systematic about it and its friends.  So I left that alone for
now.


___
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib


FYI: M4 macro documentation (was Re: gcc -Wall warning for minmax.h)

2005-06-08 Thread Derek Price
Derek Price wrote:

Would anyone mind if I committed a patch with @msindex entries for the
37 or so undocumented m4_* macros in the `Redefined M4 Macros' node of
doc/autoconf.texi?  I'm not bothering to include the patch in this email
because it is too simple but I don't want to waste the 15 minutes it
will take to write it without approval.  :)
  


No one responded for a few days, so I checked in the attached patch.  It
documents all the macros renamed from M4 except: changecom, changequote,
changeword, debugfile, debugmode, divert, divnum, traceoff, traceon, 
undivert.  I thought use of those macros by users was either very likely
to interfere with normal autoconf operation or there is an alternative
API to them on the AC command line, or both.

2005-06-08  Derek Price  [EMAIL PROTECTED]

* doc/autoconf.texi (Redefined M4 Macros): Add index entries for
most
redefined M4 macros to this node.  Document m4_include 
m4_sinclude.
Move m4_undefine to alphabetical order.

Cheers,

Derek

Index: ChangeLog
===
RCS file: /cvsroot/autoconf/autoconf/ChangeLog,v
retrieving revision 1.2553
diff -u -p -r1.2553 ChangeLog
--- ChangeLog   8 Jun 2005 07:55:28 -   1.2553
+++ ChangeLog   8 Jun 2005 15:40:40 -
@@ -1,3 +1,9 @@
+2005-06-08  Derek Price  [EMAIL PROTECTED]
+
+   * doc/autoconf.texi (Redefined M4 Macros): Add index entries for most
+   redefined M4 macros to this node.  Document m4_include  m4_sinclude.
+   Move m4_undefine to alphabetical order.
+
 2005-06-07  Paul Eggert  [EMAIL PROTECTED]
 
* README: Recommend GNU M4 1.4.3 or later.
Index: doc/autoconf.texi
===
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.908
diff -u -p -r1.908 autoconf.texi
--- doc/autoconf.texi   8 Jun 2005 07:55:29 -   1.908
+++ doc/autoconf.texi   8 Jun 2005 15:40:45 -
@@ -8726,6 +8726,27 @@ M4sugar''.
 @node Redefined M4 Macros
 @subsection Redefined M4 Macros
 
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
 With a few exceptions, all the M4 native macros are moved in the
 @samp{m4_} pseudo-namespace, e.g., M4sugar renames @code{define} as
 @code{m4_define} etc.
@@ -8756,17 +8777,11 @@ This macro corresponds to @code{m4exit}.
 This macro corresponds to @code{ifelse}.
 @end defmac
 
[EMAIL PROTECTED] m4_undefine (@var{macro})
[EMAIL PROTECTED]
-Contrary to the M4 builtin, this macro fails if @var{macro} is not
-defined.  Use
-
[EMAIL PROTECTED]
-m4_ifdef([EMAIL PROTECTED], [m4_undefine([EMAIL PROTECTED])])
[EMAIL PROTECTED] example
-
[EMAIL PROTECTED]
-to recover the behavior of the builtin.
[EMAIL PROTECTED] m4_include (@var{file})
[EMAIL PROTECTED] m4_sinclude (@var{file})
[EMAIL PROTECTED]
[EMAIL PROTECTED]
+Like the M4 builtins, but warn against multiple inclusions of @var{file}.
 @end defmac
 
 @defmac m4_bpatsubst (@var{string}, @var{regexp}, @ovar{replacement})
@@ -8807,6 +8822,19 @@ m4_wrap([foo])
 @end example
 @end defmac
 
[EMAIL PROTECTED] m4_undefine (@var{macro})
[EMAIL PROTECTED]
+Contrary to the M4 builtin, this macro fails if @var{macro} is not
+defined.  Use
+
[EMAIL PROTECTED]
+m4_ifdef([EMAIL PROTECTED], [m4_undefine([EMAIL PROTECTED])])
[EMAIL PROTECTED] example
+
[EMAIL PROTECTED]
+to recover the behavior of the builtin.
[EMAIL PROTECTED] defmac
+
 @node Evaluation Macros
 @subsection Evaluation Macros
 
___
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib


Re: gcc -Wall warning for minmax.h

2005-06-07 Thread Derek Price
Stepan Kasal wrote:

- We need to document also AS_LITERAL_IF and m4_fatal
  (And you could also document m4_warning, when you are at it.)
  


I'll see about it after I get comments on the first round back.

- we have to document also the fact that AS_TR_SH  AS_TR_CPP expand
  to literal variable (symbol) name, if their argument is a literal
  


I didn't think this was important from the user's perspective.  I showed
in my examples that variables were expanded properly before conversion,
but I didn't think it important to mention here that expansion of input
without shell meta-characters would be optimized.

Cheers,

Derek



___
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib


Re: gcc -Wall warning for minmax.h

2005-06-07 Thread Stepan Kasal
Hi,

On Tue, Jun 07, 2005 at 10:19:47AM -0400, Derek Price wrote:
 - we have to document also the fact that AS_TR_SH  AS_TR_CPP expand
   to literal variable (symbol) name, if their argument is a literal
 
 I didn't think this was important from the user's perspective.

In the patch I proposed, I used gl_CACHE_VAR as the second argument
of AC_CACHE_CHECK.
That argument cannot contain backticks, see the Appendix below.

That explains why I relied on the feature, and why I wanted to document it.
But yes, it's better to fix AC_CACHE_CHECK to remove this limitation.

After that fix, we could also remove the AS_LITERAL_IF with m4_fatal.

I'm happy that AS_LITERAL_IF will stay undocumented.
m4_fatal and m4_warning should be documented, though.

Have a nice day,
Stepan

Appendix:
If gl_CACHE_VAR expanded to

`echo xyz-xyz | sed ...`

then you get something like:

eval test \\${gl_CACHE_VAR+set}\ = set

eval test \\${`echo xyz-xyz | sed ...`+set}\ = set

And this construct is not portable, see the first paragraph of node
Shell Substitutions.

This can be fixed: AS_VAR_TEST_SET could in this case expand to
as_var=`echo xyz-xyz | sed ...`
eval test \\${$as_var+set}\ = set



___
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib


Re: gcc -Wall warning for minmax.h

2005-06-06 Thread Derek Price
Bruno Haible wrote:

I blindly searched for m4_pushdef in the manual and didn't find
it. (May I suggest that these renamed m4_* macros be added to the manual's
index, one by one?)
  


Autoconf folks:

Would anyone mind if I committed a patch with @msindex entries for the
37 or so undocumented m4_* macros in the `Redefined M4 Macros' node of
doc/autoconf.texi?  I'm not bothering to include the patch in this email
because it is too simple but I don't want to waste the 15 minutes it
will take to write it without approval.  :)

Cheers,

Derek



___
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib


Re: gcc -Wall warning for minmax.h

2005-06-06 Thread Derek Price
Bruno Haible wrote:

But AS_TR_* is actually undocumented, right?
  


Yes, AS_TR_SH  AS_TR_CPP appear to be undocumented.  I've submitted a
patch to autoconf-patches to remedy this and will commit it within a few
days unless there are objections there.

Cheers,

Derek



___
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib


[bug-gnulib] Re: gcc -Wall warning for minmax.h

2005-06-04 Thread Stepan Kasal
Hello,

On Fri, Jun 03, 2005 at 05:53:00PM +0200, Bruno Haible wrote:
 AS_TR_* are not documented in the autoconf manual

You are right.  I have to start by documenting AS_TR_SH, AS_TR_CPP,
AS_LITERAL_IF and m4_fatal.  Then I can resubmit the patch.

 AC_TRY_COMPILE is shorter and more mnemonic than the *_IFELSE macros.

I believe there were good reasons why it was obsoleted.  (Double quotes
its param, and we cannot change the behaviour without renaming it.)
If people continue to use it, they can experience unwanted surprises.

If you use obsolete macros in your code, users will follow you.
Please help spreading the message and avoid using it.

  - use m4_pushdef/m4_popdef instead of define/undefine

This change was important.

Your macro does m4_undefine([header]) and m4_undefine([HEADER]).
What if these symboles were already defined?
(Perhaps by another macro, written in a similar style.)

An updated patch attached.

Stepan
2005-06-04  Stepan Kasal  [EMAIL PROTECTED]

* minmax.m4 (gl_MINMAX_IN_HEADER): Don't use obsolete AC_TRY_COMPILE;
  use m4_pushdef/m4_popdef.

Index: m4/minmax.m4
===
RCS file: /cvsroot/gnulib/gnulib/m4/minmax.m4,v
retrieving revision 1.1
diff -u -r1.1 minmax.m4
--- m4/minmax.m423 May 2005 10:25:53 -  1.1
+++ m4/minmax.m44 Jun 2005 06:43:55 -
@@ -19,20 +19,20 @@
 dnl gl_MINMAX_IN_HEADER(HEADER)
 AC_DEFUN([gl_MINMAX_IN_HEADER],
 [
-  define([header],[translit([$1],[./-],
- [___])])
-  define([HEADER],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
- [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+  AC_PREREQ(2.50)
+  m4_pushdef([gl_CACHE_VAR], gl_cv_minmax_in_[]translit([$1], [./-], [___]))
+  m4_pushdef([HEADER],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+ [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
   AC_CACHE_CHECK([whether $1 defines MIN and MAX],
-[gl_cv_minmax_in_]header,
-[AC_TRY_COMPILE([#include $1
-int x = MIN (42, 17);], [],
-   [gl_cv_minmax_in_]header[=yes],
-   [gl_cv_minmax_in_]header[=no])])
-  if test $gl_cv_minmax_in_[]header = yes; then
+gl_CACHE_VAR,
+[AC_COMPILE_IFELSE([#include $1
+   int x = MIN (42, 17);],
+   [gl_CACHE_VAR=yes],
+   [gl_CACHE_VAR=no])])
+  if test $gl_CACHE_VAR = yes; then
 AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1,
   [Define to 1 if $1 defines the MIN and MAX macros.])
   fi
-  undefine([HEADER])
-  undefine([header])
+  m4_popdef([HEADER])
+  m4_popdef([gl_CACHE_VAR])
 ])
___
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib


Re: [bug-gnulib] Re: gcc -Wall warning for minmax.h

2005-06-03 Thread James Youngman
On Fri, Jun 03, 2005 at 01:54:01PM +0200, Stepan Kasal wrote:

 +gl_CACHE_VAR,
 +[AC_COMPILE_IFELSE([#include $1
 + int x = MIN (42, 17);],
 +   [gl_CACHE_VAR=yes],
 +   [gl_CACHE_VAR=no])])
 +  if test $gl_CACHE_VAR = yes; then
 +AC_DEFINE([HAVE_MINMAX_IN_]AS_TR_CPP([$1]), 1,
[Define to 1 if $1 defines the MIN and MAX macros.])
fi

Apologies for stating the obvious, but contrary to this description,
HAVE_MINMAX_IN_FOO_H is defined if MIN is defined in foo.h and MAX is
not.  Strictly speaking, we should change either the macro or the
description.

Regards,
James.


___
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib


[bug-gnulib] Re: gcc -Wall warning for minmax.h

2005-06-03 Thread Bruno Haible
Derek Price wrote:
 Actually, `m4_popdef' is documented explicitly in my Autoconf 2.59
 manual.  The Autoconf 2.59 manual also contains the following text:

 With a few exceptions, all the M4 native macros are moved in the `m4_'
 pseudo-namespace, e.g., M4sugar renames `define' as `m4_define' etc.

Ah, right. I blindly searched for m4_pushdef in the manual and didn't find
it. (May I suggest that these renamed m4_* macros be added to the manual's
index, one by one?)

But AS_TR_* is actually undocumented, right?

Bruno



___
bug-gnulib mailing list
bug-gnulib@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-gnulib