Skip to content
This repository has been archived by the owner on Jan 11, 2020. It is now read-only.

Commit

Permalink
Implemented the <string.h> strpbrk() function.
Browse files Browse the repository at this point in the history
  • Loading branch information
artob committed Nov 23, 2014
1 parent 4ed9af8 commit 7288ca5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/string/strpbrk.c
Expand Up @@ -4,7 +4,7 @@
#include <config.h>
#endif

#include <string.h> /* for NULL, strpbrk() */
#include <string.h> /* for NULL, strchr(), strpbrk() */

/**
* @date 2014-11-23
Expand All @@ -13,7 +13,11 @@
*/
char*
strpbrk(const char* s1,
const char* s2) {
const char* const s2) {

return (void)s1, (void)s2, NULL; // TODO
while (*s1 != '\0' && strchr(s2, *s1) == NULL) {
s1++;
}

return (*s1 != '\0') ? (char*)s1 : NULL;
}
4 changes: 2 additions & 2 deletions src/string/strspn.c
Expand Up @@ -13,11 +13,11 @@
*/
size_t
strspn(const char* s1,
const char* s2) {
const char* const s2) {

size_t result = 0;

while (*s1 && strchr(s2, *s1)) {
while (*s1 != '\0' && strchr(s2, *s1) != NULL) {
s1++, result++;
}

Expand Down

0 comments on commit 7288ca5

Please sign in to comment.