diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-06-21 10:23:17 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-06-21 10:23:17 -0700 |
commit | bda7a6e3715b270ebb0854b3cef667976d241d96 (patch) | |
tree | 86e645d4e025b1dbf0169d0a4ce1c6ec602a15d5 /nasmlib.h | |
parent | 86877b294aabac1059d32611c8dce65910243454 (diff) | |
download | nasm-bda7a6e3715b270ebb0854b3cef667976d241d96.tar.gz nasm-bda7a6e3715b270ebb0854b3cef667976d241d96.tar.bz2 nasm-bda7a6e3715b270ebb0854b3cef667976d241d96.zip |
ctype.h: wrapper ctype functions with a cast to (unsigned char)
ctype functions take an *int*, which the user is expected to have
taken the input character from getc() and friends, or taken a
character and cast it to (unsigned char).
We don't care about EOF (-1), so use macros that cast to (unsigned
char) for us.
Diffstat (limited to 'nasmlib.h')
-rw-r--r-- | nasmlib.h | 24 |
1 files changed, 15 insertions, 9 deletions
@@ -19,6 +19,21 @@ #endif /* + * tolower table -- avoids a function call on some platforms. + * NOTE: unlike the tolower() function in ctype, EOF is *NOT* + * a permitted value, for obvious reasons. + */ +void tolower_init(void); +extern 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_isalnum(x) isalnum((unsigned char)(x)) +#define nasm_isdigit(x) isdigit((unsigned char)(x)) + +/* * If this is defined, the wrappers around malloc et al will * transform into logging variants, which will cause NASM to create * a file called `malloc.log' when run, and spew details of all its @@ -176,15 +191,6 @@ void standard_extension(char *inname, char *outname, char *extension, #define elements(x) ( sizeof(x) / sizeof(*(x)) ) /* - * tolower table -- avoids a function call on some platforms. - * NOTE: unlike the tolower() function in ctype, EOF is *NOT* - * a permitted value, for obvious reasons. - */ -void tolower_init(void); -extern unsigned char nasm_tolower_tab[256]; -#define nasm_tolower(x) nasm_tolower_tab[(unsigned char)(x)] - -/* * some handy macros that will probably be of use in more than one * output format: convert integers into little-endian byte packed * format in memory |