J. David Bryan wrote:
On 17 Oct 2007 at 12:41, Lorenzo Bettini wrote:
Actually setting print_errors to 0 in the _init function causes
previous code not to work anymore in some cases, and this is quite
dangerous (e.g., some tests in the testsuite do not print error
messages anymore); thus I set print_errors to 1 also in the _init
function and changed the documentation accordingly.
I don't quite understand the intent of the "_init" function. Wouldn't it
make more sense if it initialized the values to the defaults (override = 0,
initialize = 1, check_required = 1), rather than to all zeros? Then:
params = cmdline_parser_params_init();
i = cmdline_parser_ext (..., params);
...would be the same as:
i = cmdline_parser (...);
...and then in using "cmdline_parser_params_init", you would only have to
change those items where the default behavior is not what is wanted.
But maybe I don't understand gengetopt enough yet to know why zeros are
best.
on the contrary you got the point perfectly: it was my original mistake
to initialize those fields to 0 instead of to their default values;
indeed the equivalence above is perfectly right (and probably I'll add
it to the documentation). I'm only scared that changing the _init
function now might break existing code... but probably, since this
feature was added in the previous version only, now it is the best time
to write the _init function correctly (i.e., initialize fields with
their default values). I only hope this won't break existing code (by
silently changing the semantics of the function)...
probably, since also an init function accepting a pointer to an existing
params structure would be useful; thus there would be
void cmdline_parser_params_init(struct params *params);
struct params *cmdline_parser_params_create();
this change of signature (and these names are more appropriate as well)
would make previous code non compilable and would catch the attention of
the programmer so that he can realize that something has changed.
I could also use the first function in all the generated parser
functions (by avoiding current duplication of code).
what do you think?
thanks
Lorenzo
--
Lorenzo Bettini, PhD in Computer Science, DSI, Univ. di Firenze
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
_______________________________________________
Help-gengetopt mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gengetopt