help-gengetopt
[Top][All Lists]
Advanced

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

Re: [help-gengetopt] override and multiple options


From: Lorenzo Bettini
Subject: Re: [help-gengetopt] override and multiple options
Date: Fri, 12 Dec 2008 11:51:12 +0100
User-agent: Thunderbird 2.0.0.18 (X11/20081125)

Andre Noll wrote:
Hi

I just noticed a somewhat weird behaviour of gengetopt's config file
parser in combination with multiple options and the override feature.

If a (string) option is declared as multiple in the ggo file and was
given one or more times when calling the config file parser for the
first time, everything works as expected: the xxx_given field contains
the number of times this option was given, and xxx_option_arg[]
is a NULL-terminated array of that size containing the given values.

If the config file parser is later called again with a params struct
that enables override, I would expect it to _replace_ the array by
the values which have been found in the config file during this second
call. After all, this is what the word "override" indicates.

However, the new set of options are _appended_ to the old values
instead. Is this behaviour intended? If it is, is that feature
documented anywhere? If it isn't intended, what could be done to fix
the situation while retaining backwards compatibility?


Hi Andre

I think that this is the intended behavior for multiple options, since multiple options are thought exactly to append other options to the ones already given, thus they should not be overridden; it is up to the application itself to decide what to do then.

For instance, the -O option can be given many times to the gcc compiler, and it will decide that only the last one is the one to apply (at least I think it is like that, in fact, in another program, I was struggling with a prebuilt command line option to the compiler that couldn't be changed and this contained -O2 which makes it hard to debug programs: I then appended -O0 and this solved the problem).

I agree with you that this should be stressed in the documentation: I hadn't written that because I gave it for granted, but that's my mistake :-)

any other in the list have opinion about this?

cheers
        Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
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




reply via email to

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