annotate src/character.h @ 88987:4e77456fab6c

(nonascii_insert_offset, Vnonascii_translation_table): Extern deleted.
author Kenichi Handa <handa@m17n.org>
date Thu, 15 Aug 2002 02:29:16 +0000
parents 233c080b5756
children a9f683a73092
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
1 /* Header for multibyte character handler.
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
2 Copyright (C) 1995, 1997, 1998 Electrotechnical Laboratory, JAPAN.
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
3 Licensed to the Free Software Foundation.
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
4 Copyright (C) 2001, 2002
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
5 National Institute of Advanced Industrial Science and Technology (AIST)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
6 Registration Number H13PRO009
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
7
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
8 This file is part of GNU Emacs.
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
9
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
10 GNU Emacs is free software; you can redistribute it and/or modify
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
11 it under the terms of the GNU General Public License as published by
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
12 the Free Software Foundation; either version 2, or (at your option)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
13 any later version.
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
14
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
15 GNU Emacs is distributed in the hope that it will be useful,
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
18 GNU General Public License for more details.
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
19
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
20 You should have received a copy of the GNU General Public License
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
21 along with GNU Emacs; see the file COPYING. If not, write to
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
23 Boston, MA 02111-1307, USA. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
24
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
25 #ifndef EMACS_CHARACTER_H
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
26 #define EMACS_CHARACTER_H
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
27
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
28 /* character code 1st byte byte sequence
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
29 -------------- -------- -------------
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
30 0-7F 00..7F 0xxxxxxx
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
31 80-7FF C2..DF 110xxxxx 10xxxxxx
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
32 800-FFFF E0..EF 1110xxxx 10xxxxxx 10xxxxxx
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
33 10000-1FFFFF F0..F7 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
34 200000-3FFF7F F8 11111000 1000xxxx 10xxxxxx 10xxxxxx 10xxxxxx
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
35 invalid F9..FF
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
36
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
37 raw-8-bit
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
38 3FFF80-3FFFFF C0..C1 1100000x 10xxxxxx
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
39 */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
40
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
41 /* Maximum character code ((1 << CHARACTERBITS) - 1). */
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
42 #define MAX_CHAR 0x3FFFFF
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
43
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
44 /* Maximum Unicode character code. */
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
45 #define MAX_UNICODE_CHAR 0x10FFFF
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
46
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
47 /* Maximum N-byte character codes. */
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
48 #define MAX_1_BYTE_CHAR 0x7F
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
49 #define MAX_2_BYTE_CHAR 0x7FF
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
50 #define MAX_3_BYTE_CHAR 0xFFFF
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
51 #define MAX_4_BYTE_CHAR 0x1FFFFF
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
52 #define MAX_5_BYTE_CHAR 0x3FFF7F
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
53
88946
233c080b5756 (CHAR_TO_BYTE8): If C is not eight-bit char, call
Kenichi Handa <handa@m17n.org>
parents: 88915
diff changeset
54 /* Nonzero iff C is a character that corresponds to a raw 8-bit
233c080b5756 (CHAR_TO_BYTE8): If C is not eight-bit char, call
Kenichi Handa <handa@m17n.org>
parents: 88915
diff changeset
55 byte. */
233c080b5756 (CHAR_TO_BYTE8): If C is not eight-bit char, call
Kenichi Handa <handa@m17n.org>
parents: 88915
diff changeset
56 #define CHAR_BYTE8_P(c) ((c) > MAX_5_BYTE_CHAR)
233c080b5756 (CHAR_TO_BYTE8): If C is not eight-bit char, call
Kenichi Handa <handa@m17n.org>
parents: 88915
diff changeset
57
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
58 /* Return the character code for raw 8-bit byte BYTE. */
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
59 #define BYTE8_TO_CHAR(byte) ((byte) + 0x3FFF00)
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
60
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
61 /* Return the raw 8-bit byte for character C. */
88946
233c080b5756 (CHAR_TO_BYTE8): If C is not eight-bit char, call
Kenichi Handa <handa@m17n.org>
parents: 88915
diff changeset
62 #define CHAR_TO_BYTE8(c) \
233c080b5756 (CHAR_TO_BYTE8): If C is not eight-bit char, call
Kenichi Handa <handa@m17n.org>
parents: 88915
diff changeset
63 (CHAR_BYTE8_P (c) \
233c080b5756 (CHAR_TO_BYTE8): If C is not eight-bit char, call
Kenichi Handa <handa@m17n.org>
parents: 88915
diff changeset
64 ? (c) - 0x3FFF00 \
233c080b5756 (CHAR_TO_BYTE8): If C is not eight-bit char, call
Kenichi Handa <handa@m17n.org>
parents: 88915
diff changeset
65 : multibyte_char_to_unibyte (c, Qnil))
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
66
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
67 /* Nonzero iff BYTE is the 1st byte of a multibyte form of a character
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
68 that corresponds to a raw 8-bit byte. */
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
69 #define CHAR_BYTE8_HEAD_P(byte) ((byte) == 0xC0 || (byte) == 0xC1)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
70
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
71 /* This is the maximum byte length of multibyte form. */
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
72 #define MAX_MULTIBYTE_LENGTH 5
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
73
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
74 /* Return a Lisp character whose character code is C. */
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
75 #define make_char(c) make_number (c)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
76
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
77 /* Nonzero iff C is an ASCII byte. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
78 #define ASCII_BYTE_P(c) ((unsigned) (c) < 0x80)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
79
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
80 /* Nonzero iff X is a character. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
81 #define CHARACTERP(x) (NATNUMP (x) && XFASTINT (x) <= MAX_CHAR)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
82
88832
1918306a80b1 Comment.
Dave Love <fx@gnu.org>
parents: 88742
diff changeset
83 /* Nonzero iff C is valid as a character code. GENERICP is not used
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
84 now. */
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
85 #define CHAR_VALID_P(c, genericp) ((unsigned) (c) <= MAX_CHAR)
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
86
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
87 /* Check if Lisp object X is a character or not. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
88 #define CHECK_CHARACTER(x) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
89 do { \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
90 if (! CHARACTERP(x)) x = wrong_type_argument (Qcharacterp, (x)); \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
91 } while (0)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
92
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
93 /* Nonzero iff C is an ASCII character. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
94 #define ASCII_CHAR_P(c) ((unsigned) (c) < 0x80)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
95
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
96 /* Nonzero iff C is a character of code less than 0x100. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
97 #define SINGLE_BYTE_CHAR_P(c) ((unsigned) (c) < 0x100)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
98
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
99 /* Nonzero if character C has a printable glyph. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
100 #define CHAR_PRINTABLE_P(c) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
101 (((c) >= 32 && ((c) < 127) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
102 || ! NILP (CHAR_TABLE_REF (Vprintable_chars, (c)))))
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
103
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
104 /* Return byte length of multibyte form for character C. */
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
105 #define CHAR_BYTES(c) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
106 ( (c) <= MAX_1_BYTE_CHAR ? 1 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
107 : (c) <= MAX_2_BYTE_CHAR ? 2 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
108 : (c) <= MAX_3_BYTE_CHAR ? 3 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
109 : (c) <= MAX_4_BYTE_CHAR ? 4 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
110 : (c) <= MAX_5_BYTE_CHAR ? 5 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
111 : 2)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
112
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
113 /* Store multibyte form of the character C in P. The caller should
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
114 allocate at least MAX_MULTIBYTE_LENGTH bytes area at P in advance.
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
115 Returns the length of the multibyte form. */
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
116
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
117 #define CHAR_STRING(c, p) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
118 ((unsigned) (c) <= MAX_1_BYTE_CHAR \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
119 ? ((p)[0] = (c), \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
120 1) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
121 : (unsigned) (c) <= MAX_2_BYTE_CHAR \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
122 ? ((p)[0] = (0xC0 | ((c) >> 6)), \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
123 (p)[1] = (0x80 | ((c) & 0x3F)), \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
124 2) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
125 : (unsigned) (c) <= MAX_3_BYTE_CHAR \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
126 ? ((p)[0] = (0xE0 | ((c) >> 12)), \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
127 (p)[1] = (0x80 | (((c) >> 6) & 0x3F)), \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
128 (p)[2] = (0x80 | ((c) & 0x3F)), \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
129 3) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
130 : (unsigned) (c) <= MAX_5_BYTE_CHAR \
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
131 ? char_string_with_unification (c, p) \
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
132 : ((p)[0] = (0xC0 | (((c) >> 6) & 0x01)), \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
133 (p)[1] = (0x80 | ((c) & 0x3F)), \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
134 2))
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
135
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
136
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
137 /* Store multibyte form of the character C in P. The caller should
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
138 allocate at least MAX_MULTIBYTE_LENGTH bytes area at P in advance.
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
139 And, advance P to the end of the multibyte form. */
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
140
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
141 #define CHAR_STRING_ADVANCE(c, p) \
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
142 do { \
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
143 if ((c) <= MAX_1_BYTE_CHAR) \
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
144 *(p)++ = (c); \
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
145 else if ((c) <= MAX_2_BYTE_CHAR) \
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
146 *(p)++ = (0xC0 | ((c) >> 6)), \
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
147 *(p)++ = (0x80 | ((c) & 0x3F)); \
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
148 else if ((c) <= MAX_3_BYTE_CHAR) \
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
149 *(p)++ = (0xE0 | ((c) >> 12)), \
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
150 *(p)++ = (0x80 | (((c) >> 6) & 0x3F)), \
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
151 *(p)++ = (0x80 | ((c) & 0x3F)); \
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
152 else if ((c) <= MAX_5_BYTE_CHAR) \
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
153 (p) += char_string_with_unification ((c), (p)); \
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
154 else \
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
155 *(p)++ = (0xC0 | (((c) >> 6) & 0x01)), \
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
156 *(p)++ = (0x80 | ((c) & 0x3F)); \
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
157 } while (0)
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
158
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
159 /* Nonzero iff BYTE starts a non-ASCII character in a multibyte
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
160 form. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
161 #define LEADING_CODE_P(byte) (((byte) & 0xC0) == 0xC0)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
162
88873
7d441bc35e9b (TRAILING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 88832
diff changeset
163 /* Nonzero iff BYTE is a trailing code of a non-ASCII character in a
7d441bc35e9b (TRAILING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 88832
diff changeset
164 multibyte form. */
7d441bc35e9b (TRAILING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 88832
diff changeset
165 #define TRAILING_CODE_P(byte) (((byte) & 0xC0) == 0x80)
7d441bc35e9b (TRAILING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 88832
diff changeset
166
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
167 /* Nonzero iff BYTE starts a character in a multibyte form.
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
168 This is equivalent to:
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
169 (ASCII_BYTE_P (byte) || LEADING_CODE_P (byte)) */
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
170 #define CHAR_HEAD_P(byte) (((byte) & 0xC0) != 0x80)
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
171
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
172 /* Just kept for backward compatibility. This macro will be removed
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
173 in the future. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
174 #define BASE_LEADING_CODE_P LEADING_CODE_P
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
175
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
176 /* How many bytes a character that starts with BYTE occupies in a
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
177 multibyte form. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
178 #define BYTES_BY_CHAR_HEAD(byte) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
179 (!((byte) & 0x80) ? 1 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
180 : !((byte) & 0x20) ? 2 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
181 : !((byte) & 0x10) ? 3 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
182 : !((byte) & 0x08) ? 4 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
183 : 5)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
184
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
185
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
186 /* Return the length of the multi-byte form at string STR of length
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
187 LEN while assuming that STR points a valid multi-byte form. As
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
188 this macro isn't necessary anymore, all callers will be changed to
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
189 use BYTES_BY_CHAR_HEAD directly in the future. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
190
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
191 #define MULTIBYTE_FORM_LENGTH(str, len) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
192 BYTES_BY_CHAR_HEAD (*(str))
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
193
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
194 /* Parse multibyte string STR of length LENGTH and set BYTES to the
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
195 byte length of a character at STR while assuming that STR points a
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
196 valid multibyte form. As this macro isn't necessary anymore, all
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
197 callers will be changed to use BYTES_BY_CHAR_HEAD directly in the
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
198 future. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
199
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
200 #define PARSE_MULTIBYTE_SEQ(str, length, bytes) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
201 (bytes) = BYTES_BY_CHAR_HEAD (*(str))
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
202
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
203 /* The byte length of multibyte form at unibyte string P ending at
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
204 PEND. If STR doesn't point a valid multibyte form, return 0. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
205
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
206 #define MULTIBYTE_LENGTH(p, pend) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
207 (p >= pend ? 0 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
208 : !((p)[0] & 0x80) ? 1 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
209 : ((p + 1 >= pend) || (((p)[1] & 0xC0) != 0x80)) ? 0 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
210 : ((p)[0] & 0xE0) == 0xC0 ? 2 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
211 : ((p + 2 >= pend) || (((p)[2] & 0xC0) != 0x80)) ? 0 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
212 : ((p)[0] & 0xF0) == 0xE0 ? 3 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
213 : ((p + 3 >= pend) || (((p)[3] & 0xC0) != 0x80)) ? 0 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
214 : ((p)[0] & 0xF8) == 0xF0 ? 4 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
215 : ((p + 4 >= pend) || (((p)[4] & 0xC0) != 0x80)) ? 0 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
216 : (p)[0] == 0xF8 && ((p)[1] & 0xF0) == 0x80 ? 5 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
217 : 0)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
218
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
219
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
220 /* Like MULTIBYTE_LENGTH but don't check the ending address. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
221
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
222 #define MULTIBYTE_LENGTH_NO_CHECK(p) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
223 (!((p)[0] & 0x80) ? 1 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
224 : ((p)[1] & 0xC0) != 0x80 ? 0 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
225 : ((p)[0] & 0xE0) == 0xC0 ? 2 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
226 : ((p)[2] & 0xC0) != 0x80 ? 0 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
227 : ((p)[0] & 0xF0) == 0xE0 ? 3 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
228 : ((p)[3] & 0xC0) != 0x80 ? 0 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
229 : ((p)[0] & 0xF8) == 0xF0 ? 4 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
230 : ((p)[4] & 0xC0) != 0x80 ? 0 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
231 : (p)[0] == 0xF8 && ((p)[1] & 0xF0) == 0x80 ? 5 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
232 : 0)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
233
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
234
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
235 /* Return the character code of character whose multibyte form is at
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
236 P. The argument LEN is ignored. It will be removed in the
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
237 future. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
238
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
239 #define STRING_CHAR(p, len) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
240 (!((p)[0] & 0x80) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
241 ? (p)[0] \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
242 : ! ((p)[0] & 0x20) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
243 ? (((((p)[0] & 0x1F) << 6) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
244 | ((p)[1] & 0x3F)) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
245 + (((unsigned char) (p)[0]) < 0xC2 ? 0x3FFF80 : 0)) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
246 : ! ((p)[0] & 0x10) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
247 ? ((((p)[0] & 0x0F) << 12) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
248 | (((p)[1] & 0x3F) << 6) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
249 | ((p)[2] & 0x3F)) \
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
250 : string_char_with_unification ((p), NULL, NULL))
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
251
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
252
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
253 /* Like STRING_CHAR but set ACTUAL_LEN to the length of multibyte
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
254 form. The argument LEN is ignored. It will be removed in the
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
255 future. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
256
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
257 #define STRING_CHAR_AND_LENGTH(p, len, actual_len) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
258 (!((p)[0] & 0x80) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
259 ? ((actual_len) = 1, (p)[0]) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
260 : ! ((p)[0] & 0x20) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
261 ? ((actual_len) = 2, \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
262 (((((p)[0] & 0x1F) << 6) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
263 | ((p)[1] & 0x3F)) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
264 + (((unsigned char) (p)[0]) < 0xC2 ? 0x3FFF80 : 0))) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
265 : ! ((p)[0] & 0x10) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
266 ? ((actual_len) = 3, \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
267 ((((p)[0] & 0x0F) << 12) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
268 | (((p)[1] & 0x3F) << 6) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
269 | ((p)[2] & 0x3F))) \
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
270 : string_char_with_unification ((p), NULL, &actual_len))
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
271
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
272
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
273 /* Like STRING_CHAR but advacen P to the end of multibyte form. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
274
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
275 #define STRING_CHAR_ADVANCE(p) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
276 (!((p)[0] & 0x80) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
277 ? *(p)++ \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
278 : ! ((p)[0] & 0x20) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
279 ? ((p) += 2, \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
280 ((((p)[-2] & 0x1F) << 6) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
281 | ((p)[-1] & 0x3F) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
282 | (((unsigned char) (p)[-2]) < 0xC2 ? 0x3FFF80 : 0))) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
283 : ! ((p)[0] & 0x10) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
284 ? ((p) += 3, \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
285 ((((p)[-3] & 0x0F) << 12) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
286 | (((p)[-2] & 0x3F) << 6) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
287 | ((p)[-1] & 0x3F))) \
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
288 : string_char_with_unification ((p), &(p), NULL))
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
289
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
290
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
291 /* Fetch the "next" character from Lisp string STRING at byte position
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
292 BYTEIDX, character position CHARIDX. Store it into OUTPUT.
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
293
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
294 All the args must be side-effect-free.
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
295 BYTEIDX and CHARIDX must be lvalues;
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
296 we increment them past the character fetched. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
297
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
298 #define FETCH_STRING_CHAR_ADVANCE(OUTPUT, STRING, CHARIDX, BYTEIDX) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
299 if (1) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
300 { \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
301 CHARIDX++; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
302 if (STRING_MULTIBYTE (STRING)) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
303 { \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
304 unsigned char *ptr = &XSTRING (STRING)->data[BYTEIDX]; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
305 int len; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
306 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
307 OUTPUT = STRING_CHAR_AND_LENGTH (ptr, 0, len); \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
308 BYTEIDX += len; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
309 } \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
310 else \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
311 OUTPUT = XSTRING (STRING)->data[BYTEIDX++]; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
312 } \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
313 else
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
314
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
315
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
316 /* Like FETCH_STRING_CHAR_ADVANCE but assumes STRING is multibyte. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
317
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
318 #define FETCH_STRING_CHAR_ADVANCE_NO_CHECK(OUTPUT, STRING, CHARIDX, BYTEIDX) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
319 if (1) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
320 { \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
321 unsigned char *ptr = &XSTRING (STRING)->data[BYTEIDX]; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
322 int len; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
323 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
324 OUTPUT = STRING_CHAR_AND_LENGTH (ptr, 0, len); \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
325 BYTEIDX += len; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
326 CHARIDX++; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
327 } \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
328 else
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
329
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
330
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
331 /* Like FETCH_STRING_CHAR_ADVANCE but fetch character from the current
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
332 buffer. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
333
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
334 #define FETCH_CHAR_ADVANCE(OUTPUT, CHARIDX, BYTEIDX) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
335 if (1) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
336 { \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
337 CHARIDX++; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
338 if (!NILP (current_buffer->enable_multibyte_characters)) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
339 { \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
340 unsigned char *ptr = BYTE_POS_ADDR (BYTEIDX); \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
341 int len; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
342 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
343 OUTPUT= STRING_CHAR_AND_LENGTH (ptr, 0, len); \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
344 BYTEIDX += len; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
345 } \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
346 else \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
347 { \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
348 OUTPUT = *(BYTE_POS_ADDR (BYTEIDX)); \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
349 BYTEIDX++; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
350 } \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
351 } \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
352 else
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
353
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
354
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
355 /* Like FETCH_CHAR_ADVANCE but assumes STRING is multibyte. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
356
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
357 #define FETCH_CHAR_ADVANCE_NO_CHECK(OUTPUT, CHARIDX, BYTEIDX) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
358 if (1) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
359 { \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
360 unsigned char *ptr = BYTE_POS_ADDR (BYTEIDX); \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
361 int len; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
362 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
363 OUTPUT= STRING_CHAR_AND_LENGTH (ptr, 0, len); \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
364 BYTEIDX += len; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
365 CHARIDX++; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
366 } \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
367 else
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
368
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
369
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
370 /* Increase the buffer byte position POS_BYTE of the current buffer to
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
371 the next character boundary. No range checking of POS. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
372
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
373 #define INC_POS(pos_byte) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
374 do { \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
375 unsigned char *p = BYTE_POS_ADDR (pos_byte); \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
376 pos_byte += BYTES_BY_CHAR_HEAD (*p); \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
377 } while (0)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
378
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
379
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
380 /* Decrease the buffer byte position POS_BYTE of the current buffer to
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
381 the previous character boundary. No range checking of POS. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
382
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
383 #define DEC_POS(pos_byte) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
384 do { \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
385 unsigned char *p; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
386 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
387 pos_byte--; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
388 if (pos_byte < GPT_BYTE) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
389 p = BEG_ADDR + pos_byte - 1; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
390 else \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
391 p = BEG_ADDR + GAP_SIZE + pos_byte - 1; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
392 while (!CHAR_HEAD_P (*p)) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
393 { \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
394 p--; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
395 pos_byte--; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
396 } \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
397 } while (0)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
398
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
399 /* Increment both CHARPOS and BYTEPOS, each in the appropriate way. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
400
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
401 #define INC_BOTH(charpos, bytepos) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
402 do \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
403 { \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
404 (charpos)++; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
405 if (NILP (current_buffer->enable_multibyte_characters)) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
406 (bytepos)++; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
407 else \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
408 INC_POS ((bytepos)); \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
409 } \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
410 while (0)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
411
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
412
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
413 /* Decrement both CHARPOS and BYTEPOS, each in the appropriate way. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
414
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
415 #define DEC_BOTH(charpos, bytepos) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
416 do \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
417 { \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
418 (charpos)--; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
419 if (NILP (current_buffer->enable_multibyte_characters)) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
420 (bytepos)--; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
421 else \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
422 DEC_POS ((bytepos)); \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
423 } \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
424 while (0)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
425
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
426
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
427 /* Increase the buffer byte position POS_BYTE of the current buffer to
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
428 the next character boundary. This macro relies on the fact that
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
429 *GPT_ADDR and *Z_ADDR are always accessible and the values are
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
430 '\0'. No range checking of POS_BYTE. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
431
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
432 #define BUF_INC_POS(buf, pos_byte) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
433 do { \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
434 unsigned char *p = BUF_BYTE_ADDRESS (buf, pos_byte); \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
435 pos_byte += BYTES_BY_CHAR_HEAD (*p); \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
436 } while (0)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
437
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
438
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
439 /* Decrease the buffer byte position POS_BYTE of the current buffer to
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
440 the previous character boundary. No range checking of POS_BYTE. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
441
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
442 #define BUF_DEC_POS(buf, pos_byte) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
443 do { \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
444 unsigned char *p; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
445 pos_byte--; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
446 if (pos_byte < BUF_GPT_BYTE (buf)) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
447 p = BUF_BEG_ADDR (buf) + pos_byte - 1; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
448 else \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
449 p = BUF_BEG_ADDR (buf) + BUF_GAP_SIZE (buf) + pos_byte - 1; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
450 while (!CHAR_HEAD_P (*p)) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
451 { \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
452 p--; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
453 pos_byte--; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
454 } \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
455 } while (0)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
456
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
457
88742
55e36a0cf0ee (MAYBE_UNIFY_CHAR): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 88545
diff changeset
458 #define MAYBE_UNIFY_CHAR(c) \
55e36a0cf0ee (MAYBE_UNIFY_CHAR): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 88545
diff changeset
459 if (CHAR_TABLE_P (Vchar_unify_table)) \
55e36a0cf0ee (MAYBE_UNIFY_CHAR): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 88545
diff changeset
460 { \
55e36a0cf0ee (MAYBE_UNIFY_CHAR): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 88545
diff changeset
461 Lisp_Object val; \
55e36a0cf0ee (MAYBE_UNIFY_CHAR): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 88545
diff changeset
462 int unified; \
55e36a0cf0ee (MAYBE_UNIFY_CHAR): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 88545
diff changeset
463 \
55e36a0cf0ee (MAYBE_UNIFY_CHAR): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 88545
diff changeset
464 val = CHAR_TABLE_REF (Vchar_unify_table, c); \
55e36a0cf0ee (MAYBE_UNIFY_CHAR): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 88545
diff changeset
465 if (! NILP (val)) \
55e36a0cf0ee (MAYBE_UNIFY_CHAR): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 88545
diff changeset
466 { \
55e36a0cf0ee (MAYBE_UNIFY_CHAR): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 88545
diff changeset
467 if (SYMBOLP (val)) \
55e36a0cf0ee (MAYBE_UNIFY_CHAR): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 88545
diff changeset
468 { \
88873
7d441bc35e9b (TRAILING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 88832
diff changeset
469 Funify_charset (val, Qnil, Qnil); \
88742
55e36a0cf0ee (MAYBE_UNIFY_CHAR): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 88545
diff changeset
470 val = CHAR_TABLE_REF (Vchar_unify_table, c); \
55e36a0cf0ee (MAYBE_UNIFY_CHAR): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 88545
diff changeset
471 } \
55e36a0cf0ee (MAYBE_UNIFY_CHAR): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 88545
diff changeset
472 if ((unified = XINT (val)) >= 0) \
55e36a0cf0ee (MAYBE_UNIFY_CHAR): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 88545
diff changeset
473 c = unified; \
55e36a0cf0ee (MAYBE_UNIFY_CHAR): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 88545
diff changeset
474 } \
55e36a0cf0ee (MAYBE_UNIFY_CHAR): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 88545
diff changeset
475 } \
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
476 else
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
477
88742
55e36a0cf0ee (MAYBE_UNIFY_CHAR): Adjusted for the change of
Kenichi Handa <handa@m17n.org>
parents: 88545
diff changeset
478
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
479 /* Return the width of ASCII character C. The width is measured by
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
480 how many columns occupied on the screen when displayed in the
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
481 current buffer. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
482
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
483 #define ASCII_CHAR_WIDTH(c) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
484 (c < 0x20 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
485 ? (c == '\t' \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
486 ? XFASTINT (current_buffer->tab_width) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
487 : (c == '\n' ? 0 : (NILP (current_buffer->ctl_arrow) ? 4 : 2))) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
488 : (c < 0x7f \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
489 ? 1 \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
490 : ((NILP (current_buffer->ctl_arrow) ? 4 : 2))))
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
491
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
492 /* Return the width of character C. The width is measured by how many
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
493 columns occupied on the screen when displayed in the current
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
494 buffer. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
495
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
496 #define CHAR_WIDTH(c) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
497 (ASCII_CHAR_P (c) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
498 ? ASCII_CHAR_WIDTH (c) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
499 : XINT (CHAR_TABLE_REF (Vchar_width_table, c)))
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
500
88428
5eaa8c11ab45 (CHAR_VALID_P): Don't call CHARACTERP.
Kenichi Handa <handa@m17n.org>
parents: 88363
diff changeset
501 extern int char_string_with_unification P_ ((int, unsigned char *));
88873
7d441bc35e9b (TRAILING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 88832
diff changeset
502 extern int string_char_with_unification P_ ((const unsigned char *,
7d441bc35e9b (TRAILING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 88832
diff changeset
503 const unsigned char **, int *));
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
504
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
505 extern int translate_char P_ ((Lisp_Object, int c));
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
506 extern int char_printable_p P_ ((int c));
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
507 extern void parse_str_as_multibyte P_ ((unsigned char *, int, int *, int *));
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
508 extern int parse_str_to_multibyte P_ ((unsigned char *, int));
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
509 extern int str_as_multibyte P_ ((unsigned char *, int, int, int *));
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
510 extern int str_to_multibyte P_ ((unsigned char *, int, int));
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
511 extern int str_as_unibyte P_ ((unsigned char *, int));
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
512 extern int strwidth P_ ((unsigned char *, int));
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
513 extern int c_string_width P_ ((unsigned char *, int, int, int *, int *));
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
514 extern int lisp_string_width P_ ((Lisp_Object, int, int *, int *));
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
515
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
516 extern Lisp_Object Vprintable_chars;
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
517
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
518 extern Lisp_Object Qcharacterp, Qauto_fill_chars;
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
519 extern Lisp_Object Vtranslation_table_vector;
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
520 extern Lisp_Object Vchar_width_table;
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
521 extern Lisp_Object Vchar_direction_table;
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
522 extern Lisp_Object Vchar_unify_table;
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
523
88545
2f6c9323d466 (string_escape_byte8): Declare.
Dave Love <fx@gnu.org>
parents: 88428
diff changeset
524 extern Lisp_Object string_escape_byte8 P_ ((Lisp_Object));
2f6c9323d466 (string_escape_byte8): Declare.
Dave Love <fx@gnu.org>
parents: 88428
diff changeset
525
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
526 /* Return a translation table of id number ID. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
527 #define GET_TRANSLATION_TABLE(id) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
528 (XCDR(XVECTOR(Vtranslation_table_vector)->contents[(id)]))
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
529
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
530 /* A char-table for characters which may invoke auto-filling. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
531 extern Lisp_Object Vauto_fill_chars;
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
532
88915
94184802d0cc (Vchar_script_table): Extern it.
Kenichi Handa <handa@m17n.org>
parents: 88873
diff changeset
533 extern Lisp_Object Vchar_script_table;
88873
7d441bc35e9b (TRAILING_CODE_P): New macro.
Kenichi Handa <handa@m17n.org>
parents: 88832
diff changeset
534
88363
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
535 /* Copy LEN bytes from FROM to TO. This macro should be used only
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
536 when a caller knows that LEN is short and the obvious copy loop is
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
537 faster than calling bcopy which has some overhead. Copying a
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
538 multibyte sequence of a character is the typical case. */
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
539
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
540 #define BCOPY_SHORT(from, to, len) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
541 do { \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
542 int i = len; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
543 unsigned char *from_p = from, *to_p = to; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
544 while (i--) *to_p++ = *from_p++; \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
545 } while (0)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
546
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
547 #define DEFSYM(sym, name) \
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
548 do { (sym) = intern ((name)); staticpro (&(sym)); } while (0)
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
549
13b9026422e0 New file.
Kenichi Handa <handa@m17n.org>
parents:
diff changeset
550 #endif /* EMACS_CHARACTER_H */