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