formatting

This commit is contained in:
NeGate 2022-06-02 19:57:14 -04:00
parent bdb056ee0a
commit 0972e80257
1 changed files with 17 additions and 34 deletions

View File

@ -7,86 +7,69 @@
#define in_range(low, v, high) ((low <= v) && (v <= high)) #define in_range(low, v, high) ((low <= v) && (v <= high))
int isalnum(int c) int isalnum(int c) {
{
return isalpha(c) || isdigit(c); return isalpha(c) || isdigit(c);
} }
int isalpha(int c) int isalpha(int c) {
{
return islower(c) || isupper(c); return islower(c) || isupper(c);
} }
int isblank(int c) int isblank(int c) {
{
return c == ' ' || c == '\t'; return c == ' ' || c == '\t';
} }
int iscntrl(int c) int iscntrl(int c) {
{
return in_range('\x00', c, '\x1f') || c == '\x7f'; return in_range('\x00', c, '\x1f') || c == '\x7f';
} }
int isdigit(int c) int isdigit(int c) {
{
return in_range('0', c, '9'); return in_range('0', c, '9');
} }
int isgraph(int c) int isgraph(int c) {
{
return isprint(c) && (c != ' '); return isprint(c) && (c != ' ');
} }
int islower(int c) int islower(int c) {
{
return in_range('a', c, 'z'); return in_range('a', c, 'z');
} }
int isprint(int c) int isprint(int c) {
{
return in_range(' ', c, '\x7e'); return in_range(' ', c, '\x7e');
} }
int ispunct(int c) int ispunct(int c) {
{
return in_range('\x21', c, '\x2f') return in_range('\x21', c, '\x2f')
|| in_range('\x3a', c, '\x40') || in_range('\x3a', c, '\x40')
|| in_range('\x5b', c, '\x60') || in_range('\x5b', c, '\x60')
|| in_range('\x7b', c, '\x7e'); || in_range('\x7b', c, '\x7e');
} }
int isspace(int c) int isspace(int c) {
{ return in_range('\x09', c, '\x0d') || c == ' ';
return in_range('\x09', c, '\x0d')
|| c == ' ';
} }
int isupper(int c) int isupper(int c) {
{
return in_range('A', c, 'Z'); return in_range('A', c, 'Z');
} }
int isxdigit(int c) int isxdigit(int c) {
{
return in_range('0', c, '9') return in_range('0', c, '9')
|| in_range('a', c, 'f') || in_range('a', c, 'f')
|| in_range('A', c, 'F'); || in_range('A', c, 'F');
} }
int tolower(int c) int tolower(int c) {
{
if(isupper(c)) { if(isupper(c)) {
return c-'A'+'a'; return c-'A'+'a';
} }
else return c; return c;
} }
int toupper(int c) int toupper(int c) {
{
if(islower(c)) { if(islower(c)) {
return c-'a'+'A'; return c-'a'+'A';
} }
else return c; return c;
} }