annotate src/charset.h @ 26749:5bc04426fb75

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