Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!ut-sally!ut-ngp!melpad!bigtex!james
From: james@bigtex.uucp (James Van Artsdalen)
Newsgroups: comp.bugs.sys5
Subject: Re: chars in conditional expression, 3b2 C compiler
Message-ID: <191@bigtex.uucp>
Date: Fri, 2-Jan-87 06:19:04 EST
Article-I.D.: bigtex.191
Posted: Fri Jan  2 06:19:04 1987
Date-Received: Fri, 2-Jan-87 20:37:18 EST
References: <2489@sdsu.UUCP> <189@olamb.UUCP>
Sender: news@bigtex.uucp
Reply-To: james@bigtex.UUCP (James Van Artsdalen)
Organization: F.B.N. Software, Austin TX
Lines: 18

IN article <189@olamb.UUCP>, kimcm@olamb.UUCP (Kim Chr. Madsen) wrote:
> The only thing that really bugs me is the fact that chars are unsigned
> and therefore the following code will fail:
> 
> 	while ((c=getc(stream)) != EOF) putchar(c);
> 
> And you will have to redefine EOF to 255 (0377 or 0xff) or cast it to a char!

This code will fail no matter how chars are handled, assuming "c" is a "char".
If you remember that getc() returns an *int*, not a char, and have "int c"
instead of "char c", this works just fine.

If "c" is declared "char c;", the while loop above is broken even with signed
chars: what happens to the while loop if a 0xff is in the file?  It terminates
early, whereas if c is "int c;" is works OK.  lint will find this kind of bug.
-- 
James R. Van Artsdalen   ...!ut-sally!utastro!bigtex!james   "Live Free or Die"
Voice: (512)-323-2675  Modem: (512)-323-2773  5300B McCandless, Austin TX 78756