~ubuntu-branches/ubuntu/hardy/php5/hardy-updates

« back to all changes in this revision

Viewing changes to ext/mbstring/oniguruma/enc/mktable.c

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-10-09 03:14:32 UTC
  • Revision ID: james.westby@ubuntu.com-20051009031432-kspik3lobxstafv9
Tags: upstream-5.0.5
ImportĀ upstreamĀ versionĀ 5.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**********************************************************************
 
2
  mktable.c
 
3
**********************************************************************/
 
4
/*-
 
5
 * Copyright (c) 2002-2004  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
 
6
 * All rights reserved.
 
7
 *
 
8
 * Redistribution and use in source and binary forms, with or without
 
9
 * modification, are permitted provided that the following conditions
 
10
 * are met:
 
11
 * 1. Redistributions of source code must retain the above copyright
 
12
 *    notice, this list of conditions and the following disclaimer.
 
13
 * 2. Redistributions in binary form must reproduce the above copyright
 
14
 *    notice, this list of conditions and the following disclaimer in the
 
15
 *    documentation and/or other materials provided with the distribution.
 
16
 *
 
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 
18
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
20
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 
21
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
22
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
23
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
24
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
25
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
27
 * SUCH DAMAGE.
 
28
 */
 
29
 
 
30
#include <stdio.h>
 
31
 
 
32
#define NOT_RUBY
 
33
#include "regenc.h"
 
34
 
 
35
#define UNICODE_ISO_8859_1     0
 
36
#define ISO_8859_1     1
 
37
#define ISO_8859_2     2
 
38
#define ISO_8859_3     3
 
39
#define ISO_8859_4     4
 
40
#define ISO_8859_5     5
 
41
#define ISO_8859_6     6
 
42
#define ISO_8859_7     7
 
43
#define ISO_8859_8     8
 
44
#define ISO_8859_9     9
 
45
#define ISO_8859_10   10
 
46
#define ISO_8859_11   11
 
47
#define ISO_8859_13   12
 
48
#define ISO_8859_14   13
 
49
#define ISO_8859_15   14
 
50
#define ISO_8859_16   15
 
51
#define KOI8          16
 
52
#define KOI8_R        17
 
53
 
 
54
typedef struct {
 
55
  int   num;
 
56
  char* name;
 
57
} ENC_INFO;
 
58
 
 
59
static ENC_INFO Info[] = {
 
60
  { UNICODE_ISO_8859_1,  "UNICODE_ISO_8859_1"  },
 
61
  { ISO_8859_1,  "ISO_8859_1"  },
 
62
  { ISO_8859_2,  "ISO_8859_2"  },
 
63
  { ISO_8859_3,  "ISO_8859_3"  },
 
64
  { ISO_8859_4,  "ISO_8859_4"  },
 
65
  { ISO_8859_5,  "ISO_8859_5"  },
 
66
  { ISO_8859_6,  "ISO_8859_6"  },
 
67
  { ISO_8859_7,  "ISO_8859_7"  },
 
68
  { ISO_8859_8,  "ISO_8859_8"  },
 
69
  { ISO_8859_9,  "ISO_8859_9"  },
 
70
  { ISO_8859_10, "ISO_8859_10" },
 
71
  { ISO_8859_11, "ISO_8859_11" },
 
72
  { ISO_8859_13, "ISO_8859_13" },
 
73
  { ISO_8859_14, "ISO_8859_14" },
 
74
  { ISO_8859_15, "ISO_8859_15" },
 
75
  { ISO_8859_16, "ISO_8859_16" },
 
76
  { KOI8,        "KOI8" },
 
77
  { KOI8_R,      "KOI8_R" }
 
78
};
 
79
 
 
80
 
 
81
static int IsAlpha(int enc, int c)
 
82
{
 
83
  if (c >= 0x41 && c <= 0x5a) return 1;
 
84
  if (c >= 0x61 && c <= 0x7a) return 1;
 
85
 
 
86
  switch (enc) {
 
87
  case UNICODE_ISO_8859_1:
 
88
  case ISO_8859_1:
 
89
  case ISO_8859_9:
 
90
    if (c == 0xaa) return 1;
 
91
    if (c == 0xb5) return 1;
 
92
    if (c == 0xba) return 1;
 
93
    if (c >= 0xc0 && c <= 0xd6) return 1;
 
94
    if (c >= 0xd8 && c <= 0xf6) return 1;
 
95
    if (c >= 0xf8 && c <= 0xff) return 1;
 
96
    break;
 
97
 
 
98
  case ISO_8859_2:
 
99
    if (c == 0xa1 || c == 0xa3) return 1;
 
100
    if (c == 0xa5 || c == 0xa6) return 1;
 
101
    if (c >= 0xa9 && c <= 0xac) return 1;
 
102
    if (c >= 0xae && c <= 0xaf) return 1;
 
103
    if (c == 0xb1 || c == 0xb3) return 1;
 
104
    if (c == 0xb5 || c == 0xb6) return 1;
 
105
    if (c >= 0xb9 && c <= 0xbc) return 1;
 
106
    if (c >= 0xbe && c <= 0xbf) return 1;
 
107
    if (c >= 0xc0 && c <= 0xd6) return 1;
 
108
    if (c >= 0xd8 && c <= 0xf6) return 1;
 
109
    if (c >= 0xf8 && c <= 0xfe) return 1;
 
110
    break;
 
111
 
 
112
  case ISO_8859_3:
 
113
    if (c == 0xa1) return 1;
 
114
    if (c == 0xa6) return 1;
 
115
    if (c >= 0xa9 && c <= 0xac) return 1;
 
116
    if (c == 0xaf) return 1;
 
117
    if (c == 0xb1) return 1;
 
118
    if (c == 0xb5 || c == 0xb6) return 1;
 
119
    if (c >= 0xb9 && c <= 0xbc) return 1;
 
120
    if (c == 0xbf) return 1;
 
121
    if (c >= 0xc0 && c <= 0xc2) return 1;
 
122
    if (c >= 0xc4 && c <= 0xcf) return 1;
 
123
    if (c >= 0xd1 && c <= 0xd6) return 1;
 
124
    if (c >= 0xd8 && c <= 0xe2) return 1;
 
125
    if (c >= 0xe4 && c <= 0xef) return 1;
 
126
    if (c >= 0xf1 && c <= 0xf6) return 1;
 
127
    if (c >= 0xf8 && c <= 0xfe) return 1;
 
128
    break;
 
129
 
 
130
  case ISO_8859_4:
 
131
    if (c >= 0xa1 && c <= 0xa3) return 1;
 
132
    if (c == 0xa5 || c == 0xa6) return 1;
 
133
    if (c >= 0xa9 && c <= 0xac) return 1;
 
134
    if (c == 0xae) return 1;
 
135
    if (c == 0xb1 || c == 0xb3) return 1;
 
136
    if (c == 0xb5 || c == 0xb6) return 1;
 
137
    if (c >= 0xb9 && c <= 0xbf) return 1;
 
138
    if (c >= 0xc0 && c <= 0xd6) return 1;
 
139
    if (c >= 0xd8 && c <= 0xf6) return 1;
 
140
    if (c >= 0xf8 && c <= 0xfe) return 1;
 
141
    break;
 
142
 
 
143
  case ISO_8859_5:
 
144
    if (c >= 0xa1 && c <= 0xcf && c != 0xad) return 1;
 
145
    if (c >= 0xd0 && c <= 0xff && c != 0xf0 && c != 0xfd) return 1;
 
146
    break;
 
147
 
 
148
  case ISO_8859_6:
 
149
    if (c >= 0xc1 && c <= 0xda) return 1;
 
150
    if (c >= 0xe0 && c <= 0xf2) return 1;
 
151
    break;
 
152
 
 
153
  case ISO_8859_7:
 
154
    if (c == 0xb6) return 1;
 
155
    if (c >= 0xb8 && c <= 0xba) return 1;
 
156
    if (c == 0xbc) return 1;
 
157
    if (c >= 0xbe && c <= 0xbf) return 1;
 
158
    if (c == 0xc0) return 1;
 
159
    if (c >= 0xc1 && c <= 0xdb && c != 0xd2) return 1;
 
160
    if (c >= 0xdc && c <= 0xfe) return 1;
 
161
    break;
 
162
 
 
163
  case ISO_8859_8:
 
164
    if (c == 0xb5) return 1;
 
165
    if (c >= 0xe0 && c <= 0xfa) return 1;
 
166
    break;
 
167
 
 
168
  case ISO_8859_10:
 
169
    if (c >= 0xa1 && c <= 0xa6) return 1;
 
170
    if (c >= 0xa8 && c <= 0xac) return 1;
 
171
    if (c == 0xae || c == 0xaf) return 1;
 
172
    if (c >= 0xb1 && c <= 0xb6) return 1;
 
173
    if (c >= 0xb8 && c <= 0xbc) return 1;
 
174
    if (c >= 0xbe && c <= 0xff) return 1;
 
175
    break;
 
176
 
 
177
  case ISO_8859_11:
 
178
    if (c >= 0xa1 && c <= 0xda) return 1;
 
179
    if (c >= 0xdf && c <= 0xfb) return 1;
 
180
    break;
 
181
 
 
182
  case ISO_8859_13:
 
183
    if (c == 0xa8) return 1;
 
184
    if (c == 0xaa) return 1;
 
185
    if (c == 0xaf) return 1;
 
186
    if (c == 0xb5) return 1;
 
187
    if (c == 0xb8) return 1;
 
188
    if (c == 0xba) return 1;
 
189
    if (c >= 0xbf && c <= 0xd6) return 1;
 
190
    if (c >= 0xd8 && c <= 0xf6) return 1;
 
191
    if (c >= 0xf8 && c <= 0xfe) return 1;
 
192
    break;
 
193
 
 
194
  case ISO_8859_14:
 
195
    if (c == 0xa1 || c == 0xa2) return 1;
 
196
    if (c == 0xa4 || c == 0xa5) return 1;
 
197
    if (c == 0xa6 || c == 0xa8) return 1;
 
198
    if (c >= 0xaa && c <= 0xac) return 1;
 
199
    if (c >= 0xaf && c <= 0xb5) return 1;
 
200
    if (c >= 0xb7 && c <= 0xff) return 1;
 
201
    break;
 
202
 
 
203
  case ISO_8859_15:
 
204
    if (c == 0xaa) return 1;
 
205
    if (c == 0xb5) return 1;
 
206
    if (c == 0xba) return 1;
 
207
    if (c >= 0xc0 && c <= 0xd6) return 1;
 
208
    if (c >= 0xd8 && c <= 0xf6) return 1;
 
209
    if (c >= 0xf8 && c <= 0xff) return 1;
 
210
    if (c == 0xa6) return 1;
 
211
    if (c == 0xa8) return 1;
 
212
    if (c == 0xb4) return 1;
 
213
    if (c == 0xb8) return 1;
 
214
    if (c == 0xbc) return 1;
 
215
    if (c == 0xbd) return 1;
 
216
    if (c == 0xbe) return 1;
 
217
    break;
 
218
 
 
219
  case ISO_8859_16:
 
220
    if (c == 0xa1) return 1;
 
221
    if (c == 0xa2) return 1;
 
222
    if (c == 0xa3) return 1;
 
223
    if (c == 0xa6) return 1;
 
224
    if (c == 0xa8) return 1;
 
225
    if (c == 0xaa) return 1;
 
226
    if (c == 0xac) return 1;
 
227
    if (c == 0xae) return 1;
 
228
    if (c == 0xaf) return 1;
 
229
    if (c == 0xb2) return 1;
 
230
    if (c == 0xb3) return 1;
 
231
    if (c == 0xb4) return 1;
 
232
    if (c >= 0xb8 && c <= 0xba) return 1;
 
233
    if (c == 0xbc) return 1;
 
234
    if (c == 0xbd) return 1;
 
235
    if (c == 0xbe) return 1;
 
236
    if (c == 0xbf) return 1;
 
237
    if (c >= 0xc0 && c <= 0xde) return 1;
 
238
    if (c >= 0xdf && c <= 0xff) return 1;
 
239
    break;
 
240
 
 
241
  case KOI8_R:
 
242
    if (c == 0xa3 || c == 0xb3) return 1;
 
243
    /* fall */
 
244
  case KOI8:
 
245
    if (c >= 0xc0 && c <= 0xff) return 1;
 
246
    break;
 
247
 
 
248
  default:
 
249
    exit(-1);
 
250
  }
 
251
 
 
252
  return 0;
 
253
}
 
254
 
 
255
static int IsBlank(int enc, int c)
 
256
{
 
257
  if (c == 0x09 || c == 0x20) return 1;
 
258
 
 
259
  switch (enc) {
 
260
  case UNICODE_ISO_8859_1:
 
261
  case ISO_8859_1:
 
262
  case ISO_8859_2:
 
263
  case ISO_8859_3:
 
264
  case ISO_8859_4:
 
265
  case ISO_8859_5:
 
266
  case ISO_8859_6:
 
267
  case ISO_8859_7:
 
268
  case ISO_8859_8:
 
269
  case ISO_8859_9:
 
270
  case ISO_8859_10:
 
271
  case ISO_8859_11:
 
272
  case ISO_8859_13:
 
273
  case ISO_8859_14:
 
274
  case ISO_8859_15:
 
275
  case ISO_8859_16:
 
276
  case KOI8:
 
277
    if (c == 0xa0) return 1;
 
278
    break;
 
279
 
 
280
  case KOI8_R:
 
281
    if (c == 0x9a) return 1;
 
282
    break;
 
283
 
 
284
  default:
 
285
    exit(-1);
 
286
  }
 
287
 
 
288
  return 0;
 
289
}
 
290
 
 
291
static int IsCntrl(int enc, int c)
 
292
{
 
293
  if (c >= 0x00 && c <= 0x1F) return 1;
 
294
 
 
295
  switch (enc) {
 
296
  case UNICODE_ISO_8859_1:
 
297
    if (c == 0xad) return 1;
 
298
    /* fall */
 
299
  case ISO_8859_1:
 
300
  case ISO_8859_2:
 
301
  case ISO_8859_3:
 
302
  case ISO_8859_4:
 
303
  case ISO_8859_5:
 
304
  case ISO_8859_6:
 
305
  case ISO_8859_7:
 
306
  case ISO_8859_8:
 
307
  case ISO_8859_9:
 
308
  case ISO_8859_10:
 
309
  case ISO_8859_11:
 
310
  case ISO_8859_13:
 
311
  case ISO_8859_14:
 
312
  case ISO_8859_15:
 
313
  case ISO_8859_16:
 
314
  case KOI8:
 
315
    if (c >= 0x7f && c <= 0x9F) return 1;
 
316
    break;
 
317
 
 
318
 
 
319
  case KOI8_R:
 
320
    if (c == 0x7f) return 1;
 
321
    break;
 
322
 
 
323
  default:
 
324
    exit(-1);
 
325
  }
 
326
 
 
327
  return 0;
 
328
}
 
329
 
 
330
static int IsDigit(int enc, int c)
 
331
{
 
332
  if (c >= 0x30 && c <= 0x39) return 1;
 
333
  return 0;
 
334
}
 
335
 
 
336
static int IsGraph(int enc, int c)
 
337
{
 
338
  if (c >= 0x21 && c <= 0x7e) return 1;
 
339
 
 
340
  switch (enc) {
 
341
  case UNICODE_ISO_8859_1:
 
342
  case ISO_8859_1:
 
343
  case ISO_8859_2:
 
344
  case ISO_8859_4:
 
345
  case ISO_8859_5:
 
346
  case ISO_8859_9:
 
347
  case ISO_8859_10:
 
348
  case ISO_8859_13:
 
349
  case ISO_8859_14:
 
350
  case ISO_8859_15:
 
351
  case ISO_8859_16:
 
352
    if (c >= 0xa1 && c <= 0xff) return 1;
 
353
    break;
 
354
 
 
355
  case ISO_8859_3:
 
356
    if (c >= 0xa1) {
 
357
      if (c == 0xa5 || c == 0xae || c == 0xbe || c == 0xc3 || c == 0xd0 ||
 
358
          c == 0xe3 || c == 0xf0)
 
359
        return 0;
 
360
      else
 
361
        return 1;
 
362
    }
 
363
    break;
 
364
 
 
365
  case ISO_8859_6:
 
366
    if (c == 0xa4 || c == 0xac || c == 0xad || c == 0xbb || c == 0xbf)
 
367
      return 1;
 
368
    if (c >= 0xc1 && c <= 0xda) return 1;
 
369
    if (c >= 0xe0 && c <= 0xf2) return 1;
 
370
    break;
 
371
 
 
372
  case ISO_8859_7:
 
373
    if (c >= 0xa1 && c <= 0xfe &&
 
374
        c != 0xa4 && c != 0xa5 && c != 0xaa &&
 
375
        c != 0xae && c != 0xd2) return 1;
 
376
    break;
 
377
 
 
378
  case ISO_8859_8:
 
379
    if (c >= 0xa2 && c <= 0xfa) {
 
380
      if (c >= 0xbf && c <= 0xde) return 0;
 
381
      return 1;
 
382
    }
 
383
    break;
 
384
 
 
385
  case ISO_8859_11:
 
386
    if (c >= 0xa1 && c <= 0xda) return 1;
 
387
    if (c >= 0xdf && c <= 0xfb) return 1;
 
388
    break;
 
389
 
 
390
  case KOI8:
 
391
    if (c >= 0xc0 && c <= 0xff) return 1;
 
392
    break;
 
393
 
 
394
  case KOI8_R:
 
395
    if (c >= 0x80 && c <= 0xff && c != 0x9a) return 1;
 
396
    break;
 
397
 
 
398
  default:
 
399
    exit(-1);
 
400
  }
 
401
 
 
402
  return 0;
 
403
}
 
404
 
 
405
static int IsLower(int enc, int c)
 
406
{
 
407
  if (c >= 0x61 && c <= 0x7a) return 1;
 
408
 
 
409
  switch (enc) {
 
410
  case UNICODE_ISO_8859_1:
 
411
  case ISO_8859_1:
 
412
  case ISO_8859_9:
 
413
    if (c == 0xaa) return 1;
 
414
    if (c == 0xb5) return 1;
 
415
    if (c == 0xba) return 1;
 
416
    if (c >= 0xdf && c <= 0xf6) return 1;
 
417
    if (c >= 0xf8 && c <= 0xff) return 1;
 
418
    break;
 
419
 
 
420
  case ISO_8859_2:
 
421
    if (c == 0xb1 || c == 0xb3) return 1;
 
422
    if (c == 0xb5 || c == 0xb6) return 1;
 
423
    if (c >= 0xb9 && c <= 0xbc) return 1;
 
424
    if (c >= 0xbe && c <= 0xbf) return 1;
 
425
    if (c >= 0xdf && c <= 0xf6) return 1;
 
426
    if (c >= 0xf8 && c <= 0xfe) return 1;
 
427
    break;
 
428
 
 
429
  case ISO_8859_3:
 
430
    if (c == 0xb1) return 1;
 
431
    if (c == 0xb5 || c == 0xb6) return 1;
 
432
    if (c >= 0xb9 && c <= 0xbc) return 1;
 
433
    if (c == 0xbf) return 1;
 
434
    if (c == 0xdf) return 1;
 
435
    if (c >= 0xe0 && c <= 0xe2) return 1;
 
436
    if (c >= 0xe4 && c <= 0xef) return 1;
 
437
    if (c >= 0xf1 && c <= 0xf6) return 1;
 
438
    if (c >= 0xf8 && c <= 0xfe) return 1;
 
439
    break;
 
440
 
 
441
  case ISO_8859_4:
 
442
    if (c == 0xa2) return 1;
 
443
    if (c == 0xb1 || c == 0xb3) return 1;
 
444
    if (c == 0xb5 || c == 0xb6) return 1;
 
445
    if (c >= 0xb9 && c <= 0xbc) return 1;
 
446
    if (c >= 0xbe && c <= 0xbf) return 1;
 
447
    if (c == 0xdf) return 1;
 
448
    if (c >= 0xe0 && c <= 0xf6) return 1;
 
449
    if (c >= 0xf8 && c <= 0xfe) return 1;
 
450
    break;
 
451
 
 
452
  case ISO_8859_5:
 
453
    if (c >= 0xd0 && c <= 0xff && c != 0xf0 && c != 0xfd) return 1;
 
454
    break;
 
455
 
 
456
  case ISO_8859_6:
 
457
    break;
 
458
 
 
459
  case ISO_8859_7:
 
460
    if (c == 0xc0) return 1;
 
461
    if (c >= 0xdc && c <= 0xfe) return 1;
 
462
    break;
 
463
 
 
464
  case ISO_8859_8:
 
465
    if (c == 0xb5) return 1;
 
466
    break;
 
467
 
 
468
  case ISO_8859_10:
 
469
    if (c >= 0xb1 && c <= 0xb6) return 1;
 
470
    if (c >= 0xb8 && c <= 0xbc) return 1;
 
471
    if (c == 0xbe || c == 0xbf) return 1;
 
472
    if (c >= 0xdf && c <= 0xff) return 1;
 
473
    break;
 
474
 
 
475
  case ISO_8859_11:
 
476
    break;
 
477
 
 
478
  case ISO_8859_13:
 
479
    if (c == 0xb5) return 1;
 
480
    if (c == 0xb8) return 1;
 
481
    if (c == 0xba) return 1;
 
482
    if (c == 0xbf) return 1;
 
483
    if (c >= 0xdf && c <= 0xf6) return 1;
 
484
    if (c >= 0xf8 && c <= 0xfe) return 1;
 
485
    break;
 
486
 
 
487
  case ISO_8859_14:
 
488
    if (c == 0xa2) return 1;
 
489
    if (c == 0xa5) return 1;
 
490
    if (c == 0xab) return 1;
 
491
    if (c == 0xb1 || c == 0xb3 || c == 0xb5) return 1;
 
492
    if (c >= 0xb8 && c <= 0xba) return 1;
 
493
    if (c == 0xbc) return 1;
 
494
    if (c == 0xbe || c == 0xbf) return 1;
 
495
    if (c >= 0xdf && c <= 0xff) return 1;
 
496
    break;
 
497
 
 
498
  case ISO_8859_15:
 
499
    if (c == 0xaa) return 1;
 
500
    if (c == 0xb5) return 1;
 
501
    if (c == 0xba) return 1;
 
502
    if (c >= 0xdf && c <= 0xf6) return 1;
 
503
    if (c >= 0xf8 && c <= 0xff) return 1;
 
504
    if (c == 0xa8) return 1;
 
505
    if (c == 0xb8) return 1;
 
506
    if (c == 0xbd) return 1;
 
507
    break;
 
508
 
 
509
  case ISO_8859_16:
 
510
    if (c == 0xa2) return 1;
 
511
    if (c == 0xa8) return 1;
 
512
    if (c == 0xae) return 1;
 
513
    if (c == 0xb3) return 1;
 
514
    if (c >= 0xb8 && c <= 0xba) return 1;
 
515
    if (c == 0xbd) return 1;
 
516
    if (c == 0xbf) return 1;
 
517
    if (c >= 0xdf && c <= 0xff) return 1;
 
518
    break;
 
519
 
 
520
  case KOI8_R:
 
521
    if (c == 0xa3) return 1;
 
522
    /* fall */
 
523
  case KOI8:
 
524
    if (c >= 0xc0 && c <= 0xdf) return 1;
 
525
    break;
 
526
 
 
527
  default:
 
528
    exit(-1);
 
529
  }
 
530
 
 
531
  return 0;
 
532
}
 
533
 
 
534
static int IsPrint(int enc, int c)
 
535
{
 
536
  if (c >= 0x20 && c <= 0x7e) return 1;
 
537
 
 
538
  switch (enc) {
 
539
  case UNICODE_ISO_8859_1:
 
540
    if (c >= 0x09 && c <= 0x0d) return 1;
 
541
    if (c == 0x85) return 1;
 
542
    /* fall */
 
543
  case ISO_8859_1:
 
544
  case ISO_8859_2:
 
545
  case ISO_8859_4:
 
546
  case ISO_8859_5:
 
547
  case ISO_8859_9:
 
548
  case ISO_8859_10:
 
549
  case ISO_8859_13:
 
550
  case ISO_8859_14:
 
551
  case ISO_8859_15:
 
552
  case ISO_8859_16:
 
553
    if (c >= 0xa0 && c <= 0xff) return 1;
 
554
    break;
 
555
 
 
556
  case ISO_8859_3:
 
557
    if (c >= 0xa0) {
 
558
      if (c == 0xa5 || c == 0xae || c == 0xbe || c == 0xc3 || c == 0xd0 ||
 
559
          c == 0xe3 || c == 0xf0)
 
560
        return 0;
 
561
      else
 
562
        return 1;
 
563
    }
 
564
    break;
 
565
 
 
566
  case ISO_8859_6:
 
567
    if (c == 0xa0) return 1;
 
568
    if (c == 0xa4 || c == 0xac || c == 0xad || c == 0xbb || c == 0xbf)
 
569
      return 1;
 
570
    if (c >= 0xc1 && c <= 0xda) return 1;
 
571
    if (c >= 0xe0 && c <= 0xf2) return 1;
 
572
    break;
 
573
 
 
574
  case ISO_8859_7:
 
575
    if (c >= 0xa0 && c <= 0xfe &&
 
576
        c != 0xa4 && c != 0xa5 && c != 0xaa &&
 
577
        c != 0xae && c != 0xd2) return 1;
 
578
    break;
 
579
 
 
580
  case ISO_8859_8:
 
581
    if (c >= 0xa0 && c <= 0xfa) {
 
582
      if (c >= 0xbf && c <= 0xde) return 0;
 
583
      if (c == 0xa1) return 0;
 
584
      return 1;
 
585
    }
 
586
    break;
 
587
 
 
588
  case ISO_8859_11:
 
589
    if (c >= 0xa0 && c <= 0xda) return 1;
 
590
    if (c >= 0xdf && c <= 0xfb) return 1;
 
591
    break;
 
592
 
 
593
  case KOI8:
 
594
    if (c == 0xa0) return 1;
 
595
    if (c >= 0xc0 && c <= 0xff) return 1;
 
596
    break;
 
597
 
 
598
  case KOI8_R:
 
599
    if (c >= 0x80 && c <= 0xff) return 1;
 
600
    break;
 
601
 
 
602
  default:
 
603
    exit(-1);
 
604
  }
 
605
 
 
606
  return 0;
 
607
}
 
608
 
 
609
static int IsPunct(int enc, int c)
 
610
{
 
611
  if (enc == UNICODE_ISO_8859_1) {
 
612
    if (c == 0x24 || c == 0x2b || c == 0x5e || c == 0x60 ||
 
613
        c == 0x7c || c == 0x7e) return 1;
 
614
    if (c >= 0x3c && c <= 0x3e) return 1;
 
615
  }
 
616
 
 
617
  if (c >= 0x21 && c <= 0x23) return 1;
 
618
  if (c >= 0x25 && c <= 0x2a) return 1;
 
619
  if (c >= 0x2c && c <= 0x2f) return 1;
 
620
  if (c >= 0x3a && c <= 0x3b) return 1;
 
621
  if (c >= 0x3f && c <= 0x40) return 1;
 
622
  if (c >= 0x5b && c <= 0x5d) return 1;
 
623
  if (c == 0x5f) return 1;
 
624
  if (c == 0x7b) return 1;
 
625
  if (c == 0x7d) return 1;
 
626
 
 
627
  switch (enc) {
 
628
  case ISO_8859_1:
 
629
  case ISO_8859_9:
 
630
  case ISO_8859_15:
 
631
    if (c == 0xad) return 1;
 
632
    /* fall */
 
633
  case UNICODE_ISO_8859_1:
 
634
    if (c == 0xa1) return 1;
 
635
    if (c == 0xab) return 1;
 
636
    if (c == 0xb7) return 1;
 
637
    if (c == 0xbb) return 1;
 
638
    if (c == 0xbf) return 1;
 
639
    break;
 
640
 
 
641
  case ISO_8859_2:
 
642
  case ISO_8859_4:
 
643
  case ISO_8859_5:
 
644
  case ISO_8859_14:
 
645
    if (c == 0xad) return 1;
 
646
    break;
 
647
 
 
648
  case ISO_8859_3:
 
649
  case ISO_8859_10:
 
650
    if (c == 0xad) return 1;
 
651
    if (c == 0xb7) return 1;
 
652
    if (c == 0xbd) return 1;
 
653
    break;
 
654
 
 
655
  case ISO_8859_6:
 
656
    if (c == 0xac) return 1;
 
657
    if (c == 0xad) return 1;
 
658
    if (c == 0xbb) return 1;
 
659
    if (c == 0xbf) return 1;
 
660
    break;
 
661
 
 
662
  case ISO_8859_7:
 
663
    if (c == 0xa1 || c == 0xa2) return 1;
 
664
    if (c == 0xab) return 1;
 
665
    if (c == 0xaf) return 1;
 
666
    if (c == 0xad) return 1;
 
667
    if (c == 0xb7 || c == 0xbb) return 1;
 
668
    break;
 
669
 
 
670
  case ISO_8859_8:
 
671
    if (c == 0xab) return 1;
 
672
    if (c == 0xad) return 1;
 
673
    if (c == 0xb7) return 1;
 
674
    if (c == 0xbb) return 1;
 
675
    if (c == 0xdf) return 1;
 
676
    break;
 
677
 
 
678
  case ISO_8859_13:
 
679
    if (c == 0xa1 || c == 0xa5) return 1;
 
680
    if (c == 0xab || c == 0xad) return 1;
 
681
    if (c == 0xb4 || c == 0xb7) return 1;
 
682
    if (c == 0xbb) return 1;
 
683
    if (c == 0xff) return 1;
 
684
    break;
 
685
 
 
686
  case ISO_8859_16:
 
687
    if (c == 0xa5) return 1;
 
688
    if (c == 0xab) return 1;
 
689
    if (c == 0xad) return 1;
 
690
    if (c == 0xb5) return 1;
 
691
    if (c == 0xb7) return 1;
 
692
    if (c == 0xbb) return 1;
 
693
    break;
 
694
 
 
695
  case KOI8_R:
 
696
    if (c == 0x9e) return 1;
 
697
    break;
 
698
 
 
699
  case ISO_8859_11:
 
700
  case KOI8:
 
701
    break;
 
702
 
 
703
  default:
 
704
    exit(-1);
 
705
  }
 
706
 
 
707
  return 0;
 
708
}
 
709
 
 
710
static int IsSpace(int enc, int c)
 
711
{
 
712
  if (c >= 0x09 && c <= 0x0d) return 1;
 
713
  if (c == 0x20) return 1;
 
714
 
 
715
  switch (enc) {
 
716
  case UNICODE_ISO_8859_1:
 
717
    if (c == 0x85) return 1;
 
718
    /* fall */
 
719
  case ISO_8859_1:
 
720
  case ISO_8859_2:
 
721
  case ISO_8859_3:
 
722
  case ISO_8859_4:
 
723
  case ISO_8859_5:
 
724
  case ISO_8859_6:
 
725
  case ISO_8859_7:
 
726
  case ISO_8859_8:
 
727
  case ISO_8859_9:
 
728
  case ISO_8859_10:
 
729
  case ISO_8859_11:
 
730
  case ISO_8859_13:
 
731
  case ISO_8859_14:
 
732
  case ISO_8859_15:
 
733
  case ISO_8859_16:
 
734
  case KOI8:
 
735
    if (c == 0xa0) return 1;
 
736
    break;
 
737
 
 
738
  case KOI8_R:
 
739
    if (c == 0x9a) return 1;
 
740
    break;
 
741
 
 
742
  default:
 
743
    exit(-1);
 
744
  }
 
745
 
 
746
  return 0;
 
747
}
 
748
 
 
749
static int IsUpper(int enc, int c)
 
750
{
 
751
  if (c >= 0x41 && c <= 0x5a) return 1;
 
752
 
 
753
  switch (enc) {
 
754
  case UNICODE_ISO_8859_1:
 
755
  case ISO_8859_1:
 
756
  case ISO_8859_9:
 
757
    if (c >= 0xc0 && c <= 0xd6) return 1;
 
758
    if (c >= 0xd8 && c <= 0xde) return 1;
 
759
    break;
 
760
 
 
761
  case ISO_8859_2:
 
762
    if (c == 0xa1 || c == 0xa3) return 1;
 
763
    if (c == 0xa5 || c == 0xa6) return 1;
 
764
    if (c >= 0xa9 && c <= 0xac) return 1;
 
765
    if (c >= 0xae && c <= 0xaf) return 1;
 
766
    if (c >= 0xc0 && c <= 0xd6) return 1;
 
767
    if (c >= 0xd8 && c <= 0xde) return 1;
 
768
    break;
 
769
 
 
770
  case ISO_8859_3:
 
771
    if (c == 0xa1) return 1;
 
772
    if (c == 0xa6) return 1;
 
773
    if (c >= 0xa9 && c <= 0xac) return 1;
 
774
    if (c == 0xaf) return 1;
 
775
    if (c >= 0xc0 && c <= 0xc2) return 1;
 
776
    if (c >= 0xc4 && c <= 0xcf) return 1;
 
777
    if (c >= 0xd1 && c <= 0xd6) return 1;
 
778
    if (c >= 0xd8 && c <= 0xde) return 1;
 
779
    break;
 
780
 
 
781
  case ISO_8859_4:
 
782
    if (c == 0xa1 || c == 0xa3) return 1;
 
783
    if (c == 0xa5 || c == 0xa6) return 1;
 
784
    if (c >= 0xa9 && c <= 0xac) return 1;
 
785
    if (c == 0xae) return 1;
 
786
    if (c == 0xbd) return 1;
 
787
    if (c >= 0xc0 && c <= 0xd6) return 1;
 
788
    if (c >= 0xd8 && c <= 0xde) return 1;
 
789
    break;
 
790
 
 
791
  case ISO_8859_5:
 
792
    if (c >= 0xa1 && c <= 0xcf && c != 0xad) return 1;
 
793
    break;
 
794
 
 
795
  case ISO_8859_6:
 
796
    break;
 
797
 
 
798
  case ISO_8859_7:
 
799
    if (c == 0xb6) return 1;
 
800
    if (c >= 0xb8 && c <= 0xba) return 1;
 
801
    if (c == 0xbc) return 1;
 
802
    if (c >= 0xbe && c <= 0xbf) return 1;
 
803
    if (c >= 0xc1 && c <= 0xdb && c != 0xd2) return 1;
 
804
    break;
 
805
 
 
806
  case ISO_8859_8:
 
807
  case ISO_8859_11:
 
808
    break;
 
809
 
 
810
  case ISO_8859_10:
 
811
    if (c >= 0xa1 && c <= 0xa6) return 1;
 
812
    if (c >= 0xa8 && c <= 0xac) return 1;
 
813
    if (c == 0xae || c == 0xaf) return 1;
 
814
    if (c >= 0xc0 && c <= 0xde) return 1;
 
815
    break;
 
816
 
 
817
  case ISO_8859_13:
 
818
    if (c == 0xa8) return 1;
 
819
    if (c == 0xaa) return 1;
 
820
    if (c == 0xaf) return 1;
 
821
    if (c >= 0xc0 && c <= 0xd6) return 1;
 
822
    if (c >= 0xd8 && c <= 0xde) return 1;
 
823
    break;
 
824
 
 
825
  case ISO_8859_14:
 
826
    if (c == 0xa1) return 1;
 
827
    if (c == 0xa4 || c == 0xa6) return 1;
 
828
    if (c == 0xa8) return 1;
 
829
    if (c == 0xaa || c == 0xac) return 1;
 
830
    if (c == 0xaf || c == 0xb0) return 1;
 
831
    if (c == 0xb2 || c == 0xb4 || c == 0xb7) return 1;
 
832
    if (c == 0xbb || c == 0xbd) return 1;
 
833
    if (c >= 0xc0 && c <= 0xde) return 1;
 
834
    break;
 
835
 
 
836
  case ISO_8859_15:
 
837
    if (c >= 0xc0 && c <= 0xd6) return 1;
 
838
    if (c >= 0xd8 && c <= 0xde) return 1;
 
839
    if (c == 0xa6) return 1;
 
840
    if (c == 0xb4) return 1;
 
841
    if (c == 0xbc) return 1;
 
842
    if (c == 0xbe) return 1;
 
843
    break;
 
844
 
 
845
  case ISO_8859_16:
 
846
    if (c == 0xa1) return 1;
 
847
    if (c == 0xa3) return 1;
 
848
    if (c == 0xa6) return 1;
 
849
    if (c == 0xaa) return 1;
 
850
    if (c == 0xac) return 1;
 
851
    if (c == 0xaf) return 1;
 
852
    if (c == 0xb2) return 1;
 
853
    if (c == 0xb4) return 1;
 
854
    if (c == 0xbc) return 1;
 
855
    if (c == 0xbe) return 1;
 
856
    if (c >= 0xc0 && c <= 0xde) return 1;
 
857
    break;
 
858
 
 
859
  case KOI8_R:
 
860
    if (c == 0xb3) return 1;
 
861
    /* fall */
 
862
  case KOI8:
 
863
    if (c >= 0xe0 && c <= 0xff) return 1;
 
864
    break;
 
865
 
 
866
  default:
 
867
    exit(-1);
 
868
  }
 
869
 
 
870
  return 0;
 
871
}
 
872
 
 
873
static int IsXDigit(int enc, int c)
 
874
{
 
875
  if (c >= 0x30 && c <= 0x39) return 1;
 
876
  if (c >= 0x41 && c <= 0x46) return 1;
 
877
  if (c >= 0x61 && c <= 0x66) return 1;
 
878
  return 0;
 
879
}
 
880
 
 
881
static int IsWord(int enc, int c)
 
882
{
 
883
  if (c >= 0x30 && c <= 0x39) return 1;
 
884
  if (c >= 0x41 && c <= 0x5a) return 1;
 
885
  if (c == 0x5f) return 1;
 
886
  if (c >= 0x61 && c <= 0x7a) return 1;
 
887
 
 
888
  switch (enc) {
 
889
  case UNICODE_ISO_8859_1:
 
890
  case ISO_8859_1:
 
891
  case ISO_8859_9:
 
892
    if (c == 0xaa) return 1;
 
893
    if (c >= 0xb2 && c <= 0xb3) return 1;
 
894
    if (c == 0xb5) return 1;
 
895
    if (c >= 0xb9 && c <= 0xba) return 1;
 
896
    if (c >= 0xbc && c <= 0xbe) return 1;
 
897
    if (c >= 0xc0 && c <= 0xd6) return 1;
 
898
    if (c >= 0xd8 && c <= 0xf6) return 1;
 
899
    if (c >= 0xf8 && c <= 0xff) return 1;
 
900
    break;
 
901
 
 
902
  case ISO_8859_2:
 
903
    if (c == 0xa1 || c == 0xa3) return 1;
 
904
    if (c == 0xa5 || c == 0xa6) return 1;
 
905
    if (c >= 0xa9 && c <= 0xac) return 1;
 
906
    if (c >= 0xae && c <= 0xaf) return 1;
 
907
    if (c == 0xb1 || c == 0xb3) return 1;
 
908
    if (c == 0xb5 || c == 0xb6) return 1;
 
909
    if (c >= 0xb9 && c <= 0xbc) return 1;
 
910
    if (c >= 0xbe && c <= 0xbf) return 1;
 
911
    if (c >= 0xc0 && c <= 0xd6) return 1;
 
912
    if (c >= 0xd8 && c <= 0xf6) return 1;
 
913
    if (c >= 0xf8 && c <= 0xfe) return 1;
 
914
    break;
 
915
 
 
916
  case ISO_8859_3:
 
917
    if (c == 0xa1) return 1;
 
918
    if (c == 0xa6) return 1;
 
919
    if (c >= 0xa9 && c <= 0xac) return 1;
 
920
    if (c == 0xaf) return 1;
 
921
    if (c >= 0xb1 && c <= 0xb3) return 1;
 
922
    if (c == 0xb5 || c == 0xb6) return 1;
 
923
    if (c >= 0xb9 && c <= 0xbd) return 1;
 
924
    if (c == 0xbf) return 1;
 
925
    if (c >= 0xc0 && c <= 0xc2) return 1;
 
926
    if (c >= 0xc4 && c <= 0xcf) return 1;
 
927
    if (c >= 0xd1 && c <= 0xd6) return 1;
 
928
    if (c >= 0xd8 && c <= 0xe2) return 1;
 
929
    if (c >= 0xe4 && c <= 0xef) return 1;
 
930
    if (c >= 0xf1 && c <= 0xf6) return 1;
 
931
    if (c >= 0xf8 && c <= 0xfe) return 1;
 
932
    break;
 
933
 
 
934
  case ISO_8859_4:
 
935
    if (c >= 0xa1 && c <= 0xa3) return 1;
 
936
    if (c == 0xa5 || c == 0xa6) return 1;
 
937
    if (c >= 0xa9 && c <= 0xac) return 1;
 
938
    if (c == 0xae) return 1;
 
939
    if (c == 0xb1 || c == 0xb3) return 1;
 
940
    if (c == 0xb5 || c == 0xb6) return 1;
 
941
    if (c >= 0xb9 && c <= 0xbf) return 1;
 
942
    if (c >= 0xc0 && c <= 0xd6) return 1;
 
943
    if (c >= 0xd8 && c <= 0xf6) return 1;
 
944
    if (c >= 0xf8 && c <= 0xfe) return 1;
 
945
    break;
 
946
 
 
947
  case ISO_8859_5:
 
948
    if (c >= 0xa1 && c <= 0xcf && c != 0xad) return 1;
 
949
    if (c >= 0xd0 && c <= 0xff && c != 0xf0 && c != 0xfd) return 1;
 
950
    break;
 
951
 
 
952
  case ISO_8859_6:
 
953
    if (c >= 0xc1 && c <= 0xda) return 1;
 
954
    if (c >= 0xe0 && c <= 0xea) return 1;
 
955
    if (c >= 0xeb && c <= 0xf2) return 1;
 
956
    break;
 
957
 
 
958
  case ISO_8859_7:
 
959
    if (c == 0xb2 || c == 0xb3) return 1;
 
960
    if (c == 0xb6) return 1;
 
961
    if (c >= 0xb8 && c <= 0xba) return 1;
 
962
    if (c >= 0xbc && c <= 0xbf) return 1;
 
963
    if (c == 0xc0) return 1;
 
964
    if (c >= 0xc1 && c <= 0xdb && c != 0xd2) return 1;
 
965
    if (c >= 0xdc && c <= 0xfe) return 1;
 
966
    break;
 
967
 
 
968
  case ISO_8859_8:
 
969
    if (c == 0xb2 || c == 0xb3 || c == 0xb5 || c == 0xb9) return 1;
 
970
    if (c >= 0xbc && c <= 0xbe) return 1;
 
971
    if (c >= 0xe0 && c <= 0xfa) return 1;
 
972
    break;
 
973
 
 
974
  case ISO_8859_10:
 
975
    if (c >= 0xa1 && c <= 0xff) {
 
976
      if (c != 0xa7 && c != 0xad && c != 0xb0 && c != 0xb7 && c != 0xbd)
 
977
        return 1;
 
978
    }
 
979
    break;
 
980
 
 
981
  case ISO_8859_11:
 
982
    if (c >= 0xa1 && c <= 0xda) return 1;
 
983
    if (c >= 0xdf && c <= 0xfb) return 1;
 
984
    break;
 
985
 
 
986
  case ISO_8859_13:
 
987
    if (c == 0xa8) return 1;
 
988
    if (c == 0xaa) return 1;
 
989
    if (c == 0xaf) return 1;
 
990
    if (c == 0xb2 || c == 0xb3 || c == 0xb5 || c == 0xb9) return 1;
 
991
    if (c >= 0xbc && c <= 0xbe) return 1;
 
992
    if (c == 0xb8) return 1;
 
993
    if (c == 0xba) return 1;
 
994
    if (c >= 0xbf && c <= 0xd6) return 1;
 
995
    if (c >= 0xd8 && c <= 0xf6) return 1;
 
996
    if (c >= 0xf8 && c <= 0xfe) return 1;
 
997
    break;
 
998
 
 
999
  case ISO_8859_14:
 
1000
    if (c >= 0xa1 && c <= 0xff) {
 
1001
      if (c == 0xa3 || c == 0xa7 || c == 0xa9 || c == 0xad || c == 0xae ||
 
1002
          c == 0xb6) return 0;
 
1003
      return 1;
 
1004
    }
 
1005
    break;
 
1006
 
 
1007
  case ISO_8859_15:
 
1008
    if (c == 0xaa) return 1;
 
1009
    if (c >= 0xb2 && c <= 0xb3) return 1;
 
1010
    if (c == 0xb5) return 1;
 
1011
    if (c >= 0xb9 && c <= 0xba) return 1;
 
1012
    if (c >= 0xbc && c <= 0xbe) return 1;
 
1013
    if (c >= 0xc0 && c <= 0xd6) return 1;
 
1014
    if (c >= 0xd8 && c <= 0xf6) return 1;
 
1015
    if (c >= 0xf8 && c <= 0xff) return 1;
 
1016
    if (c == 0xa6) return 1;
 
1017
    if (c == 0xa8) return 1;
 
1018
    if (c == 0xb4) return 1;
 
1019
    if (c == 0xb8) return 1;
 
1020
    break;
 
1021
 
 
1022
  case ISO_8859_16:
 
1023
    if (c == 0xa1) return 1;
 
1024
    if (c == 0xa2) return 1;
 
1025
    if (c == 0xa3) return 1;
 
1026
    if (c == 0xa6) return 1;
 
1027
    if (c == 0xa8) return 1;
 
1028
    if (c == 0xaa) return 1;
 
1029
    if (c == 0xac) return 1;
 
1030
    if (c == 0xae) return 1;
 
1031
    if (c == 0xaf) return 1;
 
1032
    if (c == 0xb2) return 1;
 
1033
    if (c == 0xb3) return 1;
 
1034
    if (c == 0xb4) return 1;
 
1035
    if (c >= 0xb8 && c <= 0xba) return 1;
 
1036
    if (c == 0xbc) return 1;
 
1037
    if (c == 0xbd) return 1;
 
1038
    if (c == 0xbe) return 1;
 
1039
    if (c == 0xbf) return 1;
 
1040
    if (c >= 0xc0 && c <= 0xde) return 1;
 
1041
    if (c >= 0xdf && c <= 0xff) return 1;
 
1042
    break;
 
1043
 
 
1044
  case KOI8_R:
 
1045
    if (c == 0x9d) return 1;
 
1046
    if (c == 0xa3 || c == 0xb3) return 1;
 
1047
    /* fall */
 
1048
  case KOI8:
 
1049
    if (c >= 0xc0 && c <= 0xff) return 1;
 
1050
    break;
 
1051
 
 
1052
  default:
 
1053
    exit(-1);
 
1054
  }
 
1055
 
 
1056
  return 0;
 
1057
}
 
1058
 
 
1059
static int IsAscii(int enc, int c)
 
1060
{
 
1061
  if (c >= 0x00 && c <= 0x7f) return 1;
 
1062
  return 0;
 
1063
}
 
1064
 
 
1065
static int IsNewline(int enc, int c)
 
1066
{
 
1067
  if (c == 0x0a) return 1;
 
1068
  return 0;
 
1069
}
 
1070
 
 
1071
static int exec(FILE* fp, ENC_INFO* einfo)
 
1072
{
 
1073
#define NCOL  8
 
1074
 
 
1075
  int c, val, enc;
 
1076
 
 
1077
  enc = einfo->num;
 
1078
 
 
1079
  fprintf(fp, "static unsigned short Enc%s_CtypeTable[256] = {\n",
 
1080
          einfo->name);
 
1081
 
 
1082
  for (c = 0; c < 256; c++) {
 
1083
    val = 0;
 
1084
    if (IsNewline(enc, c))  val |= ONIGENC_CTYPE_NEWLINE;
 
1085
    if (IsAlpha (enc, c))   val |= ONIGENC_CTYPE_ALPHA;
 
1086
    if (IsBlank (enc, c))   val |= ONIGENC_CTYPE_BLANK;
 
1087
    if (IsCntrl (enc, c))   val |= ONIGENC_CTYPE_CNTRL;
 
1088
    if (IsDigit (enc, c))   val |= ONIGENC_CTYPE_DIGIT;
 
1089
    if (IsGraph (enc, c))   val |= ONIGENC_CTYPE_GRAPH;
 
1090
    if (IsLower (enc, c))   val |= ONIGENC_CTYPE_LOWER;
 
1091
    if (IsPrint (enc, c))   val |= ONIGENC_CTYPE_PRINT;
 
1092
    if (IsPunct (enc, c))   val |= ONIGENC_CTYPE_PUNCT;
 
1093
    if (IsSpace (enc, c))   val |= ONIGENC_CTYPE_SPACE;
 
1094
    if (IsUpper (enc, c))   val |= ONIGENC_CTYPE_UPPER;
 
1095
    if (IsXDigit(enc, c))   val |= ONIGENC_CTYPE_XDIGIT;
 
1096
    if (IsWord  (enc, c))   val |= ONIGENC_CTYPE_WORD;
 
1097
    if (IsAscii (enc, c))   val |= ONIGENC_CTYPE_ASCII;
 
1098
 
 
1099
    if (c % NCOL == 0) fputs("  ", fp);
 
1100
    fprintf(fp, "0x%04x", val);
 
1101
    if (c != 255) fputs(",", fp);
 
1102
    if (c != 0 && c % NCOL == (NCOL-1))
 
1103
      fputs("\n", fp);
 
1104
    else
 
1105
      fputs(" ", fp);
 
1106
  }
 
1107
  fprintf(fp, "};\n");
 
1108
  return 0;
 
1109
}
 
1110
 
 
1111
extern int main(int argc, char* argv[])
 
1112
{
 
1113
  int i;
 
1114
  FILE* fp = stdout;
 
1115
 
 
1116
  for (i = 0; i < sizeof(Info)/sizeof(ENC_INFO); i++) {
 
1117
    exec(fp, &Info[i]);
 
1118
  }
 
1119
}