diff options
author | Rich Felker <dalias@aerifal.cx> | 2015-04-17 22:24:31 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2015-04-17 22:24:31 -0400 |
commit | 2ca55a93f2a11185d72dcb69006fd2c30b5c3144 (patch) | |
tree | 0c8262539c52947bbb1e107a81e97254cb028502 /include | |
parent | 19bcdeeb1ebef6d209dfa938011c856bc3444a92 (diff) | |
download | musl-2ca55a93f2a11185d72dcb69006fd2c30b5c3144.tar.gz musl-2ca55a93f2a11185d72dcb69006fd2c30b5c3144.tar.bz2 musl-2ca55a93f2a11185d72dcb69006fd2c30b5c3144.tar.xz musl-2ca55a93f2a11185d72dcb69006fd2c30b5c3144.zip |
improve ctype.h macros to diagnose errors
the casts of the argument to unsigned int suppressed diagnosis of
errors like passing a pointer instead of a character. putting the
actual function call in an unreachable branch restores any diagnostics
that would be present if the macros didn't exist and functions were
used.
Diffstat (limited to 'include')
-rw-r--r-- | include/ctype.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/include/ctype.h b/include/ctype.h index a7d5db5d..cd2e0169 100644 --- a/include/ctype.h +++ b/include/ctype.h @@ -28,12 +28,12 @@ static __inline int __isspace(int _c) return _c == ' ' || (unsigned)_c-'\t' < 5; } -#define isalpha(a) ((((unsigned)(a)|32)-'a') < 26) -#define isdigit(a) (((unsigned)(a)-'0') < 10) -#define islower(a) (((unsigned)(a)-'a') < 26) -#define isupper(a) (((unsigned)(a)-'A') < 26) -#define isprint(a) (((unsigned)(a)-0x20) < 0x5f) -#define isgraph(a) (((unsigned)(a)-0x21) < 0x5e) +#define isalpha(a) (0 ? isalpha(a) : (((unsigned)(a)|32)-'a') < 26) +#define isdigit(a) (0 ? isdigit(a) : ((unsigned)(a)-'0') < 10) +#define islower(a) (0 ? islower(a) : ((unsigned)(a)-'a') < 26) +#define isupper(a) (0 ? isupper(a) : ((unsigned)(a)-'A') < 26) +#define isprint(a) (0 ? isprint(a) : ((unsigned)(a)-0x20) < 0x5f) +#define isgraph(a) (0 ? isgraph(a) : ((unsigned)(a)-0x21) < 0x5e) #define isspace(a) __isspace(a) #endif |