diff options
-rw-r--r-- | src/user/app/init/driver/initctl.c | 1 | ||||
-rw-r--r-- | src/user/app/login/login.c | 1 | ||||
-rw-r--r-- | src/user/app/shell/parser.c | 1 | ||||
-rw-r--r-- | src/user/lib/ctype.c | 31 | ||||
-rw-r--r-- | src/user/lib/include/ctype.h | 8 | ||||
-rw-r--r-- | src/user/lib/include/string.h | 3 | ||||
-rw-r--r-- | src/user/lib/include/unistd.h | 1 | ||||
-rw-r--r-- | src/user/lib/string.c | 5 |
8 files changed, 44 insertions, 7 deletions
diff --git a/src/user/app/init/driver/initctl.c b/src/user/app/init/driver/initctl.c index b8fbb9b..c31e8fb 100644 --- a/src/user/app/init/driver/initctl.c +++ b/src/user/app/init/driver/initctl.c @@ -1,5 +1,6 @@ #include "driver.h" #include <camellia/syscalls.h> +#include <ctype.h> #include <errno.h> #include <string.h> #include <unistd.h> diff --git a/src/user/app/login/login.c b/src/user/app/login/login.c index c1fab3f..241bcfe 100644 --- a/src/user/app/login/login.c +++ b/src/user/app/login/login.c @@ -1,5 +1,6 @@ #include <camellia/flags.h> #include <camellia/syscalls.h> +#include <ctype.h> #include <errno.h> #include <stdbool.h> #include <stdio.h> diff --git a/src/user/app/shell/parser.c b/src/user/app/shell/parser.c index 072c720..ad09348 100644 --- a/src/user/app/shell/parser.c +++ b/src/user/app/shell/parser.c @@ -1,4 +1,5 @@ #include "shell.h" +#include <ctype.h> #include <stdbool.h> #include <string.h> 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; |