getopt required_argument (Was Re: regtool - 1.8 - Core dump)

2005-02-27 Thread Igor Pechtchanski
On Sat, 26 Feb 2005, Brian Dessent wrote:

> Alexander Joerg Herrmann wrote:
>
> > What I was mentioning is that
> > regtool -K
> > causes a core fault and something similar under windows because the
> > argument is broken. I know that the argument is missing and so should
> > regtool. It should produce a usage message insteed of a crash imo.
>
> The program should not core dump on invalid arguments.  That I agree
> with, and it's a bug that should be fixed.

Well, it's just a matter of adding a check for optarg being NULL and
printing an appropriate message (e.g.,
  if (optarg == NULL) {
fprintf(stderr, "Missing key-value separator\n");
usage();
  }
).

However, the question is what should getopt's behavior be if something
specified as a "required_argument" is missing?  Should it simply set
optarg to NULL, just like it does with "optional_argument", or should it
return an error code of some sort?  Any getopt experts out there?
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_[EMAIL PROTECTED]
 |,4-  ) )-,_. ,\ (  `'-'   Igor Pechtchanski, Ph.D.
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"The Sun will pass between the Earth and the Moon tonight for a total
Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: getopt required_argument (Was Re: regtool - 1.8 - Core dump)

2005-02-27 Thread Igor Pechtchanski
On Sun, 27 Feb 2005, Igor Pechtchanski wrote:

> On Sat, 26 Feb 2005, Brian Dessent wrote:
>
> > Alexander Joerg Herrmann wrote:
> >
> > > What I was mentioning is that
> > > regtool -K
> > > causes a core fault and something similar under windows because the
> > > argument is broken. I know that the argument is missing and so should
> > > regtool. It should produce a usage message insteed of a crash imo.
> >
> > The program should not core dump on invalid arguments.  That I agree
> > with, and it's a bug that should be fixed.
>
> Well, it's just a matter of adding a check for optarg being NULL and
> printing an appropriate message (e.g.,
>   if (optarg == NULL) {
> fprintf(stderr, "Missing key-value separator\n");
> usage();
>   }
> ).
>
> However, the question is what should getopt's behavior be if something
> specified as a "required_argument" is missing?  Should it simply set
> optarg to NULL, just like it does with "optional_argument", or should it
> return an error code of some sort?  Any getopt experts out there?

Whoops, never mind.  It's a bug, pure and simple.  According to
,
two colons after a character indicate an *optional* argument, and for a
required argument one needs to use only one colon.  The only change needed
is that opts[] needs to only have one colon after "K".
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_[EMAIL PROTECTED]
 |,4-  ) )-,_. ,\ (  `'-'   Igor Pechtchanski, Ph.D.
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"The Sun will pass between the Earth and the Moon tonight for a total
Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: getopt required_argument (Was Re: regtool - 1.8 - Core dump)

2005-03-01 Thread Alexander Joerg Herrmann
> Well, it's just a matter of adding a check for
> optarg being NULL and
> printing an appropriate message (e.g.,
>   if (optarg == NULL) {
> fprintf(stderr, "Missing key-value
> separator\n");
> usage();
>   }
> ).
Yup looks easy but I may better patch the DLL to use
some kind of fstab file which would it make complete
portable as now I'am sitting in front of a computer
which let's me run bash but not cmd - a. 

> However, the question is what should getopt's
> behavior be if something
> specified as a "required_argument" is missing? 
It sould do the same thing as the long parameter
arguments imo.
Alex

=
___
http://tahi4x4.felixfrisch.deTake a look :)
[EMAIL PROTECTED]


Yahoo! Messenger - Communicate instantly..."Ping" 
your friends today! Download Messenger Now 
http://uk.messenger.yahoo.com/download/index.html

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: getopt required_argument (Was Re: regtool - 1.8 - Core dump)

2005-03-01 Thread Igor Pechtchanski
On Tue, 1 Mar 2005, Alexander Joerg Herrmann wrote:

> > Well, it's just a matter of adding a check for
> > optarg being NULL and
> > printing an appropriate message (e.g.,
> >   if (optarg == NULL) {
> > fprintf(stderr, "Missing key-value
> > separator\n");
> > usage();
> >   }
> > ).
> Yup looks easy but I may better patch the DLL to use

FYI, this has been fixed in the snapshots by Christopher Faylor (which
happened between the time I did a "cvs update" and the time I prepared a
patch -- go figure).

> some kind of fstab file which would it make complete
> portable as now I'am sitting in front of a computer
> which let's me run bash but not cmd - a.

This has been discussed, and, in fact, is a plan for the future.  That was
one of the reasons using "mount" was suggested -- no matter where the
mounts are stored, "mount" will be guaranteed to do the right thing.

> > However, the question is what should getopt's
> > behavior be if something
> > specified as a "required_argument" is missing?
> It sould do the same thing as the long parameter
> arguments imo.

This was my bug -- the long options specified the argument as required,
but the short ones specified it as optional (two colons).  Thanks to CGF
for fixing it.
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_[EMAIL PROTECTED]
 |,4-  ) )-,_. ,\ (  `'-'   Igor Pechtchanski, Ph.D.
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"The Sun will pass between the Earth and the Moon tonight for a total
Lunar eclipse..." -- WCBS Radio Newsbrief, Oct 27 2004, 12:01 pm EDT

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/