annotate src/mule-charset.c @ 392:1f50e6fe4f3f r21-2-11

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