1 /* This file was converted by gperf_fold_key_conv.py
2 from gperf output file. */
3 /* ANSI-C code produced by gperf version 3.1 */
4 /* Command-line: gperf -n -C -T -c -t -j1 -L ANSI-C -F,-1 -N onigenc_unicode_fold2_key unicode_fold2_key.gperf */
5 /* Computed positions: -k'3,6' */
6
7
8
9 /* This gperf source file was generated by make_unicode_fold_data.py */
10
11 /*-
12 * Copyright (c) 2017-2019 K.Kosako
13 * All rights reserved.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36 #include <string.h>
37 #include "regenc.h"
38
39 #define TOTAL_KEYWORDS 59
40 #define MIN_WORD_LENGTH 6
41 #define MAX_WORD_LENGTH 6
42 #define MIN_HASH_VALUE 0
43 #define MAX_HASH_VALUE 58
44 /* maximum key range = 59, duplicates = 0 */
45
46 #ifdef __GNUC__
47 __inline
48 #else
49 #ifdef __cplusplus
50 inline
51 #endif
52 #endif
53 /*ARGSUSED*/
54 static unsigned int
hash(OnigCodePoint codes[])55 hash(OnigCodePoint codes[])
56 {
57 static const unsigned char asso_values[] =
58 {
59 58, 57, 56, 55, 54, 53, 52, 16, 50, 59,
60 15, 59, 25, 59, 59, 59, 59, 59, 59, 3,
61 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
62 59, 59, 49, 48, 47, 46, 45, 44, 43, 42,
63 59, 59, 59, 59, 59, 59, 59, 59, 59, 21,
64 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
65 59, 59, 59, 59, 59, 59, 2, 59, 59, 59,
66 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
67 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
68 59, 59, 59, 59, 59, 59, 40, 20, 39, 38,
69 37, 14, 5, 36, 20, 7, 25, 34, 29, 32,
70 16, 59, 31, 59, 59, 2, 1, 59, 25, 15,
71 59, 14, 59, 59, 28, 59, 2, 59, 59, 59,
72 11, 59, 59, 59, 59, 59, 59, 59, 59, 59,
73 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
74 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
75 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
76 59, 59, 24, 59, 22, 59, 59, 11, 59, 59,
77 59, 59, 59, 7, 59, 0, 59, 59, 16, 59,
78 1, 59, 59, 16, 59, 59, 59, 15, 59, 59,
79 59, 6, 59, 59, 59, 59, 0, 59, 59, 59,
80 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
81 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
82 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
83 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
84 59, 59, 59, 59, 59, 59
85 };
86 return asso_values[(unsigned char)onig_codes_byte_at(codes, 5)] + asso_values[(unsigned char)onig_codes_byte_at(codes, 2)];
87 }
88
89 int
onigenc_unicode_fold2_key(OnigCodePoint codes[])90 onigenc_unicode_fold2_key(OnigCodePoint codes[])
91 {
92 static const short int wordlist[] =
93 {
94
95 101,
96
97 253,
98
99 76,
100
101 29,
102
103 24,
104
105 239,
106
107 96,
108
109 71,
110
111 92,
112
113 67,
114
115 4,
116
117 62,
118
119 8,
120
121 58,
122
123 234,
124
125 109,
126
127 164,
128
129 88,
130
131 84,
132
133 80,
134
135 214,
136
137 0,
138
139 54,
140
141 261,
142
143 50,
144
145 105,
146
147 121,
148
149 125,
150
151 257,
152
153 42,
154
155 38,
156
157 249,
158
159 46,
160
161 117,
162
163 12,
164
165 113,
166
167 244,
168
169 229,
170
171 224,
172
173 219,
174
175 209,
176
177 16,
178
179 204,
180
181 199,
182
183 194,
184
185 189,
186
187 184,
188
189 179,
190
191 174,
192
193 169,
194
195 20,
196
197 34,
198
199 159,
200
201 154,
202
203 149,
204
205 144,
206
207 139,
208
209 134,
210
211 129
212 };
213
214
215 {
216 int key = hash(codes);
217
218 if (key <= MAX_HASH_VALUE)
219 {
220 int index = wordlist[key];
221
222 if (index >= 0 && onig_codes_cmp(codes, OnigUnicodeFolds2 + index, 2) == 0)
223 return index;
224 }
225 }
226 return -1;
227 }
228