Re: BUG : mutiple and argoptional option fail to fill <opt>_args[0] with default value

Lorenzo Bettini <[email protected]> Sat, 20 Oct 2012 13:42:56 +0200
Newsgroups gmane.comp.gnu.gengetopt.general
Message-ID <[email protected]>
Then, please file a bug report (see the link at gengetopt's site); but I =

won't be able to work on that for some time, so please, if you want to =

provide a patch, you're very welcome :)

cheers
	Lorenzo

On 19/10/2012 16:00, Fr=E9d=E9ric Heitzmann wrote:
> Lorenzo,
>
> It __would__ make sense if this behaviour was consistent with the 'non
> multiple option' behaviour.
> Let me show you :
>
> option "unique" - "set a 'unique' option" string typestr=3D"STR" optional
> argoptional default=3D"unique_default"
> option "multiple" - "set a 'multiple' option" string typestr=3D"STR"
> optional argoptional default=3D"multiple_default" multiple
>
> Using a small test program (code below), I see :
>
> $ ./ggotest
> unique: unique_arg=3Dunique_default unique_orig=3D(null) unique_given=3D0
> multiple: multiple_given=3D0 multiple_arg[0]=3Dmultiple_default
> multiple_orig[0]=3D(null)
>
>  >> excepted
>
> $ ./ggotest --unique --multiple
> unique: *unique_arg=3Dunique_default* unique_orig=3D(null) unique_given=
=3D1
> multiple: multiple_given=3D0 *multiple_arg[0]=3D(null)* multiple_orig[0]=
=3D(null)
>
>  >> oops ! I expected to see the same argument for both options.
> According to you, maybe it is the --unique option which should have a
> (null) argument.
> Either way, the current behaviour seems inconsistent, and unaligned with
> the documentation :
> /"If it is known that a multiple option has a default value, then it can
> be safely assumed that the first element of generated array
> <option>_arg| is always set."/
>
> What do you think ?
>
> --
> Fred
>
> On 19 October 2012 12:54, Lorenzo Bettini <[email protected]
> <mailto:[email protected]>> wrote:
>
>     Hi
>
>     since you also specify that 'argoptional' then the default value is n=
ot
>     set if you specify no argument to --foo, since the argument is option=
al,
>     so that option --foo is meant to be able to deal also with no argument
>     at all... that's how I interpreted the semantics when I implemented i=
t.
>
>     Does it make sense?
>
>     hope to hear from you soon
>     cheers
>              Lorenzo
>
>     P.S. please take a look at the current open (and closed) bugs to make
>     sure that this issue has already been raised.
>
>     On 10/19/2012 10:57 AM, Fr=E9d=E9ric Heitzmann wrote:
>      > Hi all,
>      >
>      > I defined and option like this :
>      >
>      > option "foo" - "bla bla bla" string typestr=3D"STR"
>     default=3D"default_foo"
>      > argoptional multiple optional
>      >
>      > If I call with --foo, the default value is not added to foo_args[0=
].
>      > Actually, foo_args[0] is a NULL pointer, while I expected that
>      > foo_args[0] would be string "default_foo".
>      >
>      > If I remove 'default', and set --foo without any argument, this ti=
me
>      > foo_args[0] is set to "default_foo".
>      >
>      > The documentation says :
>      > "If it is known that a multiple option has a default value, then
>     it can
>      > be safely assumed that the first element of generated array
>      > |<option>_arg| is always set. "
>      >
>      > so it really looks like a bug to me.
>      >
>      > Can someone confirm ?
>      > I may work on a patch if it helps.
>
>
>     --
>     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
>
>     _______________________________________________
>     Help-gengetopt mailing list
>     [email protected] <mailto:[email protected]>
>     https://lists.gnu.org/mailman/listinfo/help-gengetopt
>
>
>
>
> _______________________________________________
> Help-gengetopt mailing list
> [email protected]
> https://lists.gnu.org/mailman/listinfo/help-gengetopt