Mercurial > emacs
annotate src/charset.h @ 24127:250719d2b13b
Initial revision
author | Dave Love <fx@gnu.org> |
---|---|
date | Tue, 19 Jan 1999 19:58:31 +0000 |
parents | 16d0232006fb |
children | d9d0dd9ebcb5 |
rev | line source |
---|---|
17052 | 1 /* Header for multilingual character handler. |
20708 | 2 Copyright (C) 1995, 1997, 1998 Electrotechnical Laboratory, JAPAN. |
18341
33e78cc7f058
Change copyright notices.
Richard M. Stallman <rms@gnu.org>
parents:
17833
diff
changeset
|
3 Licensed to the Free Software Foundation. |
17052 | 4 |
17071 | 5 This file is part of GNU Emacs. |
6 | |
7 GNU Emacs is free software; you can redistribute it and/or modify | |
8 it under the terms of the GNU General Public License as published by | |
9 the Free Software Foundation; either version 2, or (at your option) | |
10 any later version. | |
17052 | 11 |
17071 | 12 GNU Emacs is distributed in the hope that it will be useful, |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
17052 | 16 |
17071 | 17 You should have received a copy of the GNU General Public License |
18 along with GNU Emacs; see the file COPYING. If not, write to | |
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
20 Boston, MA 02111-1307, USA. */ | |
17052 | 21 |
22 #ifndef _CHARSET_H | |
23 #define _CHARSET_H | |
24 | |
25 /*** GENERAL NOTE on CHARACTER SET (CHARSET) *** | |
26 | |
27 A character set ("charset" hereafter) is a meaningful collection | |
28 (i.e. language, culture, functionality, etc) of characters. Emacs | |
29 handles multiple charsets at once. Each charset corresponds to one | |
30 of ISO charsets (except for a special charset for composition | |
31 characters). Emacs identifies a charset by a unique identification | |
32 number, whereas ISO identifies a charset by a triplet of DIMENSION, | |
33 CHARS and FINAL-CHAR. So, hereafter, just saying "charset" means an | |
34 identification number (integer value). | |
35 | |
36 The value range of charset is 0x00, 0x80..0xFE. There are four | |
37 kinds of charset depending on DIMENSION (1 or 2) and CHARS (94 or | |
38 96). For instance, a charset of DIMENSION2_CHARS94 contains 94x94 | |
39 | |
40 | |
41 Within Emacs Lisp, a charset is treated as a symbol which has a | |
42 property `charset'. The property value is a vector containing | |
43 various information about the charset. For readability of C codes, | |
44 we use the following convention on C variable names: | |
45 charset_symbol: Emacs Lisp symbol of a charset | |
46 charset_id: Emacs Lisp integer of an identification number of a charset | |
47 charset: C integer of an identification number of a charset | |
48 | |
49 Each charset (except for ASCII) is assigned a base leading-code | |
50 (range 0x80..0x9D). In addition, a charset of greater than 0xA0 | |
51 (whose base leading-code is 0x9A..0x9D) is assigned an extended | |
52 leading-code (range 0xA0..0xFE). In this case, each base | |
53 leading-code specify the allowable range of extended leading-code as | |
54 shown in the table below. A leading-code is used to represent a | |
55 character in Emacs' buffer and string. | |
56 | |
57 We call a charset which has extended leading-code as "private | |
58 charset" because those are mainly for a charset which is not | |
59 registered by ISO. On the contrary, we call a charset which does | |
60 not have extended leading-code as "official charset". | |
61 | |
62 --------------------------------------------------------------------------- | |
63 charset dimension base leading-code extended leading-code | |
64 --------------------------------------------------------------------------- | |
65 0x00 official dim1 -- none -- -- none -- | |
66 (ASCII) | |
67 0x01..0x7F --never used-- | |
68 0x80 COMPOSITION same as charset -- none -- | |
69 0x81..0x8F official dim1 same as charset -- none -- | |
70 0x90..0x99 official dim2 same as charset -- none -- | |
71 0x9A..0x9F --never used-- | |
72 0xA0..0xDF private dim1 0x9A same as charset | |
73 of 1-column width | |
74 0xE0..0xEF private dim1 0x9B same as charset | |
75 of 2-column width | |
76 0xF0..0xF4 private dim2 0x9C same as charset | |
77 of 1-column width | |
78 0xF5..0xFE private dim2 0x9D same as charset | |
79 of 2-column width | |
80 0xFF --never used-- | |
81 --------------------------------------------------------------------------- | |
82 | |
83 In the table, "COMPOSITION" means a charset for a composite | |
84 character which is a character composed from several (up to 16) | |
85 non-composite characters (components). Although a composite | |
86 character can contain components of many charsets, a composite | |
87 character itself belongs to the charset CHARSET-COMPOSITION. See | |
88 the document "GENERAL NOTE on COMPOSITE CHARACTER" below for more | |
89 detail. | |
90 | |
91 */ | |
92 | |
93 /* Definition of special leading-codes. */ | |
94 /* Base leading-code. */ | |
95 /* Special leading-code followed by components of a composite character. */ | |
96 #define LEADING_CODE_COMPOSITION 0x80 | |
97 /* Leading-code followed by extended leading-code. */ | |
98 #define LEADING_CODE_PRIVATE_11 0x9A /* for private DIMENSION1 of 1-column */ | |
99 #define LEADING_CODE_PRIVATE_12 0x9B /* for private DIMENSION1 of 2-column */ | |
100 #define LEADING_CODE_PRIVATE_21 0x9C /* for private DIMENSION2 of 1-column */ | |
19643
1defeafe575b
(LEADING_CODE_PRIVATE_22): Comment fixed.
Kenichi Handa <handa@m17n.org>
parents:
19319
diff
changeset
|
101 #define LEADING_CODE_PRIVATE_22 0x9D /* for private DIMENSION2 of 2-column */ |
17052 | 102 |
103 /* Extended leading-code. */ | |
104 /* Start of each extended leading-codes. */ | |
105 #define LEADING_CODE_EXT_11 0xA0 /* follows LEADING_CODE_PRIVATE_11 */ | |
106 #define LEADING_CODE_EXT_12 0xE0 /* follows LEADING_CODE_PRIVATE_12 */ | |
107 #define LEADING_CODE_EXT_21 0xF0 /* follows LEADING_CODE_PRIVATE_21 */ | |
108 #define LEADING_CODE_EXT_22 0xF5 /* follows LEADING_CODE_PRIVATE_22 */ | |
109 /* Maximum value of extended leading-codes. */ | |
110 #define LEADING_CODE_EXT_MAX 0xFE | |
111 | |
112 /* Definition of minimum/maximum charset of each DIMENSION. */ | |
113 #define MIN_CHARSET_OFFICIAL_DIMENSION1 0x81 | |
114 #define MAX_CHARSET_OFFICIAL_DIMENSION1 0x8F | |
115 #define MIN_CHARSET_OFFICIAL_DIMENSION2 0x90 | |
116 #define MAX_CHARSET_OFFICIAL_DIMENSION2 0x99 | |
117 #define MIN_CHARSET_PRIVATE_DIMENSION1 LEADING_CODE_EXT_11 | |
118 #define MIN_CHARSET_PRIVATE_DIMENSION2 LEADING_CODE_EXT_21 | |
119 | |
17185
0d5a1bae9d73
(MAX_CHARSET): Definition changed to the actual
Kenichi Handa <handa@m17n.org>
parents:
17120
diff
changeset
|
120 /* Maximum value of overall charset identification number. */ |
0d5a1bae9d73
(MAX_CHARSET): Definition changed to the actual
Kenichi Handa <handa@m17n.org>
parents:
17120
diff
changeset
|
121 #define MAX_CHARSET 0xFE |
0d5a1bae9d73
(MAX_CHARSET): Definition changed to the actual
Kenichi Handa <handa@m17n.org>
parents:
17120
diff
changeset
|
122 |
17052 | 123 /* Definition of special charsets. */ |
124 #define CHARSET_ASCII 0 | |
125 #define CHARSET_COMPOSITION 0x80 | |
126 | |
127 extern int charset_ascii; /* ASCII */ | |
128 extern int charset_composition; /* for a composite character */ | |
129 extern int charset_latin_iso8859_1; /* ISO8859-1 (Latin-1) */ | |
130 extern int charset_jisx0208_1978; /* JISX0208.1978 (Japanese Kanji old set) */ | |
131 extern int charset_jisx0208; /* JISX0208.1983 (Japanese Kanji) */ | |
132 extern int charset_katakana_jisx0201; /* JISX0201.Kana (Japanese Katakana) */ | |
133 extern int charset_latin_jisx0201; /* JISX0201.Roman (Japanese Roman) */ | |
134 extern int charset_big5_1; /* Big5 Level 1 (Chinese Traditional) */ | |
135 extern int charset_big5_2; /* Big5 Level 2 (Chinese Traditional) */ | |
136 | |
20531
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
137 /* Check if CH is the head of multi-byte form, i.e., |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
138 an ASCII character or a base leading-code. */ |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
139 #define CHAR_HEAD_P(ch) ((unsigned char) (ch) < 0xA0) |
17052 | 140 |
141 /*** GENERAL NOTE on CHARACTER REPRESENTATION *** | |
142 | |
143 At first, the term "character" or "char" is used for a multilingual | |
144 character (of course, including ASCII character), not for a byte in | |
145 computer memory. We use the term "code" or "byte" for the latter | |
146 case. | |
147 | |
148 A character is identified by charset and one or two POSITION-CODEs. | |
149 POSITION-CODE is the position of the character in the charset. A | |
150 character of DIMENSION1 charset has one POSITION-CODE: POSITION-CODE-1. | |
151 A character of DIMENSION2 charset has two POSITION-CODE: | |
152 POSITION-CODE-1 and POSITION-CODE-2. The code range of | |
153 POSITION-CODE is 0x20..0x7F. | |
154 | |
155 Emacs has two kinds of representation of a character: multi-byte | |
156 form (for buffer and string) and single-word form (for character | |
157 object in Emacs Lisp). The latter is called "character code" here | |
22529 | 158 after. Both representations encode the information of charset and |
17052 | 159 POSITION-CODE but in a different way (for instance, MSB of |
160 POSITION-CODE is set in multi-byte form). | |
161 | |
162 For details of multi-byte form, see the section "2. Emacs internal | |
163 format handlers" of `coding.c'. | |
164 | |
165 Emacs uses 19 bits for a character code. The bits are divided into | |
166 3 fields: FIELD1(5bits):FIELD2(7bits):FIELD3(7bits). | |
167 | |
168 A character code of DIMENSION1 character uses FIELD2 to hold charset | |
169 and FIELD3 to hold POSITION-CODE-1. A character code of DIMENSION2 | |
170 character uses FIELD1 to hold charset, FIELD2 and FIELD3 to hold | |
171 POSITION-CODE-1 and POSITION-CODE-2 respectively. | |
172 | |
173 More precisely... | |
174 | |
175 FIELD2 of DIMENSION1 character (except for ASCII) is "charset - 0x70". | |
176 This is to make all character codes except for ASCII greater than | |
177 256 (ASCII's FIELD2 is 0). So, the range of FIELD2 of DIMENSION1 | |
178 character is 0 or 0x11..0x7F. | |
179 | |
180 FIELD1 of DIMENSION2 character is "charset - 0x8F" for official | |
181 charset and "charset - 0xE0" for private charset. So, the range of | |
182 FIELD1 of DIMENSION2 character is 0x01..0x1E. | |
183 | |
184 ----------------------------------------------------------------------- | |
185 charset FIELD1 (5-bit) FIELD2 (7-bit) FIELD3 (7-bit) | |
186 ----------------------------------------------------------------------- | |
187 ASCII 0 0 POSITION-CODE-1 | |
188 DIMENSION1 0 charset - 0x70 POSITION-CODE-1 | |
189 DIMENSION2(o) charset - 0x8F POSITION-CODE-1 POSITION-CODE-2 | |
190 DIMENSION2(p) charset - 0xE0 POSITION-CODE-1 POSITION-CODE-2 | |
191 ----------------------------------------------------------------------- | |
192 "(o)": official, "(p)": private | |
193 ----------------------------------------------------------------------- | |
194 | |
195 */ | |
196 | |
197 /*** GENERAL NOTE on COMPOSITE CHARACTER *** | |
198 | |
199 A composite character is a character composed from several (up to | |
22529 | 200 16) non-composite characters (components). Although each component |
17052 | 201 can belong to any charset, a composite character itself belongs to |
202 the charset `charset-composition' and is assigned a special | |
203 leading-code `LEADING_CODE_COMPOSITION' for multi-byte form. See | |
204 the document "2. Emacs internal format handlers" in `coding.c' for | |
205 more detail about multi-byte form. | |
206 | |
207 A character code of composite character has special format. In the | |
208 above document, FIELD1 of a composite character is 0x1F. Each | |
209 composite character is assigned a sequential number CMPCHAR-ID. | |
210 FIELD2 and FIELD3 are combined to make 14bits field for holding | |
211 CMPCHAR-ID, which means that Emacs can handle at most 2^14 (= 16384) | |
212 composite characters at once. | |
213 | |
214 ----------------------------------------------------------------------- | |
215 charset FIELD1 (5-bit) FIELD2&3 (14-bit) | |
216 ----------------------------------------------------------------------- | |
217 CHARSET-COMPOSITION 0x1F CMPCHAR-ID | |
218 ----------------------------------------------------------------------- | |
219 | |
220 Emacs assigns CMPCHAR-ID to a composite character only when it | |
221 requires the character code of the composite character (e.g. while | |
222 displaying the composite character). | |
223 | |
224 */ | |
225 | |
226 /* Masks of each field of character code. */ | |
227 #define CHAR_FIELD1_MASK (0x1F << 14) | |
228 #define CHAR_FIELD2_MASK (0x7F << 7) | |
229 #define CHAR_FIELD3_MASK 0x7F | |
230 | |
231 /* Macros to access each field of character C. */ | |
232 #define CHAR_FIELD1(c) (((c) & CHAR_FIELD1_MASK) >> 14) | |
233 #define CHAR_FIELD2(c) (((c) & CHAR_FIELD2_MASK) >> 7) | |
234 #define CHAR_FIELD3(c) ((c) & CHAR_FIELD3_MASK) | |
235 | |
236 /* Minimum character code of character of each DIMENSION. */ | |
237 #define MIN_CHAR_OFFICIAL_DIMENSION1 \ | |
238 ((MIN_CHARSET_OFFICIAL_DIMENSION1 - 0x70) << 7) | |
239 #define MIN_CHAR_PRIVATE_DIMENSION1 \ | |
240 ((MIN_CHARSET_PRIVATE_DIMENSION1 - 0x70) << 7) | |
241 #define MIN_CHAR_OFFICIAL_DIMENSION2 \ | |
242 ((MIN_CHARSET_OFFICIAL_DIMENSION2 - 0x8F) << 14) | |
243 #define MIN_CHAR_PRIVATE_DIMENSION2 \ | |
244 ((MIN_CHARSET_PRIVATE_DIMENSION2 - 0xE0) << 14) | |
245 #define MIN_CHAR_COMPOSITION \ | |
246 (0x1F << 14) | |
22702
1e265354a43a
(MAX_CHAR_COMPOSITION): Defined as (GLYPH_MASK_CHAR -
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
247 #define MAX_CHAR_COMPOSITION (GLYPH_MASK_CHAR - 1) |
1e265354a43a
(MAX_CHAR_COMPOSITION): Defined as (GLYPH_MASK_CHAR -
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
248 |
1e265354a43a
(MAX_CHAR_COMPOSITION): Defined as (GLYPH_MASK_CHAR -
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
249 /* A generic character for composition characters. */ |
1e265354a43a
(MAX_CHAR_COMPOSITION): Defined as (GLYPH_MASK_CHAR -
Kenichi Handa <handa@m17n.org>
parents:
22529
diff
changeset
|
250 #define GENERIC_COMPOSITION_CHAR (GLYPH_MASK_CHAR) |
17052 | 251 |
252 /* 1 if C is an ASCII character, else 0. */ | |
23719
5802b0df4800
(SINGLE_BYTE_CHAR_P): Check if C is negative or not.
Kenichi Handa <handa@m17n.org>
parents:
23667
diff
changeset
|
253 #define SINGLE_BYTE_CHAR_P(c) ((c) >= 0 && (c) < 0x100) |
17052 | 254 /* 1 if C is an composite character, else 0. */ |
255 #define COMPOSITE_CHAR_P(c) ((c) >= MIN_CHAR_COMPOSITION) | |
256 | |
20257 | 257 /* 1 if BYTE is a character in itself, in multibyte mode. */ |
258 #define ASCII_BYTE_P(byte) ((byte) < 0x80) | |
259 | |
17052 | 260 /* A char-table containing information of each character set. |
261 | |
262 Unlike ordinary char-tables, this doesn't contain any nested table. | |
263 Only the top level elements are used. Each element is a vector of | |
264 the following information: | |
265 CHARSET-ID, BYTES, DIMENSION, CHARS, WIDTH, DIRECTION, | |
266 LEADING-CODE-BASE, LEADING-CODE-EXT, | |
267 ISO-FINAL-CHAR, ISO-GRAPHIC-PLANE, | |
268 REVERSE-CHARSET, SHORT-NAME, LONG-NAME, DESCRIPTION, | |
269 PLIST. | |
270 | |
271 CHARSET-ID (integer) is the identification number of the charset. | |
272 | |
273 BYTE (integer) is the length of multi-byte form of a character in | |
274 the charset: one of 1, 2, 3, and 4. | |
275 | |
276 DIMENSION (integer) is the number of bytes to represent a character: 1 or 2. | |
277 | |
278 CHARS (integer) is the number of characters in a dimension: 94 or 96. | |
279 | |
280 WIDTH (integer) is the number of columns a character in the charset | |
281 occupies on the screen: one of 0, 1, and 2. | |
282 | |
283 DIRECTION (integer) is the rendering direction of characters in the | |
284 charset when rendering. If 0, render from right to left, else | |
285 render from left to right. | |
286 | |
287 LEADING-CODE-BASE (integer) is the base leading-code for the | |
288 charset. | |
289 | |
290 LEADING-CODE-EXT (integer) is the extended leading-code for the | |
291 charset. All charsets of less than 0xA0 has the value 0. | |
292 | |
293 ISO-FINAL-CHAR (character) is the final character of the | |
294 corresponding ISO 2022 charset. | |
295 | |
296 ISO-GRAPHIC-PLANE (integer) is the graphic plane to be invoked | |
297 while encoding to variants of ISO 2022 coding system, one of the | |
298 following: 0/graphic-plane-left(GL), 1/graphic-plane-right(GR). | |
299 | |
300 REVERSE-CHARSET (integer) is the charset which differs only in | |
301 LEFT-TO-RIGHT value from the charset. If there's no such a | |
302 charset, the value is -1. | |
303 | |
304 SHORT-NAME (string) is the short name to refer to the charset. | |
305 | |
306 LONG-NAME (string) is the long name to refer to the charset. | |
307 | |
308 DESCRIPTION (string) is the description string of the charset. | |
309 | |
310 PLIST (property list) may contain any type of information a user | |
311 want to put and get by functions `put-charset-property' and | |
312 `get-charset-property' respectively. */ | |
313 extern Lisp_Object Vcharset_table; | |
314 | |
315 /* Macros to access various information of CHARSET in Vcharset_table. | |
316 We provide these macros for efficiency. No range check of CHARSET. */ | |
317 | |
318 /* Return entry of CHARSET (lisp integer) in Vcharset_table. */ | |
17321
9f837bea89e3
(CHARSET_TABLE_ENTRY): Handle ASCII charset correctly.
Kenichi Handa <handa@m17n.org>
parents:
17185
diff
changeset
|
319 #define CHARSET_TABLE_ENTRY(charset) \ |
9f837bea89e3
(CHARSET_TABLE_ENTRY): Handle ASCII charset correctly.
Kenichi Handa <handa@m17n.org>
parents:
17185
diff
changeset
|
320 XCHAR_TABLE (Vcharset_table)->contents[((charset) == CHARSET_ASCII \ |
9f837bea89e3
(CHARSET_TABLE_ENTRY): Handle ASCII charset correctly.
Kenichi Handa <handa@m17n.org>
parents:
17185
diff
changeset
|
321 ? 0 : (charset) + 128)] |
17052 | 322 |
323 /* Return information INFO-IDX of CHARSET. */ | |
324 #define CHARSET_TABLE_INFO(charset, info_idx) \ | |
325 XVECTOR (CHARSET_TABLE_ENTRY (charset))->contents[info_idx] | |
326 | |
327 #define CHARSET_ID_IDX (0) | |
328 #define CHARSET_BYTES_IDX (1) | |
329 #define CHARSET_DIMENSION_IDX (2) | |
330 #define CHARSET_CHARS_IDX (3) | |
331 #define CHARSET_WIDTH_IDX (4) | |
332 #define CHARSET_DIRECTION_IDX (5) | |
333 #define CHARSET_LEADING_CODE_BASE_IDX (6) | |
334 #define CHARSET_LEADING_CODE_EXT_IDX (7) | |
335 #define CHARSET_ISO_FINAL_CHAR_IDX (8) | |
336 #define CHARSET_ISO_GRAPHIC_PLANE_IDX (9) | |
337 #define CHARSET_REVERSE_CHARSET_IDX (10) | |
338 #define CHARSET_SHORT_NAME_IDX (11) | |
339 #define CHARSET_LONG_NAME_IDX (12) | |
340 #define CHARSET_DESCRIPTION_IDX (13) | |
341 #define CHARSET_PLIST_IDX (14) | |
342 /* Size of a vector of each entry of Vcharset_table. */ | |
343 #define CHARSET_MAX_IDX (15) | |
344 | |
345 /* And several more macros to be used frequently. */ | |
346 #define CHARSET_BYTES(charset) \ | |
347 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_BYTES_IDX)) | |
348 #define CHARSET_DIMENSION(charset) \ | |
349 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_DIMENSION_IDX)) | |
350 #define CHARSET_CHARS(charset) \ | |
351 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_CHARS_IDX)) | |
352 #define CHARSET_WIDTH(charset) \ | |
353 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_WIDTH_IDX)) | |
354 #define CHARSET_DIRECTION(charset) \ | |
355 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_DIRECTION_IDX)) | |
356 #define CHARSET_LEADING_CODE_BASE(charset) \ | |
357 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_LEADING_CODE_BASE_IDX)) | |
358 #define CHARSET_LEADING_CODE_EXT(charset) \ | |
359 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_LEADING_CODE_EXT_IDX)) | |
360 #define CHARSET_ISO_FINAL_CHAR(charset) \ | |
361 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_ISO_FINAL_CHAR_IDX)) | |
362 #define CHARSET_ISO_GRAPHIC_PLANE(charset) \ | |
363 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_ISO_GRAPHIC_PLANE_IDX)) | |
364 #define CHARSET_REVERSE_CHARSET(charset) \ | |
365 XINT (CHARSET_TABLE_INFO (charset, CHARSET_REVERSE_CHARSET_IDX)) | |
366 | |
367 /* Macros to specify direction of a charset. */ | |
368 #define CHARSET_DIRECTION_LEFT_TO_RIGHT 0 | |
369 #define CHARSET_DIRECTION_RIGHT_TO_LEFT 1 | |
370 | |
371 /* A vector of charset symbol indexed by charset-id. This is used | |
372 only for returning charset symbol from C functions. */ | |
373 extern Lisp_Object Vcharset_symbol_table; | |
374 | |
375 /* Return symbol of CHARSET. */ | |
376 #define CHARSET_SYMBOL(charset) \ | |
377 XVECTOR (Vcharset_symbol_table)->contents[charset] | |
378 | |
379 /* 1 if CHARSET is valid, else 0. */ | |
380 #define CHARSET_VALID_P(charset) \ | |
381 ((charset) == 0 \ | |
382 || ((charset) >= 0x80 && (charset) <= MAX_CHARSET_OFFICIAL_DIMENSION2) \ | |
17185
0d5a1bae9d73
(MAX_CHARSET): Definition changed to the actual
Kenichi Handa <handa@m17n.org>
parents:
17120
diff
changeset
|
383 || ((charset) >= MIN_CHARSET_PRIVATE_DIMENSION1 && (charset) <= MAX_CHARSET)) |
17052 | 384 |
385 /* 1 if CHARSET is already defined, else 0. */ | |
386 #define CHARSET_DEFINED_P(charset) \ | |
17185
0d5a1bae9d73
(MAX_CHARSET): Definition changed to the actual
Kenichi Handa <handa@m17n.org>
parents:
17120
diff
changeset
|
387 (((charset) >= 0) && ((charset) <= MAX_CHARSET) \ |
17052 | 388 && !NILP (CHARSET_TABLE_ENTRY (charset))) |
389 | |
390 /* Since the information CHARSET-BYTES and CHARSET-WIDTH of | |
391 Vcharset_table can be retrieved only from the first byte of | |
392 multi-byte form (an ASCII code or a base leading-code), we provide | |
393 here tables to be used by macros BYTES_BY_CHAR_HEAD and | |
394 WIDTH_BY_CHAR_HEAD for faster information retrieval. */ | |
395 extern int bytes_by_char_head[256]; | |
396 extern int width_by_char_head[256]; | |
397 | |
398 #define BYTES_BY_CHAR_HEAD(char_head) bytes_by_char_head[char_head] | |
399 #define WIDTH_BY_CHAR_HEAD(char_head) width_by_char_head[char_head] | |
400 | |
401 /* Charset of the character C. */ | |
402 #define CHAR_CHARSET(c) \ | |
403 (SINGLE_BYTE_CHAR_P (c) \ | |
404 ? CHARSET_ASCII \ | |
405 : ((c) < MIN_CHAR_OFFICIAL_DIMENSION2 \ | |
406 ? CHAR_FIELD2 (c) + 0x70 \ | |
407 : ((c) < MIN_CHAR_PRIVATE_DIMENSION2 \ | |
408 ? CHAR_FIELD1 (c) + 0x8F \ | |
409 : ((c) < MIN_CHAR_COMPOSITION \ | |
410 ? CHAR_FIELD1 (c) + 0xE0 \ | |
20719 | 411 : ((c) <= MAX_CHAR_COMPOSITION \ |
412 ? CHARSET_COMPOSITION \ | |
413 : CHARSET_ASCII))))) | |
17052 | 414 |
415 /* Return charset at the place pointed by P. */ | |
416 #define CHARSET_AT(p) \ | |
417 (*(p) < 0x80 \ | |
418 ? CHARSET_ASCII \ | |
419 : (*(p) == LEADING_CODE_COMPOSITION \ | |
420 ? CHARSET_COMPOSITION \ | |
421 : (*(p) < LEADING_CODE_PRIVATE_11 \ | |
422 ? (int)*(p) \ | |
423 : (*(p) <= LEADING_CODE_PRIVATE_22 \ | |
424 ? (int)*((p) + 1) \ | |
425 : -1)))) | |
426 | |
427 /* Same as `CHARSET_AT ()' but perhaps runs faster because of an | |
428 additional argument C which is the code (byte) at P. */ | |
429 #define FIRST_CHARSET_AT(p, c) \ | |
430 ((c) < 0x80 \ | |
431 ? CHARSET_ASCII \ | |
432 : ((c) == LEADING_CODE_COMPOSITION \ | |
433 ? CHARSET_COMPOSITION \ | |
434 : ((c) < LEADING_CODE_PRIVATE_11 \ | |
435 ? (int)(c) \ | |
436 : ((c) <= LEADING_CODE_PRIVATE_22 \ | |
437 ? (int)*((p) + 1) \ | |
438 : -1)))) | |
439 | |
440 /* Check if two characters C1 and C2 belong to the same charset. | |
441 Always return 0 for composite characters. */ | |
442 #define SAME_CHARSET_P(c1, c2) \ | |
443 (c1 < MIN_CHAR_COMPOSITION \ | |
444 && (SINGLE_BYTE_CHAR_P (c1) \ | |
445 ? SINGLE_BYTE_CHAR_P (c2) \ | |
446 : (c1 < MIN_CHAR_OFFICIAL_DIMENSION2 \ | |
447 ? (c1 & CHAR_FIELD2_MASK) == (c2 & CHAR_FIELD2_MASK) \ | |
448 : (c1 & CHAR_FIELD1_MASK) == (c2 & CHAR_FIELD1_MASK)))) | |
449 | |
450 /* Return a non-ASCII character of which charset is CHARSET and | |
451 position-codes are C1 and C2. DIMENSION1 character ignores C2. */ | |
23648
06e645781762
(MAKE_NON_ASCII_CHAR): Check validity of CHARSET.
Kenichi Handa <handa@m17n.org>
parents:
23488
diff
changeset
|
452 #define MAKE_NON_ASCII_CHAR(charset, c1, c2) \ |
06e645781762
(MAKE_NON_ASCII_CHAR): Check validity of CHARSET.
Kenichi Handa <handa@m17n.org>
parents:
23488
diff
changeset
|
453 ((charset) == CHARSET_COMPOSITION \ |
06e645781762
(MAKE_NON_ASCII_CHAR): Check validity of CHARSET.
Kenichi Handa <handa@m17n.org>
parents:
23488
diff
changeset
|
454 ? MAKE_COMPOSITE_CHAR (((c1) << 7) + (c2)) \ |
06e645781762
(MAKE_NON_ASCII_CHAR): Check validity of CHARSET.
Kenichi Handa <handa@m17n.org>
parents:
23488
diff
changeset
|
455 : (! CHARSET_DEFINED_P (charset) || CHARSET_DIMENSION (charset) == 1 \ |
06e645781762
(MAKE_NON_ASCII_CHAR): Check validity of CHARSET.
Kenichi Handa <handa@m17n.org>
parents:
23488
diff
changeset
|
456 ? (((charset) - 0x70) << 7) | (c1) \ |
06e645781762
(MAKE_NON_ASCII_CHAR): Check validity of CHARSET.
Kenichi Handa <handa@m17n.org>
parents:
23488
diff
changeset
|
457 : ((charset) < MIN_CHARSET_PRIVATE_DIMENSION2 \ |
06e645781762
(MAKE_NON_ASCII_CHAR): Check validity of CHARSET.
Kenichi Handa <handa@m17n.org>
parents:
23488
diff
changeset
|
458 ? (((charset) - 0x8F) << 14) | ((c1) << 7) | (c2) \ |
17052 | 459 : (((charset) - 0xE0) << 14) | ((c1) << 7) | (c2)))) |
460 | |
461 /* Return a composite character of which CMPCHAR-ID is ID. */ | |
462 #define MAKE_COMPOSITE_CHAR(id) (MIN_CHAR_COMPOSITION + (id)) | |
463 | |
464 /* Return CMPCHAR-ID of a composite character C. */ | |
465 #define COMPOSITE_CHAR_ID(c) ((c) - MIN_CHAR_COMPOSITION) | |
466 | |
467 /* Return a character of which charset is CHARSET and position-codes | |
468 are C1 and C2. DIMENSION1 character ignores C2. */ | |
469 #define MAKE_CHAR(charset, c1, c2) \ | |
470 ((charset) == CHARSET_ASCII \ | |
471 ? (c1) \ | |
472 : MAKE_NON_ASCII_CHAR ((charset), (c1) & 0x7F, (c2) & 0x7F)) | |
473 | |
20151
82ca32c55fa3
(CHAR_VALID_P): Renamed from VALID_CHAR_P, new
Kenichi Handa <handa@m17n.org>
parents:
19643
diff
changeset
|
474 /* If GENERICP is nonzero, return nonzero iff C is a valid normal or |
82ca32c55fa3
(CHAR_VALID_P): Renamed from VALID_CHAR_P, new
Kenichi Handa <handa@m17n.org>
parents:
19643
diff
changeset
|
475 generic character. If GENERICP is zero, return nonzero iff C is a |
82ca32c55fa3
(CHAR_VALID_P): Renamed from VALID_CHAR_P, new
Kenichi Handa <handa@m17n.org>
parents:
19643
diff
changeset
|
476 valid normal character. */ |
82ca32c55fa3
(CHAR_VALID_P): Renamed from VALID_CHAR_P, new
Kenichi Handa <handa@m17n.org>
parents:
19643
diff
changeset
|
477 #define CHAR_VALID_P(c, genericp) \ |
82ca32c55fa3
(CHAR_VALID_P): Renamed from VALID_CHAR_P, new
Kenichi Handa <handa@m17n.org>
parents:
19643
diff
changeset
|
478 ((c) >= 0 \ |
82ca32c55fa3
(CHAR_VALID_P): Renamed from VALID_CHAR_P, new
Kenichi Handa <handa@m17n.org>
parents:
19643
diff
changeset
|
479 && (SINGLE_BYTE_CHAR_P (c) || char_valid_p (c, genericp))) |
17833
59aa4a0772f6
(VALID_CHAR_P): New macro.
Kenichi Handa <handa@m17n.org>
parents:
17726
diff
changeset
|
480 |
22184
003ac1231096
(STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
22167
diff
changeset
|
481 /* This default value is used when nonascii-translation-table or |
21033
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
482 nonascii-insert-offset fail to convert unibyte character to a valid |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
483 multibyte character. This makes a Latin-1 character. */ |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
484 |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
485 #define DEFAULT_NONASCII_INSERT_OFFSET 0x800 |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
486 |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
487 /* Check if the character C is valid as a multibyte character. */ |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
488 |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
489 #define VALID_MULTIBYTE_CHAR_P(c) \ |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
490 ((c) < MIN_CHAR_OFFICIAL_DIMENSION2 \ |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
491 ? (!NILP (XCHAR_TABLE (Vcharset_table)->contents[CHAR_FIELD2 (c) \ |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
492 + 0xF0]) \ |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
493 && CHAR_FIELD3 (c) >= 32) \ |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
494 : ((c) < MIN_CHAR_PRIVATE_DIMENSION2 \ |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
495 ? (!NILP (XCHAR_TABLE (Vcharset_table)->contents[CHAR_FIELD1 (c) \ |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
496 + 0x10F]) \ |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
497 && CHAR_FIELD2 (c) >= 32 && CHAR_FIELD3 (c) >= 32) \ |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
498 : ((c) < MIN_CHAR_COMPOSITION \ |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
499 ? (!NILP (XCHAR_TABLE (Vcharset_table)->contents[CHAR_FIELD1 (c) \ |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
500 + 0x160]) \ |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
501 && CHAR_FIELD2 (c) >= 32 && CHAR_FIELD3 (c) >= 32) \ |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
502 : (c) < MIN_CHAR_COMPOSITION + n_cmpchars))) |
9f32198e0d9f
(NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents:
20932
diff
changeset
|
503 |
19319 | 504 /* The charset of non-ASCII character C is stored in CHARSET, and the |
505 position-codes of C are stored in C1 and C2. | |
506 We store -1 in C2 if the character is just 2 bytes. | |
507 | |
508 Do not use this macro for an ASCII character. */ | |
509 | |
17052 | 510 #define SPLIT_NON_ASCII_CHAR(c, charset, c1, c2) \ |
23653
67907ea2c6ac
(SPLIT_NON_ASCII_CHAR): Check dimension of an invalid
Kenichi Handa <handa@m17n.org>
parents:
23648
diff
changeset
|
511 ((c) & CHAR_FIELD1_MASK \ |
67907ea2c6ac
(SPLIT_NON_ASCII_CHAR): Check dimension of an invalid
Kenichi Handa <handa@m17n.org>
parents:
23648
diff
changeset
|
512 ? (charset = ((c) < MIN_CHAR_COMPOSITION \ |
17052 | 513 ? (CHAR_FIELD1 (c) \ |
514 + ((c) < MIN_CHAR_PRIVATE_DIMENSION2 ? 0x8F : 0xE0)) \ | |
515 : CHARSET_COMPOSITION), \ | |
516 c1 = CHAR_FIELD2 (c), \ | |
23653
67907ea2c6ac
(SPLIT_NON_ASCII_CHAR): Check dimension of an invalid
Kenichi Handa <handa@m17n.org>
parents:
23648
diff
changeset
|
517 c2 = CHAR_FIELD3 (c)) \ |
67907ea2c6ac
(SPLIT_NON_ASCII_CHAR): Check dimension of an invalid
Kenichi Handa <handa@m17n.org>
parents:
23648
diff
changeset
|
518 : (charset = CHAR_FIELD2 (c) + 0x70, \ |
67907ea2c6ac
(SPLIT_NON_ASCII_CHAR): Check dimension of an invalid
Kenichi Handa <handa@m17n.org>
parents:
23648
diff
changeset
|
519 c1 = CHAR_FIELD3 (c), \ |
67907ea2c6ac
(SPLIT_NON_ASCII_CHAR): Check dimension of an invalid
Kenichi Handa <handa@m17n.org>
parents:
23648
diff
changeset
|
520 c2 = -1)) |
17052 | 521 |
19319 | 522 /* The charset of character C is stored in CHARSET, and the |
523 position-codes of C are stored in C1 and C2. | |
524 We store -1 in C2 if the character is just 2 bytes. */ | |
525 | |
17052 | 526 #define SPLIT_CHAR(c, charset, c1, c2) \ |
527 (SINGLE_BYTE_CHAR_P (c) \ | |
17321
9f837bea89e3
(CHARSET_TABLE_ENTRY): Handle ASCII charset correctly.
Kenichi Handa <handa@m17n.org>
parents:
17185
diff
changeset
|
528 ? charset = CHARSET_ASCII, c1 = (c), c2 = -1 \ |
17052 | 529 : SPLIT_NON_ASCII_CHAR (c, charset, c1, c2)) |
530 | |
19319 | 531 /* The charset of the character at STR is stored in CHARSET, and the |
532 position-codes are stored in C1 and C2. | |
533 We store -1 in C2 if the character is just 2 bytes. | |
534 | |
17052 | 535 If the character is a composite character, the upper 7-bit and |
536 lower 7-bit of CMPCHAR-ID are set in C1 and C2 respectively. No | |
537 range checking. */ | |
19319 | 538 |
17052 | 539 #define SPLIT_STRING(str, len, charset, c1, c2) \ |
540 ((BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) < 2 \ | |
541 || BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) > len \ | |
20352
e9b5f67264cc
(SPLIT_STRING): Remove extra argument to
Andreas Schwab <schwab@suse.de>
parents:
20308
diff
changeset
|
542 || split_non_ascii_string (str, len, &charset, &c1, &c2) < 0) \ |
17052 | 543 ? c1 = *(str), charset = CHARSET_ASCII \ |
544 : charset) | |
545 | |
546 /* Mapping table from ISO2022's charset (specified by DIMENSION, | |
547 CHARS, and FINAL_CHAR) to Emacs' charset. Should be accessed by | |
548 macro ISO_CHARSET_TABLE (DIMENSION, CHARS, FINAL_CHAR). */ | |
549 extern int iso_charset_table[2][2][128]; | |
550 | |
551 #define ISO_CHARSET_TABLE(dimension, chars, final_char) \ | |
552 iso_charset_table[XINT (dimension) - 1][XINT (chars) > 94][XINT (final_char)] | |
553 | |
554 #define BASE_LEADING_CODE_P(c) (BYTES_BY_CHAR_HEAD ((unsigned char) (c)) > 1) | |
555 | |
23130 | 556 /* Return how many bytes C will occupy in a multibyte buffer. */ |
23766
5ee484eaf2bb
(CHAR_BYTES): If C has modifier bits, return 1.
Kenichi Handa <handa@m17n.org>
parents:
23719
diff
changeset
|
557 #define CHAR_BYTES(c) \ |
5ee484eaf2bb
(CHAR_BYTES): If C has modifier bits, return 1.
Kenichi Handa <handa@m17n.org>
parents:
23719
diff
changeset
|
558 ((SINGLE_BYTE_CHAR_P ((c)) || ((c) & ~GLYPH_MASK_CHAR)) ? 1 : char_bytes (c)) |
23130 | 559 |
17052 | 560 /* The following two macros CHAR_STRING and STRING_CHAR are the main |
561 entry points to convert between Emacs two types of character | |
562 representations: multi-byte form and single-word form (character | |
563 code). */ | |
564 | |
565 /* Set STR a pointer to the multi-byte form of the character C. If C | |
566 is not a composite character, the multi-byte form is set in WORKBUF | |
567 and STR points WORKBUF. The caller should allocate at least 4-byte | |
568 area at WORKBUF in advance. Returns the length of the multi-byte | |
17833
59aa4a0772f6
(VALID_CHAR_P): New macro.
Kenichi Handa <handa@m17n.org>
parents:
17726
diff
changeset
|
569 form. If C is an invalid character code, signal an error. */ |
17052 | 570 |
571 #define CHAR_STRING(c, workbuf, str) \ | |
572 (SINGLE_BYTE_CHAR_P (c) \ | |
573 ? *(str = workbuf) = (unsigned char)(c), 1 \ | |
21416
384d40966004
(CHAR_STRING): Cast to unsigned char ** explicitly.
Karl Heuer <kwzh@gnu.org>
parents:
21033
diff
changeset
|
574 : non_ascii_char_to_string (c, workbuf, (unsigned char **)&str)) |
17052 | 575 |
576 /* Return a character code of the character of which multi-byte form | |
577 is at STR and the length is LEN. If STR doesn't contain valid | |
578 multi-byte form, only the first byte in STR is returned. */ | |
579 | |
23653
67907ea2c6ac
(SPLIT_NON_ASCII_CHAR): Check dimension of an invalid
Kenichi Handa <handa@m17n.org>
parents:
23648
diff
changeset
|
580 #define STRING_CHAR(str, len) \ |
67907ea2c6ac
(SPLIT_NON_ASCII_CHAR): Check dimension of an invalid
Kenichi Handa <handa@m17n.org>
parents:
23648
diff
changeset
|
581 (BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) == 1 \ |
67907ea2c6ac
(SPLIT_NON_ASCII_CHAR): Check dimension of an invalid
Kenichi Handa <handa@m17n.org>
parents:
23648
diff
changeset
|
582 ? (unsigned char) *(str) \ |
22184
003ac1231096
(STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
22167
diff
changeset
|
583 : string_to_non_ascii_char (str, len, 0, 0)) |
17052 | 584 |
585 /* This is like STRING_CHAR but the third arg ACTUAL_LEN is set to | |
586 the length of the multi-byte form. Just to know the length, use | |
587 MULTIBYTE_FORM_LENGTH. */ | |
588 | |
589 #define STRING_CHAR_AND_LENGTH(str, len, actual_len) \ | |
23202
750deb2c6c0b
(STRING_CHAR_AND_LENGTH): Return correct value in
Kenichi Handa <handa@m17n.org>
parents:
23130
diff
changeset
|
590 (BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) == 1 \ |
17052 | 591 ? (actual_len = 1), (unsigned char) *(str) \ |
22184
003ac1231096
(STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
22167
diff
changeset
|
592 : string_to_non_ascii_char (str, len, &actual_len, 0)) |
003ac1231096
(STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
22167
diff
changeset
|
593 |
003ac1231096
(STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
22167
diff
changeset
|
594 /* This is like STRING_CHAR_AND_LENGTH but the third arg ACTUAL_LEN |
003ac1231096
(STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
22167
diff
changeset
|
595 does not include garbage bytes following the multibyte character. */ |
23202
750deb2c6c0b
(STRING_CHAR_AND_LENGTH): Return correct value in
Kenichi Handa <handa@m17n.org>
parents:
23130
diff
changeset
|
596 #define STRING_CHAR_AND_CHAR_LENGTH(str, len, actual_len) \ |
750deb2c6c0b
(STRING_CHAR_AND_LENGTH): Return correct value in
Kenichi Handa <handa@m17n.org>
parents:
23130
diff
changeset
|
597 (BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) == 1 \ |
22184
003ac1231096
(STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
22167
diff
changeset
|
598 ? (actual_len = 1), (unsigned char) *(str) \ |
003ac1231096
(STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
22167
diff
changeset
|
599 : string_to_non_ascii_char (str, len, &actual_len, 1)) |
17052 | 600 |
20589
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
601 /* Fetch the "next" multibyte character from Lisp string STRING |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
602 at byte position BYTEIDX, character position CHARIDX. |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
603 Store it into OUTPUT. |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
604 |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
605 All the args must be side-effect-free. |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
606 BYTEIDX and CHARIDX must be lvalues; |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
607 we increment them past the character fetched. */ |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
608 |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
609 #define FETCH_STRING_CHAR_ADVANCE(OUTPUT, STRING, CHARIDX, BYTEIDX) \ |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
610 if (1) \ |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
611 { \ |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
612 unsigned char *fetch_string_char_ptr = &XSTRING (STRING)->data[BYTEIDX]; \ |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
613 int fetch_string_char_space_left = XSTRING (STRING)->size_byte - BYTEIDX; \ |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
614 int actual_len; \ |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
615 \ |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
616 OUTPUT \ |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
617 = STRING_CHAR_AND_LENGTH (fetch_string_char_ptr, \ |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
618 fetch_string_char_space_left, actual_len); \ |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
619 \ |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
620 BYTEIDX += actual_len; \ |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
621 CHARIDX++; \ |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
622 } \ |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
623 else |
3acb053e757e
(FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents:
20531
diff
changeset
|
624 |
17052 | 625 /* Return the length of the multi-byte form at string STR of length LEN. */ |
626 | |
21444
0cba6f211d7c
(MULTIBYTE_FORM_LENGTH): Don't check LEN here.
Kenichi Handa <handa@m17n.org>
parents:
21419
diff
changeset
|
627 #define MULTIBYTE_FORM_LENGTH(str, len) \ |
0cba6f211d7c
(MULTIBYTE_FORM_LENGTH): Don't check LEN here.
Kenichi Handa <handa@m17n.org>
parents:
21419
diff
changeset
|
628 (BYTES_BY_CHAR_HEAD (*(unsigned char *)(str)) == 1 \ |
0cba6f211d7c
(MULTIBYTE_FORM_LENGTH): Don't check LEN here.
Kenichi Handa <handa@m17n.org>
parents:
21419
diff
changeset
|
629 ? 1 \ |
17052 | 630 : multibyte_form_length (str, len)) |
631 | |
632 /* Set C a (possibly multibyte) character at P. P points into a | |
633 string which is the virtual concatenation of STR1 (which ends at | |
634 END1) or STR2 (which ends at END2). */ | |
635 | |
636 #define GET_CHAR_AFTER_2(c, p, str1, end1, str2, end2) \ | |
637 do { \ | |
638 const char *dtemp = (p) == (end1) ? (str2) : (p); \ | |
639 const char *dlimit = ((p) >= (str1) && (p) < (end1)) ? (end1) : (end2); \ | |
640 c = STRING_CHAR (dtemp, dlimit - dtemp); \ | |
641 } while (0) | |
642 | |
643 /* Set C a (possibly multibyte) character before P. P points into a | |
644 string which is the virtual concatenation of STR1 (which ends at | |
645 END1) or STR2 (which ends at END2). */ | |
646 | |
647 #define GET_CHAR_BEFORE_2(c, p, str1, end1, str2, end2) \ | |
648 do { \ | |
649 const char *dtemp = (p); \ | |
650 const char *dlimit = ((p) > (str2) && (p) <= (end2)) ? (str2) : (str1); \ | |
651 while (dtemp-- > dlimit && (unsigned char) *dtemp >= 0xA0); \ | |
652 c = STRING_CHAR (dtemp, p - dtemp); \ | |
653 } while (0) | |
654 | |
655 #ifdef emacs | |
656 | |
657 /* Increase the buffer point POS of the current buffer to the next | |
658 character boundary. This macro relies on the fact that *GPT_ADDR | |
659 and *Z_ADDR are always accessible and the values are '\0'. No | |
660 range checking of POS. */ | |
17120
c9c1bc92b8f8
(INC_POS, DEC_POS): Don't increase or decrease too
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
661 #define INC_POS(pos) \ |
c9c1bc92b8f8
(INC_POS, DEC_POS): Don't increase or decrease too
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
662 do { \ |
20531
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
663 unsigned char *p = BYTE_POS_ADDR (pos); \ |
17120
c9c1bc92b8f8
(INC_POS, DEC_POS): Don't increase or decrease too
Kenichi Handa <handa@m17n.org>
parents:
17071
diff
changeset
|
664 pos++; \ |
20932
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
665 if (BASE_LEADING_CODE_P (*p++)) \ |
20531
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
666 while (!CHAR_HEAD_P (*p)) p++, pos++; \ |
17052 | 667 } while (0) |
668 | |
669 /* Decrease the buffer point POS of the current buffer to the previous | |
670 character boundary. No range checking of POS. */ | |
20932
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
671 #define DEC_POS(pos) \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
672 do { \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
673 unsigned char *p, *p_min; \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
674 \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
675 pos--; \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
676 if (pos < GPT_BYTE) \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
677 p = BEG_ADDR + pos - 1, p_min = BEG_ADDR; \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
678 else \ |
17052 | 679 p = BEG_ADDR + GAP_SIZE + pos - 1, p_min = GAP_END_ADDR; \ |
20932
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
680 if (p > p_min && !CHAR_HEAD_P (*p)) \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
681 { \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
682 int pos_saved = pos--; \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
683 p--; \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
684 while (p > p_min && !CHAR_HEAD_P (*p)) p--, pos--; \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
685 if (!BASE_LEADING_CODE_P (*p)) pos = pos_saved; \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
686 } \ |
20531
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
687 } while (0) |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
688 |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
689 /* Increment both CHARPOS and BYTEPOS, each in the appropriate way. */ |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
690 |
20904
79d73f468e38
(INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents:
20759
diff
changeset
|
691 #define INC_BOTH(charpos, bytepos) \ |
79d73f468e38
(INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents:
20759
diff
changeset
|
692 do \ |
79d73f468e38
(INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents:
20759
diff
changeset
|
693 { \ |
79d73f468e38
(INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents:
20759
diff
changeset
|
694 (charpos)++; \ |
79d73f468e38
(INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents:
20759
diff
changeset
|
695 if (NILP (current_buffer->enable_multibyte_characters)) \ |
79d73f468e38
(INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents:
20759
diff
changeset
|
696 (bytepos)++; \ |
79d73f468e38
(INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents:
20759
diff
changeset
|
697 else \ |
79d73f468e38
(INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents:
20759
diff
changeset
|
698 INC_POS ((bytepos)); \ |
79d73f468e38
(INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents:
20759
diff
changeset
|
699 } \ |
20531
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
700 while (0) |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
701 |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
702 /* Decrement both CHARPOS and BYTEPOS, each in the appropriate way. */ |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
703 |
20904
79d73f468e38
(INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents:
20759
diff
changeset
|
704 #define DEC_BOTH(charpos, bytepos) \ |
79d73f468e38
(INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents:
20759
diff
changeset
|
705 do \ |
79d73f468e38
(INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents:
20759
diff
changeset
|
706 { \ |
79d73f468e38
(INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents:
20759
diff
changeset
|
707 (charpos)--; \ |
79d73f468e38
(INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents:
20759
diff
changeset
|
708 if (NILP (current_buffer->enable_multibyte_characters)) \ |
79d73f468e38
(INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents:
20759
diff
changeset
|
709 (bytepos)--; \ |
79d73f468e38
(INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents:
20759
diff
changeset
|
710 else \ |
79d73f468e38
(INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents:
20759
diff
changeset
|
711 DEC_POS ((bytepos)); \ |
79d73f468e38
(INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents:
20759
diff
changeset
|
712 } \ |
20531
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
713 while (0) |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
714 |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
715 /* Increase the buffer point POS of the current buffer to the next |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
716 character boundary. This macro relies on the fact that *GPT_ADDR |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
717 and *Z_ADDR are always accessible and the values are '\0'. No |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
718 range checking of POS. */ |
20932
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
719 #define BUF_INC_POS(buf, pos) \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
720 do { \ |
20531
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
721 unsigned char *p = BUF_BYTE_ADDRESS (buf, pos); \ |
20932
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
722 pos++; \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
723 if (BASE_LEADING_CODE_P (*p++)) \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
724 while (!CHAR_HEAD_P (*p)) p++, pos++; \ |
20531
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
725 } while (0) |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
726 |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
727 /* Decrease the buffer point POS of the current buffer to the previous |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
728 character boundary. No range checking of POS. */ |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
729 #define BUF_DEC_POS(buf, pos) \ |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
730 do { \ |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
731 unsigned char *p, *p_min; \ |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
732 int pos_saved = --pos; \ |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
733 if (pos < BUF_GPT_BYTE (buf)) \ |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
734 { \ |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
735 p = BUF_BEG_ADDR (buf) + pos - 1; \ |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
736 p_min = BUF_BEG_ADDR (buf); \ |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
737 } \ |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
738 else \ |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
739 { \ |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
740 p = BUF_BEG_ADDR (buf) + BUF_GAP_SIZE (buf) + pos - 1; \ |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
741 p_min = BUF_GAP_END_ADDR (buf); \ |
f019e056ad9a
(CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents:
20352
diff
changeset
|
742 } \ |
20932
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
743 if (p > p_min && !CHAR_HEAD_P (*p)) \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
744 { \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
745 int pos_saved = pos--; \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
746 p--; \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
747 while (p > p_min && !CHAR_HEAD_P (*p)) p--, pos--; \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
748 if (!BASE_LEADING_CODE_P (*p)) pos = pos_saved; \ |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
749 } \ |
17052 | 750 } while (0) |
751 | |
752 #endif /* emacs */ | |
753 | |
754 /* Maximum counts of components in one composite character. */ | |
755 #define MAX_COMPONENT_COUNT 16 | |
756 | |
757 /* Structure to hold information of a composite character. */ | |
758 struct cmpchar_info { | |
759 /* Byte length of the composite character. */ | |
760 int len; | |
761 | |
762 /* Multi-byte form of the composite character. */ | |
763 unsigned char *data; | |
764 | |
765 /* Length of glyph codes. */ | |
766 int glyph_len; | |
767 | |
768 /* Width of the overall glyph of the composite character. */ | |
769 int width; | |
770 | |
771 /* Pointer to an array of glyph codes of the composite character. | |
772 This actually contains only character code, no face. */ | |
773 GLYPH *glyph; | |
774 | |
775 /* Pointer to an array of composition rules. The value has the form: | |
776 (0xA0 + ((GLOBAL-REF-POINT << 2) | NEW-REF-POINT)) | |
777 where each XXX-REF-POINT is 0..8. */ | |
778 unsigned char *cmp_rule; | |
779 | |
780 /* Pointer to an array of x-axis offset of left edge of glyphs | |
781 relative to the left of of glyph[0] except for the first element | |
782 which is the absolute offset from the left edge of overall glyph. | |
783 The actual pixel offset should be calculated by multiplying each | |
784 frame's one column width by this value: | |
785 (i.e. FONT_WIDTH (f->output_data.x->font) * col_offset[N]). */ | |
786 float *col_offset; | |
787 | |
788 /* Work slot used by `dumpglyphs' (xterm.c). */ | |
789 int face_work; | |
790 }; | |
791 | |
792 /* Table of pointers to the structure `cmpchar_info' indexed by | |
793 CMPCHAR-ID. */ | |
794 extern struct cmpchar_info **cmpchar_table; | |
795 /* Number of the current composite characters. */ | |
796 extern int n_cmpchars; | |
797 | |
798 /* This is the maximum length of multi-byte form. */ | |
799 #define MAX_LENGTH_OF_MULTI_BYTE_FORM (MAX_COMPONENT_COUNT * 6) | |
800 | |
17185
0d5a1bae9d73
(MAX_CHARSET): Definition changed to the actual
Kenichi Handa <handa@m17n.org>
parents:
17120
diff
changeset
|
801 /* Maximum character code currently used. */ |
0d5a1bae9d73
(MAX_CHARSET): Definition changed to the actual
Kenichi Handa <handa@m17n.org>
parents:
17120
diff
changeset
|
802 #define MAX_CHAR (MIN_CHAR_COMPOSITION + n_cmpchars) |
0d5a1bae9d73
(MAX_CHARSET): Definition changed to the actual
Kenichi Handa <handa@m17n.org>
parents:
17120
diff
changeset
|
803 |
20932
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
804 extern void invalid_character P_ ((int)); |
3c2c8431c51d
(INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents:
20904
diff
changeset
|
805 |
22120
90f77c401689
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
21444
diff
changeset
|
806 extern int translate_char P_ ((Lisp_Object, int, int, int, int)); |
21419
95aae2ff5fcd
(string_to_non_ascii_char, multibyte_form_length)
Karl Heuer <kwzh@gnu.org>
parents:
21416
diff
changeset
|
807 extern int split_non_ascii_string P_ ((const unsigned char *, int, int *, |
20308
8d520e3dcb86
Add more prototypes and function declarations.
Andreas Schwab <schwab@suse.de>
parents:
20257
diff
changeset
|
808 unsigned char *, unsigned char *)); |
22184
003ac1231096
(STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
22167
diff
changeset
|
809 extern int string_to_non_ascii_char P_ ((const unsigned char *, int, int *, |
003ac1231096
(STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
22167
diff
changeset
|
810 int)); |
20308
8d520e3dcb86
Add more prototypes and function declarations.
Andreas Schwab <schwab@suse.de>
parents:
20257
diff
changeset
|
811 extern int non_ascii_char_to_string P_ ((int, unsigned char *, unsigned char **)); |
21419
95aae2ff5fcd
(string_to_non_ascii_char, multibyte_form_length)
Karl Heuer <kwzh@gnu.org>
parents:
21416
diff
changeset
|
812 extern int multibyte_form_length P_ ((const unsigned char *, int)); |
95aae2ff5fcd
(string_to_non_ascii_char, multibyte_form_length)
Karl Heuer <kwzh@gnu.org>
parents:
21416
diff
changeset
|
813 extern int str_cmpchar_id P_ ((const unsigned char *, int)); |
20308
8d520e3dcb86
Add more prototypes and function declarations.
Andreas Schwab <schwab@suse.de>
parents:
20257
diff
changeset
|
814 extern int get_charset_id P_ ((Lisp_Object)); |
23667
0351c9791549
(cmpchar_component): Proto-type adjusted.
Kenichi Handa <handa@m17n.org>
parents:
23653
diff
changeset
|
815 extern int cmpchar_component P_ ((int, int, int)); |
22167
bb7c53dee594
(find_charset_in_str): Number of arguments fixed.
Kenichi Handa <handa@m17n.org>
parents:
22120
diff
changeset
|
816 extern int find_charset_in_str P_ ((unsigned char *, int, int *, |
23882
16d0232006fb
(find_charset_in_str): Update declaration.
Kenichi Handa <handa@m17n.org>
parents:
23810
diff
changeset
|
817 Lisp_Object, int, int)); |
20308
8d520e3dcb86
Add more prototypes and function declarations.
Andreas Schwab <schwab@suse.de>
parents:
20257
diff
changeset
|
818 extern int strwidth P_ ((unsigned char *, int)); |
23130 | 819 extern int char_bytes P_ ((int)); |
23810 | 820 extern int char_valid_p P_ ((int, int)); |
17726 | 821 |
22184
003ac1231096
(STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
22167
diff
changeset
|
822 extern Lisp_Object Vtranslation_table_vector; |
22120
90f77c401689
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
21444
diff
changeset
|
823 |
22184
003ac1231096
(STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
22167
diff
changeset
|
824 /* Return a translation table of id number ID. */ |
22120
90f77c401689
Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents:
21444
diff
changeset
|
825 #define GET_TRANSLATION_TABLE(id) \ |
22184
003ac1231096
(STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents:
22167
diff
changeset
|
826 (XCONS(XVECTOR(Vtranslation_table_vector)->contents[(id)])->cdr) |
20719 | 827 |
23488
958ab288116d
(Vauto_fill_chars): Extern it.
Kenichi Handa <handa@m17n.org>
parents:
23202
diff
changeset
|
828 /* A char-table for characters which may invoke auto-filling. */ |
958ab288116d
(Vauto_fill_chars): Extern it.
Kenichi Handa <handa@m17n.org>
parents:
23202
diff
changeset
|
829 extern Lisp_Object Vauto_fill_chars; |
958ab288116d
(Vauto_fill_chars): Extern it.
Kenichi Handa <handa@m17n.org>
parents:
23202
diff
changeset
|
830 |
20719 | 831 /* Copy LEN bytes from FROM to TO. This macro should be used only |
832 when a caller knows that LEN is short and the obvious copy loop is | |
833 faster than calling bcopy which has some overhead. */ | |
834 | |
835 #define BCOPY_SHORT(from, to, len) \ | |
836 do { \ | |
837 int i = len; \ | |
838 unsigined char *from_p = from, *to_p = to; \ | |
839 while (i--) *from_p++ = *to_p++; \ | |
840 } while (0) | |
841 | |
17052 | 842 #endif /* _CHARSET_H */ |