diff options
author | Anton Kling <anton@kling.gg> | 2024-04-21 18:39:36 +0200 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2024-04-21 19:29:50 +0200 |
commit | 821eb5ff9ed60d4b1c7a50ebf406f22bc0da9bd4 (patch) | |
tree | 4562261e5bd41e215c277998f20d736d28a33430 /userland | |
parent | a8959b3da1b160c84da6ead6f12188b1824d76e6 (diff) |
LibC: Add different isX() functions
Diffstat (limited to 'userland')
-rw-r--r-- | userland/libc/Makefile | 2 | ||||
-rw-r--r-- | userland/libc/ctype/isblank.c | 5 | ||||
-rw-r--r-- | userland/libc/ctype/iscntrl.c | 6 | ||||
-rw-r--r-- | userland/libc/ctype/isgraph.c | 5 | ||||
-rw-r--r-- | userland/libc/ctype/islower.c | 5 | ||||
-rw-r--r-- | userland/libc/ctype/isupper.c | 5 | ||||
-rw-r--r-- | userland/libc/include/ctype.h | 5 |
7 files changed, 32 insertions, 1 deletions
diff --git a/userland/libc/Makefile b/userland/libc/Makefile index 17135d6..94cf28f 100644 --- a/userland/libc/Makefile +++ b/userland/libc/Makefile @@ -2,7 +2,7 @@ CC="i686-sb-gcc" AR="i686-sb-ar" AS="i686-sb-as" CFLAGS = -ggdb -ffreestanding -O2 -Wall -Wextra -pedantic -Werror -Wimplicit-fallthrough -I./include/ -static -I../../include/ -Wno-int-conversion -Wno-unused-parameter -OBJ=crt0.o libc.o malloc/malloc.o pty.o sys/mman/mmap.o sys/mman/munmap.o memset.o assert.o stdio/snprintf.o stdio/vfprintf.o string/memcpy.o string/memcmp.o string/strcmp.o ubsan.o string/strcpy.o isspace.o stdio/puts.o stdio/putchar.o dirent/opendir.o dirent/readdir.o dirent/closedir.o unistd/getopt.o dirent/scandir.o dirent/alphasort.o stdio/printf.o stdio/vdprintf.o stdio/vprintf.o stdio/dprintf.o stdio/vprintf.o string/strlen.o string/strnlen.o stdio/stdin.o stdio/getchar.o stdio/fgetc.o arpa/inet/htons.o arpa/inet/htonl.o stdio/fread.o stdio/fwrite.o stdio/fopen.o stdio/fclose.o stdio/fseek.o ctype/isascii.o stdio/fprintf.o stdlib/atoi.o stdlib/strtol.o ctype/toupper.o ctype/tolower.o string/strcat.o string/strchr.o string/sscanf.o sys/stat/stat.o stdlib/getenv.o string/strrchr.o stdio/ftell.o stdio/tmpfile.o stdio/fgets.o stdio/feof.o stdio/fscanf.o stdio/ungetc.o string/strncmp.o stdio/fputc.o string/strncpy.o stdio/remove.o stdio/ferror.o stdio/fputs.o stdlib/rand.o stdlib/srand.o unistd/getpid.o stdlib/strtoul.o stdio/fflush.o stdlib/abort.o string/strcspn.o time/localtime.o time/time.o time/clock_gettime.o time/gmtime.o time/strftime.o string/strpbrk.o ctype/isdigit.o ctype/isalpha.o ctype/isxdigit.o ctype/ispunct.o stdio/setvbuf.o stdio/fileno.o stdio/putc.o stdio/sprintf.o stdlib/abs.o string/strspn.o stdlib/qsort.o string/memmove.o setjmp/longjmp.o setjmp/setjmp.o libgen/basename.o string/strdup.o string/strndup.o string/strlcpy.o stdlib/atexit.o stdio/open_memstream.o libgen/dirname.o unistd/unlink.o string/strstr.o string/strcasecmp.o string/strncasecmp.o stdlib/mkstemp.o string/strtok.o unistd/execvp.o unistd/_exit.o ctype/isalnum.o time/ctime_r.o stdlib/strtold.o sys/time/gettimeofday.o stdio/fgetpos.o stdio/fsetpos.o ctype/isprint.o stdlib/system.o stdio/tmpnam.o unistd/msleep.o stdlib/atof.o stdlib/strtod.o stdio/rename.o sys/stat/mkdir.o unistd/uptime.o unistd/ftruncate.o sys/socket/recvfrom.o sys/socket/sendto.o signal/kill.o signal/sigaction.o unistd/chdir.o unistd/getcwd.o stdio/getdelim.o stdio/getline.o unistd/isatty.o sys/socket/listen.o stdlib/realpath.o systemcall.o sys/random/randomfill.o fcntl/open.o unistd/write.o unistd/pwrite.o fcntl/open_process.o tb/sb.o tb/sv.o string/memchr.o stdlib/atol.o stdlib/atoll.o stdlib/strtoll.o sys/stat/fstat.o unistd/lseek.o +OBJ=crt0.o libc.o malloc/malloc.o pty.o sys/mman/mmap.o sys/mman/munmap.o memset.o assert.o stdio/snprintf.o stdio/vfprintf.o string/memcpy.o string/memcmp.o string/strcmp.o ubsan.o string/strcpy.o isspace.o stdio/puts.o stdio/putchar.o dirent/opendir.o dirent/readdir.o dirent/closedir.o unistd/getopt.o dirent/scandir.o dirent/alphasort.o stdio/printf.o stdio/vdprintf.o stdio/vprintf.o stdio/dprintf.o stdio/vprintf.o string/strlen.o string/strnlen.o stdio/stdin.o stdio/getchar.o stdio/fgetc.o arpa/inet/htons.o arpa/inet/htonl.o stdio/fread.o stdio/fwrite.o stdio/fopen.o stdio/fclose.o stdio/fseek.o ctype/isascii.o stdio/fprintf.o stdlib/atoi.o stdlib/strtol.o ctype/toupper.o ctype/tolower.o string/strcat.o string/strchr.o string/sscanf.o sys/stat/stat.o stdlib/getenv.o string/strrchr.o stdio/ftell.o stdio/tmpfile.o stdio/fgets.o stdio/feof.o stdio/fscanf.o stdio/ungetc.o string/strncmp.o stdio/fputc.o string/strncpy.o stdio/remove.o stdio/ferror.o stdio/fputs.o stdlib/rand.o stdlib/srand.o unistd/getpid.o stdlib/strtoul.o stdio/fflush.o stdlib/abort.o string/strcspn.o time/localtime.o time/time.o time/clock_gettime.o time/gmtime.o time/strftime.o string/strpbrk.o ctype/isdigit.o ctype/isalpha.o ctype/isxdigit.o ctype/ispunct.o stdio/setvbuf.o stdio/fileno.o stdio/putc.o stdio/sprintf.o stdlib/abs.o string/strspn.o stdlib/qsort.o string/memmove.o setjmp/longjmp.o setjmp/setjmp.o libgen/basename.o string/strdup.o string/strndup.o string/strlcpy.o stdlib/atexit.o stdio/open_memstream.o libgen/dirname.o unistd/unlink.o string/strstr.o string/strcasecmp.o string/strncasecmp.o stdlib/mkstemp.o string/strtok.o unistd/execvp.o unistd/_exit.o ctype/isalnum.o time/ctime_r.o stdlib/strtold.o sys/time/gettimeofday.o stdio/fgetpos.o stdio/fsetpos.o ctype/isprint.o stdlib/system.o stdio/tmpnam.o unistd/msleep.o stdlib/atof.o stdlib/strtod.o stdio/rename.o sys/stat/mkdir.o unistd/uptime.o unistd/ftruncate.o sys/socket/recvfrom.o sys/socket/sendto.o signal/kill.o signal/sigaction.o unistd/chdir.o unistd/getcwd.o stdio/getdelim.o stdio/getline.o unistd/isatty.o sys/socket/listen.o stdlib/realpath.o systemcall.o sys/random/randomfill.o fcntl/open.o unistd/write.o unistd/pwrite.o fcntl/open_process.o tb/sb.o tb/sv.o string/memchr.o stdlib/atol.o stdlib/atoll.o stdlib/strtoll.o sys/stat/fstat.o unistd/lseek.o ctype/isupper.o ctype/islower.o ctype/isblank.o ctype/isgraph.o ctype/iscntrl.o all: libc.a %.o: %.c diff --git a/userland/libc/ctype/isblank.c b/userland/libc/ctype/isblank.c new file mode 100644 index 0000000..488fa88 --- /dev/null +++ b/userland/libc/ctype/isblank.c @@ -0,0 +1,5 @@ +#include <ctype.h> + +int isblank(int c) { + return (c == ' ' || c == '\t'); +} diff --git a/userland/libc/ctype/iscntrl.c b/userland/libc/ctype/iscntrl.c new file mode 100644 index 0000000..92ed7f0 --- /dev/null +++ b/userland/libc/ctype/iscntrl.c @@ -0,0 +1,6 @@ +#include <ctype.h> + +int iscntrl(int c) +{ + return (unsigned)c < 0x20 || c == 0x7f; +} diff --git a/userland/libc/ctype/isgraph.c b/userland/libc/ctype/isgraph.c new file mode 100644 index 0000000..28bf695 --- /dev/null +++ b/userland/libc/ctype/isgraph.c @@ -0,0 +1,5 @@ +#include <ctype.h> + +int isgraph(int c) { + return (unsigned)c - 0x21 < 0x5e; +} diff --git a/userland/libc/ctype/islower.c b/userland/libc/ctype/islower.c new file mode 100644 index 0000000..d3bed82 --- /dev/null +++ b/userland/libc/ctype/islower.c @@ -0,0 +1,5 @@ +#include <ctype.h> + +int islower(int c) { + return (c >= 'a' && c <= 'z'); +} diff --git a/userland/libc/ctype/isupper.c b/userland/libc/ctype/isupper.c new file mode 100644 index 0000000..9df4fb5 --- /dev/null +++ b/userland/libc/ctype/isupper.c @@ -0,0 +1,5 @@ +#include <ctype.h> + +int isupper(int c) { + return (c >= 'A' && c <= 'Z'); +} diff --git a/userland/libc/include/ctype.h b/userland/libc/include/ctype.h index 7c8c311..c04f96a 100644 --- a/userland/libc/include/ctype.h +++ b/userland/libc/include/ctype.h @@ -11,4 +11,9 @@ int isxdigit(int c); int ispunct(int c); int isalnum(int c); int isprint(int c); +int isupper(int c); +int islower(int c); +int isgraph(int c); +int isblank(int c); +int iscntrl(int c); #endif |