blob: 3f6773f58824c1c82d34aafe066bc9b553b4a0d8 (
plain)
| 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
48
49
50
51
52
53
54
55
56
57
 | /*
** Copyright 2020 Double Precision, Inc.
** See COPYING for distribution information.
**
*/
#include	"unicode_config.h"
#include	"courier-unicode.h"
#include <string.h>
struct canon_map_table {
	char32_t lookup_char;
	unsigned char fmt_flag_v;
	unsigned char n_chars;
	unsigned short offset;
};
#include "canonicalmappings.h"
unicode_canonical_t unicode_canonical(char32_t c)
{
	size_t i=canon_map_hash[c % HASH_SIZE]
		+
		/* Compile-time sanity check */
		sizeof(char[ sizeof(canon_map_hash)/
			     sizeof(canon_map_hash[0]) == HASH_SIZE
			     ? 1:-1])*0;
	while (i < sizeof(canon_map_lookup)/sizeof(canon_map_lookup[0]))
	{
		if (canon_map_lookup[i].lookup_char == c)
		{
			unicode_canonical_t ret;
			ret.canonical_chars=
				canon_map_values+canon_map_lookup[i].offset;
			ret.n_canonical_chars=
				canon_map_lookup[i].n_chars;
			ret.format=
				(unicode_canonical_fmt_t)
				canon_map_lookup[i].fmt_flag_v;
			return ret;
		}
		if ((canon_map_lookup[i].lookup_char % HASH_SIZE) !=
		    (c % HASH_SIZE))
			break;
		++i;
	}
	unicode_canonical_t ret;
	memset(&ret, 0, sizeof(ret));
	return ret;
}
 |