+2016-08-18 Pino Toscano <ptoscano@redhat.com>
+
+ Port modules to use getprogname explicitly, instead of requiring
+ progname to be used (or program_name to be provided).
+ * lib/argmatch.c: Do not include progname.h.
+ [TEST] (program_name): Do not define.
+ [TEST] (main): Call getprogname instead of using program_name.
+ * lib/c-stack.c: Do not include progname.h.
+ (program_name): Do not define.
+ (die): Call getprogname instead of using program_name.
+ * lib/chdir-long.c: Do not include progname.h.
+ [TEST_CHDIR] (main): Do not set program_name.
+ * lib/error.c [!_LIBC]: Include progname.h.
+ [!_LIBC] (program_name): Define using getprogname.
+ * lib/euidaccess.c: Do not include progname.h.
+ [TEST] (main): Do not set program_name.
+ * lib/git-merge-changelog.c: Include getprogname.h instead of
+ progname.h.
+ (usage): Call getprogname instead of using program_name.
+ (main): Likewise. Stop calling set_program_name.
+ * lib/group-member.c: Do not include progname.h.
+ [TEST] (main): Do not set program_name.
+ * modules/argmatch (Depends-on): Add getprogname.
+ * modules/c-stack (Depends-on): Likewise.
+ * modules/error (Depends-on): Likewise.
+ * modules/git-merge-changelog (Depends-on): Likewise.
+ Also remove progname.
+
2016-09-05 Pino Toscano <ptoscano@redhat.com>
* NEWS: Document the deprecation of the 'progname' module.
#include "error.h"
#include "quotearg.h"
#include "quote.h"
+#include "getprogname.h"
#if USE_UNLOCKED_IO
# include "unlocked-io.h"
/*
* Based on "getversion.c" by David MacKenzie <djm@gnu.ai.mit.edu>
*/
-char *program_name;
/* When to make backup files. */
enum backup_type
const char *cp;
enum backup_type backup_type = no_backups;
- program_name = (char *) argv[0];
-
if (argc > 2)
{
- fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", program_name);
+ fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", getprogname ());
exit (1);
}
backup_args, backup_vals);
if (argc == 2)
- backup_type = XARGMATCH (program_name, argv[1],
+ backup_type = XARGMATCH (getprogname (), argv[1],
backup_args, backup_vals);
printf ("The version control is '%s'\n",
#include "c-stack.h"
#include "exitfail.h"
#include "ignore-value.h"
+#include "getprogname.h"
#if defined SA_ONSTACK && defined SA_SIGINFO
# define SIGINFO_WORKS 1
# endif
#endif
-extern char *program_name;
-
/* The user-specified action to take when a SEGV-related program error
or stack overflow occurs. */
static void (* volatile segv_action) (int);
#endif /* !SIGINFO_WORKS && !HAVE_LIBSIGSEGV */
segv_action (signo);
message = signo ? program_error_message : stack_overflow_message;
- ignore_value (write (STDERR_FILENO, program_name, strlen (program_name)));
+ ignore_value (write (STDERR_FILENO, getprogname (), strlen (getprogname ())));
ignore_value (write (STDERR_FILENO, ": ", 2));
ignore_value (write (STDERR_FILENO, message, strlen (message)));
ignore_value (write (STDERR_FILENO, "\n", 1));
# include "closeout.h"
# include "error.h"
-char *program_name;
-
int
main (int argc, char *argv[])
{
size_t n = 0;
int len;
- program_name = argv[0];
atexit (close_stdout);
len = getline (&line, &n, stdin);
# define USE_UNLOCKED_IO 0
# define _GL_ATTRIBUTE_FORMAT_PRINTF(a, b)
# define _GL_ARG_NONNULL(a)
+#else
+# include "getprogname.h"
#endif
#if USE_UNLOCKED_IO
# endif
# endif
-/* The calling program should define program_name and set it to the
- name of the executing program. */
-extern char *program_name;
+#define program_name getprogname ()
# if HAVE_STRERROR_R || defined strerror_r
# define __strerror_r strerror_r
# include <stdio.h>
# include <stdlib.h>
-char *program_name;
-
int
main (int argc, char **argv)
{
int mode;
int err;
- program_name = argv[0];
if (argc < 3)
abort ();
file = argv[1];
#include <sys/types.h>
#include <unistd.h>
-#include "progname.h"
#include "error.h"
#include "read-file.h"
#include "gl_xlist.h"
#include "minmax.h"
#include "c-strstr.h"
#include "fwriteerror.h"
+#include "getprogname.h"
#define ASSERT(expr) \
do \
{
if (status != EXIT_SUCCESS)
fprintf (stderr, "Try '%s --help' for more information.\n",
- program_name);
+ getprogname ());
else
{
printf ("Usage: %s [OPTION] O-FILE-NAME A-FILE-NAME B-FILE-NAME\n",
- program_name);
+ getprogname ());
printf ("\n");
printf ("Merges independent modifications of a ChangeLog style file.\n");
printf ("O-FILE-NAME names the original file, the ancestor of the two others.\n");
bool do_version;
bool split_merged_entry;
- /* Set program name for messages. */
- set_program_name (argv[0]);
-
/* Set default values for variables. */
do_help = false;
do_version = false;
if (do_version)
{
/* Version information is requested. */
- printf ("%s\n", program_name);
+ printf ("%s\n", getprogname ());
printf ("Copyright (C) %s Free Software Foundation, Inc.\n\
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>\n\
This is free software: you are free to change and redistribute it.\n\
#ifdef TEST
-char *program_name;
-
int
main (int argc, char **argv)
{
int i;
- program_name = argv[0];
-
for (i = 1; i < argc; i++)
{
gid_t gid;
stdbool
stdlib
memcmp
+getprogname
configure.ac:
raise
sigaction
libsigsegv
+getprogname
configure.ac:
gl_C_STACK
m4/error.m4
Depends-on:
+getprogname
stdio [test $ac_cv_lib_error_at_line = no]
strerror [test $ac_cv_lib_error_at_line = no]
unistd [test $ac_cv_lib_error_at_line = no]
getopt-gnu
stdbool
stdlib
-progname
error
read-file
xlist
fwriteerror
memchr
memcmp
+getprogname
configure.ac: