summaryrefslogtreecommitdiffstats
path: root/pintos-progos/lib/ctype.h
diff options
context:
space:
mode:
Diffstat (limited to 'pintos-progos/lib/ctype.h')
-rw-r--r--pintos-progos/lib/ctype.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/pintos-progos/lib/ctype.h b/pintos-progos/lib/ctype.h
new file mode 100644
index 0000000..9096aca
--- /dev/null
+++ b/pintos-progos/lib/ctype.h
@@ -0,0 +1,28 @@
1#ifndef __LIB_CTYPE_H
2#define __LIB_CTYPE_H
3
4static inline int islower (int c) { return c >= 'a' && c <= 'z'; }
5static inline int isupper (int c) { return c >= 'A' && c <= 'Z'; }
6static inline int isalpha (int c) { return islower (c) || isupper (c); }
7static inline int isdigit (int c) { return c >= '0' && c <= '9'; }
8static inline int isalnum (int c) { return isalpha (c) || isdigit (c); }
9static inline int isxdigit (int c) {
10 return isdigit (c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
11}
12static inline int isspace (int c) {
13 return (c == ' ' || c == '\f' || c == '\n'
14 || c == '\r' || c == '\t' || c == '\v');
15}
16static inline int isblank (int c) { return c == ' ' || c == '\t'; }
17static inline int isgraph (int c) { return c > 32 && c < 127; }
18static inline int isprint (int c) { return c >= 32 && c < 127; }
19static inline int iscntrl (int c) { return (c >= 0 && c < 32) || c == 127; }
20static inline int isascii (int c) { return c >= 0 && c < 128; }
21static inline int ispunct (int c) {
22 return isprint (c) && !isalnum (c) && !isspace (c);
23}
24
25static inline int tolower (int c) { return isupper (c) ? c - 'A' + 'a' : c; }
26static inline int toupper (int c) { return islower (c) ? c - 'a' + 'A' : c; }
27
28#endif /* lib/ctype.h */