Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!linus!philabs!cmcl2!seismo!brl-tgr!internet!Ron Natalie From: Ron Natalie Newsgroups: net.unix-wizards Subject: Re: 4.2bsd eof flag in stdio Message-ID: <5936@brl-tgr.ARPA> Date: Tue, 20-Nov-84 09:54:55 EST Article-I.D.: brl-tgr.5936 Posted: Tue Nov 20 09:54:55 1984 Date-Received: Thu, 22-Nov-84 06:23:51 EST Sender: news@brl-tgr.ARPA Organization: Ballistic Research Lab Lines: 48 Doug: Looking in your beloved System V manuals you will find under READ(2): A value of zero is returned when end-of-file has been reached. and When attempting to read a file associated with a tty that has no data currently available ... the read will block until the data becomes available. And then looking at the documentation for the TTY driver, where is it oh yes, it's called TERMIO and it's in the system administrators manual. Of course, no ordinary user would ever want to change his terminal modes. A line is delimited by a new-line (ASCII LF), an end-of-file (ASCII-EOT), or an end-of-line character. EOF - may be used to generate an end-of-file from a terminal. Thus if there are no characters waiting, which is to say EOF occurred at the beginning of line, zero characters will be passed back, which is the standard end-of-file indication. What this implies is the zero return from TTY reads are END-OF-FILE and should be treated as such. It is possible to continue reading past end of file on some devices such as TTY and Magtape, but that doesn't mean you shouldn't handle EOF properly. Fread states Fread stops appending bytes if an end-of-file or error condition occurs. Ferror states Feof returns non-zero when EOF has previously been detected reading the named input stream. Clearerr resets the error indicator and EOF indicator to zero. It is obvious from this, that no distinction is made of EOT chars meaning anything but the absolute end-of-file on TTY. If you were attempting to write a Stdio using the definitions in the manual, you would have to implement it this way. You need to stop defining UNIX by whatever bugs AT&T has and penalize Berkeley because they have fixed a legitimate bug in the original UNIX code. -Ron Like I'm from the Mystic Valley.