From e85e3b53e8e4488ad90ad9c08e410d0b524fd16c Mon Sep 17 00:00:00 2001 From: Greg Haerr Date: Sat, 16 Nov 2024 19:23:26 -0800 Subject: [PATCH] Add strupr and strlwr --- libc/include/string.h | 3 +++ libc/string/Makefile | 2 ++ libc/string/strlwr.c | 12 ++++++++++++ libc/string/strupr.c | 12 ++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 libc/string/strlwr.c create mode 100644 libc/string/strupr.c diff --git a/libc/include/string.h b/libc/include/string.h index 7d4fa0557..ee7bb2621 100644 --- a/libc/include/string.h +++ b/libc/include/string.h @@ -51,6 +51,9 @@ char *strsep(char **, const char *); size_t strcspn(const char *, const char *); size_t strspn(const char *, const char *); +char *strlwr(char *str); +char *strupr(char *str); + /* Linux silly hour */ char *strfry(char *); diff --git a/libc/string/Makefile b/libc/string/Makefile index 28a653ee1..590701e2b 100644 --- a/libc/string/Makefile +++ b/libc/string/Makefile @@ -31,6 +31,8 @@ OBJS = \ strspn.o \ strstr.o \ strtok.o \ + strlwr.o \ + strupr.o \ # end of list .PHONY: all diff --git a/libc/string/strlwr.c b/libc/string/strlwr.c new file mode 100644 index 000000000..753991518 --- /dev/null +++ b/libc/string/strlwr.c @@ -0,0 +1,12 @@ +#include +#include + +char * +strlwr(char *str) +{ + unsigned char *p; + + for (p = (unsigned char *)str; *p != '\0'; p++) + *p = tolower(*p); + return str; +} diff --git a/libc/string/strupr.c b/libc/string/strupr.c new file mode 100644 index 000000000..1ecdbe539 --- /dev/null +++ b/libc/string/strupr.c @@ -0,0 +1,12 @@ +#include +#include + +char * +strupr(char *str) +{ + unsigned char *p; + + for (p = (unsigned char *)str; *p != '\0'; p++) + *p = toupper(*p); + return str; +}