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