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-2020  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 "regint.h"
37 
38 #define TOTAL_KEYWORDS 59
39 #define MIN_WORD_LENGTH 6
40 #define MAX_WORD_LENGTH 6
41 #define MIN_HASH_VALUE 0
42 #define MAX_HASH_VALUE 58
43 /* maximum key range = 59, duplicates = 0 */
44 
45 #ifdef __GNUC__
46 __inline
47 #else
48 #ifdef __cplusplus
49 inline
50 #endif
51 #endif
52 /*ARGSUSED*/
53 static unsigned int
hash(OnigCodePoint codes[])54 hash(OnigCodePoint codes[])
55 {
56   static const unsigned char asso_values[] =
57     {
58       58, 57, 56, 55, 54, 53, 52, 16, 50, 59,
59       15, 59, 25, 59, 59, 59, 59, 59, 59,  3,
60       59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
61       59, 59, 49, 48, 47, 46, 45, 44, 43, 42,
62       59, 59, 59, 59, 59, 59, 59, 59, 59, 21,
63       59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
64       59, 59, 59, 59, 59, 59,  2, 59, 59, 59,
65       59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
66       59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
67       59, 59, 59, 59, 59, 59, 40, 20, 39, 38,
68       37, 14,  5, 36, 20,  7, 25, 34, 29, 32,
69       16, 59, 31, 59, 59,  2,  1, 59, 25, 15,
70       59, 14, 59, 59, 28, 59,  2, 59, 59, 59,
71       11, 59, 59, 59, 59, 59, 59, 59, 59, 59,
72       59, 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, 24, 59, 22, 59, 59, 11, 59, 59,
76       59, 59, 59,  7, 59,  0, 59, 59, 16, 59,
77        1, 59, 59, 16, 59, 59, 59, 15, 59, 59,
78       59,  6, 59, 59, 59, 59,  0, 59, 59, 59,
79       59, 59, 59, 59, 59, 59, 59, 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
84     };
85   return asso_values[(unsigned char)onig_codes_byte_at(codes, 5)] + asso_values[(unsigned char)onig_codes_byte_at(codes, 2)];
86 }
87 
88 int
onigenc_unicode_fold2_key(OnigCodePoint codes[])89 onigenc_unicode_fold2_key(OnigCodePoint codes[])
90 {
91   static const short int wordlist[] =
92     {
93 
94       101,
95 
96       253,
97 
98       76,
99 
100       29,
101 
102       24,
103 
104       239,
105 
106       96,
107 
108       71,
109 
110       92,
111 
112       67,
113 
114       4,
115 
116       62,
117 
118       8,
119 
120       58,
121 
122       234,
123 
124       109,
125 
126       164,
127 
128       88,
129 
130       84,
131 
132       80,
133 
134       214,
135 
136       0,
137 
138       54,
139 
140       261,
141 
142       50,
143 
144       105,
145 
146       121,
147 
148       125,
149 
150       257,
151 
152       42,
153 
154       38,
155 
156       249,
157 
158       46,
159 
160       117,
161 
162       12,
163 
164       113,
165 
166       244,
167 
168       229,
169 
170       224,
171 
172       219,
173 
174       209,
175 
176       16,
177 
178       204,
179 
180       199,
181 
182       194,
183 
184       189,
185 
186       184,
187 
188       179,
189 
190       174,
191 
192       169,
193 
194       20,
195 
196       34,
197 
198       159,
199 
200       154,
201 
202       149,
203 
204       144,
205 
206       139,
207 
208       134,
209 
210       129
211     };
212 
213 
214     {
215       int key = hash(codes);
216 
217       if (key <= MAX_HASH_VALUE)
218         {
219           int index = wordlist[key];
220 
221           if (index >= 0 && onig_codes_cmp(codes, OnigUnicodeFolds2 + index, 2) == 0)
222             return index;
223         }
224     }
225   return -1;
226 }
227