summaryrefslogtreecommitdiff
path: root/src/string/strpbrk.c
blob: 9ad6a5ffabd933024b35a5da887944efe7d45887 (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
29
30
#include <string.h>
#include "_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)
*/