summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Holmgren <magnushol@gmail.com>2005-08-11 19:32:39 +0000
committerMagnus Holmgren <magnushol@gmail.com>2005-08-11 19:32:39 +0000
commit889ab162a53f573ddddae2ee6d1c97889695ff90 (patch)
treeab44983be22ab3b0ecb1a4a47e3d439a5fbdef6a
parentdc4a6b828ea9a36e839747249dfdb085ced7af07 (diff)
downloadrockbox-889ab162a53f573ddddae2ee6d1c97889695ff90.tar.gz
rockbox-889ab162a53f573ddddae2ee6d1c97889695ff90.zip
Cast to unsigned isn't enough in the isXXXX macros (chars > 127 caused a negative array index). With a cast to unsigned char, the macros work as expected. The other macros were changed accordingly.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7305 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/include/ctype.h28
1 files changed, 14 insertions, 14 deletions
diff --git a/firmware/include/ctype.h b/firmware/include/ctype.h
index e0d20cc672..aba91a826b 100644
--- a/firmware/include/ctype.h
+++ b/firmware/include/ctype.h
@@ -43,29 +43,29 @@ extern const unsigned char _ctype_[257];
43#endif 43#endif
44 44
45#ifndef __cplusplus 45#ifndef __cplusplus
46#define isalpha(c) ((_ctype_+1)[(unsigned)(c)]&(_U|_L)) 46#define isalpha(c) ((_ctype_+1)[(unsigned char)(c)]&(_U|_L))
47#define isupper(c) ((_ctype_+1)[(unsigned)(c)]&_U) 47#define isupper(c) ((_ctype_+1)[(unsigned char)(c)]&_U)
48#define islower(c) ((_ctype_+1)[(unsigned)(c)]&_L) 48#define islower(c) ((_ctype_+1)[(unsigned char)(c)]&_L)
49#define isdigit(c) ((_ctype_+1)[(unsigned)(c)]&_N) 49#define isdigit(c) ((_ctype_+1)[(unsigned char)(c)]&_N)
50#define isxdigit(c) ((_ctype_+1)[(unsigned)(c)]&(_X|_N)) 50#define isxdigit(c) ((_ctype_+1)[(unsigned char)(c)]&(_X|_N))
51#define isspace(c) ((_ctype_+1)[(unsigned)(c)]&_S) 51#define isspace(c) ((_ctype_+1)[(unsigned char)(c)]&_S)
52#define ispunct(c) ((_ctype_+1)[(unsigned)(c)]&_P) 52#define ispunct(c) ((_ctype_+1)[(unsigned char)(c)]&_P)
53#define isalnum(c) ((_ctype_+1)[(unsigned)(c)]&(_U|_L|_N)) 53#define isalnum(c) ((_ctype_+1)[(unsigned char)(c)]&(_U|_L|_N))
54#define isprint(c) ((_ctype_+1)[(unsigned)(c)]&(_P|_U|_L|_N|_B)) 54#define isprint(c) ((_ctype_+1)[(unsigned char)(c)]&(_P|_U|_L|_N|_B))
55#define isgraph(c) ((_ctype_+1)[(unsigned)(c)]&(_P|_U|_L|_N)) 55#define isgraph(c) ((_ctype_+1)[(unsigned char)(c)]&(_P|_U|_L|_N))
56#define iscntrl(c) ((_ctype_+1)[(unsigned)(c)]&_C) 56#define iscntrl(c) ((_ctype_+1)[(unsigned char)(c)]&_C)
57/* Non-gcc versions will get the library versions, and will be 57/* Non-gcc versions will get the library versions, and will be
58 slightly slower */ 58 slightly slower */
59#ifdef __GNUC__ 59#ifdef __GNUC__
60# define toupper(c) \ 60# define toupper(c) \
61 __extension__ ({ int __x = (c); islower(__x) ? (__x - 'a' + 'A') : __x;}) 61 __extension__ ({ int __x = (unsigned char) (c); islower(__x) ? (__x - 'a' + 'A') : __x;})
62# define tolower(c) \ 62# define tolower(c) \
63 __extension__ ({ int __x = (c); isupper(__x) ? (__x - 'A' + 'a') : __x;}) 63 __extension__ ({ int __x = (unsigned char) (c); isupper(__x) ? (__x - 'A' + 'a') : __x;})
64#endif 64#endif
65#endif /* !__cplusplus */ 65#endif /* !__cplusplus */
66 66
67#ifndef __STRICT_ANSI__ 67#ifndef __STRICT_ANSI__
68#define isascii(c) ((unsigned)(c)<=0177) 68#define isascii(c) ((unsigned char)(c)<=0177)
69#define toascii(c) ((c)&0177) 69#define toascii(c) ((c)&0177)
70#endif 70#endif
71 71