bug-gnulib
[Top][All Lists]
Advanced

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

Re: error.c has an unnecessary dependency on "program_name"


From: Bruno Haible
Subject: Re: error.c has an unnecessary dependency on "program_name"
Date: Sun, 7 Nov 2010 21:40:55 +0100
User-agent: KMail/1.9.9

Bruce Korb wrote:
> error.c has an unnecessary dependency on "program_name"

No, it is not an "unnecessary" dependency. There is no portable way for code
in a module to determine the name of the current program. Programs that use the
'error' module must define the program_name variable and assign it a value.

> 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;
> ...
> +      char const *p = program_name ? program_name : "unknown";

No, this is not OK, for two reasons:
  1) It will cause a link error for all programs that define the 'program_name'
     variable, on all non-ELF platforms (mainly MacOS X and Woe32).
  2) Substituting "unknown" instead of a real program name will not help the
     end user.

Bruno



reply via email to

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