Skip to content

Commit

Permalink
Add strupr and strlwr
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaerr committed Nov 17, 2024
1 parent 72e0872 commit e85e3b5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libc/include/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);

Expand Down
2 changes: 2 additions & 0 deletions libc/string/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ OBJS = \
strspn.o \
strstr.o \
strtok.o \
strlwr.o \
strupr.o \
# end of list

.PHONY: all
Expand Down
12 changes: 12 additions & 0 deletions libc/string/strlwr.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <string.h>
#include <ctype.h>

char *
strlwr(char *str)
{
unsigned char *p;

for (p = (unsigned char *)str; *p != '\0'; p++)
*p = tolower(*p);
return str;
}
12 changes: 12 additions & 0 deletions libc/string/strupr.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <string.h>
#include <ctype.h>

char *
strupr(char *str)
{
unsigned char *p;

for (p = (unsigned char *)str; *p != '\0'; p++)
*p = toupper(*p);
return str;
}

0 comments on commit e85e3b5

Please sign in to comment.