Re: gcc -Wall warning for minmax.h
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
Re: gcc -Wall warning for minmax.h
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
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
FYI: M4 macro documentation (was Re: gcc -Wall warning for minmax.h)
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
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
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
Hello Derek, thank you very much for taking care about this. On Mon, Jun 06, 2005 at 02:31:24PM -0400, Derek Price wrote: > 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. I haven't seen the patch; and won't see before you commit, as I'll be offline until Jun 21. That's why I add some comments now, though you probably know most of them: - We need to document also AS_LITERAL_IF and m4_fatal (And you could also document m4_warning, when you are at it.) - 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 A cheeky closing note: Bruno, your code also uses undocumented macros: `define', `undefine' and `translit'. Please note that the manual states that they are _moved_ into the m4_ pseudo-namespace. And IMHO these will never be documented, they are only for backward compatibility. ;-) Have a nice day, Stepan ___ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib
Re: gcc -Wall warning for minmax.h
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
Re: gcc -Wall warning for minmax.h
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
[bug-gnulib] Re: gcc -Wall warning for minmax.h
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
[bug-gnulib] Re: gcc -Wall warning for minmax.h
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
Re: [bug-gnulib] Re: gcc -Wall warning for minmax.h
Bruno Haible wrote: >>- use m4_pushdef/m4_popdef instead of define/undefine >>- use AS_TR_* instead of raw m4_translit >> >> > >m4_pushdef, m4_popdef, AS_TR_* are not documented in the autoconf manual >(latest release, 2.59). In consequence, their meaning can change, or they >can go away entirely, without notice. Therefore, I don't wish to apply >this patch. > > 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. Since the manual goes on to list the exceptions (including a slightly different usage for `m4_popdef'), and the fact that `pushdef' is documented in at least the GNU M4 1.4.1 manual and I would guess earlier versions, I would consider `m4_pushdef' documented as well. 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
On Fri, Jun 03, 2005 at 05:54:29PM +0200, Bruno Haible wrote: > James Youngman wrote: > > HAVE_MINMAX_IN_FOO_H is defined if MIN is defined in foo.h and MAX is > > not. > > Have you seen a system where this is the case? No, never. > The autoconf test assumes that when MIN is defined in a header, MAX > will be defined as well, and vice versa. It's not an unreasonable assumption. 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
Stepan Kasal wrote: > I read your macro in minmax.m4. I'd like to propose some > changes in style: > - avoid the obsoleted AC_TRY_COMPILE AC_TRY_COMPILE is shorter and more mnemonic than the *_IFELSE macros. > - use m4_pushdef/m4_popdef instead of define/undefine > - use AS_TR_* instead of raw m4_translit m4_pushdef, m4_popdef, AS_TR_* are not documented in the autoconf manual (latest release, 2.59). In consequence, their meaning can change, or they can go away entirely, without notice. Therefore, I don't wish to apply this patch. Bruno ___ 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
James Youngman wrote: > HAVE_MINMAX_IN_FOO_H is defined if MIN is defined in foo.h and MAX is > not. Have you seen a system where this is the case? The autoconf test assumes that when MIN is defined in a header, MAX will be defined as well, and vice versa. Bruno ___ 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
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
Re: [bug-gnulib] Re: gcc -Wall warning for minmax.h
Hi Bruno, I read your macro in minmax.m4. I'd like to propose some changes in style: - avoid the obsoleted AC_TRY_COMPILE - use m4_pushdef/m4_popdef instead of define/undefine - use AS_TR_* instead of raw m4_translit A patch with my proposal is attached; it's not tested, sorry. Could you please find some time to look at it? [FYI: I'll be offline Jun 7 - Jun 21.] Have a nice day, Stepan 2005-06-03 Stepan Kasal <[EMAIL PROTECTED]> * minmax.m4 (gl_MINMAX_IN_HEADER): Use more modern macros. 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.m43 Jun 2005 11:53:03 - @@ -19,20 +19,19 @@ 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) + AS_LITERAL_IF([$1], [], +[m4_fatal([gl_MINMAX_IN_HEADER requires a literal parameter.])]) + m4_pushdef([gl_CACHE_VAR], gl_cv_minmax_in_[]AS_TR_SH([$1])) 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 -AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1, +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 - undefine([HEADER]) - undefine([header]) + m4_popdef([gl_CACHE_VAR]) ]) ___ 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
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Bruno Haible wrote: >I therefore commit this patch. Thanks, Bruno. Thank, Paul. Derek -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.0 (Cygwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCkeZjLD1OTBfyMaQRAgmpAKDlA/P6rAbI5ug2WehJCmbrECEvVgCfUpl8 XG5YgKc2A9/HJwEn1VyNApE= =CL5t -END PGP SIGNATURE- ___ 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
Paul Eggert wrote: > Second, suppose and have conflicting > definitions of MIN and MAX? To work around the latter potential > problem you can #undef MIN and MAX after including . In this case we'll still get warnings, either when the user does #include #include or when he does #include #include Since the first case is more probable (because comes from a more generic standard than ), I'll just take the definition from in this case, and ignore . I therefore commit this patch. Bruno *** lib/minmax.h.bak2003-09-29 10:33:09.0 +0200 --- lib/minmax.h2005-05-22 22:49:38.0 +0200 *** *** 1,5 /* MIN, MAX macros. !Copyright (C) 1995, 1998, 2001, 2003 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 --- 1,5 /* MIN, MAX macros. !Copyright (C) 1995, 1998, 2001, 2003, 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 *** *** 24,31 #include this file as the last one among the #include list. */ /* Before we define the following symbols we get the file !since otherwise we get redefinitions on some systems. */ ! #include /* Note: MIN and MAX should be used with two arguments of the same type. They might not return the minimum and maximum of their two --- 24,38 #include this file as the last one among the #include list. */ /* Before we define the following symbols we get the file !since otherwise we get redefinitions on some systems if is !included after this file. Likewise for . !If more than one of these system headers define MIN and MAX, pick just !one of the headers (because the definitions most likely are the same). */ ! #if HAVE_MINMAX_IN_LIMITS_H ! # include ! #elif HAVE_MINMAX_IN_SYS_PARAM_H ! # include ! #endif /* Note: MIN and MAX should be used with two arguments of the same type. They might not return the minimum and maximum of their two *** m4/minmax.m4.bak2005-05-22 22:43:10.0 +0200 --- m4/minmax.m42005-05-22 23:09:58.0 +0200 *** *** 0 --- 1,38 + # minmax.m4 serial 1 + dnl Copyright (C) 2005 Free Software Foundation, Inc. + dnl This file is free software; the Free Software Foundation + dnl gives unlimited permission to copy and/or distribute it, + dnl with or without modifications, as long as this notice is preserved. + + AC_DEFUN([gl_MINMAX], + [ + AC_REQUIRE([gl_PREREQ_MINMAX]) + ]) + + # Prerequisites of lib/minmax.h. + AC_DEFUN([gl_PREREQ_MINMAX], + [ + gl_MINMAX_IN_HEADER([limits.h]) + gl_MINMAX_IN_HEADER([sys/param.h]) + ]) + + dnl gl_MINMAX_IN_HEADER(HEADER) + AC_DEFUN([gl_MINMAX_IN_HEADER], + [ + define([header],[translit([$1],[./-], + [___])]) + define([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 + AC_DEFINE([HAVE_MINMAX_IN_]HEADER, 1, + [Define to 1 if <$1> defines the MIN and MAX macros.]) + fi + undefine([HEADER]) + undefine([header]) + ]) ___ 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
Derek Price wrote: > >First, the $gl_* variables should be cached, with AC_CACHE_CHECK. > > Done. Thanks. > + AC_CACHE_CHECK([whether defines MIN & MAX], > + gl_limits_h_has_minmax, Cache variables need to have _cv_ in their name. So one needs to change this to gl_cv_limits_h_has_minmax. > + AC_CACHE_CHECK([whether defines MIN & MAX], > + gl_sys_param_h_has_minmax, This code is essentially duplicated from the above. Someday we may have 3 or 4 header file candidates, not just 2, so it's worth unifying this. Bruno ___ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib
Re: [bug-gnulib] gcc -Wall warning for minmax.h
The latest patch looks reasonable to me. Bruno, you're the minmax maintainer: can you please take a look at it? ___ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib
Re: [bug-gnulib] gcc -Wall warning for minmax.h
Paul Eggert wrote: >Derek Price <[EMAIL PROTECTED]> writes: > > > >>Corrected patch attached. >> >> > >Thanks. A couple more things. (Sorry I didn't catch it earlier.) >First, the $gl_* variables should be cached, with AC_CACHE_CHECK. > > Done. >Second, suppose and have conflicting >definitions of MIN and MAX? To work around the latter potential >problem you can #undef MIN and MAX after including . > > Done. Since you are worried about potential system header conflicts, I also had to update gl_PREREQ_MINMAX to always check for MIN in as well as . It used to skip the check if MIN was found in . Revised patch attached. 2005-05-18 Derek Price <[EMAIL PROTECTED]> * lib/minmax.h: Only include and when needed. * m4/minmax.m4: New file. * modules/minmax: Add minmax.m4. Regards, Derek Index: lib/minmax.h === RCS file: /cvsroot/gnulib/gnulib/lib/minmax.h,v retrieving revision 1.4 diff -u -p -r1.4 minmax.h --- lib/minmax.h14 May 2005 06:03:58 - 1.4 +++ lib/minmax.h18 May 2005 18:10:23 - @@ -23,9 +23,19 @@ MIN, MAX macro redefinitions on some systems; the workaround is to #include this file as the last one among the #include list. */ -/* Before we define the following symbols we get the file - since otherwise we get redefinitions on some systems. */ -#include +/* Before we define the following symbols we try to get the + or files since otherwise we get redefinitions on some + systems. */ +#ifdef LIMITS_H_HAS_MINMAX +# include +/* Avoid allowing the MIN & MAX definitions from these two headers to conflict. + There are no known systems where this is a problem. */ +# undef MIN +# undef MAX +#endif +#ifdef SYS_PARAM_H_HAS_MINMAX +# include +#endif /* Note: MIN and MAX should be used with two arguments of the same type. They might not return the minimum and maximum of their two Index: m4/minmax.m4 === RCS file: m4/minmax.m4 diff -N m4/minmax.m4 --- /dev/null 1 Jan 1970 00:00:00 - +++ m4/minmax.m418 May 2005 18:10:23 - @@ -0,0 +1,35 @@ +# minmax.m4 serial 1 +dnl Copyright (C) 2005 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_MINMAX], [gl_PREREQ_MINMAX]) + +# Prerequisites of minmax.h. +AC_DEFUN([gl_PREREQ_MINMAX], +[ + AC_CACHE_CHECK([whether defines MIN & MAX], +gl_limits_h_has_minmax, +[AC_COMPILE_IFELSE( +[#include +int x = MIN (1, 2);], + [gl_limits_h_has_minmax=yes], [gl_limits_h_has_minmax=no])]) + + if test $gl_limits_h_has_minmax = yes; then +AC_DEFINE(LIMITS_H_HAS_MINMAX, 1, + [Define to 1 if defines the MIN and MAX macros.]) + fi + + AC_CACHE_CHECK([whether defines MIN & MAX], +gl_sys_param_h_has_minmax, +[AC_COMPILE_IFELSE( +[#include +int x = MIN (1, 2);], + [gl_sys_param_h_has_minmax=yes], [gl_sys_param_h_has_minmax=no])]) + + if test $gl_sys_param_h_has_minmax = yes; then +AC_DEFINE(SYS_PARAM_H_HAS_MINMAX, 1, + [Define to 1 if defines the MIN and MAX macros.]) + fi + :]) Index: modules/minmax === RCS file: /cvsroot/gnulib/gnulib/modules/minmax,v retrieving revision 1.3 diff -u -p -r1.3 minmax --- modules/minmax 28 Sep 2004 20:15:39 - 1.3 +++ modules/minmax 18 May 2005 18:10:23 - @@ -3,10 +3,12 @@ MIN, MAX macros. Files: lib/minmax.h +m4/minmax.m4 Depends-on: configure.ac: +gl_MINMAX Makefile.am: lib_SOURCES += minmax.h ___ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib
Re: [bug-gnulib] gcc -Wall warning for minmax.h
Derek Price <[EMAIL PROTECTED]> writes: > Corrected patch attached. Thanks. A couple more things. (Sorry I didn't catch it earlier.) First, the $gl_* variables should be cached, with AC_CACHE_CHECK. Second, suppose and have conflicting definitions of MIN and MAX? To work around the latter potential problem you can #undef MIN and MAX after including . ___ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib
Re: [bug-gnulib] gcc -Wall warning for minmax.h
Paul Eggert wrote: >Derek Price <[EMAIL PROTECTED]> writes: > > > > >>+#ifdef LIMITS_H_HAS_MINMAX >>+# include >>+#elif SYS_PARAM_H_HAS_MINMAX >>+# include >>+#endif >> >> > >This doesn't work if and both define MIN. > > Hrm. Okay, I've fixed this, though I think such a system that is also broken with respect to the current "minmax.h" (where _and_ both define MIN _without protecting the definitions with #ifndef MIN_) is not likely to occur in practice since it would require a system where the order of inclusion of and mattered. >>+ AC_CHECK_HEADERS_ONCE([sys/param.h], >>+[gl_have_sys_param_h=:], [gl_have_sys_param_h=false])dnl >> >> > >You don't need to check whether sys/param.h exists. All you >need to do is to see whether the following program compiles: > >#include >int x = MIN (1, 2); > >Similarly for . You shouldn't need to use EGREP_CPP. > > Okay, I see that now. Fixed. Corrected patch attached. Regards, Derek Index: m4/minmax.m4 === RCS file: m4/minmax.m4 diff -N m4/minmax.m4 --- /dev/null 1 Jan 1970 00:00:00 - +++ m4/minmax.m417 May 2005 16:44:20 - @@ -0,0 +1,31 @@ +# minmax.m4 serial 1 +dnl Copyright (C) 2005 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_MINMAX], [gl_PREREQ_MINMAX]) + +# Prerequisites of minmax.h. +AC_DEFUN([gl_PREREQ_MINMAX], +[ + AC_COMPILE_IFELSE( +[#include +int x = MIN (1, 2);], +[gl_limits_h_has_minmax=:], [gl_limits_h_has_minmax=false]) + + if $gl_limits_h_has_minmax; then +AC_DEFINE(LIMITS_H_HAS_MINMAX, 1, + [Define to 1 if defines the MIN and MAX macros.]) + else +AC_COMPILE_IFELSE( +[#include +int x = MIN (1, 2);], + [gl_sys_param_h_has_minmax=:], [gl_sys_param_h_has_minmax=false]) + +if $gl_sys_param_h_has_minmax; then + AC_DEFINE(SYS_PARAM_H_HAS_MINMAX, 1, + [Define to 1 if defines the MIN and MAX macros.]) +fi + fi + :]) Index: lib/minmax.h === RCS file: /cvsroot/gnulib/gnulib/lib/minmax.h,v retrieving revision 1.4 diff -u -p -r1.4 minmax.h --- lib/minmax.h14 May 2005 06:03:58 - 1.4 +++ lib/minmax.h17 May 2005 16:44:20 - @@ -23,9 +23,15 @@ MIN, MAX macro redefinitions on some systems; the workaround is to #include this file as the last one among the #include list. */ -/* Before we define the following symbols we get the file - since otherwise we get redefinitions on some systems. */ -#include +/* Before we define the following symbols we try to get the + or files since otherwise we get redefinitions on some + systems. */ +#ifdef LIMITS_H_HAS_MINMAX +# include +#endif +#ifdef SYS_PARAM_H_HAS_MINMAX +# include +#endif /* Note: MIN and MAX should be used with two arguments of the same type. They might not return the minimum and maximum of their two Index: modules/minmax === RCS file: /cvsroot/gnulib/gnulib/modules/minmax,v retrieving revision 1.3 diff -u -p -r1.3 minmax --- modules/minmax 28 Sep 2004 20:15:39 - 1.3 +++ modules/minmax 17 May 2005 16:44:20 - @@ -3,10 +3,12 @@ MIN, MAX macros. Files: lib/minmax.h +m4/minmax.m4 Depends-on: configure.ac: +gl_MINMAX Makefile.am: lib_SOURCES += minmax.h ___ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib
Re: [bug-gnulib] gcc -Wall warning for minmax.h
Derek Price <[EMAIL PROTECTED]> writes: > +#ifdef LIMITS_H_HAS_MINMAX > +# include > +#elif SYS_PARAM_H_HAS_MINMAX > +# include > +#endif This doesn't work if and both define MIN. > + AC_CHECK_HEADERS_ONCE([sys/param.h], > +[gl_have_sys_param_h=:], [gl_have_sys_param_h=false])dnl You don't need to check whether sys/param.h exists. All you need to do is to see whether the following program compiles: #include int x = MIN (1, 2); Similarly for . You shouldn't need to use EGREP_CPP. ___ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib
Re: [bug-gnulib] gcc -Wall warning for minmax.h
Paul Eggert wrote: >Derek Price <[EMAIL PROTECTED]> writes: > > > >>minmax was so nice and small, but would you be willing to add an m4 file >>which called AC_CHECK_HEADERS([sys/param.h]) and the following lines to >>the beginning of minmax.h? >> >>#ifdef HAVE_SYS_PARAM_H >># include >>#endif >> >> > >Better yet, why not have "configure" check whether >defines MIN and MAX, and include only if that's true? >Similarly for . That way, minmax.h will include these other >files only on broken systems. > > > >>I'll send the complete patch if you approve. >> >> > >Could you please implement something along those lines? Thanks. > > Okay, I've attached the patch you suggested, though I am still using the AC_EGREP_CPP construct you mentioned you disliked in our glob discussion. Since this method works when cross-compiling and I've yet to be convinced it is fragile, I'm going to hold off on a rewrite until we settle the other discussion. 2005-05-15 Derek Price <[EMAIL PROTECTED]> * lib/minmax.h: Only include and when needed. * m4/minmax.m4: New file. * modules/minmax: Add minmax.m4. Cheers, Derek Index: lib/minmax.h === RCS file: /cvsroot/gnulib/gnulib/lib/minmax.h,v retrieving revision 1.4 diff -u -p -r1.4 minmax.h --- lib/minmax.h14 May 2005 06:03:58 - 1.4 +++ lib/minmax.h15 May 2005 18:22:52 - @@ -23,9 +23,14 @@ MIN, MAX macro redefinitions on some systems; the workaround is to #include this file as the last one among the #include list. */ -/* Before we define the following symbols we get the file - since otherwise we get redefinitions on some systems. */ -#include +/* Before we define the following symbols we try to get the + or files since otherwise we get redefinitions on some + systems. */ +#ifdef LIMITS_H_HAS_MINMAX +# include +#elif SYS_PARAM_H_HAS_MINMAX +# include +#endif /* Note: MIN and MAX should be used with two arguments of the same type. They might not return the minimum and maximum of their two Index: m4/minmax.m4 === RCS file: m4/minmax.m4 diff -N m4/minmax.m4 --- /dev/null 1 Jan 1970 00:00:00 - +++ m4/minmax.m415 May 2005 18:22:52 - @@ -0,0 +1,34 @@ +# minmax.m4 serial 1 +dnl Copyright (C) 2005 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_MINMAX], [gl_PREREQ_MINMAX]) + +# Prerequisites of minmax.h. +AC_DEFUN([gl_PREREQ_MINMAX], +[ dnl This really calls AC_REQUIRE, so just put it first. + AC_CHECK_HEADERS_ONCE([sys/param.h], +[gl_have_sys_param_h=:], [gl_have_sys_param_h=false])dnl + + AC_EGREP_CPP([gl_minmax_test = MIN], +[#include +gl_minmax_test = MIN (xxx, yyy)], +[gl_limits_h_has_minmax=false], [gl_limits_h_has_minmax=:]) + + if $gl_limits_h_has_minmax; then +AC_DEFINE(LIMITS_H_HAS_MINMAX, 1, + [Define to 1 if defines the MIN and MAX macros.]) + elif $gl_have_sys_param_h; then +AC_EGREP_CPP([gl_minmax_test = MIN], +[#include +gl_minmax_test = MIN (xxx, yyy)], + [gl_sys_param_h_has_minmax=false], [gl_sys_param_h_has_minmax=:]) + +if $gl_sys_param_h_has_minmax; then + AC_DEFINE(SYS_PARAM_H_HAS_MINMAX, 1, + [Define to 1 if defines the MIN and MAX macros.]) +fi + fi + :]) Index: modules/minmax === RCS file: /cvsroot/gnulib/gnulib/modules/minmax,v retrieving revision 1.3 diff -u -p -r1.3 minmax --- modules/minmax 28 Sep 2004 20:15:39 - 1.3 +++ modules/minmax 15 May 2005 18:22:52 - @@ -3,10 +3,12 @@ MIN, MAX macros. Files: lib/minmax.h +m4/minmax.m4 Depends-on: configure.ac: +gl_MINMAX Makefile.am: lib_SOURCES += minmax.h ___ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib
Re: [bug-gnulib] gcc -Wall warning for minmax.h
Derek Price <[EMAIL PROTECTED]> writes: > minmax was so nice and small, but would you be willing to add an m4 file > which called AC_CHECK_HEADERS([sys/param.h]) and the following lines to > the beginning of minmax.h? > > #ifdef HAVE_SYS_PARAM_H > # include > #endif Better yet, why not have "configure" check whether defines MIN and MAX, and include only if that's true? Similarly for . That way, minmax.h will include these other files only on broken systems. > I'll send the complete patch if you approve. Could you please implement something along those lines? Thanks. ___ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib
Re: [bug-gnulib] gcc -Wall warning for minmax.h
On Friday, May 13, 2005 at 18:54, Derek Price wrote: > /usr/include/sys/param.h:222: warning: `MIN' redefined > /usr/include/sys/param.h:223: warning: `MAX' redefined [..] > minmax was so nice and small, but would you be willing to add an m4 file > which called AC_CHECK_HEADERS([sys/param.h]) and the following lines to > the beginning of minmax.h? [..] > I'll send the complete patch if you approve. GNU libc also has MIN/MAX macros, so a check for that header file might be useful. Regards, Oskar Liljeblad ([EMAIL PROTECTED]) ___ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib
[bug-gnulib] gcc -Wall warning for minmax.h
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I get the following warning on NetBSD 1.6.1 when using the minmax module: In file included from /usr/include/arpa/inet.h:65, from socket-client.h:27, from socket-client.c:20: /usr/include/sys/param.h:222: warning: `MIN' redefined ../lib/minmax.h:50: warning: this is the location of the previous definition /usr/include/sys/param.h:223: warning: `MAX' redefined ../lib/minmax.h:45: warning: this is the location of the previous definition source='stack.c' object='stack.o' libtool=no DEPDIR=.deps depmode=gcc /bin/sh ../build-aux/depcomp gcc -DHAVE_CONFIG_H -I. -I. -I.. -I../lib -I../lib -I../diff -I../zlib -Wall -Ino/include -g -O2 -c stack.c minmax was so nice and small, but would you be willing to add an m4 file which called AC_CHECK_HEADERS([sys/param.h]) and the following lines to the beginning of minmax.h? #ifdef HAVE_SYS_PARAM_H # include #endif I'll send the complete patch if you approve. Cheers, Derek -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.0 (Cygwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFChSRFLD1OTBfyMaQRAiBGAKD99phnBoA8q1KnjRkech6pqE83uQCeK5Ta EWudGtyfcxUtVRiapxWtWQs= =DmyC -END PGP SIGNATURE- ___ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib