ngspice.h, cm.h, cmpp.h, introduce char variants of the <ctype.h> family

This commit is contained in:
rlar 2016-03-08 21:12:38 +01:00
parent 07aba2e2ae
commit d0c5a495ca
3 changed files with 69 additions and 0 deletions

View File

@ -57,4 +57,27 @@ NON-STANDARD FEATURES
#endif
/*
* type safe variants of the <ctype.h> functions for char arguments
*/
#if !defined(isalpha_c)
inline static int char_to_int(char c) { return (unsigned char) c; }
#define isalpha_c(x) isalpha(char_to_int(x))
#define islower_c(x) islower(char_to_int(x))
#define isdigit_c(x) isdigit(char_to_int(x))
#define isalnum_c(x) isalnum(char_to_int(x))
#define isprint_c(x) isprint(char_to_int(x))
#define isblank_c(x) isblank(char_to_int(x))
#define isspace_c(x) isspace(char_to_int(x))
#define isupper_c(x) isupper(char_to_int(x))
#define tolower_c(x) ((char) tolower(char_to_int(x)))
#define toupper_c(x) ((char) toupper(char_to_int(x)))
#endif
#endif

View File

@ -334,4 +334,27 @@ ATTRIBUTE_NORETURN void controlled_exit(int status);
#endif
/*
* type safe variants of the <ctype.h> functions for char arguments
*/
#if !defined(isalpha_c)
inline static int char_to_int(char c) { return (unsigned char) c; }
#define isalpha_c(x) isalpha(char_to_int(x))
#define islower_c(x) islower(char_to_int(x))
#define isdigit_c(x) isdigit(char_to_int(x))
#define isalnum_c(x) isalnum(char_to_int(x))
#define isprint_c(x) isprint(char_to_int(x))
#define isblank_c(x) isblank(char_to_int(x))
#define isspace_c(x) isspace(char_to_int(x))
#define isupper_c(x) isupper(char_to_int(x))
#define tolower_c(x) ((char) tolower(char_to_int(x)))
#define toupper_c(x) ((char) toupper(char_to_int(x)))
#endif
#endif

View File

@ -300,3 +300,26 @@ Status_t write_ifs_c_file(const char *filename, Ifs_Table_t *ifs_table);
FILE *fopen_cmpp(const char **path_p, const char *mode);
/*
* type safe variants of the <ctype.h> functions for char arguments
*/
#if !defined(isalpha_c)
inline static int char_to_int(char c) { return (unsigned char) c; }
#define isalpha_c(x) isalpha(char_to_int(x))
#define islower_c(x) islower(char_to_int(x))
#define isdigit_c(x) isdigit(char_to_int(x))
#define isalnum_c(x) isalnum(char_to_int(x))
#define isprint_c(x) isprint(char_to_int(x))
#define isblank_c(x) isblank(char_to_int(x))
#define isspace_c(x) isspace(char_to_int(x))
#define isupper_c(x) isupper(char_to_int(x))
#define tolower_c(x) ((char) tolower(char_to_int(x)))
#define toupper_c(x) ((char) toupper(char_to_int(x)))
#endif