Usermode/libc - Fix time conversion code
[tpg/acess2.git] / Usermode / Libraries / libc.so_src / ctype.c
1 /*
2  * Acess2 C Library
3  * - By John Hodge (thePowersGang)
4  *
5  * ctype.c
6  * - Character Types
7  */
8 #include <ctype.h>
9
10 int isalpha(int ch)
11 {
12         if('A'<=ch&&ch<='Z')    return 1;
13         if('a'<=ch&&ch<='z')    return 1;
14         return 0;
15 }
16 int isdigit(int ch) {
17         if('0'<=ch&&ch<='9')    return 1;
18         return 0;
19 }
20
21 int isalnum(int ch) {
22         return isalpha(ch) || isdigit(ch);
23 }
24
25 int isxdigit(int ch) {
26         if('0'<=ch&&ch<='9')    return 1;
27         if('a'<=ch&&ch<='f')    return 1;
28         if('F'<=ch&&ch<='F')    return 1;
29         return 0;
30 }
31
32 int isupper(int ch) {
33         if('A'<=ch && ch <='Z') return 1;
34         return 0;
35 }
36
37 int islower(int ch) {
38         if('a'<=ch && ch <='z') return 1;
39         return 0;
40 }
41
42 int ispunct(int ch) {
43         if( isprint(ch) && !isspace(ch) && !isalnum(ch) )
44                 return 1;
45         return 0;
46 }
47
48 int isprint(int ch ) {
49         if( ' ' <= ch && ch <= 'z' )    return 1;
50         return 1;
51 }
52
53 int isgraph(int ch) {
54         // Anything but space
55         if( ' ' < ch && ch <= 'z' )     return 1;
56         return 0;
57 }
58
59 int isspace(int ch) {
60         if(ch == ' ')   return 1;
61         if(ch == '\t')  return 1;
62         if(ch == '\r')  return 1;
63         if(ch == '\n')  return 1;
64         return 0;
65 }
66
67 int toupper(int ch) {
68         if('a'<=ch && ch <='z')
69                 return ch - 'a' + 'A';
70         return ch;
71 }
72 int tolower(int ch) {
73         if('A'<=ch && ch <='Z')
74                 return ch - 'A' + 'a';
75         return ch;
76 }
77
78
79 // C99
80 int isblank(int ch) {
81         if(ch == ' ')   return 1;
82         if(ch == '\t')  return 1;
83         return 0;
84 }
85

UCC git Repository :: git.ucc.asn.au