[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-gnulib] Re: requirements of 'error' module
From: |
Simon Josefsson |
Subject: |
[Bug-gnulib] Re: requirements of 'error' module |
Date: |
Fri, 21 Nov 2003 06:50:16 +0100 |
User-agent: |
Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) |
Bruno Haible <address@hidden> writes:
> Simon Josefsson wrote:
>> error: assumes the application add a symbol 'program_name'. This is
>> difficult to do properly if my application is a library with its own
>> namespace.
>
> How should an error message from the library look like to the end user?
>
> "libgsasl: invalid signature"
> or
> "mutt: invalid signature"
> ?
For libgsasl, I don't want it to ever output anything on
stdout/stderr. The error module was added because Nettle (the
low-level crypto library) used alloca, and I copied alloca from
gnulib. I don't want to support my own alloca.c, so I rewrote Nettle
to use a fixed size buffer instead and call assert if it is too small
(it already use assert for similar errors, and only two functions was
involved, so I deemed it acceptable).
Here's what I proposed in an earlier message:
#if __GNUC__
#define program_name program_invocation_name
#else
char *program_name = "unknown";
#endif
#define SET_PROGRAM_NAME(name) program_name = strdup (name)
I think this should be appended with:
#define SET_PROGRAM_NAME_IF_UNSET(name) if (strcmp (program_name, "unknown") ==
0) program_name = strdup (name)
Then libraries can call
SET_PROGRAM_NAME_IF_UNSET("libgsasl")
to make error message look nicer, but applications that also use the
error package can call SET_PROGRAM_NAME("mutt") to override it.
What do you think?