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

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Does getopt() return "-1", or "EOF", at end?
Date: 2002-01-09 21:10:15
Message-ID: 200201092110.g09LAFT10967@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Doug Royer 2002-01-09 21:27:47 Re: Does getopt() return "-1", or "EOF", at end?
Previous Message Peter Eisentraut 2002-01-09 21:06:49 Re: Does getopt() return "-1", or "EOF", at end?