aboutsummaryrefslogtreecommitdiff
path: root/lib/mbstring/u8cut.c
blob: 3dd9663f64cc0435c638fa0da1651d0f30554a72 (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(struct u8view *restrict x, struct u8view *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;
}