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

From: David Terrell <dbt(at)meat(dot)net>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Does getopt() return "-1", or "EOF", at end?
Date: 2002-01-09 21:29:49
Message-ID: 20020109132949.A8808@pianosa.catch22.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jan 09, 2002 at 12:58:45PM -0500, 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?

OpenBSD's getopt(3):
The getopt() function was once specified to return EOF instead of -1.
This was changed by IEEE Std1003.2-1992 (``POSIX.2'') to decouple
getopt() from <stdio.h>.

--
David Terrell | "If NNTP had a protocol extension for
dbt(at)meat(dot)net | administering a spanking (long overdue if
Nebcorp Prime Minister | you ask me), you'd be yelping right now."
http://wwn.nebcorp.com/ | - Miguel Cruz

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-01-09 21:42:23 Re: Does getopt() return "-1", or "EOF", at end?
Previous Message Doug Royer 2002-01-09 21:27:47 Re: Does getopt() return "-1", or "EOF", at end?