1 |
/* $Header$ */
|
2 |
|
3 |
/*
|
4 |
* regc_locale.c --
|
5 |
*
|
6 |
* This file contains the Unicode locale specific regexp routines.
|
7 |
* This file is #included by regcomp.c.
|
8 |
*
|
9 |
* Copyright (c) 1998 by Scriptics Corporation.
|
10 |
*
|
11 |
* See the file "license.terms" for information on usage and redistribution
|
12 |
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
13 |
*
|
14 |
* RCS: @(#) $Id: regc_locale.c,v 1.1.1.1 2001/06/13 04:32:00 dtashley Exp $
|
15 |
*/
|
16 |
|
17 |
/* ASCII character-name table */
|
18 |
|
19 |
static struct cname {
|
20 |
char *name;
|
21 |
char code;
|
22 |
} cnames[] = {
|
23 |
{"NUL", '\0'},
|
24 |
{"SOH", '\001'},
|
25 |
{"STX", '\002'},
|
26 |
{"ETX", '\003'},
|
27 |
{"EOT", '\004'},
|
28 |
{"ENQ", '\005'},
|
29 |
{"ACK", '\006'},
|
30 |
{"BEL", '\007'},
|
31 |
{"alert", '\007'},
|
32 |
{"BS", '\010'},
|
33 |
{"backspace", '\b'},
|
34 |
{"HT", '\011'},
|
35 |
{"tab", '\t'},
|
36 |
{"LF", '\012'},
|
37 |
{"newline", '\n'},
|
38 |
{"VT", '\013'},
|
39 |
{"vertical-tab", '\v'},
|
40 |
{"FF", '\014'},
|
41 |
{"form-feed", '\f'},
|
42 |
{"CR", '\015'},
|
43 |
{"carriage-return", '\r'},
|
44 |
{"SO", '\016'},
|
45 |
{"SI", '\017'},
|
46 |
{"DLE", '\020'},
|
47 |
{"DC1", '\021'},
|
48 |
{"DC2", '\022'},
|
49 |
{"DC3", '\023'},
|
50 |
{"DC4", '\024'},
|
51 |
{"NAK", '\025'},
|
52 |
{"SYN", '\026'},
|
53 |
{"ETB", '\027'},
|
54 |
{"CAN", '\030'},
|
55 |
{"EM", '\031'},
|
56 |
{"SUB", '\032'},
|
57 |
{"ESC", '\033'},
|
58 |
{"IS4", '\034'},
|
59 |
{"FS", '\034'},
|
60 |
{"IS3", '\035'},
|
61 |
{"GS", '\035'},
|
62 |
{"IS2", '\036'},
|
63 |
{"RS", '\036'},
|
64 |
{"IS1", '\037'},
|
65 |
{"US", '\037'},
|
66 |
{"space", ' '},
|
67 |
{"exclamation-mark", '!'},
|
68 |
{"quotation-mark", '"'},
|
69 |
{"number-sign", '#'},
|
70 |
{"dollar-sign", '$'},
|
71 |
{"percent-sign", '%'},
|
72 |
{"ampersand", '&'},
|
73 |
{"apostrophe", '\''},
|
74 |
{"left-parenthesis", '('},
|
75 |
{"right-parenthesis", ')'},
|
76 |
{"asterisk", '*'},
|
77 |
{"plus-sign", '+'},
|
78 |
{"comma", ','},
|
79 |
{"hyphen", '-'},
|
80 |
{"hyphen-minus", '-'},
|
81 |
{"period", '.'},
|
82 |
{"full-stop", '.'},
|
83 |
{"slash", '/'},
|
84 |
{"solidus", '/'},
|
85 |
{"zero", '0'},
|
86 |
{"one", '1'},
|
87 |
{"two", '2'},
|
88 |
{"three", '3'},
|
89 |
{"four", '4'},
|
90 |
{"five", '5'},
|
91 |
{"six", '6'},
|
92 |
{"seven", '7'},
|
93 |
{"eight", '8'},
|
94 |
{"nine", '9'},
|
95 |
{"colon", ':'},
|
96 |
{"semicolon", ';'},
|
97 |
{"less-than-sign", '<'},
|
98 |
{"equals-sign", '='},
|
99 |
{"greater-than-sign", '>'},
|
100 |
{"question-mark", '?'},
|
101 |
{"commercial-at", '@'},
|
102 |
{"left-square-bracket", '['},
|
103 |
{"backslash", '\\'},
|
104 |
{"reverse-solidus", '\\'},
|
105 |
{"right-square-bracket", ']'},
|
106 |
{"circumflex", '^'},
|
107 |
{"circumflex-accent", '^'},
|
108 |
{"underscore", '_'},
|
109 |
{"low-line", '_'},
|
110 |
{"grave-accent", '`'},
|
111 |
{"left-brace", '{'},
|
112 |
{"left-curly-bracket", '{'},
|
113 |
{"vertical-line", '|'},
|
114 |
{"right-brace", '}'},
|
115 |
{"right-curly-bracket", '}'},
|
116 |
{"tilde", '~'},
|
117 |
{"DEL", '\177'},
|
118 |
{NULL, 0}
|
119 |
};
|
120 |
|
121 |
/* Unicode character-class tables */
|
122 |
|
123 |
typedef struct crange {
|
124 |
chr start;
|
125 |
chr end;
|
126 |
} crange;
|
127 |
|
128 |
/* Unicode: (Alphabetic) */
|
129 |
|
130 |
static crange alphaRangeTable[] = {
|
131 |
{0x0041, 0x005a}, {0x0061, 0x007a}, {0x00c0, 0x00d6}, {0x00d8, 0x00f6},
|
132 |
{0x00f8, 0x01f5}, {0x01fa, 0x0217}, {0x0250, 0x02a8}, {0x02b0, 0x02b8},
|
133 |
{0x02bb, 0x02c1}, {0x02e0, 0x02e4}, {0x0388, 0x038a}, {0x038e, 0x03a1},
|
134 |
{0x03a3, 0x03ce}, {0x03d0, 0x03d6}, {0x03e2, 0x03f3}, {0x0401, 0x040c},
|
135 |
{0x040e, 0x044f}, {0x0451, 0x045c}, {0x045e, 0x0481}, {0x0490, 0x04c4},
|
136 |
{0x04d0, 0x04eb}, {0x04ee, 0x04f5}, {0x0531, 0x0556}, {0x0561, 0x0587},
|
137 |
{0x05d0, 0x05ea}, {0x05f0, 0x05f2}, {0x0621, 0x063a}, {0x0640, 0x064a},
|
138 |
{0x0671, 0x06b7}, {0x06ba, 0x06be}, {0x06c0, 0x06ce}, {0x06d0, 0x06d3},
|
139 |
{0x0905, 0x0939}, {0x0958, 0x0961}, {0x0985, 0x098c}, {0x0993, 0x09a8},
|
140 |
{0x09aa, 0x09b0}, {0x09b6, 0x09b9}, {0x09df, 0x09e1}, {0x0a05, 0x0a0a},
|
141 |
{0x0a13, 0x0a28}, {0x0a2a, 0x0a30}, {0x0a59, 0x0a5c}, {0x0a72, 0x0a74},
|
142 |
{0x0a85, 0x0a8b}, {0x0a8f, 0x0a91}, {0x0a93, 0x0aa8}, {0x0aaa, 0x0ab0},
|
143 |
{0x0ab5, 0x0ab9}, {0x0b05, 0x0b0c}, {0x0b13, 0x0b28}, {0x0b2a, 0x0b30},
|
144 |
{0x0b36, 0x0b39}, {0x0b5f, 0x0b61}, {0x0b85, 0x0b8a}, {0x0b8e, 0x0b90},
|
145 |
{0x0b92, 0x0b95}, {0x0ba8, 0x0baa}, {0x0bae, 0x0bb5}, {0x0bb7, 0x0bb9},
|
146 |
{0x0c05, 0x0c0c}, {0x0c0e, 0x0c10}, {0x0c12, 0x0c28}, {0x0c2a, 0x0c33},
|
147 |
{0x0c35, 0x0c39}, {0x0c85, 0x0c8c}, {0x0c8e, 0x0c90}, {0x0c92, 0x0ca8},
|
148 |
{0x0caa, 0x0cb3}, {0x0cb5, 0x0cb9}, {0x0d05, 0x0d0c}, {0x0d0e, 0x0d10},
|
149 |
{0x0d12, 0x0d28}, {0x0d2a, 0x0d39}, {0x0e01, 0x0e30}, {0x0e40, 0x0e46},
|
150 |
{0x0e94, 0x0e97}, {0x0e99, 0x0e9f}, {0x0ea1, 0x0ea3}, {0x0ead, 0x0eb0},
|
151 |
{0x0ec0, 0x0ec4}, {0x0f40, 0x0f47}, {0x0f49, 0x0f69}, {0x0f88, 0x0f8b},
|
152 |
{0x10a0, 0x10c5}, {0x10d0, 0x10f6}, {0x1100, 0x1159}, {0x115f, 0x11a2},
|
153 |
{0x11a8, 0x11f9}, {0x1e00, 0x1e9b}, {0x1ea0, 0x1ef9}, {0x1f00, 0x1f15},
|
154 |
{0x1f18, 0x1f1d}, {0x1f20, 0x1f45}, {0x1f48, 0x1f4d}, {0x1f50, 0x1f57},
|
155 |
{0x1f5f, 0x1f7d}, {0x1f80, 0x1fb4}, {0x1fb6, 0x1fbc}, {0x1fc2, 0x1fc4},
|
156 |
{0x1fc6, 0x1fcc}, {0x1fd0, 0x1fd3}, {0x1fd6, 0x1fdb}, {0x1fe0, 0x1fec},
|
157 |
{0x1ff2, 0x1ff4}, {0x1ff6, 0x1ffc}, {0x210a, 0x2113}, {0x2118, 0x211d},
|
158 |
{0x212a, 0x2131}, {0x2133, 0x2138}, {0x3031, 0x3035}, {0x3041, 0x3094},
|
159 |
{0x30a1, 0x30fa}, {0x30fc, 0x30fe}, {0x3105, 0x312c}, {0x3131, 0x318e},
|
160 |
{0x4e00, 0x9fa5}, {0xac00, 0xd7a3}, {0xf900, 0xfa2d}, {0xfb00, 0xfb06},
|
161 |
{0xfb13, 0xfb17}, {0xfb1f, 0xfb28}, {0xfb2a, 0xfb36}, {0xfb38, 0xfb3c},
|
162 |
{0xfb46, 0xfbb1}, {0xfbd3, 0xfd3d}, {0xfd50, 0xfd8f}, {0xfd92, 0xfdc7},
|
163 |
{0xfdf0, 0xfdfb}, {0xfe70, 0xfe72}, {0xfe76, 0xfefc}, {0xff21, 0xff3a},
|
164 |
{0xff41, 0xff5a}, {0xff66, 0xffbe}, {0xffc2, 0xffc7}, {0xffca, 0xffcf},
|
165 |
{0xffd2, 0xffd7}, {0xffda, 0xffdc}
|
166 |
};
|
167 |
|
168 |
#define NUM_ALPHA_RANGE (sizeof(alphaRangeTable)/sizeof(crange))
|
169 |
|
170 |
static chr alphaCharTable[] = {
|
171 |
0x00aa, 0x00b5, 0x00ba, 0x02d0, 0x02d1, 0x037a, 0x0386, 0x038c, 0x03da,
|
172 |
0x03dc, 0x03de, 0x03e0, 0x04c7, 0x04c8, 0x04cb, 0x04cc, 0x04f8, 0x04f9,
|
173 |
0x0559, 0x06d5, 0x06e5, 0x06e6, 0x093d, 0x0950, 0x098f, 0x0990, 0x09b2,
|
174 |
0x09dc, 0x09dd, 0x09f0, 0x09f1, 0x0a0f, 0x0a10, 0x0a32, 0x0a33, 0x0a35,
|
175 |
0x0a36, 0x0a38, 0x0a39, 0x0a5e, 0x0a8d, 0x0ab2, 0x0ab3, 0x0abd, 0x0ad0,
|
176 |
0x0ae0, 0x0b0f, 0x0b10, 0x0b32, 0x0b33, 0x0b3d, 0x0b5c, 0x0b5d, 0x0b99,
|
177 |
0x0b9a, 0x0b9c, 0x0b9e, 0x0b9f, 0x0ba3, 0x0ba4, 0x0c60, 0x0c61, 0x0cde,
|
178 |
0x0ce0, 0x0ce1, 0x0d60, 0x0d61, 0x0e32, 0x0e33, 0x0e81, 0x0e82, 0x0e84,
|
179 |
0x0e87, 0x0e88, 0x0e8a, 0x0e8d, 0x0ea5, 0x0ea7, 0x0eaa, 0x0eab, 0x0eb2,
|
180 |
0x0eb3, 0x0ebd, 0x0ec6, 0x0edc, 0x0edd, 0x0f00, 0x1f59, 0x1f5b, 0x1f5d,
|
181 |
0x1fbe, 0x207f, 0x2102, 0x2107, 0x2115, 0x2124, 0x2126, 0x2128, 0x3005,
|
182 |
0x3006, 0x309d, 0x309e, 0xfb3e, 0xfb40, 0xfb41, 0xfb43, 0xfb44, 0xfe74
|
183 |
};
|
184 |
|
185 |
#define NUM_ALPHA_CHAR (sizeof(alphaCharTable)/sizeof(chr))
|
186 |
|
187 |
/* Unicode: (Decimal digit) */
|
188 |
|
189 |
static crange digitRangeTable[] = {
|
190 |
{0x0030, 0x0039}, {0x0660, 0x0669}, {0x06f0, 0x06f9}, {0x0966, 0x096f},
|
191 |
{0x09e6, 0x09ef}, {0x0a66, 0x0a6f}, {0x0ae6, 0x0aef}, {0x0b66, 0x0b6f},
|
192 |
{0x0be7, 0x0bef}, {0x0c66, 0x0c6f}, {0x0ce6, 0x0cef}, {0x0d66, 0x0d6f},
|
193 |
{0x0e50, 0x0e59}, {0x0ed0, 0x0ed9}, {0x0f20, 0x0f29}, {0xff10, 0xff19}
|
194 |
};
|
195 |
|
196 |
#define NUM_DIGIT_RANGE (sizeof(digitRangeTable)/sizeof(crange))
|
197 |
|
198 |
/* Unicode: (Punctuation) */
|
199 |
|
200 |
static crange punctRangeTable[] = {
|
201 |
{0x0021, 0x0023}, {0x0025, 0x002a}, {0x002c, 0x002f}, {0x005b, 0x005d},
|
202 |
{0x055a, 0x055f}, {0x066a, 0x066d}, {0x0f04, 0x0f12}, {0x0f3a, 0x0f3d},
|
203 |
{0x2010, 0x2027}, {0x2030, 0x2043}, {0x3001, 0x3003}, {0x3008, 0x3011},
|
204 |
{0x3014, 0x301f}, {0xfe30, 0xfe44}, {0xfe49, 0xfe52}, {0xfe54, 0xfe61},
|
205 |
{0xff01, 0xff03}, {0xff05, 0xff0a}, {0xff0c, 0xff0f}, {0xff3b, 0xff3d},
|
206 |
{0xff61, 0xff65}
|
207 |
};
|
208 |
|
209 |
#define NUM_PUNCT_RANGE (sizeof(punctRangeTable)/sizeof(crange))
|
210 |
|
211 |
static chr punctCharTable[] = {
|
212 |
0x003a, 0x003b, 0x003f, 0x0040, 0x005f, 0x007b, 0x007d, 0x00a1, 0x00ab,
|
213 |
0x00ad, 0x00b7, 0x00bb, 0x00bf, 0x037e, 0x0387, 0x0589, 0x05be, 0x05c0,
|
214 |
0x05c3, 0x05f3, 0x05f4, 0x060c, 0x061b, 0x061f, 0x06d4, 0x0964, 0x0965,
|
215 |
0x0970, 0x0e5a, 0x0e5b, 0x0f85, 0x10fb, 0x2045, 0x2046, 0x207d, 0x207e,
|
216 |
0x208d, 0x208e, 0x2329, 0x232a, 0x3030, 0x30fb, 0xfd3e, 0xfd3f, 0xfe63,
|
217 |
0xfe68, 0xfe6a, 0xfe6b, 0xff1a, 0xff1b, 0xff1f, 0xff20, 0xff3f, 0xff5b,
|
218 |
0xff5d
|
219 |
};
|
220 |
|
221 |
#define NUM_PUNCT_CHAR (sizeof(punctCharTable)/sizeof(chr))
|
222 |
|
223 |
/* Unicode: (White space) */
|
224 |
|
225 |
static crange spaceRangeTable[] = {
|
226 |
{0x0009, 0x000d}, {0x2000, 0x200b},
|
227 |
};
|
228 |
|
229 |
#define NUM_SPACE_RANGE (sizeof(spaceRangeTable)/sizeof(crange))
|
230 |
|
231 |
static chr spaceCharTable[] = {
|
232 |
0x0020, 0x00a0, 0x2028, 0x2029, 0x3000
|
233 |
};
|
234 |
|
235 |
#define NUM_SPACE_CHAR (sizeof(spaceCharTable)/sizeof(chr))
|
236 |
|
237 |
/* Unicode: lowercase characters */
|
238 |
|
239 |
static crange lowerRangeTable[] = {
|
240 |
{0x0061, 0x007a}, {0x00df, 0x00f6}, {0x00f8, 0x00ff}, {0x017e, 0x0180},
|
241 |
{0x0199, 0x019b}, {0x0250, 0x02a8}, {0x03ac, 0x03ce}, {0x03ef, 0x03f2},
|
242 |
{0x0430, 0x044f}, {0x0451, 0x045c}, {0x0561, 0x0587}, {0x10d0, 0x10f6},
|
243 |
{0x1e95, 0x1e9b}, {0x1f00, 0x1f07}, {0x1f10, 0x1f15}, {0x1f20, 0x1f27},
|
244 |
{0x1f30, 0x1f37}, {0x1f40, 0x1f45}, {0x1f50, 0x1f57}, {0x1f60, 0x1f67},
|
245 |
{0x1f70, 0x1f7d}, {0x1f80, 0x1f87}, {0x1f90, 0x1f97}, {0x1fa0, 0x1fa7},
|
246 |
{0x1fb0, 0x1fb4}, {0x1fc2, 0x1fc4}, {0x1fd0, 0x1fd3}, {0x1fe0, 0x1fe7},
|
247 |
{0x1ff2, 0x1ff4}, {0xfb00, 0xfb06}, {0xfb13, 0xfb17}, {0xff41, 0xff5a}
|
248 |
};
|
249 |
|
250 |
#define NUM_LOWER_RANGE (sizeof(lowerRangeTable)/sizeof(crange))
|
251 |
|
252 |
static chr lowerCharTable[] = {
|
253 |
0x00aa, 0x00b5, 0x00ba, 0x0101, 0x0103, 0x0105, 0x0107, 0x0109, 0x010b,
|
254 |
0x010d, 0x010f, 0x0111, 0x0113, 0x0115, 0x0117, 0x0119, 0x011b, 0x011d,
|
255 |
0x011f, 0x0121, 0x0123, 0x0125, 0x0127, 0x0129, 0x012b, 0x012d, 0x012f,
|
256 |
0x0131, 0x0133, 0x0135, 0x0137, 0x0138, 0x013a, 0x013c, 0x013e, 0x0140,
|
257 |
0x0142, 0x0144, 0x0146, 0x0148, 0x0149, 0x014b, 0x014d, 0x014f, 0x0151,
|
258 |
0x0153, 0x0155, 0x0157, 0x0159, 0x015b, 0x015d, 0x015f, 0x0161, 0x0163,
|
259 |
0x0165, 0x0167, 0x0169, 0x016b, 0x016d, 0x016f, 0x0171, 0x0173, 0x0175,
|
260 |
0x0177, 0x017a, 0x017c, 0x0183, 0x0185, 0x0188, 0x018c, 0x018d, 0x0192,
|
261 |
0x0195, 0x019e, 0x01a1, 0x01a3, 0x01a5, 0x01a8, 0x01ab, 0x01ad, 0x01b0,
|
262 |
0x01b4, 0x01b6, 0x01b9, 0x01ba, 0x01bd, 0x01c6, 0x01c9, 0x01cc, 0x01ce,
|
263 |
0x01d0, 0x01d2, 0x01d4, 0x01d6, 0x01d8, 0x01da, 0x01dc, 0x01dd, 0x01df,
|
264 |
0x01e1, 0x01e3, 0x01e5, 0x01e7, 0x01e9, 0x01eb, 0x01ed, 0x01ef, 0x01f0,
|
265 |
0x01f3, 0x01f5, 0x01fb, 0x01fd, 0x01ff, 0x0201, 0x0203, 0x0205, 0x0207,
|
266 |
0x0209, 0x020b, 0x020d, 0x020f, 0x0211, 0x0213, 0x0215, 0x0217, 0x0390,
|
267 |
0x03d0, 0x03d1, 0x03d5, 0x03d6, 0x03e3, 0x03e5, 0x03e7, 0x03e9, 0x03eb,
|
268 |
0x03ed, 0x045e, 0x045f, 0x0461, 0x0463, 0x0465, 0x0467, 0x0469, 0x046b,
|
269 |
0x046d, 0x046f, 0x0471, 0x0473, 0x0475, 0x0477, 0x0479, 0x047b, 0x047d,
|
270 |
0x047f, 0x0481, 0x0491, 0x0493, 0x0495, 0x0497, 0x0499, 0x049b, 0x049d,
|
271 |
0x049f, 0x04a1, 0x04a3, 0x04a5, 0x04a7, 0x04a9, 0x04ab, 0x04ad, 0x04af,
|
272 |
0x04b1, 0x04b3, 0x04b5, 0x04b7, 0x04b9, 0x04bb, 0x04bd, 0x04bf, 0x04c2,
|
273 |
0x04c4, 0x04c8, 0x04cc, 0x04d1, 0x04d3, 0x04d5, 0x04d7, 0x04d9, 0x04db,
|
274 |
0x04dd, 0x04df, 0x04e1, 0x04e3, 0x04e5, 0x04e7, 0x04e9, 0x04eb, 0x04ef,
|
275 |
0x04f1, 0x04f3, 0x04f5, 0x04f9, 0x1e01, 0x1e03, 0x1e05, 0x1e07, 0x1e09,
|
276 |
0x1e0b, 0x1e0d, 0x1e0f, 0x1e11, 0x1e13, 0x1e15, 0x1e17, 0x1e19, 0x1e1b,
|
277 |
0x1e1d, 0x1e1f, 0x1e21, 0x1e23, 0x1e25, 0x1e27, 0x1e29, 0x1e2b, 0x1e2d,
|
278 |
0x1e2f, 0x1e31, 0x1e33, 0x1e35, 0x1e37, 0x1e39, 0x1e3b, 0x1e3d, 0x1e3f,
|
279 |
0x1e41, 0x1e43, 0x1e45, 0x1e47, 0x1e49, 0x1e4b, 0x1e4d, 0x1e4f, 0x1e51,
|
280 |
0x1e53, 0x1e55, 0x1e57, 0x1e59, 0x1e5b, 0x1e5d, 0x1e5f, 0x1e61, 0x1e63,
|
281 |
0x1e65, 0x1e67, 0x1e69, 0x1e6b, 0x1e6d, 0x1e6f, 0x1e71, 0x1e73, 0x1e75,
|
282 |
0x1e77, 0x1e79, 0x1e7b, 0x1e7d, 0x1e7f, 0x1e81, 0x1e83, 0x1e85, 0x1e87,
|
283 |
0x1e89, 0x1e8b, 0x1e8d, 0x1e8f, 0x1e91, 0x1e93, 0x1ea1, 0x1ea3, 0x1ea5,
|
284 |
0x1ea7, 0x1ea9, 0x1eab, 0x1ead, 0x1eaf, 0x1eb1, 0x1eb3, 0x1eb5, 0x1eb7,
|
285 |
0x1eb9, 0x1ebb, 0x1ebd, 0x1ebf, 0x1ec1, 0x1ec3, 0x1ec5, 0x1ec7, 0x1ec9,
|
286 |
0x1ecb, 0x1ecd, 0x1ecf, 0x1ed1, 0x1ed3, 0x1ed5, 0x1ed7, 0x1ed9, 0x1edb,
|
287 |
0x1edd, 0x1edf, 0x1ee1, 0x1ee3, 0x1ee5, 0x1ee7, 0x1ee9, 0x1eeb, 0x1eed,
|
288 |
0x1eef, 0x1ef1, 0x1ef3, 0x1ef5, 0x1ef7, 0x1ef9, 0x1fb6, 0x1fb7, 0x1fbe,
|
289 |
0x1fc6, 0x1fc7, 0x1fd6, 0x1fd7, 0x1ff6, 0x1ff7, 0x207f, 0x210a, 0x210e,
|
290 |
0x210f, 0x2113, 0x2118, 0x212e, 0x212f, 0x2134
|
291 |
};
|
292 |
|
293 |
#define NUM_LOWER_CHAR (sizeof(lowerCharTable)/sizeof(chr))
|
294 |
|
295 |
/* Unicode: uppercase characters */
|
296 |
|
297 |
static crange upperRangeTable[] = {
|
298 |
{0x0041, 0x005a}, {0x00c0, 0x00d6}, {0x00d8, 0x00de}, {0x0189, 0x018b},
|
299 |
{0x018e, 0x0191}, {0x0196, 0x0198}, {0x01b1, 0x01b3}, {0x0388, 0x038a},
|
300 |
{0x0391, 0x03a1}, {0x03a3, 0x03ab}, {0x03d2, 0x03d4}, {0x0401, 0x040c},
|
301 |
{0x040e, 0x042f}, {0x0531, 0x0556}, {0x10a0, 0x10c5}, {0x1f08, 0x1f0f},
|
302 |
{0x1f18, 0x1f1d}, {0x1f28, 0x1f2f}, {0x1f38, 0x1f3f}, {0x1f48, 0x1f4d},
|
303 |
{0x1f68, 0x1f6f}, {0x1f88, 0x1f8f}, {0x1f98, 0x1f9f}, {0x1fa8, 0x1faf},
|
304 |
{0x1fb8, 0x1fbc}, {0x1fc8, 0x1fcc}, {0x1fd8, 0x1fdb}, {0x1fe8, 0x1fec},
|
305 |
{0x1ff8, 0x1ffc}, {0x210b, 0x210d}, {0x2110, 0x2112}, {0x2119, 0x211d},
|
306 |
{0x212a, 0x212d}, {0xff21, 0xff3a}
|
307 |
};
|
308 |
|
309 |
#define NUM_UPPER_RANGE (sizeof(upperRangeTable)/sizeof(crange))
|
310 |
|
311 |
static chr upperCharTable[] = {
|
312 |
0x0100, 0x0102, 0x0104, 0x0106, 0x0108, 0x010a, 0x010c, 0x010e, 0x0110,
|
313 |
0x0112, 0x0114, 0x0116, 0x0118, 0x011a, 0x011c, 0x011e, 0x0120, 0x0122,
|
314 |
0x0124, 0x0126, 0x0128, 0x012a, 0x012c, 0x012e, 0x0130, 0x0132, 0x0134,
|
315 |
0x0136, 0x0139, 0x013b, 0x013d, 0x013f, 0x0141, 0x0143, 0x0145, 0x0147,
|
316 |
0x014a, 0x014c, 0x014e, 0x0150, 0x0152, 0x0154, 0x0156, 0x0158, 0x015a,
|
317 |
0x015c, 0x015e, 0x0160, 0x0162, 0x0164, 0x0166, 0x0168, 0x016a, 0x016c,
|
318 |
0x016e, 0x0170, 0x0172, 0x0174, 0x0176, 0x0178, 0x0179, 0x017b, 0x017d,
|
319 |
0x0181, 0x0182, 0x0184, 0x0186, 0x0187, 0x0193, 0x0194, 0x019c, 0x019d,
|
320 |
0x019f, 0x01a0, 0x01a2, 0x01a4, 0x01a6, 0x01a7, 0x01a9, 0x01ac, 0x01ae,
|
321 |
0x01af, 0x01b5, 0x01b7, 0x01b8, 0x01bc, 0x01c4, 0x01c7, 0x01ca, 0x01cd,
|
322 |
0x01cf, 0x01d1, 0x01d3, 0x01d5, 0x01d7, 0x01d9, 0x01db, 0x01de, 0x01e0,
|
323 |
0x01e2, 0x01e4, 0x01e6, 0x01e8, 0x01ea, 0x01ec, 0x01ee, 0x01f1, 0x01f4,
|
324 |
0x01fa, 0x01fc, 0x01fe, 0x0200, 0x0202, 0x0204, 0x0206, 0x0208, 0x020a,
|
325 |
0x020c, 0x020e, 0x0210, 0x0212, 0x0214, 0x0216, 0x0386, 0x038c, 0x038e,
|
326 |
0x038f, 0x03da, 0x03dc, 0x03de, 0x03e0, 0x03e2, 0x03e4, 0x03e6, 0x03e8,
|
327 |
0x03ea, 0x03ec, 0x03ee, 0x0460, 0x0462, 0x0464, 0x0466, 0x0468, 0x046a,
|
328 |
0x046c, 0x046e, 0x0470, 0x0472, 0x0474, 0x0476, 0x0478, 0x047a, 0x047c,
|
329 |
0x047e, 0x0480, 0x0490, 0x0492, 0x0494, 0x0496, 0x0498, 0x049a, 0x049c,
|
330 |
0x049e, 0x04a0, 0x04a2, 0x04a4, 0x04a6, 0x04a8, 0x04aa, 0x04ac, 0x04ae,
|
331 |
0x04b0, 0x04b2, 0x04b4, 0x04b6, 0x04b8, 0x04ba, 0x04bc, 0x04be, 0x04c1,
|
332 |
0x04c3, 0x04c7, 0x04cb, 0x04d0, 0x04d2, 0x04d4, 0x04d6, 0x04d8, 0x04da,
|
333 |
0x04dc, 0x04de, 0x04e0, 0x04e2, 0x04e4, 0x04e6, 0x04e8, 0x04ea, 0x04ee,
|
334 |
0x04f0, 0x04f2, 0x04f4, 0x04f8, 0x1e00, 0x1e02, 0x1e04, 0x1e06, 0x1e08,
|
335 |
0x1e0a, 0x1e0c, 0x1e0e, 0x1e10, 0x1e12, 0x1e14, 0x1e16, 0x1e18, 0x1e1a,
|
336 |
0x1e1c, 0x1e1e, 0x1e20, 0x1e22, 0x1e24, 0x1e26, 0x1e28, 0x1e2a, 0x1e2c,
|
337 |
0x1e2e, 0x1e30, 0x1e32, 0x1e34, 0x1e36, 0x1e38, 0x1e3a, 0x1e3c, 0x1e3e,
|
338 |
0x1e40, 0x1e42, 0x1e44, 0x1e46, 0x1e48, 0x1e4a, 0x1e4c, 0x1e4e, 0x1e50,
|
339 |
0x1e52, 0x1e54, 0x1e56, 0x1e58, 0x1e5a, 0x1e5c, 0x1e5e, 0x1e60, 0x1e62,
|
340 |
0x1e64, 0x1e66, 0x1e68, 0x1e6a, 0x1e6c, 0x1e6e, 0x1e70, 0x1e72, 0x1e74,
|
341 |
0x1e76, 0x1e78, 0x1e7a, 0x1e7c, 0x1e7e, 0x1e80, 0x1e82, 0x1e84, 0x1e86,
|
342 |
0x1e88, 0x1e8a, 0x1e8c, 0x1e8e, 0x1e90, 0x1e92, 0x1e94, 0x1ea0, 0x1ea2,
|
343 |
0x1ea4, 0x1ea6, 0x1ea8, 0x1eaa, 0x1eac, 0x1eae, 0x1eb0, 0x1eb2, 0x1eb4,
|
344 |
0x1eb6, 0x1eb8, 0x1eba, 0x1ebc, 0x1ebe, 0x1ec0, 0x1ec2, 0x1ec4, 0x1ec6,
|
345 |
0x1ec8, 0x1eca, 0x1ecc, 0x1ece, 0x1ed0, 0x1ed2, 0x1ed4, 0x1ed6, 0x1ed8,
|
346 |
0x1eda, 0x1edc, 0x1ede, 0x1ee0, 0x1ee2, 0x1ee4, 0x1ee6, 0x1ee8, 0x1eea,
|
347 |
0x1eec, 0x1eee, 0x1ef0, 0x1ef2, 0x1ef4, 0x1ef6, 0x1ef8, 0x1f59, 0x1f5b,
|
348 |
0x1f5d, 0x1f5f, 0x2102, 0x2107, 0x2115, 0x2124, 0x2126, 0x2128, 0x2130,
|
349 |
0x2131, 0x2133
|
350 |
};
|
351 |
|
352 |
#define NUM_UPPER_CHAR (sizeof(upperCharTable)/sizeof(chr))
|
353 |
|
354 |
/*
|
355 |
* The graph table includes the set of characters that are Unicode
|
356 |
* print characters excluding space.
|
357 |
*/
|
358 |
|
359 |
static crange graphRangeTable[] = {
|
360 |
{0x0021, 0x007e}, {0x00a0, 0x011f}, {0x0121, 0x01f5}, {0x01fa, 0x0217},
|
361 |
{0x0250, 0x02a8}, {0x02b0, 0x02de}, {0x02e0, 0x02e9}, {0x0300, 0x031f},
|
362 |
{0x0321, 0x0345}, {0x0384, 0x038a}, {0x038e, 0x03a1}, {0x03a3, 0x03ce},
|
363 |
{0x03d0, 0x03d6}, {0x03e2, 0x03f3}, {0x0401, 0x040c}, {0x040e, 0x041f},
|
364 |
{0x0421, 0x044f}, {0x0451, 0x045c}, {0x045e, 0x0486}, {0x0490, 0x04c4},
|
365 |
{0x04d0, 0x04eb}, {0x04ee, 0x04f5}, {0x0531, 0x0556}, {0x0559, 0x055f},
|
366 |
{0x0561, 0x0587}, {0x0591, 0x05a1}, {0x05a3, 0x05b9}, {0x05bb, 0x05c4},
|
367 |
{0x05d0, 0x05ea}, {0x05f0, 0x05f4}, {0x0621, 0x063a}, {0x0640, 0x0652},
|
368 |
{0x0660, 0x066d}, {0x0670, 0x06b7}, {0x06ba, 0x06be}, {0x06c0, 0x06ce},
|
369 |
{0x06d0, 0x06ed}, {0x06f0, 0x06f9}, {0x0901, 0x0903}, {0x0905, 0x091f},
|
370 |
{0x0921, 0x0939}, {0x093c, 0x094d}, {0x0950, 0x0954}, {0x0958, 0x0970},
|
371 |
{0x0981, 0x0983}, {0x0985, 0x098c}, {0x0993, 0x09a8}, {0x09aa, 0x09b0},
|
372 |
{0x09b6, 0x09b9}, {0x09be, 0x09c4}, {0x09cb, 0x09cd}, {0x09df, 0x09e3},
|
373 |
{0x09e6, 0x09fa}, {0x0a05, 0x0a0a}, {0x0a13, 0x0a1f}, {0x0a21, 0x0a28},
|
374 |
{0x0a2a, 0x0a30}, {0x0a3e, 0x0a42}, {0x0a4b, 0x0a4d}, {0x0a59, 0x0a5c},
|
375 |
{0x0a66, 0x0a74}, {0x0a81, 0x0a83}, {0x0a85, 0x0a8b}, {0x0a8f, 0x0a91},
|
376 |
{0x0a93, 0x0aa8}, {0x0aaa, 0x0ab0}, {0x0ab5, 0x0ab9}, {0x0abc, 0x0ac5},
|
377 |
{0x0ac7, 0x0ac9}, {0x0acb, 0x0acd}, {0x0ae6, 0x0aef}, {0x0b01, 0x0b03},
|
378 |
{0x0b05, 0x0b0c}, {0x0b13, 0x0b1f}, {0x0b21, 0x0b28}, {0x0b2a, 0x0b30},
|
379 |
{0x0b36, 0x0b39}, {0x0b3c, 0x0b43}, {0x0b4b, 0x0b4d}, {0x0b5f, 0x0b61},
|
380 |
{0x0b66, 0x0b70}, {0x0b85, 0x0b8a}, {0x0b8e, 0x0b90}, {0x0b92, 0x0b95},
|
381 |
{0x0ba8, 0x0baa}, {0x0bae, 0x0bb5}, {0x0bb7, 0x0bb9}, {0x0bbe, 0x0bc2},
|
382 |
{0x0bc6, 0x0bc8}, {0x0bca, 0x0bcd}, {0x0be7, 0x0bf2}, {0x0c01, 0x0c03},
|
383 |
{0x0c05, 0x0c0c}, {0x0c0e, 0x0c10}, {0x0c12, 0x0c1f}, {0x0c21, 0x0c28},
|
384 |
{0x0c2a, 0x0c33}, {0x0c35, 0x0c39}, {0x0c3e, 0x0c44}, {0x0c46, 0x0c48},
|
385 |
{0x0c4a, 0x0c4d}, {0x0c66, 0x0c6f}, {0x0c85, 0x0c8c}, {0x0c8e, 0x0c90},
|
386 |
{0x0c92, 0x0ca8}, {0x0caa, 0x0cb3}, {0x0cb5, 0x0cb9}, {0x0cbe, 0x0cc4},
|
387 |
{0x0cc6, 0x0cc8}, {0x0cca, 0x0ccd}, {0x0ce6, 0x0cef}, {0x0d05, 0x0d0c},
|
388 |
{0x0d0e, 0x0d10}, {0x0d12, 0x0d1f}, {0x0d21, 0x0d28}, {0x0d2a, 0x0d39},
|
389 |
{0x0d3e, 0x0d43}, {0x0d46, 0x0d48}, {0x0d4a, 0x0d4d}, {0x0d66, 0x0d6f},
|
390 |
{0x0e01, 0x0e1f}, {0x0e21, 0x0e3a}, {0x0e3f, 0x0e5b}, {0x0e94, 0x0e97},
|
391 |
{0x0e99, 0x0e9f}, {0x0ea1, 0x0ea3}, {0x0ead, 0x0eb9}, {0x0ebb, 0x0ebd},
|
392 |
{0x0ec0, 0x0ec4}, {0x0ec8, 0x0ecd}, {0x0ed0, 0x0ed9}, {0x0f00, 0x0f1f},
|
393 |
{0x0f21, 0x0f47}, {0x0f49, 0x0f69}, {0x0f71, 0x0f8b}, {0x0f90, 0x0f95},
|
394 |
{0x0f99, 0x0fad}, {0x0fb1, 0x0fb7}, {0x10a0, 0x10c5}, {0x10d0, 0x10f6},
|
395 |
{0x1100, 0x111f}, {0x1121, 0x1159}, {0x115f, 0x11a2}, {0x11a8, 0x11f9},
|
396 |
{0x1e00, 0x1e1f}, {0x1e21, 0x1e9b}, {0x1ea0, 0x1ef9}, {0x1f00, 0x1f15},
|
397 |
{0x1f18, 0x1f1d}, {0x1f21, 0x1f45}, {0x1f48, 0x1f4d}, {0x1f50, 0x1f57},
|
398 |
{0x1f5f, 0x1f7d}, {0x1f80, 0x1fb4}, {0x1fb6, 0x1fc4}, {0x1fc6, 0x1fd3},
|
399 |
{0x1fd6, 0x1fdb}, {0x1fdd, 0x1fef}, {0x1ff2, 0x1ff4}, {0x1ff6, 0x1ffe},
|
400 |
{0x2000, 0x200b}, {0x2010, 0x201f}, {0x2021, 0x2029}, {0x2030, 0x2046},
|
401 |
{0x2074, 0x208e}, {0x20a0, 0x20ac}, {0x20d0, 0x20e1}, {0x2100, 0x211f},
|
402 |
{0x2121, 0x2138}, {0x2153, 0x2182}, {0x2190, 0x21ea}, {0x2200, 0x221f},
|
403 |
{0x2221, 0x22f1}, {0x2302, 0x231f}, {0x2321, 0x237a}, {0x2400, 0x241f},
|
404 |
{0x2421, 0x2424}, {0x2440, 0x244a}, {0x2460, 0x24ea}, {0x2500, 0x251f},
|
405 |
{0x2521, 0x2595}, {0x25a0, 0x25ef}, {0x2600, 0x2613}, {0x261a, 0x261f},
|
406 |
{0x2621, 0x266f}, {0x2701, 0x2704}, {0x2706, 0x2709}, {0x270c, 0x271f},
|
407 |
{0x2721, 0x2727}, {0x2729, 0x274b}, {0x274f, 0x2752}, {0x2758, 0x275e},
|
408 |
{0x2761, 0x2767}, {0x2776, 0x2794}, {0x2798, 0x27af}, {0x27b1, 0x27be},
|
409 |
{0x3000, 0x301f}, {0x3021, 0x3037}, {0x3041, 0x3094}, {0x3099, 0x309e},
|
410 |
{0x30a1, 0x30fe}, {0x3105, 0x311f}, {0x3121, 0x312c}, {0x3131, 0x318e},
|
411 |
{0x3190, 0x319f}, {0x3200, 0x321c}, {0x3221, 0x3243}, {0x3260, 0x327b},
|
412 |
{0x327f, 0x32b0}, {0x32c0, 0x32cb}, {0x32d0, 0x32fe}, {0x3300, 0x331f},
|
413 |
{0x3321, 0x3376}, {0x337b, 0x33dd}, {0x33e0, 0x33fe}, {0x4e00, 0x4e1f},
|
414 |
{0x4e21, 0x4f1f}, {0x4f21, 0x501f}, {0x5021, 0x511f}, {0x5121, 0x521f},
|
415 |
{0x5221, 0x531f}, {0x5321, 0x541f}, {0x5421, 0x551f}, {0x5521, 0x561f},
|
416 |
{0x5621, 0x571f}, {0x5721, 0x581f}, {0x5821, 0x591f}, {0x5921, 0x5a1f},
|
417 |
{0x5a21, 0x5b1f}, {0x5b21, 0x5c1f}, {0x5c21, 0x5d1f}, {0x5d21, 0x5e1f},
|
418 |
{0x5e21, 0x5f1f}, {0x5f21, 0x601f}, {0x6021, 0x611f}, {0x6121, 0x621f},
|
419 |
{0x6221, 0x631f}, {0x6321, 0x641f}, {0x6421, 0x651f}, {0x6521, 0x661f},
|
420 |
{0x6621, 0x671f}, {0x6721, 0x681f}, {0x6821, 0x691f}, {0x6921, 0x6a1f},
|
421 |
{0x6a21, 0x6b1f}, {0x6b21, 0x6c1f}, {0x6c21, 0x6d1f}, {0x6d21, 0x6e1f},
|
422 |
{0x6e21, 0x6f1f}, {0x6f21, 0x701f}, {0x7021, 0x711f}, {0x7121, 0x721f},
|
423 |
{0x7221, 0x731f}, {0x7321, 0x741f}, {0x7421, 0x751f}, {0x7521, 0x761f},
|
424 |
{0x7621, 0x771f}, {0x7721, 0x781f}, {0x7821, 0x791f}, {0x7921, 0x7a1f},
|
425 |
{0x7a21, 0x7b1f}, {0x7b21, 0x7c1f}, {0x7c21, 0x7d1f}, {0x7d21, 0x7e1f},
|
426 |
{0x7e21, 0x7f1f}, {0x7f21, 0x801f}, {0x8021, 0x811f}, {0x8121, 0x821f},
|
427 |
{0x8221, 0x831f}, {0x8321, 0x841f}, {0x8421, 0x851f}, {0x8521, 0x861f},
|
428 |
{0x8621, 0x871f}, {0x8721, 0x881f}, {0x8821, 0x891f}, {0x8921, 0x8a1f},
|
429 |
{0x8a21, 0x8b1f}, {0x8b21, 0x8c1f}, {0x8c21, 0x8d1f}, {0x8d21, 0x8e1f},
|
430 |
{0x8e21, 0x8f1f}, {0x8f21, 0x901f}, {0x9021, 0x911f}, {0x9121, 0x921f},
|
431 |
{0x9221, 0x931f}, {0x9321, 0x941f}, {0x9421, 0x951f}, {0x9521, 0x961f},
|
432 |
{0x9621, 0x971f}, {0x9721, 0x981f}, {0x9821, 0x991f}, {0x9921, 0x9a1f},
|
433 |
{0x9a21, 0x9b1f}, {0x9b21, 0x9c1f}, {0x9c21, 0x9d1f}, {0x9d21, 0x9e1f},
|
434 |
{0x9e21, 0x9f1f}, {0x9f21, 0x9fa5}, {0xac00, 0xac1f}, {0xac21, 0xad1f},
|
435 |
{0xad21, 0xae1f}, {0xae21, 0xaf1f}, {0xaf21, 0xb01f}, {0xb021, 0xb11f},
|
436 |
{0xb121, 0xb21f}, {0xb221, 0xb31f}, {0xb321, 0xb41f}, {0xb421, 0xb51f},
|
437 |
{0xb521, 0xb61f}, {0xb621, 0xb71f}, {0xb721, 0xb81f}, {0xb821, 0xb91f},
|
438 |
{0xb921, 0xba1f}, {0xba21, 0xbb1f}, {0xbb21, 0xbc1f}, {0xbc21, 0xbd1f},
|
439 |
{0xbd21, 0xbe1f}, {0xbe21, 0xbf1f}, {0xbf21, 0xc01f}, {0xc021, 0xc11f},
|
440 |
{0xc121, 0xc21f}, {0xc221, 0xc31f}, {0xc321, 0xc41f}, {0xc421, 0xc51f},
|
441 |
{0xc521, 0xc61f}, {0xc621, 0xc71f}, {0xc721, 0xc81f}, {0xc821, 0xc91f},
|
442 |
{0xc921, 0xca1f}, {0xca21, 0xcb1f}, {0xcb21, 0xcc1f}, {0xcc21, 0xcd1f},
|
443 |
{0xcd21, 0xce1f}, {0xce21, 0xcf1f}, {0xcf21, 0xd01f}, {0xd021, 0xd11f},
|
444 |
{0xd121, 0xd21f}, {0xd221, 0xd31f}, {0xd321, 0xd41f}, {0xd421, 0xd51f},
|
445 |
{0xd521, 0xd61f}, {0xd621, 0xd71f}, {0xd721, 0xd7a3}, {0xf900, 0xf91f},
|
446 |
{0xf921, 0xfa1f}, {0xfa21, 0xfa2d}, {0xfb00, 0xfb06}, {0xfb13, 0xfb17},
|
447 |
{0xfb21, 0xfb36}, {0xfb38, 0xfb3c}, {0xfb46, 0xfbb1}, {0xfbd3, 0xfc1f},
|
448 |
{0xfc21, 0xfd1f}, {0xfd21, 0xfd3f}, {0xfd50, 0xfd8f}, {0xfd92, 0xfdc7},
|
449 |
{0xfdf0, 0xfdfb}, {0xfe21, 0xfe23}, {0xfe30, 0xfe44}, {0xfe49, 0xfe52},
|
450 |
{0xfe54, 0xfe66}, {0xfe68, 0xfe6b}, {0xfe70, 0xfe72}, {0xfe76, 0xfefc},
|
451 |
{0xff01, 0xff1f}, {0xff21, 0xff5e}, {0xff61, 0xffbe}, {0xffc2, 0xffc7},
|
452 |
{0xffca, 0xffcf}, {0xffd2, 0xffd7}, {0xffda, 0xffdc}, {0xffe0, 0xffe6},
|
453 |
{0xffe8, 0xffee}
|
454 |
};
|
455 |
|
456 |
#define NUM_GRAPH_RANGE (sizeof(graphRangeTable)/sizeof(crange))
|
457 |
|
458 |
static chr graphCharTable[] = {
|
459 |
0x0360, 0x0361, 0x0374, 0x0375, 0x037a, 0x037e, 0x038c, 0x03da, 0x03dc,
|
460 |
0x03de, 0x03e0, 0x04c7, 0x04c8, 0x04cb, 0x04cc, 0x04f8, 0x04f9, 0x0589,
|
461 |
0x060c, 0x061b, 0x061f, 0x098f, 0x0990, 0x09b2, 0x09bc, 0x09c7, 0x09c8,
|
462 |
0x09d7, 0x09dc, 0x09dd, 0x0a02, 0x0a0f, 0x0a10, 0x0a32, 0x0a33, 0x0a35,
|
463 |
0x0a36, 0x0a38, 0x0a39, 0x0a3c, 0x0a47, 0x0a48, 0x0a5e, 0x0a8d, 0x0ab2,
|
464 |
0x0ab3, 0x0ad0, 0x0ae0, 0x0b0f, 0x0b10, 0x0b32, 0x0b33, 0x0b47, 0x0b48,
|
465 |
0x0b56, 0x0b57, 0x0b5c, 0x0b5d, 0x0b82, 0x0b83, 0x0b99, 0x0b9a, 0x0b9c,
|
466 |
0x0b9e, 0x0b9f, 0x0ba3, 0x0ba4, 0x0bd7, 0x0c55, 0x0c56, 0x0c60, 0x0c61,
|
467 |
0x0c82, 0x0c83, 0x0cd5, 0x0cd6, 0x0cde, 0x0ce0, 0x0ce1, 0x0d02, 0x0d03,
|
468 |
0x0d57, 0x0d60, 0x0d61, 0x0e81, 0x0e82, 0x0e84, 0x0e87, 0x0e88, 0x0e8a,
|
469 |
0x0e8d, 0x0ea5, 0x0ea7, 0x0eaa, 0x0eab, 0x0ec6, 0x0edc, 0x0edd, 0x0f97,
|
470 |
0x0fb9, 0x10fb, 0x1f59, 0x1f5b, 0x1f5d, 0x2070, 0x2300, 0x274d, 0x2756,
|
471 |
0x303f, 0xfb1e, 0xfb1f, 0xfb3e, 0xfb40, 0xfb41, 0xfb43, 0xfb44, 0xfe74,
|
472 |
0xfffc, 0xfffd
|
473 |
};
|
474 |
|
475 |
#define NUM_GRAPH_CHAR (sizeof(graphCharTable)/sizeof(chr))
|
476 |
|
477 |
|
478 |
#define CH NOCELT
|
479 |
|
480 |
/*
|
481 |
- nmcces - how many distinct MCCEs are there?
|
482 |
^ static int nmcces(struct vars *);
|
483 |
*/
|
484 |
static int
|
485 |
nmcces(v)
|
486 |
struct vars *v;
|
487 |
{
|
488 |
return 0;
|
489 |
}
|
490 |
|
491 |
/*
|
492 |
- nleaders - how many chrs can be first chrs of MCCEs?
|
493 |
^ static int nleaders(struct vars *);
|
494 |
*/
|
495 |
static int
|
496 |
nleaders(v)
|
497 |
struct vars *v;
|
498 |
{
|
499 |
return 0;
|
500 |
}
|
501 |
|
502 |
/*
|
503 |
- allmcces - return a cvec with all the MCCEs of the locale
|
504 |
^ static struct cvec *allmcces(struct vars *, struct cvec *);
|
505 |
*/
|
506 |
static struct cvec *
|
507 |
allmcces(v, cv)
|
508 |
struct vars *v;
|
509 |
struct cvec *cv; /* this is supposed to have enough room */
|
510 |
{
|
511 |
return clearcvec(cv);
|
512 |
}
|
513 |
|
514 |
/*
|
515 |
- element - map collating-element name to celt
|
516 |
^ static celt element(struct vars *, chr *, chr *);
|
517 |
*/
|
518 |
static celt
|
519 |
element(v, startp, endp)
|
520 |
struct vars *v;
|
521 |
chr *startp; /* points to start of name */
|
522 |
chr *endp; /* points just past end of name */
|
523 |
{
|
524 |
struct cname *cn;
|
525 |
size_t len;
|
526 |
Tcl_DString ds;
|
527 |
char *np;
|
528 |
|
529 |
/* generic: one-chr names stand for themselves */
|
530 |
assert(startp < endp);
|
531 |
len = endp - startp;
|
532 |
if (len == 1)
|
533 |
return *startp;
|
534 |
|
535 |
NOTE(REG_ULOCALE);
|
536 |
|
537 |
/* search table */
|
538 |
Tcl_DStringInit(&ds);
|
539 |
np = Tcl_UniCharToUtfDString(startp, (int)len, &ds);
|
540 |
for (cn = cnames; cn->name != NULL; cn++)
|
541 |
if (strlen(cn->name) == len && strncmp(cn->name, np, len) == 0)
|
542 |
break; /* NOTE BREAK OUT */
|
543 |
Tcl_DStringFree(&ds);
|
544 |
if (cn->name != NULL)
|
545 |
return CHR(cn->code);
|
546 |
|
547 |
/* couldn't find it */
|
548 |
ERR(REG_ECOLLATE);
|
549 |
return 0;
|
550 |
}
|
551 |
|
552 |
/*
|
553 |
- range - supply cvec for a range, including legality check
|
554 |
^ static struct cvec *range(struct vars *, celt, celt, int);
|
555 |
*/
|
556 |
static struct cvec *
|
557 |
range(v, a, b, cases)
|
558 |
struct vars *v;
|
559 |
celt a;
|
560 |
celt b; /* might equal a */
|
561 |
int cases; /* case-independent? */
|
562 |
{
|
563 |
int nchrs;
|
564 |
struct cvec *cv;
|
565 |
celt c, lc, uc, tc;
|
566 |
|
567 |
if (a != b && !before(a, b)) {
|
568 |
ERR(REG_ERANGE);
|
569 |
return NULL;
|
570 |
}
|
571 |
|
572 |
if (!cases) { /* easy version */
|
573 |
cv = getcvec(v, 0, 1, 0);
|
574 |
NOERRN();
|
575 |
addrange(cv, a, b);
|
576 |
return cv;
|
577 |
}
|
578 |
|
579 |
/*
|
580 |
* When case-independent, it's hard to decide when cvec ranges are
|
581 |
* usable, so for now at least, we won't try. We allocate enough
|
582 |
* space for two case variants plus a little extra for the two
|
583 |
* title case variants.
|
584 |
*/
|
585 |
|
586 |
nchrs = (b - a + 1)*2 + 4;
|
587 |
|
588 |
cv = getcvec(v, nchrs, 0, 0);
|
589 |
NOERRN();
|
590 |
|
591 |
for (c = a; c <= b; c++) {
|
592 |
addchr(cv, c);
|
593 |
lc = Tcl_UniCharToLower((chr)c);
|
594 |
uc = Tcl_UniCharToUpper((chr)c);
|
595 |
tc = Tcl_UniCharToTitle((chr)c);
|
596 |
if (c != lc) {
|
597 |
addchr(cv, lc);
|
598 |
}
|
599 |
if (c != uc) {
|
600 |
addchr(cv, uc);
|
601 |
}
|
602 |
if (c != tc && tc != uc) {
|
603 |
addchr(cv, tc);
|
604 |
}
|
605 |
}
|
606 |
|
607 |
return cv;
|
608 |
}
|
609 |
|
610 |
/*
|
611 |
- before - is celt x before celt y, for purposes of range legality?
|
612 |
^ static int before(celt, celt);
|
613 |
*/
|
614 |
static int /* predicate */
|
615 |
before(x, y)
|
616 |
celt x;
|
617 |
celt y;
|
618 |
{
|
619 |
/* trivial because no MCCEs */
|
620 |
if (x < y)
|
621 |
return 1;
|
622 |
return 0;
|
623 |
}
|
624 |
|
625 |
/*
|
626 |
- eclass - supply cvec for an equivalence class
|
627 |
* Must include case counterparts on request.
|
628 |
^ static struct cvec *eclass(struct vars *, celt, int);
|
629 |
*/
|
630 |
static struct cvec *
|
631 |
eclass(v, c, cases)
|
632 |
struct vars *v;
|
633 |
celt c;
|
634 |
int cases; /* all cases? */
|
635 |
{
|
636 |
struct cvec *cv;
|
637 |
|
638 |
/* crude fake equivalence class for testing */
|
639 |
if ((v->cflags®_FAKE) && c == 'x') {
|
640 |
cv = getcvec(v, 4, 0, 0);
|
641 |
addchr(cv, (chr)'x');
|
642 |
addchr(cv, (chr)'y');
|
643 |
if (cases) {
|
644 |
addchr(cv, (chr)'X');
|
645 |
addchr(cv, (chr)'Y');
|
646 |
}
|
647 |
return cv;
|
648 |
}
|
649 |
|
650 |
/* otherwise, none */
|
651 |
if (cases)
|
652 |
return allcases(v, c);
|
653 |
cv = getcvec(v, 1, 0, 0);
|
654 |
assert(cv != NULL);
|
655 |
addchr(cv, (chr)c);
|
656 |
return cv;
|
657 |
}
|
658 |
|
659 |
/*
|
660 |
- cclass - supply cvec for a character class
|
661 |
* Must include case counterparts on request.
|
662 |
^ static struct cvec *cclass(struct vars *, chr *, chr *, int);
|
663 |
*/
|
664 |
static struct cvec *
|
665 |
cclass(v, startp, endp, cases)
|
666 |
struct vars *v;
|
667 |
chr *startp; /* where the name starts */
|
668 |
chr *endp; /* just past the end of the name */
|
669 |
int cases; /* case-independent? */
|
670 |
{
|
671 |
size_t len;
|
672 |
struct cvec *cv = NULL;
|
673 |
Tcl_DString ds;
|
674 |
char *np, **namePtr;
|
675 |
int i, index;
|
676 |
|
677 |
/*
|
678 |
* The following arrays define the valid character class names.
|
679 |
*/
|
680 |
|
681 |
static char *classNames[] = {
|
682 |
"alnum", "alpha", "ascii", "blank", "cntrl", "digit", "graph",
|
683 |
"lower", "print", "punct", "space", "upper", "xdigit", NULL
|
684 |
};
|
685 |
|
686 |
enum classes {
|
687 |
CC_ALNUM, CC_ALPHA, CC_ASCII, CC_BLANK, CC_CNTRL, CC_DIGIT, CC_GRAPH,
|
688 |
CC_LOWER, CC_PRINT, CC_PUNCT, CC_SPACE, CC_UPPER, CC_XDIGIT
|
689 |
};
|
690 |
|
691 |
|
692 |
/*
|
693 |
* Extract the class name
|
694 |
*/
|
695 |
|
696 |
len = endp - startp;
|
697 |
Tcl_DStringInit(&ds);
|
698 |
np = Tcl_UniCharToUtfDString(startp, (int)len, &ds);
|
699 |
|
700 |
/*
|
701 |
* Remap lower and upper to alpha if the match is case insensitive.
|
702 |
*/
|
703 |
|
704 |
if (cases && len == 5 && (strncmp("lower", np, 5) == 0
|
705 |
|| strncmp("upper", np, 5) == 0)) {
|
706 |
np = "alpha";
|
707 |
}
|
708 |
|
709 |
/*
|
710 |
* Map the name to the corresponding enumerated value.
|
711 |
*/
|
712 |
|
713 |
index = -1;
|
714 |
for (namePtr = classNames, i = 0; *namePtr != NULL; namePtr++, i++) {
|
715 |
if ((strlen(*namePtr) == len) && (strncmp(*namePtr, np, len) == 0)) {
|
716 |
index = i;
|
717 |
break;
|
718 |
}
|
719 |
}
|
720 |
Tcl_DStringInit(&ds);
|
721 |
if (index == -1) {
|
722 |
ERR(REG_ECTYPE);
|
723 |
return NULL;
|
724 |
}
|
725 |
|
726 |
/*
|
727 |
* Now compute the character class contents.
|
728 |
*/
|
729 |
|
730 |
switch((enum classes) index) {
|
731 |
case CC_PRINT:
|
732 |
case CC_ALNUM:
|
733 |
cv = getcvec(v, NUM_ALPHA_CHAR,
|
734 |
NUM_DIGIT_RANGE + NUM_ALPHA_RANGE, 0);
|
735 |
if (cv) {
|
736 |
for (i = 0; i < NUM_ALPHA_CHAR; i++) {
|
737 |
addchr(cv, alphaCharTable[i]);
|
738 |
}
|
739 |
for (i = 0; i < NUM_ALPHA_RANGE; i++) {
|
740 |
addrange(cv, alphaRangeTable[i].start,
|
741 |
alphaRangeTable[i].end);
|
742 |
}
|
743 |
for (i = 0; i < NUM_DIGIT_RANGE; i++) {
|
744 |
addrange(cv, digitRangeTable[i].start,
|
745 |
digitRangeTable[i].end);
|
746 |
}
|
747 |
}
|
748 |
break;
|
749 |
case CC_ALPHA:
|
750 |
cv = getcvec(v, NUM_ALPHA_CHAR, NUM_ALPHA_RANGE, 0);
|
751 |
if (cv) {
|
752 |
for (i = 0; i < NUM_ALPHA_RANGE; i++) {
|
753 |
addrange(cv, alphaRangeTable[i].start,
|
754 |
alphaRangeTable[i].end);
|
755 |
}
|
756 |
for (i = 0; i < NUM_ALPHA_CHAR; i++) {
|
757 |
addchr(cv, alphaCharTable[i]);
|
758 |
}
|
759 |
}
|
760 |
break;
|
761 |
case CC_ASCII:
|
762 |
cv = getcvec(v, 0, 1, 0);
|
763 |
if (cv) {
|
764 |
addrange(cv, 0, 0x7f);
|
765 |
}
|
766 |
break;
|
767 |
case CC_BLANK:
|
768 |
cv = getcvec(v, 2, 0, 0);
|
769 |
addchr(cv, '\t');
|
770 |
addchr(cv, ' ');
|
771 |
break;
|
772 |
case CC_CNTRL:
|
773 |
cv = getcvec(v, 0, 2, 0);
|
774 |
addrange(cv, 0x0, 0x1f);
|
775 |
addrange(cv, 0x7f, 0x9f);
|
776 |
break;
|
777 |
case CC_DIGIT:
|
778 |
cv = getcvec(v, 0, NUM_DIGIT_RANGE, 0);
|
779 |
if (cv) {
|
780 |
for (i = 0; i < NUM_DIGIT_RANGE; i++) {
|
781 |
addrange(cv, digitRangeTable[i].start,
|
782 |
digitRangeTable[i].end);
|
783 |
}
|
784 |
}
|
785 |
break;
|
786 |
case CC_PUNCT:
|
787 |
cv = getcvec(v, NUM_PUNCT_CHAR, NUM_PUNCT_RANGE, 0);
|
788 |
if (cv) {
|
789 |
for (i = 0; i < NUM_PUNCT_RANGE; i++) {
|
790 |
addrange(cv, punctRangeTable[i].start,
|
791 |
punctRangeTable[i].end);
|
792 |
}
|
793 |
for (i = 0; i < NUM_PUNCT_CHAR; i++) {
|
794 |
addchr(cv, punctCharTable[i]);
|
795 |
}
|
796 |
}
|
797 |
break;
|
798 |
case CC_XDIGIT:
|
799 |
cv = getcvec(v, 0, NUM_DIGIT_RANGE+2, 0);
|
800 |
if (cv) {
|
801 |
addrange(cv, '0', '9');
|
802 |
addrange(cv, 'a', 'f');
|
803 |
addrange(cv, 'A', 'F');
|
804 |
}
|
805 |
break;
|
806 |
case CC_SPACE:
|
807 |
cv = getcvec(v, NUM_SPACE_CHAR, NUM_SPACE_RANGE, 0);
|
808 |
if (cv) {
|
809 |
for (i = 0; i < NUM_SPACE_RANGE; i++) {
|
810 |
addrange(cv, spaceRangeTable[i].start,
|
811 |
spaceRangeTable[i].end);
|
812 |
}
|
813 |
for (i = 0; i < NUM_SPACE_CHAR; i++) {
|
814 |
addchr(cv, spaceCharTable[i]);
|
815 |
}
|
816 |
}
|
817 |
break;
|
818 |
case CC_LOWER:
|
819 |
cv = getcvec(v, NUM_LOWER_CHAR, NUM_LOWER_RANGE, 0);
|
820 |
if (cv) {
|
821 |
for (i = 0; i < NUM_LOWER_RANGE; i++) {
|
822 |
addrange(cv, lowerRangeTable[i].start,
|
823 |
lowerRangeTable[i].end);
|
824 |
}
|
825 |
for (i = 0; i < NUM_LOWER_CHAR; i++) {
|
826 |
addchr(cv, lowerCharTable[i]);
|
827 |
}
|
828 |
}
|
829 |
break;
|
830 |
case CC_UPPER:
|
831 |
cv = getcvec(v, NUM_UPPER_CHAR, NUM_UPPER_RANGE, 0);
|
832 |
if (cv) {
|
833 |
for (i = 0; i < NUM_UPPER_RANGE; i++) {
|
834 |
addrange(cv, upperRangeTable[i].start,
|
835 |
upperRangeTable[i].end);
|
836 |
}
|
837 |
for (i = 0; i < NUM_UPPER_CHAR; i++) {
|
838 |
addchr(cv, upperCharTable[i]);
|
839 |
}
|
840 |
}
|
841 |
break;
|
842 |
case CC_GRAPH:
|
843 |
cv = getcvec(v, NUM_GRAPH_CHAR, NUM_GRAPH_RANGE, 0);
|
844 |
if (cv) {
|
845 |
for (i = 0; i < NUM_GRAPH_RANGE; i++) {
|
846 |
addrange(cv, graphRangeTable[i].start,
|
847 |
graphRangeTable[i].end);
|
848 |
}
|
849 |
for (i = 0; i < NUM_GRAPH_CHAR; i++) {
|
850 |
addchr(cv, graphCharTable[i]);
|
851 |
}
|
852 |
}
|
853 |
break;
|
854 |
}
|
855 |
if (cv == NULL) {
|
856 |
ERR(REG_ESPACE);
|
857 |
}
|
858 |
return cv;
|
859 |
}
|
860 |
|
861 |
/*
|
862 |
- allcases - supply cvec for all case counterparts of a chr (including itself)
|
863 |
* This is a shortcut, preferably an efficient one, for simple characters;
|
864 |
* messy cases are done via range().
|
865 |
^ static struct cvec *allcases(struct vars *, pchr);
|
866 |
*/
|
867 |
static struct cvec *
|
868 |
allcases(v, pc)
|
869 |
struct vars *v;
|
870 |
pchr pc;
|
871 |
{
|
872 |
struct cvec *cv;
|
873 |
chr c = (chr)pc;
|
874 |
chr lc, uc, tc;
|
875 |
|
876 |
lc = Tcl_UniCharToLower((chr)c);
|
877 |
uc = Tcl_UniCharToUpper((chr)c);
|
878 |
tc = Tcl_UniCharToTitle((chr)c);
|
879 |
|
880 |
if (tc != uc) {
|
881 |
cv = getcvec(v, 3, 0, 0);
|
882 |
addchr(cv, tc);
|
883 |
} else {
|
884 |
cv = getcvec(v, 2, 0, 0);
|
885 |
}
|
886 |
addchr(cv, lc);
|
887 |
if (lc != uc) {
|
888 |
addchr(cv, uc);
|
889 |
}
|
890 |
return cv;
|
891 |
}
|
892 |
|
893 |
/*
|
894 |
- cmp - chr-substring compare
|
895 |
* Backrefs need this. It should preferably be efficient.
|
896 |
* Note that it does not need to report anything except equal/unequal.
|
897 |
* Note also that the length is exact, and the comparison should not
|
898 |
* stop at embedded NULs!
|
899 |
^ static int cmp(CONST chr *, CONST chr *, size_t);
|
900 |
*/
|
901 |
static int /* 0 for equal, nonzero for unequal */
|
902 |
cmp(x, y, len)
|
903 |
CONST chr *x;
|
904 |
CONST chr *y;
|
905 |
size_t len; /* exact length of comparison */
|
906 |
{
|
907 |
return memcmp(VS(x), VS(y), len*sizeof(chr));
|
908 |
}
|
909 |
|
910 |
/*
|
911 |
- casecmp - case-independent chr-substring compare
|
912 |
* REG_ICASE backrefs need this. It should preferably be efficient.
|
913 |
* Note that it does not need to report anything except equal/unequal.
|
914 |
* Note also that the length is exact, and the comparison should not
|
915 |
* stop at embedded NULs!
|
916 |
^ static int casecmp(CONST chr *, CONST chr *, size_t);
|
917 |
*/
|
918 |
static int /* 0 for equal, nonzero for unequal */
|
919 |
casecmp(x, y, len)
|
920 |
CONST chr *x;
|
921 |
CONST chr *y;
|
922 |
size_t len; /* exact length of comparison */
|
923 |
{
|
924 |
size_t i;
|
925 |
CONST chr *xp;
|
926 |
CONST chr *yp;
|
927 |
|
928 |
for (xp = x, yp = y, i = len; i > 0; i--)
|
929 |
if (Tcl_UniCharToLower(*xp++) != Tcl_UniCharToLower(*yp++))
|
930 |
return 1;
|
931 |
return 0;
|
932 |
}
|
933 |
|
934 |
/* $History: regc_locale.c $
|
935 |
*
|
936 |
* ***************** Version 1 *****************
|
937 |
* User: Dtashley Date: 1/02/01 Time: 12:05a
|
938 |
* Created in $/IjuScripter, IjuConsole/Source/Tcl Base
|
939 |
* Initial check-in.
|
940 |
*/
|
941 |
|
942 |
/* End of REGC_LOCALE.C */ |