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