ciabatta/src/ctype.c

68 lines
1.1 KiB
C
Raw Normal View History

2022-06-02 23:41:48 +00:00
2022-06-02 23:57:14 +00:00
int isalnum(int c) {
2022-06-02 23:41:48 +00:00
return isalpha(c) || isdigit(c);
}
2022-06-02 23:57:14 +00:00
int isalpha(int c) {
2022-06-02 23:41:48 +00:00
return islower(c) || isupper(c);
}
2022-06-02 23:57:14 +00:00
int isblank(int c) {
2022-06-02 23:41:48 +00:00
return c == ' ' || c == '\t';
}
2022-06-02 23:57:14 +00:00
int iscntrl(int c) {
2022-08-05 08:17:24 +00:00
return IN_RANGE('\x00', c, '\x1f') || c == '\x7f';
2022-06-02 23:41:48 +00:00
}
2022-06-02 23:57:14 +00:00
int isdigit(int c) {
2022-08-05 08:17:24 +00:00
return IN_RANGE('0', c, '9');
2022-06-02 23:41:48 +00:00
}
2022-06-02 23:57:14 +00:00
int isgraph(int c) {
2022-06-02 23:41:48 +00:00
return isprint(c) && (c != ' ');
}
2022-06-02 23:57:14 +00:00
int islower(int c) {
2022-08-05 08:17:24 +00:00
return IN_RANGE('a', c, 'z');
2022-06-02 23:41:48 +00:00
}
2022-06-02 23:57:14 +00:00
int isprint(int c) {
2022-08-05 08:17:24 +00:00
return IN_RANGE(' ', c, '\x7e');
2022-06-02 23:41:48 +00:00
}
2022-06-02 23:57:14 +00:00
int ispunct(int c) {
2022-08-05 08:17:24 +00:00
return IN_RANGE('\x21', c, '\x2f')
|| IN_RANGE('\x3a', c, '\x40')
|| IN_RANGE('\x5b', c, '\x60')
|| IN_RANGE('\x7b', c, '\x7e');
2022-06-02 23:41:48 +00:00
}
2022-06-02 23:57:14 +00:00
int isspace(int c) {
2022-08-05 08:17:24 +00:00
return IN_RANGE('\x09', c, '\x0d') || c == ' ';
2022-06-02 23:41:48 +00:00
}
2022-06-02 23:57:14 +00:00
int isupper(int c) {
2022-08-05 08:17:24 +00:00
return IN_RANGE('A', c, 'Z');
2022-06-02 23:41:48 +00:00
}
2022-06-02 23:57:14 +00:00
int isxdigit(int c) {
2022-08-05 08:17:24 +00:00
return IN_RANGE('0', c, '9')
|| IN_RANGE('a', c, 'f')
|| IN_RANGE('A', c, 'F');
2022-06-02 23:41:48 +00:00
}
2022-06-02 23:57:14 +00:00
int tolower(int c) {
2022-06-02 23:41:48 +00:00
if(isupper(c)) {
return c-'A'+'a';
}
return c;
2022-06-02 23:41:48 +00:00
}
2022-06-02 23:57:14 +00:00
int toupper(int c) {
2022-06-02 23:41:48 +00:00
if(islower(c)) {
return c-'a'+'A';
}
2022-06-02 23:57:14 +00:00
return c;
2022-06-02 23:41:48 +00:00
}