annotate src/mule-charset.c @ 420:41dbb7a9d5f2 r21-2-18

Import from CVS: tag r21-2-18
author cvs
date Mon, 13 Aug 2007 11:24:09 +0200
parents e804706bfb8c
children 95016f13131a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1 /* Functions to handle multilingual characters.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
2 Copyright (C) 1992, 1995 Free Software Foundation, Inc.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
3 Copyright (C) 1995 Sun Microsystems, Inc.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
4
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
5 This file is part of XEmacs.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
6
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
10 later version.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
11
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
15 for more details.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
16
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
21
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
22 /* Synched up with: FSF 20.3. Not in FSF. */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
23
298
70ad99077275 Import from CVS: tag r21-0b47
cvs
parents: 284
diff changeset
24 /* Rewritten by Ben Wing <ben@xemacs.org>. */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
25
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
26 #include <config.h>
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
27 #include "lisp.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
28
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
29 #include "buffer.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
30 #include "chartab.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
31 #include "elhash.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
32 #include "lstream.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
33 #include "device.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
34 #include "faces.h"
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
35
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
36 /* The various pre-defined charsets. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
37
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
38 Lisp_Object Vcharset_ascii;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
39 Lisp_Object Vcharset_control_1;
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
40 Lisp_Object Vcharset_latin_iso8859_1;
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
41 Lisp_Object Vcharset_latin_iso8859_2;
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
42 Lisp_Object Vcharset_latin_iso8859_3;
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
43 Lisp_Object Vcharset_latin_iso8859_4;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
44 Lisp_Object Vcharset_thai_tis620;
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
45 Lisp_Object Vcharset_greek_iso8859_7;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
46 Lisp_Object Vcharset_arabic_iso8859_6;
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
47 Lisp_Object Vcharset_hebrew_iso8859_8;
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
48 Lisp_Object Vcharset_katakana_jisx0201;
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
49 Lisp_Object Vcharset_latin_jisx0201;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
50 Lisp_Object Vcharset_cyrillic_iso8859_5;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
51 Lisp_Object Vcharset_latin_iso8859_9;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
52 Lisp_Object Vcharset_japanese_jisx0208_1978;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
53 Lisp_Object Vcharset_chinese_gb2312;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
54 Lisp_Object Vcharset_japanese_jisx0208;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
55 Lisp_Object Vcharset_korean_ksc5601;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
56 Lisp_Object Vcharset_japanese_jisx0212;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
57 Lisp_Object Vcharset_chinese_cns11643_1;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
58 Lisp_Object Vcharset_chinese_cns11643_2;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
59 Lisp_Object Vcharset_chinese_big5_1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
60 Lisp_Object Vcharset_chinese_big5_2;
396
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 392
diff changeset
61
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 392
diff changeset
62 #ifdef ENABLE_COMPOSITE_CHARS
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
63 Lisp_Object Vcharset_composite;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
64
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
65 /* Hash tables for composite chars. One maps string representing
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
66 composed chars to their equivalent chars; one goes the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
67 other way. */
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
68 Lisp_Object Vcomposite_char_char2string_hash_table;
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
69 Lisp_Object Vcomposite_char_string2char_hash_table;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
70
396
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 392
diff changeset
71 static int composite_char_row_next;
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 392
diff changeset
72 static int composite_char_col_next;
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 392
diff changeset
73
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 392
diff changeset
74 #endif /* ENABLE_COMPOSITE_CHARS */
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 392
diff changeset
75
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
76 /* Table of charsets indexed by leading byte. */
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
77 Lisp_Object charset_by_leading_byte[128];
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
78
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
79 /* Table of charsets indexed by type/final-byte/direction. */
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
80 Lisp_Object charset_by_attributes[4][128][2];
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
81
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
82 /* Table of number of bytes in the string representation of a character
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
83 indexed by the first byte of that representation.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
84
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
85 rep_bytes_by_first_byte(c) is more efficient than the equivalent
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
86 canonical computation:
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
87
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
88 (BYTE_ASCII_P (c) ? 1 : XCHARSET_REP_BYTES (CHARSET_BY_LEADING_BYTE (c))) */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
89
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
90 Bytecount rep_bytes_by_first_byte[0xA0] =
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
91 { /* 0x00 - 0x7f are for straight ASCII */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
92 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
93 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
94 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
95 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
96 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
97 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
98 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
99 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
100 /* 0x80 - 0x8f are for Dimension-1 official charsets */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
101 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
102 /* 0x90 - 0x9d are for Dimension-2 official charsets */
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
103 /* 0x9e is for Dimension-1 private charsets */
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
104 /* 0x9f is for Dimension-2 private charsets */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
105 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
106 };
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
107
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
108 Lisp_Object Qcharsetp;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
109
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
110 /* Qdoc_string, Qdimension, Qchars defined in general.c */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
111 Lisp_Object Qregistry, Qfinal, Qgraphic;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
112 Lisp_Object Qdirection;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
113 Lisp_Object Qreverse_direction_charset;
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
114 Lisp_Object Qccl_program;
392
1f50e6fe4f3f Import from CVS: tag r21-2-11
cvs
parents: 380
diff changeset
115 Lisp_Object Qleading_byte;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
116 Lisp_Object Qshort_name, Qlong_name;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
117
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
118 Lisp_Object Qascii,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
119 Qcontrol_1,
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
120 Qlatin_iso8859_1,
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
121 Qlatin_iso8859_2,
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
122 Qlatin_iso8859_3,
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
123 Qlatin_iso8859_4,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
124 Qthai_tis620,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
125 Qgreek_iso8859_7,
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
126 Qarabic_iso8859_6,
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
127 Qhebrew_iso8859_8,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
128 Qkatakana_jisx0201,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
129 Qlatin_jisx0201,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
130 Qcyrillic_iso8859_5,
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
131 Qlatin_iso8859_9,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
132 Qjapanese_jisx0208_1978,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
133 Qchinese_gb2312,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
134 Qjapanese_jisx0208,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
135 Qkorean_ksc5601,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
136 Qjapanese_jisx0212,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
137 Qchinese_cns11643_1,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
138 Qchinese_cns11643_2,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
139 Qchinese_big5_1,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
140 Qchinese_big5_2,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
141 Qcomposite;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
142
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
143 Lisp_Object Ql2r, Qr2l;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
144
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
145 Lisp_Object Vcharset_hash_table;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
146
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
147 static Bufbyte next_allocated_1_byte_leading_byte;
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
148 static Bufbyte next_allocated_2_byte_leading_byte;
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
149
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
150 /* Composite characters are characters constructed by overstriking two
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
151 or more regular characters.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
152
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
153 1) The old Mule implementation involves storing composite characters
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
154 in a buffer as a tag followed by all of the actual characters
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
155 used to make up the composite character. I think this is a bad
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
156 idea; it greatly complicates code that wants to handle strings
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
157 one character at a time because it has to deal with the possibility
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
158 of great big ungainly characters. It's much more reasonable to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
159 simply store an index into a table of composite characters.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
160
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
161 2) The current implementation only allows for 16,384 separate
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
162 composite characters over the lifetime of the XEmacs process.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
163 This could become a potential problem if the user
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
164 edited lots of different files that use composite characters.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
165 Due to FSF bogosity, increasing the number of allowable
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
166 composite characters under Mule would decrease the number
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
167 of possible faces that can exist. Mule already has shrunk
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
168 this to 2048, and further shrinkage would become uncomfortable.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
169 No such problems exist in XEmacs.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
170
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
171 Composite characters could be represented as 0x80 C1 C2 C3,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
172 where each C[1-3] is in the range 0xA0 - 0xFF. This allows
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
173 for slightly under 2^20 (one million) composite characters
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
174 over the XEmacs process lifetime, and you only need to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
175 increase the size of a Mule character from 19 to 21 bits.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
176 Or you could use 0x80 C1 C2 C3 C4, allowing for about
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
177 85 million (slightly over 2^26) composite characters. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
178
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
179
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
180 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
181 /* Basic Emchar functions */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
182 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
183
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
184 /* Convert a non-ASCII Mule character C into a one-character Mule-encoded
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
185 string in STR. Returns the number of bytes stored.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
186 Do not call this directly. Use the macro set_charptr_emchar() instead.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
187 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
188
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
189 Bytecount
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
190 non_ascii_set_charptr_emchar (Bufbyte *str, Emchar c)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
191 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
192 Bufbyte *p;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
193 Bufbyte lb;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
194 int c1, c2;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
195 Lisp_Object charset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
196
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
197 p = str;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
198 BREAKUP_CHAR (c, charset, c1, c2);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
199 lb = CHAR_LEADING_BYTE (c);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
200 if (LEADING_BYTE_PRIVATE_P (lb))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
201 *p++ = PRIVATE_LEADING_BYTE_PREFIX (lb);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
202 *p++ = lb;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
203 if (EQ (charset, Vcharset_control_1))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
204 c1 += 0x20;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
205 *p++ = c1 | 0x80;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
206 if (c2)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
207 *p++ = c2 | 0x80;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
208
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
209 return (p - str);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
210 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
211
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
212 /* Return the first character from a Mule-encoded string in STR,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
213 assuming it's non-ASCII. Do not call this directly.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
214 Use the macro charptr_emchar() instead. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
215
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
216 Emchar
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
217 non_ascii_charptr_emchar (CONST Bufbyte *str)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
218 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
219 Bufbyte i0 = *str, i1, i2 = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
220 Lisp_Object charset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
221
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
222 if (i0 == LEADING_BYTE_CONTROL_1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
223 return (Emchar) (*++str - 0x20);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
224
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
225 if (LEADING_BYTE_PREFIX_P (i0))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
226 i0 = *++str;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
227
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
228 i1 = *++str & 0x7F;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
229
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
230 charset = CHARSET_BY_LEADING_BYTE (i0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
231 if (XCHARSET_DIMENSION (charset) == 2)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
232 i2 = *++str & 0x7F;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
233
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
234 return MAKE_CHAR (charset, i1, i2);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
235 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
236
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
237 /* Return whether CH is a valid Emchar, assuming it's non-ASCII.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
238 Do not call this directly. Use the macro valid_char_p() instead. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
239
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
240 int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
241 non_ascii_valid_char_p (Emchar ch)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
242 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
243 int f1, f2, f3;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
244
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
245 /* Must have only lowest 19 bits set */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
246 if (ch & ~0x7FFFF)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
247 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
248
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
249 f1 = CHAR_FIELD1 (ch);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
250 f2 = CHAR_FIELD2 (ch);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
251 f3 = CHAR_FIELD3 (ch);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
252
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
253 if (f1 == 0)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
254 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
255 Lisp_Object charset;
371
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 367
diff changeset
256
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
257 if (f2 < MIN_CHAR_FIELD2_OFFICIAL ||
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
258 (f2 > MAX_CHAR_FIELD2_OFFICIAL && f2 < MIN_CHAR_FIELD2_PRIVATE) ||
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
259 f2 > MAX_CHAR_FIELD2_PRIVATE)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
260 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
261 if (f3 < 0x20)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
262 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
263
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
264 if (f3 != 0x20 && f3 != 0x7F)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
265 return 1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
266
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
267 /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
268 NOTE: This takes advantage of the fact that
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
269 FIELD2_TO_OFFICIAL_LEADING_BYTE and
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
270 FIELD2_TO_PRIVATE_LEADING_BYTE are the same.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
271 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
272 charset = CHARSET_BY_LEADING_BYTE (f2 + FIELD2_TO_OFFICIAL_LEADING_BYTE);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
273 return (XCHARSET_CHARS (charset) == 96);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
274 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
275 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
276 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
277 Lisp_Object charset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
278
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
279 if (f1 < MIN_CHAR_FIELD1_OFFICIAL ||
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
280 (f1 > MAX_CHAR_FIELD1_OFFICIAL && f1 < MIN_CHAR_FIELD1_PRIVATE) ||
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
281 f1 > MAX_CHAR_FIELD1_PRIVATE)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
282 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
283 if (f2 < 0x20 || f3 < 0x20)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
284 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
285
396
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 392
diff changeset
286 #ifdef ENABLE_COMPOSITE_CHARS
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
287 if (f1 + FIELD1_TO_OFFICIAL_LEADING_BYTE == LEADING_BYTE_COMPOSITE)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
288 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
289 if (UNBOUNDP (Fgethash (make_int (ch),
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
290 Vcomposite_char_char2string_hash_table,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
291 Qunbound)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
292 return 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
293 return 1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
294 }
396
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 392
diff changeset
295 #endif /* ENABLE_COMPOSITE_CHARS */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
296
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
297 if (f2 != 0x20 && f2 != 0x7F && f3 != 0x20 && f3 != 0x7F)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
298 return 1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
299
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
300 if (f1 <= MAX_CHAR_FIELD1_OFFICIAL)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
301 charset =
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
302 CHARSET_BY_LEADING_BYTE (f1 + FIELD1_TO_OFFICIAL_LEADING_BYTE);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
303 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
304 charset =
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
305 CHARSET_BY_LEADING_BYTE (f1 + FIELD1_TO_PRIVATE_LEADING_BYTE);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
306
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
307 return (XCHARSET_CHARS (charset) == 96);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
308 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
309 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
310
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
311
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
312 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
313 /* Basic string functions */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
314 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
315
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
316 /* Copy the character pointed to by PTR into STR, assuming it's
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
317 non-ASCII. Do not call this directly. Use the macro
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
318 charptr_copy_char() instead. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
319
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
320 Bytecount
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
321 non_ascii_charptr_copy_char (CONST Bufbyte *ptr, Bufbyte *str)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
322 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
323 Bufbyte *strptr = str;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
324 *strptr = *ptr++;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
325 switch (REP_BYTES_BY_FIRST_BYTE (*strptr))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
326 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
327 /* Notice fallthrough. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
328 case 4: *++strptr = *ptr++;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
329 case 3: *++strptr = *ptr++;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
330 case 2: *++strptr = *ptr;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
331 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
332 default:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
333 abort ();
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
334 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
335 return strptr + 1 - str;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
336 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
337
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
338
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
339 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
340 /* streams of Emchars */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
341 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
342
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
343 /* Treat a stream as a stream of Emchar's rather than a stream of bytes.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
344 The functions below are not meant to be called directly; use
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
345 the macros in insdel.h. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
346
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
347 Emchar
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
348 Lstream_get_emchar_1 (Lstream *stream, int ch)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
349 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
350 Bufbyte str[MAX_EMCHAR_LEN];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
351 Bufbyte *strptr = str;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
352
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
353 str[0] = (Bufbyte) ch;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
354 switch (REP_BYTES_BY_FIRST_BYTE (ch))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
355 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
356 /* Notice fallthrough. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
357 case 4:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
358 ch = Lstream_getc (stream);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
359 assert (ch >= 0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
360 *++strptr = (Bufbyte) ch;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
361 case 3:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
362 ch = Lstream_getc (stream);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
363 assert (ch >= 0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
364 *++strptr = (Bufbyte) ch;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
365 case 2:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
366 ch = Lstream_getc (stream);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
367 assert (ch >= 0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
368 *++strptr = (Bufbyte) ch;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
369 break;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
370 default:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
371 abort ();
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
372 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
373 return charptr_emchar (str);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
374 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
375
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
376 int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
377 Lstream_fput_emchar (Lstream *stream, Emchar ch)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
378 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
379 Bufbyte str[MAX_EMCHAR_LEN];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
380 Bytecount len = set_charptr_emchar (str, ch);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
381 return Lstream_write (stream, str, len);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
382 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
383
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
384 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
385 Lstream_funget_emchar (Lstream *stream, Emchar ch)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
386 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
387 Bufbyte str[MAX_EMCHAR_LEN];
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
388 Bytecount len = set_charptr_emchar (str, ch);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
389 Lstream_unread (stream, str, len);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
390 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
391
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
392
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
393 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
394 /* charset object */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
395 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
396
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
397 static Lisp_Object
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
398 mark_charset (Lisp_Object obj, void (*markobj) (Lisp_Object))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
399 {
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
400 struct Lisp_Charset *cs = XCHARSET (obj);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
401
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
402 markobj (cs->short_name);
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
403 markobj (cs->long_name);
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
404 markobj (cs->doc_string);
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
405 markobj (cs->registry);
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
406 markobj (cs->ccl_program);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
407 return cs->name;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
408 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
409
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
410 static void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
411 print_charset (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
412 {
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
413 struct Lisp_Charset *cs = XCHARSET (obj);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
414 char buf[200];
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
415
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
416 if (print_readably)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
417 error ("printing unreadable object #<charset %s 0x%x>",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
418 string_data (XSYMBOL (CHARSET_NAME (cs))->name),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
419 cs->header.uid);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
420
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
421 write_c_string ("#<charset ", printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
422 print_internal (CHARSET_NAME (cs), printcharfun, 0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
423 write_c_string (" ", printcharfun);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
424 print_internal (CHARSET_SHORT_NAME (cs), printcharfun, 1);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
425 write_c_string (" ", printcharfun);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
426 print_internal (CHARSET_LONG_NAME (cs), printcharfun, 1);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
427 write_c_string (" ", printcharfun);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
428 print_internal (CHARSET_DOC_STRING (cs), printcharfun, 1);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
429 sprintf (buf, " %s %s cols=%d g%d final='%c' reg=",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
430 CHARSET_TYPE (cs) == CHARSET_TYPE_94 ? "94" :
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
431 CHARSET_TYPE (cs) == CHARSET_TYPE_96 ? "96" :
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
432 CHARSET_TYPE (cs) == CHARSET_TYPE_94X94 ? "94x94" :
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
433 "96x96",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
434 CHARSET_DIRECTION (cs) == CHARSET_LEFT_TO_RIGHT ? "l2r" : "r2l",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
435 CHARSET_COLUMNS (cs),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
436 CHARSET_GRAPHIC (cs),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
437 CHARSET_FINAL (cs));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
438 write_c_string (buf, printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
439 print_internal (CHARSET_REGISTRY (cs), printcharfun, 0);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
440 sprintf (buf, " 0x%x>", cs->header.uid);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
441 write_c_string (buf, printcharfun);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
442 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
443
420
41dbb7a9d5f2 Import from CVS: tag r21-2-18
cvs
parents: 418
diff changeset
444 static const struct lrecord_description charset_description[] = {
41dbb7a9d5f2 Import from CVS: tag r21-2-18
cvs
parents: 418
diff changeset
445 { XD_LISP_OBJECT, offsetof(struct Lisp_Charset, name), 7 },
41dbb7a9d5f2 Import from CVS: tag r21-2-18
cvs
parents: 418
diff changeset
446 { XD_END }
41dbb7a9d5f2 Import from CVS: tag r21-2-18
cvs
parents: 418
diff changeset
447 };
41dbb7a9d5f2 Import from CVS: tag r21-2-18
cvs
parents: 418
diff changeset
448
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
449 DEFINE_LRECORD_IMPLEMENTATION ("charset", charset,
420
41dbb7a9d5f2 Import from CVS: tag r21-2-18
cvs
parents: 418
diff changeset
450 mark_charset, print_charset, 0, 0, 0, charset_description,
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
451 struct Lisp_Charset);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
452 /* Make a new charset. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
453
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
454 static Lisp_Object
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
455 make_charset (int id, Lisp_Object name, unsigned char rep_bytes,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
456 unsigned char type, unsigned char columns, unsigned char graphic,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
457 Bufbyte final, unsigned char direction, Lisp_Object short_name,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
458 Lisp_Object long_name, Lisp_Object doc,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
459 Lisp_Object reg)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
460 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
461 Lisp_Object obj;
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
462 struct Lisp_Charset *cs =
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
463 alloc_lcrecord_type (struct Lisp_Charset, &lrecord_charset);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
464 XSETCHARSET (obj, cs);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
465
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
466 CHARSET_ID (cs) = id;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
467 CHARSET_NAME (cs) = name;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
468 CHARSET_SHORT_NAME (cs) = short_name;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
469 CHARSET_LONG_NAME (cs) = long_name;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
470 CHARSET_REP_BYTES (cs) = rep_bytes;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
471 CHARSET_DIRECTION (cs) = direction;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
472 CHARSET_TYPE (cs) = type;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
473 CHARSET_COLUMNS (cs) = columns;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
474 CHARSET_GRAPHIC (cs) = graphic;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
475 CHARSET_FINAL (cs) = final;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
476 CHARSET_DOC_STRING (cs) = doc;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
477 CHARSET_REGISTRY (cs) = reg;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
478 CHARSET_CCL_PROGRAM (cs) = Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
479 CHARSET_REVERSE_DIRECTION_CHARSET (cs) = Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
480
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 272
diff changeset
481 CHARSET_DIMENSION (cs) = (CHARSET_TYPE (cs) == CHARSET_TYPE_94 ||
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 272
diff changeset
482 CHARSET_TYPE (cs) == CHARSET_TYPE_96) ? 1 : 2;
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 272
diff changeset
483 CHARSET_CHARS (cs) = (CHARSET_TYPE (cs) == CHARSET_TYPE_94 ||
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 272
diff changeset
484 CHARSET_TYPE (cs) == CHARSET_TYPE_94X94) ? 94 : 96;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
485
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
486 if (final)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
487 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
488 /* some charsets do not have final characters. This includes
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
489 ASCII, Control-1, Composite, and the two faux private
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
490 charsets. */
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
491 assert (NILP (charset_by_attributes[type][final][direction]));
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
492 charset_by_attributes[type][final][direction] = obj;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
493 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
494
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
495 assert (NILP (charset_by_leading_byte[id - 128]));
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
496 charset_by_leading_byte[id - 128] = obj;
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
497 if (id < 0xA0)
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
498 /* official leading byte */
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
499 rep_bytes_by_first_byte[id] = rep_bytes;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
500
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
501 /* Some charsets are "faux" and don't have names or really exist at
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
502 all except in the leading-byte table. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
503 if (!NILP (name))
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
504 Fputhash (name, obj, Vcharset_hash_table);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
505 return obj;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
506 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
507
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
508 static int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
509 get_unallocated_leading_byte (int dimension)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
510 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
511 int lb;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
512
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
513 if (dimension == 1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
514 {
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
515 if (next_allocated_1_byte_leading_byte > MAX_LEADING_BYTE_PRIVATE_1)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
516 lb = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
517 else
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
518 lb = next_allocated_1_byte_leading_byte++;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
519 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
520 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
521 {
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
522 if (next_allocated_2_byte_leading_byte > MAX_LEADING_BYTE_PRIVATE_2)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
523 lb = 0;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
524 else
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
525 lb = next_allocated_2_byte_leading_byte++;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
526 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
527
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
528 if (!lb)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
529 signal_simple_error
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
530 ("No more character sets free for this dimension",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
531 make_int (dimension));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
532
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
533 return lb;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
534 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
535
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
536
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
537 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
538 /* Basic charset Lisp functions */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
539 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
540
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
541 DEFUN ("charsetp", Fcharsetp, 1, 1, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
542 Return non-nil if OBJECT is a charset.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
543 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
544 (object))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
545 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
546 return CHARSETP (object) ? Qt : Qnil;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
547 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
548
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
549 DEFUN ("find-charset", Ffind_charset, 1, 1, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
550 Retrieve the charset of the given name.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
551 If CHARSET-OR-NAME is a charset object, it is simply returned.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
552 Otherwise, CHARSET-OR-NAME should be a symbol. If there is no such charset,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
553 nil is returned. Otherwise the associated charset object is returned.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
554 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
555 (charset_or_name))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
556 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
557 if (CHARSETP (charset_or_name))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
558 return charset_or_name;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
559
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
560 CHECK_SYMBOL (charset_or_name);
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
561 return Fgethash (charset_or_name, Vcharset_hash_table, Qnil);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
562 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
563
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
564 DEFUN ("get-charset", Fget_charset, 1, 1, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
565 Retrieve the charset of the given name.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
566 Same as `find-charset' except an error is signalled if there is no such
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
567 charset instead of returning nil.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
568 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
569 (name))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
570 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
571 Lisp_Object charset = Ffind_charset (name);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
572
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
573 if (NILP (charset))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
574 signal_simple_error ("No such charset", name);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
575 return charset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
576 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
577
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
578 /* We store the charsets in hash tables with the names as the key and the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
579 actual charset object as the value. Occasionally we need to use them
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
580 in a list format. These routines provide us with that. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
581 struct charset_list_closure
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
582 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
583 Lisp_Object *charset_list;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
584 };
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
585
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 213
diff changeset
586 static int
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
587 add_charset_to_list_mapper (Lisp_Object key, Lisp_Object value,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
588 void *charset_list_closure)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
589 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
590 /* This function can GC */
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
591 struct charset_list_closure *chcl =
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 183
diff changeset
592 (struct charset_list_closure*) charset_list_closure;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
593 Lisp_Object *charset_list = chcl->charset_list;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
594
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
595 *charset_list = Fcons (XCHARSET_NAME (value), *charset_list);
241
f955c73f5258 Import from CVS: tag r20-5b19
cvs
parents: 213
diff changeset
596 return 0;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
597 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
598
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
599 DEFUN ("charset-list", Fcharset_list, 0, 0, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
600 Return a list of the names of all defined charsets.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
601 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
602 ())
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
603 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
604 Lisp_Object charset_list = Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
605 struct gcpro gcpro1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
606 struct charset_list_closure charset_list_closure;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
607
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
608 GCPRO1 (charset_list);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
609 charset_list_closure.charset_list = &charset_list;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
610 elisp_maphash (add_charset_to_list_mapper, Vcharset_hash_table,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
611 &charset_list_closure);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
612 UNGCPRO;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
613
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
614 return charset_list;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
615 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
616
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
617 DEFUN ("charset-name", Fcharset_name, 1, 1, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
618 Return the name of the given charset.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
619 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
620 (charset))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
621 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
622 return XCHARSET_NAME (Fget_charset (charset));
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
623 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
624
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
625 DEFUN ("make-charset", Fmake_charset, 3, 3, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
626 Define a new character set.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
627 This function is for use with Mule support.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
628 NAME is a symbol, the name by which the character set is normally referred.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
629 DOC-STRING is a string describing the character set.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
630 PROPS is a property list, describing the specific nature of the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
631 character set. Recognized properties are:
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
632
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
633 'short-name Short version of the charset name (ex: Latin-1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
634 'long-name Long version of the charset name (ex: ISO8859-1 (Latin-1))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
635 'registry A regular expression matching the font registry field for
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
636 this character set.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
637 'dimension Number of octets used to index a character in this charset.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
638 Either 1 or 2. Defaults to 1.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
639 'columns Number of columns used to display a character in this charset.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
640 Only used in TTY mode. (Under X, the actual width of a
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
641 character can be derived from the font used to display the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
642 characters.) If unspecified, defaults to the dimension
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
643 (this is almost always the correct value).
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
644 'chars Number of characters in each dimension (94 or 96).
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
645 Defaults to 94. Note that if the dimension is 2, the
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
646 character set thus described is 94x94 or 96x96.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
647 'final Final byte of ISO 2022 escape sequence. Must be
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
648 supplied. Each combination of (DIMENSION, CHARS) defines a
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
649 separate namespace for final bytes. Note that ISO
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
650 2022 restricts the final byte to the range
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
651 0x30 - 0x7E if dimension == 1, and 0x30 - 0x5F if
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
652 dimension == 2. Note also that final bytes in the range
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
653 0x30 - 0x3F are reserved for user-defined (not official)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
654 character sets.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
655 'graphic 0 (use left half of font on output) or 1 (use right half
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
656 of font on output). Defaults to 0. For example, for
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
657 a font whose registry is ISO8859-1, the left half
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
658 (octets 0x20 - 0x7F) is the `ascii' character set, while
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
659 the right half (octets 0xA0 - 0xFF) is the `latin-1'
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
660 character set. With 'graphic set to 0, the octets
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
661 will have their high bit cleared; with it set to 1,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
662 the octets will have their high bit set.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
663 'direction 'l2r (left-to-right) or 'r2l (right-to-left).
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
664 Defaults to 'l2r.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
665 'ccl-program A compiled CCL program used to convert a character in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
666 this charset into an index into the font. This is in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
667 addition to the 'graphic property. The CCL program
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
668 is passed the octets of the character, with the high
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
669 bit cleared and set depending upon whether the value
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
670 of the 'graphic property is 0 or 1.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
671 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
672 (name, doc_string, props))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
673 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
674 int id, dimension = 1, chars = 94, graphic = 0, final = 0, columns = -1;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
675 int direction = CHARSET_LEFT_TO_RIGHT;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
676 int type;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
677 Lisp_Object registry = Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
678 Lisp_Object charset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
679 Lisp_Object rest, keyword, value;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
680 Lisp_Object ccl_program = Qnil;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
681 Lisp_Object short_name = Qnil, long_name = Qnil;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
682
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
683 CHECK_SYMBOL (name);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
684 if (!NILP (doc_string))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
685 CHECK_STRING (doc_string);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
686
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
687 charset = Ffind_charset (name);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
688 if (!NILP (charset))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
689 signal_simple_error ("Cannot redefine existing charset", name);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
690
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
691 EXTERNAL_PROPERTY_LIST_LOOP (rest, keyword, value, props)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
692 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
693 if (EQ (keyword, Qshort_name))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
694 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
695 CHECK_STRING (value);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
696 short_name = value;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
697 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
698
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
699 if (EQ (keyword, Qlong_name))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
700 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
701 CHECK_STRING (value);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
702 long_name = value;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
703 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
704
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
705 else if (EQ (keyword, Qdimension))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
706 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
707 CHECK_INT (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
708 dimension = XINT (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
709 if (dimension < 1 || dimension > 2)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
710 signal_simple_error ("Invalid value for 'dimension", value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
711 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
712
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
713 else if (EQ (keyword, Qchars))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
714 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
715 CHECK_INT (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
716 chars = XINT (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
717 if (chars != 94 && chars != 96)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
718 signal_simple_error ("Invalid value for 'chars", value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
719 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
720
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
721 else if (EQ (keyword, Qcolumns))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
722 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
723 CHECK_INT (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
724 columns = XINT (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
725 if (columns != 1 && columns != 2)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
726 signal_simple_error ("Invalid value for 'columns", value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
727 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
728
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
729 else if (EQ (keyword, Qgraphic))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
730 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
731 CHECK_INT (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
732 graphic = XINT (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
733 if (graphic < 0 || graphic > 1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
734 signal_simple_error ("Invalid value for 'graphic", value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
735 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
736
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
737 else if (EQ (keyword, Qregistry))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
738 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
739 CHECK_STRING (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
740 registry = value;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
741 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
742
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
743 else if (EQ (keyword, Qdirection))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
744 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
745 if (EQ (value, Ql2r))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
746 direction = CHARSET_LEFT_TO_RIGHT;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
747 else if (EQ (value, Qr2l))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
748 direction = CHARSET_RIGHT_TO_LEFT;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
749 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
750 signal_simple_error ("Invalid value for 'direction", value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
751 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
752
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
753 else if (EQ (keyword, Qfinal))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
754 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
755 CHECK_CHAR_COERCE_INT (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
756 final = XCHAR (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
757 if (final < '0' || final > '~')
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
758 signal_simple_error ("Invalid value for 'final", value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
759 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
760
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
761 else if (EQ (keyword, Qccl_program))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
762 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
763 CHECK_VECTOR (value);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
764 ccl_program = value;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
765 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
766
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
767 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
768 signal_simple_error ("Unrecognized property", keyword);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
769 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
770
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
771 if (!final)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
772 error ("'final must be specified");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
773 if (dimension == 2 && final > 0x5F)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
774 signal_simple_error
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
775 ("Final must be in the range 0x30 - 0x5F for dimension == 2",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
776 make_char (final));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
777
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
778 if (dimension == 1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
779 type = (chars == 94) ? CHARSET_TYPE_94 : CHARSET_TYPE_96;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
780 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
781 type = (chars == 94) ? CHARSET_TYPE_94X94 : CHARSET_TYPE_96X96;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
782
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
783 if (!NILP (CHARSET_BY_ATTRIBUTES (type, final, CHARSET_LEFT_TO_RIGHT)) ||
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
784 !NILP (CHARSET_BY_ATTRIBUTES (type, final, CHARSET_RIGHT_TO_LEFT)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
785 error
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
786 ("Character set already defined for this DIMENSION/CHARS/FINAL combo");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
787
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
788 id = get_unallocated_leading_byte (dimension);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
789
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
790 if (NILP (doc_string))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
791 doc_string = build_string ("");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
792
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
793 if (NILP (registry))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
794 registry = build_string ("");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
795
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
796 if (NILP (short_name))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
797 XSETSTRING (short_name, XSYMBOL (name)->name);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
798
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
799 if (NILP (long_name))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
800 long_name = doc_string;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
801
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
802 if (columns == -1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
803 columns = dimension;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
804 charset = make_charset (id, name, dimension + 2, type, columns, graphic,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
805 final, direction, short_name, long_name, doc_string, registry);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
806 if (!NILP (ccl_program))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
807 XCHARSET_CCL_PROGRAM (charset) = ccl_program;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
808 return charset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
809 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
810
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 272
diff changeset
811 DEFUN ("make-reverse-direction-charset", Fmake_reverse_direction_charset,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 272
diff changeset
812 2, 2, 0, /*
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
813 Make a charset equivalent to CHARSET but which goes in the opposite direction.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
814 NEW-NAME is the name of the new charset. Return the new charset.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
815 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
816 (charset, new_name))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
817 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
818 Lisp_Object new_charset = Qnil;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
819 int id, dimension, columns, graphic, final;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
820 int direction, type;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
821 Lisp_Object registry, doc_string, short_name, long_name;
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
822 struct Lisp_Charset *cs;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
823
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
824 charset = Fget_charset (charset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
825 if (!NILP (XCHARSET_REVERSE_DIRECTION_CHARSET (charset)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
826 signal_simple_error ("Charset already has reverse-direction charset",
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
827 charset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
828
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
829 CHECK_SYMBOL (new_name);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
830 if (!NILP (Ffind_charset (new_name)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
831 signal_simple_error ("Cannot redefine existing charset", new_name);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
832
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
833 cs = XCHARSET (charset);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
834
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
835 type = CHARSET_TYPE (cs);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
836 columns = CHARSET_COLUMNS (cs);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
837 dimension = CHARSET_DIMENSION (cs);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
838 id = get_unallocated_leading_byte (dimension);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
839
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
840 graphic = CHARSET_GRAPHIC (cs);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
841 final = CHARSET_FINAL (cs);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
842 direction = CHARSET_RIGHT_TO_LEFT;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
843 if (CHARSET_DIRECTION (cs) == CHARSET_RIGHT_TO_LEFT)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
844 direction = CHARSET_LEFT_TO_RIGHT;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
845 doc_string = CHARSET_DOC_STRING (cs);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
846 short_name = CHARSET_SHORT_NAME (cs);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
847 long_name = CHARSET_LONG_NAME (cs);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
848 registry = CHARSET_REGISTRY (cs);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
849
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
850 new_charset = make_charset (id, new_name, dimension + 2, type, columns,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
851 graphic, final, direction, short_name, long_name,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
852 doc_string, registry);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
853
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
854 CHARSET_REVERSE_DIRECTION_CHARSET (cs) = new_charset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
855 XCHARSET_REVERSE_DIRECTION_CHARSET (new_charset) = charset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
856
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
857 return new_charset;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
858 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
859
284
558f606b08ae Import from CVS: tag r21-0b40
cvs
parents: 280
diff changeset
860 /* #### Reverse direction charsets not yet implemented. */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
861 #if 0
280
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 272
diff changeset
862 DEFUN ("charset-reverse-direction-charset", Fcharset_reverse_direction_charset,
7df0dd720c89 Import from CVS: tag r21-0b38
cvs
parents: 272
diff changeset
863 1, 1, 0, /*
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
864 Return the reverse-direction charset parallel to CHARSET, if any.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
865 This is the charset with the same properties (in particular, the same
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
866 dimension, number of characters per dimension, and final byte) as
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
867 CHARSET but whose characters are displayed in the opposite direction.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
868 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
869 (charset))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
870 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
871 charset = Fget_charset (charset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
872 return XCHARSET_REVERSE_DIRECTION_CHARSET (charset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
873 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
874 #endif
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
875
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
876 DEFUN ("charset-from-attributes", Fcharset_from_attributes, 3, 4, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
877 Return a charset with the given DIMENSION, CHARS, FINAL, and DIRECTION.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
878 If DIRECTION is omitted, both directions will be checked (left-to-right
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
879 will be returned if character sets exist for both directions).
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
880 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
881 (dimension, chars, final, direction))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
882 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
883 int dm, ch, fi, di = -1;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
884 int type;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
885 Lisp_Object obj = Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
886
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
887 CHECK_INT (dimension);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
888 dm = XINT (dimension);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
889 if (dm < 1 || dm > 2)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
890 signal_simple_error ("Invalid value for DIMENSION", dimension);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
891
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
892 CHECK_INT (chars);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
893 ch = XINT (chars);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
894 if (ch != 94 && ch != 96)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
895 signal_simple_error ("Invalid value for CHARS", chars);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
896
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
897 CHECK_CHAR_COERCE_INT (final);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
898 fi = XCHAR (final);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
899 if (fi < '0' || fi > '~')
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
900 signal_simple_error ("Invalid value for FINAL", final);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
901
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
902 if (EQ (direction, Ql2r))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
903 di = CHARSET_LEFT_TO_RIGHT;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
904 else if (EQ (direction, Qr2l))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
905 di = CHARSET_RIGHT_TO_LEFT;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
906 else if (!NILP (direction))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
907 signal_simple_error ("Invalid value for DIRECTION", direction);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
908
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
909 if (dm == 2 && fi > 0x5F)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
910 signal_simple_error
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
911 ("Final must be in the range 0x30 - 0x5F for dimension == 2", final);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
912
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
913 if (dm == 1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
914 type = (ch == 94) ? CHARSET_TYPE_94 : CHARSET_TYPE_96;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
915 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
916 type = (ch == 94) ? CHARSET_TYPE_94X94 : CHARSET_TYPE_96X96;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
917
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
918 if (di == -1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
919 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
920 obj = CHARSET_BY_ATTRIBUTES (type, fi, CHARSET_LEFT_TO_RIGHT);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
921 if (NILP (obj))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
922 obj = CHARSET_BY_ATTRIBUTES (type, fi, CHARSET_RIGHT_TO_LEFT);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
923 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
924 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
925 obj = CHARSET_BY_ATTRIBUTES (type, fi, di);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
926
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
927 if (CHARSETP (obj))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
928 return XCHARSET_NAME (obj);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
929 return obj;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
930 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
931
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
932 DEFUN ("charset-short-name", Fcharset_short_name, 1, 1, 0, /*
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
933 Return short name of CHARSET.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
934 */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
935 (charset))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
936 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
937 return XCHARSET_SHORT_NAME (Fget_charset (charset));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
938 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
939
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
940 DEFUN ("charset-long-name", Fcharset_long_name, 1, 1, 0, /*
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
941 Return long name of CHARSET.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
942 */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
943 (charset))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
944 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
945 return XCHARSET_LONG_NAME (Fget_charset (charset));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
946 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
947
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
948 DEFUN ("charset-description", Fcharset_description, 1, 1, 0, /*
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
949 Return description of CHARSET.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
950 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
951 (charset))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
952 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
953 return XCHARSET_DOC_STRING (Fget_charset (charset));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
954 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
955
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
956 DEFUN ("charset-dimension", Fcharset_dimension, 1, 1, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
957 Return dimension of CHARSET.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
958 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
959 (charset))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
960 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
961 return make_int (XCHARSET_DIMENSION (Fget_charset (charset)));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
962 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
963
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
964 DEFUN ("charset-property", Fcharset_property, 2, 2, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
965 Return property PROP of CHARSET.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
966 Recognized properties are those listed in `make-charset', as well as
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
967 'name and 'doc-string.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
968 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
969 (charset, prop))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
970 {
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
971 struct Lisp_Charset *cs;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
972
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
973 charset = Fget_charset (charset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
974 cs = XCHARSET (charset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
975
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
976 CHECK_SYMBOL (prop);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
977 if (EQ (prop, Qname)) return CHARSET_NAME (cs);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
978 if (EQ (prop, Qshort_name)) return CHARSET_SHORT_NAME (cs);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
979 if (EQ (prop, Qlong_name)) return CHARSET_LONG_NAME (cs);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
980 if (EQ (prop, Qdoc_string)) return CHARSET_DOC_STRING (cs);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
981 if (EQ (prop, Qdimension)) return make_int (CHARSET_DIMENSION (cs));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
982 if (EQ (prop, Qcolumns)) return make_int (CHARSET_COLUMNS (cs));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
983 if (EQ (prop, Qgraphic)) return make_int (CHARSET_GRAPHIC (cs));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
984 if (EQ (prop, Qfinal)) return make_char (CHARSET_FINAL (cs));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
985 if (EQ (prop, Qchars)) return make_int (CHARSET_CHARS (cs));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
986 if (EQ (prop, Qregistry)) return CHARSET_REGISTRY (cs);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
987 if (EQ (prop, Qccl_program)) return CHARSET_CCL_PROGRAM (cs);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
988 if (EQ (prop, Qdirection))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 241
diff changeset
989 return CHARSET_DIRECTION (cs) == CHARSET_LEFT_TO_RIGHT ? Ql2r : Qr2l;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
990 if (EQ (prop, Qreverse_direction_charset))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
991 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
992 Lisp_Object obj = CHARSET_REVERSE_DIRECTION_CHARSET (cs);
371
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 367
diff changeset
993 if (NILP (obj))
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 367
diff changeset
994 return Qnil;
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 367
diff changeset
995 else
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 367
diff changeset
996 return XCHARSET_NAME (obj);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
997 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
998 signal_simple_error ("Unrecognized charset property name", prop);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
999 return Qnil; /* not reached */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1000 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1001
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1002 DEFUN ("charset-id", Fcharset_id, 1, 1, 0, /*
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1003 Return charset identification number of CHARSET.
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1004 */
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1005 (charset))
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1006 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1007 return make_int(XCHARSET_LEADING_BYTE (Fget_charset (charset)));
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1008 }
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1009
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1010 /* #### We need to figure out which properties we really want to
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1011 allow to be set. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1012
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1013 DEFUN ("set-charset-ccl-program", Fset_charset_ccl_program, 2, 2, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1014 Set the 'ccl-program property of CHARSET to CCL-PROGRAM.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1015 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1016 (charset, ccl_program))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1017 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1018 charset = Fget_charset (charset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1019 CHECK_VECTOR (ccl_program);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1020 XCHARSET_CCL_PROGRAM (charset) = ccl_program;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1021 return Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1022 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1023
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1024 static void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1025 invalidate_charset_font_caches (Lisp_Object charset)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1026 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1027 /* Invalidate font cache entries for charset on all devices. */
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1028 Lisp_Object devcons, concons, hash_table;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1029 DEVICE_LOOP_NO_BREAK (devcons, concons)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1030 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1031 struct device *d = XDEVICE (XCAR (devcons));
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1032 hash_table = Fgethash (charset, d->charset_font_cache, Qunbound);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1033 if (!UNBOUNDP (hash_table))
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1034 Fclrhash (hash_table);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1035 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1036 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1037
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1038 /* Japanese folks may want to (set-charset-registry 'ascii "jisx0201") */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1039 DEFUN ("set-charset-registry", Fset_charset_registry, 2, 2, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1040 Set the 'registry property of CHARSET to REGISTRY.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1041 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1042 (charset, registry))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1043 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1044 charset = Fget_charset (charset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1045 CHECK_STRING (registry);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1046 XCHARSET_REGISTRY (charset) = registry;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1047 invalidate_charset_font_caches (charset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1048 face_property_was_changed (Vdefault_face, Qfont, Qglobal);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1049 return Qnil;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1050 }
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
1051
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1052
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1053 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1054 /* Lisp primitives for working with characters */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1055 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1056
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1057 DEFUN ("make-char", Fmake_char, 2, 3, 0, /*
416
ebe98a74bd68 Import from CVS: tag r21-2-16
cvs
parents: 414
diff changeset
1058 Make a character from CHARSET and octets ARG1 and ARG2.
ebe98a74bd68 Import from CVS: tag r21-2-16
cvs
parents: 414
diff changeset
1059 ARG2 is required only for characters from two-dimensional charsets.
ebe98a74bd68 Import from CVS: tag r21-2-16
cvs
parents: 414
diff changeset
1060 For example, (make-char 'latin-iso8859-2 185) will return the Latin 2
ebe98a74bd68 Import from CVS: tag r21-2-16
cvs
parents: 414
diff changeset
1061 character s with caron.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1062 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1063 (charset, arg1, arg2))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1064 {
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
1065 struct Lisp_Charset *cs;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1066 int a1, a2;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1067 int lowlim, highlim;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1068
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1069 charset = Fget_charset (charset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1070 cs = XCHARSET (charset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1071
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1072 if (EQ (charset, Vcharset_ascii)) lowlim = 0, highlim = 127;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1073 else if (EQ (charset, Vcharset_control_1)) lowlim = 0, highlim = 31;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1074 else if (CHARSET_CHARS (cs) == 94) lowlim = 33, highlim = 126;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1075 else /* CHARSET_CHARS (cs) == 96) */ lowlim = 32, highlim = 127;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1076
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1077 CHECK_INT (arg1);
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
1078 /* It is useful (and safe, according to Olivier Galibert) to strip
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
1079 the 8th bit off ARG1 and ARG2 becaue it allows programmers to
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
1080 write (make-char 'latin-iso8859-2 CODE) where code is the actual
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
1081 Latin 2 code of the character. */
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
1082 a1 = XINT (arg1) & 0x7f;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1083 if (a1 < lowlim || a1 > highlim)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1084 args_out_of_range_3 (arg1, make_int (lowlim), make_int (highlim));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1085
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1086 if (CHARSET_DIMENSION (cs) == 1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1087 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1088 if (!NILP (arg2))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1089 signal_simple_error
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1090 ("Charset is of dimension one; second octet must be nil", arg2);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1091 return make_char (MAKE_CHAR (charset, a1, 0));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1092 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1093
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1094 CHECK_INT (arg2);
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
1095 a2 = XINT (arg2) & 0x7f;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1096 if (a2 < lowlim || a2 > highlim)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1097 args_out_of_range_3 (arg2, make_int (lowlim), make_int (highlim));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1098
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1099 return make_char (MAKE_CHAR (charset, a1, a2));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1100 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1101
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1102 DEFUN ("char-charset", Fchar_charset, 1, 1, 0, /*
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1103 Return the character set of char CH.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1104 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1105 (ch))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1106 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1107 CHECK_CHAR_COERCE_INT (ch);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1108
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1109 return XCHARSET_NAME (CHARSET_BY_LEADING_BYTE
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1110 (CHAR_LEADING_BYTE (XCHAR (ch))));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1111 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1112
418
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1113 DEFUN ("split-char", Fsplit_char, 1, 1, 0, /*
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1114 Return list of charset and one or two position-codes of CHAR.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1115 */
418
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1116 (character))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1117 {
418
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1118 /* This function can GC */
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1119 struct gcpro gcpro1, gcpro2;
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1120 Lisp_Object charset = Qnil;
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1121 Lisp_Object rc = Qnil;
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1122 int c1, c2;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1123
418
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1124 GCPRO2 (charset, rc);
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1125 CHECK_CHAR_COERCE_INT (character);
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1126
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1127 BREAKUP_CHAR (XCHAR (character), charset, c1, c2);
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1128
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1129 if (XCHARSET_DIMENSION (Fget_charset (charset)) == 2)
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1130 {
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1131 rc = list3 (XCHARSET_NAME (charset), make_int (c1), make_int (c2));
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1132 }
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1133 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1134 {
418
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1135 rc = list2 (XCHARSET_NAME (charset), make_int (c1));
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1136 }
418
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1137 UNGCPRO;
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1138
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1139 return rc;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1140 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1141
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1142
396
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 392
diff changeset
1143 #ifdef ENABLE_COMPOSITE_CHARS
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1144 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1145 /* composite character functions */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1146 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1147
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1148 Emchar
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1149 lookup_composite_char (Bufbyte *str, int len)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1150 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1151 Lisp_Object lispstr = make_string (str, len);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1152 Lisp_Object ch = Fgethash (lispstr,
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1153 Vcomposite_char_string2char_hash_table,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1154 Qunbound);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1155 Emchar emch;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1156
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1157 if (UNBOUNDP (ch))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1158 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1159 if (composite_char_row_next >= 128)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1160 signal_simple_error ("No more composite chars available", lispstr);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1161 emch = MAKE_CHAR (Vcharset_composite, composite_char_row_next,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1162 composite_char_col_next);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1163 Fputhash (make_char (emch), lispstr,
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1164 Vcomposite_char_char2string_hash_table);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1165 Fputhash (lispstr, make_char (emch),
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1166 Vcomposite_char_string2char_hash_table);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1167 composite_char_col_next++;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1168 if (composite_char_col_next >= 128)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1169 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1170 composite_char_col_next = 32;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1171 composite_char_row_next++;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1172 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1173 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1174 else
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1175 emch = XCHAR (ch);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1176 return emch;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1177 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1178
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1179 Lisp_Object
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1180 composite_char_string (Emchar ch)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1181 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1182 Lisp_Object str = Fgethash (make_char (ch),
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1183 Vcomposite_char_char2string_hash_table,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1184 Qunbound);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1185 assert (!UNBOUNDP (str));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1186 return str;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1187 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1188
396
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 392
diff changeset
1189 xxDEFUN ("make-composite-char", Fmake_composite_char, 1, 1, 0, /*
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1190 Convert a string into a single composite character.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1191 The character is the result of overstriking all the characters in
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1192 the string.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1193 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1194 (string))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1195 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1196 CHECK_STRING (string);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1197 return make_char (lookup_composite_char (XSTRING_DATA (string),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1198 XSTRING_LENGTH (string)));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1199 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1200
396
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 392
diff changeset
1201 xxDEFUN ("composite-char-string", Fcomposite_char_string, 1, 1, 0, /*
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1202 Return a string of the characters comprising a composite character.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1203 */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1204 (ch))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1205 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1206 Emchar emch;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1207
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1208 CHECK_CHAR (ch);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1209 emch = XCHAR (ch);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1210 if (CHAR_LEADING_BYTE (emch) != LEADING_BYTE_COMPOSITE)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1211 signal_simple_error ("Must be composite char", ch);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1212 return composite_char_string (emch);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1213 }
396
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 392
diff changeset
1214 #endif /* ENABLE_COMPOSITE_CHARS */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1215
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1216
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1217 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1218 /* initialization */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1219 /************************************************************************/
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1220
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1221 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1222 syms_of_mule_charset (void)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1223 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1224 DEFSUBR (Fcharsetp);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1225 DEFSUBR (Ffind_charset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1226 DEFSUBR (Fget_charset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1227 DEFSUBR (Fcharset_list);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1228 DEFSUBR (Fcharset_name);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1229 DEFSUBR (Fmake_charset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1230 DEFSUBR (Fmake_reverse_direction_charset);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1231 /* DEFSUBR (Freverse_direction_charset); */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1232 DEFSUBR (Fcharset_from_attributes);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1233 DEFSUBR (Fcharset_short_name);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1234 DEFSUBR (Fcharset_long_name);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1235 DEFSUBR (Fcharset_description);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1236 DEFSUBR (Fcharset_dimension);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1237 DEFSUBR (Fcharset_property);
213
78f53ef88e17 Import from CVS: tag r20-4b5
cvs
parents: 185
diff changeset
1238 DEFSUBR (Fcharset_id);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1239 DEFSUBR (Fset_charset_ccl_program);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1240 DEFSUBR (Fset_charset_registry);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1241
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1242 DEFSUBR (Fmake_char);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1243 DEFSUBR (Fchar_charset);
418
e804706bfb8c Import from CVS: tag r21-2-17
cvs
parents: 416
diff changeset
1244 DEFSUBR (Fsplit_char);
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1245
396
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 392
diff changeset
1246 #ifdef ENABLE_COMPOSITE_CHARS
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1247 DEFSUBR (Fmake_composite_char);
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1248 DEFSUBR (Fcomposite_char_string);
396
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 392
diff changeset
1249 #endif
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1250
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1251 defsymbol (&Qcharsetp, "charsetp");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1252 defsymbol (&Qregistry, "registry");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1253 defsymbol (&Qfinal, "final");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1254 defsymbol (&Qgraphic, "graphic");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1255 defsymbol (&Qdirection, "direction");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1256 defsymbol (&Qreverse_direction_charset, "reverse-direction-charset");
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
1257 defsymbol (&Qccl_program, "ccl-program");
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1258 defsymbol (&Qshort_name, "short-name");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1259 defsymbol (&Qlong_name, "long-name");
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1260
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1261 defsymbol (&Ql2r, "l2r");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1262 defsymbol (&Qr2l, "r2l");
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1263
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1264 /* Charsets, compatible with FSF 20.3
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1265 Naming convention is Script-Charset[-Edition] */
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1266 defsymbol (&Qascii, "ascii");
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1267 defsymbol (&Qcontrol_1, "control-1");
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1268 defsymbol (&Qlatin_iso8859_1, "latin-iso8859-1");
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1269 defsymbol (&Qlatin_iso8859_2, "latin-iso8859-2");
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1270 defsymbol (&Qlatin_iso8859_3, "latin-iso8859-3");
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1271 defsymbol (&Qlatin_iso8859_4, "latin-iso8859-4");
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1272 defsymbol (&Qthai_tis620, "thai-tis620");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1273 defsymbol (&Qgreek_iso8859_7, "greek-iso8859-7");
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1274 defsymbol (&Qarabic_iso8859_6, "arabic-iso8859-6");
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1275 defsymbol (&Qhebrew_iso8859_8, "hebrew-iso8859-8");
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1276 defsymbol (&Qkatakana_jisx0201, "katakana-jisx0201");
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1277 defsymbol (&Qlatin_jisx0201, "latin-jisx0201");
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1278 defsymbol (&Qcyrillic_iso8859_5, "cyrillic-iso8859-5");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1279 defsymbol (&Qlatin_iso8859_9, "latin-iso8859-9");
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1280 defsymbol (&Qjapanese_jisx0208_1978, "japanese-jisx0208-1978");
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1281 defsymbol (&Qchinese_gb2312, "chinese-gb2312");
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1282 defsymbol (&Qjapanese_jisx0208, "japanese-jisx0208");
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1283 defsymbol (&Qkorean_ksc5601, "korean-ksc5601");
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1284 defsymbol (&Qjapanese_jisx0212, "japanese-jisx0212");
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1285 defsymbol (&Qchinese_cns11643_1, "chinese-cns11643-1");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1286 defsymbol (&Qchinese_cns11643_2, "chinese-cns11643-2");
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1287 defsymbol (&Qchinese_big5_1, "chinese-big5-1");
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1288 defsymbol (&Qchinese_big5_2, "chinese-big5-2");
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
1289
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1290 defsymbol (&Qcomposite, "composite");
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1291 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1292
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1293 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1294 vars_of_mule_charset (void)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1295 {
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1296 int i, j, k;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1297
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
1298 /* Table of charsets indexed by leading byte. */
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
1299 for (i = 0; i < countof (charset_by_leading_byte); i++)
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
1300 charset_by_leading_byte[i] = Qnil;
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
1301
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
1302 /* Table of charsets indexed by type/final-byte/direction. */
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
1303 for (i = 0; i < countof (charset_by_attributes); i++)
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
1304 for (j = 0; j < countof (charset_by_attributes[0]); j++)
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
1305 for (k = 0; k < countof (charset_by_attributes[0][0]); k++)
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
1306 charset_by_attributes[i][j][k] = Qnil;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1307
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
1308 next_allocated_1_byte_leading_byte = MIN_LEADING_BYTE_PRIVATE_1;
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 406
diff changeset
1309 next_allocated_2_byte_leading_byte = MIN_LEADING_BYTE_PRIVATE_2;
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1310 }
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1311
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1312 void
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1313 complex_vars_of_mule_charset (void)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1314 {
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1315 staticpro (&Vcharset_hash_table);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1316 Vcharset_hash_table =
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1317 make_lisp_hash_table (50, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
183
e121b013d1f0 Import from CVS: tag r20-3b18
cvs
parents: 167
diff changeset
1318
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1319 /* Predefined character sets. We store them into variables for
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1320 ease of access. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1321
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1322 Vcharset_ascii =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1323 make_charset (LEADING_BYTE_ASCII, Qascii, 1,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1324 CHARSET_TYPE_94, 1, 0, 'B',
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1325 CHARSET_LEFT_TO_RIGHT,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1326 build_string ("ASCII"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1327 build_string ("ASCII)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1328 build_string ("ASCII (ISO646 IRV)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1329 build_string ("\\(iso8859-[0-9]*\\|-ascii\\)"));
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1330 Vcharset_control_1 =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1331 make_charset (LEADING_BYTE_CONTROL_1, Qcontrol_1, 2,
377
d883f39b8495 Import from CVS: tag r21-2b4
cvs
parents: 371
diff changeset
1332 CHARSET_TYPE_94, 1, 1, 0,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1333 CHARSET_LEFT_TO_RIGHT,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1334 build_string ("C1"),
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1335 build_string ("Control characters"),
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1336 build_string ("Control characters 128-191"),
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1337 build_string (""));
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1338 Vcharset_latin_iso8859_1 =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1339 make_charset (LEADING_BYTE_LATIN_ISO8859_1, Qlatin_iso8859_1, 2,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1340 CHARSET_TYPE_96, 1, 1, 'A',
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1341 CHARSET_LEFT_TO_RIGHT,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1342 build_string ("Latin-1"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1343 build_string ("ISO8859-1 (Latin-1)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1344 build_string ("ISO8859-1 (Latin-1)"),
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 74
diff changeset
1345 build_string ("iso8859-1"));
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1346 Vcharset_latin_iso8859_2 =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1347 make_charset (LEADING_BYTE_LATIN_ISO8859_2, Qlatin_iso8859_2, 2,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1348 CHARSET_TYPE_96, 1, 1, 'B',
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1349 CHARSET_LEFT_TO_RIGHT,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1350 build_string ("Latin-2"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1351 build_string ("ISO8859-2 (Latin-2)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1352 build_string ("ISO8859-2 (Latin-2)"),
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 74
diff changeset
1353 build_string ("iso8859-2"));
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1354 Vcharset_latin_iso8859_3 =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1355 make_charset (LEADING_BYTE_LATIN_ISO8859_3, Qlatin_iso8859_3, 2,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1356 CHARSET_TYPE_96, 1, 1, 'C',
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1357 CHARSET_LEFT_TO_RIGHT,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1358 build_string ("Latin-3"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1359 build_string ("ISO8859-3 (Latin-3)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1360 build_string ("ISO8859-3 (Latin-3)"),
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 74
diff changeset
1361 build_string ("iso8859-3"));
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1362 Vcharset_latin_iso8859_4 =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1363 make_charset (LEADING_BYTE_LATIN_ISO8859_4, Qlatin_iso8859_4, 2,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1364 CHARSET_TYPE_96, 1, 1, 'D',
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1365 CHARSET_LEFT_TO_RIGHT,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1366 build_string ("Latin-4"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1367 build_string ("ISO8859-4 (Latin-4)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1368 build_string ("ISO8859-4 (Latin-4)"),
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 74
diff changeset
1369 build_string ("iso8859-4"));
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1370 Vcharset_thai_tis620 =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1371 make_charset (LEADING_BYTE_THAI_TIS620, Qthai_tis620, 2,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1372 CHARSET_TYPE_96, 1, 1, 'T',
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1373 CHARSET_LEFT_TO_RIGHT,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1374 build_string ("TIS620"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1375 build_string ("TIS620 (Thai)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1376 build_string ("TIS620.2529 (Thai)"),
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 74
diff changeset
1377 build_string ("tis620"));
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1378 Vcharset_greek_iso8859_7 =
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1379 make_charset (LEADING_BYTE_GREEK_ISO8859_7, Qgreek_iso8859_7, 2,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1380 CHARSET_TYPE_96, 1, 1, 'F',
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1381 CHARSET_LEFT_TO_RIGHT,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1382 build_string ("ISO8859-7"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1383 build_string ("ISO8859-7 (Greek)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1384 build_string ("ISO8859-7 (Greek)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1385 build_string ("iso8859-7"));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1386 Vcharset_arabic_iso8859_6 =
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1387 make_charset (LEADING_BYTE_ARABIC_ISO8859_6, Qarabic_iso8859_6, 2,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1388 CHARSET_TYPE_96, 1, 1, 'G',
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1389 CHARSET_RIGHT_TO_LEFT,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1390 build_string ("ISO8859-6"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1391 build_string ("ISO8859-6 (Arabic)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1392 build_string ("ISO8859-6 (Arabic)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1393 build_string ("iso8859-6"));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1394 Vcharset_hebrew_iso8859_8 =
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1395 make_charset (LEADING_BYTE_HEBREW_ISO8859_8, Qhebrew_iso8859_8, 2,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1396 CHARSET_TYPE_96, 1, 1, 'H',
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1397 CHARSET_RIGHT_TO_LEFT,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1398 build_string ("ISO8859-8"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1399 build_string ("ISO8859-8 (Hebrew)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1400 build_string ("ISO8859-8 (Hebrew)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1401 build_string ("iso8859-8"));
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1402 Vcharset_katakana_jisx0201 =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1403 make_charset (LEADING_BYTE_KATAKANA_JISX0201, Qkatakana_jisx0201, 2,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1404 CHARSET_TYPE_94, 1, 1, 'I',
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1405 CHARSET_LEFT_TO_RIGHT,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1406 build_string ("JISX0201 Kana"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1407 build_string ("JISX0201.1976 (Japanese Kana)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1408 build_string ("JISX0201.1976 Japanese Kana"),
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 74
diff changeset
1409 build_string ("jisx0201.1976"));
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1410 Vcharset_latin_jisx0201 =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1411 make_charset (LEADING_BYTE_LATIN_JISX0201, Qlatin_jisx0201, 2,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1412 CHARSET_TYPE_94, 1, 0, 'J',
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1413 CHARSET_LEFT_TO_RIGHT,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1414 build_string ("JISX0201 Roman"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1415 build_string ("JISX0201.1976 (Japanese Roman)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1416 build_string ("JISX0201.1976 Japanese Roman"),
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 74
diff changeset
1417 build_string ("jisx0201.1976"));
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1418 Vcharset_cyrillic_iso8859_5 =
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1419 make_charset (LEADING_BYTE_CYRILLIC_ISO8859_5, Qcyrillic_iso8859_5, 2,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1420 CHARSET_TYPE_96, 1, 1, 'L',
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1421 CHARSET_LEFT_TO_RIGHT,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1422 build_string ("ISO8859-5"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1423 build_string ("ISO8859-5 (Cyrillic)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1424 build_string ("ISO8859-5 (Cyrillic)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1425 build_string ("iso8859-5"));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1426 Vcharset_latin_iso8859_9 =
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1427 make_charset (LEADING_BYTE_LATIN_ISO8859_9, Qlatin_iso8859_9, 2,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1428 CHARSET_TYPE_96, 1, 1, 'M',
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1429 CHARSET_LEFT_TO_RIGHT,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1430 build_string ("Latin-5"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1431 build_string ("ISO8859-9 (Latin-5)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1432 build_string ("ISO8859-9 (Latin-5)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1433 build_string ("iso8859-9"));
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1434 Vcharset_japanese_jisx0208_1978 =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1435 make_charset (LEADING_BYTE_JAPANESE_JISX0208_1978, Qjapanese_jisx0208_1978, 3,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1436 CHARSET_TYPE_94X94, 2, 0, '@',
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1437 CHARSET_LEFT_TO_RIGHT,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1438 build_string ("JISX0208.1978"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1439 build_string ("JISX0208.1978 (Japanese)"),
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 78
diff changeset
1440 build_string
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1441 ("JISX0208.1978 Japanese Kanji (so called \"old JIS\")"),
414
da8ed4261e83 Import from CVS: tag r21-2-15
cvs
parents: 412
diff changeset
1442 build_string ("\\(jisx0208\\|jisc6226\\)\\.1978"));
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1443 Vcharset_chinese_gb2312 =
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1444 make_charset (LEADING_BYTE_CHINESE_GB2312, Qchinese_gb2312, 3,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1445 CHARSET_TYPE_94X94, 2, 0, 'A',
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1446 CHARSET_LEFT_TO_RIGHT,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1447 build_string ("GB2312"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1448 build_string ("GB2312)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1449 build_string ("GB2312 Chinese simplified"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1450 build_string ("gb2312"));
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1451 Vcharset_japanese_jisx0208 =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1452 make_charset (LEADING_BYTE_JAPANESE_JISX0208, Qjapanese_jisx0208, 3,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1453 CHARSET_TYPE_94X94, 2, 0, 'B',
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1454 CHARSET_LEFT_TO_RIGHT,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1455 build_string ("JISX0208"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1456 build_string ("JISX0208.1983/1990 (Japanese)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1457 build_string ("JISX0208.1983/1990 Japanese Kanji"),
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 74
diff changeset
1458 build_string ("jisx0208.19\\(83\\|90\\)"));
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1459 Vcharset_korean_ksc5601 =
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1460 make_charset (LEADING_BYTE_KOREAN_KSC5601, Qkorean_ksc5601, 3,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1461 CHARSET_TYPE_94X94, 2, 0, 'C',
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1462 CHARSET_LEFT_TO_RIGHT,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1463 build_string ("KSC5601"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1464 build_string ("KSC5601 (Korean"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1465 build_string ("KSC5601 Korean Hangul and Hanja"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1466 build_string ("ksc5601"));
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1467 Vcharset_japanese_jisx0212 =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1468 make_charset (LEADING_BYTE_JAPANESE_JISX0212, Qjapanese_jisx0212, 3,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1469 CHARSET_TYPE_94X94, 2, 0, 'D',
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1470 CHARSET_LEFT_TO_RIGHT,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1471 build_string ("JISX0212"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1472 build_string ("JISX0212 (Japanese)"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1473 build_string ("JISX0212 Japanese Supplement"),
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 74
diff changeset
1474 build_string ("jisx0212"));
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1475
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 74
diff changeset
1476 #define CHINESE_CNS_PLANE_RE(n) "cns11643[.-]\\(.*[.-]\\)?" n "$"
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1477 Vcharset_chinese_cns11643_1 =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1478 make_charset (LEADING_BYTE_CHINESE_CNS11643_1, Qchinese_cns11643_1, 3,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1479 CHARSET_TYPE_94X94, 2, 0, 'G',
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1480 CHARSET_LEFT_TO_RIGHT,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1481 build_string ("CNS11643-1"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1482 build_string ("CNS11643-1 (Chinese traditional)"),
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 78
diff changeset
1483 build_string
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1484 ("CNS 11643 Plane 1 Chinese traditional"),
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1485 build_string (CHINESE_CNS_PLANE_RE("1")));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1486 Vcharset_chinese_cns11643_2 =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1487 make_charset (LEADING_BYTE_CHINESE_CNS11643_2, Qchinese_cns11643_2, 3,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1488 CHARSET_TYPE_94X94, 2, 0, 'H',
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1489 CHARSET_LEFT_TO_RIGHT,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1490 build_string ("CNS11643-2"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1491 build_string ("CNS11643-2 (Chinese traditional)"),
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 78
diff changeset
1492 build_string
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1493 ("CNS 11643 Plane 2 Chinese traditional"),
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1494 build_string (CHINESE_CNS_PLANE_RE("2")));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1495 Vcharset_chinese_big5_1 =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1496 make_charset (LEADING_BYTE_CHINESE_BIG5_1, Qchinese_big5_1, 3,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1497 CHARSET_TYPE_94X94, 2, 0, '0',
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1498 CHARSET_LEFT_TO_RIGHT,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1499 build_string ("Big5"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1500 build_string ("Big5 (Level-1)"),
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 78
diff changeset
1501 build_string
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1502 ("Big5 Level-1 Chinese traditional"),
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 74
diff changeset
1503 build_string ("big5"));
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1504 Vcharset_chinese_big5_2 =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1505 make_charset (LEADING_BYTE_CHINESE_BIG5_2, Qchinese_big5_2, 3,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1506 CHARSET_TYPE_94X94, 2, 0, '1',
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1507 CHARSET_LEFT_TO_RIGHT,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1508 build_string ("Big5"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1509 build_string ("Big5 (Level-2)"),
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents: 78
diff changeset
1510 build_string
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1511 ("Big5 Level-2 Chinese traditional"),
78
c7528f8e288d Import from CVS: tag r20-0b34
cvs
parents: 74
diff changeset
1512 build_string ("big5"));
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1513
396
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 392
diff changeset
1514
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 392
diff changeset
1515 #ifdef ENABLE_COMPOSITE_CHARS
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1516 /* #### For simplicity, we put composite chars into a 96x96 charset.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1517 This is going to lead to problems because you can run out of
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1518 room, esp. as we don't yet recycle numbers. */
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1519 Vcharset_composite =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1520 make_charset (LEADING_BYTE_COMPOSITE, Qcomposite, 3,
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1521 CHARSET_TYPE_96X96, 2, 0, 0,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1522 CHARSET_LEFT_TO_RIGHT,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1523 build_string ("Composite"),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 396
diff changeset
1524 build_string ("Composite characters"),
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1525 build_string ("Composite characters"),
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1526 build_string (""));
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1527
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1528 composite_char_row_next = 32;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1529 composite_char_col_next = 32;
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1530
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1531 Vcomposite_char_string2char_hash_table =
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1532 make_lisp_hash_table (500, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1533 Vcomposite_char_char2string_hash_table =
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1534 make_lisp_hash_table (500, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1535 staticpro (&Vcomposite_char_string2char_hash_table);
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
1536 staticpro (&Vcomposite_char_char2string_hash_table);
396
6719134a07c2 Import from CVS: tag r21-2-13
cvs
parents: 392
diff changeset
1537 #endif /* ENABLE_COMPOSITE_CHARS */
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1538
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents:
diff changeset
1539 }