pcre_tables.c

Go to the documentation of this file.
00001 /*************************************************
00002 *      Perl-Compatible Regular Expressions       *
00003 *************************************************/
00004 
00005 /* PCRE is a library of functions to support regular expressions whose syntax
00006 and semantics are as close as possible to those of the Perl 5 language.
00007 
00008                        Written by Philip Hazel
00009            Copyright (c) 1997-2008 University of Cambridge
00010 
00011 -----------------------------------------------------------------------------
00012 Redistribution and use in source and binary forms, with or without
00013 modification, are permitted provided that the following conditions are met:
00014 
00015     * Redistributions of source code must retain the above copyright notice,
00016       this list of conditions and the following disclaimer.
00017 
00018     * Redistributions in binary form must reproduce the above copyright
00019       notice, this list of conditions and the following disclaimer in the
00020       documentation and/or other materials provided with the distribution.
00021 
00022     * Neither the name of the University of Cambridge nor the names of its
00023       contributors may be used to endorse or promote products derived from
00024       this software without specific prior written permission.
00025 
00026 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00027 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00029 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00030 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00031 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00032 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00033 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00034 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00035 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00036 POSSIBILITY OF SUCH DAMAGE.
00037 -----------------------------------------------------------------------------
00038 */
00039 
00040 
00041 /* This module contains some fixed tables that are used by more than one of the
00042 PCRE code modules. The tables are also #included by the pcretest program, which
00043 uses macros to change their names from _pcre_xxx to xxxx, thereby avoiding name
00044 clashes with the library. */
00045 
00046 
00047 #ifdef HAVE_CONFIG_H
00048 #include "config.h"
00049 #endif
00050 
00051 #include "pcre_internal.h"
00052 
00053 
00054 /* Table of sizes for the fixed-length opcodes. It's defined in a macro so that
00055 the definition is next to the definition of the opcodes in pcre_internal.h. */
00056 
00057 const uschar _pcre_OP_lengths[] = { OP_LENGTHS };
00058 
00059 
00060 
00061 /*************************************************
00062 *           Tables for UTF-8 support             *
00063 *************************************************/
00064 
00065 /* These are the breakpoints for different numbers of bytes in a UTF-8
00066 character. */
00067 
00068 #ifdef SUPPORT_UTF8
00069 
00070 const int _pcre_utf8_table1[] =
00071   { 0x7f, 0x7ff, 0xffff, 0x1fffff, 0x3ffffff, 0x7fffffff};
00072 
00073 const int _pcre_utf8_table1_size = sizeof(_pcre_utf8_table1)/sizeof(int);
00074 
00075 /* These are the indicator bits and the mask for the data bits to set in the
00076 first byte of a character, indexed by the number of additional bytes. */
00077 
00078 const int _pcre_utf8_table2[] = { 0,    0xc0, 0xe0, 0xf0, 0xf8, 0xfc};
00079 const int _pcre_utf8_table3[] = { 0xff, 0x1f, 0x0f, 0x07, 0x03, 0x01};
00080 
00081 /* Table of the number of extra bytes, indexed by the first byte masked with
00082 0x3f. The highest number for a valid UTF-8 first byte is in fact 0x3d. */
00083 
00084 const uschar _pcre_utf8_table4[] = {
00085   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
00086   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
00087   2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
00088   3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 };
00089 
00090 /* Table to translate from particular type value to the general value. */
00091 
00092 const int _pcre_ucp_gentype[] = {
00093   ucp_C, ucp_C, ucp_C, ucp_C, ucp_C,  /* Cc, Cf, Cn, Co, Cs */
00094   ucp_L, ucp_L, ucp_L, ucp_L, ucp_L,  /* Ll, Lu, Lm, Lo, Lt */
00095   ucp_M, ucp_M, ucp_M,                /* Mc, Me, Mn */
00096   ucp_N, ucp_N, ucp_N,                /* Nd, Nl, No */
00097   ucp_P, ucp_P, ucp_P, ucp_P, ucp_P,  /* Pc, Pd, Pe, Pf, Pi */
00098   ucp_P, ucp_P,                       /* Ps, Po */
00099   ucp_S, ucp_S, ucp_S, ucp_S,         /* Sc, Sk, Sm, So */
00100   ucp_Z, ucp_Z, ucp_Z                 /* Zl, Zp, Zs */
00101 };
00102 
00103 /* The pcre_utt[] table below translates Unicode property names into type and
00104 code values. It is searched by binary chop, so must be in collating sequence of
00105 name. Originally, the table contained pointers to the name strings in the first
00106 field of each entry. However, that leads to a large number of relocations when
00107 a shared library is dynamically loaded. A significant reduction is made by
00108 putting all the names into a single, large string and then using offsets in the
00109 table itself. Maintenance is more error-prone, but frequent changes to this
00110 data are unlikely.
00111 
00112 July 2008: There is now a script called maint/GenerateUtt.py which can be used
00113 to generate this data instead of maintaining it entirely by hand. */
00114 
00115 const char _pcre_utt_names[] =
00116   "Any\0"
00117   "Arabic\0"
00118   "Armenian\0"
00119   "Balinese\0"
00120   "Bengali\0"
00121   "Bopomofo\0"
00122   "Braille\0"
00123   "Buginese\0"
00124   "Buhid\0"
00125   "C\0"
00126   "Canadian_Aboriginal\0"
00127   "Carian\0"
00128   "Cc\0"
00129   "Cf\0"
00130   "Cham\0"
00131   "Cherokee\0"
00132   "Cn\0"
00133   "Co\0"
00134   "Common\0"
00135   "Coptic\0"
00136   "Cs\0"
00137   "Cuneiform\0"
00138   "Cypriot\0"
00139   "Cyrillic\0"
00140   "Deseret\0"
00141   "Devanagari\0"
00142   "Ethiopic\0"
00143   "Georgian\0"
00144   "Glagolitic\0"
00145   "Gothic\0"
00146   "Greek\0"
00147   "Gujarati\0"
00148   "Gurmukhi\0"
00149   "Han\0"
00150   "Hangul\0"
00151   "Hanunoo\0"
00152   "Hebrew\0"
00153   "Hiragana\0"
00154   "Inherited\0"
00155   "Kannada\0"
00156   "Katakana\0"
00157   "Kayah_Li\0"
00158   "Kharoshthi\0"
00159   "Khmer\0"
00160   "L\0"
00161   "L&\0"
00162   "Lao\0"
00163   "Latin\0"
00164   "Lepcha\0"
00165   "Limbu\0"
00166   "Linear_B\0"
00167   "Ll\0"
00168   "Lm\0"
00169   "Lo\0"
00170   "Lt\0"
00171   "Lu\0"
00172   "Lycian\0"
00173   "Lydian\0"
00174   "M\0"
00175   "Malayalam\0"
00176   "Mc\0"
00177   "Me\0"
00178   "Mn\0"
00179   "Mongolian\0"
00180   "Myanmar\0"
00181   "N\0"
00182   "Nd\0"
00183   "New_Tai_Lue\0"
00184   "Nko\0"
00185   "Nl\0"
00186   "No\0"
00187   "Ogham\0"
00188   "Ol_Chiki\0"
00189   "Old_Italic\0"
00190   "Old_Persian\0"
00191   "Oriya\0"
00192   "Osmanya\0"
00193   "P\0"
00194   "Pc\0"
00195   "Pd\0"
00196   "Pe\0"
00197   "Pf\0"
00198   "Phags_Pa\0"
00199   "Phoenician\0"
00200   "Pi\0"
00201   "Po\0"
00202   "Ps\0"
00203   "Rejang\0"
00204   "Runic\0"
00205   "S\0"
00206   "Saurashtra\0"
00207   "Sc\0"
00208   "Shavian\0"
00209   "Sinhala\0"
00210   "Sk\0"
00211   "Sm\0"
00212   "So\0"
00213   "Sundanese\0"
00214   "Syloti_Nagri\0"
00215   "Syriac\0"
00216   "Tagalog\0"
00217   "Tagbanwa\0"
00218   "Tai_Le\0"
00219   "Tamil\0"
00220   "Telugu\0"
00221   "Thaana\0"
00222   "Thai\0"
00223   "Tibetan\0"
00224   "Tifinagh\0"
00225   "Ugaritic\0"
00226   "Vai\0"
00227   "Yi\0"
00228   "Z\0"
00229   "Zl\0"
00230   "Zp\0"
00231   "Zs\0";
00232 
00233 const ucp_type_table _pcre_utt[] = {
00234   {   0, PT_ANY, 0 },
00235   {   4, PT_SC, ucp_Arabic },
00236   {  11, PT_SC, ucp_Armenian },
00237   {  20, PT_SC, ucp_Balinese },
00238   {  29, PT_SC, ucp_Bengali },
00239   {  37, PT_SC, ucp_Bopomofo },
00240   {  46, PT_SC, ucp_Braille },
00241   {  54, PT_SC, ucp_Buginese },
00242   {  63, PT_SC, ucp_Buhid },
00243   {  69, PT_GC, ucp_C },
00244   {  71, PT_SC, ucp_Canadian_Aboriginal },
00245   {  91, PT_SC, ucp_Carian },
00246   {  98, PT_PC, ucp_Cc },
00247   { 101, PT_PC, ucp_Cf },
00248   { 104, PT_SC, ucp_Cham },
00249   { 109, PT_SC, ucp_Cherokee },
00250   { 118, PT_PC, ucp_Cn },
00251   { 121, PT_PC, ucp_Co },
00252   { 124, PT_SC, ucp_Common },
00253   { 131, PT_SC, ucp_Coptic },
00254   { 138, PT_PC, ucp_Cs },
00255   { 141, PT_SC, ucp_Cuneiform },
00256   { 151, PT_SC, ucp_Cypriot },
00257   { 159, PT_SC, ucp_Cyrillic },
00258   { 168, PT_SC, ucp_Deseret },
00259   { 176, PT_SC, ucp_Devanagari },
00260   { 187, PT_SC, ucp_Ethiopic },
00261   { 196, PT_SC, ucp_Georgian },
00262   { 205, PT_SC, ucp_Glagolitic },
00263   { 216, PT_SC, ucp_Gothic },
00264   { 223, PT_SC, ucp_Greek },
00265   { 229, PT_SC, ucp_Gujarati },
00266   { 238, PT_SC, ucp_Gurmukhi },
00267   { 247, PT_SC, ucp_Han },
00268   { 251, PT_SC, ucp_Hangul },
00269   { 258, PT_SC, ucp_Hanunoo },
00270   { 266, PT_SC, ucp_Hebrew },
00271   { 273, PT_SC, ucp_Hiragana },
00272   { 282, PT_SC, ucp_Inherited },
00273   { 292, PT_SC, ucp_Kannada },
00274   { 300, PT_SC, ucp_Katakana },
00275   { 309, PT_SC, ucp_Kayah_Li },
00276   { 318, PT_SC, ucp_Kharoshthi },
00277   { 329, PT_SC, ucp_Khmer },
00278   { 335, PT_GC, ucp_L },
00279   { 337, PT_LAMP, 0 },
00280   { 340, PT_SC, ucp_Lao },
00281   { 344, PT_SC, ucp_Latin },
00282   { 350, PT_SC, ucp_Lepcha },
00283   { 357, PT_SC, ucp_Limbu },
00284   { 363, PT_SC, ucp_Linear_B },
00285   { 372, PT_PC, ucp_Ll },
00286   { 375, PT_PC, ucp_Lm },
00287   { 378, PT_PC, ucp_Lo },
00288   { 381, PT_PC, ucp_Lt },
00289   { 384, PT_PC, ucp_Lu },
00290   { 387, PT_SC, ucp_Lycian },
00291   { 394, PT_SC, ucp_Lydian },
00292   { 401, PT_GC, ucp_M },
00293   { 403, PT_SC, ucp_Malayalam },
00294   { 413, PT_PC, ucp_Mc },
00295   { 416, PT_PC, ucp_Me },
00296   { 419, PT_PC, ucp_Mn },
00297   { 422, PT_SC, ucp_Mongolian },
00298   { 432, PT_SC, ucp_Myanmar },
00299   { 440, PT_GC, ucp_N },
00300   { 442, PT_PC, ucp_Nd },
00301   { 445, PT_SC, ucp_New_Tai_Lue },
00302   { 457, PT_SC, ucp_Nko },
00303   { 461, PT_PC, ucp_Nl },
00304   { 464, PT_PC, ucp_No },
00305   { 467, PT_SC, ucp_Ogham },
00306   { 473, PT_SC, ucp_Ol_Chiki },
00307   { 482, PT_SC, ucp_Old_Italic },
00308   { 493, PT_SC, ucp_Old_Persian },
00309   { 505, PT_SC, ucp_Oriya },
00310   { 511, PT_SC, ucp_Osmanya },
00311   { 519, PT_GC, ucp_P },
00312   { 521, PT_PC, ucp_Pc },
00313   { 524, PT_PC, ucp_Pd },
00314   { 527, PT_PC, ucp_Pe },
00315   { 530, PT_PC, ucp_Pf },
00316   { 533, PT_SC, ucp_Phags_Pa },
00317   { 542, PT_SC, ucp_Phoenician },
00318   { 553, PT_PC, ucp_Pi },
00319   { 556, PT_PC, ucp_Po },
00320   { 559, PT_PC, ucp_Ps },
00321   { 562, PT_SC, ucp_Rejang },
00322   { 569, PT_SC, ucp_Runic },
00323   { 575, PT_GC, ucp_S },
00324   { 577, PT_SC, ucp_Saurashtra },
00325   { 588, PT_PC, ucp_Sc },
00326   { 591, PT_SC, ucp_Shavian },
00327   { 599, PT_SC, ucp_Sinhala },
00328   { 607, PT_PC, ucp_Sk },
00329   { 610, PT_PC, ucp_Sm },
00330   { 613, PT_PC, ucp_So },
00331   { 616, PT_SC, ucp_Sundanese },
00332   { 626, PT_SC, ucp_Syloti_Nagri },
00333   { 639, PT_SC, ucp_Syriac },
00334   { 646, PT_SC, ucp_Tagalog },
00335   { 654, PT_SC, ucp_Tagbanwa },
00336   { 663, PT_SC, ucp_Tai_Le },
00337   { 670, PT_SC, ucp_Tamil },
00338   { 676, PT_SC, ucp_Telugu },
00339   { 683, PT_SC, ucp_Thaana },
00340   { 690, PT_SC, ucp_Thai },
00341   { 695, PT_SC, ucp_Tibetan },
00342   { 703, PT_SC, ucp_Tifinagh },
00343   { 712, PT_SC, ucp_Ugaritic },
00344   { 721, PT_SC, ucp_Vai },
00345   { 725, PT_SC, ucp_Yi },
00346   { 728, PT_GC, ucp_Z },
00347   { 730, PT_PC, ucp_Zl },
00348   { 733, PT_PC, ucp_Zp },
00349   { 736, PT_PC, ucp_Zs }
00350 };
00351 
00352 const int _pcre_utt_size = sizeof(_pcre_utt)/sizeof(ucp_type_table);
00353 
00354 #endif  /* SUPPORT_UTF8 */
00355 
00356 /* End of pcre_tables.c */

Generated on Tue Jul 5 14:11:57 2011 for ROOT_528-00b_version by  doxygen 1.5.1