diff --git a/lib/getopt.in.h b/lib/getopt.in.h index 91e086c..900b54d 100644 --- a/lib/getopt.in.h +++ b/lib/getopt.in.h @@ -52,6 +52,8 @@ # endif #endif +/* The definition of _GL_ARG_NONNULL is copied here. */ + #include #include #include diff --git a/lib/getopt_core.h b/lib/getopt_core.h index d6ef8a6..f543024 100644 --- a/lib/getopt_core.h +++ b/lib/getopt_core.h @@ -88,8 +88,12 @@ extern int optopt; enabled, the argv array (not the strings it points to) must be writable. */ +#ifndef _GL_ARG_NONNULL +# define _GL_ARG_NONNULL __nonnull +#endif + extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) - __THROW __nonnull ((2, 3)); + __THROW _GL_ARG_NONNULL ((2, 3)); __END_DECLS diff --git a/lib/getopt_ext.h b/lib/getopt_ext.h index 79b7a67..fc99e3a 100644 --- a/lib/getopt_ext.h +++ b/lib/getopt_ext.h @@ -63,14 +63,18 @@ struct option #define required_argument 1 #define optional_argument 2 +#ifndef _GL_ARG_NONNULL +# define _GL_ARG_NONNULL __nonnull +#endif + 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 diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index 38adf2a..d25ea0a 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -1527,6 +1527,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 $@