annotate src/charset.h @ 28593:9e0cd0f9571f

Don't define autoconfiscated HAVE_GETLOADAVG.
author Dave Love <fx@gnu.org>
date Fri, 14 Apr 2000 17:52:41 +0000
parents 1fec001e68c5
children 383e4e21306a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
1 /* Header for multibyte 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
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
30 of ISO charsets. Emacs identifies a charset by a unique
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
31 identification number, whereas ISO identifies a charset by a triplet
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
32 of DIMENSION, CHARS and FINAL-CHAR. So, hereafter, just saying
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
33 "charset" means an identification number (integer value).
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
34
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
35 The value range of charset is 0x00, 0x81..0xFE. There are four
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
36 kinds of charset depending on DIMENSION (1 or 2) and CHARS (94 or
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
37 96). For instance, a charset of DIMENSION2_CHARS94 contains 94x94
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
38 characters.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
39
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
40 Within Emacs Lisp, a charset is treated as a symbol which has a
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41 property `charset'. The property value is a vector containing
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42 various information about the charset. For readability of C codes,
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
43 we use the following convention for C variable names:
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44 charset_symbol: Emacs Lisp symbol of a charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 charset_id: Emacs Lisp integer of an identification number of a charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 charset: C integer of an identification number of a charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
47
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
48 Each charset (except for ASCII) is assigned a base leading-code
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
49 (range 0x80..0x9D). In addition, a charset of greater than 0xA0
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
50 (whose base leading-code is 0x9A..0x9D) is assigned an extended
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
51 leading-code (range 0xA0..0xFE). In this case, each base
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
52 leading-code specify the allowable range of extended leading-code as
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
53 shown in the table below. A leading-code is used to represent a
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
54 character in Emacs' buffer and string.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
55
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
56 We call a charset which has extended leading-code as "private
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
57 charset" because those are mainly for a charset which is not yet
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
58 registered by ISO. On the contrary, we call a charset which does
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
59 not have extended leading-code as "official charset".
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
60
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
61 ---------------------------------------------------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
62 charset dimension base leading-code extended leading-code
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
63 ---------------------------------------------------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
64 0x00 official dim1 -- none -- -- none --
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
65 (ASCII)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
66 0x01..0x7F --never used--
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
67 0x80 --never used--
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
68 0x81..0x8F official dim1 same as charset -- none --
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
69 0x90..0x99 official dim2 same as charset -- none --
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
70 0x9A..0x9F --never used--
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
71 0xA0..0xDF private dim1 0x9A same as charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
72 of 1-column width
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
73 0xE0..0xEF private dim1 0x9B same as charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
74 of 2-column width
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
75 0xF0..0xF4 private dim2 0x9C same as charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
76 of 1-column width
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
77 0xF5..0xFE private dim2 0x9D same as charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
78 of 2-column width
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
79 0xFF --never used--
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
80 ---------------------------------------------------------------------------
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
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
84 /* Definition of special leading-codes. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
85 /* Leading-code followed by extended leading-code. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
86 #define LEADING_CODE_PRIVATE_11 0x9A /* for private DIMENSION1 of 1-column */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
87 #define LEADING_CODE_PRIVATE_12 0x9B /* for private DIMENSION1 of 2-column */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
88 #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
89 #define LEADING_CODE_PRIVATE_22 0x9D /* for private DIMENSION2 of 2-column */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
90
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
91 /* Extended leading-code. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
92 /* Start of each extended leading-codes. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
93 #define LEADING_CODE_EXT_11 0xA0 /* follows LEADING_CODE_PRIVATE_11 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
94 #define LEADING_CODE_EXT_12 0xE0 /* follows LEADING_CODE_PRIVATE_12 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
95 #define LEADING_CODE_EXT_21 0xF0 /* follows LEADING_CODE_PRIVATE_21 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
96 #define LEADING_CODE_EXT_22 0xF5 /* follows LEADING_CODE_PRIVATE_22 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
97 /* Maximum value of extended leading-codes. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
98 #define LEADING_CODE_EXT_MAX 0xFE
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
99
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100 /* Definition of minimum/maximum charset of each DIMENSION. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 #define MIN_CHARSET_OFFICIAL_DIMENSION1 0x81
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
102 #define MAX_CHARSET_OFFICIAL_DIMENSION1 0x8F
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
103 #define MIN_CHARSET_OFFICIAL_DIMENSION2 0x90
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
104 #define MAX_CHARSET_OFFICIAL_DIMENSION2 0x99
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
105 #define MIN_CHARSET_PRIVATE_DIMENSION1 LEADING_CODE_EXT_11
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
106 #define MIN_CHARSET_PRIVATE_DIMENSION2 LEADING_CODE_EXT_21
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
107
17185
0d5a1bae9d73 (MAX_CHARSET): Definition changed to the actual
Kenichi Handa <handa@m17n.org>
parents: 17120
diff changeset
108 /* Maximum value of overall charset identification number. */
0d5a1bae9d73 (MAX_CHARSET): Definition changed to the actual
Kenichi Handa <handa@m17n.org>
parents: 17120
diff changeset
109 #define MAX_CHARSET 0xFE
0d5a1bae9d73 (MAX_CHARSET): Definition changed to the actual
Kenichi Handa <handa@m17n.org>
parents: 17120
diff changeset
110
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
111 /* Definition of special charsets. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
112 #define CHARSET_ASCII 0
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
113
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
114 extern int charset_ascii; /* ASCII */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
115 extern int charset_latin_iso8859_1; /* ISO8859-1 (Latin-1) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
116 extern int charset_jisx0208_1978; /* JISX0208.1978 (Japanese Kanji old set) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
117 extern int charset_jisx0208; /* JISX0208.1983 (Japanese Kanji) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
118 extern int charset_katakana_jisx0201; /* JISX0201.Kana (Japanese Katakana) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
119 extern int charset_latin_jisx0201; /* JISX0201.Roman (Japanese Roman) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
120 extern int charset_big5_1; /* Big5 Level 1 (Chinese Traditional) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
121 extern int charset_big5_2; /* Big5 Level 2 (Chinese Traditional) */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
122
20531
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
123 /* 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
124 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
125 #define CHAR_HEAD_P(ch) ((unsigned char) (ch) < 0xA0)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
126
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
127 /*** GENERAL NOTE on CHARACTER REPRESENTATION ***
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
129 At first, the term "character" or "char" is used for a multilingual
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130 character (of course, including ASCII character), not for a byte in
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 computer memory. We use the term "code" or "byte" for the latter
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 case.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
133
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
134 A character is identified by charset and one or two POSITION-CODEs.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
135 POSITION-CODE is the position of the character in the charset. A
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
136 character of DIMENSION1 charset has one POSITION-CODE: POSITION-CODE-1.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
137 A character of DIMENSION2 charset has two POSITION-CODE:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
138 POSITION-CODE-1 and POSITION-CODE-2. The code range of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
139 POSITION-CODE is 0x20..0x7F.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
140
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
141 Emacs has two kinds of representation of a character: multi-byte
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
142 form (for buffer and string) and single-word form (for character
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
143 object in Emacs Lisp). The latter is called "character code" here
22529
d9eac134a41b Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 22184
diff changeset
144 after. Both representations encode the information of charset and
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
145 POSITION-CODE but in a different way (for instance, MSB of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
146 POSITION-CODE is set in multi-byte form).
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
147
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
148 For details of multi-byte form, see the section "2. Emacs internal
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
149 format handlers" of `coding.c'.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
150
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
151 Emacs uses 19 bits for a character code. The bits are divided into
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
152 3 fields: FIELD1(5bits):FIELD2(7bits):FIELD3(7bits).
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
153
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
154 A character code of DIMENSION1 character uses FIELD2 to hold charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
155 and FIELD3 to hold POSITION-CODE-1. A character code of DIMENSION2
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
156 character uses FIELD1 to hold charset, FIELD2 and FIELD3 to hold
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
157 POSITION-CODE-1 and POSITION-CODE-2 respectively.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
158
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
159 More precisely...
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
160
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
161 FIELD2 of DIMENSION1 character (except for ASCII) is "charset - 0x70".
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
162 This is to make all character codes except for ASCII greater than
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163 256 (ASCII's FIELD2 is 0). So, the range of FIELD2 of DIMENSION1
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
164 character is 0 or 0x11..0x7F.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166 FIELD1 of DIMENSION2 character is "charset - 0x8F" for official
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
167 charset and "charset - 0xE0" for private charset. So, the range of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168 FIELD1 of DIMENSION2 character is 0x01..0x1E.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
169
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170 -----------------------------------------------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
171 charset FIELD1 (5-bit) FIELD2 (7-bit) FIELD3 (7-bit)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
172 -----------------------------------------------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
173 ASCII 0 0 POSITION-CODE-1
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
174 DIMENSION1 0 charset - 0x70 POSITION-CODE-1
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
175 DIMENSION2(o) charset - 0x8F POSITION-CODE-1 POSITION-CODE-2
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
176 DIMENSION2(p) charset - 0xE0 POSITION-CODE-1 POSITION-CODE-2
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
177 -----------------------------------------------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
178 "(o)": official, "(p)": private
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
179 -----------------------------------------------------------------------
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
180
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
181 */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
182
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
183 /* Masks of each field of character code. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
184 #define CHAR_FIELD1_MASK (0x1F << 14)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
185 #define CHAR_FIELD2_MASK (0x7F << 7)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
186 #define CHAR_FIELD3_MASK 0x7F
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
187
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
188 /* Macros to access each field of character C. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
189 #define CHAR_FIELD1(c) (((c) & CHAR_FIELD1_MASK) >> 14)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
190 #define CHAR_FIELD2(c) (((c) & CHAR_FIELD2_MASK) >> 7)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
191 #define CHAR_FIELD3(c) ((c) & CHAR_FIELD3_MASK)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
192
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
193 /* Minimum character code of character of each DIMENSION. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
194 #define MIN_CHAR_OFFICIAL_DIMENSION1 \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
195 ((MIN_CHARSET_OFFICIAL_DIMENSION1 - 0x70) << 7)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
196 #define MIN_CHAR_PRIVATE_DIMENSION1 \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
197 ((MIN_CHARSET_PRIVATE_DIMENSION1 - 0x70) << 7)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
198 #define MIN_CHAR_OFFICIAL_DIMENSION2 \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
199 ((MIN_CHARSET_OFFICIAL_DIMENSION2 - 0x8F) << 14)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
200 #define MIN_CHAR_PRIVATE_DIMENSION2 \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
201 ((MIN_CHARSET_PRIVATE_DIMENSION2 - 0xE0) << 14)
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
202 /* Maximum character code currently used plus 1. */
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
203 #define MAX_CHAR (0x1F << 14)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
204
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
205 /* 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
206 #define SINGLE_BYTE_CHAR_P(c) ((c) >= 0 && (c) < 0x100)
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
207
20257
7ba68c0e1bee (ASCII_BYTE_P): New macro.
Karl Heuer <kwzh@gnu.org>
parents: 20151
diff changeset
208 /* 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
209 #define ASCII_BYTE_P(byte) ((byte) < 0x80)
7ba68c0e1bee (ASCII_BYTE_P): New macro.
Karl Heuer <kwzh@gnu.org>
parents: 20151
diff changeset
210
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
211 /* A char-table containing information of each character set.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
212
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
213 Unlike ordinary char-tables, this doesn't contain any nested table.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
214 Only the top level elements are used. Each element is a vector of
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
215 the following information:
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
216 CHARSET-ID, BYTES, DIMENSION, CHARS, WIDTH, DIRECTION,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
217 LEADING-CODE-BASE, LEADING-CODE-EXT,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
218 ISO-FINAL-CHAR, ISO-GRAPHIC-PLANE,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
219 REVERSE-CHARSET, SHORT-NAME, LONG-NAME, DESCRIPTION,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
220 PLIST.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
221
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
222 CHARSET-ID (integer) is the identification number of the charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
223
24779
4a0857b795bd Fix previous change.
Kenichi Handa <handa@m17n.org>
parents: 24777
diff changeset
224 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
225 the charset: one of 1, 2, 3, and 4.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
226
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
227 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
228
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
229 CHARS (integer) is the number of characters in a dimension: 94 or 96.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
230
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
231 WIDTH (integer) is the number of columns a character in the charset
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
232 occupies on the screen: one of 0, 1, and 2.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
233
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
234 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
235 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
236 render from right to left.
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
237
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
238 LEADING-CODE-BASE (integer) is the base leading-code for the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
239 charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
240
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
241 LEADING-CODE-EXT (integer) is the extended leading-code for the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
242 charset. All charsets of less than 0xA0 has the value 0.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
243
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
244 ISO-FINAL-CHAR (character) is the final character of the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
245 corresponding ISO 2022 charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
246
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
247 ISO-GRAPHIC-PLANE (integer) is the graphic plane to be invoked
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
248 while encoding to variants of ISO 2022 coding system, one of the
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
249 following: 0/graphic-plane-left(GL), 1/graphic-plane-right(GR).
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
250
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
251 REVERSE-CHARSET (integer) is the charset which differs only in
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
252 LEFT-TO-RIGHT value from the charset. If there's no such a
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
253 charset, the value is -1.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
254
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
255 SHORT-NAME (string) is the short name to refer to the charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
256
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
257 LONG-NAME (string) is the long name to refer to the charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
258
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
259 DESCRIPTION (string) is the description string of the charset.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
260
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
261 PLIST (property list) may contain any type of information a user
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
262 want to put and get by functions `put-charset-property' and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
263 `get-charset-property' respectively. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
264 extern Lisp_Object Vcharset_table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
265
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
266 /* Macros to access various information of CHARSET in Vcharset_table.
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
267 We provide these macros for efficiency. No range check of CHARSET. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
268
28513
1fec001e68c5 (CHARSET_TABLE_ENTRY): Fix comment -- argument is a C int, not a lisp integer.
Ken Raeburn <raeburn@raeburn.org>
parents: 28473
diff changeset
269 /* Return entry of CHARSET (C integer) in Vcharset_table. */
17321
9f837bea89e3 (CHARSET_TABLE_ENTRY): Handle ASCII charset correctly.
Kenichi Handa <handa@m17n.org>
parents: 17185
diff changeset
270 #define CHARSET_TABLE_ENTRY(charset) \
9f837bea89e3 (CHARSET_TABLE_ENTRY): Handle ASCII charset correctly.
Kenichi Handa <handa@m17n.org>
parents: 17185
diff changeset
271 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
272 ? 0 : (charset) + 128)]
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
273
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
274 /* Return information INFO-IDX of CHARSET. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
275 #define CHARSET_TABLE_INFO(charset, info_idx) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
276 XVECTOR (CHARSET_TABLE_ENTRY (charset))->contents[info_idx]
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
277
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
278 #define CHARSET_ID_IDX (0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
279 #define CHARSET_BYTES_IDX (1)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
280 #define CHARSET_DIMENSION_IDX (2)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
281 #define CHARSET_CHARS_IDX (3)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
282 #define CHARSET_WIDTH_IDX (4)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
283 #define CHARSET_DIRECTION_IDX (5)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
284 #define CHARSET_LEADING_CODE_BASE_IDX (6)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
285 #define CHARSET_LEADING_CODE_EXT_IDX (7)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
286 #define CHARSET_ISO_FINAL_CHAR_IDX (8)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
287 #define CHARSET_ISO_GRAPHIC_PLANE_IDX (9)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
288 #define CHARSET_REVERSE_CHARSET_IDX (10)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
289 #define CHARSET_SHORT_NAME_IDX (11)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
290 #define CHARSET_LONG_NAME_IDX (12)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
291 #define CHARSET_DESCRIPTION_IDX (13)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
292 #define CHARSET_PLIST_IDX (14)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
293 /* Size of a vector of each entry of Vcharset_table. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
294 #define CHARSET_MAX_IDX (15)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
295
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
296 /* And several more macros to be used frequently. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
297 #define CHARSET_BYTES(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
298 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_BYTES_IDX))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
299 #define CHARSET_DIMENSION(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
300 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_DIMENSION_IDX))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
301 #define CHARSET_CHARS(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
302 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_CHARS_IDX))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
303 #define CHARSET_WIDTH(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
304 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_WIDTH_IDX))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
305 #define CHARSET_DIRECTION(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
306 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_DIRECTION_IDX))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
307 #define CHARSET_LEADING_CODE_BASE(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
308 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_LEADING_CODE_BASE_IDX))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
309 #define CHARSET_LEADING_CODE_EXT(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
310 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_LEADING_CODE_EXT_IDX))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
311 #define CHARSET_ISO_FINAL_CHAR(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
312 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_ISO_FINAL_CHAR_IDX))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
313 #define CHARSET_ISO_GRAPHIC_PLANE(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
314 XFASTINT (CHARSET_TABLE_INFO (charset, CHARSET_ISO_GRAPHIC_PLANE_IDX))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
315 #define CHARSET_REVERSE_CHARSET(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
316 XINT (CHARSET_TABLE_INFO (charset, CHARSET_REVERSE_CHARSET_IDX))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
317
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
318 /* Macros to specify direction of a charset. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
319 #define CHARSET_DIRECTION_LEFT_TO_RIGHT 0
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
320 #define CHARSET_DIRECTION_RIGHT_TO_LEFT 1
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
321
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
322 /* A vector of charset symbol indexed by charset-id. This is used
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
323 only for returning charset symbol from C functions. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
324 extern Lisp_Object Vcharset_symbol_table;
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
325
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
326 /* Return symbol of CHARSET. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
327 #define CHARSET_SYMBOL(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
328 XVECTOR (Vcharset_symbol_table)->contents[charset]
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
329
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
330 /* 1 if CHARSET is in valid value range, else 0. */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
331 #define CHARSET_VALID_P(charset) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
332 ((charset) == 0 \
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
333 || ((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
334 || ((charset) >= MIN_CHARSET_PRIVATE_DIMENSION1 && (charset) <= MAX_CHARSET))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
335
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
336 /* 1 if CHARSET is already defined, else 0. */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
337 #define CHARSET_DEFINED_P(charset) \
17185
0d5a1bae9d73 (MAX_CHARSET): Definition changed to the actual
Kenichi Handa <handa@m17n.org>
parents: 17120
diff changeset
338 (((charset) >= 0) && ((charset) <= MAX_CHARSET) \
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
339 && !NILP (CHARSET_TABLE_ENTRY (charset)))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
340
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
341 /* 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
342 Vcharset_table can be retrieved only the first byte of
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
343 multi-byte form (an ASCII code or a base leading-code), we provide
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
344 here tables to be used by macros BYTES_BY_CHAR_HEAD and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
345 WIDTH_BY_CHAR_HEAD for faster information retrieval. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
346 extern int bytes_by_char_head[256];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
347 extern int width_by_char_head[256];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
348
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
349 #define BYTES_BY_CHAR_HEAD(char_head) bytes_by_char_head[char_head]
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
350 #define WIDTH_BY_CHAR_HEAD(char_head) width_by_char_head[char_head]
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
351
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
352 /* Charset of the character C. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
353 #define CHAR_CHARSET(c) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
354 (SINGLE_BYTE_CHAR_P (c) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
355 ? CHARSET_ASCII \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
356 : ((c) < MIN_CHAR_OFFICIAL_DIMENSION2 \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
357 ? CHAR_FIELD2 (c) + 0x70 \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
358 : ((c) < MIN_CHAR_PRIVATE_DIMENSION2 \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
359 ? CHAR_FIELD1 (c) + 0x8F \
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
360 : CHAR_FIELD1 (c) + 0xE0)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
361
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
362 /* Return charset at the place pointed by P. */
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
363 #define CHARSET_AT(p) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
364 (*(p) < 0x80 \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
365 ? CHARSET_ASCII \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
366 : (*(p) < LEADING_CODE_PRIVATE_11 \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
367 ? (int)*(p) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
368 : (*(p) <= LEADING_CODE_PRIVATE_22 \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
369 ? (int)*((p) + 1) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
370 : -1)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
371
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
372 /* Same as `CHARSET_AT ()' but perhaps runs faster because of an
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
373 additional argument C which is the code (byte) at P. */
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
374 #define FIRST_CHARSET_AT(p, c) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
375 ((c) < 0x80 \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
376 ? CHARSET_ASCII \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
377 : ((c) < LEADING_CODE_PRIVATE_11 \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
378 ? (int)(c) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
379 : ((c) <= LEADING_CODE_PRIVATE_22 \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
380 ? (int)*((p) + 1) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
381 : -1)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
382
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
383 /* Check if two characters C1 and C2 belong to the same charset. */
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
384 #define SAME_CHARSET_P(c1, c2) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
385 (SINGLE_BYTE_CHAR_P (c1) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
386 ? SINGLE_BYTE_CHAR_P (c2) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
387 : (c1 < MIN_CHAR_OFFICIAL_DIMENSION2 \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
388 ? (c1 & CHAR_FIELD2_MASK) == (c2 & CHAR_FIELD2_MASK) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
389 : (c1 & CHAR_FIELD1_MASK) == (c2 & CHAR_FIELD1_MASK)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
390
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
391 /* Return a non-ASCII character of which charset is CHARSET and
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
392 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
393 #define MAKE_NON_ASCII_CHAR(charset, c1, c2) \
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
394 (! CHARSET_DEFINED_P (charset) || CHARSET_DIMENSION (charset) == 1 \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
395 ? (((charset) - 0x70) << 7) | ((c1) <= 0 ? 0 : (c1)) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
396 : ((charset) < MIN_CHARSET_PRIVATE_DIMENSION2 \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
397 ? ((((charset) - 0x8F) << 14) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
398 | ((c1) <= 0 ? 0 : ((c1) << 7)) | ((c2) <= 0 ? 0 : (c2))) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
399 : ((((charset) - 0xE0) << 14) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
400 | ((c1) <= 0 ? 0 : ((c1) << 7)) | ((c2) <= 0 ? 0 : (c2)))))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
401
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
402 /* Return a character of which charset is CHARSET and position-codes
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
403 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
404 #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
405 ((charset) == CHARSET_ASCII \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
406 ? (c1) \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
407 : MAKE_NON_ASCII_CHAR ((charset), (c1), (c2)))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
408
20151
82ca32c55fa3 (CHAR_VALID_P): Renamed from VALID_CHAR_P, new
Kenichi Handa <handa@m17n.org>
parents: 19643
diff changeset
409 /* 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
410 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
411 valid normal character. */
82ca32c55fa3 (CHAR_VALID_P): Renamed from VALID_CHAR_P, new
Kenichi Handa <handa@m17n.org>
parents: 19643
diff changeset
412 #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
413 ((c) >= 0 \
82ca32c55fa3 (CHAR_VALID_P): Renamed from VALID_CHAR_P, new
Kenichi Handa <handa@m17n.org>
parents: 19643
diff changeset
414 && (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
415
22184
003ac1231096 (STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 22167
diff changeset
416 /* 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
417 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
418 multibyte character. This makes a Latin-1 character. */
9f32198e0d9f (NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20932
diff changeset
419
9f32198e0d9f (NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20932
diff changeset
420 #define DEFAULT_NONASCII_INSERT_OFFSET 0x800
9f32198e0d9f (NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20932
diff changeset
421
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
422 /* 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
423 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
424 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
425
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
426 #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
427 do { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
428 int i = 1; \
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
429 while (i < (length) && ! CHAR_HEAD_P ((str)[i])) i++; \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
430 if (i == 1) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
431 (bytes) = 1; \
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
432 else \
25583
2c0d3a9d33e8 Lots of comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 25505
diff changeset
433 { \
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
434 (bytes) = BYTES_BY_CHAR_HEAD ((str)[0]); \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
435 if ((bytes) > (length)) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
436 (bytes) = (length); \
25583
2c0d3a9d33e8 Lots of comments fixed.
Kenichi Handa <handa@m17n.org>
parents: 25505
diff changeset
437 } \
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
438 } while (0)
21033
9f32198e0d9f (NONASCII_INSERT_OFFSET): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20932
diff changeset
439
19319
9ea3c87ea61d Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 18341
diff changeset
440 /* 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
441 position-codes of C are stored in C1 and C2.
9ea3c87ea61d Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 18341
diff changeset
442 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
443
9ea3c87ea61d Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 18341
diff changeset
444 Do not use this macro for an ASCII character. */
9ea3c87ea61d Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 18341
diff changeset
445
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
446 #define SPLIT_NON_ASCII_CHAR(c, charset, c1, c2) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
447 ((c) & CHAR_FIELD1_MASK \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
448 ? (charset = (CHAR_FIELD1 (c) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
449 + ((c) < MIN_CHAR_PRIVATE_DIMENSION2 ? 0x8F : 0xE0)), \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
450 c1 = CHAR_FIELD2 (c), \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
451 c2 = CHAR_FIELD3 (c)) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
452 : (charset = CHAR_FIELD2 (c) + 0x70, \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
453 c1 = CHAR_FIELD3 (c), \
23653
67907ea2c6ac (SPLIT_NON_ASCII_CHAR): Check dimension of an invalid
Kenichi Handa <handa@m17n.org>
parents: 23648
diff changeset
454 c2 = -1))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
455
19319
9ea3c87ea61d Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 18341
diff changeset
456 /* The charset of character C is stored in CHARSET, and the
9ea3c87ea61d Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 18341
diff changeset
457 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
458 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
459
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
460 #define SPLIT_CHAR(c, charset, c1, c2) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
461 (SINGLE_BYTE_CHAR_P (c) \
17321
9f837bea89e3 (CHARSET_TABLE_ENTRY): Handle ASCII charset correctly.
Kenichi Handa <handa@m17n.org>
parents: 17185
diff changeset
462 ? charset = CHARSET_ASCII, c1 = (c), c2 = -1 \
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
463 : SPLIT_NON_ASCII_CHAR (c, charset, c1, c2))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
464
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
465 /* Return 1 iff character C has valid printable glyph. */
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
466 #define CHAR_PRINTABLE_P(c) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
467 (SINGLE_BYTE_CHAR_P (c) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
468 || char_printable_p (c))
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
469
19319
9ea3c87ea61d Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 18341
diff changeset
470 /* 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
471 position-codes are stored in C1 and C2.
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
472 We store -1 in C2 if the character is just 2 bytes. */
19319
9ea3c87ea61d Comment changes.
Richard M. Stallman <rms@gnu.org>
parents: 18341
diff changeset
473
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
474 #define SPLIT_STRING(str, len, charset, c1, c2) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
475 ((BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) < 2 \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
476 || BYTES_BY_CHAR_HEAD ((unsigned char) *(str)) > len \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
477 || split_string (str, len, &charset, &c1, &c2) < 0) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
478 ? c1 = *(str), charset = CHARSET_ASCII \
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
479 : charset)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
480
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
481 /* Mapping table from ISO2022's charset (specified by DIMENSION,
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
482 CHARS, and FINAL_CHAR) to Emacs' charset. Should be accessed by
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
483 macro ISO_CHARSET_TABLE (DIMENSION, CHARS, FINAL_CHAR). */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
484 extern int iso_charset_table[2][2][128];
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
485
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
486 #define ISO_CHARSET_TABLE(dimension, chars, final_char) \
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
487 iso_charset_table[XINT (dimension) - 1][XINT (chars) > 94][XINT (final_char)]
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
488
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
489 #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
490
23130
f2cee3bcef78 (CHAR_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents: 22702
diff changeset
491 /* Return how many bytes C will occupy in a multibyte buffer. */
26995
85c7cda1975f (CHAR_BYTES): Use ((1 << CHARACTERBITS) - 1) instead
Kenichi Handa <handa@m17n.org>
parents: 26843
diff changeset
492 #define CHAR_BYTES(c) \
85c7cda1975f (CHAR_BYTES): Use ((1 << CHARACTERBITS) - 1) instead
Kenichi Handa <handa@m17n.org>
parents: 26843
diff changeset
493 ((SINGLE_BYTE_CHAR_P ((c)) || ((c) & ~((1 << CHARACTERBITS) - 1))) \
85c7cda1975f (CHAR_BYTES): Use ((1 << CHARACTERBITS) - 1) instead
Kenichi Handa <handa@m17n.org>
parents: 26843
diff changeset
494 ? 1 : char_bytes (c))
23130
f2cee3bcef78 (CHAR_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents: 22702
diff changeset
495
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
496 /* The following two macros CHAR_STRING and STRING_CHAR are the main
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
497 entry points to convert between Emacs two types of character
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
498 representations: multi-byte form and single-word form (character
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
499 code). */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
500
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
501 /* Store multi-byte form of the character C in STR. The caller should
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
502 allocate at least 4-byte area at STR in advance. Returns the
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
503 length of the multi-byte form. If C is an invalid character code,
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
504 signal an error. */
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
505
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
506 #define CHAR_STRING(c, str) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
507 (SINGLE_BYTE_CHAR_P (c) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
508 ? *(str) = (unsigned char)(c), 1 \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
509 : char_to_string (c, (unsigned char *)str))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
510
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
511 /* Return a character code of the character of which multi-byte form
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
512 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
513 multi-byte form, only the first byte in STR is returned. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
514
23653
67907ea2c6ac (SPLIT_NON_ASCII_CHAR): Check dimension of an invalid
Kenichi Handa <handa@m17n.org>
parents: 23648
diff changeset
515 #define STRING_CHAR(str, len) \
67907ea2c6ac (SPLIT_NON_ASCII_CHAR): Check dimension of an invalid
Kenichi Handa <handa@m17n.org>
parents: 23648
diff changeset
516 (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
517 ? (unsigned char) *(str) \
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
518 : string_to_char (str, len, 0))
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
519
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
520 /* 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
521 length of the multi-byte form. Just to know the length, use
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
522 MULTIBYTE_FORM_LENGTH. */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
523
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
524 #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
525 (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
526 ? ((actual_len) = 1), (unsigned char) *(str) \
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
527 : string_to_char (str, len, &(actual_len)))
22184
003ac1231096 (STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 22167
diff changeset
528
20589
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
529 /* 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
530 at byte position BYTEIDX, character position CHARIDX.
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
531 Store it into OUTPUT.
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
532
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
533 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
534 BYTEIDX and CHARIDX must be lvalues;
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
535 we increment them past the character fetched. */
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
536
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
537 #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
538 if (1) \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
539 { \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
540 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
541 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
542 int actual_len; \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
543 \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
544 OUTPUT \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
545 = 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
546 fetch_string_char_space_left, actual_len); \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
547 \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
548 BYTEIDX += actual_len; \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
549 CHARIDX++; \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
550 } \
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
551 else
3acb053e757e (FETCH_STRING_CHAR_ADVANCE): New macro.
Richard M. Stallman <rms@gnu.org>
parents: 20531
diff changeset
552
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
553 /* Like FETCH_STRING_CHAR_SPACE_LEFT but fetch character from the
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
554 current buffer. */
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
555
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
556 #define FETCH_CHAR_ADVANCE(OUTPUT, CHARIDX, BYTEIDX) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
557 if (1) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
558 { \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
559 unsigned char *fetch_buf_char_ptr = BYTE_POS_ADDR (BYTEIDX); \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
560 int fetch_buf_char_space_left = ((CHARIDX < GPT ? GPT_BYTE : Z_BYTE) \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
561 - BYTEIDX); \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
562 int actual_len; \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
563 \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
564 OUTPUT \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
565 = STRING_CHAR_AND_LENGTH (fetch_buf_char_ptr, \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
566 fetch_buf_char_space_left, actual_len); \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
567 \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
568 BYTEIDX += actual_len; \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
569 CHARIDX++; \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
570 } \
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
571 else
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
572
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
573 /* 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
574
21444
0cba6f211d7c (MULTIBYTE_FORM_LENGTH): Don't check LEN here.
Kenichi Handa <handa@m17n.org>
parents: 21419
diff changeset
575 #define MULTIBYTE_FORM_LENGTH(str, len) \
0cba6f211d7c (MULTIBYTE_FORM_LENGTH): Don't check LEN here.
Kenichi Handa <handa@m17n.org>
parents: 21419
diff changeset
576 (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
577 ? 1 \
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
578 : multibyte_form_length (str, len))
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
579
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
580 #ifdef emacs
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
581
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
582 /* 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
583 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
584 *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
585 '\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
586 #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
587 do { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
588 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
589 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
590 { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
591 int len, bytes; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
592 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
593 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
594 pos_byte += bytes; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
595 } \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
596 else \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
597 pos_byte++; \
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
598 } while (0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
599
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
600 /* 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
601 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
602 #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
603 do { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
604 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
605 \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
606 pos_byte--; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
607 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
608 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
609 else \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
610 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
611 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
612 { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
613 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
614 int len, bytes; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
615 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
616 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
617 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
618 if (bytes == len) \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
619 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
620 } \
20531
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
621 } while (0)
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
622
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
623 /* 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
624
20904
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
625 #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
626 do \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
627 { \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
628 (charpos)++; \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
629 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
630 (bytepos)++; \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
631 else \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
632 INC_POS ((bytepos)); \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
633 } \
20531
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
634 while (0)
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
635
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
636 /* 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
637
20904
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
638 #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
639 do \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
640 { \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
641 (charpos)--; \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
642 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
643 (bytepos)--; \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
644 else \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
645 DEC_POS ((bytepos)); \
79d73f468e38 (INC_BOTH, DEC_BOTH): In unibyte mode, simply increment bytepos.
Richard M. Stallman <rms@gnu.org>
parents: 20759
diff changeset
646 } \
20531
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
647 while (0)
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
648
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
649 /* 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
650 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
651 *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
652 '\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
653 #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
654 do { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
655 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
656 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
657 { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
658 int len, bytes; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
659 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
660 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
661 pos_byte += bytes; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
662 } \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
663 else \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
664 pos_byte++; \
20531
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
665 } while (0)
f019e056ad9a (CHAR_HEAD_P): Take char, not pointer, as arg.
Richard M. Stallman <rms@gnu.org>
parents: 20352
diff changeset
666
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
667 /* 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
668 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
669 #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
670 do { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
671 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
672 pos_byte--; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
673 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
674 { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
675 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
676 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
677 } \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
678 else \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
679 { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
680 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
681 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
682 } \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
683 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
684 { \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
685 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
686 int len, bytes; \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
687 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
688 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
689 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
690 if (bytes == len) \
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
691 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
692 } \
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
693 } while (0)
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
694
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
695 #endif /* emacs */
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
696
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
697 /* This is the maximum byte length of multi-byte sequence. */
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
698 #define MAX_MULTIBYTE_LENGTH 4
17185
0d5a1bae9d73 (MAX_CHARSET): Definition changed to the actual
Kenichi Handa <handa@m17n.org>
parents: 17120
diff changeset
699
20932
3c2c8431c51d (INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents: 20904
diff changeset
700 extern void invalid_character P_ ((int));
3c2c8431c51d (INC_POS): Use macro BASE_LEADING_CODE_P.
Kenichi Handa <handa@m17n.org>
parents: 20904
diff changeset
701
22120
90f77c401689 Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents: 21444
diff changeset
702 extern int translate_char P_ ((Lisp_Object, int, int, int, int));
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
703 extern int split_string P_ ((const unsigned char *, int, int *,
20308
8d520e3dcb86 Add more prototypes and function declarations.
Andreas Schwab <schwab@suse.de>
parents: 20257
diff changeset
704 unsigned char *, unsigned char *));
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
705 extern int char_to_string P_ ((int, unsigned char *));
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
706 extern int string_to_char P_ ((const unsigned char *, int, int *));
25505
4d5f87073d63 (MAKE_NON_ASCII_CHAR): Handle the case that C1 or C2
Kenichi Handa <handa@m17n.org>
parents: 25234
diff changeset
707 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
708 extern int multibyte_form_length P_ ((const unsigned char *, int));
20308
8d520e3dcb86 Add more prototypes and function declarations.
Andreas Schwab <schwab@suse.de>
parents: 20257
diff changeset
709 extern int get_charset_id P_ ((Lisp_Object));
22167
bb7c53dee594 (find_charset_in_str): Number of arguments fixed.
Kenichi Handa <handa@m17n.org>
parents: 22120
diff changeset
710 extern int find_charset_in_str P_ ((unsigned char *, int, int *,
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
711 Lisp_Object, int));
20308
8d520e3dcb86 Add more prototypes and function declarations.
Andreas Schwab <schwab@suse.de>
parents: 20257
diff changeset
712 extern int strwidth P_ ((unsigned char *, int));
23130
f2cee3bcef78 (CHAR_BYTES): New macro.
Kenichi Handa <handa@m17n.org>
parents: 22702
diff changeset
713 extern int char_bytes P_ ((int));
23810
e473bf3419a9 Declare char_valid_p.
Andreas Schwab <schwab@suse.de>
parents: 23766
diff changeset
714 extern int char_valid_p P_ ((int, int));
17726
b5f2a7d6a2d0 (unify_char): Extern it.
Kenichi Handa <handa@m17n.org>
parents: 17321
diff changeset
715
22184
003ac1231096 (STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 22167
diff changeset
716 extern Lisp_Object Vtranslation_table_vector;
22120
90f77c401689 Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents: 21444
diff changeset
717
22184
003ac1231096 (STRING_CHAR_AND_CHAR_LENGTH): New macro.
Kenichi Handa <handa@m17n.org>
parents: 22167
diff changeset
718 /* Return a translation table of id number ID. */
22120
90f77c401689 Change terms unify/unification to
Kenichi Handa <handa@m17n.org>
parents: 21444
diff changeset
719 #define GET_TRANSLATION_TABLE(id) \
25637
2e3ab6dece24 (GET_TRANSLATION_TABLE): Use XCDR.
Ken Raeburn <raeburn@raeburn.org>
parents: 25583
diff changeset
720 (XCDR(XVECTOR(Vtranslation_table_vector)->contents[(id)]))
20719
78d95f2a9d92 (BCOPY_SHORT): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
721
23488
958ab288116d (Vauto_fill_chars): Extern it.
Kenichi Handa <handa@m17n.org>
parents: 23202
diff changeset
722 /* 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
723 extern Lisp_Object Vauto_fill_chars;
958ab288116d (Vauto_fill_chars): Extern it.
Kenichi Handa <handa@m17n.org>
parents: 23202
diff changeset
724
20719
78d95f2a9d92 (BCOPY_SHORT): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
725 /* 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
726 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
727 faster than calling bcopy which has some overhead. */
78d95f2a9d92 (BCOPY_SHORT): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
728
78d95f2a9d92 (BCOPY_SHORT): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
729 #define BCOPY_SHORT(from, to, len) \
78d95f2a9d92 (BCOPY_SHORT): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
730 do { \
78d95f2a9d92 (BCOPY_SHORT): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
731 int i = len; \
25234
17336b4fc693 (BCOPY_SHORT): Fix typo `unsigined'.
Karl Heuer <kwzh@gnu.org>
parents: 25016
diff changeset
732 unsigned char *from_p = from, *to_p = to; \
20719
78d95f2a9d92 (BCOPY_SHORT): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
733 while (i--) *from_p++ = *to_p++; \
78d95f2a9d92 (BCOPY_SHORT): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
734 } while (0)
78d95f2a9d92 (BCOPY_SHORT): New macro.
Kenichi Handa <handa@m17n.org>
parents: 20708
diff changeset
735
25016
15a2436cb80f (CHAR_LEN): Moved here from dispextern.h.
Gerd Moellmann <gerd@gnu.org>
parents: 24779
diff changeset
736 /* Length of C in bytes. */
15a2436cb80f (CHAR_LEN): Moved here from dispextern.h.
Gerd Moellmann <gerd@gnu.org>
parents: 24779
diff changeset
737
26843
0aadeca4a4a7 In this entry, just `Modified' means that codes for a
Kenichi Handa <handa@m17n.org>
parents: 25637
diff changeset
738 #define CHAR_LEN(C) CHARSET_BYTES (CHAR_CHARSET ((C)))
25016
15a2436cb80f (CHAR_LEN): Moved here from dispextern.h.
Gerd Moellmann <gerd@gnu.org>
parents: 24779
diff changeset
739
17052
d0d7b244b1d0 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
740 #endif /* _CHARSET_H */