00001 /* This is JavaScriptCore's variant of the PCRE library. While this library 00002 started out as a copy of PCRE, many of the features of PCRE have been 00003 removed. This library now supports only the regular expression features 00004 required by the JavaScript language specification, and has only the functions 00005 needed by JavaScriptCore and the rest of WebKit. 00006 00007 Originally written by Philip Hazel 00008 Copyright (c) 1997-2006 University of Cambridge 00009 Copyright (C) 2002, 2004, 2006, 2007 Apple Inc. All rights reserved. 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 * Unicode Property Table handler * 00042 *************************************************/ 00043 00044 /* Internal header file defining the layout of the bits in each pair of 32-bit 00045 words that form a data item in the table. */ 00046 00047 typedef struct cnode { 00048 unsigned f0; 00049 unsigned f1; 00050 } cnode; 00051 00052 /* Things for the f0 field */ 00053 00054 #define f0_scriptmask 0xff000000 /* Mask for script field */ 00055 #define f0_scriptshift 24 /* Shift for script value */ 00056 #define f0_rangeflag 0x00f00000 /* Flag for a range item */ 00057 #define f0_charmask 0x001fffff /* Mask for code point value */ 00058 00059 /* Things for the f1 field */ 00060 00061 #define f1_typemask 0xfc000000 /* Mask for char type field */ 00062 #define f1_typeshift 26 /* Shift for the type field */ 00063 #define f1_rangemask 0x0000ffff /* Mask for a range offset */ 00064 #define f1_casemask 0x0000ffff /* Mask for a case offset */ 00065 #define f1_caseneg 0xffff8000 /* Bits for negation */ 00066 00067 /* The data consists of a vector of structures of type cnode. The two unsigned 00068 32-bit integers are used as follows: 00069 00070 (f0) (1) The most significant byte holds the script number. The numbers are 00071 defined by the enum in ucp.h. 00072 00073 (2) The 0x00800000 bit is set if this entry defines a range of characters. 00074 It is not set if this entry defines a single character 00075 00076 (3) The 0x00600000 bits are spare. 00077 00078 (4) The 0x001fffff bits contain the code point. No Unicode code point will 00079 ever be greater than 0x0010ffff, so this should be OK for ever. 00080 00081 (f1) (1) The 0xfc000000 bits contain the character type number. The numbers are 00082 defined by an enum in ucp.h. 00083 00084 (2) The 0x03ff0000 bits are spare. 00085 00086 (3) The 0x0000ffff bits contain EITHER the unsigned offset to the top of 00087 range if this entry defines a range, OR the *signed* offset to the 00088 character's "other case" partner if this entry defines a single 00089 character. There is no partner if the value is zero. 00090 00091 ------------------------------------------------------------------------------- 00092 | script (8) |.|.|.| codepoint (21) || type (6) |.|.| spare (8) | offset (16) | 00093 ------------------------------------------------------------------------------- 00094 | | | | | 00095 | | |-> spare | |-> spare 00096 | | | 00097 | |-> spare |-> spare 00098 | 00099 |-> range flag 00100 00101 The upper/lower casing information is set only for characters that come in 00102 pairs. The non-one-to-one mappings in the Unicode data are ignored. 00103 00104 When searching the data, proceed as follows: 00105 00106 (1) Set up for a binary chop search. 00107 00108 (2) If the top is not greater than the bottom, the character is not in the 00109 table. Its type must therefore be "Cn" ("Undefined"). 00110 00111 (3) Find the middle vector element. 00112 00113 (4) Extract the code point and compare. If equal, we are done. 00114 00115 (5) If the test character is smaller, set the top to the current point, and 00116 goto (2). 00117 00118 (6) If the current entry defines a range, compute the last character by adding 00119 the offset, and see if the test character is within the range. If it is, 00120 we are done. 00121 00122 (7) Otherwise, set the bottom to one element past the current point and goto 00123 (2). 00124 */ 00125 00126 /* End of ucpinternal.h */