diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-12-15 13:53:40 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-12-15 13:53:40 +0000 |
commit | c1c7970e6de825e7dc39a8cfa0432ad115c64afa (patch) | |
tree | 9d263dea122f17802f0688a3eb1d81a49f4f17c4 /lib | |
parent | 291a1676ac5b8d9f5e8a9507ff70e93b26eb0854 (diff) |
Casting to unsigned int in isfoo() causes problems on alpha and
sparc64. Change cast back to unsigned char but do a bitwise AND
with 0xff to avoid any sign extension weirdness and to make it
impossible for us to overflow _C_ctype_. The bitwise AND is probably
not needed and may be removed later if this does not trigger compiler bugs.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gen/isctype.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/libc/gen/isctype.c b/lib/libc/gen/isctype.c index 4202b5acbe5..d02179a8a65 100644 --- a/lib/libc/gen/isctype.c +++ b/lib/libc/gen/isctype.c @@ -37,7 +37,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: isctype.c,v 1.6 2002/12/14 02:34:39 millert Exp $"; +static char rcsid[] = "$OpenBSD: isctype.c,v 1.7 2002/12/15 13:53:39 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #define _ANSI_LIBRARY @@ -49,7 +49,7 @@ int isalnum(c) int c; { - return (c == EOF ? 0 : (_ctype_ + 1)[(unsigned int)c] & (_U|_L|_N)); + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)(c & 0xff)] & (_U|_L|_N))); } #undef isalpha @@ -57,7 +57,7 @@ int isalpha(c) int c; { - return (c == EOF ? 0 : (_ctype_ + 1)[(unsigned int)c] & (_U|_L)); + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)(c & 0xff)] & (_U|_L))); } #undef isblank @@ -73,7 +73,7 @@ int iscntrl(c) int c; { - return (c == EOF ? 0 : (_ctype_ + 1)[(unsigned int)c] & _C); + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)(c & 0xff)] & _C)); } #undef isdigit @@ -81,7 +81,7 @@ int isdigit(c) int c; { - return (c == EOF ? 0 : (_ctype_ + 1)[(unsigned int)c] & _N); + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)(c & 0xff)] & _N)); } #undef isgraph @@ -89,7 +89,7 @@ int isgraph(c) int c; { - return (c == EOF ? 0 : (_ctype_ + 1)[(unsigned int)c] & (_P|_U|_L|_N)); + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)(c & 0xff)] & (_P|_U|_L|_N))); } #undef islower @@ -97,7 +97,7 @@ int islower(c) int c; { - return (c == EOF ? 0 : (_ctype_ + 1)[(unsigned int)c] & _L); + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)(c & 0xff)] & _L)); } #undef isprint @@ -105,7 +105,7 @@ int isprint(c) int c; { - return (c == EOF ? 0 : (_ctype_ + 1)[(unsigned int)c] & (_P|_U|_L|_N|_B)); + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)(c & 0xff)] & (_P|_U|_L|_N|_B))); } #undef ispunct @@ -113,7 +113,7 @@ int ispunct(c) int c; { - return (c == EOF ? 0 : (_ctype_ + 1)[(unsigned int)c] & _P); + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)(c & 0xff)] & _P)); } #undef isspace @@ -121,7 +121,7 @@ int isspace(c) int c; { - return (c == EOF ? 0 : (_ctype_ + 1)[(unsigned int)c] & _S); + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)(c & 0xff)] & _S)); } #undef isupper @@ -129,7 +129,7 @@ int isupper(c) int c; { - return (c == EOF ? 0 : (_ctype_ + 1)[(unsigned int)c] & _U); + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)(c & 0xff)] & _U)); } #undef isxdigit @@ -137,7 +137,7 @@ int isxdigit(c) int c; { - return (c == EOF ? 0 : (_ctype_ + 1)[(unsigned int)c] & (_N|_X)); + return (c == EOF ? 0 : ((_ctype_ + 1)[(unsigned char)(c & 0xff)] & (_N|_X))); } #undef isascii |