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

From Doug McNaught
Subject Re: Does getopt() return "-1", or "EOF", at end?
Date
Msg-id m3r8oz6z4m.fsf@varsoon.denali.to
Whole thread Raw
In response to Does getopt() return "-1", or "EOF", at end?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane <tgl@sss.pgh.pa.us> writes:

> 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 don't know, but the Solaris getopt() manpage specifies it as
returning EOF rather than -1.  I *think* POSIX mandates EOF == -1
anyhow but I'm certainly not sure of that (and we run on non-POSIX
systems too I guess). 

-Doug
-- 
Let us cross over the river, and rest under the shade of the trees.  --T. J. Jackson, 1863


pgsql-hackers by date:

Previous
From: "Marc G. Fournier"
Date:
Subject: pg_dump bug ... or not?
Next
From: Peter Eisentraut
Date:
Subject: Re: Does getopt() return "-1", or "EOF", at end?