I've just pushed the attached to make grep use gnulib's new
getprogname module instead of the classic "progname" module. This
means there is no longer the classic "char const *program_name"
variable, nor any need to call set_program_name.
From 6c96214b4d75de6bf6cf95514e39c494fdcc8c4f Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Mon, 5 Sep 2016 09:27:28 -0700
Subject: [PATCH] maint: switch from gnulib's progname to getprogname module
* gnulib: Update to latest, for its new getprogname module.
* bootstrap.conf (avoided_gnulib_modules): Include the getprogname
module rather than the now-obsolescent progname.
* src/grep.c: Include "getprogname.h" rather than "progname.h"
and remove any use of set_program_name.
* tests/dfa-match-aux.c (main): Likewise.
* tests/get-mb-cur-max.c (main): Likewise.
* src/grep.c (usage, main): Use getprogname() in place of program_name.
---
bootstrap.conf | 2 +-
gnulib | 2 +-
src/grep.c | 14 ++++++--------
tests/dfa-match-aux.c | 3 +--
tests/get-mb-cur-max.c | 3 +--
5 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index 9e76131..841937e 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -39,6 +39,7 @@ fstatat
fts
getopt-gnu
getpagesize
+getprogname
gettext-h
git-version-gen
gitlog-to-changelog
@@ -65,7 +66,6 @@ minmax
obstack
openat-safer
perl
-progname
propername
quote
readme-release
diff --git a/gnulib b/gnulib
index cffe9ac..7a10276 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit cffe9acc622fe5aa274c5c78ea860c9c17f8664c
+Subproject commit 7a10276e59a05f4176464e0fbadc3f743c8ed244
diff --git a/src/grep.c b/src/grep.c
index 15c6dc6..d07f5da 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -38,9 +38,9 @@
#include "fcntl-safer.h"
#include "fts_.h"
#include "getopt.h"
+#include "getprogname.h"
#include "grep.h"
#include "intprops.h"
-#include "progname.h"
#include "propername.h"
#include "quote.h"
#include "safe-read.h"
@@ -1897,19 +1897,19 @@ usage (int status)
if (status != 0)
{
fprintf (stderr, _("Usage: %s [OPTION]... PATTERN [FILE]...\n"),
- program_name);
+ getprogname());
fprintf (stderr, _("Try '%s --help' for more information.\n"),
- program_name);
+ getprogname());
}
else
{
- printf (_("Usage: %s [OPTION]... PATTERN [FILE]...\n"), program_name);
+ printf (_("Usage: %s [OPTION]... PATTERN [FILE]...\n"), getprogname());
printf (_("Search for PATTERN in each FILE or standard input.\n"));
printf (_("PATTERN is, by default, a basic regular expression
(BRE).\n"));
printf (_("\
Example: %s -i 'hello world' menu.h main.c\n\
\n\
-Regexp selection and interpretation:\n"), program_name);
+Regexp selection and interpretation:\n"), getprogname());
printf (_("\
-E, --extended-regexp PATTERN is an extended regular expression (ERE)\n\
-F, --fixed-strings PATTERN is a set of newline-separated strings\n\
@@ -2358,8 +2358,6 @@ main (int argc, char **argv)
FILE *fp;
exit_failure = EXIT_TROUBLE;
initialize_main (&argc, &argv);
- set_program_name (argv[0]);
- program_name = argv[0];
keys = NULL;
keycc = 0;
@@ -2689,7 +2687,7 @@ main (int argc, char **argv)
if (show_version)
{
- version_etc (stdout, program_name, PACKAGE_NAME, VERSION, AUTHORS,
+ version_etc (stdout, getprogname(), PACKAGE_NAME, VERSION, AUTHORS,
(char *) NULL);
return EXIT_SUCCESS;
}
diff --git a/tests/dfa-match-aux.c b/tests/dfa-match-aux.c
index 070089c..af80628 100644
--- a/tests/dfa-match-aux.c
+++ b/tests/dfa-match-aux.c
@@ -26,7 +26,7 @@
#include <dfa.h>
#include <localeinfo.h>
-#include "progname.h"
+#include "getprogname.h"
_Noreturn void
dfaerror (char const *mesg)
@@ -50,7 +50,6 @@ main (int argc, char **argv)
int allow_nl;
struct localeinfo localeinfo;
- set_program_name (argv[0]);
if (argc < 3)
exit (EXIT_FAILURE);
diff --git a/tests/get-mb-cur-max.c b/tests/get-mb-cur-max.c
index 403beb4..6e92796 100644
--- a/tests/get-mb-cur-max.c
+++ b/tests/get-mb-cur-max.c
@@ -21,12 +21,11 @@
#include <stdio.h>
#include <stdlib.h>
-#include "progname.h"
+#include "getprogname.h"
int
main (int argc, char **argv)
{
- set_program_name (argv[0]);
if (1 < argc && setlocale (LC_ALL, argv[1]))
{
printf ("%d\n", (int) MB_CUR_MAX);
--
2.8.0-rc2