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