4.2bsd eof flag in stdio

Spencer W. Thomas thomas at utah-gr.UUCP
Mon Nov 19 16:41:01 AEST 1984


In article <5867 at brl-tgr.ARPA> gwyn at brl-tgr.ARPA (Doug Gwyn <gwyn>) writes:
>fread() returns 0 if there are 0 characters left in the terminal
>input queue when the ^D is typed.  What would you have it do?
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.
>
>Contrary to popular misconception, ^D is NOT an "EOF" character;
>rather, it marks a delimiter for input canonicalization.  If all
>previous input has been consumed and a ^D is typed, then read()
>returns a count of 0.  This is often interpreted as EOF.  If there
>is some uncanonicalized input and ^D is typed, it acts much like
>NEWLINE except of course no \n is appended.
>
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"?

>If the 4.2BSD fread() was buggy, it should have been fixed rather
>than introducing a significant incompatibility with other STDIOs.
This bug is in ALL versions of fread (and getchar, and ...) *except*
4.2.

=Spencer



More information about the Comp.unix.wizards mailing list