blob: 17237ebf91a0859904bf6762d2b6beabff4d019f (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
/* See LICENSE file for copyright and license details. */
#include "lib-common.h"
enum libcharconv_result
libcharconv_cypriot(const char *s, size_t slen, size_t *n, uint_least32_t *cp, size_t *ncp)
{
uint_least32_t c;
*n = 0;
for (; slen--; s++) {
switch (s[0]) {
case 'A': case 'a': c = UINT32_C(0x10800); goto conv1;
case 'E': case 'e': c = UINT32_C(0x10801); goto conv1;
case 'I': case 'i': c = UINT32_C(0x10802); goto conv1;
case 'O': case 'o': c = UINT32_C(0x10803); goto conv1;
case 'U': case 'u': c = UINT32_C(0x10804); goto conv1;
case 'J': case 'j':
if (!slen)
return LIBCHARCONV_INDETERMINATE;
switch (s[1]) {
case 'A': case 'a': c = UINT32_C(0x10805); goto conv2;
case 'O': case 'o': c = UINT32_C(0x10808); goto conv2;
default:
goto no_match;
}
case 'K': case 'k':
if (!slen)
return LIBCHARCONV_INDETERMINATE;
switch (s[1]) {
case 'A': case 'a': c = UINT32_C(0x1080A); goto conv2;
case 'E': case 'e': c = UINT32_C(0x1080B); goto conv2;
case 'I': case 'i': c = UINT32_C(0x1080C); goto conv2;
case 'O': case 'o': c = UINT32_C(0x1080D); goto conv2;
case 'U': case 'u': c = UINT32_C(0x1080E); goto conv2;
default:
goto no_match;
}
case 'L': case 'l':
if (!slen)
return LIBCHARCONV_INDETERMINATE;
switch (s[1]) {
case 'A': case 'a': c = UINT32_C(0x1080F); goto conv2;
case 'E': case 'e': c = UINT32_C(0x10810); goto conv2;
case 'I': case 'i': c = UINT32_C(0x10811); goto conv2;
case 'O': case 'o': c = UINT32_C(0x10812); goto conv2;
case 'U': case 'u': c = UINT32_C(0x10813); goto conv2;
default:
goto no_match;
}
case 'M': case 'm':
if (!slen)
return LIBCHARCONV_INDETERMINATE;
switch (s[1]) {
case 'A': case 'a': c = UINT32_C(0x10814); goto conv2;
case 'E': case 'e': c = UINT32_C(0x10815); goto conv2;
case 'I': case 'i': c = UINT32_C(0x10816); goto conv2;
case 'O': case 'o': c = UINT32_C(0x10817); goto conv2;
case 'U': case 'u': c = UINT32_C(0x10818); goto conv2;
default:
goto no_match;
}
case 'N': case 'n':
if (!slen)
return LIBCHARCONV_INDETERMINATE;
switch (s[1]) {
case 'A': case 'a': c = UINT32_C(0x10819); goto conv2;
case 'E': case 'e': c = UINT32_C(0x1081A); goto conv2;
case 'I': case 'i': c = UINT32_C(0x1081B); goto conv2;
case 'O': case 'o': c = UINT32_C(0x1081C); goto conv2;
case 'U': case 'u': c = UINT32_C(0x1081D); goto conv2;
default:
goto no_match;
}
case 'P': case 'p':
if (!slen)
return LIBCHARCONV_INDETERMINATE;
switch (s[1]) {
case 'A': case 'a': c = UINT32_C(0x1081E); goto conv2;
case 'E': case 'e': c = UINT32_C(0x1081F); goto conv2;
case 'I': case 'i': c = UINT32_C(0x10820); goto conv2;
case 'O': case 'o': c = UINT32_C(0x10821); goto conv2;
case 'U': case 'u': c = UINT32_C(0x10822); goto conv2;
default:
goto no_match;
}
case 'R': case 'r':
if (!slen)
return LIBCHARCONV_INDETERMINATE;
switch (s[1]) {
case 'A': case 'a': c = UINT32_C(0x10823); goto conv2;
case 'E': case 'e': c = UINT32_C(0x10824); goto conv2;
case 'I': case 'i': c = UINT32_C(0x10825); goto conv2;
case 'O': case 'o': c = UINT32_C(0x10826); goto conv2;
case 'U': case 'u': c = UINT32_C(0x10827); goto conv2;
default:
goto no_match;
}
case 'S': case 's':
if (!slen)
return LIBCHARCONV_INDETERMINATE;
switch (s[1]) {
case 'A': case 'a': c = UINT32_C(0x10828); goto conv2;
case 'E': case 'e': c = UINT32_C(0x10829); goto conv2;
case 'I': case 'i': c = UINT32_C(0x1082A); goto conv2;
case 'O': case 'o': c = UINT32_C(0x1082B); goto conv2;
case 'U': case 'u': c = UINT32_C(0x1082C); goto conv2;
default:
goto no_match;
}
case 'T': case 't':
if (!slen)
return LIBCHARCONV_INDETERMINATE;
switch (s[1]) {
case 'A': case 'a': c = UINT32_C(0x1082D); goto conv2;
case 'E': case 'e': c = UINT32_C(0x1082E); goto conv2;
case 'I': case 'i': c = UINT32_C(0x1082F); goto conv2;
case 'O': case 'o': c = UINT32_C(0x10831); goto conv2;
case 'U': case 'u': c = UINT32_C(0x10830); goto conv2;
default:
goto no_match;
}
case 'W': case 'w':
if (!slen)
return LIBCHARCONV_INDETERMINATE;
switch (s[1]) {
case 'A': case 'a': c = UINT32_C(0x10832); goto conv2;
case 'E': case 'e': c = UINT32_C(0x10833); goto conv2;
case 'I': case 'i': c = UINT32_C(0x10834); goto conv2;
case 'O': case 'o': c = UINT32_C(0x10835); goto conv2;
default:
goto no_match;
}
case 'X': case 'x':
if (!slen)
return LIBCHARCONV_INDETERMINATE;
switch (s[1]) {
case 'A': case 'a': c = UINT32_C(0x10837); goto conv2;
case 'E': case 'e': c = UINT32_C(0x10838); goto conv2;
default:
goto no_match;
}
case 'Z': case 'z':
if (!slen)
return LIBCHARCONV_INDETERMINATE;
switch (s[1]) {
case 'A': case 'a': c = UINT32_C(0x1083C); goto conv2;
case 'O': case 'o': c = UINT32_C(0x1083F); goto conv2;
default:
goto no_match;
}
default:
no_match:
*n += 1u;
break;
}
}
no_conv:
return LIBCHARCONV_NO_CONVERT;
conv1:
if (*n)
goto no_conv;
if (*ncp)
*cp = c;
*n += 1u;
*ncp = 1u;
return LIBCHARCONV_CONVERTED;
conv2:
if (*n)
goto no_conv;
if (*ncp)
*cp = c;
*n += 2u;
*ncp = 1u;
return LIBCHARCONV_CONVERTED;
}
|