/[pcre]/code/trunk/ucpinternal.h
ViewVC logotype

Contents of /code/trunk/ucpinternal.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 87 - (hide annotations) (download)
Sat Feb 24 21:41:21 2007 UTC (7 years, 9 months ago) by nigel
File MIME type: text/plain
File size: 3376 byte(s)
Load pcre-6.5 into code/trunk.

1 nigel 75 /*************************************************
2 nigel 87 * Unicode Property Table handler *
3 nigel 75 *************************************************/
4    
5 nigel 87 /* Internal header file defining the layout of the bits in each pair of 32-bit
6     words that form a data item in the table. */
7 nigel 75
8     typedef struct cnode {
9 nigel 87 pcre_uint32 f0;
10     pcre_uint32 f1;
11 nigel 75 } cnode;
12    
13     /* Things for the f0 field */
14    
15 nigel 87 #define f0_scriptmask 0xff000000 /* Mask for script field */
16     #define f0_scriptshift 24 /* Shift for script value */
17     #define f0_rangeflag 0x00f00000 /* Flag for a range item */
18     #define f0_charmask 0x001fffff /* Mask for code point value */
19 nigel 75
20 nigel 87 /* Things for the f1 field */
21 nigel 75
22 nigel 87 #define f1_typemask 0xfc000000 /* Mask for char type field */
23     #define f1_typeshift 26 /* Shift for the type field */
24     #define f1_rangemask 0x0000ffff /* Mask for a range offset */
25     #define f1_casemask 0x0000ffff /* Mask for a case offset */
26     #define f1_caseneg 0xffff8000 /* Bits for negation */
27 nigel 75
28 nigel 87 /* The data consists of a vector of structures of type cnode. The two unsigned
29     32-bit integers are used as follows:
30 nigel 75
31 nigel 87 (f0) (1) The most significant byte holds the script number. The numbers are
32     defined by the enum in ucp.h.
33 nigel 75
34 nigel 87 (2) The 0x00800000 bit is set if this entry defines a range of characters.
35     It is not set if this entry defines a single character
36 nigel 75
37 nigel 87 (3) The 0x00600000 bits are spare.
38 nigel 75
39 nigel 87 (4) The 0x001fffff bits contain the code point. No Unicode code point will
40     ever be greater than 0x0010ffff, so this should be OK for ever.
41 nigel 75
42 nigel 87 (f1) (1) The 0xfc000000 bits contain the character type number. The numbers are
43     defined by an enum in ucp.h.
44 nigel 75
45 nigel 87 (2) The 0x03ff0000 bits are spare.
46 nigel 75
47 nigel 87 (3) The 0x0000ffff bits contain EITHER the unsigned offset to the top of
48     range if this entry defines a range, OR the *signed* offset to the
49     character's "other case" partner if this entry defines a single
50     character. There is no partner if the value is zero.
51 nigel 75
52 nigel 87 -------------------------------------------------------------------------------
53     | script (8) |.|.|.| codepoint (21) || type (6) |.|.| spare (8) | offset (16) |
54     -------------------------------------------------------------------------------
55     | | | | |
56     | | |-> spare | |-> spare
57     | | |
58     | |-> spare |-> spare
59     |
60     |-> range flag
61    
62 nigel 75 The upper/lower casing information is set only for characters that come in
63 nigel 87 pairs. The non-one-to-one mappings in the Unicode data are ignored.
64 nigel 75
65 nigel 87 When searching the data, proceed as follows:
66 nigel 75
67 nigel 87 (1) Set up for a binary chop search.
68 nigel 75
69 nigel 87 (2) If the top is not greater than the bottom, the character is not in the
70     table. Its type must therefore be "Cn" ("Undefined").
71 nigel 75
72 nigel 87 (3) Find the middle vector element.
73 nigel 75
74 nigel 87 (4) Extract the code point and compare. If equal, we are done.
75 nigel 75
76 nigel 87 (5) If the test character is smaller, set the top to the current point, and
77     goto (2).
78 nigel 75
79 nigel 87 (6) If the current entry defines a range, compute the last character by adding
80     the offset, and see if the test character is within the range. If it is,
81     we are done.
82 nigel 75
83 nigel 87 (7) Otherwise, set the bottom to one element past the current point and goto
84     (2).
85 nigel 75 */
86    
87 nigel 87 /* End of ucpinternal.h */

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12