diff --git a/CMakeLists.txt b/CMakeLists.txt index 585758f..6b792ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,6 +150,7 @@ set(SOURCES src/libc/string/strncpy.c src/libc/string/strndup.c src/libc/string/strnlen.c + src/libc/string/strpbrk.c src/libc/string/strrchr.c src/libc/string/strspn.c src/libc/string/strxfrm.c) diff --git a/STATUS b/STATUS index 6cb91f8..6375e71 100644 --- a/STATUS +++ b/STATUS @@ -123,7 +123,7 @@ DONE: Function/symbol/macro is defined, builds, links, and is tested 7.21.5.1 memchr: DONE 7.21.5.2 strchr: DONE 7.21.5.3 strcspn: DONE -! 7.21.5.4 strpbrk: TODO + 7.21.5.4 strpbrk: DONE 7.21.5.5 strrchr: DONE 7.21.5.6 strspn: DONE ! 7.21.5.7 strstr: TODO diff --git a/src/libc/string/strpbrk.c b/src/libc/string/strpbrk.c new file mode 100644 index 0000000..97bbac1 --- /dev/null +++ b/src/libc/string/strpbrk.c @@ -0,0 +1,10 @@ +#include + +char *strpbrk(char const *str, char const *accept) +{ + for(size_t i = 0; str[i]; i++) { + if(strchr(accept, str[i])) return (char *)&str[i]; + } + + return NULL; +}