Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!usc!snorkelwacker!spdcc!mirror!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: How to write an 8-bit clean program Message-ID: <15945@haddock.ima.isc.com> Date: 14 Feb 90 22:42:50 GMT References: <1990Feb10.151053.16702@is.uu.no> <1990Feb11.012110.2338@utzoo.uucp> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 16 In article <1990Feb11.012110.2338@utzoo.uucp> henry@utzoo.uucp (Henry Spencer) writes: >Most of the time, cleanly-written code does not care. Using chars as >characters -- rather than small integers -- seldom runs into sign issues The problem is that getc() and the functions deal with a type which should have been "char" but in fact is a certain subrange of "int", namely the union of {EOF} and the values of "unsigned char". Thus, even cleanly-written code has to be sprinkled with casts to convert "plain char" to "unsigned char" before handing it to "isprint()". (I'm assuming ANSI C semantics here, so there's no isascii() nonsense.) Fixing this (by which I mean doing it *right*, not slapping on a backward- compatible patch) would involve getting rid of the constant EOF entirely. Of course, it's too late to change it now. Karl W. Z. Heuer (karl@ima.ima.isc.com or harvard!ima!karl), The Walking Lint