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