]>
Commit | Line | Data |
---|---|---|
11a3e7b6 VZ |
1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd |
2 | See the file COPYING for copying permission. | |
3 | */ | |
4 | ||
5 | #include <string.h> | |
6 | #include <stdio.h> | |
7 | #include <stddef.h> | |
8 | ||
9 | struct range { | |
10 | int start; | |
11 | int end; | |
12 | }; | |
13 | ||
14 | struct range nmstrt[] = { | |
15 | { '_' }, | |
16 | { ':' }, | |
17 | /* BaseChar */ | |
18 | { 0x0041, 0x005a }, | |
19 | { 0x0061, 0x007a }, | |
20 | { 0x00c0, 0x00d6 }, | |
21 | { 0x00d8, 0x00f6 }, | |
22 | { 0x00f8, 0x00ff }, | |
23 | { 0x0100, 0x0131 }, | |
24 | { 0x0134, 0x013e }, | |
25 | { 0x0141, 0x0148 }, | |
26 | { 0x014a, 0x017e }, | |
27 | { 0x0180, 0x01c3 }, | |
28 | { 0x01cd, 0x01f0 }, | |
29 | { 0x01f4, 0x01f5 }, | |
30 | { 0x01fa, 0x0217 }, | |
31 | { 0x0250, 0x02a8 }, | |
32 | { 0x02bb, 0x02c1 }, | |
33 | { 0x0386 }, | |
34 | { 0x0388, 0x038a }, | |
35 | { 0x038c }, | |
36 | { 0x038e, 0x03a1 }, | |
37 | { 0x03a3, 0x03ce }, | |
38 | { 0x03d0, 0x03d6 }, | |
39 | { 0x03da }, | |
40 | { 0x03dc }, | |
41 | { 0x03de }, | |
42 | { 0x03e0 }, | |
43 | { 0x03e2, 0x03f3 }, | |
44 | { 0x0401, 0x040c }, | |
45 | { 0x040e, 0x044f }, | |
46 | { 0x0451, 0x045c }, | |
47 | { 0x045e, 0x0481 }, | |
48 | { 0x0490, 0x04c4 }, | |
49 | { 0x04c7, 0x04c8 }, | |
50 | { 0x04cb, 0x04cc }, | |
51 | { 0x04d0, 0x04eb }, | |
52 | { 0x04ee, 0x04f5 }, | |
53 | { 0x04f8, 0x04f9 }, | |
54 | { 0x0531, 0x0556 }, | |
55 | { 0x0559 }, | |
56 | { 0x0561, 0x0586 }, | |
57 | { 0x05d0, 0x05ea }, | |
58 | { 0x05f0, 0x05f2 }, | |
59 | { 0x0621, 0x063a }, | |
60 | { 0x0641, 0x064a }, | |
61 | { 0x0671, 0x06b7 }, | |
62 | { 0x06ba, 0x06be }, | |
63 | { 0x06c0, 0x06ce }, | |
64 | { 0x06d0, 0x06d3 }, | |
65 | { 0x06d5 }, | |
66 | { 0x06e5, 0x06e6 }, | |
67 | { 0x0905, 0x0939 }, | |
68 | { 0x093d }, | |
69 | { 0x0958, 0x0961 }, | |
70 | { 0x0985, 0x098c }, | |
71 | { 0x098f, 0x0990 }, | |
72 | { 0x0993, 0x09a8 }, | |
73 | { 0x09aa, 0x09b0 }, | |
74 | { 0x09b2 }, | |
75 | { 0x09b6, 0x09b9 }, | |
76 | { 0x09dc, 0x09dd }, | |
77 | { 0x09df, 0x09e1 }, | |
78 | { 0x09f0, 0x09f1 }, | |
79 | { 0x0a05, 0x0a0a }, | |
80 | { 0x0a0f, 0x0a10 }, | |
81 | { 0x0a13, 0x0a28 }, | |
82 | { 0x0a2a, 0x0a30 }, | |
83 | { 0x0a32, 0x0a33 }, | |
84 | { 0x0a35, 0x0a36 }, | |
85 | { 0x0a38, 0x0a39 }, | |
86 | { 0x0a59, 0x0a5c }, | |
87 | { 0x0a5e }, | |
88 | { 0x0a72, 0x0a74 }, | |
89 | { 0x0a85, 0x0a8b }, | |
90 | { 0x0a8d }, | |
91 | { 0x0a8f, 0x0a91 }, | |
92 | { 0x0a93, 0x0aa8 }, | |
93 | { 0x0aaa, 0x0ab0 }, | |
94 | { 0x0ab2, 0x0ab3 }, | |
95 | { 0x0ab5, 0x0ab9 }, | |
96 | { 0x0abd }, | |
97 | { 0x0ae0 }, | |
98 | { 0x0b05, 0x0b0c }, | |
99 | { 0x0b0f, 0x0b10 }, | |
100 | { 0x0b13, 0x0b28 }, | |
101 | { 0x0b2a, 0x0b30 }, | |
102 | { 0x0b32, 0x0b33 }, | |
103 | { 0x0b36, 0x0b39 }, | |
104 | { 0x0b3d }, | |
105 | { 0x0b5c, 0x0b5d }, | |
106 | { 0x0b5f, 0x0b61 }, | |
107 | { 0x0b85, 0x0b8a }, | |
108 | { 0x0b8e, 0x0b90 }, | |
109 | { 0x0b92, 0x0b95 }, | |
110 | { 0x0b99, 0x0b9a }, | |
111 | { 0x0b9c }, | |
112 | { 0x0b9e, 0x0b9f }, | |
113 | { 0x0ba3, 0x0ba4 }, | |
114 | { 0x0ba8, 0x0baa }, | |
115 | { 0x0bae, 0x0bb5 }, | |
116 | { 0x0bb7, 0x0bb9 }, | |
117 | { 0x0c05, 0x0c0c }, | |
118 | { 0x0c0e, 0x0c10 }, | |
119 | { 0x0c12, 0x0c28 }, | |
120 | { 0x0c2a, 0x0c33 }, | |
121 | { 0x0c35, 0x0c39 }, | |
122 | { 0x0c60, 0x0c61 }, | |
123 | { 0x0c85, 0x0c8c }, | |
124 | { 0x0c8e, 0x0c90 }, | |
125 | { 0x0c92, 0x0ca8 }, | |
126 | { 0x0caa, 0x0cb3 }, | |
127 | { 0x0cb5, 0x0cb9 }, | |
128 | { 0x0cde }, | |
129 | { 0x0ce0, 0x0ce1 }, | |
130 | { 0x0d05, 0x0d0c }, | |
131 | { 0x0d0e, 0x0d10 }, | |
132 | { 0x0d12, 0x0d28 }, | |
133 | { 0x0d2a, 0x0d39 }, | |
134 | { 0x0d60, 0x0d61 }, | |
135 | { 0x0e01, 0x0e2e }, | |
136 | { 0x0e30 }, | |
137 | { 0x0e32, 0x0e33 }, | |
138 | { 0x0e40, 0x0e45 }, | |
139 | { 0x0e81, 0x0e82 }, | |
140 | { 0x0e84 }, | |
141 | { 0x0e87, 0x0e88 }, | |
142 | { 0x0e8a }, | |
143 | { 0x0e8d }, | |
144 | { 0x0e94, 0x0e97 }, | |
145 | { 0x0e99, 0x0e9f }, | |
146 | { 0x0ea1, 0x0ea3 }, | |
147 | { 0x0ea5 }, | |
148 | { 0x0ea7 }, | |
149 | { 0x0eaa, 0x0eab }, | |
150 | { 0x0ead, 0x0eae }, | |
151 | { 0x0eb0 }, | |
152 | { 0x0eb2, 0x0eb3 }, | |
153 | { 0x0ebd }, | |
154 | { 0x0ec0, 0x0ec4 }, | |
155 | { 0x0f40, 0x0f47 }, | |
156 | { 0x0f49, 0x0f69 }, | |
157 | { 0x10a0, 0x10c5 }, | |
158 | { 0x10d0, 0x10f6 }, | |
159 | { 0x1100 }, | |
160 | { 0x1102, 0x1103 }, | |
161 | { 0x1105, 0x1107 }, | |
162 | { 0x1109 }, | |
163 | { 0x110b, 0x110c }, | |
164 | { 0x110e, 0x1112 }, | |
165 | { 0x113c }, | |
166 | { 0x113e }, | |
167 | { 0x1140 }, | |
168 | { 0x114c }, | |
169 | { 0x114e }, | |
170 | { 0x1150 }, | |
171 | { 0x1154, 0x1155 }, | |
172 | { 0x1159 }, | |
173 | { 0x115f, 0x1161 }, | |
174 | { 0x1163 }, | |
175 | { 0x1165 }, | |
176 | { 0x1167 }, | |
177 | { 0x1169 }, | |
178 | { 0x116d, 0x116e }, | |
179 | { 0x1172, 0x1173 }, | |
180 | { 0x1175 }, | |
181 | { 0x119e }, | |
182 | { 0x11a8 }, | |
183 | { 0x11ab }, | |
184 | { 0x11ae, 0x11af }, | |
185 | { 0x11b7, 0x11b8 }, | |
186 | { 0x11ba }, | |
187 | { 0x11bc, 0x11c2 }, | |
188 | { 0x11eb }, | |
189 | { 0x11f0 }, | |
190 | { 0x11f9 }, | |
191 | { 0x1e00, 0x1e9b }, | |
192 | { 0x1ea0, 0x1ef9 }, | |
193 | { 0x1f00, 0x1f15 }, | |
194 | { 0x1f18, 0x1f1d }, | |
195 | { 0x1f20, 0x1f45 }, | |
196 | { 0x1f48, 0x1f4d }, | |
197 | { 0x1f50, 0x1f57 }, | |
198 | { 0x1f59 }, | |
199 | { 0x1f5b }, | |
200 | { 0x1f5d }, | |
201 | { 0x1f5f, 0x1f7d }, | |
202 | { 0x1f80, 0x1fb4 }, | |
203 | { 0x1fb6, 0x1fbc }, | |
204 | { 0x1fbe }, | |
205 | { 0x1fc2, 0x1fc4 }, | |
206 | { 0x1fc6, 0x1fcc }, | |
207 | { 0x1fd0, 0x1fd3 }, | |
208 | { 0x1fd6, 0x1fdb }, | |
209 | { 0x1fe0, 0x1fec }, | |
210 | { 0x1ff2, 0x1ff4 }, | |
211 | { 0x1ff6, 0x1ffc }, | |
212 | { 0x2126 }, | |
213 | { 0x212a, 0x212b }, | |
214 | { 0x212e }, | |
215 | { 0x2180, 0x2182 }, | |
216 | { 0x3041, 0x3094 }, | |
217 | { 0x30a1, 0x30fa }, | |
218 | { 0x3105, 0x312c }, | |
219 | { 0xac00, 0xd7a3 }, | |
220 | /* Ideographic */ | |
221 | { 0x4e00, 0x9fa5 }, | |
222 | { 0x3007 }, | |
223 | { 0x3021, 0x3029 }, | |
224 | }; | |
225 | ||
226 | /* name chars that are not name start chars */ | |
227 | struct range name[] = { | |
228 | { '.' }, | |
229 | { '-' }, | |
230 | /* CombiningChar */ | |
231 | { 0x0300, 0x0345 }, | |
232 | { 0x0360, 0x0361 }, | |
233 | { 0x0483, 0x0486 }, | |
234 | { 0x0591, 0x05a1 }, | |
235 | { 0x05a3, 0x05b9 }, | |
236 | { 0x05bb, 0x05bd }, | |
237 | { 0x05bf }, | |
238 | { 0x05c1, 0x05c2 }, | |
239 | { 0x05c4 }, | |
240 | { 0x064b, 0x0652 }, | |
241 | { 0x0670 }, | |
242 | { 0x06d6, 0x06dc }, | |
243 | { 0x06dd, 0x06df }, | |
244 | { 0x06e0, 0x06e4 }, | |
245 | { 0x06e7, 0x06e8 }, | |
246 | { 0x06ea, 0x06ed }, | |
247 | { 0x0901, 0x0903 }, | |
248 | { 0x093c }, | |
249 | { 0x093e, 0x094c }, | |
250 | { 0x094d }, | |
251 | { 0x0951, 0x0954 }, | |
252 | { 0x0962, 0x0963 }, | |
253 | { 0x0981, 0x0983 }, | |
254 | { 0x09bc }, | |
255 | { 0x09be }, | |
256 | { 0x09bf }, | |
257 | { 0x09c0, 0x09c4 }, | |
258 | { 0x09c7, 0x09c8 }, | |
259 | { 0x09cb, 0x09cd }, | |
260 | { 0x09d7 }, | |
261 | { 0x09e2, 0x09e3 }, | |
262 | { 0x0a02 }, | |
263 | { 0x0a3c }, | |
264 | { 0x0a3e }, | |
265 | { 0x0a3f }, | |
266 | { 0x0a40, 0x0a42 }, | |
267 | { 0x0a47, 0x0a48 }, | |
268 | { 0x0a4b, 0x0a4d }, | |
269 | { 0x0a70, 0x0a71 }, | |
270 | { 0x0a81, 0x0a83 }, | |
271 | { 0x0abc }, | |
272 | { 0x0abe, 0x0ac5 }, | |
273 | { 0x0ac7, 0x0ac9 }, | |
274 | { 0x0acb, 0x0acd }, | |
275 | { 0x0b01, 0x0b03 }, | |
276 | { 0x0b3c }, | |
277 | { 0x0b3e, 0x0b43 }, | |
278 | { 0x0b47, 0x0b48 }, | |
279 | { 0x0b4b, 0x0b4d }, | |
280 | { 0x0b56, 0x0b57 }, | |
281 | { 0x0b82, 0x0b83 }, | |
282 | { 0x0bbe, 0x0bc2 }, | |
283 | { 0x0bc6, 0x0bc8 }, | |
284 | { 0x0bca, 0x0bcd }, | |
285 | { 0x0bd7 }, | |
286 | { 0x0c01, 0x0c03 }, | |
287 | { 0x0c3e, 0x0c44 }, | |
288 | { 0x0c46, 0x0c48 }, | |
289 | { 0x0c4a, 0x0c4d }, | |
290 | { 0x0c55, 0x0c56 }, | |
291 | { 0x0c82, 0x0c83 }, | |
292 | { 0x0cbe, 0x0cc4 }, | |
293 | { 0x0cc6, 0x0cc8 }, | |
294 | { 0x0cca, 0x0ccd }, | |
295 | { 0x0cd5, 0x0cd6 }, | |
296 | { 0x0d02, 0x0d03 }, | |
297 | { 0x0d3e, 0x0d43 }, | |
298 | { 0x0d46, 0x0d48 }, | |
299 | { 0x0d4a, 0x0d4d }, | |
300 | { 0x0d57 }, | |
301 | { 0x0e31 }, | |
302 | { 0x0e34, 0x0e3a }, | |
303 | { 0x0e47, 0x0e4e }, | |
304 | { 0x0eb1 }, | |
305 | { 0x0eb4, 0x0eb9 }, | |
306 | { 0x0ebb, 0x0ebc }, | |
307 | { 0x0ec8, 0x0ecd }, | |
308 | { 0x0f18, 0x0f19 }, | |
309 | { 0x0f35 }, | |
310 | { 0x0f37 }, | |
311 | { 0x0f39 }, | |
312 | { 0x0f3e }, | |
313 | { 0x0f3f }, | |
314 | { 0x0f71, 0x0f84 }, | |
315 | { 0x0f86, 0x0f8b }, | |
316 | { 0x0f90, 0x0f95 }, | |
317 | { 0x0f97 }, | |
318 | { 0x0f99, 0x0fad }, | |
319 | { 0x0fb1, 0x0fb7 }, | |
320 | { 0x0fb9 }, | |
321 | { 0x20d0, 0x20dc }, | |
322 | { 0x20e1 }, | |
323 | { 0x302a, 0x302f }, | |
324 | { 0x3099 }, | |
325 | { 0x309a }, | |
326 | /* Digit */ | |
327 | { 0x0030, 0x0039 }, | |
328 | { 0x0660, 0x0669 }, | |
329 | { 0x06f0, 0x06f9 }, | |
330 | { 0x0966, 0x096f }, | |
331 | { 0x09e6, 0x09ef }, | |
332 | { 0x0a66, 0x0a6f }, | |
333 | { 0x0ae6, 0x0aef }, | |
334 | { 0x0b66, 0x0b6f }, | |
335 | { 0x0be7, 0x0bef }, | |
336 | { 0x0c66, 0x0c6f }, | |
337 | { 0x0ce6, 0x0cef }, | |
338 | { 0x0d66, 0x0d6f }, | |
339 | { 0x0e50, 0x0e59 }, | |
340 | { 0x0ed0, 0x0ed9 }, | |
341 | { 0x0f20, 0x0f29 }, | |
342 | /* Extender */ | |
343 | { 0xb7 }, | |
344 | { 0x02d0 }, | |
345 | { 0x02d1 }, | |
346 | { 0x0387 }, | |
347 | { 0x0640 }, | |
348 | { 0x0e46 }, | |
349 | { 0x0ec6 }, | |
350 | { 0x3005 }, | |
351 | { 0x3031, 0x3035 }, | |
352 | { 0x309d, 0x309e }, | |
353 | { 0x30fc, 0x30fe }, | |
354 | }; | |
355 | ||
356 | static void | |
357 | setTab(char *tab, struct range *ranges, size_t nRanges) | |
358 | { | |
359 | size_t i; | |
360 | int j; | |
361 | for (i = 0; i < nRanges; i++) { | |
362 | if (ranges[i].end) { | |
363 | for (j = ranges[i].start; j <= ranges[i].end; j++) | |
364 | tab[j] = 1; | |
365 | } | |
366 | else | |
367 | tab[ranges[i].start] = 1; | |
368 | } | |
369 | } | |
370 | ||
371 | static void | |
372 | printTabs(char *tab) | |
373 | { | |
374 | int nBitmaps = 2; | |
375 | int i, j, k; | |
376 | unsigned char pageIndex[512]; | |
377 | ||
378 | printf( | |
379 | "static const unsigned namingBitmap[] = {\n\ | |
380 | 0x00000000, 0x00000000, 0x00000000, 0x00000000,\n\ | |
381 | 0x00000000, 0x00000000, 0x00000000, 0x00000000,\n\ | |
382 | 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,\n\ | |
383 | 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,\n"); | |
384 | for (i = 0; i < 512; i++) { | |
385 | int kind = tab[i*256]; | |
386 | for (j = 1; j < 256; j++) | |
387 | if (tab[i*256 +j] != kind) { | |
388 | kind = -1; | |
389 | break; | |
390 | } | |
391 | if (i >= 256 && memcmp(tab + (i - 256)*256, tab + i*256, 256) == 0) | |
392 | pageIndex[i] = pageIndex[i - 256]; | |
393 | else if (kind == -1) { | |
394 | pageIndex[i] = nBitmaps++; | |
395 | for (j = 0; j < 8; j++) { | |
396 | unsigned val = 0; | |
397 | for (k = 0; k < 32; k++) { | |
398 | if (tab[i*256 + j*32 +k]) | |
399 | val |= (1 << k); | |
400 | } | |
401 | printf("0x%08X,", val); | |
402 | putchar((((j + 1) & 3) == 0) ? '\n' : ' '); | |
403 | } | |
404 | } | |
405 | else | |
406 | pageIndex[i] = kind; | |
407 | } | |
408 | printf("};\n"); | |
409 | printf("static const unsigned char nmstrtPages[] = {\n"); | |
410 | for (i = 0; i < 512; i++) { | |
411 | if (i == 256) | |
412 | printf("};\nstatic const unsigned char namePages[] = {\n"); | |
413 | printf("0x%02X,", pageIndex[i]); | |
414 | putchar((((i + 1) & 7) == 0) ? '\n' : ' '); | |
415 | } | |
416 | printf("};\n"); | |
417 | } | |
418 | ||
419 | int | |
420 | main() | |
421 | { | |
422 | char tab[2*65536]; | |
423 | memset(tab, 0, 65536); | |
424 | setTab(tab, nmstrt, sizeof(nmstrt)/sizeof(nmstrt[0])); | |
425 | memcpy(tab + 65536, tab, 65536); | |
426 | setTab(tab + 65536, name, sizeof(name)/sizeof(name[0])); | |
427 | printTabs(tab); | |
428 | return 0; | |
429 | } |