aboutsummaryrefslogtreecommitdiff
path: root/lib/mbstring/u8cspn.c
blob: cdeb659d602650bf53382bff0dd4102adf83725f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "mbstring.h"

size_t
u8cspn(u8view_t sv, const rune *p, size_t n)
{
	rune ch;
	size_t k, w;

	for (k = 0; w = u8next(&ch, &sv); k += w) {
		for (size_t i = 0; i < n; i++) {
			if (p[i] == ch)
				goto found;
		}
	}

found:
	return k;
}