It is fairly easy to fix, just make the definition weak
and check for a NULL value before using it. OK to push?
index ed9dba0..65f2d9d 100644
--- a/lib/error.c
+++ b/lib/error.c
@@ -106,7 +106,7 @@ char *strerror_r ();
/* The calling program should define program_name and set it to the
name of the executing program. */
-extern char *program_name;
+char *program_name;
# if HAVE_STRERROR_R || defined strerror_r
# define __strerror_r strerror_r
@@ -300,10 +300,11 @@ error (int status, int errnum, const char *message, ...)
(*error_print_progname) ();
else
{
+ char const *p = program_name ? program_name : "unknown";
#if _LIBC
- __fxprintf (NULL, "%s: ", program_name);
+ __fxprintf (NULL, "%s: ", p);
#else
- fprintf (stderr, "%s: ", program_name);
+ fprintf (stderr, "%s: ", p);
#endif
}
@@ -359,10 +360,11 @@ error_at_line (int status, int errnum, const char
*file_name,
(*error_print_progname) ();
else
{
+ char const *p = program_name ? program_name : "unknown";
#if _LIBC
- __fxprintf (NULL, "%s:", program_name);
+ __fxprintf (NULL, "%s: ", p);
#else
- fprintf (stderr, "%s:", program_name);
+ fprintf (stderr, "%s: ", p);
#endif
}