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

Поиск
Список
Период
Сортировка
От Doug McNaught
Тема Re: Does getopt() return "-1", or "EOF", at end?
Дата
Msg-id m3r8oz6z4m.fsf@varsoon.denali.to
обсуждение исходный текст
Ответ на Does getopt() return "-1", or "EOF", at end?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: "Marc G. Fournier"
Дата:
Сообщение: pg_dump bug ... or not?
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: Does getopt() return "-1", or "EOF", at end?