fix ctype macros to cast argument to (unsigned) first
issue reported by nsz, but it's actually not just pedantic. the functions can take input of any arithmetic type, including floating point, and the behavior needs to be as if the conversion implicit in the function call took place.
This commit is contained in:
parent
3bec53e0d3
commit
7e14ed1360
2 changed files with 7 additions and 7 deletions
|
|
@ -16,12 +16,12 @@ int isxdigit(int);
|
||||||
int tolower(int);
|
int tolower(int);
|
||||||
int toupper(int);
|
int toupper(int);
|
||||||
|
|
||||||
#define isalpha(a) ((unsigned)(((a)|32)-'a') < 26)
|
#define isalpha(a) ((((unsigned)(a)|32)-'a') < 26)
|
||||||
#define isdigit(a) ((unsigned)((a)-'0') < 10)
|
#define isdigit(a) (((unsigned)(a)-'0') < 10)
|
||||||
#define islower(a) ((unsigned)((a)-'a') < 26)
|
#define islower(a) (((unsigned)(a)-'a') < 26)
|
||||||
#define isupper(a) ((unsigned)((a)-'A') < 26)
|
#define isupper(a) (((unsigned)(a)-'A') < 26)
|
||||||
#define isprint(a) ((unsigned)((a)-0x20) < 0x5f)
|
#define isprint(a) (((unsigned)(a)-0x20) < 0x5f)
|
||||||
#define isgraph(a) ((unsigned)((a)-0x21) < 0x5e)
|
#define isgraph(a) (((unsigned)(a)-0x21) < 0x5e)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ wctrans_t wctrans(const char *);
|
||||||
wctype_t wctype(const char *);
|
wctype_t wctype(const char *);
|
||||||
|
|
||||||
#undef iswdigit
|
#undef iswdigit
|
||||||
#define iswdigit(a) ((unsigned)((a)-L'0') < 10)
|
#define iswdigit(a) (((unsigned)(a)-L'0') < 10)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue