-
Notifications
You must be signed in to change notification settings - Fork 16
/
ctype.c
62 lines (50 loc) · 845 Bytes
/
ctype.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <ctype.h>
int isascii(int c)
{
return (unsigned) c < 128u;
}
int isblank(int c)
{
return c == ' ' || c == '\t';
}
int isalpha(int c)
{
return (unsigned) ((c | 0x20) - 'a') < 26u;
}
int isdigit(int c)
{
return (unsigned) (c - '0') < 10u;
}
int isalnum(int c)
{
return (unsigned) ((c | 0x20) - 'a') < 26u ||
(unsigned) (c - '0') < 10u;
}
int isspace(int c)
{
return (unsigned) (c - 9) < 5u || c == ' ';
}
int isupper(int c)
{
return (unsigned) (c - 'A') < 26u;
}
int islower(int c)
{
return (unsigned) (c - 'a') < 26u;
}
int tolower(int c)
{
return (unsigned) (c - 'A') < 26u ? c + ('a' - 'A') : c;
}
int toupper(int c)
{
return (unsigned) (c - 'a') < 26u ? c + ('A' - 'a') : c;
}
int isprint(int c)
{
return (c & 0x7f) >= 32 && c < 127;
}
int ispunct(int c)
{
return isprint(c) && !isalnum(c) && !isspace(c);
}