Re: Usage of isspace and friends

From: Linus Torvalds <torvalds@osdl.org>
Date: 2005-10-14 01:04:17
On Wed, 12 Oct 2005, Junio C Hamano wrote:
> 
> Huh?  isspace is "int isspace(int)".  Presumably standard
> integral promotion rules applies here whether char is signed or
> unsigned, doesn't it?

No.

The input range for the "isxxxxx()" macros is the same as the range for 
the "[f]getc[h]()" family: unsigned char + EOF (the latter usually being 
-1).

So Morten is right - if you have a "char *", it should not be dereferenced 
and used directly, although I think glibc does the right thing (and, in 
fact, I can't understand why the standards haven't been updated to do the 
right thing: it's _not_ that hard. In fact, it should be trivial apart 
from the special case of "255" that looks undistinguishable from EOF in 
signed char representation).

I'm almost goign to suggest that we do our own ctype.h, just to get the 
sane semantics: we want locale-independence, _and_ we want the right 
signed behaviour. Plus we only use a very small subset of ctype.h anyway 
(isspace, isalpha, isdigit and isalnum).

			Linus
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Fri Oct 14 01:05:12 2005

This archive was generated by hypermail 2.1.8 : 2005-10-14 01:05:15 EST