summaryrefslogtreecommitdiff
path: root/src/string/strpbrk.c
blob: 0b88b99971e2a87e113d1c36cf89a52c0b04a3e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <string.h>
#include "nonstd/assert.h"

/** count matching characters **/
char * strpbrk(const char *s1, const char *s2)
{
	size_t i;

	ASSERT_NONNULL(s1);
	ASSERT_NONNULL(s2);

	for (i = 0; i < strlen (s1); i++) {
		if (strchr(s2, s1[i]) != NULL) {
			return (char*)s1 + i;
		}
	}

	return NULL;
}

/***
locates the first occurence in ARGUMENT(s1) of any character in ARGUMENT(s2).
***/
/*
	RETURN_FAILURE(CONSTANT(NULL));
	RETURN_SUCCESS(a pointer to the located character);
STDC(1)
*/