src/bijfmtest.c
/* [<][>][^][v][top][bottom][index][help] */
FUNCTIONS
This source file includes following functions.
- vf_tfm_builtin_jfm_chartype
- main
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 struct s_chartype_info {
5 int char_code;
6 int char_type;
7 };
8
9 static struct s_chartype_info chartype_info_table[] = {
10 /* obtained by running mkbijfm.scm */
11 {0x2122, 9},
12 {0x2123, 9},
13 {0x2124, 8},
14 {0x2125, 8},
15 {0x2126, 4},
16 {0x2127, 4},
17 {0x2128, 4},
18 {0x2129, 5},
19 {0x212a, 4},
20 {0x212b, 2},
21 {0x212c, 2},
22 {0x212d, 4},
23 {0x212e, 4},
24 {0x212f, 5},
25 {0x2130, 5},
26 {0x2133, 5},
27 {0x2135, 5},
28 {0x2136, 3},
29 {0x2137, 3},
30 {0x2139, 3},
31 {0x213e, 4},
32 {0x2142, 4},
33 {0x2143, 4},
34 {0x2146, 4},
35 {0x2147, 4},
36 {0x2148, 5},
37 {0x2149, 5},
38 {0x214a, 6},
39 {0x214b, 1},
40 {0x214c, 6},
41 {0x214d, 1},
42 {0x214e, 6},
43 {0x214f, 1},
44 {0x2150, 6},
45 {0x2151, 1},
46 {0x2152, 6},
47 {0x2153, 1},
48 {0x2154, 6},
49 {0x2155, 1},
50 {0x2156, 6},
51 {0x2157, 1},
52 {0x2158, 6},
53 {0x2159, 1},
54 {0x215a, 6},
55 {0x215b, 1},
56 {0x2168, 3},
57 {0x2169, 3},
58 {0x216a, 3},
59 {0x216b, 5},
60 {0x216c, 5},
61 {0x216d, 5},
62 {0x2170, 3},
63 {0x2171, 3},
64 {0x2172, 3},
65 {0x2178, 5},
66 {0x2421, 3},
67 {0x2423, 3},
68 {0x2425, 3},
69 {0x2426, 7},
70 {0x2427, 3},
71 {0x2429, 3},
72 {0x242f, 7},
73 {0x2430, 7},
74 {0x2431, 7},
75 {0x2432, 7},
76 {0x2439, 7},
77 {0x243a, 7},
78 {0x2443, 3},
79 {0x2463, 3},
80 {0x2465, 3},
81 {0x2467, 3},
82 {0x246a, 7},
83 {0x246e, 3},
84 {0x2521, 3},
85 {0x2522, 10},
86 {0x2523, 3},
87 {0x2524, 10},
88 {0x2525, 3},
89 {0x2526, 10},
90 {0x2527, 3},
91 {0x2529, 3},
92 {0x252a, 10},
93 {0x252f, 11},
94 {0x2530, 11},
95 {0x2531, 10},
96 {0x2532, 10},
97 {0x2535, 10},
98 {0x2536, 10},
99 {0x253d, 10},
100 {0x253e, 10},
101 {0x253f, 11},
102 {0x2540, 11},
103 {0x2541, 10},
104 {0x2542, 10},
105 {0x2543, 3},
106 {0x2544, 10},
107 {0x2545, 10},
108 {0x2546, 7},
109 {0x2547, 7},
110 {0x2548, 10},
111 {0x2549, 10},
112 {0x254a, 10},
113 {0x254e, 12},
114 {0x2555, 10},
115 {0x2556, 10},
116 {0x2557, 10},
117 {0x255f, 10},
118 {0x2561, 10},
119 {0x2563, 3},
120 {0x2564, 7},
121 {0x2565, 3},
122 {0x2567, 3},
123 {0x2569, 10},
124 {0x256a, 10},
125 {0x256e, 3},
126 {0x256f, 10},
127 {0x2572, 10},
128 {0x2575, 3},
129 {0x2576, 3},
130 {0x2577, 3}
131 };
132
133
134 int
135 vf_tfm_builtin_jfm_chartype(long code_point)
/* [<][>][^][v][top][bottom][index][help] */
136 {
137 int ct;
138 int n, hi, lo, m;
139
140 n = sizeof(chartype_info_table) / sizeof(struct s_chartype_info);
141
142 if ((code_point < chartype_info_table[0].char_code)
143 || (chartype_info_table[n-1].char_code < code_point))
144 return 0;
145
146 lo = 0;
147 hi = n - 1;
148 while (lo < hi){
149 m = (lo + hi) / 2;
150 if (chartype_info_table[m].char_code == code_point)
151 return chartype_info_table[m].char_type;
152 if (code_point < chartype_info_table[m].char_code)
153 hi = m-1;
154 else
155 lo = m+1;
156 }
157
158 return 0;
159 }
160
161
162 int main(int argc, char **argv)
/* [<][>][^][v][top][bottom][index][help] */
163 {
164 long d;
165 int ct;
166
167 sscanf(argv[1], "%li", &d);
168
169 ct = vf_tfm_builtin_jfm_chartype(d);
170 printf("*** 0x%lx => %d\n", d, ct);
171 }