use progname module

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.m4.patches
Message-ID <[email protected]>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The master branch already uses the progname module; and based on coreutils
recent switch to use it, I decided that it is worth making branch-1.6 do
likewise.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             [email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkhFPPoACgkQ84KuGfSFAYB8mgCgrt8x54j4wfw64LkrRX05L4jN
NcQAnRRDn1HAh6cJwfueweTXdi+vbKCl
=yZI8
-----END PGP SIGNATURE-----

_______________________________________________
M4-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/m4-patches
m4.patch355 (text/plain, 4.1 KB)
From 3be468475e78fc79f2e4aa60585daf7232e5c68d Mon Sep 17 00:00:00 2001
From: Eric Blake <[email protected]>
Date: Tue, 3 Jun 2008 06:42:14 -0600
Subject: [PATCH] Use progname module rather than rolling our own program_name.

* m4/gnulib-cache.m4: Import progname module.
* src/m4.c (program_name): Replace...
(main): ...with a call to set_program_name.

Signed-off-by: Eric Blake <[email protected]>
---
 ChangeLog          |    7 +++++++
 m4/gnulib-cache.m4 |    4 ++--
 src/m4.c           |    6 ++----
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b3ddf60..adc0364 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-06-03  Eric Blake  <[email protected]>
+
+	Use progname module rather than rolling our own program_name.
+	* m4/gnulib-cache.m4: Import progname module.
+	* src/m4.c (program_name): Replace...
+	(main): ...with a call to set_program_name.
+
 2008-06-02  Eric Blake  <[email protected]>
 
 	Stage 24: Allow embedded NUL in macro names.
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index b6ba202..5aa4820 100644
--- a/m4/gnulib-cache.m4
+++ b/m4/gnulib-cache.m4
@@ -15,11 +15,11 @@
 
 
 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --local-dir=local --lib=libm4 --source-base=lib --m4-base=m4 --doc-base=doc --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=M4 announce-gen assert autobuild avltree-oset binary-io clean-temp cloexec close-stream closein config-h error fdl fflush flexmember fopen-safer fseeko gendocs getopt git-version-gen gnumakefile gnupload gpl-3.0 intprops memchr2 memmem mkstemp obstack quote regex stdbool stdint stdlib-safer strtod strtol unlocked-io vasnprintf-posix verror version-etc version-etc-fsf xalloc xmemdup0 xprintf xvasprintf-posix
+#   gnulib-tool --import --dir=. --local-dir=local --lib=libm4 --source-base=lib --m4-base=m4 --doc-base=doc --aux-dir=build-aux --with-tests --no-libtool --macro-prefix=M4 announce-gen assert autobuild avltree-oset binary-io clean-temp cloexec close-stream closein config-h error fdl fflush flexmember fopen-safer fseeko gendocs getopt git-version-gen gnumakefile gnupload gpl-3.0 intprops memchr2 memmem mkstemp obstack progname quote regex stdbool stdint stdlib-safer strtod strtol unlocked-io vasnprintf-posix verror version-etc version-etc-fsf xalloc xmemdup0 xprintf xvasprintf-posix
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([local])
-gl_MODULES([announce-gen assert autobuild avltree-oset binary-io clean-temp cloexec close-stream closein config-h error fdl fflush flexmember fopen-safer fseeko gendocs getopt git-version-gen gnumakefile gnupload gpl-3.0 intprops memchr2 memmem mkstemp obstack quote regex stdbool stdint stdlib-safer strtod strtol unlocked-io vasnprintf-posix verror version-etc version-etc-fsf xalloc xmemdup0 xprintf xvasprintf-posix])
+gl_MODULES([announce-gen assert autobuild avltree-oset binary-io clean-temp cloexec close-stream closein config-h error fdl fflush flexmember fopen-safer fseeko gendocs getopt git-version-gen gnumakefile gnupload gpl-3.0 intprops memchr2 memmem mkstemp obstack progname quote regex stdbool stdint stdlib-safer strtod strtol unlocked-io vasnprintf-posix verror version-etc version-etc-fsf xalloc xmemdup0 xprintf xvasprintf-posix])
 gl_AVOID([])
 gl_SOURCE_BASE([lib])
 gl_M4_BASE([m4])
diff --git a/src/m4.c b/src/m4.c
index e2ef4bc..238222f 100644
--- a/src/m4.c
+++ b/src/m4.c
@@ -25,6 +25,7 @@
 #include <signal.h>
 #include <stdarg.h>
 
+#include "progname.h"
 #include "version-etc.h"
 
 #define AUTHORS "Rene' Seindal", "Eric Blake"
@@ -66,9 +67,6 @@ int nesting_limit = 1024;
 const char *user_word_regexp = "";
 #endif
 
-/* The name this program was run with. */
-const char *program_name;
-
 /* Global catchall for any errors that should affect final error status, but
    where we try to continue execution in the meantime.  */
 int retcode;
@@ -413,7 +411,7 @@ main (int argc, char *const *argv, char *const *envp)
   const char *frozen_file_to_write = NULL;
   const char *macro_sequence = "";
 
-  program_name = argv[0];
+  set_program_name (argv[0]);
   retcode = EXIT_SUCCESS;
   atexit (close_stdin);
 
-- 
1.5.5.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.