[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gnulib] Re: use of program_name
From: |
Bruno Haible |
Subject: |
Re: [bug-gnulib] Re: use of program_name |
Date: |
Mon, 9 Jan 2006 14:49:45 +0100 |
User-agent: |
KMail/1.5 |
James Youngman wrote on 2006-01-05:
> My problem is that we have changed the interface without making it
> impossible for the user to use the new interface wrongly. I would
> prefer an arrangement which results in a compilation or link failure
> if the user (i.e. software maintainer) fails to initialise things
> properly. A runtime failure is insufficiently helpful in my opinion.
The appended patch will help against a direct assignment of program_name,
reminding the developer to call set_program_name().
Against a missing set_program_name call, we'll only have the core dump of
the error() function. Like now, against a missing program_name assignment.
> A runtime failure is insufficiently helpful in my opinion.
And how about a runtime failure that occurs in every invocation? We could
add a check in getopt() and getopt_long(), verifying that program_name is
non-NULL. Most GNU programs use getopt() and getopt_long().
Bruno
*** progname.h.bak 2005-05-14 15:46:42.000000000 +0200
--- progname.h 2006-01-07 03:10:40.000000000 +0100
***************
*** 30,36 ****
/* String containing name the program is called with. */
! extern const char *program_name;
/* Set program_name, based on argv[0]. */
extern void set_program_name (const char *argv0);
--- 30,36 ----
/* String containing name the program is called with. */
! extern const char * const program_name;
/* Set program_name, based on argv[0]. */
extern void set_program_name (const char *argv0);
*** progname.c.bak 2005-09-21 13:08:21.000000000 +0200
--- progname.c 2006-01-07 03:10:22.000000000 +0100
***************
*** 22,28 ****
--- 22,30 ----
#endif
/* Specification. */
+ #define program_name readonly_program_name
#include "progname.h"
+ #undef program_name
#include <string.h>
- Re: use of -fno-common on Darwin, (continued)
- Re: use of -fno-common on Darwin, Peter O'Gorman, 2006/01/10
- Re: getprogname, Bruno Haible, 2006/01/10
- Re: getprogname, Paul Eggert, 2006/01/10
- Re: getprogname, Bruno Haible, 2006/01/10
- Re: getprogname, Paul Eggert, 2006/01/11
- Re: use of -fno-common on Darwin, James Youngman, 2006/01/10
- Re: getprogname, Bruno Haible, 2006/01/11
- Re: getprogname, Paul Eggert, 2006/01/11
- Re: [bug-gnulib] Re: use of program_name, Bruno Haible, 2006/01/09
- Re: use of program_name, James Youngman, 2006/01/05
- Re: [bug-gnulib] Re: use of program_name,
Bruno Haible <=
- Re: [bug-gnulib] Re: use of program_name, James Youngman, 2006/01/09
- Re: use of program_name, Dave Love, 2006/01/05
- Re: [bug-gnulib] Re: use of program_name, Bruno Haible, 2006/01/09
- Re: [bug-gnulib] Re: use of program_name, Bruno Haible, 2006/01/09
Re: [bug-gnulib] use of program_name, Bruno Haible, 2006/01/09