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

From: Richard Kuhns <rjk(at)grauel(dot)com>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Does getopt() return "-1", or "EOF", at end?
Date: 2002-01-10 12:33:09
Message-ID: 20020110073309.3aa35b6a.rjk@grauel.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 9 Jan 2002 16:10:15 -0500 (EST)
Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)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(at)grauel(dot)com
PO Box 6249 Tel: (765)477-6000 \
100 Sawmill Road x319
Lafayette, IN 47903 (800)489-4891 /

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zeugswetter Andreas SB SD 2002-01-10 14:46:54 Re: again on index usage
Previous Message Daniel Kalchev 2002-01-10 12:03:15 Re: again on index usage