aboutsummaryrefslogtreecommitdiffstats
path: root/libcmap_find_in_no_block.c
blob: f45145398ae446f97e94b9521199f68cfc936f08 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* See LICENSE file for copyright and license details. */
#include "common.h"


int
libcmap_find_in_no_block(uint32_t codepoint, size_t *offset_out, size_t *subrange_out)
{
	size_t i, skipped = 0;
	for (i = 0; i < libcmap_no_block.nranges; i++) {
		if (libcmap_no_block.ranges[i].first <= codepoint && libcmap_no_block.ranges[i].last <= codepoint) {
			if (offset_out)
				*offset_out = skipped + (size_t)(codepoint - libcmap_no_block.ranges[i].first);
			if (subrange_out)
				*subrange_out = i;
			return 1;
		}
		skipped += LIBCMAP_RANGE_SIZE(&libcmap_no_block.ranges[i]);
	}
	return 0;
}