+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>.
#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>
*/
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
}
Depends-on:
configure.ac:
+AC_CHECK_DECLS([program_invocation_name], [], [], [#include <errno.h>])
Makefile.am:
lib_SOURCES += progname.h progname.c