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> _______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib