[klibc] isspace() and other ctype.h functions
H. Peter Anvin
hpa at zytor.com
Tue Nov 11 23:46:21 PST 2003
Greg KH wrote:
> Hm, finally subscribed here, forgot to...
>
> Anyway, I'm using klibc in udev and have added some needed functions
> (like ftruncate and vsyslog). Should I post the patches here before
> commiting them to the cvs tree?
>
That would be a good idea.
> Also, it looks like ctype.h has a off-by-one bug. isspace(' ') returns
> 0 right now, but if you change the function from:
>
> __ctype_inline int isspace(int __c)
> {
> return __ctypes[__c+1] & __ctype_space; */
> }
>
> to
> __ctype_inline int isspace(int __c)
> {
> return __ctypes[__c] & __ctype_space; */
> }
>
> things start working again :)
>
> In looking at the __ctypes[] array, it is 0 based, so all of the +1
> array changes in ctype.h should be removed. Or am I missing something
> here?
>
Yes, the first element should be -1 == EOF. However, the array starts:
const unsigned char __ctypes[257] = {
0, /* EOF */
0, /* control character */
0, /* control character */
0, /* control character */
0, /* control character */
0, /* control character */
0, /* control character */
0, /* control character */
__ctype_space, /* BS */
... there is one too few of the middle lines; I'll check that in right away.
-hpa
More information about the klibc
mailing list