nmh-workers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nmh-workers] char args passed to isalpha() et al.


From: Valdis . Kletnieks
Subject: Re: [Nmh-workers] char args passed to isalpha() et al.
Date: Wed, 11 Apr 2007 11:20:55 -0400

On Wed, 11 Apr 2007 10:44:09 BST, Peter Maydell said:

> I'm not sure, but I think that the problem is to do with 'signed'
> vs 'unsigned' char. isalpha() et al want a value which is an unsigned
> char. If on some platform char is signed and we do something like:
> 
>   isalpha((int)*p)  /* p is a 'char *' */
> 
> and whatever char p points to is in the -ve range then isalpha is
> entitled to blow up.

Linus Torvalds recently had a longish rant on the Linux-Kernel list regarding
why passing functions signed or unsigned chars to a function whose prototype
contains just 'char' is a complete crock.  Basically, there's two cases - one
where signed and unsigned are treated identically, in which case the signedness
is superfluous.  In the other case, the function is by definition buggy (or at
least non-portable), because if it works *right* if passed an explicit "signed
char", it will blow up if compiled on a system where char defaults to unsigned,
and passed a 'char'.



Attachment: pgpQDWTNPL0w4.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]