updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / links-utf8 / links-2.2-utf8.diff
blobcf3cedfba55c282bcfd17ea61c5579743d605238
1 diff -ur links-2.1pre31/charsets.c links-2.1pre31.utf8/charsets.c
2 --- links-2.1pre31/charsets.c 2006-07-09 05:35:52.000000000 +0300
3 +++ links-2.1pre31.utf8/charsets.c 2007-11-14 14:42:04.000000000 +0200
4 @@ -93,7 +93,7 @@
5 #define U_EQUAL(a, b) unicode_7b[a].x == (b)
6 #define U_ABOVE(a, b) unicode_7b[a].x > (b)
8 -static inline unsigned char *u2cp(int u, int to, int fallback)
9 +unsigned char *u2cp(int u, int to, int fallback)
11 int j, s;
12 again:
13 @@ -156,6 +156,22 @@
14 return utf_buffer;
17 +/* this slow and ugly code is used by the terminal utf_8_io */
18 +unsigned char *cp2utf_8(int from, int c)
20 + int j;
22 + if (codepages[from].table == table_utf_8) return strings[c];
23 + for (j = 0; codepages[from].table[j].c; j++) {
24 + if (codepages[from].table[j].c == c)
25 + {
26 + return encode_utf_8(codepages[from].table[j].u);
27 + }
28 + }
29 + if (c < 128) return strings[c];
30 + return encode_utf_8(UCS_NO_CHAR);
33 void add_utf_8(struct conv_table *ct, int u, unsigned char *str)
35 unsigned char *p = encode_utf_8(u);
36 diff -ur links-2.1pre31/default.c links-2.1pre31.utf8/default.c
37 --- links-2.1pre31/default.c 2007-10-24 19:19:29.000000000 +0300
38 +++ links-2.1pre31.utf8/default.c 2007-11-14 14:42:04.000000000 +0200
39 @@ -743,6 +743,7 @@
43 +/* terminal NAME(str) MODE(0-3) M11_HACK(0-1) BLOCK_CURSOR.RESTRICT_852.COL(0-7) CHARSET(str) [ UTF_8_IO("utf-8") ]*/
44 unsigned char *term_rd(struct option *o, unsigned char *c)
46 struct term_spec *ts;
47 @@ -753,6 +754,7 @@
48 mem_free(w);
49 goto end;
51 + ts->utf_8_io = 0;
52 mem_free(w);
53 if (!(w = get_token(&c))) goto err;
54 if (strlen(w) != 1 || w[0] < '0' || w[0] > '4') goto err_f;
55 @@ -773,6 +775,9 @@
56 if ((i = get_cp_index(w)) == -1 || is_cp_special(i)) goto err_f;
57 ts->charset = i;
58 mem_free(w);
59 + if (!(w = get_token(&c))) goto end;
60 + if (!(strcasecmp(w, "utf-8"))) ts->utf_8_io = 1;
61 + mem_free(w);
62 end:
63 return NULL;
64 err_f:
65 @@ -781,6 +786,7 @@
66 return "Error reading terminal specification";
69 +/* terminal2 NAME(str) MODE(0-3) M11_HACK(0-1) RESTRICT_852(0-1) COL(0-1) CHARSET(str) [ UTF_8_IO("utf-8") ]*/
70 unsigned char *term2_rd(struct option *o, unsigned char *c)
72 struct term_spec *ts;
73 @@ -791,6 +797,7 @@
74 mem_free(w);
75 goto end;
77 + ts->utf_8_io = 0;
78 mem_free(w);
79 if (!(w = get_token(&c))) goto err;
80 if (strlen(w) != 1 || w[0] < '0' || w[0] > '3') goto err_f;
81 @@ -812,6 +819,9 @@
82 if ((i = get_cp_index(w)) == -1 || is_cp_special(i)) goto err_f;
83 ts->charset = i;
84 mem_free(w);
85 + if (!(w = get_token(&c))) goto end;
86 + if (!(strcasecmp(w, "utf-8"))) ts->utf_8_io = 1;
87 + mem_free(w);
88 end:
89 return NULL;
90 err_f:
91 @@ -834,6 +844,10 @@
92 add_num_to_str(s, l, !!ts->col + !!ts->restrict_852 * 2 + !!ts->block_cursor * 4);
93 add_to_str(s, l, " ");
94 add_to_str(s, l, get_cp_mime_name(ts->charset));
95 + if (ts->utf_8_io)
96 + {
97 + add_to_str(s, l, " utf-8");
98 + }
102 diff -ur links-2.1pre31/intl/bahasa_indonesian.lng links-2.1pre31.utf8/intl/bahasa_indonesian.lng
103 --- links-2.1pre31/intl/bahasa_indonesian.lng 2007-10-24 19:19:34.000000000 +0300
104 +++ links-2.1pre31.utf8/intl/bahasa_indonesian.lng 2007-11-14 14:42:04.000000000 +0200
105 @@ -528,3 +528,4 @@
106 T_HK_COPY_URL_LOCATION, "C",
107 T_HK_BLOCK_URL, "B",
108 T_HK_BLOCK_LIST, "B",
109 +T_UTF_8_IO, "UTF-8 I/O",
110 diff -ur links-2.1pre31/intl/belarusian.lng links-2.1pre31.utf8/intl/belarusian.lng
111 --- links-2.1pre31/intl/belarusian.lng 2007-10-24 19:19:34.000000000 +0300
112 +++ links-2.1pre31.utf8/intl/belarusian.lng 2007-11-14 14:42:04.000000000 +0200
113 @@ -528,3 +528,4 @@
114 T_HK_COPY_URL_LOCATION, NULL,
115 T_HK_BLOCK_URL, NULL,
116 T_HK_BLOCK_LIST, NULL,
117 +T_UTF_8_IO, "UTF-8 I/O",
118 diff -ur links-2.1pre31/intl/brazilian_portuguese.lng links-2.1pre31.utf8/intl/brazilian_portuguese.lng
119 --- links-2.1pre31/intl/brazilian_portuguese.lng 2007-10-24 19:19:34.000000000 +0300
120 +++ links-2.1pre31.utf8/intl/brazilian_portuguese.lng 2007-11-14 14:42:04.000000000 +0200
121 @@ -528,3 +528,4 @@
122 T_HK_COPY_URL_LOCATION, NULL,
123 T_HK_BLOCK_URL, NULL,
124 T_HK_BLOCK_LIST, NULL,
125 +T_UTF_8_IO, "UTF-8 I/O",
126 diff -ur links-2.1pre31/intl/bulgarian.lng links-2.1pre31.utf8/intl/bulgarian.lng
127 --- links-2.1pre31/intl/bulgarian.lng 2007-10-24 19:19:34.000000000 +0300
128 +++ links-2.1pre31.utf8/intl/bulgarian.lng 2007-11-14 14:42:04.000000000 +0200
129 @@ -528,3 +528,4 @@
130 T_HK_COPY_URL_LOCATION, NULL,
131 T_HK_BLOCK_URL, NULL,
132 T_HK_BLOCK_LIST, NULL,
133 +T_UTF_8_IO, "UTF-8 I/O",
134 diff -ur links-2.1pre31/intl/catalan.lng links-2.1pre31.utf8/intl/catalan.lng
135 --- links-2.1pre31/intl/catalan.lng 2007-10-24 19:19:34.000000000 +0300
136 +++ links-2.1pre31.utf8/intl/catalan.lng 2007-11-14 14:42:04.000000000 +0200
137 @@ -528,3 +528,4 @@
138 T_HK_COPY_URL_LOCATION, NULL,
139 T_HK_BLOCK_URL, NULL,
140 T_HK_BLOCK_LIST, NULL,
141 +T_UTF_8_IO, "UTF-8 I/O",
142 diff -ur links-2.1pre31/intl/croatian.lng links-2.1pre31.utf8/intl/croatian.lng
143 --- links-2.1pre31/intl/croatian.lng 2007-10-24 19:19:34.000000000 +0300
144 +++ links-2.1pre31.utf8/intl/croatian.lng 2007-11-14 14:42:04.000000000 +0200
145 @@ -528,3 +528,4 @@
146 T_HK_COPY_URL_LOCATION, NULL,
147 T_HK_BLOCK_URL, NULL,
148 T_HK_BLOCK_LIST, NULL,
149 +T_UTF_8_IO, "UTF-8 I/O",
150 diff -ur links-2.1pre31/intl/czech.lng links-2.1pre31.utf8/intl/czech.lng
151 --- links-2.1pre31/intl/czech.lng 2007-10-24 19:19:35.000000000 +0300
152 +++ links-2.1pre31.utf8/intl/czech.lng 2007-11-14 14:42:04.000000000 +0200
153 @@ -528,3 +528,4 @@
154 T_HK_COPY_URL_LOCATION, "C",
155 T_HK_BLOCK_URL, "B",
156 T_HK_BLOCK_LIST, "B",
157 +T_UTF_8_IO, "UTF-8 I/O",
158 diff -ur links-2.1pre31/intl/danish.lng links-2.1pre31.utf8/intl/danish.lng
159 --- links-2.1pre31/intl/danish.lng 2007-10-24 19:19:35.000000000 +0300
160 +++ links-2.1pre31.utf8/intl/danish.lng 2007-11-14 14:42:04.000000000 +0200
161 @@ -528,3 +528,4 @@
162 T_HK_COPY_URL_LOCATION, NULL,
163 T_HK_BLOCK_URL, NULL,
164 T_HK_BLOCK_LIST, NULL,
165 +T_UTF_8_IO, "UTF-8 I/O",
166 diff -ur links-2.1pre31/intl/dutch.lng links-2.1pre31.utf8/intl/dutch.lng
167 --- links-2.1pre31/intl/dutch.lng 2007-10-24 19:19:35.000000000 +0300
168 +++ links-2.1pre31.utf8/intl/dutch.lng 2007-11-14 14:42:04.000000000 +0200
169 @@ -528,3 +528,4 @@
170 T_HK_COPY_URL_LOCATION, NULL,
171 T_HK_BLOCK_URL, NULL,
172 T_HK_BLOCK_LIST, NULL,
173 +T_UTF_8_IO, "UTF-8 I/O",
174 diff -ur links-2.1pre31/intl/english.lng links-2.1pre31.utf8/intl/english.lng
175 --- links-2.1pre31/intl/english.lng 2007-10-24 19:19:35.000000000 +0300
176 +++ links-2.1pre31.utf8/intl/english.lng 2007-11-14 14:42:04.000000000 +0200
177 @@ -528,3 +528,4 @@
178 T_HK_COPY_URL_LOCATION, "C",
179 T_HK_BLOCK_URL, "B",
180 T_HK_BLOCK_LIST, "B",
181 +T_UTF_8_IO, "UTF-8 I/O",
182 diff -ur links-2.1pre31/intl/estonian.lng links-2.1pre31.utf8/intl/estonian.lng
183 --- links-2.1pre31/intl/estonian.lng 2007-10-24 19:19:35.000000000 +0300
184 +++ links-2.1pre31.utf8/intl/estonian.lng 2007-11-14 14:42:04.000000000 +0200
185 @@ -528,3 +528,4 @@
186 T_HK_COPY_URL_LOCATION, NULL,
187 T_HK_BLOCK_URL, NULL,
188 T_HK_BLOCK_LIST, NULL,
189 +T_UTF_8_IO, "UTF-8 I/O",
190 diff -ur links-2.1pre31/intl/finnish.lng links-2.1pre31.utf8/intl/finnish.lng
191 --- links-2.1pre31/intl/finnish.lng 2007-10-24 19:19:35.000000000 +0300
192 +++ links-2.1pre31.utf8/intl/finnish.lng 2007-11-14 14:42:04.000000000 +0200
193 @@ -528,3 +528,4 @@
194 T_HK_COPY_URL_LOCATION, "U",
195 T_HK_BLOCK_URL, NULL,
196 T_HK_BLOCK_LIST, NULL,
197 +T_UTF_8_IO, "UTF-8 I/O",
198 diff -ur links-2.1pre31/intl/french.lng links-2.1pre31.utf8/intl/french.lng
199 --- links-2.1pre31/intl/french.lng 2007-10-24 19:19:35.000000000 +0300
200 +++ links-2.1pre31.utf8/intl/french.lng 2007-11-14 14:42:04.000000000 +0200
201 @@ -528,3 +528,4 @@
202 T_HK_COPY_URL_LOCATION, NULL,
203 T_HK_BLOCK_URL, NULL,
204 T_HK_BLOCK_LIST, NULL,
205 +T_UTF_8_IO, "UTF-8 I/O",
206 diff -ur links-2.1pre31/intl/galician.lng links-2.1pre31.utf8/intl/galician.lng
207 --- links-2.1pre31/intl/galician.lng 2007-10-24 19:19:35.000000000 +0300
208 +++ links-2.1pre31.utf8/intl/galician.lng 2007-11-14 14:42:04.000000000 +0200
209 @@ -528,3 +528,4 @@
210 T_HK_COPY_URL_LOCATION, NULL,
211 T_HK_BLOCK_URL, NULL,
212 T_HK_BLOCK_LIST, NULL,
213 +T_UTF_8_IO, "UTF-8 I/O",
214 diff -ur links-2.1pre31/intl/german.lng links-2.1pre31.utf8/intl/german.lng
215 --- links-2.1pre31/intl/german.lng 2007-10-24 19:19:35.000000000 +0300
216 +++ links-2.1pre31.utf8/intl/german.lng 2007-11-14 14:42:04.000000000 +0200
217 @@ -528,3 +528,4 @@
218 T_HK_COPY_URL_LOCATION, "U",
219 T_HK_BLOCK_URL, NULL,
220 T_HK_BLOCK_LIST, NULL,
221 +T_UTF_8_IO, "UTF-8 I/O",
222 diff -ur links-2.1pre31/intl/greek.lng links-2.1pre31.utf8/intl/greek.lng
223 --- links-2.1pre31/intl/greek.lng 2007-10-24 19:19:35.000000000 +0300
224 +++ links-2.1pre31.utf8/intl/greek.lng 2007-11-14 14:42:04.000000000 +0200
225 @@ -528,3 +528,4 @@
226 T_HK_COPY_URL_LOCATION, NULL,
227 T_HK_BLOCK_URL, NULL,
228 T_HK_BLOCK_LIST, NULL,
229 +T_UTF_8_IO, "UTF-8 I/O",
230 diff -ur links-2.1pre31/intl/hungarian.lng links-2.1pre31.utf8/intl/hungarian.lng
231 --- links-2.1pre31/intl/hungarian.lng 2007-10-24 19:19:35.000000000 +0300
232 +++ links-2.1pre31.utf8/intl/hungarian.lng 2007-11-14 14:42:04.000000000 +0200
233 @@ -528,3 +528,4 @@
234 T_HK_COPY_URL_LOCATION, NULL,
235 T_HK_BLOCK_URL, NULL,
236 T_HK_BLOCK_LIST, NULL,
237 +T_UTF_8_IO, "UTF-8 I/O",
238 diff -ur links-2.1pre31/intl/icelandic.lng links-2.1pre31.utf8/intl/icelandic.lng
239 --- links-2.1pre31/intl/icelandic.lng 2007-10-24 19:19:35.000000000 +0300
240 +++ links-2.1pre31.utf8/intl/icelandic.lng 2007-11-14 14:42:04.000000000 +0200
241 @@ -528,3 +528,4 @@
242 T_HK_COPY_URL_LOCATION, NULL,
243 T_HK_BLOCK_URL, NULL,
244 T_HK_BLOCK_LIST, NULL,
245 +T_UTF_8_IO, "UTF-8 I/O",
246 diff -ur links-2.1pre31/intl/italian.lng links-2.1pre31.utf8/intl/italian.lng
247 --- links-2.1pre31/intl/italian.lng 2007-10-24 19:19:35.000000000 +0300
248 +++ links-2.1pre31.utf8/intl/italian.lng 2007-11-14 14:42:04.000000000 +0200
249 @@ -528,3 +528,4 @@
250 T_HK_COPY_URL_LOCATION, NULL,
251 T_HK_BLOCK_URL, NULL,
252 T_HK_BLOCK_LIST, NULL,
253 +T_UTF_8_IO, "UTF-8 I/O",
254 diff -ur links-2.1pre31/intl/lithuanian.lng links-2.1pre31.utf8/intl/lithuanian.lng
255 --- links-2.1pre31/intl/lithuanian.lng 2007-10-24 19:19:35.000000000 +0300
256 +++ links-2.1pre31.utf8/intl/lithuanian.lng 2007-11-14 14:42:04.000000000 +0200
257 @@ -528,3 +528,4 @@
258 T_HK_COPY_URL_LOCATION, NULL,
259 T_HK_BLOCK_URL, NULL,
260 T_HK_BLOCK_LIST, NULL,
261 +T_UTF_8_IO, "UTF-8 I/O",
262 diff -ur links-2.1pre31/intl/norwegian.lng links-2.1pre31.utf8/intl/norwegian.lng
263 --- links-2.1pre31/intl/norwegian.lng 2007-10-24 19:19:35.000000000 +0300
264 +++ links-2.1pre31.utf8/intl/norwegian.lng 2007-11-14 14:42:04.000000000 +0200
265 @@ -528,3 +528,4 @@
266 T_HK_COPY_URL_LOCATION, "C",
267 T_HK_BLOCK_URL, "B",
268 T_HK_BLOCK_LIST, "B",
269 +T_UTF_8_IO, "UTF-8 I/O",
270 diff -ur links-2.1pre31/intl/polish.lng links-2.1pre31.utf8/intl/polish.lng
271 --- links-2.1pre31/intl/polish.lng 2007-10-24 19:19:35.000000000 +0300
272 +++ links-2.1pre31.utf8/intl/polish.lng 2007-11-14 14:42:04.000000000 +0200
273 @@ -528,3 +528,4 @@
274 T_HK_COPY_URL_LOCATION, NULL,
275 T_HK_BLOCK_URL, NULL,
276 T_HK_BLOCK_LIST, NULL,
277 +T_UTF_8_IO, "UTF-8 I/O",
278 diff -ur links-2.1pre31/intl/portuguese.lng links-2.1pre31.utf8/intl/portuguese.lng
279 --- links-2.1pre31/intl/portuguese.lng 2007-10-24 19:19:35.000000000 +0300
280 +++ links-2.1pre31.utf8/intl/portuguese.lng 2007-11-14 14:42:04.000000000 +0200
281 @@ -528,3 +528,4 @@
282 T_HK_COPY_URL_LOCATION, NULL,
283 T_HK_BLOCK_URL, NULL,
284 T_HK_BLOCK_LIST, NULL,
285 +T_UTF_8_IO, "UTF-8 I/O",
286 diff -ur links-2.1pre31/intl/romanian.lng links-2.1pre31.utf8/intl/romanian.lng
287 --- links-2.1pre31/intl/romanian.lng 2007-10-24 19:19:35.000000000 +0300
288 +++ links-2.1pre31.utf8/intl/romanian.lng 2007-11-14 14:42:04.000000000 +0200
289 @@ -528,3 +528,4 @@
290 T_HK_COPY_URL_LOCATION, NULL,
291 T_HK_BLOCK_URL, NULL,
292 T_HK_BLOCK_LIST, NULL,
293 +T_UTF_8_IO, "UTF-8 I/O",
294 diff -ur links-2.1pre31/intl/russian.lng links-2.1pre31.utf8/intl/russian.lng
295 --- links-2.1pre31/intl/russian.lng 2007-10-24 19:19:35.000000000 +0300
296 +++ links-2.1pre31.utf8/intl/russian.lng 2007-11-14 14:42:04.000000000 +0200
297 @@ -528,3 +528,4 @@
298 T_HK_COPY_URL_LOCATION, NULL,
299 T_HK_BLOCK_URL, NULL,
300 T_HK_BLOCK_LIST, NULL,
301 +T_UTF_8_IO, "UTF-8 I/O",
302 diff -ur links-2.1pre31/intl/serbian.lng links-2.1pre31.utf8/intl/serbian.lng
303 --- links-2.1pre31/intl/serbian.lng 2007-10-24 19:19:35.000000000 +0300
304 +++ links-2.1pre31.utf8/intl/serbian.lng 2007-11-14 14:42:04.000000000 +0200
305 @@ -528,3 +528,4 @@
306 T_HK_COPY_URL_LOCATION, "�,
307 T_HK_BLOCK_URL, NULL,
308 T_HK_BLOCK_LIST, NULL,
309 +T_UTF_8_IO, "UTF-8 I/O",
310 diff -ur links-2.1pre31/intl/slovak.lng links-2.1pre31.utf8/intl/slovak.lng
311 --- links-2.1pre31/intl/slovak.lng 2007-10-24 19:19:35.000000000 +0300
312 +++ links-2.1pre31.utf8/intl/slovak.lng 2007-11-14 14:42:04.000000000 +0200
313 @@ -528,3 +528,4 @@
314 T_HK_COPY_URL_LOCATION, NULL,
315 T_HK_BLOCK_URL, NULL,
316 T_HK_BLOCK_LIST, NULL,
317 +T_UTF_8_IO, "UTF-8 I/O",
318 diff -ur links-2.1pre31/intl/swedish.lng links-2.1pre31.utf8/intl/swedish.lng
319 --- links-2.1pre31/intl/swedish.lng 2007-10-24 19:19:35.000000000 +0300
320 +++ links-2.1pre31.utf8/intl/swedish.lng 2007-11-14 14:42:04.000000000 +0200
321 @@ -528,3 +528,4 @@
322 T_HK_COPY_URL_LOCATION, NULL,
323 T_HK_BLOCK_URL, NULL,
324 T_HK_BLOCK_LIST, NULL,
325 +T_UTF_8_IO, "UTF-8 I/O",
326 diff -ur links-2.1pre31/intl/turkish.lng links-2.1pre31.utf8/intl/turkish.lng
327 --- links-2.1pre31/intl/turkish.lng 2007-10-24 19:19:35.000000000 +0300
328 +++ links-2.1pre31.utf8/intl/turkish.lng 2007-11-14 14:42:04.000000000 +0200
329 @@ -528,3 +528,4 @@
330 T_HK_COPY_URL_LOCATION, NULL,
331 T_HK_BLOCK_URL, NULL,
332 T_HK_BLOCK_LIST, NULL,
333 +T_UTF_8_IO, "UTF-8 I/O",
334 diff -ur links-2.1pre31/intl/ukrainian.lng links-2.1pre31.utf8/intl/ukrainian.lng
335 --- links-2.1pre31/intl/ukrainian.lng 2007-10-24 19:19:35.000000000 +0300
336 +++ links-2.1pre31.utf8/intl/ukrainian.lng 2007-11-14 14:42:04.000000000 +0200
337 @@ -528,3 +528,4 @@
338 T_HK_COPY_URL_LOCATION, NULL,
339 T_HK_BLOCK_URL, NULL,
340 T_HK_BLOCK_LIST, NULL,
341 +T_UTF_8_IO, "UTF-8 I/O",
342 diff -ur links-2.1pre31/intl/upper_sorbian.lng links-2.1pre31.utf8/intl/upper_sorbian.lng
343 --- links-2.1pre31/intl/upper_sorbian.lng 2007-10-24 19:19:36.000000000 +0300
344 +++ links-2.1pre31.utf8/intl/upper_sorbian.lng 2007-11-14 14:42:04.000000000 +0200
345 @@ -528,3 +528,4 @@
346 T_HK_COPY_URL_LOCATION, NULL,
347 T_HK_BLOCK_URL, NULL,
348 T_HK_BLOCK_LIST, NULL,
349 +T_UTF_8_IO, "UTF-8 I/O",
350 diff -ur links-2.1pre31/links.h links-2.1pre31.utf8/links.h
351 --- links-2.1pre31/links.h 2007-10-27 04:36:22.000000000 +0300
352 +++ links-2.1pre31.utf8/links.h 2007-11-14 14:42:04.000000000 +0200
353 @@ -1879,6 +1879,11 @@
354 #ifdef G
355 struct graphics_device *dev;
356 #endif
357 + struct {
358 + int ucs;
359 + int len;
360 + int min;
361 + } utf_8;
364 struct term_spec {
365 @@ -1887,6 +1892,7 @@
366 unsigned char term[MAX_TERM_LEN];
367 int mode;
368 int m11_hack;
369 + int utf_8_io;
370 int restrict_852;
371 int block_cursor;
372 int col;
373 @@ -3457,6 +3463,9 @@
375 /* charsets.c */
377 +/* UCS/Unicode replacement character */
378 +#define UCS_NO_CHAR 0xFFFD
380 #include "codepage.h"
382 extern int utf8_table;
383 @@ -3480,6 +3489,8 @@
384 void free_conv_table(void);
385 unsigned char *encode_utf_8(int);
386 int cp2u(unsigned char, int);
387 +unsigned char *cp2utf_8(int, int);
388 +unsigned char *u2cp(int, int, int);
390 unsigned char charset_upcase(unsigned char, int);
391 void charset_upcase_string(unsigned char **, int);
392 diff -ur links-2.1pre31/menu.c links-2.1pre31.utf8/menu.c
393 --- links-2.1pre31/menu.c 2007-10-24 19:19:30.000000000 +0300
394 +++ links-2.1pre31.utf8/menu.c 2007-11-14 14:42:04.000000000 +0200
395 @@ -537,14 +537,14 @@
396 cls_redraw_all_terminals();
399 -unsigned char *td_labels[] = { TEXT(T_NO_FRAMES), TEXT(T_VT_100_FRAMES), TEXT(T_LINUX_OR_OS2_FRAMES), TEXT(T_KOI8R_FRAMES), TEXT(T_FREEBSD_FRAMES), TEXT(T_USE_11M), TEXT(T_RESTRICT_FRAMES_IN_CP850_852), TEXT(T_BLOCK_CURSOR), TEXT(T_COLOR), TEXT(T_BRAILLE_TERMINAL), NULL };
400 +unsigned char *td_labels[] = { TEXT(T_NO_FRAMES), TEXT(T_VT_100_FRAMES), TEXT(T_LINUX_OR_OS2_FRAMES), TEXT(T_KOI8R_FRAMES), TEXT(T_FREEBSD_FRAMES), TEXT(T_USE_11M), TEXT(T_RESTRICT_FRAMES_IN_CP850_852), TEXT(T_BLOCK_CURSOR), TEXT(T_COLOR), TEXT(T_BRAILLE_TERMINAL), TEXT(T_UTF_8_IO), NULL };
402 void terminal_options(struct terminal *term, void *xxx, struct session *ses)
404 struct dialog *d;
405 struct term_spec *ts = new_term_spec(term->term);
406 if (!ts) return;
407 - d = mem_calloc(sizeof(struct dialog) + 12 * sizeof(struct dialog_item));
408 + d = mem_calloc(sizeof(struct dialog) + 14 * sizeof(struct dialog_item));
409 d->title = TEXT(T_TERMINAL_OPTIONS);
410 d->fn = checkbox_list_fn;
411 d->udata = td_labels;
412 @@ -594,15 +594,19 @@
413 d->items[9].gid = 0;
414 d->items[9].dlen = sizeof(int);
415 d->items[9].data = (void *)&ts->braille;
416 - d->items[10].type = D_BUTTON;
417 - d->items[10].gid = B_ENTER;
418 - d->items[10].fn = ok_dialog;
419 - d->items[10].text = TEXT(T_OK);
420 + d->items[10].type = D_CHECKBOX;
421 + d->items[10].gid = 0;
422 + d->items[10].dlen = sizeof(int);
423 + d->items[10].data = (void *)&ts->utf_8_io; d->items[11].type = D_BUTTON;
424 d->items[11].type = D_BUTTON;
425 - d->items[11].gid = B_ESC;
426 - d->items[11].fn = cancel_dialog;
427 - d->items[11].text = TEXT(T_CANCEL);
428 - d->items[12].type = D_END;
429 + d->items[11].gid = B_ENTER;
430 + d->items[11].fn = ok_dialog;
431 + d->items[11].text = TEXT(T_OK);
432 + d->items[12].type = D_BUTTON;
433 + d->items[12].gid = B_ESC;
434 + d->items[12].fn = cancel_dialog;
435 + d->items[12].text = TEXT(T_CANCEL);
436 + d->items[13].type = D_END;
437 do_dialog(term, d, getml(d, NULL));
440 diff -ur links-2.1pre31/terminal.c links-2.1pre31.utf8/terminal.c
441 --- links-2.1pre31/terminal.c 2007-10-27 04:36:22.000000000 +0300
442 +++ links-2.1pre31.utf8/terminal.c 2007-11-14 14:45:25.000000000 +0200
443 @@ -680,6 +680,25 @@
445 #endif
447 +static inline void term_send_event(struct terminal *term, struct event *ev)
449 + ((struct window *)&term->windows)->next->handler(term->windows.next, ev, 0);
452 +static inline void term_send_ucs(struct terminal *term, struct event *ev, int u)
454 + unsigned char *recoded;
456 + if (u == 0xA0) u = ' ';
457 + recoded = u2cp(u, term->spec->charset, 1);
458 + if (! recoded) recoded = "*";
459 + while (*recoded) {
460 + ev->x = *recoded;
461 + term_send_event(term, ev);
462 + recoded ++;
466 void in_term(struct terminal *term)
468 struct event *ev;
469 @@ -739,7 +758,40 @@
470 goto send_redraw;
472 else if (ev->ev == EV_KBD && ev->x == KBD_CTRL_C) ((struct window *)(void *)&term->windows)->prev->handler(term->windows.prev, ev, 0);
473 - else ((struct window *)(void *)&term->windows)->next->handler(term->windows.next, ev, 0);
474 + else if (ev->ev == EV_KBD) {
475 + if (term->utf_8.len) {
476 + if ((ev->x & 0xC0) == 0x80 && term->spec->utf_8_io) {
477 + term->utf_8.ucs <<= 6;
478 + term->utf_8.ucs |= ev->x & 0x3F;
479 + if (! --term->utf_8.len) {
480 + int u = term->utf_8.ucs;
482 + if (u < term->utf_8.min) u = UCS_NO_CHAR;
483 + term_send_ucs(term, ev, u);
485 + goto mm;
486 + } else {
487 + term->utf_8.len = 0;
488 + term_send_ucs(term, ev, UCS_NO_CHAR);
491 + if (ev->x < 0x80 || ev->x > 0xFF || ! term->spec->utf_8_io) {
492 + term_send_event(term, ev);
493 + goto mm;
494 + } else if ((ev->x & 0xC0) == 0xC0 && (ev->x & 0xFE) != 0xFE) {
495 + int mask, len = 0, cov = 0x80;
497 + for (mask = 0x80; ev->x & mask; mask >>= 1) {
498 + len++;
499 + term->utf_8.min = cov;
500 + cov = 1 << (1 + 5 * len);
502 + term->utf_8.len = len - 1;
503 + term->utf_8.ucs = ev->x & (mask - 1);
504 + goto mm;
506 + term_send_ucs(term, ev, UCS_NO_CHAR);
507 + } else term_send_event(term, ev);
509 if (ev->ev == EV_ABORT) {
510 destroy_terminal(term);
511 @@ -759,6 +811,14 @@
513 unsigned char frame_dumb[48] = " ||||++||++++++--|-+||++--|-+----++++++++ ";
514 unsigned char frame_vt100[48] = "aaaxuuukkuxkjjjkmvwtqnttmlvwtqnvvwwmmllnnjla ";
515 +unsigned char frame_vt100_u[48] = {
516 + 177,177,177,179,180,180,180,191,
517 + 191,180,179,191,217,217,217,191,
518 + 192,193,194,195,196,197,195,195,
519 + 192,218,193,194,195,196,197,193,
520 + 193,194,194,192,192,218,218,197,
521 + 197,217,218,177, 32, 32, 32, 32
523 unsigned char frame_koi[48] = {
524 144,145,146,129,135,178,180,167,
525 166,181,161,168,174,173,172,131,
526 @@ -790,7 +850,7 @@
527 unsigned char c = ch & 0xff; \
528 unsigned char A = ch >> 8 & 0x7f; \
529 if (s->mode == TERM_LINUX) { \
530 - if (s->m11_hack) { \
531 + if (s->m11_hack && !s->utf_8_io) { \
532 if ((int)(ch >> 15) != mode) { \
533 if (!(mode = ch >> 15)) add_to_str(&a, &l, "\033[10m"); \
534 else add_to_str(&a, &l, "\033[11m"); \
535 @@ -799,12 +859,14 @@
536 if (s->restrict_852 && (ch >> 15) && c >= 176 && c < 224) { \
537 if (frame_restrict[c - 176]) c = frame_restrict[c - 176]; \
539 - } else if (s->mode == TERM_VT100) { \
540 + } else if (s->mode == TERM_VT100 && !s->utf_8_io) { \
541 if ((int)(ch >> 15) != mode) { \
542 if (!(mode = ch >> 15)) add_to_str(&a, &l, "\017"); \
543 else add_to_str(&a, &l, "\016"); \
545 if (mode && c >= 176 && c < 224) c = frame_vt100[c - 176]; \
546 + } else if (s->mode == TERM_VT100 && (ch >> 15) && c >= 176 && c < 224) { \
547 + c = frame_vt100_u[c - 176]; \
548 } else if (s->mode == TERM_KOI8 && (ch >> 15) && c >= 176 && c < 224) { c = frame_koi[c - 176];\
549 } else if (s->mode == TERM_FREEBSD && (ch >> 15) && c >= 176 && c < 224) { c = frame_freebsd[c - 176];\
550 } else if (s->mode == TERM_DUMB && (ch >> 15) && c >= 176 && c < 224) c = frame_dumb[c - 176];\
551 @@ -825,7 +887,20 @@
552 if (attrib & 0100) add_to_str(&a, &l, ";1"); \
553 add_to_str(&a, &l, "m"); \
555 - if (c >= ' ' && c != 127/* && c != 155*/) add_chr_to_str(&a, &l, c); \
556 + if (c >= ' ' && c != 127/* && c != 155*/) { \
557 + int charset = s->charset; \
559 + if (ch >> 15) { \
560 + int frames_charset = (s->mode == TERM_LINUX || s->mode == TERM_VT100) \
561 + ? get_cp_index("cp437") \
562 + : s->mode == TERM_KOI8 \
563 + ? get_cp_index("koi8-r") \
564 + : -1; \
565 + if (frames_charset != -1) charset = frames_charset; \
566 + } \
567 + if (s->utf_8_io) add_to_str(&a, &l, cp2utf_8(charset, c)); \
568 + else add_chr_to_str(&a, &l, c); \
569 + } \
570 else if (!c || c == 1) add_chr_to_str(&a, &l, ' '); \
571 else add_chr_to_str(&a, &l, '.'); \
572 cx++; \