🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9632

Re: How it got "broke"...

#9632
From: Chris Torek
Date: Wed, 22 Oct 1986 04:07
22 lines
1381 bytes
In article <1322@umd5> don@umd5 (Chris Sylvain) writes:
>Why "while( fputc(fgetc(fd), fe) != EOF )" quit working as it
>did under both 2.9BSD and Ultrix 1.2 ...

Chances are it never really worked: fputc(EOF, fe) is likely to
put a meta-DEL into file `fe'.

>1)  At the end of file, fgetc() returns (int) -1.
>2)  fputc() prints (char) -1 and then returns a CHAR not an INT.

Actually, fputc returns (unsigned char)c, which turned EOF to 255.

>Naturally, (int) -1 != (char) -1, so we have a problem.

On Ultrix 1.2 Vaxen and 2.9BSD 11s, (int) -1 *is* equal to
(char) -1.  The code is wrong in the first place; fputc is
not supposed to be handed an EOF.  What it does in such cases
is undefined.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@mimsy.umd.edu
Technical Details
Message-ID: <3966@umcp-cs.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!umcp-cs!chris
References: <1322@umd5>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!umcp-cs!chris
From: chris@umcp-cs.UUCP (Chris Torek)
Newsgroups: net.lang.c
Subject: Re: How it got "broke"...
Message-ID: <3966@umcp-cs.UUCP>
Date: Wed, 22-Oct-86 00:07:39 EDT
Article-I.D.: umcp-cs.3966
Posted: Wed Oct 22 00:07:39 1986
Date-Received: Wed, 22-Oct-86 22:14:28 EDT
References: <1322@umd5>
Reply-To: chris@umcp-cs.UUCP (Chris Torek)
Organization: University of Maryland, Dept. of Computer Sci.
Lines: 22