Re: Does getopt() return "-1", or "EOF", at end? - Mailing list pgsql-hackers

From Richard Kuhns
Subject Re: Does getopt() return "-1", or "EOF", at end?
Date
Msg-id 20020110073309.3aa35b6a.rjk@grauel.com
Whole thread Raw
In response to Re: Does getopt() return "-1", or "EOF", at end?  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-hackers
On Wed, 9 Jan 2002 16:10:15 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us> wrote:

> Tom Lane wrote:
> > I notice that in some places we compare the result of getopt(3) to
> > "EOF", and in some other places we compare it to "-1".  I think we
> > should standardize on one or the other; anyone have an opinion
> > which it should be?
> > 
> > The man pages I have here (HPUX and Linux) both describe the
> > end-of-switches return value as being "-1".  The glibc sources also
> > use "-1".  Replacing this by EOF seems more readable but perhaps is
> > not strictly correct.
> > 
> > Are there any platforms that define EOF as something other than -1?
> 
> I think -1 is the only way to go.  EOF just doesn't seem right for a
> non-file access function.

FWIW, here's a quote from the FreeBSD man page:
   The getopt() function was once specified to return EOF instead of -1.    This was changed by IEEE Std 1003.2-1992
(``POSIX.2'')to decouple    getopt() from <stdio.h>.
 

-- 
Richard Kuhns            rjk@grauel.com
PO Box 6249            Tel: (765)477-6000 \
100 Sawmill Road                    x319
Lafayette, IN  47903             (800)489-4891 /


pgsql-hackers by date:

Previous
From: Daniel Kalchev
Date:
Subject: Re: again on index usage
Next
From: "Zeugswetter Andreas SB SD"
Date:
Subject: Re: again on index usage