Re: Usage of isspace and friends

From: Junio C Hamano <junkio@cox.net>
Date: 2005-10-13 16:49:30
Morten Welinder <mwelinder@gmail.com> writes:

> Someone needs to audit the usage of isspace, tolower, and
> friends.  There are things like this in the code:
>
> static int is_dev_null(const char *str)
> {
> 	return !memcmp("/dev/null", str, 9) && isspace(str[9]);
> }
>
> Since str[9] is of type char it should not be used as a argument to
> isspace directly,
> but rather be cast to unsigned char:
>
>     ... isspace((unsigned char)str[9]);

Huh?  isspace is "int isspace(int)".  Presumably standard
integral promotion rules applies here whether char is signed or
unsigned, doesn't it?

The snippet you quoted is from apply.c, and I would say what is
more problematic is that we do not force C locale while parsing
the diff (see another thread -- we would want to process diffs
as byte streams).

-
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 Thu Oct 13 16:50:54 2005

This archive was generated by hypermail 2.1.8 : 2005-10-13 16:50:57 EST