string: add and test strpbrk (DONE)

This commit is contained in:
Lephenixnoir 2021-05-23 18:11:12 +02:00
parent d105b1d60a
commit 8ffc104798
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
3 changed files with 12 additions and 1 deletions

View File

@ -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)

2
STATUS
View File

@ -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

10
src/libc/string/strpbrk.c Normal file
View File

@ -0,0 +1,10 @@
#include <string.h>
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;
}