"Fossies" - the Fresh Open Source Software Archive

Member "tin-2.4.1/pcre/ucpinternal.h" (28 Aug 2013, 3452 Bytes) of package /linux/misc/tin-2.4.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ucpinternal.h" see the Fossies "Dox" file reference documentation.

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