bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCHv2] argp: make HAVE_DECL usage consistent


From: Eric Blake
Subject: [PATCHv2] argp: make HAVE_DECL usage consistent
Date: Fri, 13 Jul 2012 12:23:03 -0600

Autoconf guarantees that AC_CHECK_DECLS always defines the
corresponding HAVE_DECL_*.  But our hand-coded use of AC_CHECK_DECL
did not define the macro to 0, leading to a false positive complaint:
https://lists.gnu.org/archive/html/coreutils/2012-06/msg00037.html
By sticking to conventions, we avoid the false positive.

* lib/argp-parse.c (__argp_parse): Check contents of HAVE_DECL
macros, not whether they are defined.
* m4/argp.m4 (gl_ARGP): Always define HAVE_DECL_* macros, per
convention with other declaration checks.
Reported by Karel Zak, with suggestions from Paul Eggert.
---

v2: also touch the m4 file, suggested by Paul Eggert.

 ChangeLog        |    7 +++++++
 lib/argp-parse.c |    4 ++--
 m4/argp.m4       |   22 +++++++++-------------
 3 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a35ea2f..67791ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2012-07-13  Eric Blake  <address@hidden>

+       argp: fix HAVE_DECL usage error
+       * lib/argp-parse.c (__argp_parse): Check contents of HAVE_DECL
+       macros, not whether they are defined.
+       * m4/argp.m4 (gl_ARGP): Always define HAVE_DECL_* macros, per
+       convention with other declaration checks.
+       Reported by Karel Zak.
+
        strndup: fix m4 usage error
        * m4/strndup.m4 (gl_FUNC_STRNDUP): HAVE_DECL_STRNDUP is always
        defined, to either 0 or 1.
diff --git a/lib/argp-parse.c b/lib/argp-parse.c
index 3b411d4..6bbb145 100644
--- a/lib/argp-parse.c
+++ b/lib/argp-parse.c
@@ -880,11 +880,11 @@ __argp_parse (const struct argp *argp, int argc, char 
**argv, unsigned flags,
 #ifndef _LIBC
   if (!(flags & ARGP_PARSE_ARGV0))
     {
-#ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME
+#if HAVE_DECL_PROGRAM_INVOCATION_NAME
       if (!program_invocation_name)
         program_invocation_name = argv[0];
 #endif
-#ifdef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
+#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
       if (!program_invocation_short_name)
         program_invocation_short_name = __argp_base_name (argv[0]);
 #endif
diff --git a/m4/argp.m4 b/m4/argp.m4
index 87c7da6..0d1de3a 100644
--- a/m4/argp.m4
+++ b/m4/argp.m4
@@ -1,4 +1,4 @@
-# argp.m4 serial 13
+# argp.m4 serial 14
 dnl Copyright (C) 2003-2012 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -10,18 +10,14 @@ AC_DEFUN([gl_ARGP],
   AC_REQUIRE([AC_C_RESTRICT])
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])

-  AC_CHECK_DECL([program_invocation_name],
-                [AC_DEFINE([HAVE_DECL_PROGRAM_INVOCATION_NAME], [1],
-                           [Define if program_invocation_name is declared])],
-                [AC_DEFINE([GNULIB_PROGRAM_INVOCATION_NAME], [1],
-                           [Define to 1 to add extern declaration of 
program_invocation_name to argp.h])],
-                [[#include <errno.h>]])
-  AC_CHECK_DECL([program_invocation_short_name],
-                [AC_DEFINE([HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME], [1],
-                           [Define if program_invocation_short_name is 
declared])],
-                [AC_DEFINE([GNULIB_PROGRAM_INVOCATION_SHORT_NAME], [1],
-                           [Define to 1 to add extern declaration of 
program_invocation_short_name to argp.h])],
-                [[#include <errno.h>]])
+  AC_CHECK_DECLS([program_invocation_name], [],
+                 [AC_DEFINE([GNULIB_PROGRAM_INVOCATION_NAME], [1],
+                            [Define to 1 to add extern declaration of 
program_invocation_name to argp.h])],
+                 [[#include <errno.h>]])
+  AC_CHECK_DECLS([program_invocation_short_name], [],
+                 [AC_DEFINE([GNULIB_PROGRAM_INVOCATION_SHORT_NAME], [1],
+                            [Define to 1 to add extern declaration of 
program_invocation_short_name to argp.h])],
+                 [[#include <errno.h>]])

   # Check if program_invocation_name and program_invocation_short_name
   # are defined elsewhere. It is improbable that only one of them will
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]