Discussion:
GetLongOpts won't set flag when long option is found
(too old to reply)
grouchysmurf
2016-10-10 18:33:56 UTC
Permalink
Raw Message
Hi.

I've been playing with GetLongOpts recently and I *think* I found a
bug though this may be as well a required behaviour but I decided to
report it anyway.

GetLongOpts fails to set a flag even when directly told to so.

Consider following code [1].

When executed with '-o' it sets flag as expected. When one uses
'--option' instead flag is not set.

In getopts.pp, line #397:

if longind<>nil then
plongint(longind)^:=indfound+1;
if pfound^.flag<>nil then
begin
pfound^.flag^:=pfound^.value;
internal_getopt:=#0;
exit;
end;

I do believe that the exit should be there but again, maybe that's
just me.

Looking forward to your reply,
Łukasz

[1]. https://gist.github.com/anonymous/e26fdadd4a88fbd3c27db74d09db5158

_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mai
Michael Van Canneyt
2016-10-13 12:21:01 UTC
Permalink
Raw Message
Post by grouchysmurf
Hi.
I've been playing with GetLongOpts recently and I *think* I found a
bug though this may be as well a required behaviour but I decided to
report it anyway.
GetLongOpts fails to set a flag even when directly told to so.
Consider following code [1].
When executed with '-o' it sets flag as expected. When one uses
'--option' instead flag is not set.
if longind<>nil then
plongint(longind)^:=indfound+1;
if pfound^.flag<>nil then
begin
pfound^.flag^:=pfound^.value;
internal_getopt:=#0;
exit;
end;
I do believe that the exit should be there but again, maybe that's
just me.
I will look at it, at least I can reproduce the problem.

Can you please post a bugreport, so it will not be forgotten ?

Michael.
_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
grouchysmurf
2016-10-13 19:38:57 UTC
Permalink
Raw Message
Hi.
Post by Michael Van Canneyt
I will look at it, at least I can reproduce the problem.
Can you please post a bugreport, so it will not be forgotten ?
Cool, thanks.

http://bugs.freepascal.org/view.php?id=30736

I forgot that mantis automatically changes #xxx to link pointing
to a corresponding bug report.

Łukasz

_______________________________________________
fpc-devel maillist - fpc-***@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinf

Loading...