summaryrefslogtreecommitdiff
path: root/src/user/lib/ctype.c
diff options
context:
space:
mode:
authordzwdz2022-08-29 13:57:47 +0200
committerdzwdz2022-08-29 13:58:02 +0200
commit4ae57a7fb13e68c5e6f1c1246a867555dbd986db (patch)
tree3bee7f7eee21e9f2ed3b9f07dd1671a1c230cf66 /src/user/lib/ctype.c
parentedb7fc07bf93e4a1883cccf45ad7a4b2cbf390d9 (diff)
user/lua: implement the bare minimum for it to link and "run"
Diffstat (limited to 'src/user/lib/ctype.c')
-rw-r--r--src/user/lib/ctype.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/user/lib/ctype.c b/src/user/lib/ctype.c
index 7d3a707..fa49a07 100644
--- a/src/user/lib/ctype.c
+++ b/src/user/lib/ctype.c
@@ -1,21 +1,40 @@
#include <ctype.h>
+int isalnum(int c) {
+ return isalpha(c) || isdigit(c);
+}
+
int isalpha(int c) {
return islower(c) || isupper(c);
}
-int isalnum(int c) {
- return isalpha(c) || isdigit(c);
+int iscntrl(int c) {
+ return c <= 0x1f || c == 0x7f;
}
int isdigit(int c) {
return '0' <= c && c <= '9';
}
+int isgraph(int c) {
+ return isalpha(c) || isdigit(c) || ispunct(c);
+}
+
int islower(int c) {
return 'a' <= c && c <= 'z';
}
+int isprint(int c) {
+ return isgraph(c) || c == ' ';
+}
+
+int ispunct(int c) {
+ return ('!' <= c && c <= '/')
+ || (':' <= c && c <= '@')
+ || ('[' <= c && c <= '`')
+ || ('{' <= c && c <= '~');
+}
+
int isspace(int c) {
return c == ' '
|| c == '\f'
@@ -29,6 +48,12 @@ int isupper(int c) {
return 'A' <= c && c <= 'Z';
}
+int isxdigit(int c) {
+ return ('0' <= c && c <= '9')
+ || ('A' <= c && c <= 'F')
+ || ('a' <= c && c <= 'f');
+}
+
int tolower(int c) {
if (isupper(c)) return c - 'A' + 'a';
return c;