diff options
Diffstat (limited to 'userland/libc/ctype')
-rw-r--r-- | userland/libc/ctype/isalnum.c | 6 | ||||
-rw-r--r-- | userland/libc/ctype/isalpha.c | 4 | ||||
-rw-r--r-- | userland/libc/ctype/isascii.c | 4 | ||||
-rw-r--r-- | userland/libc/ctype/isdigit.c | 6 | ||||
-rw-r--r-- | userland/libc/ctype/isprint.c | 3 | ||||
-rw-r--r-- | userland/libc/ctype/ispunct.c | 6 | ||||
-rw-r--r-- | userland/libc/ctype/isxdigit.c | 6 | ||||
-rw-r--r-- | userland/libc/ctype/tolower.c | 7 | ||||
-rw-r--r-- | userland/libc/ctype/toupper.c | 7 |
9 files changed, 49 insertions, 0 deletions
diff --git a/userland/libc/ctype/isalnum.c b/userland/libc/ctype/isalnum.c new file mode 100644 index 0000000..870728d --- /dev/null +++ b/userland/libc/ctype/isalnum.c @@ -0,0 +1,6 @@ +#include <ctype.h> + +// This is probably the most useless libc function I have seen so far. +int isalnum(int c) { + return isalpha(c) || isdigit(c); +} diff --git a/userland/libc/ctype/isalpha.c b/userland/libc/ctype/isalpha.c new file mode 100644 index 0000000..130f493 --- /dev/null +++ b/userland/libc/ctype/isalpha.c @@ -0,0 +1,4 @@ +#include <ctype.h> + +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/isalpha.html +int isalpha(int c) { return (('A' <= toupper(c)) && ('Z' >= toupper(c))); } diff --git a/userland/libc/ctype/isascii.c b/userland/libc/ctype/isascii.c new file mode 100644 index 0000000..660c8bb --- /dev/null +++ b/userland/libc/ctype/isascii.c @@ -0,0 +1,4 @@ +#include <ctype.h> + +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/isascii.html +int isascii(int c) { return (c < 128); } diff --git a/userland/libc/ctype/isdigit.c b/userland/libc/ctype/isdigit.c new file mode 100644 index 0000000..790b9f1 --- /dev/null +++ b/userland/libc/ctype/isdigit.c @@ -0,0 +1,6 @@ +#include <ctype.h> + +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/isdigit.html +int isdigit(int c) { + return ('0' <= c && c <= '9'); +} diff --git a/userland/libc/ctype/isprint.c b/userland/libc/ctype/isprint.c new file mode 100644 index 0000000..e6a3d0e --- /dev/null +++ b/userland/libc/ctype/isprint.c @@ -0,0 +1,3 @@ +#include <ctype.h> + +int isprint(int c) { return c > 0x20 && 0x7F != c; } diff --git a/userland/libc/ctype/ispunct.c b/userland/libc/ctype/ispunct.c new file mode 100644 index 0000000..18dc7d8 --- /dev/null +++ b/userland/libc/ctype/ispunct.c @@ -0,0 +1,6 @@ +#include <ctype.h> + +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/ispunct.html +int ispunct(int c) { + return (c == '.'); +} diff --git a/userland/libc/ctype/isxdigit.c b/userland/libc/ctype/isxdigit.c new file mode 100644 index 0000000..c843725 --- /dev/null +++ b/userland/libc/ctype/isxdigit.c @@ -0,0 +1,6 @@ +#include <ctype.h> + +// https://pubs.opengroup.org/onlinepubs/9699919799/functions/isxdigit.html +int isxdigit(int c) { + return isdigit(c) || ('A' >= toupper(c) && 'Z' <= toupper(c)); +} diff --git a/userland/libc/ctype/tolower.c b/userland/libc/ctype/tolower.c new file mode 100644 index 0000000..f1bb163 --- /dev/null +++ b/userland/libc/ctype/tolower.c @@ -0,0 +1,7 @@ +#include <ctype.h> + +int tolower(int c) { + if (c >= 'A' && c <= 'Z') + return c - 'A' + 'a'; + return c; +} diff --git a/userland/libc/ctype/toupper.c b/userland/libc/ctype/toupper.c new file mode 100644 index 0000000..0f33886 --- /dev/null +++ b/userland/libc/ctype/toupper.c @@ -0,0 +1,7 @@ +#include <ctype.h> + +int toupper(int c) { + if (c >= 'a' && c <= 'z') + return c - 'a' + 'A'; + return c; +} |