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

size_t
u8spn(struct u8view sv, const rune *p, size_t n)
{
	rune ch;
	size_t k = 0, w;

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

		break;
found:;
	}

	return k;
}