diff --git a/photon/libc/include/string.h b/photon/libc/include/string.h index 5d7822e..d0d58f3 100644 --- a/photon/libc/include/string.h +++ b/photon/libc/include/string.h @@ -20,6 +20,7 @@ extern char *strcpy(char *dest, const char *src); extern char *strncpy(char *dest, const char *src, size_t sz); extern char *strrchr(const char *s, int c); +extern size_t strcspn(const char *str1, const char *str2); extern char *strdup(const char *s); diff --git a/photon/libc/string/strcspn.c b/photon/libc/string/strcspn.c new file mode 100644 index 0000000..9220d63 --- /dev/null +++ b/photon/libc/string/strcspn.c @@ -0,0 +1,15 @@ +#include + +size_t strcspn(const char *str1, const char *str2) +{ + size_t i; + for (i = 0; str1[i]; i++) { + for (size_t ii = 0; str2[ii]; ii++) { + if (str1[i] == str2[ii]) { + return i; + } + } + } + + return i; +}