bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] progname: also set global program_invocation_name, when possible


From: Jim Meyering
Subject: [PATCH] progname: also set global program_invocation_name, when possible
Date: Mon, 24 Aug 2009 20:14:51 +0200

Hi Bruno,

Before this change, I saw this:

    $ ./guestfish --help > /dev/full
    /w/co/libguestfs/fish/.libs/lt-guestfish: write error: No space left on 
device

With the updated module, I get this:

    $ ./guestfish --help > /dev/full
    guestfish: write error: No space left on device

I considered writing a test, but it would require running
libtool, and I'd rather not impose that on all users of
this module who choose to run gnulib tests.

>From 34963232379a99953721754a9b9721146f1a428b Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 24 Aug 2009 20:10:16 +0200
Subject: [PATCH] progname: also set global program_invocation_name, when 
possible

Before this change, a libtool-enabled program that calls glibc's
error function would report the program name as
"/abs/dir/.libs/lt-program_name" rather than the desired program_name.
* modules/progname (configure.ac): Check for a declaration of
program_invocation_name.
* lib/progname.c:  Include <errno.h>.
(set_program_name) [HAVE_DECL_PROGRAM_INVOCATION_NAME]:
Set program_invocation_name.
---
 ChangeLog        |   12 ++++++++++++
 lib/progname.c   |    5 +++++
 modules/progname |    1 +
 3 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 21e02a2..6ad5647 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2009-08-24  Jim Meyering  <address@hidden>
+
+       progname: also set global program_invocation_name, when possible
+       Before this change, a libtool-enabled program that calls glibc's
+       error function would report the program name as
+       "/abs/dir/.libs/lt-program_name" rather than the desired program_name.
+       * modules/progname (configure.ac): Check for a declaration of
+       program_invocation_name.
+       * lib/progname.c:  Include <errno.h>.
+       (set_program_name) [HAVE_DECL_PROGRAM_INVOCATION_NAME]:
+       Set program_invocation_name.
+
 2009-08-23  Bruno Haible  <address@hidden>

        * lib/dup3.c: Include <string.h>.
diff --git a/lib/progname.c b/lib/progname.c
index 9854b5e..a7397e9 100644
--- a/lib/progname.c
+++ b/lib/progname.c
@@ -22,6 +22,7 @@
 #undef ENABLE_RELOCATABLE /* avoid defining set_program_name as a macro */
 #include "progname.h"

+#include <errno.h>
 #include <string.h>


@@ -60,4 +61,8 @@ set_program_name (const char *argv0)
    */

   program_name = argv0;
+
+#if HAVE_DECL_PROGRAM_INVOCATION_NAME
+  program_invocation_name = (char *) argv0;
+#endif
 }
diff --git a/modules/progname b/modules/progname
index eacc452..0877801 100644
--- a/modules/progname
+++ b/modules/progname
@@ -8,6 +8,7 @@ lib/progname.c
 Depends-on:

 configure.ac:
+AC_CHECK_DECLS([program_invocation_name], [], [], [#include <errno.h>])

 Makefile.am:
 lib_SOURCES += progname.h progname.c
--
1.6.4.378.g88f2f




reply via email to

[Prev in Thread] Current Thread [Next in Thread]