diff options
author | H. Peter Anvin <hpa@zytor.com> | 2016-03-03 17:11:28 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2016-03-03 17:18:38 -0800 |
commit | 3a27b17c7fea3845c63864e11008edf8cebd7e17 (patch) | |
tree | 4e8ab085247347eddf76fe242b76198d8e6332c1 /nasmlib.h | |
parent | a9a1b5c318e7bcb7680483c51933c6f3d6c69cd9 (diff) | |
download | nasm-3a27b17c7fea3845c63864e11008edf8cebd7e17.tar.gz |
Replace external dependencies on <ctype.h> with an internal tablectype
Don't rely on the platform <ctype.h>; hopefully this can avoid
problems.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'nasmlib.h')
-rw-r--r-- | nasmlib.h | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -48,21 +48,22 @@ #endif /* - * tolower table -- avoids a function call on some platforms. - * NOTE: unlike the tolower() function in ctype, EOF is *NOT* + * tolower/toupper tables -- avoids a function call on some platforms. + * NOTE: unlike the to*() and is*() functions in ctype.h, EOF is *NOT* * a permitted value, for obvious reasons. */ -void tolower_init(void); -extern unsigned char nasm_tolower_tab[256]; +extern const unsigned char nasm_tolower_tab[256]; #define nasm_tolower(x) nasm_tolower_tab[(unsigned char)(x)] -/* Wrappers around <ctype.h> functions */ -/* These are only valid for values that cannot include EOF */ -#define nasm_isspace(x) isspace((unsigned char)(x)) -#define nasm_isalpha(x) isalpha((unsigned char)(x)) -#define nasm_isdigit(x) isdigit((unsigned char)(x)) -#define nasm_isalnum(x) isalnum((unsigned char)(x)) -#define nasm_isxdigit(x) isxdigit((unsigned char)(x)) +extern const unsigned char nasm_toupper_tab[256]; +#define nasm_toupper(x) nasm_toupper_tab[(unsigned char)(x)] + +extern const unsigned char nasm_ctype_tab[256]; +#define nasm_isspace(x) (!!(nasm_ctype_tab[(unsigned char)(x)] & 0x01)) +#define nasm_isalpha(x) (!!(nasm_ctype_tab[(unsigned char)(x)] & 0x02)) +#define nasm_isdigit(x) (!!(nasm_ctype_tab[(unsigned char)(x)] & 0x04)) +#define nasm_isalnum(x) (!!(nasm_ctype_tab[(unsigned char)(x)] & 0x06)) +#define nasm_isxdigit(x) (!!(nasm_ctype_tab[(unsigned char)(x)] & 0x08)) /* * ------------------------- |