summaryrefslogtreecommitdiff
path: root/src/user/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/lib')
-rw-r--r--src/user/lib/ctype.c31
-rw-r--r--src/user/lib/include/ctype.h8
-rw-r--r--src/user/lib/include/string.h3
-rw-r--r--src/user/lib/include/unistd.h1
-rw-r--r--src/user/lib/string.c5
5 files changed, 41 insertions, 7 deletions
diff --git a/src/user/lib/ctype.c b/src/user/lib/ctype.c
new file mode 100644
index 0000000..b702703
--- /dev/null
+++ b/src/user/lib/ctype.c
@@ -0,0 +1,31 @@
+#include <ctype.h>
+
+int isalpha(int c) {
+ return islower(c) || isupper(c);
+}
+
+int isalnum(int c) {
+ return isalpha(c) || isdigit(c);
+}
+
+int isdigit(int c) {
+ return '0' <= c && c <= '9';
+}
+
+int islower(int c) {
+ return 'a' <= c && c <= 'z';
+}
+
+int isspace(int c) {
+ return c == ' '
+ || c == '\f'
+ || c == '\n'
+ || c == '\r'
+ || c == '\t'
+ || c == '\v';
+}
+
+int isupper(int c) {
+ return 'A' <= c && c <= 'Z';
+}
+
diff --git a/src/user/lib/include/ctype.h b/src/user/lib/include/ctype.h
new file mode 100644
index 0000000..4b15b1d
--- /dev/null
+++ b/src/user/lib/include/ctype.h
@@ -0,0 +1,8 @@
+#pragma once
+
+int isalnum(int c);
+int isalpha(int c);
+int isdigit(int c);
+int islower(int c);
+int isspace(int c);
+int isupper(int c);
diff --git a/src/user/lib/include/string.h b/src/user/lib/include/string.h
index 9e08ae5..eda4e48 100644
--- a/src/user/lib/include/string.h
+++ b/src/user/lib/include/string.h
@@ -1,8 +1,5 @@
#pragma once
#include <shared/mem.h>
-int isspace(char c);
-
long strtol(const char *restrict s, char **restrict end, int base);
-
char *strchr(const char *s, int c);
diff --git a/src/user/lib/include/unistd.h b/src/user/lib/include/unistd.h
index 2b75a13..9b368dc 100644
--- a/src/user/lib/include/unistd.h
+++ b/src/user/lib/include/unistd.h
@@ -1,5 +1,6 @@
#pragma once
#include <camellia/types.h> // TODO only needed because of handle_t
+#include <user/lib/vendor/getopt/getopt.h>
int fork(void);
int close(handle_t h);
diff --git a/src/user/lib/string.c b/src/user/lib/string.c
index a6ac75b..9c347d0 100644
--- a/src/user/lib/string.c
+++ b/src/user/lib/string.c
@@ -1,10 +1,7 @@
+#include <ctype.h>
#include <errno.h>
#include <string.h>
-int isspace(char c) {
- return c == ' ' || c == '\t' || c == '\n';
-}
-
long strtol(const char *restrict s, char **restrict end, int base) {
long res = 0;
int sign = 1;