1
0

ctypef(3)

This commit is contained in:
dtb 2022-07-11 19:38:25 -04:00
parent 68ce0ae227
commit d231f7f234
4 changed files with 159 additions and 0 deletions

55
include/ctypef.c Normal file
View File

@ -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'); }

75
include/ctypef.h Normal file
View File

@ -0,0 +1,75 @@
#ifndef _CTYPEF_H
#define _CTYPEF_H
#include <ctype.h>
# 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

29
man/ctypef.3 Normal file
View File

@ -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)