* lib/stdlib.in.h (getprogname): New declaration.
* lib/getprogname.h: Add deprecation warning.
(getprogname): Remove declaration.
* lib/getprogname.c: Include <stdlib.h> instead of getprogname.h.
* m4/stdlib_h.m4 (gl_STDLIB_H): Test whether getprogname is declared.
(gl_STDLIB_H_REQUIRE_DEFAULTS): Initialize GNULIB_GETPROGNAME.
(gl_STDLIB_H_DEFAULTS): Initialize HAVE_GETPROGNAME.
* m4/getprogname.m4 (gl_PREREQ_GETPROGNAME): New macro, extracted from
gl_FUNC_GETPROGNAME. Set HAVE_GETPROGNAME.
(gl_FUNC_GETPROGNAME): Remove code that was moved to
gl_PREREQ_GETPROGNAME.
* modules/stdlib (Makefile.am): Substitute GNULIB_GETPROGNAME and
HAVE_GETPROGNAME.
* modules/getprogname (Depends-on): Add stdlib.
(configure.ac): Define a module indicator. Invoke gl_PREREQ_GETPROGNAME.
(Makefile.am): Don't compile getprogname.c if not needed.
(Include): List <stdlib.h> instead of getprogname.h.
* tests/test-getprogname.c: Include <stdlib.h> instead of getprogname.h.
* NEWS: Mention the change.
* lib/argmatch.c: Don't include getprogname.h.
* lib/c-stack.c: Likewise.
* lib/error.c: Likewise.
* lib/git-merge-changelog.c: Likewise.
+2023-01-21 Bruno Haible <bruno@clisp.org>
+
+ getprogname: Move declaration from "getprogname.h" to <stdlib.h>.
+ * lib/stdlib.in.h (getprogname): New declaration.
+ * lib/getprogname.h: Add deprecation warning.
+ (getprogname): Remove declaration.
+ * lib/getprogname.c: Include <stdlib.h> instead of getprogname.h.
+ * m4/stdlib_h.m4 (gl_STDLIB_H): Test whether getprogname is declared.
+ (gl_STDLIB_H_REQUIRE_DEFAULTS): Initialize GNULIB_GETPROGNAME.
+ (gl_STDLIB_H_DEFAULTS): Initialize HAVE_GETPROGNAME.
+ * m4/getprogname.m4 (gl_PREREQ_GETPROGNAME): New macro, extracted from
+ gl_FUNC_GETPROGNAME. Set HAVE_GETPROGNAME.
+ (gl_FUNC_GETPROGNAME): Remove code that was moved to
+ gl_PREREQ_GETPROGNAME.
+ * modules/stdlib (Makefile.am): Substitute GNULIB_GETPROGNAME and
+ HAVE_GETPROGNAME.
+ * modules/getprogname (Depends-on): Add stdlib.
+ (configure.ac): Define a module indicator. Invoke gl_PREREQ_GETPROGNAME.
+ (Makefile.am): Don't compile getprogname.c if not needed.
+ (Include): List <stdlib.h> instead of getprogname.h.
+ * tests/test-getprogname.c: Include <stdlib.h> instead of getprogname.h.
+ * NEWS: Mention the change.
+ * lib/argmatch.c: Don't include getprogname.h.
+ * lib/c-stack.c: Likewise.
+ * lib/error.c: Likewise.
+ * lib/git-merge-changelog.c: Likewise.
+
2023-01-19 Paul Eggert <eggert@cs.ucla.edu>
snippet/_Noreturn: work around Clang _Noreturn bug
Date Modules Changes
+2023-01-21 getprogname The include file is changed from "getprogname.h"
+ to <stdlib.h>.
+
2023-01-15 stdalign This module is deprecated. Use alignasof instead.
2023-01-07 timer_time Link with $(TIMER_TIME_LIB) instead of
#include "error.h"
#include "quotearg.h"
-#include "getprogname.h"
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
#include <sigsegv.h>
#include "exitfail.h"
-#include "getprogname.h"
#include "idx.h"
#include "ignore-value.h"
# define USE_UNLOCKED_IO 0
# define _GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD(a, b)
# define _GL_ARG_NONNULL(a)
-#else
-# include "getprogname.h"
#endif
#if USE_UNLOCKED_IO
#include <config.h>
-/* Specification. */
-#include "getprogname.h"
+/* Specification. Also get __argv declaration. */
+#include <stdlib.h>
#include <errno.h> /* get program_invocation_name declaration */
-#include <stdlib.h> /* get __argv declaration */
#ifdef _AIX
# include <unistd.h>
#if defined __SCO_VERSION__ || defined __sysv5__
# include <fcntl.h>
-# include <stdlib.h>
# include <string.h>
#endif
#include "basename-lgpl.h"
-#ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Cygwin */
+#ifndef HAVE_GETPROGNAME /* not Mac OS X, FreeBSD, NetBSD, OpenBSD >= 5.4, Solaris >= 11, Cygwin, Android API level >= 21 */
char const *
getprogname (void)
{
#include <stdlib.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Return the base name of the executing program.
- On native Windows this will usually end in ".exe" or ".EXE". */
-#ifndef HAVE_GETPROGNAME
-extern char const *getprogname (void)
-# ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME
- _GL_ATTRIBUTE_PURE
-# endif
- ;
-#endif
-
-#ifdef __cplusplus
-}
+#if __GNUC__ || (__clang_major__ >= 4)
+# warning "The include file getprogname.h is deprecated. Use <stdlib.h> instead."
#endif
#endif
#include "minmax.h"
#include "c-strstr.h"
#include "fwriteerror.h"
-#include "getprogname.h"
#define ASSERT(expr) \
do \
# endif
#endif
+#if @GNULIB_GETPROGNAME@
+/* Return the base name of the executing program.
+ On native Windows this will usually end in ".exe" or ".EXE". */
+# if !@HAVE_GETPROGNAME@
+# ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME
+_GL_FUNCDECL_SYS (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE);
+# else
+_GL_FUNCDECL_SYS (getprogname, const char *, (void));
+# endif
+# endif
+_GL_CXXALIAS_SYS (getprogname, const char *, (void));
+_GL_CXXALIASWARN (getprogname);
+#elif defined GNULIB_POSIXCHECK
+# undef getprogname
+# if HAVE_RAW_DECL_GETPROGNAME
+_GL_WARN_ON_USE (getprogname, "getprogname is unportable - "
+ "use gnulib module getprogname for portability");
+# endif
+#endif
+
#if @GNULIB_GETSUBOPT@
/* Assuming *OPTIONP is a comma separated list of elements of the form
"token" or "token=value", getsubopt parses the first of these elements.
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
-# serial 5
+# serial 6
AC_DEFUN([gl_FUNC_GETPROGNAME],
[
- AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
gl_CHECK_FUNCS_ANDROID([getprogname], [[#include <stdlib.h>]])
+ if test $ac_cv_func_getprogname = no; then
+ HAVE_GETPROGNAME=0
+ fi
+])
+
+AC_DEFUN([gl_PREREQ_GETPROGNAME],
+[
+ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
AC_CHECK_FUNCS_ONCE([getexecname])
ac_found=0
AC_CHECK_DECLS([program_invocation_name], [ac_found=1], [],
-# stdlib_h.m4 serial 66
+# stdlib_h.m4 serial 67
dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
# include <random.h>
#endif
]], [_Exit aligned_alloc atoll canonicalize_file_name free
- getloadavg getsubopt grantpt
+ getloadavg getprogname getsubopt grantpt
initstate initstate_r mbtowc mkdtemp mkostemp mkostemps mkstemp mkstemps
posix_memalign posix_openpt ptsname ptsname_r qsort_r
random random_r reallocarray realpath rpmatch secure_getenv setenv
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CANONICALIZE_FILE_NAME])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FREE_POSIX])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOADAVG])
+ gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPROGNAME])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETSUBOPT])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GRANTPT])
gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MALLOC_GNU])
HAVE_DECL_FCVT=1; AC_SUBST([HAVE_DECL_FCVT])
HAVE_DECL_GCVT=1; AC_SUBST([HAVE_DECL_GCVT])
HAVE_DECL_GETLOADAVG=1; AC_SUBST([HAVE_DECL_GETLOADAVG])
+ HAVE_GETPROGNAME=1; AC_SUBST([HAVE_GETPROGNAME])
HAVE_GETSUBOPT=1; AC_SUBST([HAVE_GETSUBOPT])
HAVE_GRANTPT=1; AC_SUBST([HAVE_GRANTPT])
HAVE_INITSTATE=1; AC_SUBST([HAVE_INITSTATE])
m4/getprogname.m4
Depends-on:
-basename-lgpl
-extensions
-open
+stdlib
+basename-lgpl [test $HAVE_GETPROGNAME = 0]
+extensions [test $HAVE_GETPROGNAME = 0]
+open [test $HAVE_GETPROGNAME = 0]
configure.ac:
gl_FUNC_GETPROGNAME
+gl_CONDITIONAL([GL_COND_OBJ_GETPROGNAME], [test $HAVE_GETPROGNAME = 0])
+AM_COND_IF([GL_COND_OBJ_GETPROGNAME], [
+ gl_PREREQ_GETPROGNAME
+])
+gl_STDLIB_MODULE_INDICATOR([getprogname])
Makefile.am:
-lib_SOURCES += getprogname.h getprogname.c
+if GL_COND_OBJ_GETPROGNAME
+lib_SOURCES += getprogname.c
+endif
Include:
-"getprogname.h"
+<stdlib.h>
License:
LGPLv2+
-e 's/@''GNULIB_CANONICALIZE_FILE_NAME''@/$(GNULIB_CANONICALIZE_FILE_NAME)/g' \
-e 's/@''GNULIB_FREE_POSIX''@/$(GNULIB_FREE_POSIX)/g' \
-e 's/@''GNULIB_GETLOADAVG''@/$(GNULIB_GETLOADAVG)/g' \
+ -e 's/@''GNULIB_GETPROGNAME''@/$(GNULIB_GETPROGNAME)/g' \
-e 's/@''GNULIB_GETSUBOPT''@/$(GNULIB_GETSUBOPT)/g' \
-e 's/@''GNULIB_GRANTPT''@/$(GNULIB_GRANTPT)/g' \
-e 's/@''GNULIB_MALLOC_GNU''@/$(GNULIB_MALLOC_GNU)/g' \
-e 's|@''HAVE_DECL_FCVT''@|$(HAVE_DECL_FCVT)|g' \
-e 's|@''HAVE_DECL_GCVT''@|$(HAVE_DECL_GCVT)|g' \
-e 's|@''HAVE_DECL_GETLOADAVG''@|$(HAVE_DECL_GETLOADAVG)|g' \
+ -e 's|@''HAVE_GETPROGNAME''@|$(HAVE_GETPROGNAME)|g' \
-e 's|@''HAVE_GETSUBOPT''@|$(HAVE_GETSUBOPT)|g' \
-e 's|@''HAVE_GRANTPT''@|$(HAVE_GRANTPT)|g' \
-e 's|@''HAVE_INITSTATE''@|$(HAVE_INITSTATE)|g' \
#include <config.h>
-#include "getprogname.h"
+#include <stdlib.h>
+
#include <string.h>
#include <assert.h>