Commit 9cedf3e1 authored by Jim Meyering's avatar Jim Meyering Committed by Bruno Haible
Browse files

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.
parent d7b888c5
2009-08-24 Jim Meyering <meyering@redhat.com>
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 <bruno@clisp.org>
 
* lib/dup3.c: Include <string.h>.
......@@ -22,6 +22,7 @@
#undef ENABLE_RELOCATABLE /* avoid defining set_program_name as a macro */
#include "progname.h"
#include <errno.h> /* get program_invocation_name declaration */
#include <string.h>
......@@ -60,4 +61,11 @@ set_program_name (const char *argv0)
*/
program_name = argv0;
/* On glibc systems, when the gnulib module 'error' is not used, the error()
function comes from libc and uses the variable program_invocation_name,
not program_name. So set this variable as well. */
#if HAVE_DECL_PROGRAM_INVOCATION_NAME
program_invocation_name = (char *) argv0;
#endif
}
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment