summaryrefslogtreecommitdiffstats
path: root/feed/test-lex-c.c
blob: 9b984bb887b5f73cb7d643c29ec7c50ab60c19ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
static const Summary16 jisx0208_uni2indx_page30[16] = {
  /* 0x3000 */
  {  232, 0xffef }, {  247, 0x103f }, {  254, 0x0000 }, {  254, 0x0000 },
  {  254, 0xfffe }, {  269, 0xffff }, {  285, 0xffff }, {  301, 0xffff },
  {  317, 0xffff }, {  333, 0x780f }, {  341, 0xfffe }, {  356, 0xffff },
  {  372, 0xffff }, {  388, 0xffff }, {  404, 0xffff }, {  420, 0x787f },
};
static const Summary16 jisx0208_uni2indx_page4e[1307] = {
  /* 0x4e00 */
  {  431, 0x6f8b }, {  441, 0x43f3 }, {  450, 0x2442 }, {  454, 0x9b46 },
  {  462, 0xe82c }, {  469, 0xe3e0 }, {  477, 0x0004 }, {  478, 0x400a },
  {  481, 0x5f65 }, {  491, 0xdb36 }, {  501, 0x7977 }, {  512, 0x0449 },
  {  516, 0xecd7 }, {  527, 0xe3f0 }, {  536, 0x6038 }, {  541, 0x08c5 },
  /* 0x4f00 */
  {  546, 0xe602 }, {  552, 0x3403 }, {  557, 0x8000 }, {  558, 0x3551 },
  {  565, 0xe0c8 }, {  571, 0x7eab }, {  582, 0x8200 }, {  584, 0x9869 },
  {  591, 0xa948 }, {  597, 0x2942 }, {  602, 0xe803 }, {  608, 0x8060 },
  {  611, 0x441c }, {  616, 0xad93 }, {  625, 0xc03a }, {  631, 0x4568 },
  /* 0x5000 */
  {  637, 0xaa60 }, {  643, 0x8656 }, {  650, 0x3f7a }, {  661, 0x0240 },
  {  663, 0x8388 }, {  668, 0x1461 }, {  673, 0x1020 }, {  675, 0x2174 },
  {  681, 0x2021 }, {  684, 0x0702 }, {  688, 0x3000 }, {  690, 0x40bc },
  {  696, 0xa624 }, {  702, 0x4462 }, {  707, 0x60a8 }, {  712, 0x0a20 },
  /* 0x5100 */
  {  715, 0x0217 }, {  720, 0x8574 }, {  727, 0x0402 }, {  729, 0x9c84 },
  {  735, 0x7bfb }, {  748, 0x1415 }, {  753, 0x7f24 }, {  762, 0x11e2 },


jisx0208_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)
{
  if (n >= 2) {
    const Summary16 *summary = NULL;
    if (wc >= 0x0000 && wc < 0x0100)
      summary = &jisx0208_uni2indx_page00[(wc>>4)];
    else if (wc >= 0x0300 && wc < 0x0460)
      summary = &jisx0208_uni2indx_page03[(wc>>4)-0x030];
    else if (wc >= 0x2000 && wc < 0x2320)
      summary = &jisx0208_uni2indx_page20[(wc>>4)-0x200];
    else if (wc >= 0x2500 && wc < 0x2670)
      summary = &jisx0208_uni2indx_page25[(wc>>4)-0x250];
    else if (wc >= 0x3000 && wc < 0x3100)
      summary = &jisx0208_uni2indx_page30[(wc>>4)-0x300];
    else if (wc >= 0x4e00 && wc < 0x9fb0)
      summary = &jisx0208_uni2indx_page4e[(wc>>4)-0x4e0];
    else if (wc >= 0xff00 && wc < 0xfff0)
      summary = &jisx0208_uni2indx_pageff[(wc>>4)-0xff0];
    if (summary) {
      unsigned short used = summary->used;
      unsigned int i = wc & 0x0f;
      if (used & ((unsigned short) 1 << i)) {
        unsigned short c;
        /* Keep in `used' only the bits 0..i-1. */
        used &= ((unsigned short) 1 << i) - 1;
        /* Add `summary->indx' and the number of bits set in `used'. */
        used = (used & 0x5555) + ((used & 0xaaaa) >> 1);
        used = (used & 0x3333) + ((used & 0xcccc) >> 2);
        used = (used & 0x0f0f) + ((used & 0xf0f0) >> 4);
        used = (used & 0x00ff) + (used >> 8);
        c = jisx0208_2charset[summary->indx + used];
        r[0] = (c >> 8); r[1] = (c & 0xff);
        return 2;
      }
    }
    return RET_ILUNI;
  }
  return RET_TOOSMALL;
}


static const unsigned short jisx0208_2uni_page30[6398] = {
  /* 0x30 */
  0x4e9c, 0x5516, 0x5a03, 0x963f, 0x54c0, 0x611b, 0x6328, 0x59f6,
  0x9022, 0x8475, 0x831c, 0x7a50, 0x60aa, 0x63e1, 0x6e25, 0x65ed,
  0x8466, 0x82a6, 0x9bf5, 0x6893, 0x5727, 0x65a1, 0x6271, 0x5b9b,
  0x59d0, 0x867b, 0x98f4, 0x7d62, 0x7dbe, 0x9b8e, 0x6216, 0x7c9f,
  0x88b7, 0x5b89, 0x5eb5, 0x6309, 0x6697, 0x6848, 0x95c7, 0x978d,
  0x674f, 0x4ee5, 0x4f0a, 0x4f4d, 0x4f9d, 0x5049, 0x56f2, 0x5937,
  0x59d4, 0x5a01, 0x5c09, 0x60df, 0x610f, 0x6170, 0x6613, 0x6905,
  0x70ba, 0x754f, 0x7570, 0x79fb, 0x7dad, 0x7def, 0x80c3, 0x840e,
  0x8863, 0x8b02, 0x9055, 0x907a, 0x533b, 0x4e95, 0x4ea5, 0x57df,
  0x80b2, 0x90c1, 0x78ef, 0x4e00, 0x58f1, 0x6ea2, 0x9038, 0x7a32,
  0x8328, 0x828b, 0x9c2f, 0x5141, 0x5370, 0x54bd, 0x54e1, 0x56e0,
  0x59fb, 0x5f15, 0x98f2, 0x6deb, 0x80e4, 0x852d,
  /* 0x31 */
  0x9662, 0x9670, 0x96a0, 0x97fb, 0x540b, 0x53f3, 0x5b87, 0x70cf,
  0x7fbd, 0x8fc2, 0x96e8, 0x536f, 0x9d5c, 0x7aba, 0x4e11, 0x7893,
  0x81fc, 0x6e26, 0x5618, 0x5504, 0x6b1d, 0x851a, 0x9c3b, 0x59e5,
  0x53a9, 0x6d66, 0x74dc, 0x958f, 0x5642, 0x4e91, 0x904b, 0x96f2,
  0x834f, 0x990c, 0x53e1, 0x55b6, 0x5b30, 0x5f71, 0x6620, 0x66f3,
  0x6804, 0x6c38, 0x6cf3, 0x6d29, 0x745b, 0x76c8, 0x7a4e, 0x9834,
  0x82f1, 0x885b, 0x8a60, 0x92ed, 0x6db2, 0x75ab, 0x76ca, 0x99c5,
  0x60a6, 0x8b01, 0x8d8a, 0x95b2, 0x698e, 0x53ad, 0x5186, 0x5712,
  0x5830, 0x5944, 0x5bb4, 0x5ef6, 0x6028, 0x63a9, 0x63f4, 0x6cbf,
  0x6f14, 0x708e, 0x7114, 0x7159, 0x71d5, 0x733f, 0x7e01, 0x8276,
  0x82d1, 0x8597, 0x9060, 0x925b, 0x9d1b, 0x5869, 0x65bc, 0x6c5a,
  0x7525, 0x51f9, 0x592e, 0x5965, 0x5f80, 0x5fdc,
  /* 0x32 */
  0x62bc, 0x65fa, 0x6a2a, 0x6b27, 0x6bb4, 0x738b, 0x7fc1, 0x8956,
  0x9d2c, 0x9d0e, 0x9ec4, 0x5ca1, 0x6c96, 0x837b, 0x5104, 0x5c4b,
  0x61b6, 0x81c6, 0x6876, 0x7261, 0x4e59, 0x4ffa, 0x5378, 0x6069,
  0x6e29, 0x7a4f, 0x97f3, 0x4e0b, 0x5316, 0x4eee, 0x4f55, 0x4f3d,
  0x4fa1, 0x4f73, 0x52a0, 0x53ef, 0x5609, 0x590f, 0x5ac1, 0x5bb6,
  0x5be1, 0x79d1, 0x6687, 0x679c, 0x67b6, 0x6b4c, 0x6cb3, 0x706b,


int main(int argc, char argv[]) {

    /* multiline
     * foo */

    // c comment

    fprintf(stderr, "this is a \"string %s %i", 0x5656, 6786);

    c = 'c';
    c = '\\';
    c = '\000';

    FOO_BAR(blafasel);
}



  dies_ist_ein_test
___DIES___IST___EIN__TEST_______

  alpha beta gamma
  _________


  DiesIstEinTest

  Dies_Ist_Ein_Test___

  ArschTritt

  deppVomLande