This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: warnings from use of ctype.h methods
- From: DJ Delorie <dj at redhat dot com>
- To: Joel Sherrill <joel dot sherrill at oarcorp dot com>
- Cc: newlib at sources dot redhat dot com
- Date: Thu, 11 Mar 2010 18:26:48 -0500
- Subject: Re: warnings from use of ctype.h methods
- References: <4B9919E5.3020008@redhat.com> <4B991ECE.4030100@oarcorp.com>
In the case where you have a string, and you're explicitly checking for
NUL elsewhere, the right thing to do is to map the data you have into
the domain the function wants. In this case, a cast to (unsigned char)
gives your data the correct interpretation for the is*() functions.
If you cast a plain char to an int, you get values in the set
[-128..127], which is not the domain of values the is*() functions
expect. You should provide the is*() functions values in the set
[0..255, EOF].