1 /*************************************************
2 *      Perl-Compatible Regular Expressions       *
3 *************************************************/
4 
5 /* PCRE is a library of functions to support regular expressions whose syntax
6 and semantics are as close as possible to those of the Perl 5 language.
7 
8                        Written by Philip Hazel
9            Copyright (c) 1997-2007 University of Cambridge
10 
11 -----------------------------------------------------------------------------
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14 
15     * Redistributions of source code must retain the above copyright notice,
16       this list of conditions and the following disclaimer.
17 
18     * Redistributions in binary form must reproduce the above copyright
19       notice, this list of conditions and the following disclaimer in the
20       documentation and/or other materials provided with the distribution.
21 
22     * Neither the name of the University of Cambridge nor the names of its
23       contributors may be used to endorse or promote products derived from
24       this software without specific prior written permission.
25 
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 POSSIBILITY OF SUCH DAMAGE.
37 -----------------------------------------------------------------------------
38 */
39 
40 
41 /* This module contains some fixed tables that are used by more than one of the
42 PCRE code modules. The tables are also #included by the pcretest program, which
43 uses macros to change their names from _pcre_xxx to xxxx, thereby avoiding name
44 clashes with the library. */
45 
46 
47 #ifdef HAVE_CONFIG_H
48 #include "config.h"
49 #endif
50 
51 #include "pcre_internal.h"
52 
53 
54 /* Table of sizes for the fixed-length opcodes. It's defined in a macro so that
55 the definition is next to the definition of the opcodes in pcre_internal.h. */
56 
57 //const uschar _pcre_OP_lengths[] = { OP_LENGTHS };
58 
59 
60 
61 /*************************************************
62 *           Tables for UTF-8 support             *
63 *************************************************/
64 
65 /* These are the breakpoints for different numbers of bytes in a UTF-8
66 character. */
67 
68 #ifdef SUPPORT_UTF8
69 
70 const int _pcre_utf8_table1[] =
71 { 0x7f, 0x7ff, 0xffff, 0x1fffff, 0x3ffffff, 0x7fffffff};
72 
73 const int _pcre_utf8_table1_size = sizeof(_pcre_utf8_table1) / sizeof(int);
74 
75 /* These are the indicator bits and the mask for the data bits to set in the
76 first byte of a character, indexed by the number of additional bytes. */
77 
78 const int _pcre_utf8_table2[] = { 0,    0xc0, 0xe0, 0xf0, 0xf8, 0xfc};
79 const int _pcre_utf8_table3[] = { 0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01};
80 
81 /* Table of the number of extra bytes, indexed by the first byte masked with
82 0x3f. The highest number for a valid UTF-8 first byte is in fact 0x3d. */
83 
84 const uschar _pcre_utf8_table4[] =
85 {
86     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
87     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
88     2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
89     3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5
90 };
91 
92 /* The pcre_utt[] table below translates Unicode property names into type and
93 code values. It is searched by binary chop, so must be in collating sequence of
94 name. Originally, the table contained pointers to the name strings in the first
95 field of each entry. However, that leads to a large number of relocations when
96 a shared library is dynamically loaded. A significant reduction is made by
97 putting all the names into a single, large string and then using offsets in the
98 table itself. Maintenance is more error-prone, but frequent changes to this
99 data is unlikely. */
100 
101 const char _pcre_utt_names[] =
102     "Any\0"
103     "Arabic\0"
104     "Armenian\0"
105     "Balinese\0"
106     "Bengali\0"
107     "Bopomofo\0"
108     "Braille\0"
109     "Buginese\0"
110     "Buhid\0"
111     "C\0"
112     "Canadian_Aboriginal\0"
113     "Cc\0"
114     "Cf\0"
115     "Cherokee\0"
116     "Cn\0"
117     "Co\0"
118     "Common\0"
119     "Coptic\0"
120     "Cs\0"
121     "Cuneiform\0"
122     "Cypriot\0"
123     "Cyrillic\0"
124     "Deseret\0"
125     "Devanagari\0"
126     "Ethiopic\0"
127     "Georgian\0"
128     "Glagolitic\0"
129     "Gothic\0"
130     "Greek\0"
131     "Gujarati\0"
132     "Gurmukhi\0"
133     "Han\0"
134     "Hangul\0"
135     "Hanunoo\0"
136     "Hebrew\0"
137     "Hiragana\0"
138     "Inherited\0"
139     "Kannada\0"
140     "Katakana\0"
141     "Kharoshthi\0"
142     "Khmer\0"
143     "L\0"
144     "L&\0"
145     "Lao\0"
146     "Latin\0"
147     "Limbu\0"
148     "Linear_B\0"
149     "Ll\0"
150     "Lm\0"
151     "Lo\0"
152     "Lt\0"
153     "Lu\0"
154     "M\0"
155     "Malayalam\0"
156     "Mc\0"
157     "Me\0"
158     "Mn\0"
159     "Mongolian\0"
160     "Myanmar\0"
161     "N\0"
162     "Nd\0"
163     "New_Tai_Lue\0"
164     "Nko\0"
165     "Nl\0"
166     "No\0"
167     "Ogham\0"
168     "Old_Italic\0"
169     "Old_Persian\0"
170     "Oriya\0"
171     "Osmanya\0"
172     "P\0"
173     "Pc\0"
174     "Pd\0"
175     "Pe\0"
176     "Pf\0"
177     "Phags_Pa\0"
178     "Phoenician\0"
179     "Pi\0"
180     "Po\0"
181     "Ps\0"
182     "Runic\0"
183     "S\0"
184     "Sc\0"
185     "Shavian\0"
186     "Sinhala\0"
187     "Sk\0"
188     "Sm\0"
189     "So\0"
190     "Syloti_Nagri\0"
191     "Syriac\0"
192     "Tagalog\0"
193     "Tagbanwa\0"
194     "Tai_Le\0"
195     "Tamil\0"
196     "Telugu\0"
197     "Thaana\0"
198     "Thai\0"
199     "Tibetan\0"
200     "Tifinagh\0"
201     "Ugaritic\0"
202     "Yi\0"
203     "Z\0"
204     "Zl\0"
205     "Zp\0"
206     "Zs\0";
207 
208 const ucp_type_table _pcre_utt[] =
209 {
210     { 0,   PT_ANY, 0 },
211     { 4,   PT_SC, ucp_Arabic },
212     { 11,  PT_SC, ucp_Armenian },
213     { 20,  PT_SC, ucp_Balinese },
214     { 29,  PT_SC, ucp_Bengali },
215     { 37,  PT_SC, ucp_Bopomofo },
216     { 46,  PT_SC, ucp_Braille },
217     { 54,  PT_SC, ucp_Buginese },
218     { 63,  PT_SC, ucp_Buhid },
219     { 69,  PT_GC, ucp_C },
220     { 71,  PT_SC, ucp_Canadian_Aboriginal },
221     { 91,  PT_PC, ucp_Cc },
222     { 94,  PT_PC, ucp_Cf },
223     { 97,  PT_SC, ucp_Cherokee },
224     { 106, PT_PC, ucp_Cn },
225     { 109, PT_PC, ucp_Co },
226     { 112, PT_SC, ucp_Common },
227     { 119, PT_SC, ucp_Coptic },
228     { 126, PT_PC, ucp_Cs },
229     { 129, PT_SC, ucp_Cuneiform },
230     { 139, PT_SC, ucp_Cypriot },
231     { 147, PT_SC, ucp_Cyrillic },
232     { 156, PT_SC, ucp_Deseret },
233     { 164, PT_SC, ucp_Devanagari },
234     { 175, PT_SC, ucp_Ethiopic },
235     { 184, PT_SC, ucp_Georgian },
236     { 193, PT_SC, ucp_Glagolitic },
237     { 204, PT_SC, ucp_Gothic },
238     { 211, PT_SC, ucp_Greek },
239     { 217, PT_SC, ucp_Gujarati },
240     { 226, PT_SC, ucp_Gurmukhi },
241     { 235, PT_SC, ucp_Han },
242     { 239, PT_SC, ucp_Hangul },
243     { 246, PT_SC, ucp_Hanunoo },
244     { 254, PT_SC, ucp_Hebrew },
245     { 261, PT_SC, ucp_Hiragana },
246     { 270, PT_SC, ucp_Inherited },
247     { 280, PT_SC, ucp_Kannada },
248     { 288, PT_SC, ucp_Katakana },
249     { 297, PT_SC, ucp_Kharoshthi },
250     { 308, PT_SC, ucp_Khmer },
251     { 314, PT_GC, ucp_L },
252     { 316, PT_LAMP, 0 },
253     { 319, PT_SC, ucp_Lao },
254     { 323, PT_SC, ucp_Latin },
255     { 329, PT_SC, ucp_Limbu },
256     { 335, PT_SC, ucp_Linear_B },
257     { 344, PT_PC, ucp_Ll },
258     { 347, PT_PC, ucp_Lm },
259     { 350, PT_PC, ucp_Lo },
260     { 353, PT_PC, ucp_Lt },
261     { 356, PT_PC, ucp_Lu },
262     { 359, PT_GC, ucp_M },
263     { 361, PT_SC, ucp_Malayalam },
264     { 371, PT_PC, ucp_Mc },
265     { 374, PT_PC, ucp_Me },
266     { 377, PT_PC, ucp_Mn },
267     { 380, PT_SC, ucp_Mongolian },
268     { 390, PT_SC, ucp_Myanmar },
269     { 398, PT_GC, ucp_N },
270     { 400, PT_PC, ucp_Nd },
271     { 403, PT_SC, ucp_New_Tai_Lue },
272     { 415, PT_SC, ucp_Nko },
273     { 419, PT_PC, ucp_Nl },
274     { 422, PT_PC, ucp_No },
275     { 425, PT_SC, ucp_Ogham },
276     { 431, PT_SC, ucp_Old_Italic },
277     { 442, PT_SC, ucp_Old_Persian },
278     { 454, PT_SC, ucp_Oriya },
279     { 460, PT_SC, ucp_Osmanya },
280     { 468, PT_GC, ucp_P },
281     { 470, PT_PC, ucp_Pc },
282     { 473, PT_PC, ucp_Pd },
283     { 476, PT_PC, ucp_Pe },
284     { 479, PT_PC, ucp_Pf },
285     { 482, PT_SC, ucp_Phags_Pa },
286     { 491, PT_SC, ucp_Phoenician },
287     { 502, PT_PC, ucp_Pi },
288     { 505, PT_PC, ucp_Po },
289     { 508, PT_PC, ucp_Ps },
290     { 511, PT_SC, ucp_Runic },
291     { 517, PT_GC, ucp_S },
292     { 519, PT_PC, ucp_Sc },
293     { 522, PT_SC, ucp_Shavian },
294     { 530, PT_SC, ucp_Sinhala },
295     { 538, PT_PC, ucp_Sk },
296     { 541, PT_PC, ucp_Sm },
297     { 544, PT_PC, ucp_So },
298     { 547, PT_SC, ucp_Syloti_Nagri },
299     { 560, PT_SC, ucp_Syriac },
300     { 567, PT_SC, ucp_Tagalog },
301     { 575, PT_SC, ucp_Tagbanwa },
302     { 584, PT_SC, ucp_Tai_Le },
303     { 591, PT_SC, ucp_Tamil },
304     { 597, PT_SC, ucp_Telugu },
305     { 604, PT_SC, ucp_Thaana },
306     { 611, PT_SC, ucp_Thai },
307     { 616, PT_SC, ucp_Tibetan },
308     { 624, PT_SC, ucp_Tifinagh },
309     { 633, PT_SC, ucp_Ugaritic },
310     { 642, PT_SC, ucp_Yi },
311     { 645, PT_GC, ucp_Z },
312     { 647, PT_PC, ucp_Zl },
313     { 650, PT_PC, ucp_Zp },
314     { 653, PT_PC, ucp_Zs }
315 };
316 
317 const int _pcre_utt_size = sizeof(_pcre_utt) / sizeof(ucp_type_table);
318 
319 #endif  /* SUPPORT_UTF8 */
320 
321 /* End of pcre_tables.c */
322