delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/02/27/11:47:34

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Sun, 27 Feb 2005 11:47:19 -0500 (EST)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: cygwin AT cygwin DOT com
Subject: getopt required_argument (Was Re: regtool - 1.8 - Core dump)
In-Reply-To: <4221625B.8D133A7D@dessent.net>
Message-ID: <Pine.GSO.4.61.0502271142170.14885@slinky.cs.nyu.edu>
References: <20050227054557 DOT 45931 DOT qmail AT web51102 DOT mail DOT yahoo DOT com> <4221625B DOT 8D133A7D AT dessent DOT net>
MIME-Version: 1.0

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/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019