aboutsummaryrefslogtreecommitdiff
path: root/lib/unicode/prop/uprop_get_lc.c
blob: 0ce1072226e5ae2e4f017c1227f943acfc99ad9a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "macros.h"
#include "unicode/prop.h"

#define M(...) ((struct rview)_(__VA_ARGS__))
#define _(...) \
	{(const rune[]){__VA_ARGS__}, lengthof(((const rune[]){__VA_ARGS__}))}

struct rview
uprop_get_lc(rune ch, struct lcctx ctx)
{
	if (ch == U'Σ')
		return ctx.eow ? M(U'ς') : M(U'σ');
	if (ch == U'İ')
		return ctx.az_or_tr ? M('i') : M('i', 0x307);

	if (ctx.lt) {
		if (ctx.before_acc) {
			switch (ch) {
			case 'I':
				return M('i', 0x307);
			case 'J':
				return M('j', 0x307);
			case U'Į':
				return M(U'į', 0x307);
			}
		}

		switch (ch) {
		case U'Ì':
			return M('i', 0x307, 0x300);
		case U'Í':
			return M('i', 0x307, 0x301);
		case U'Ĩ':
			return M('i', 0x307, 0x303);
		}
	}

	if (ctx.az_or_tr) {
		if (ch == 0x307 && ctx.after_I)
			return M();
		if (ch == 'I' && !ctx.before_dot)
			return M(U'ı');
	}

	ch = uprop_get_slc(ch);
	return M(ch);
}