4.2bsd eof flag in stdio

Doug Gwyn <gwyn> gwyn at brl-tgr.ARPA
Tue Nov 20 02:54:19 AEST 1984


> The problem is if you type 'foo^D' with no newline.  You would expect
> that this would terminate input reading, but it does not -- you must
> type another ^D to finish it off.

This is just what I expect.  Why should the first ^D terminate input
reading, since the read will return 3 characters at that point?

> This is, of course, a matter of opinion, but all the documentation
> states that ^D is the *end-of-file* character.  Perhaps the
> documentation (unchanged since my memory) is "buggy"?

Yup.  Kernighan & Pike got it right in their book.

> This bug is in ALL versions of fread (and getchar, and ...) *except*
> 4.2.

The UNIX System V Release 2.0 fread() acts as I originally described,
which is what I would expect.  In any case, judging from the number of
times people have had problems caused by this change, it was not a wise
move.



More information about the Comp.unix.wizards mailing list