428
|
1 /* Functions to handle multilingual characters.
|
|
2 Copyright (C) 1992, 1995 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1995 Sun Microsystems, Inc.
|
771
|
4 Copyright (C) 2001, 2002 Ben Wing.
|
428
|
5
|
|
6 This file is part of XEmacs.
|
|
7
|
|
8 XEmacs is free software; you can redistribute it and/or modify it
|
|
9 under the terms of the GNU General Public License as published by the
|
|
10 Free Software Foundation; either version 2, or (at your option) any
|
|
11 later version.
|
|
12
|
|
13 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
16 for more details.
|
|
17
|
|
18 You should have received a copy of the GNU General Public License
|
|
19 along with XEmacs; see the file COPYING. If not, write to
|
|
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
21 Boston, MA 02111-1307, USA. */
|
|
22
|
|
23 /* Synched up with: FSF 20.3. Not in FSF. */
|
|
24
|
|
25 /* Rewritten by Ben Wing <ben@xemacs.org>. */
|
|
26
|
|
27 #include <config.h>
|
|
28 #include "lisp.h"
|
|
29
|
|
30 #include "buffer.h"
|
|
31 #include "chartab.h"
|
|
32 #include "elhash.h"
|
|
33 #include "device.h"
|
|
34 #include "faces.h"
|
771
|
35 #include "lstream.h"
|
428
|
36 #include "mule-ccl.h"
|
872
|
37 #include "objects.h"
|
428
|
38
|
|
39 /* The various pre-defined charsets. */
|
|
40
|
|
41 Lisp_Object Vcharset_ascii;
|
|
42 Lisp_Object Vcharset_control_1;
|
|
43 Lisp_Object Vcharset_latin_iso8859_1;
|
|
44 Lisp_Object Vcharset_latin_iso8859_2;
|
|
45 Lisp_Object Vcharset_latin_iso8859_3;
|
|
46 Lisp_Object Vcharset_latin_iso8859_4;
|
|
47 Lisp_Object Vcharset_thai_tis620;
|
|
48 Lisp_Object Vcharset_greek_iso8859_7;
|
|
49 Lisp_Object Vcharset_arabic_iso8859_6;
|
|
50 Lisp_Object Vcharset_hebrew_iso8859_8;
|
|
51 Lisp_Object Vcharset_katakana_jisx0201;
|
|
52 Lisp_Object Vcharset_latin_jisx0201;
|
|
53 Lisp_Object Vcharset_cyrillic_iso8859_5;
|
|
54 Lisp_Object Vcharset_latin_iso8859_9;
|
728
|
55 Lisp_Object Vcharset_latin_iso8859_15;
|
428
|
56 Lisp_Object Vcharset_japanese_jisx0208_1978;
|
|
57 Lisp_Object Vcharset_chinese_gb2312;
|
|
58 Lisp_Object Vcharset_japanese_jisx0208;
|
|
59 Lisp_Object Vcharset_korean_ksc5601;
|
|
60 Lisp_Object Vcharset_japanese_jisx0212;
|
|
61 Lisp_Object Vcharset_chinese_cns11643_1;
|
|
62 Lisp_Object Vcharset_chinese_cns11643_2;
|
|
63 Lisp_Object Vcharset_chinese_big5_1;
|
|
64 Lisp_Object Vcharset_chinese_big5_2;
|
|
65 Lisp_Object Vcharset_composite;
|
|
66
|
|
67 struct charset_lookup *chlook;
|
|
68
|
|
69 static const struct lrecord_description charset_lookup_description_1[] = {
|
771
|
70 { XD_LISP_OBJECT_ARRAY, offsetof (struct charset_lookup, charset_by_leading_byte), NUM_LEADING_BYTES+4*128*2 },
|
428
|
71 { XD_END }
|
|
72 };
|
|
73
|
|
74 static const struct struct_description charset_lookup_description = {
|
440
|
75 sizeof (struct charset_lookup),
|
428
|
76 charset_lookup_description_1
|
|
77 };
|
|
78
|
|
79 Lisp_Object Qcharsetp;
|
|
80
|
|
81 /* Qdoc_string, Qdimension, Qchars defined in general.c */
|
|
82 Lisp_Object Qregistry, Qfinal, Qgraphic;
|
|
83 Lisp_Object Qdirection;
|
|
84 Lisp_Object Qreverse_direction_charset;
|
|
85 Lisp_Object Qshort_name, Qlong_name;
|
|
86
|
771
|
87 Lisp_Object Qfrom_unicode, Qto_unicode;
|
|
88
|
|
89 Lisp_Object
|
428
|
90 Qlatin_iso8859_1,
|
|
91 Qlatin_iso8859_2,
|
|
92 Qlatin_iso8859_3,
|
|
93 Qlatin_iso8859_4,
|
|
94 Qthai_tis620,
|
|
95 Qgreek_iso8859_7,
|
|
96 Qarabic_iso8859_6,
|
|
97 Qhebrew_iso8859_8,
|
|
98 Qkatakana_jisx0201,
|
|
99 Qlatin_jisx0201,
|
|
100 Qcyrillic_iso8859_5,
|
|
101 Qlatin_iso8859_9,
|
728
|
102 Qlatin_iso8859_15,
|
428
|
103 Qjapanese_jisx0208_1978,
|
|
104 Qchinese_gb2312,
|
|
105 Qjapanese_jisx0208,
|
|
106 Qkorean_ksc5601,
|
|
107 Qjapanese_jisx0212,
|
|
108 Qchinese_cns11643_1,
|
|
109 Qchinese_cns11643_2,
|
|
110 Qchinese_big5_1,
|
|
111 Qchinese_big5_2,
|
|
112 Qcomposite;
|
|
113
|
|
114 Lisp_Object Ql2r, Qr2l;
|
|
115
|
|
116 Lisp_Object Vcharset_hash_table;
|
|
117
|
|
118
|
|
119 /************************************************************************/
|
|
120 /* charset object */
|
|
121 /************************************************************************/
|
|
122
|
|
123 static Lisp_Object
|
|
124 mark_charset (Lisp_Object obj)
|
|
125 {
|
440
|
126 Lisp_Charset *cs = XCHARSET (obj);
|
428
|
127
|
|
128 mark_object (cs->short_name);
|
|
129 mark_object (cs->long_name);
|
|
130 mark_object (cs->doc_string);
|
|
131 mark_object (cs->registry);
|
|
132 mark_object (cs->ccl_program);
|
|
133 return cs->name;
|
|
134 }
|
|
135
|
|
136 static void
|
|
137 print_charset (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
|
|
138 {
|
440
|
139 Lisp_Charset *cs = XCHARSET (obj);
|
428
|
140
|
|
141 if (print_readably)
|
563
|
142 printing_unreadable_object ("#<charset %s 0x%x>",
|
793
|
143 XSTRING_DATA (XSYMBOL (CHARSET_NAME (cs))->
|
563
|
144 name),
|
|
145 cs->header.uid);
|
428
|
146
|
771
|
147 write_fmt_string_lisp (printcharfun, "#<charset %s %S %S %S", 4,
|
|
148 CHARSET_NAME (cs), CHARSET_SHORT_NAME (cs),
|
|
149 CHARSET_LONG_NAME (cs), CHARSET_DOC_STRING (cs));
|
|
150 write_fmt_string (printcharfun, " %s %s cols=%d g%d final='%c' reg=",
|
|
151 CHARSET_TYPE (cs) == CHARSET_TYPE_94 ? "94" :
|
|
152 CHARSET_TYPE (cs) == CHARSET_TYPE_96 ? "96" :
|
|
153 CHARSET_TYPE (cs) == CHARSET_TYPE_94X94 ? "94x94" :
|
|
154 "96x96",
|
|
155 CHARSET_DIRECTION (cs) == CHARSET_LEFT_TO_RIGHT ? "l2r" :
|
|
156 "r2l",
|
|
157 CHARSET_COLUMNS (cs),
|
|
158 CHARSET_GRAPHIC (cs),
|
|
159 CHARSET_FINAL (cs));
|
428
|
160 print_internal (CHARSET_REGISTRY (cs), printcharfun, 0);
|
771
|
161 write_fmt_string (printcharfun, " 0x%x>", cs->header.uid);
|
|
162 }
|
|
163
|
|
164 static void
|
|
165 finalize_charset (void *header, int for_disksave)
|
|
166 {
|
|
167 /* See mule-charset.h, definition of Lisp_Charset. */
|
|
168 Lisp_Object charset = wrap_charset ((Lisp_Charset *) header);
|
|
169 if (for_disksave && XCHARSET_TO_UNICODE_TABLE (charset))
|
|
170 {
|
|
171 /* Control-1, ASCII, Composite don't have tables */
|
|
172 free_charset_unicode_tables (charset);
|
|
173 XCHARSET_TO_UNICODE_TABLE (charset) = 0;
|
|
174 XCHARSET_FROM_UNICODE_TABLE (charset) = 0;
|
|
175 }
|
428
|
176 }
|
|
177
|
|
178 static const struct lrecord_description charset_description[] = {
|
440
|
179 { XD_LISP_OBJECT, offsetof (Lisp_Charset, name) },
|
|
180 { XD_LISP_OBJECT, offsetof (Lisp_Charset, doc_string) },
|
|
181 { XD_LISP_OBJECT, offsetof (Lisp_Charset, registry) },
|
|
182 { XD_LISP_OBJECT, offsetof (Lisp_Charset, short_name) },
|
|
183 { XD_LISP_OBJECT, offsetof (Lisp_Charset, long_name) },
|
|
184 { XD_LISP_OBJECT, offsetof (Lisp_Charset, reverse_direction_charset) },
|
|
185 { XD_LISP_OBJECT, offsetof (Lisp_Charset, ccl_program) },
|
771
|
186 #if 0
|
|
187 /* #### XD_UNION not yet implemented! pdump version of XEmacs will
|
|
188 not work! */
|
|
189 { XD_UNION, offsetof (Lisp_Charset, to_unicode_table),
|
|
190 XD_INDIRECT (offsetof (Lisp_Charset, dimension), 0),
|
|
191 to_unicode_description },
|
|
192 { XD_UNION, offsetof (Lisp_Charset, from_unicode_table),
|
|
193 XD_INDIRECT (offsetof (Lisp_Charset, from_unicode_levels), 0),
|
|
194 from_unicode_description },
|
|
195 #endif
|
428
|
196 { XD_END }
|
|
197 };
|
|
198
|
934
|
199 #ifdef USE_KKCC
|
|
200 DEFINE_LRECORD_IMPLEMENTATION ("charset", charset,
|
|
201 1, /* dumpable flag */
|
|
202 mark_charset, print_charset, finalize_charset,
|
|
203 0, 0, charset_description, Lisp_Charset);
|
|
204 #else /* not USE_KKCC */
|
428
|
205 DEFINE_LRECORD_IMPLEMENTATION ("charset", charset,
|
771
|
206 mark_charset, print_charset, finalize_charset,
|
|
207 0, 0, charset_description, Lisp_Charset);
|
934
|
208 #endif /* not USE_KKCC */
|
428
|
209 /* Make a new charset. */
|
446
|
210 /* #### SJT Should generic properties be allowed? */
|
428
|
211 static Lisp_Object
|
771
|
212 make_charset (int id, Lisp_Object name, int rep_bytes,
|
|
213 int type, int columns, int graphic,
|
867
|
214 Ibyte final, int direction, Lisp_Object short_name,
|
428
|
215 Lisp_Object long_name, Lisp_Object doc,
|
771
|
216 Lisp_Object reg, int overwrite)
|
428
|
217 {
|
|
218 Lisp_Object obj;
|
771
|
219 Lisp_Charset *cs;
|
|
220
|
|
221 if (!overwrite)
|
|
222 {
|
|
223 cs = alloc_lcrecord_type (Lisp_Charset, &lrecord_charset);
|
|
224 zero_lcrecord (cs);
|
793
|
225 obj = wrap_charset (cs);
|
771
|
226
|
|
227 if (final)
|
|
228 {
|
|
229 /* some charsets do not have final characters. This includes
|
|
230 ASCII, Control-1, Composite, and the two faux private
|
|
231 charsets. */
|
|
232 assert (NILP (chlook->
|
|
233 charset_by_attributes[type][final][direction]));
|
|
234 chlook->charset_by_attributes[type][final][direction] = obj;
|
|
235 }
|
440
|
236
|
771
|
237 assert (NILP (chlook->charset_by_leading_byte[id - MIN_LEADING_BYTE]));
|
|
238 chlook->charset_by_leading_byte[id - MIN_LEADING_BYTE] = obj;
|
|
239 }
|
|
240 else
|
|
241 {
|
|
242 Lisp_Object ret;
|
|
243 /* Actually overwrite the properties of the existing charset.
|
|
244 We do this because until now charsets could never be "deleted",
|
|
245 so parts of the code don't bother to GC charsets. */
|
|
246 obj = chlook->charset_by_leading_byte[id - MIN_LEADING_BYTE];
|
|
247 cs = XCHARSET (obj);
|
|
248 assert (EQ (chlook->charset_by_attributes[type][final][direction],
|
|
249 obj));
|
|
250
|
|
251 ret = Fremhash (XCHARSET_NAME (obj), Vcharset_hash_table);
|
|
252 assert (!NILP (ret));
|
|
253 }
|
428
|
254
|
|
255 CHARSET_ID (cs) = id;
|
|
256 CHARSET_NAME (cs) = name;
|
|
257 CHARSET_SHORT_NAME (cs) = short_name;
|
|
258 CHARSET_LONG_NAME (cs) = long_name;
|
|
259 CHARSET_REP_BYTES (cs) = rep_bytes;
|
|
260 CHARSET_DIRECTION (cs) = direction;
|
|
261 CHARSET_TYPE (cs) = type;
|
|
262 CHARSET_COLUMNS (cs) = columns;
|
|
263 CHARSET_GRAPHIC (cs) = graphic;
|
|
264 CHARSET_FINAL (cs) = final;
|
|
265 CHARSET_DOC_STRING (cs) = doc;
|
|
266 CHARSET_REGISTRY (cs) = reg;
|
|
267 CHARSET_CCL_PROGRAM (cs) = Qnil;
|
|
268 CHARSET_REVERSE_DIRECTION_CHARSET (cs) = Qnil;
|
|
269
|
771
|
270 CHARSET_DIMENSION (cs) = (CHARSET_TYPE (cs) == CHARSET_TYPE_94 ||
|
|
271 CHARSET_TYPE (cs) == CHARSET_TYPE_96) ? 1 : 2;
|
|
272 CHARSET_CHARS (cs) = (CHARSET_TYPE (cs) == CHARSET_TYPE_94 ||
|
|
273 CHARSET_TYPE (cs) == CHARSET_TYPE_94X94) ? 94 : 96;
|
428
|
274
|
771
|
275 if (id == LEADING_BYTE_ASCII || id == LEADING_BYTE_CONTROL_1
|
|
276 #ifdef ENABLE_COMPOSITE_CHARS
|
|
277 || id == LEADING_BYTE_COMPOSITE
|
|
278 #endif
|
|
279 )
|
|
280 assert (!overwrite);
|
|
281 else
|
428
|
282 {
|
771
|
283 if (overwrite)
|
|
284 free_charset_unicode_tables (obj);
|
|
285 init_charset_unicode_tables (obj);
|
428
|
286 }
|
|
287
|
|
288 /* Some charsets are "faux" and don't have names or really exist at
|
|
289 all except in the leading-byte table. */
|
|
290 if (!NILP (name))
|
771
|
291 {
|
|
292 assert (NILP (Fgethash (name, Vcharset_hash_table, Qnil)));
|
|
293 Fputhash (name, obj, Vcharset_hash_table);
|
|
294 }
|
|
295
|
|
296 recalculate_unicode_precedence ();
|
428
|
297 return obj;
|
|
298 }
|
|
299
|
|
300 static int
|
|
301 get_unallocated_leading_byte (int dimension)
|
|
302 {
|
|
303 int lb;
|
|
304
|
|
305 if (dimension == 1)
|
|
306 {
|
771
|
307 if (chlook->next_allocated_1_byte_leading_byte >
|
|
308 MAX_LEADING_BYTE_PRIVATE_1)
|
428
|
309 lb = 0;
|
|
310 else
|
442
|
311 lb = chlook->next_allocated_1_byte_leading_byte++;
|
428
|
312 }
|
|
313 else
|
|
314 {
|
771
|
315 if (chlook->next_allocated_2_byte_leading_byte >
|
|
316 MAX_LEADING_BYTE_PRIVATE_2)
|
428
|
317 lb = 0;
|
|
318 else
|
442
|
319 lb = chlook->next_allocated_2_byte_leading_byte++;
|
428
|
320 }
|
|
321
|
|
322 if (!lb)
|
563
|
323 invalid_operation
|
771
|
324 ("No more character sets free for this dimension", make_int (dimension));
|
428
|
325
|
|
326 return lb;
|
|
327 }
|
|
328
|
|
329
|
|
330 /************************************************************************/
|
|
331 /* Basic charset Lisp functions */
|
|
332 /************************************************************************/
|
|
333
|
788
|
334 void
|
|
335 get_charset_limits (Lisp_Object charset, int *low, int *high)
|
|
336 {
|
|
337 Lisp_Charset *cs = XCHARSET (charset);
|
|
338
|
|
339 if (EQ (charset, Vcharset_ascii)) *low = 0, *high = 127;
|
|
340 else if (EQ (charset, Vcharset_control_1)) *low = 0, *high = 31;
|
|
341 else if (CHARSET_CHARS (cs) == 94) *low = 33, *high = 126;
|
|
342 else /* CHARSET_CHARS (cs) == 96) */ *low = 32, *high = 127;
|
|
343 }
|
|
344
|
428
|
345 DEFUN ("charsetp", Fcharsetp, 1, 1, 0, /*
|
|
346 Return non-nil if OBJECT is a charset.
|
|
347 */
|
|
348 (object))
|
|
349 {
|
|
350 return CHARSETP (object) ? Qt : Qnil;
|
|
351 }
|
|
352
|
|
353 DEFUN ("find-charset", Ffind_charset, 1, 1, 0, /*
|
|
354 Retrieve the charset of the given name.
|
|
355 If CHARSET-OR-NAME is a charset object, it is simply returned.
|
|
356 Otherwise, CHARSET-OR-NAME should be a symbol. If there is no such charset,
|
|
357 nil is returned. Otherwise the associated charset object is returned.
|
|
358 */
|
|
359 (charset_or_name))
|
|
360 {
|
|
361 if (CHARSETP (charset_or_name))
|
|
362 return charset_or_name;
|
|
363
|
|
364 CHECK_SYMBOL (charset_or_name);
|
|
365 return Fgethash (charset_or_name, Vcharset_hash_table, Qnil);
|
|
366 }
|
|
367
|
|
368 DEFUN ("get-charset", Fget_charset, 1, 1, 0, /*
|
|
369 Retrieve the charset of the given name.
|
|
370 Same as `find-charset' except an error is signalled if there is no such
|
|
371 charset instead of returning nil.
|
|
372 */
|
|
373 (name))
|
|
374 {
|
|
375 Lisp_Object charset = Ffind_charset (name);
|
|
376
|
|
377 if (NILP (charset))
|
563
|
378 invalid_argument ("No such charset", name);
|
428
|
379 return charset;
|
|
380 }
|
|
381
|
|
382 /* We store the charsets in hash tables with the names as the key and the
|
|
383 actual charset object as the value. Occasionally we need to use them
|
|
384 in a list format. These routines provide us with that. */
|
|
385 struct charset_list_closure
|
|
386 {
|
|
387 Lisp_Object *charset_list;
|
|
388 };
|
|
389
|
|
390 static int
|
|
391 add_charset_to_list_mapper (Lisp_Object key, Lisp_Object value,
|
|
392 void *charset_list_closure)
|
|
393 {
|
|
394 /* This function can GC */
|
|
395 struct charset_list_closure *chcl =
|
|
396 (struct charset_list_closure*) charset_list_closure;
|
|
397 Lisp_Object *charset_list = chcl->charset_list;
|
|
398
|
|
399 *charset_list = Fcons (XCHARSET_NAME (value), *charset_list);
|
|
400 return 0;
|
|
401 }
|
|
402
|
|
403 DEFUN ("charset-list", Fcharset_list, 0, 0, 0, /*
|
|
404 Return a list of the names of all defined charsets.
|
|
405 */
|
|
406 ())
|
|
407 {
|
|
408 Lisp_Object charset_list = Qnil;
|
|
409 struct gcpro gcpro1;
|
|
410 struct charset_list_closure charset_list_closure;
|
|
411
|
|
412 GCPRO1 (charset_list);
|
|
413 charset_list_closure.charset_list = &charset_list;
|
|
414 elisp_maphash (add_charset_to_list_mapper, Vcharset_hash_table,
|
|
415 &charset_list_closure);
|
|
416 UNGCPRO;
|
|
417
|
|
418 return charset_list;
|
|
419 }
|
|
420
|
|
421 DEFUN ("charset-name", Fcharset_name, 1, 1, 0, /*
|
444
|
422 Return the name of charset CHARSET.
|
428
|
423 */
|
|
424 (charset))
|
|
425 {
|
|
426 return XCHARSET_NAME (Fget_charset (charset));
|
|
427 }
|
|
428
|
446
|
429 /* #### SJT Should generic properties be allowed? */
|
428
|
430 DEFUN ("make-charset", Fmake_charset, 3, 3, 0, /*
|
|
431 Define a new character set.
|
|
432 This function is for use with Mule support.
|
|
433 NAME is a symbol, the name by which the character set is normally referred.
|
|
434 DOC-STRING is a string describing the character set.
|
|
435 PROPS is a property list, describing the specific nature of the
|
|
436 character set. Recognized properties are:
|
|
437
|
|
438 'short-name Short version of the charset name (ex: Latin-1)
|
|
439 'long-name Long version of the charset name (ex: ISO8859-1 (Latin-1))
|
|
440 'registry A regular expression matching the font registry field for
|
|
441 this character set.
|
|
442 'dimension Number of octets used to index a character in this charset.
|
|
443 Either 1 or 2. Defaults to 1.
|
|
444 'columns Number of columns used to display a character in this charset.
|
|
445 Only used in TTY mode. (Under X, the actual width of a
|
|
446 character can be derived from the font used to display the
|
|
447 characters.) If unspecified, defaults to the dimension
|
|
448 (this is almost always the correct value).
|
|
449 'chars Number of characters in each dimension (94 or 96).
|
|
450 Defaults to 94. Note that if the dimension is 2, the
|
|
451 character set thus described is 94x94 or 96x96.
|
|
452 'final Final byte of ISO 2022 escape sequence. Must be
|
|
453 supplied. Each combination of (DIMENSION, CHARS) defines a
|
|
454 separate namespace for final bytes. Note that ISO
|
|
455 2022 restricts the final byte to the range
|
|
456 0x30 - 0x7E if dimension == 1, and 0x30 - 0x5F if
|
|
457 dimension == 2. Note also that final bytes in the range
|
|
458 0x30 - 0x3F are reserved for user-defined (not official)
|
|
459 character sets.
|
|
460 'graphic 0 (use left half of font on output) or 1 (use right half
|
|
461 of font on output). Defaults to 0. For example, for
|
|
462 a font whose registry is ISO8859-1, the left half
|
|
463 (octets 0x20 - 0x7F) is the `ascii' character set, while
|
|
464 the right half (octets 0xA0 - 0xFF) is the `latin-1'
|
|
465 character set. With 'graphic set to 0, the octets
|
|
466 will have their high bit cleared; with it set to 1,
|
|
467 the octets will have their high bit set.
|
|
468 'direction 'l2r (left-to-right) or 'r2l (right-to-left).
|
|
469 Defaults to 'l2r.
|
|
470 'ccl-program A compiled CCL program used to convert a character in
|
|
471 this charset into an index into the font. This is in
|
|
472 addition to the 'graphic property. The CCL program
|
|
473 is passed the octets of the character, with the high
|
|
474 bit cleared and set depending upon whether the value
|
|
475 of the 'graphic property is 0 or 1.
|
|
476 */
|
|
477 (name, doc_string, props))
|
|
478 {
|
771
|
479 int id, dimension = 1, chars = 94, graphic = 0, columns = -1;
|
867
|
480 Ibyte final = 0;
|
428
|
481 int direction = CHARSET_LEFT_TO_RIGHT;
|
|
482 int type;
|
|
483 Lisp_Object registry = Qnil;
|
771
|
484 Lisp_Object charset = Qnil;
|
428
|
485 Lisp_Object ccl_program = Qnil;
|
|
486 Lisp_Object short_name = Qnil, long_name = Qnil;
|
771
|
487 Lisp_Object existing_charset;
|
|
488 int temporary = UNBOUNDP (name);
|
428
|
489
|
771
|
490 /* NOTE: name == Qunbound is a directive from the iso2022 code to
|
|
491 create a temporary charset for an unknown final. We allow the final
|
|
492 to be overwritten with a real charset later on. */
|
|
493
|
428
|
494 if (!NILP (doc_string))
|
|
495 CHECK_STRING (doc_string);
|
771
|
496 if (!UNBOUNDP (name))
|
|
497 {
|
|
498 CHECK_SYMBOL (name);
|
428
|
499
|
771
|
500 charset = Ffind_charset (name);
|
|
501 if (!NILP (charset))
|
|
502 invalid_operation ("Cannot redefine existing charset", name);
|
|
503 }
|
428
|
504
|
442
|
505 {
|
|
506 EXTERNAL_PROPERTY_LIST_LOOP_3 (keyword, value, props)
|
|
507 {
|
|
508 if (EQ (keyword, Qshort_name))
|
|
509 {
|
|
510 CHECK_STRING (value);
|
|
511 short_name = value;
|
|
512 }
|
428
|
513
|
519
|
514 else if (EQ (keyword, Qlong_name))
|
442
|
515 {
|
|
516 CHECK_STRING (value);
|
|
517 long_name = value;
|
|
518 }
|
428
|
519
|
442
|
520 else if (EQ (keyword, Qdimension))
|
|
521 {
|
|
522 CHECK_INT (value);
|
|
523 dimension = XINT (value);
|
|
524 if (dimension < 1 || dimension > 2)
|
563
|
525 invalid_constant ("Invalid value for 'dimension", value);
|
442
|
526 }
|
428
|
527
|
442
|
528 else if (EQ (keyword, Qchars))
|
|
529 {
|
|
530 CHECK_INT (value);
|
|
531 chars = XINT (value);
|
|
532 if (chars != 94 && chars != 96)
|
563
|
533 invalid_constant ("Invalid value for 'chars", value);
|
442
|
534 }
|
428
|
535
|
442
|
536 else if (EQ (keyword, Qcolumns))
|
|
537 {
|
|
538 CHECK_INT (value);
|
|
539 columns = XINT (value);
|
|
540 if (columns != 1 && columns != 2)
|
563
|
541 invalid_constant ("Invalid value for 'columns", value);
|
442
|
542 }
|
428
|
543
|
442
|
544 else if (EQ (keyword, Qgraphic))
|
|
545 {
|
|
546 CHECK_INT (value);
|
|
547 graphic = XINT (value);
|
|
548 if (graphic < 0 || graphic > 1)
|
563
|
549 invalid_constant ("Invalid value for 'graphic", value);
|
442
|
550 }
|
428
|
551
|
442
|
552 else if (EQ (keyword, Qregistry))
|
|
553 {
|
|
554 CHECK_STRING (value);
|
|
555 registry = value;
|
|
556 }
|
428
|
557
|
442
|
558 else if (EQ (keyword, Qdirection))
|
|
559 {
|
|
560 if (EQ (value, Ql2r))
|
|
561 direction = CHARSET_LEFT_TO_RIGHT;
|
|
562 else if (EQ (value, Qr2l))
|
|
563 direction = CHARSET_RIGHT_TO_LEFT;
|
|
564 else
|
563
|
565 invalid_constant ("Invalid value for 'direction", value);
|
442
|
566 }
|
428
|
567
|
442
|
568 else if (EQ (keyword, Qfinal))
|
|
569 {
|
|
570 CHECK_CHAR_COERCE_INT (value);
|
|
571 final = XCHAR (value);
|
|
572 if (final < '0' || final > '~')
|
563
|
573 invalid_constant ("Invalid value for 'final", value);
|
442
|
574 }
|
428
|
575
|
442
|
576 else if (EQ (keyword, Qccl_program))
|
|
577 {
|
444
|
578 struct ccl_program test_ccl;
|
|
579
|
|
580 if (setup_ccl_program (&test_ccl, value) < 0)
|
563
|
581 invalid_argument ("Invalid value for 'ccl-program", value);
|
442
|
582 ccl_program = value;
|
|
583 }
|
|
584 else
|
563
|
585 invalid_constant ("Unrecognized property", keyword);
|
442
|
586 }
|
|
587 }
|
428
|
588
|
|
589 if (!final)
|
563
|
590 invalid_argument ("'final must be specified", Qunbound);
|
428
|
591 if (dimension == 2 && final > 0x5F)
|
563
|
592 invalid_constant
|
428
|
593 ("Final must be in the range 0x30 - 0x5F for dimension == 2",
|
|
594 make_char (final));
|
|
595
|
|
596 if (dimension == 1)
|
|
597 type = (chars == 94) ? CHARSET_TYPE_94 : CHARSET_TYPE_96;
|
|
598 else
|
|
599 type = (chars == 94) ? CHARSET_TYPE_94X94 : CHARSET_TYPE_96X96;
|
|
600
|
826
|
601 existing_charset = charset_by_attributes (type, final, direction);
|
771
|
602
|
|
603 if (!NILP (existing_charset) && !XCHARSET (existing_charset)->temporary)
|
578
|
604 invalid_argument
|
793
|
605 ("Character set already defined for this DIMENSION/CHARS/FINAL/DIRECTION combo",
|
771
|
606 existing_charset);
|
|
607
|
|
608 if (!NILP (existing_charset))
|
|
609 /* Reuse same leading byte */
|
|
610 id = XCHARSET_ID (existing_charset);
|
|
611 else
|
|
612 id = get_unallocated_leading_byte (dimension);
|
428
|
613
|
771
|
614 if (temporary)
|
|
615 {
|
867
|
616 Ibyte tempname[80];
|
428
|
617
|
771
|
618 qxesprintf (tempname, "___temporary___%d__", id);
|
|
619 name = intern_int (tempname);
|
|
620 }
|
428
|
621 if (NILP (doc_string))
|
|
622 doc_string = build_string ("");
|
|
623 if (NILP (registry))
|
|
624 registry = build_string ("");
|
|
625 if (NILP (short_name))
|
793
|
626 short_name = XSYMBOL (name)->name;
|
428
|
627 if (NILP (long_name))
|
|
628 long_name = doc_string;
|
|
629 if (columns == -1)
|
|
630 columns = dimension;
|
771
|
631
|
428
|
632 charset = make_charset (id, name, dimension + 2, type, columns, graphic,
|
771
|
633 final, direction, short_name, long_name,
|
|
634 doc_string, registry, !NILP (existing_charset));
|
|
635
|
|
636 XCHARSET (charset)->temporary = temporary;
|
428
|
637 if (!NILP (ccl_program))
|
|
638 XCHARSET_CCL_PROGRAM (charset) = ccl_program;
|
771
|
639
|
793
|
640 {
|
|
641 Lisp_Object revdircs =
|
826
|
642 charset_by_attributes (type, final,
|
793
|
643 direction == CHARSET_LEFT_TO_RIGHT ?
|
|
644 CHARSET_RIGHT_TO_LEFT : CHARSET_LEFT_TO_RIGHT);
|
|
645 if (!NILP (revdircs))
|
|
646 {
|
|
647 XCHARSET_REVERSE_DIRECTION_CHARSET (revdircs) = charset;
|
|
648 XCHARSET_REVERSE_DIRECTION_CHARSET (charset) = revdircs;
|
|
649 }
|
|
650 }
|
|
651
|
428
|
652 return charset;
|
|
653 }
|
|
654
|
|
655 DEFUN ("make-reverse-direction-charset", Fmake_reverse_direction_charset,
|
|
656 2, 2, 0, /*
|
|
657 Make a charset equivalent to CHARSET but which goes in the opposite direction.
|
|
658 NEW-NAME is the name of the new charset. Return the new charset.
|
|
659 */
|
|
660 (charset, new_name))
|
|
661 {
|
|
662 Lisp_Object new_charset = Qnil;
|
771
|
663 int id, dimension, columns, graphic;
|
867
|
664 Ibyte final;
|
428
|
665 int direction, type;
|
|
666 Lisp_Object registry, doc_string, short_name, long_name;
|
440
|
667 Lisp_Charset *cs;
|
428
|
668
|
|
669 charset = Fget_charset (charset);
|
|
670 if (!NILP (XCHARSET_REVERSE_DIRECTION_CHARSET (charset)))
|
563
|
671 invalid_operation ("Charset already has reverse-direction charset",
|
793
|
672 charset);
|
428
|
673
|
|
674 CHECK_SYMBOL (new_name);
|
|
675 if (!NILP (Ffind_charset (new_name)))
|
563
|
676 invalid_operation ("Cannot redefine existing charset", new_name);
|
428
|
677
|
|
678 cs = XCHARSET (charset);
|
|
679
|
|
680 type = CHARSET_TYPE (cs);
|
|
681 columns = CHARSET_COLUMNS (cs);
|
|
682 dimension = CHARSET_DIMENSION (cs);
|
|
683 id = get_unallocated_leading_byte (dimension);
|
|
684
|
|
685 graphic = CHARSET_GRAPHIC (cs);
|
|
686 final = CHARSET_FINAL (cs);
|
|
687 direction = CHARSET_RIGHT_TO_LEFT;
|
|
688 if (CHARSET_DIRECTION (cs) == CHARSET_RIGHT_TO_LEFT)
|
|
689 direction = CHARSET_LEFT_TO_RIGHT;
|
|
690 doc_string = CHARSET_DOC_STRING (cs);
|
|
691 short_name = CHARSET_SHORT_NAME (cs);
|
|
692 long_name = CHARSET_LONG_NAME (cs);
|
|
693 registry = CHARSET_REGISTRY (cs);
|
|
694
|
|
695 new_charset = make_charset (id, new_name, dimension + 2, type, columns,
|
|
696 graphic, final, direction, short_name, long_name,
|
771
|
697 doc_string, registry, 0);
|
428
|
698
|
|
699 CHARSET_REVERSE_DIRECTION_CHARSET (cs) = new_charset;
|
|
700 XCHARSET_REVERSE_DIRECTION_CHARSET (new_charset) = charset;
|
|
701
|
|
702 return new_charset;
|
|
703 }
|
|
704
|
|
705 DEFUN ("charset-reverse-direction-charset", Fcharset_reverse_direction_charset,
|
|
706 1, 1, 0, /*
|
|
707 Return the reverse-direction charset parallel to CHARSET, if any.
|
|
708 This is the charset with the same properties (in particular, the same
|
|
709 dimension, number of characters per dimension, and final byte) as
|
|
710 CHARSET but whose characters are displayed in the opposite direction.
|
|
711 */
|
|
712 (charset))
|
|
713 {
|
|
714 charset = Fget_charset (charset);
|
|
715 return XCHARSET_REVERSE_DIRECTION_CHARSET (charset);
|
|
716 }
|
|
717
|
|
718 DEFUN ("charset-from-attributes", Fcharset_from_attributes, 3, 4, 0, /*
|
|
719 Return a charset with the given DIMENSION, CHARS, FINAL, and DIRECTION.
|
|
720 If DIRECTION is omitted, both directions will be checked (left-to-right
|
|
721 will be returned if character sets exist for both directions).
|
|
722 */
|
|
723 (dimension, chars, final, direction))
|
|
724 {
|
|
725 int dm, ch, fi, di = -1;
|
|
726 int type;
|
|
727 Lisp_Object obj = Qnil;
|
|
728
|
|
729 CHECK_INT (dimension);
|
|
730 dm = XINT (dimension);
|
|
731 if (dm < 1 || dm > 2)
|
563
|
732 invalid_constant ("Invalid value for DIMENSION", dimension);
|
428
|
733
|
|
734 CHECK_INT (chars);
|
|
735 ch = XINT (chars);
|
|
736 if (ch != 94 && ch != 96)
|
563
|
737 invalid_constant ("Invalid value for CHARS", chars);
|
428
|
738
|
|
739 CHECK_CHAR_COERCE_INT (final);
|
|
740 fi = XCHAR (final);
|
|
741 if (fi < '0' || fi > '~')
|
563
|
742 invalid_constant ("Invalid value for FINAL", final);
|
428
|
743
|
|
744 if (EQ (direction, Ql2r))
|
|
745 di = CHARSET_LEFT_TO_RIGHT;
|
|
746 else if (EQ (direction, Qr2l))
|
|
747 di = CHARSET_RIGHT_TO_LEFT;
|
|
748 else if (!NILP (direction))
|
563
|
749 invalid_constant ("Invalid value for DIRECTION", direction);
|
428
|
750
|
|
751 if (dm == 2 && fi > 0x5F)
|
563
|
752 invalid_constant
|
428
|
753 ("Final must be in the range 0x30 - 0x5F for dimension == 2", final);
|
|
754
|
|
755 if (dm == 1)
|
|
756 type = (ch == 94) ? CHARSET_TYPE_94 : CHARSET_TYPE_96;
|
|
757 else
|
|
758 type = (ch == 94) ? CHARSET_TYPE_94X94 : CHARSET_TYPE_96X96;
|
|
759
|
|
760 if (di == -1)
|
|
761 {
|
826
|
762 obj = charset_by_attributes (type, fi, CHARSET_LEFT_TO_RIGHT);
|
428
|
763 if (NILP (obj))
|
826
|
764 obj = charset_by_attributes (type, fi, CHARSET_RIGHT_TO_LEFT);
|
428
|
765 }
|
|
766 else
|
826
|
767 obj = charset_by_attributes (type, fi, di);
|
428
|
768
|
|
769 if (CHARSETP (obj))
|
|
770 return XCHARSET_NAME (obj);
|
|
771 return obj;
|
|
772 }
|
|
773
|
|
774 DEFUN ("charset-short-name", Fcharset_short_name, 1, 1, 0, /*
|
|
775 Return short name of CHARSET.
|
|
776 */
|
|
777 (charset))
|
|
778 {
|
|
779 return XCHARSET_SHORT_NAME (Fget_charset (charset));
|
|
780 }
|
|
781
|
|
782 DEFUN ("charset-long-name", Fcharset_long_name, 1, 1, 0, /*
|
|
783 Return long name of CHARSET.
|
|
784 */
|
|
785 (charset))
|
|
786 {
|
|
787 return XCHARSET_LONG_NAME (Fget_charset (charset));
|
|
788 }
|
|
789
|
|
790 DEFUN ("charset-description", Fcharset_description, 1, 1, 0, /*
|
|
791 Return description of CHARSET.
|
|
792 */
|
|
793 (charset))
|
|
794 {
|
|
795 return XCHARSET_DOC_STRING (Fget_charset (charset));
|
|
796 }
|
|
797
|
|
798 DEFUN ("charset-dimension", Fcharset_dimension, 1, 1, 0, /*
|
|
799 Return dimension of CHARSET.
|
|
800 */
|
|
801 (charset))
|
|
802 {
|
|
803 return make_int (XCHARSET_DIMENSION (Fget_charset (charset)));
|
|
804 }
|
|
805
|
|
806 DEFUN ("charset-property", Fcharset_property, 2, 2, 0, /*
|
446
|
807 Return property PROP of CHARSET, a charset object or symbol naming a charset.
|
428
|
808 Recognized properties are those listed in `make-charset', as well as
|
|
809 'name and 'doc-string.
|
|
810 */
|
|
811 (charset, prop))
|
|
812 {
|
440
|
813 Lisp_Charset *cs;
|
428
|
814
|
|
815 charset = Fget_charset (charset);
|
|
816 cs = XCHARSET (charset);
|
|
817
|
|
818 CHECK_SYMBOL (prop);
|
|
819 if (EQ (prop, Qname)) return CHARSET_NAME (cs);
|
|
820 if (EQ (prop, Qshort_name)) return CHARSET_SHORT_NAME (cs);
|
|
821 if (EQ (prop, Qlong_name)) return CHARSET_LONG_NAME (cs);
|
|
822 if (EQ (prop, Qdoc_string)) return CHARSET_DOC_STRING (cs);
|
|
823 if (EQ (prop, Qdimension)) return make_int (CHARSET_DIMENSION (cs));
|
|
824 if (EQ (prop, Qcolumns)) return make_int (CHARSET_COLUMNS (cs));
|
|
825 if (EQ (prop, Qgraphic)) return make_int (CHARSET_GRAPHIC (cs));
|
|
826 if (EQ (prop, Qfinal)) return make_char (CHARSET_FINAL (cs));
|
|
827 if (EQ (prop, Qchars)) return make_int (CHARSET_CHARS (cs));
|
|
828 if (EQ (prop, Qregistry)) return CHARSET_REGISTRY (cs);
|
|
829 if (EQ (prop, Qccl_program)) return CHARSET_CCL_PROGRAM (cs);
|
|
830 if (EQ (prop, Qdirection))
|
|
831 return CHARSET_DIRECTION (cs) == CHARSET_LEFT_TO_RIGHT ? Ql2r : Qr2l;
|
|
832 if (EQ (prop, Qreverse_direction_charset))
|
|
833 {
|
|
834 Lisp_Object obj = CHARSET_REVERSE_DIRECTION_CHARSET (cs);
|
446
|
835 /* #### Is this translation OK? If so, error checking sufficient? */
|
|
836 return CHARSETP (obj) ? XCHARSET_NAME (obj) : obj;
|
428
|
837 }
|
563
|
838 invalid_constant ("Unrecognized charset property name", prop);
|
801
|
839 RETURN_NOT_REACHED (Qnil)
|
428
|
840 }
|
|
841
|
|
842 DEFUN ("charset-id", Fcharset_id, 1, 1, 0, /*
|
|
843 Return charset identification number of CHARSET.
|
|
844 */
|
|
845 (charset))
|
|
846 {
|
793
|
847 return make_int (XCHARSET_LEADING_BYTE (Fget_charset (charset)));
|
428
|
848 }
|
|
849
|
|
850 /* #### We need to figure out which properties we really want to
|
|
851 allow to be set. */
|
|
852
|
|
853 DEFUN ("set-charset-ccl-program", Fset_charset_ccl_program, 2, 2, 0, /*
|
|
854 Set the 'ccl-program property of CHARSET to CCL-PROGRAM.
|
|
855 */
|
|
856 (charset, ccl_program))
|
|
857 {
|
444
|
858 struct ccl_program test_ccl;
|
|
859
|
428
|
860 charset = Fget_charset (charset);
|
444
|
861 if (setup_ccl_program (&test_ccl, ccl_program) < 0)
|
563
|
862 invalid_argument ("Invalid ccl-program", ccl_program);
|
428
|
863 XCHARSET_CCL_PROGRAM (charset) = ccl_program;
|
510
|
864 face_property_was_changed (Vdefault_face, Qfont, Qglobal);
|
428
|
865 return Qnil;
|
|
866 }
|
|
867
|
|
868 /* Japanese folks may want to (set-charset-registry 'ascii "jisx0201") */
|
|
869 DEFUN ("set-charset-registry", Fset_charset_registry, 2, 2, 0, /*
|
|
870 Set the 'registry property of CHARSET to REGISTRY.
|
|
871 */
|
|
872 (charset, registry))
|
|
873 {
|
|
874 charset = Fget_charset (charset);
|
|
875 CHECK_STRING (registry);
|
|
876 XCHARSET_REGISTRY (charset) = registry;
|
|
877 invalidate_charset_font_caches (charset);
|
|
878 face_property_was_changed (Vdefault_face, Qfont, Qglobal);
|
|
879 return Qnil;
|
|
880 }
|
|
881
|
|
882
|
|
883 /************************************************************************/
|
771
|
884 /* memory usage */
|
428
|
885 /************************************************************************/
|
|
886
|
771
|
887 #ifdef MEMORY_USAGE_STATS
|
428
|
888
|
771
|
889 struct charset_stats
|
|
890 {
|
|
891 int from_unicode;
|
|
892 int to_unicode;
|
|
893 int other;
|
|
894 };
|
428
|
895
|
771
|
896 static void
|
|
897 compute_charset_usage (Lisp_Object charset, struct charset_stats *stats,
|
|
898 struct overhead_stats *ovstats)
|
428
|
899 {
|
771
|
900 struct Lisp_Charset *c = XCHARSET (charset);
|
|
901 xzero (*stats);
|
|
902 stats->other += malloced_storage_size (c, sizeof (*c), ovstats);
|
|
903 stats->from_unicode += compute_from_unicode_table_size (charset, ovstats);
|
|
904 stats->to_unicode += compute_to_unicode_table_size (charset, ovstats);
|
438
|
905 }
|
|
906
|
771
|
907 DEFUN ("charset-memory-usage", Fcharset_memory_usage, 1, 1, 0, /*
|
|
908 Return stats about the memory usage of charset CHARSET.
|
|
909 The values returned are in the form of an alist of usage types and
|
|
910 byte counts. The byte counts attempt to encompass all the memory used
|
|
911 by the charset (separate from the memory logically associated with a
|
|
912 charset or frame), including internal structures and any malloc()
|
|
913 overhead associated with them. In practice, the byte counts are
|
|
914 underestimated for various reasons, e.g. because certain memory usage
|
|
915 is very hard to determine \(e.g. the amount of memory used inside the
|
|
916 Xt library or inside the X server).
|
428
|
917
|
771
|
918 Multiple slices of the total memory usage may be returned, separated
|
|
919 by a nil. Each slice represents a particular view of the memory, a
|
|
920 particular way of partitioning it into groups. Within a slice, there
|
|
921 is no overlap between the groups of memory, and each slice collectively
|
|
922 represents all the memory concerned.
|
|
923 */
|
|
924 (charset))
|
|
925 {
|
|
926 struct charset_stats stats;
|
|
927 struct overhead_stats ovstats;
|
|
928 Lisp_Object val = Qnil;
|
428
|
929
|
771
|
930 charset = Fget_charset (charset);
|
|
931 xzero (ovstats);
|
|
932 compute_charset_usage (charset, &stats, &ovstats);
|
428
|
933
|
771
|
934 val = acons (Qfrom_unicode, make_int (stats.from_unicode), val);
|
|
935 val = acons (Qto_unicode, make_int (stats.to_unicode), val);
|
|
936 val = Fcons (Qnil, val);
|
|
937 val = acons (Qactually_requested, make_int (ovstats.was_requested), val);
|
|
938 val = acons (Qmalloc_overhead, make_int (ovstats.malloc_overhead), val);
|
|
939 val = acons (Qgap_overhead, make_int (ovstats.gap_overhead), val);
|
|
940 val = acons (Qdynarr_overhead, make_int (ovstats.dynarr_overhead), val);
|
|
941
|
|
942 return Fnreverse (val);
|
428
|
943 }
|
|
944
|
771
|
945 #endif /* MEMORY_USAGE_STATS */
|
428
|
946
|
|
947
|
|
948 /************************************************************************/
|
|
949 /* initialization */
|
|
950 /************************************************************************/
|
|
951
|
|
952 void
|
|
953 syms_of_mule_charset (void)
|
|
954 {
|
442
|
955 INIT_LRECORD_IMPLEMENTATION (charset);
|
|
956
|
428
|
957 DEFSUBR (Fcharsetp);
|
|
958 DEFSUBR (Ffind_charset);
|
|
959 DEFSUBR (Fget_charset);
|
|
960 DEFSUBR (Fcharset_list);
|
|
961 DEFSUBR (Fcharset_name);
|
|
962 DEFSUBR (Fmake_charset);
|
|
963 DEFSUBR (Fmake_reverse_direction_charset);
|
793
|
964 DEFSUBR (Fcharset_reverse_direction_charset);
|
428
|
965 DEFSUBR (Fcharset_from_attributes);
|
|
966 DEFSUBR (Fcharset_short_name);
|
|
967 DEFSUBR (Fcharset_long_name);
|
|
968 DEFSUBR (Fcharset_description);
|
|
969 DEFSUBR (Fcharset_dimension);
|
|
970 DEFSUBR (Fcharset_property);
|
|
971 DEFSUBR (Fcharset_id);
|
|
972 DEFSUBR (Fset_charset_ccl_program);
|
|
973 DEFSUBR (Fset_charset_registry);
|
|
974
|
771
|
975 #ifdef MEMORY_USAGE_STATS
|
|
976 DEFSUBR (Fcharset_memory_usage);
|
428
|
977 #endif
|
|
978
|
563
|
979 DEFSYMBOL (Qcharsetp);
|
|
980 DEFSYMBOL (Qregistry);
|
|
981 DEFSYMBOL (Qfinal);
|
|
982 DEFSYMBOL (Qgraphic);
|
|
983 DEFSYMBOL (Qdirection);
|
|
984 DEFSYMBOL (Qreverse_direction_charset);
|
|
985 DEFSYMBOL (Qshort_name);
|
|
986 DEFSYMBOL (Qlong_name);
|
428
|
987
|
771
|
988 DEFSYMBOL (Qfrom_unicode);
|
|
989 DEFSYMBOL (Qto_unicode);
|
|
990
|
563
|
991 DEFSYMBOL (Ql2r);
|
|
992 DEFSYMBOL (Qr2l);
|
428
|
993
|
|
994 /* Charsets, compatible with FSF 20.3
|
|
995 Naming convention is Script-Charset[-Edition] */
|
563
|
996 DEFSYMBOL (Qlatin_iso8859_1);
|
|
997 DEFSYMBOL (Qlatin_iso8859_2);
|
|
998 DEFSYMBOL (Qlatin_iso8859_3);
|
|
999 DEFSYMBOL (Qlatin_iso8859_4);
|
|
1000 DEFSYMBOL (Qthai_tis620);
|
|
1001 DEFSYMBOL (Qgreek_iso8859_7);
|
|
1002 DEFSYMBOL (Qarabic_iso8859_6);
|
|
1003 DEFSYMBOL (Qhebrew_iso8859_8);
|
|
1004 DEFSYMBOL (Qkatakana_jisx0201);
|
|
1005 DEFSYMBOL (Qlatin_jisx0201);
|
|
1006 DEFSYMBOL (Qcyrillic_iso8859_5);
|
|
1007 DEFSYMBOL (Qlatin_iso8859_9);
|
728
|
1008 DEFSYMBOL (Qlatin_iso8859_15);
|
563
|
1009 DEFSYMBOL (Qjapanese_jisx0208_1978);
|
|
1010 DEFSYMBOL (Qchinese_gb2312);
|
|
1011 DEFSYMBOL (Qjapanese_jisx0208);
|
|
1012 DEFSYMBOL (Qkorean_ksc5601);
|
|
1013 DEFSYMBOL (Qjapanese_jisx0212);
|
|
1014 DEFSYMBOL (Qchinese_cns11643_1);
|
|
1015 DEFSYMBOL (Qchinese_cns11643_2);
|
|
1016 DEFSYMBOL (Qchinese_big5_1);
|
|
1017 DEFSYMBOL (Qchinese_big5_2);
|
428
|
1018
|
563
|
1019 DEFSYMBOL (Qcomposite);
|
428
|
1020 }
|
|
1021
|
771
|
1022 static int
|
|
1023 init_charset_unicode_tables_mapper (Lisp_Object key, Lisp_Object value,
|
|
1024 void *closure)
|
|
1025 {
|
|
1026 init_charset_unicode_tables (value);
|
|
1027 return 0;
|
|
1028 }
|
|
1029
|
|
1030 void
|
|
1031 init_mule_charset (void)
|
|
1032 {
|
|
1033 /* See mule-charset.h, definition of Lisp_Charset. */
|
|
1034 if (initialized)
|
|
1035 elisp_maphash (init_charset_unicode_tables_mapper, Vcharset_hash_table,
|
|
1036 0);
|
|
1037 }
|
|
1038
|
428
|
1039 void
|
|
1040 vars_of_mule_charset (void)
|
|
1041 {
|
|
1042 int i, j, k;
|
|
1043
|
452
|
1044 chlook = xnew_and_zero (struct charset_lookup); /* zero for Purify. */
|
|
1045 dump_add_root_struct_ptr (&chlook, &charset_lookup_description);
|
428
|
1046
|
|
1047 /* Table of charsets indexed by leading byte. */
|
|
1048 for (i = 0; i < countof (chlook->charset_by_leading_byte); i++)
|
|
1049 chlook->charset_by_leading_byte[i] = Qnil;
|
|
1050
|
|
1051 /* Table of charsets indexed by type/final-byte/direction. */
|
|
1052 for (i = 0; i < countof (chlook->charset_by_attributes); i++)
|
|
1053 for (j = 0; j < countof (chlook->charset_by_attributes[0]); j++)
|
|
1054 for (k = 0; k < countof (chlook->charset_by_attributes[0][0]); k++)
|
|
1055 chlook->charset_by_attributes[i][j][k] = Qnil;
|
|
1056
|
442
|
1057 chlook->next_allocated_1_byte_leading_byte = MIN_LEADING_BYTE_PRIVATE_1;
|
|
1058 chlook->next_allocated_2_byte_leading_byte = MIN_LEADING_BYTE_PRIVATE_2;
|
771
|
1059
|
|
1060 staticpro (&Vcharset_hash_table);
|
|
1061 Vcharset_hash_table =
|
|
1062 make_lisp_hash_table (50, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
|
428
|
1063 }
|
|
1064
|
|
1065 void
|
|
1066 complex_vars_of_mule_charset (void)
|
|
1067 {
|
|
1068 /* Predefined character sets. We store them into variables for
|
|
1069 ease of access. */
|
|
1070
|
|
1071 staticpro (&Vcharset_ascii);
|
|
1072 Vcharset_ascii =
|
|
1073 make_charset (LEADING_BYTE_ASCII, Qascii, 1,
|
|
1074 CHARSET_TYPE_94, 1, 0, 'B',
|
|
1075 CHARSET_LEFT_TO_RIGHT,
|
|
1076 build_string ("ASCII"),
|
771
|
1077 build_msg_string ("ASCII"),
|
|
1078 build_msg_string ("ASCII (ISO646 IRV)"),
|
|
1079 build_string ("\\(iso8859-[0-9]*\\|-ascii\\)"), 0);
|
428
|
1080 staticpro (&Vcharset_control_1);
|
|
1081 Vcharset_control_1 =
|
|
1082 make_charset (LEADING_BYTE_CONTROL_1, Qcontrol_1, 2,
|
|
1083 CHARSET_TYPE_94, 1, 1, 0,
|
|
1084 CHARSET_LEFT_TO_RIGHT,
|
|
1085 build_string ("C1"),
|
771
|
1086 build_msg_string ("Control characters"),
|
|
1087 build_msg_string ("Control characters 128-191"),
|
|
1088 build_string (""), 0);
|
428
|
1089 staticpro (&Vcharset_latin_iso8859_1);
|
|
1090 Vcharset_latin_iso8859_1 =
|
|
1091 make_charset (LEADING_BYTE_LATIN_ISO8859_1, Qlatin_iso8859_1, 2,
|
|
1092 CHARSET_TYPE_96, 1, 1, 'A',
|
|
1093 CHARSET_LEFT_TO_RIGHT,
|
|
1094 build_string ("Latin-1"),
|
771
|
1095 build_msg_string ("ISO8859-1 (Latin-1)"),
|
|
1096 build_msg_string ("ISO8859-1 (Latin-1)"),
|
|
1097 build_string ("iso8859-1"), 0);
|
428
|
1098 staticpro (&Vcharset_latin_iso8859_2);
|
|
1099 Vcharset_latin_iso8859_2 =
|
|
1100 make_charset (LEADING_BYTE_LATIN_ISO8859_2, Qlatin_iso8859_2, 2,
|
|
1101 CHARSET_TYPE_96, 1, 1, 'B',
|
|
1102 CHARSET_LEFT_TO_RIGHT,
|
|
1103 build_string ("Latin-2"),
|
771
|
1104 build_msg_string ("ISO8859-2 (Latin-2)"),
|
|
1105 build_msg_string ("ISO8859-2 (Latin-2)"),
|
|
1106 build_string ("iso8859-2"), 0);
|
428
|
1107 staticpro (&Vcharset_latin_iso8859_3);
|
|
1108 Vcharset_latin_iso8859_3 =
|
|
1109 make_charset (LEADING_BYTE_LATIN_ISO8859_3, Qlatin_iso8859_3, 2,
|
|
1110 CHARSET_TYPE_96, 1, 1, 'C',
|
|
1111 CHARSET_LEFT_TO_RIGHT,
|
|
1112 build_string ("Latin-3"),
|
771
|
1113 build_msg_string ("ISO8859-3 (Latin-3)"),
|
|
1114 build_msg_string ("ISO8859-3 (Latin-3)"),
|
|
1115 build_string ("iso8859-3"), 0);
|
428
|
1116 staticpro (&Vcharset_latin_iso8859_4);
|
|
1117 Vcharset_latin_iso8859_4 =
|
|
1118 make_charset (LEADING_BYTE_LATIN_ISO8859_4, Qlatin_iso8859_4, 2,
|
|
1119 CHARSET_TYPE_96, 1, 1, 'D',
|
|
1120 CHARSET_LEFT_TO_RIGHT,
|
|
1121 build_string ("Latin-4"),
|
771
|
1122 build_msg_string ("ISO8859-4 (Latin-4)"),
|
|
1123 build_msg_string ("ISO8859-4 (Latin-4)"),
|
|
1124 build_string ("iso8859-4"), 0);
|
428
|
1125 staticpro (&Vcharset_thai_tis620);
|
|
1126 Vcharset_thai_tis620 =
|
|
1127 make_charset (LEADING_BYTE_THAI_TIS620, Qthai_tis620, 2,
|
|
1128 CHARSET_TYPE_96, 1, 1, 'T',
|
|
1129 CHARSET_LEFT_TO_RIGHT,
|
|
1130 build_string ("TIS620"),
|
771
|
1131 build_msg_string ("TIS620 (Thai)"),
|
|
1132 build_msg_string ("TIS620.2529 (Thai)"),
|
|
1133 build_string ("tis620"),0);
|
428
|
1134 staticpro (&Vcharset_greek_iso8859_7);
|
|
1135 Vcharset_greek_iso8859_7 =
|
|
1136 make_charset (LEADING_BYTE_GREEK_ISO8859_7, Qgreek_iso8859_7, 2,
|
|
1137 CHARSET_TYPE_96, 1, 1, 'F',
|
|
1138 CHARSET_LEFT_TO_RIGHT,
|
|
1139 build_string ("ISO8859-7"),
|
771
|
1140 build_msg_string ("ISO8859-7 (Greek)"),
|
|
1141 build_msg_string ("ISO8859-7 (Greek)"),
|
|
1142 build_string ("iso8859-7"), 0);
|
428
|
1143 staticpro (&Vcharset_arabic_iso8859_6);
|
|
1144 Vcharset_arabic_iso8859_6 =
|
|
1145 make_charset (LEADING_BYTE_ARABIC_ISO8859_6, Qarabic_iso8859_6, 2,
|
|
1146 CHARSET_TYPE_96, 1, 1, 'G',
|
|
1147 CHARSET_RIGHT_TO_LEFT,
|
|
1148 build_string ("ISO8859-6"),
|
771
|
1149 build_msg_string ("ISO8859-6 (Arabic)"),
|
|
1150 build_msg_string ("ISO8859-6 (Arabic)"),
|
|
1151 build_string ("iso8859-6"), 0);
|
428
|
1152 staticpro (&Vcharset_hebrew_iso8859_8);
|
|
1153 Vcharset_hebrew_iso8859_8 =
|
|
1154 make_charset (LEADING_BYTE_HEBREW_ISO8859_8, Qhebrew_iso8859_8, 2,
|
|
1155 CHARSET_TYPE_96, 1, 1, 'H',
|
|
1156 CHARSET_RIGHT_TO_LEFT,
|
|
1157 build_string ("ISO8859-8"),
|
771
|
1158 build_msg_string ("ISO8859-8 (Hebrew)"),
|
|
1159 build_msg_string ("ISO8859-8 (Hebrew)"),
|
|
1160 build_string ("iso8859-8"), 0);
|
428
|
1161 staticpro (&Vcharset_katakana_jisx0201);
|
|
1162 Vcharset_katakana_jisx0201 =
|
|
1163 make_charset (LEADING_BYTE_KATAKANA_JISX0201, Qkatakana_jisx0201, 2,
|
|
1164 CHARSET_TYPE_94, 1, 1, 'I',
|
|
1165 CHARSET_LEFT_TO_RIGHT,
|
|
1166 build_string ("JISX0201 Kana"),
|
771
|
1167 build_msg_string ("JISX0201.1976 (Japanese Kana)"),
|
|
1168 build_msg_string ("JISX0201.1976 Japanese Kana"),
|
|
1169 build_string ("jisx0201.1976"), 0);
|
428
|
1170 staticpro (&Vcharset_latin_jisx0201);
|
|
1171 Vcharset_latin_jisx0201 =
|
|
1172 make_charset (LEADING_BYTE_LATIN_JISX0201, Qlatin_jisx0201, 2,
|
|
1173 CHARSET_TYPE_94, 1, 0, 'J',
|
|
1174 CHARSET_LEFT_TO_RIGHT,
|
|
1175 build_string ("JISX0201 Roman"),
|
771
|
1176 build_msg_string ("JISX0201.1976 (Japanese Roman)"),
|
|
1177 build_msg_string ("JISX0201.1976 Japanese Roman"),
|
|
1178 build_string ("jisx0201.1976"), 0);
|
428
|
1179 staticpro (&Vcharset_cyrillic_iso8859_5);
|
|
1180 Vcharset_cyrillic_iso8859_5 =
|
|
1181 make_charset (LEADING_BYTE_CYRILLIC_ISO8859_5, Qcyrillic_iso8859_5, 2,
|
|
1182 CHARSET_TYPE_96, 1, 1, 'L',
|
|
1183 CHARSET_LEFT_TO_RIGHT,
|
|
1184 build_string ("ISO8859-5"),
|
771
|
1185 build_msg_string ("ISO8859-5 (Cyrillic)"),
|
|
1186 build_msg_string ("ISO8859-5 (Cyrillic)"),
|
|
1187 build_string ("iso8859-5"), 0);
|
428
|
1188 staticpro (&Vcharset_latin_iso8859_9);
|
|
1189 Vcharset_latin_iso8859_9 =
|
|
1190 make_charset (LEADING_BYTE_LATIN_ISO8859_9, Qlatin_iso8859_9, 2,
|
|
1191 CHARSET_TYPE_96, 1, 1, 'M',
|
|
1192 CHARSET_LEFT_TO_RIGHT,
|
|
1193 build_string ("Latin-5"),
|
771
|
1194 build_msg_string ("ISO8859-9 (Latin-5)"),
|
|
1195 build_msg_string ("ISO8859-9 (Latin-5)"),
|
|
1196 build_string ("iso8859-9"), 0);
|
728
|
1197 staticpro (&Vcharset_latin_iso8859_15);
|
|
1198 Vcharset_latin_iso8859_15 =
|
|
1199 make_charset (LEADING_BYTE_LATIN_ISO8859_15, Qlatin_iso8859_15, 2,
|
|
1200 CHARSET_TYPE_96, 1, 1, 'b',
|
|
1201 CHARSET_LEFT_TO_RIGHT,
|
|
1202 build_string ("Latin-9"),
|
771
|
1203 build_msg_string ("ISO8859-15 (Latin-9)"),
|
|
1204 build_msg_string ("ISO8859-15 (Latin-9)"),
|
|
1205 build_string ("iso8859-15"), 0);
|
428
|
1206 staticpro (&Vcharset_japanese_jisx0208_1978);
|
|
1207 Vcharset_japanese_jisx0208_1978 =
|
|
1208 make_charset (LEADING_BYTE_JAPANESE_JISX0208_1978, Qjapanese_jisx0208_1978, 3,
|
|
1209 CHARSET_TYPE_94X94, 2, 0, '@',
|
|
1210 CHARSET_LEFT_TO_RIGHT,
|
|
1211 build_string ("JISX0208.1978"),
|
771
|
1212 build_msg_string ("JISX0208.1978 (Japanese)"),
|
|
1213 build_msg_string
|
428
|
1214 ("JISX0208.1978 Japanese Kanji (so called \"old JIS\")"),
|
771
|
1215 build_string ("\\(jisx0208\\|jisc6226\\)\\.1978"), 0);
|
428
|
1216 staticpro (&Vcharset_chinese_gb2312);
|
|
1217 Vcharset_chinese_gb2312 =
|
|
1218 make_charset (LEADING_BYTE_CHINESE_GB2312, Qchinese_gb2312, 3,
|
|
1219 CHARSET_TYPE_94X94, 2, 0, 'A',
|
|
1220 CHARSET_LEFT_TO_RIGHT,
|
|
1221 build_string ("GB2312"),
|
771
|
1222 build_msg_string ("GB2312)"),
|
|
1223 build_msg_string ("GB2312 Chinese simplified"),
|
|
1224 build_string ("gb2312"), 0);
|
428
|
1225 staticpro (&Vcharset_japanese_jisx0208);
|
|
1226 Vcharset_japanese_jisx0208 =
|
|
1227 make_charset (LEADING_BYTE_JAPANESE_JISX0208, Qjapanese_jisx0208, 3,
|
|
1228 CHARSET_TYPE_94X94, 2, 0, 'B',
|
|
1229 CHARSET_LEFT_TO_RIGHT,
|
|
1230 build_string ("JISX0208"),
|
771
|
1231 build_msg_string ("JISX0208.1983/1990 (Japanese)"),
|
|
1232 build_msg_string ("JISX0208.1983/1990 Japanese Kanji"),
|
|
1233 build_string ("jisx0208.19\\(83\\|90\\)"), 0);
|
428
|
1234 staticpro (&Vcharset_korean_ksc5601);
|
|
1235 Vcharset_korean_ksc5601 =
|
|
1236 make_charset (LEADING_BYTE_KOREAN_KSC5601, Qkorean_ksc5601, 3,
|
|
1237 CHARSET_TYPE_94X94, 2, 0, 'C',
|
|
1238 CHARSET_LEFT_TO_RIGHT,
|
|
1239 build_string ("KSC5601"),
|
771
|
1240 build_msg_string ("KSC5601 (Korean"),
|
|
1241 build_msg_string ("KSC5601 Korean Hangul and Hanja"),
|
|
1242 build_string ("ksc5601"), 0);
|
428
|
1243 staticpro (&Vcharset_japanese_jisx0212);
|
|
1244 Vcharset_japanese_jisx0212 =
|
|
1245 make_charset (LEADING_BYTE_JAPANESE_JISX0212, Qjapanese_jisx0212, 3,
|
|
1246 CHARSET_TYPE_94X94, 2, 0, 'D',
|
|
1247 CHARSET_LEFT_TO_RIGHT,
|
|
1248 build_string ("JISX0212"),
|
771
|
1249 build_msg_string ("JISX0212 (Japanese)"),
|
|
1250 build_msg_string ("JISX0212 Japanese Supplement"),
|
|
1251 build_string ("jisx0212"), 0);
|
428
|
1252
|
|
1253 #define CHINESE_CNS_PLANE_RE(n) "cns11643[.-]\\(.*[.-]\\)?" n "$"
|
|
1254 staticpro (&Vcharset_chinese_cns11643_1);
|
|
1255 Vcharset_chinese_cns11643_1 =
|
|
1256 make_charset (LEADING_BYTE_CHINESE_CNS11643_1, Qchinese_cns11643_1, 3,
|
|
1257 CHARSET_TYPE_94X94, 2, 0, 'G',
|
|
1258 CHARSET_LEFT_TO_RIGHT,
|
|
1259 build_string ("CNS11643-1"),
|
771
|
1260 build_msg_string ("CNS11643-1 (Chinese traditional)"),
|
|
1261 build_msg_string
|
428
|
1262 ("CNS 11643 Plane 1 Chinese traditional"),
|
771
|
1263 build_string (CHINESE_CNS_PLANE_RE("1")), 0);
|
428
|
1264 staticpro (&Vcharset_chinese_cns11643_2);
|
|
1265 Vcharset_chinese_cns11643_2 =
|
|
1266 make_charset (LEADING_BYTE_CHINESE_CNS11643_2, Qchinese_cns11643_2, 3,
|
|
1267 CHARSET_TYPE_94X94, 2, 0, 'H',
|
|
1268 CHARSET_LEFT_TO_RIGHT,
|
|
1269 build_string ("CNS11643-2"),
|
771
|
1270 build_msg_string ("CNS11643-2 (Chinese traditional)"),
|
|
1271 build_msg_string
|
428
|
1272 ("CNS 11643 Plane 2 Chinese traditional"),
|
771
|
1273 build_string (CHINESE_CNS_PLANE_RE("2")), 0);
|
428
|
1274 staticpro (&Vcharset_chinese_big5_1);
|
|
1275 Vcharset_chinese_big5_1 =
|
|
1276 make_charset (LEADING_BYTE_CHINESE_BIG5_1, Qchinese_big5_1, 3,
|
|
1277 CHARSET_TYPE_94X94, 2, 0, '0',
|
|
1278 CHARSET_LEFT_TO_RIGHT,
|
|
1279 build_string ("Big5"),
|
771
|
1280 build_msg_string ("Big5 (Level-1)"),
|
|
1281 build_msg_string
|
428
|
1282 ("Big5 Level-1 Chinese traditional"),
|
771
|
1283 build_string ("big5"), 0);
|
428
|
1284 staticpro (&Vcharset_chinese_big5_2);
|
|
1285 Vcharset_chinese_big5_2 =
|
|
1286 make_charset (LEADING_BYTE_CHINESE_BIG5_2, Qchinese_big5_2, 3,
|
|
1287 CHARSET_TYPE_94X94, 2, 0, '1',
|
|
1288 CHARSET_LEFT_TO_RIGHT,
|
|
1289 build_string ("Big5"),
|
771
|
1290 build_msg_string ("Big5 (Level-2)"),
|
|
1291 build_msg_string
|
428
|
1292 ("Big5 Level-2 Chinese traditional"),
|
771
|
1293 build_string ("big5"), 0);
|
428
|
1294
|
|
1295
|
|
1296 #ifdef ENABLE_COMPOSITE_CHARS
|
|
1297 /* #### For simplicity, we put composite chars into a 96x96 charset.
|
|
1298 This is going to lead to problems because you can run out of
|
|
1299 room, esp. as we don't yet recycle numbers. */
|
|
1300 staticpro (&Vcharset_composite);
|
|
1301 Vcharset_composite =
|
|
1302 make_charset (LEADING_BYTE_COMPOSITE, Qcomposite, 3,
|
|
1303 CHARSET_TYPE_96X96, 2, 0, 0,
|
|
1304 CHARSET_LEFT_TO_RIGHT,
|
|
1305 build_string ("Composite"),
|
771
|
1306 build_msg_string ("Composite characters"),
|
|
1307 build_msg_string ("Composite characters"),
|
|
1308 build_string (""), 0);
|
|
1309 #else
|
|
1310 /* We create a hack so that we have a way of storing ESC 0 and ESC 1
|
|
1311 sequences as "characters", so that they will be output correctly. */
|
|
1312 staticpro (&Vcharset_composite);
|
|
1313 Vcharset_composite =
|
|
1314 make_charset (LEADING_BYTE_COMPOSITE_REPLACEMENT, Qcomposite, 2,
|
|
1315 CHARSET_TYPE_96, 1, 1, '|',
|
|
1316 CHARSET_LEFT_TO_RIGHT,
|
|
1317 build_string ("Composite hack"),
|
|
1318 build_msg_string ("Composite characters hack"),
|
|
1319 build_msg_string ("Composite characters hack"),
|
|
1320 build_string (""), 0);
|
428
|
1321 #endif /* ENABLE_COMPOSITE_CHARS */
|
|
1322 }
|