List Info

Thread: Re: using the interfaces in ctype.h




Re: using the interfaces in ctype.h
user name
2008-04-17 09:32:00
>> - cast ctype arguments to unsigned char and not
int, [...]

Yes.  I was going to give a detailed reply, but others, such
as
christos and apb, beat me to it.

> Unfortunately even various NetBSD architectures, at
least for some
> releases, are inconsistent in how these interfaces are
defined and
> what warnings are given for various usages.

Yes; when I started to build my ocde on 4.0 I got a lot of
"array
subscript has type char" warnings, which caught places
where I'd been
sloppy in this respect.

I wish there were versions of those calls that were defined
to take
unsigned char rather than int, for use when you have
something that
can't be EOF (like an element of a buffer).

> I've had the best luck getting the least warnings on a
wide variety
> of platforms by always casting to (int) too.

That will work fine, if your only goal is to shut up the
warnings.  But
it won't make the code any more correct.   (In
passing, do incorrect
calls actually core, or just produce nonsense?  I'd expect
ctype to
have at least 128 bytes of valid memory before it....)

/~ The ASCII				der Mouse
 / Ribbon Campaign
 X  Against HTML	       mouserodents.montreal.qc.ca
/  Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3
27 4B

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )