]> Savannah Git Hosting - gnulib.git/commitdiff
getopt: port recent getopt changes to macOS
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 9 Apr 2017 00:26:03 +0000 (17:26 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 9 Apr 2017 07:52:20 +0000 (00:52 -0700)
Problem reported by Harald Maier (Bug#26398).
The macOS C compiler uses __nonnull for its own purposes and that
clashes with glibc's __nonnull.
* lib/getopt.in.h: Add comment for _GL_ARG_NONNULL snippet.
* lib/getopt_cdefs.in.h (__nonnull): Remove.
* lib/getopt_core.h (getopt):
* lib/getopt_ext.h (getopt_long, getopt_long_only):
Use _GL_ARG_NONNULL, not __nonnull.
* lib/unistd.in.h: Move snippet hooks to before where the getopt
.h files are included, so that _GL_ARG_NONNULL is defined in time.
* modules/getopt-posix (Depends-on): Add snippet/arg-nonnull.
(getopt.h): Interpolate _GL_ARG_NONNULL snippet.

ChangeLog
lib/getopt.in.h
lib/getopt_cdefs.in.h
lib/getopt_core.h
lib/getopt_ext.h
lib/unistd.in.h
modules/getopt-posix

index db893f5e165c3f0486d9eed70449fcea177cb8f2..595f2ba43d0381960cd0f5f9f74338a3eced766a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2017-04-08  Paul Eggert  <eggert@cs.ucla.edu>
+
+       getopt: port recent getopt changes to macOS
+       Problem reported by Harald Maier (Bug#26398).
+       The macOS C compiler uses __nonnull for its own purposes and that
+       clashes with glibc's __nonnull.
+       * lib/getopt.in.h: Add comment for _GL_ARG_NONNULL snippet.
+       * lib/getopt_cdefs.in.h (__nonnull): Remove.
+       * lib/getopt_core.h (getopt):
+       * lib/getopt_ext.h (getopt_long, getopt_long_only):
+       Use _GL_ARG_NONNULL, not __nonnull.
+       * lib/unistd.in.h: Move snippet hooks to before where the getopt
+       .h files are included, so that _GL_ARG_NONNULL is defined in time.
+       * modules/getopt-posix (Depends-on): Add snippet/arg-nonnull.
+       (getopt.h): Interpolate _GL_ARG_NONNULL snippet.
+
 2017-04-06  Paul Eggert  <eggert@cs.ucla.edu>
 
        getopt-gnu: omit some duplicate code
index c3ffd955d0571ee7853b4de7acbd36c848dc504b..9f84c277520618ffed97808698ba54527fb7644c 100644 (file)
@@ -52,6 +52,8 @@
 # endif
 #endif
 
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
 #include <getopt_cdefs.h>
 #include <getopt_pfx_core.h>
 #include <getopt_pfx_ext.h>
index 35a266933adbb017ba6917a2505a130311fb18d3..54da28d1f2c179a1d1c80b2cef077d9008fa65d7 100644 (file)
 # endif
 #endif
 
-#ifndef __nonnull
-# if __GNUC_PREREQ (3,3)
-#  define __nonnull(params) __attribute__ ((__nonnull__ params))
-# else
-#  define __nonnull(params)
-# endif
-#endif
-
 #endif /* getopt_cdefs.h */
index 1744c29b74590045869a45d33af65fc87a7aa55d..76ef46646c48cc2315a5f68f9d10e4439d7f2d63 100644 (file)
@@ -89,7 +89,7 @@ extern int optopt;
    writable.  */
 
 extern int getopt (int ___argc, char *const *___argv, const char *__shortopts)
-       __THROW __nonnull ((2, 3));
+       __THROW _GL_ARG_NONNULL ((2, 3));
 
 __END_DECLS
 
index c1a58da8046727dffd96cd9c2415f0dac2a29caf..a3a6750875d68f040dc228def1eafc2854417dcb 100644 (file)
@@ -66,11 +66,11 @@ struct option
 extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv,
                        const char *__shortopts,
                        const struct option *__longopts, int *__longind)
-       __THROW __nonnull ((2, 3));
+       __THROW _GL_ARG_NONNULL ((2, 3));
 extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv,
                             const char *__shortopts,
                             const struct option *__longopts, int *__longind)
-       __THROW __nonnull ((2, 3));
+       __THROW _GL_ARG_NONNULL ((2, 3));
 
 __END_DECLS
 
index 38a0f0a9fc0b94c54c5ee8d94688c2e65707a747..de619dcca121413a501d315994118590ec0baa68 100644 (file)
 # include <sys/types.h>
 #endif
 
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+
 /* Get getopt(), optarg, optind, opterr, optopt.
    But avoid namespace pollution on glibc systems.  */
 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
@@ -142,13 +149,6 @@ _GL_INLINE_HEADER_BEGIN
 # define _GL_UNISTD_INLINE _GL_INLINE
 #endif
 
-/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
-
-/* The definition of _GL_ARG_NONNULL is copied here.  */
-
-/* The definition of _GL_WARN_ON_USE is copied here.  */
-
-
 /* Hide some function declarations from <winsock2.h>.  */
 
 #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
index 5844217ae5556f05753be941397495165f4fc02c..220875641cca48e00d0d714a1545826b4fdfbc4a 100644 (file)
@@ -18,6 +18,7 @@ unistd
 extensions
 include_next
 gettext-h       [test $REPLACE_GETOPT = 1]
+snippet/arg-nonnull
 
 configure.ac:
 gl_FUNC_GETOPT_POSIX
@@ -43,6 +44,7 @@ getopt.h: getopt.in.h $(top_builddir)/config.status
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
              -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_GETOPT_H''@|$(NEXT_GETOPT_H)|g' \
+             -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
              < $(srcdir)/getopt.in.h; \
        } > $@-t && \
        mv -f $@-t $@