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

char8_t *
u8chk(const char8_t *s, size_t n)
{
	while (n) {
		rune ch;
		int m = u8tor(&ch, s);

		if (ch == RUNE_ERROR)
			return (char8_t *)s;
		n -= m;
		s += m;
	}

	return nullptr;
}