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