diff --git a/lib/banned.h b/include/banned.h similarity index 100% rename from lib/banned.h rename to include/banned.h diff --git a/include/ctypef.c b/include/ctypef.c new file mode 100644 index 0000000..7cd10fc --- /dev/null +++ b/include/ctypef.c @@ -0,0 +1,55 @@ +int +_isblank(int c){ + return c == '\t' + || c == ' '; +} + +int +_isspace(int c){ + return isblank(c) + || c == '\n' + || c == '\v' + || c == '\f' + || c == '\r'; +} + +int +_isgraph(int c){ return c >= '!' && c <= '~'; } + +int +_isprint(int c){ return c == ' ' || isgraph(c); } + +int +_iscntrl(int c){ return !isprint(c); } + +int +_isdigit(int c){ return c >= '0' && c <= '9'; } + +int +_islower(int c){ return c >= 'a' && c <= 'z'; } + +int +_isupper(int c){ return c >= 'A' && c <= 'Z'; } + +int +_isxdigit(int c){ + return + isdigit(c) + || (c >= 'a' && c <= 'f') + || (c >= 'A' && c <= 'F'); +} + +int +_isalpha(int c){ return islower(c) || isupper(c); } + +int +_isalnum(int c){ return isalpha(c) || isdigit(c) }; + +int +_ispunct(int c){ return c != ' ' && !isalnum(c) }; + +int +_tolower(int c){ return c -= isupper(c) * ('A' - 'a'); } + +int +_toupper(int c){ return c += islower(c) * ('A' - 'a'); } diff --git a/include/ctypef.h b/include/ctypef.h new file mode 100644 index 0000000..33ba53f --- /dev/null +++ b/include/ctypef.h @@ -0,0 +1,75 @@ +#ifndef _CTYPEF_H +#define _CTYPEF_H +#include + +# ifdef isalnum +# undef isalnum +# define isalnum _isalnum +# endif + +# ifdef isalpha +# undef isalpha +# define isalpha _isalpha +# endif + +# ifdef isblank +# undef isblank +# define isblank _isblank +# endif + +# ifdef iscntrl +# undef iscntrl +# define iscntrl _iscntrl +# endif + +# ifdef isdigit +# undef isdigit +# define isdigit _isdigit +# endif + +# ifdef isxdigit +# undef isxdigit +# define isxdigit _isxdigit +# endif + +# ifdef isgraph +# undef isgraph +# define isgraph _isgraph + +# ifdef islower +# undef islower +# define islower _islower +# endif + +# ifdef isprint +# undef isprint +# define isprint _isprint +# endif + +# ifdef ispunct +# undef ispunct +# define ispunct _ispunct +# endif + +# ifdef isspace +# undef isspace +# define isspace _isspace +# endif + +# ifdef isupper +# undef isupper +# define isupper _isupper +# endif + +# ifdef tolower +# undef tolower +# define tolower _tolower +# endif + +# ifdef toupper +# undef toupper +# define toupper _toupper +# endif + +#include "ctypef.c" +#endif diff --git a/man/ctypef.3 b/man/ctypef.3 new file mode 100644 index 0000000..06f1ee9 --- /dev/null +++ b/man/ctypef.3 @@ -0,0 +1,29 @@ +.TH CTYPEF 3 + +.SH NAME +ctypef \- ctype, guaranteed to be functions + +.SH SYNOPSIS + +See ctype(3). + +.SH DESCRIPTION + +In some ancient environments ctype.h defines macros rather than functions for its methods. +ctypef.h replaces any macros from ctype.h with functions. + +.SH STANDARDS + +Redundant on standards conformant systems. + +.SH COPYRIGHT + +Public domain. + +.SH CAVEATS + +See ctype(3). + +.SH SEE ALSO + +ctype(3), ascii(7)