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

rune
u8cut(u8view_t *restrict x, u8view_t *restrict y, const rune *seps,
      size_t n)
{
	ASSUME(y != nullptr);
	ASSUME(seps != nullptr);
	size_t off = u8cspn(*y, seps, n);
	if (x != nullptr) {
		x->p = y->p;
		x->len = off;
	}
	VSHFT(y, off);
	rune ch = MBEND;
	u8next(&ch, y);
	return ch;
}