forked from len0rd/rockbox
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
This commit is contained in:
parent
dc4a6b828e
commit
889ab162a5
1 changed files with 14 additions and 14 deletions
|
@ -43,29 +43,29 @@ extern const unsigned char _ctype_[257];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
#define isalpha(c) ((_ctype_+1)[(unsigned)(c)]&(_U|_L))
|
#define isalpha(c) ((_ctype_+1)[(unsigned char)(c)]&(_U|_L))
|
||||||
#define isupper(c) ((_ctype_+1)[(unsigned)(c)]&_U)
|
#define isupper(c) ((_ctype_+1)[(unsigned char)(c)]&_U)
|
||||||
#define islower(c) ((_ctype_+1)[(unsigned)(c)]&_L)
|
#define islower(c) ((_ctype_+1)[(unsigned char)(c)]&_L)
|
||||||
#define isdigit(c) ((_ctype_+1)[(unsigned)(c)]&_N)
|
#define isdigit(c) ((_ctype_+1)[(unsigned char)(c)]&_N)
|
||||||
#define isxdigit(c) ((_ctype_+1)[(unsigned)(c)]&(_X|_N))
|
#define isxdigit(c) ((_ctype_+1)[(unsigned char)(c)]&(_X|_N))
|
||||||
#define isspace(c) ((_ctype_+1)[(unsigned)(c)]&_S)
|
#define isspace(c) ((_ctype_+1)[(unsigned char)(c)]&_S)
|
||||||
#define ispunct(c) ((_ctype_+1)[(unsigned)(c)]&_P)
|
#define ispunct(c) ((_ctype_+1)[(unsigned char)(c)]&_P)
|
||||||
#define isalnum(c) ((_ctype_+1)[(unsigned)(c)]&(_U|_L|_N))
|
#define isalnum(c) ((_ctype_+1)[(unsigned char)(c)]&(_U|_L|_N))
|
||||||
#define isprint(c) ((_ctype_+1)[(unsigned)(c)]&(_P|_U|_L|_N|_B))
|
#define isprint(c) ((_ctype_+1)[(unsigned char)(c)]&(_P|_U|_L|_N|_B))
|
||||||
#define isgraph(c) ((_ctype_+1)[(unsigned)(c)]&(_P|_U|_L|_N))
|
#define isgraph(c) ((_ctype_+1)[(unsigned char)(c)]&(_P|_U|_L|_N))
|
||||||
#define iscntrl(c) ((_ctype_+1)[(unsigned)(c)]&_C)
|
#define iscntrl(c) ((_ctype_+1)[(unsigned char)(c)]&_C)
|
||||||
/* Non-gcc versions will get the library versions, and will be
|
/* Non-gcc versions will get the library versions, and will be
|
||||||
slightly slower */
|
slightly slower */
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
# define toupper(c) \
|
# define toupper(c) \
|
||||||
__extension__ ({ int __x = (c); islower(__x) ? (__x - 'a' + 'A') : __x;})
|
__extension__ ({ int __x = (unsigned char) (c); islower(__x) ? (__x - 'a' + 'A') : __x;})
|
||||||
# define tolower(c) \
|
# define tolower(c) \
|
||||||
__extension__ ({ int __x = (c); isupper(__x) ? (__x - 'A' + 'a') : __x;})
|
__extension__ ({ int __x = (unsigned char) (c); isupper(__x) ? (__x - 'A' + 'a') : __x;})
|
||||||
#endif
|
#endif
|
||||||
#endif /* !__cplusplus */
|
#endif /* !__cplusplus */
|
||||||
|
|
||||||
#ifndef __STRICT_ANSI__
|
#ifndef __STRICT_ANSI__
|
||||||
#define isascii(c) ((unsigned)(c)<=0177)
|
#define isascii(c) ((unsigned char)(c)<=0177)
|
||||||
#define toascii(c) ((c)&0177)
|
#define toascii(c) ((c)&0177)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue