progname: also set global program_invocation_name, when possible.
[pspp] / lib / progname.c
index 9854b5e7ccbb73cbac054802940a55528b61fbac..19df10ad7169d43016a12e5bfc1dc1f5fcbb9d9a 100644 (file)
@@ -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
 }